if (filename) {
proto_drv = bdrv_find_protocol(filename, true, &local_err);
if (!proto_drv) {
- qerror_report_err(local_err);
- error_free(local_err);
+ error_report_err(local_err);
qemu_opts_free(create_opts);
return 1;
}
Error *err = NULL;
if (base_filename) {
- qemu_opt_set_err(opts, BLOCK_OPT_BACKING_FILE, base_filename, &err);
+ qemu_opt_set(opts, BLOCK_OPT_BACKING_FILE, base_filename, &err);
if (err) {
error_report("Backing file not supported for file format '%s'",
fmt);
}
}
if (base_fmt) {
- qemu_opt_set_err(opts, BLOCK_OPT_BACKING_FMT, base_fmt, &err);
+ qemu_opt_set(opts, BLOCK_OPT_BACKING_FMT, base_fmt, &err);
if (err) {
error_report("Backing file format not supported for file "
"format '%s'", fmt);
static int compare_sectors(const uint8_t *buf1, const uint8_t *buf2, int n,
int *pnum)
{
- int res, i;
+ bool res;
+ int i;
if (n <= 0) {
*pnum = 0;
proto_drv = bdrv_find_protocol(out_filename, true, &local_err);
if (!proto_drv) {
- qerror_report_err(local_err);
- error_free(local_err);
+ error_report_err(local_err);
ret = -1;
goto out;
}
create_opts = qemu_opts_append(create_opts, proto_drv->create_opts);
opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
- if (options && qemu_opts_do_parse(opts, options, NULL)) {
- error_report("Invalid options for file format '%s'", out_fmt);
- ret = -1;
- goto out;
+ if (options) {
+ qemu_opts_do_parse(opts, options, NULL, &local_err);
+ if (local_err) {
+ error_report_err(local_err);
+ ret = -1;
+ goto out;
+ }
}
qemu_opt_set_number(opts, BLOCK_OPT_SIZE, total_sectors * 512,
if (skip_create) {
int64_t output_sectors = blk_nb_sectors(out_blk);
if (output_sectors < 0) {
- error_report("unable to get output image length: %s\n",
+ error_report("unable to get output image length: %s",
strerror(-output_sectors));
ret = -1;
goto out;
/* Parse size */
param = qemu_opts_create(&resize_options, NULL, 0, &error_abort);
- qemu_opt_set_err(param, BLOCK_OPT_SIZE, size, &err);
+ qemu_opt_set(param, BLOCK_OPT_SIZE, size, &err);
if (err) {
error_report_err(err);
ret = -1;
static int img_amend(int argc, char **argv)
{
+ Error *err = NULL;
int c, ret = 0;
char *options = NULL;
QemuOptsList *create_opts = NULL;
create_opts = qemu_opts_append(create_opts, bs->drv->create_opts);
opts = qemu_opts_create(create_opts, NULL, 0, &error_abort);
- if (options && qemu_opts_do_parse(opts, options, NULL)) {
- error_report("Invalid options for file format '%s'", fmt);
- ret = -1;
- goto out;
+ if (options) {
+ qemu_opts_do_parse(opts, options, NULL, &err);
+ if (err) {
+ error_report_err(err);
+ ret = -1;
+ goto out;
+ }
}
/* In case the driver does not call amend_status_cb() */