[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/4] blockdev: Don't call create_implicit_virtio_dev
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PATCH 2/4] blockdev: Don't call create_implicit_virtio_device() when it has no effect |
Date: |
Thu, 4 Jun 2015 17:20:51 +0100 |
create_implicit_virtio_device() just adds a device to the "device" QEMU
options list. This means that it only has an effect if it is called
before vl.c processes that list to create all the devices. If it is
called after that (ie for hotplug drives created from the monitor) then
it has no effect. To avoid confusion, don't call the code at all if
it isn't going to do anything.
Signed-off-by: Peter Maydell <address@hidden>
---
blockdev.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/blockdev.c b/blockdev.c
index 9cf6123..177b285 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -78,6 +78,11 @@ static int if_max_devs[IF_COUNT] = {
[IF_SCSI] = 7,
};
+/* True once we've created all the command line drives and run
+ * drive_check_orphaned().
+ */
+static bool done_orphan_check;
+
/**
* Boards may call this to offer board-by-board overrides
* of the default, global values.
@@ -239,6 +244,8 @@ bool drive_check_orphaned(void)
DriveInfo *dinfo;
bool rs = false;
+ done_orphan_check = true;
+
for (blk = blk_next(NULL); blk; blk = blk_next(blk)) {
dinfo = blk_legacy_dinfo(blk);
/* If dinfo->bdrv->dev is NULL, it has no device attached. */
@@ -949,7 +956,10 @@ DriveInfo *drive_new(QemuOpts *all_opts,
BlockInterfaceType block_default_type)
goto fail;
}
- if (type == IF_VIRTIO) {
+ if (type == IF_VIRTIO && !done_orphan_check) {
+ /* Drives created via the monitor (hotplugged) do not get the
+ * magic implicit device created for them.
+ */
create_implicit_virtio_device(qdict_get_str(bs_opts, "id"), devaddr);
}
--
1.9.1
- [Qemu-devel] [PATCH 0/4] blockdev: Defer creation of implicit PCI devices for IF_VIRTIO drives, Peter Maydell, 2015/06/04
- [Qemu-devel] [PATCH 4/4] hw/arm/virt: Make block devices default to virtio, Peter Maydell, 2015/06/04
- [Qemu-devel] [PATCH 1/4] blockdev: Factor out create_implicit_virtio_device, Peter Maydell, 2015/06/04
- [Qemu-devel] [PATCH 2/4] blockdev: Don't call create_implicit_virtio_device() when it has no effect,
Peter Maydell <=
- [Qemu-devel] [PATCH 3/4] blockdev: Defer creation of implicit PCI devices for IF_VIRTIO drives, Peter Maydell, 2015/06/04
- Re: [Qemu-devel] [PATCH 0/4] blockdev: Defer creation of implicit PCI devices for IF_VIRTIO drives, Christian Borntraeger, 2015/06/08
- Re: [Qemu-devel] [PATCH 0/4] blockdev: Defer creation of implicit PCI devices for IF_VIRTIO drives, Markus Armbruster, 2015/06/08