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;
- }
- }
-}
-
+/*
+ * Check board claimed all -drive that are meant to be claimed.
+ * Fatal error if any remain unclaimed.
+ */
void drive_check_orphaned(void)
{
BlockBackend *blk;
for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {
dinfo = blk_legacy_dinfo(blk);
- if (dinfo->is_default || dinfo->type == IF_NONE) {
+ /*
+ * Ignore default drives, because we create certain default
+ * drives unconditionally, then leave them unclaimed. Not the
+ * users fault.
+ * Ignore IF_VIRTIO, because it gets desugared into -device,
+ * so we can leave failing to -device.
+ * Ignore IF_NONE, because leaving unclaimed IF_NONE remains
+ * available for device_add is a feature.
+ */
+ if (dinfo->is_default || dinfo->type == IF_VIRTIO
+ || dinfo->type == IF_NONE) {
continue;
}
if (!blk_get_attached_dev(blk)) {
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);
}
}
blk = blk_new(qemu_get_aio_context(), 0, BLK_PERM_ALL);
blk_rs = blk_get_root_state(blk);
- blk_rs->open_flags = bdrv_flags;
- blk_rs->read_only = read_only;
+ blk_rs->open_flags = bdrv_flags | (read_only ? 0 : BDRV_O_RDWR);
blk_rs->detect_zeroes = detect_zeroes;
qobject_unref(bs_opts);
QemuOpts *devopts;
devopts = qemu_opts_create(qemu_find_opts("device"), NULL, 0,
&error_abort);
- if (arch_type == QEMU_ARCH_S390X) {
- qemu_opt_set(devopts, "driver", "virtio-blk-ccw", &error_abort);
- } else {
- qemu_opt_set(devopts, "driver", "virtio-blk-pci", &error_abort);
- }
+ qemu_opt_set(devopts, "driver", "virtio-blk", &error_abort);
qemu_opt_set(devopts, "drive", qdict_get_str(bs_opts, "id"),
&error_abort);
}
goto out;
}
- /* This removes our old bs and adds the new bs. This is an operation that
- * can fail, so we need to do it in .prepare; undoing it for abort is
- * always possible. */
- bdrv_ref(state->new_bs);
ret = bdrv_append(state->new_bs, state->old_bs, errp);
if (ret < 0) {
goto out;
aio_context_acquire(aio_context);
if (set_backing_hd) {
- bdrv_set_backing_hd(target_bs, source, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ if (bdrv_set_backing_hd(target_bs, source, errp) < 0) {
goto unref;
}
}
job_txn_unref(block_job_txn);
}
-void qmp_block_passwd(bool has_device, const char *device,
- bool has_node_name, const char *node_name,
- const char *password, Error **errp)
-{
- error_setg(errp,
- "Setting block passwords directly is no longer supported");
-}
-
BlockDirtyBitmapSha256 *qmp_x_debug_block_dirty_bitmap_sha256(const char *node,
const char *name,
Error **errp)