return NULL;
}
+void drive_mark_claimed_by_board(void)
+{
+ BlockBackend *blk;
+ DriveInfo *dinfo;
+
+ for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {
+ dinfo = blk_legacy_dinfo(blk);
+ if (dinfo && blk_get_attached_dev(blk)) {
+ dinfo->claimed_by_board = true;
+ }
+ }
+}
+
void drive_check_orphaned(void)
{
BlockBackend *blk;
for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {
dinfo = blk_legacy_dinfo(blk);
- if (!blk_get_attached_dev(blk) && !dinfo->is_default &&
- dinfo->type != IF_NONE) {
+ if (dinfo->is_default || dinfo->type == IF_NONE) {
+ continue;
+ }
+ if (!blk_get_attached_dev(blk)) {
loc_push_none(&loc);
qemu_opts_loc_restore(dinfo->opts);
error_report("machine type does not support"
if_name[dinfo->type], dinfo->bus, dinfo->unit);
loc_pop(&loc);
orphans = true;
+ continue;
+ }
+ if (!dinfo->claimed_by_board && dinfo->type != IF_VIRTIO) {
+ loc_push_none(&loc);
+ qemu_opts_loc_restore(dinfo->opts);
+ warn_report("bogus if=%s is deprecated, use if=none",
+ if_name[dinfo->type]);
+ loc_pop(&loc);
}
}
/* Check common options by copying from bs_opts to opts, all other options
* stay in bs_opts for processing by bdrv_open(). */
id = qdict_get_try_str(bs_opts, "id");
- opts = qemu_opts_create(&qemu_common_drive_opts, id, 1, &error);
- if (error) {
- error_propagate(errp, error);
+ opts = qemu_opts_create(&qemu_common_drive_opts, id, 1, errp);
+ if (!opts) {
goto err_no_opts;
}
- qemu_opts_absorb_qdict(opts, bs_opts, &error);
- if (error) {
- error_propagate(errp, error);
+ if (!qemu_opts_absorb_qdict(opts, bs_opts, errp)) {
goto early_err;
}
: QTAILQ_FIRST(&monitor_bdrv_states);
}
-static void qemu_opt_rename(QemuOpts *opts, const char *from, const char *to,
+static bool qemu_opt_rename(QemuOpts *opts, const char *from, const char *to,
Error **errp)
{
const char *value;
if (qemu_opt_find(opts, to)) {
error_setg(errp, "'%s' and its alias '%s' can't be used at the "
"same time", to, from);
- return;
+ return false;
}
}
qemu_opt_set(opts, to, value, &error_abort);
qemu_opt_unset(opts, from);
}
+ return true;
}
QemuOptsList qemu_legacy_drive_opts = {
bool read_only = false;
bool copy_on_read;
const char *filename;
- Error *local_err = NULL;
int i;
/* Change legacy command line options into QMP ones */
};
for (i = 0; i < ARRAY_SIZE(opt_renames); i++) {
- qemu_opt_rename(all_opts, opt_renames[i].from, opt_renames[i].to,
- &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opt_rename(all_opts, opt_renames[i].from,
+ opt_renames[i].to, errp)) {
return NULL;
}
}
legacy_opts = qemu_opts_create(&qemu_legacy_drive_opts, NULL, 0,
&error_abort);
- qemu_opts_absorb_qdict(legacy_opts, bs_opts, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (!qemu_opts_absorb_qdict(legacy_opts, bs_opts, errp)) {
goto fail;
}
}
/* Actual block device init: Functionality shared with blockdev-add */
- blk = blockdev_init(filename, bs_opts, &local_err);
+ blk = blockdev_init(filename, bs_opts, errp);
bs_opts = NULL;
if (!blk) {
- error_propagate(errp, local_err);
goto fail;
- } else {
- assert(!local_err);
}
/* Create legacy DriveInfo */
arg->has_copy_mode, arg->copy_mode,
arg->has_auto_finalize, arg->auto_finalize,
arg->has_auto_dismiss, arg->auto_dismiss,
- &local_err);
+ errp);
bdrv_unref(target_bs);
- error_propagate(errp, local_err);
out:
aio_context_release(aio_context);
}
AioContext *aio_context;
AioContext *old_context;
BlockMirrorBackingMode backing_mode = MIRROR_LEAVE_BACKING_CHAIN;
- Error *local_err = NULL;
bool zero_target;
int ret;
has_copy_mode, copy_mode,
has_auto_finalize, auto_finalize,
has_auto_dismiss, auto_dismiss,
- &local_err);
- error_propagate(errp, local_err);
+ errp);
out:
aio_context_release(aio_context);
}
}
ret = bdrv_change_backing_file(image_bs, backing_file,
- image_bs->drv ? image_bs->drv->format_name : "");
+ image_bs->drv ? image_bs->drv->format_name : "",
+ false);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not change backing file to '%s'",
}
if (ro) {
- bdrv_reopen_set_read_only(image_bs, true, &local_err);
- error_propagate(errp, local_err);
+ bdrv_reopen_set_read_only(image_bs, true, errp);
}
out: