[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 16/24] qdev hotplug: infrastructure and monitor
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH 16/24] qdev hotplug: infrastructure and monitor commands. |
Date: |
Mon, 28 Sep 2009 22:32:19 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux) |
Gerd Hoffmann <address@hidden> writes:
> From: Gerd Hoffmann <address@hidden>
> Subject: [Qemu-devel] [PATCH 16/24] qdev hotplug: infrastructure and monitor
> commands.
> To: address@hidden
> Cc: Gerd Hoffmann <address@hidden>
> Date: Fri, 25 Sep 2009 21:42:41 +0200
>
> Adds device_add and device_del commands. device_add accepts accepts
> the same syntax like the -device command line switch. device_del
> expects a device id. So you should tag your devices with ids if you
> want to remove them later on, like this:
>
> device_add pci-ohci,id=ohci
> device_del ohci
>
> Unplugging via pci_del or usb_del works too.
>
> Signed-off-by: Gerd Hoffmann <address@hidden>
> ---
> hw/qdev.c | 79
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++
> hw/qdev.h | 12 +++++++-
> qemu-monitor.hx | 16 +++++++++++
> vl.c | 2 +
> 4 files changed, 107 insertions(+), 2 deletions(-)
>
> diff --git a/hw/qdev.c b/hw/qdev.c
> index a25245a..00cb849 100644
> --- a/hw/qdev.c
> +++ b/hw/qdev.c
> @@ -31,6 +31,8 @@
> #include "monitor.h"
>
> /* This is a nasty hack to allow passing a NULL bus to qdev_create. */
> +static int qdev_hotplug = 0;
> +
I see the "nasty hack" part, but I don't see how qdev_create() accepts a
null bus now:
> static BusState *main_system_bus;
>
> static DeviceInfo *device_info_list;
> @@ -102,6 +104,10 @@ DeviceState *qdev_create(BusState *bus, const char *name)
> qdev_prop_set_defaults(dev, dev->parent_bus->info->props);
> qdev_prop_set_compat(dev);
> QLIST_INSERT_HEAD(&bus->children, dev, sibling);
It still derefences bus.
> + if (qdev_hotplug) {
> + assert(bus->allow_hotplug);
> + dev->hotplugged = 1;
> + }
> dev->state = DEV_STATE_CREATED;
> return dev;
> }
> @@ -192,6 +198,11 @@ DeviceState *qdev_device_add(QemuOpts *opts)
> path ? path : info->bus_info->name, info->name);
> return NULL;
> }
> + if (qdev_hotplug && !bus->allow_hotplug) {
> + qemu_error("Bus %s does not support hotplugging\n",
> + bus->name);
> + return NULL;
> + }
>
> /* create device, set properties */
> qdev = qdev_create(bus, driver);
[...]
As far as I can see, all qdev_hotplug does is telling qdev_device_add()
and qdev_create() that this is a hotplug.
What about something like:
DeviceState *qdev_device_add(QemuOpts *opts, int hotplug)
{
[...]
if (hotplug && !bus->allow_hotplug) {
qemu_error("Bus %s does not support hotplugging\n",
bus->name);
return NULL;
}
/* create device, set properties */
qdev = qdev_create(bus, driver);
if (hotplug) {
dev->hotplugged = 1;
[...]
}
- [Qemu-devel] [PATCH 23/24] allow if=none for drive_add, (continued)
- [Qemu-devel] [PATCH 23/24] allow if=none for drive_add, Gerd Hoffmann, 2009/09/25
- [Qemu-devel] [PATCH 19/24] pci: hotplug windup, Gerd Hoffmann, 2009/09/25
- [Qemu-devel] [PATCH 15/24] switch qemu-config to qemu_error, Gerd Hoffmann, 2009/09/25
- [Qemu-devel] [PATCH 21/24] drive cleanup fixes., Gerd Hoffmann, 2009/09/25
- [Qemu-devel] [PATCH 18/24] scsi: hotplug windup, Gerd Hoffmann, 2009/09/25
- [Qemu-devel] [PATCH 22/24] refactor drive_hot_add, Gerd Hoffmann, 2009/09/25
- [Qemu-devel] [PATCH 24/24] store a pointer to QemuOpts in DeviceState, release it when zapping a device., Gerd Hoffmann, 2009/09/25
- [Qemu-devel] [PATCH 16/24] qdev hotplug: infrastructure and monitor commands., Gerd Hoffmann, 2009/09/25
- Re: [Qemu-devel] [PATCH 16/24] qdev hotplug: infrastructure and monitor commands.,
Markus Armbruster <=
[Qemu-devel] [PATCH 20/24] pci: windup acpi-based hotplug, Gerd Hoffmann, 2009/09/25
Re: [Qemu-devel] [PATCH 00/24] qdev: bus management updates., Anthony Liguori, 2009/09/25
Re: [Qemu-devel] [PATCH 00/24] qdev: bus management updates., Markus Armbruster, 2009/09/28