Message ID | 1409126919-22233-5-git-send-email-tangchen@cn.fujitsu.com |
---|---|
State | New |
Headers | show |
On Wed, 27 Aug 2014 16:08:35 +0800 Tang Chen <tangchen@cn.fujitsu.com> wrote: > From: Hu Tao <hutao@cn.fujitsu.com> > > Implement bus-less device hot-remove in qdev_unplug(). It will call PCMachine > callback introduced in previous patch. > subject/commit message doesn't need to mention memory hotplug/PCMachine, it's generic handling that applies to other devices even though pc-dimm is the only bus-less device handled here. > Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> > Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com> > --- > hw/core/qdev.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/hw/core/qdev.c b/hw/core/qdev.c > index da1ba48..e365a74 100644 > --- a/hw/core/qdev.c > +++ b/hw/core/qdev.c > @@ -228,6 +228,14 @@ void qdev_unplug(DeviceState *dev, Error **errp) > > if (dev->parent_bus && dev->parent_bus->hotplug_handler) { > hotplug_handler_unplug(dev->parent_bus->hotplug_handler, dev, errp); > + } else if (*errp == NULL) { what's the reason for ^^^ condition here? > + HotplugHandler *hotplug_ctrl; > + MachineState *machine = MACHINE(qdev_get_machine()); > + MachineClass *mc = MACHINE_GET_CLASS(machine); > + > + hotplug_ctrl = mc->get_hotplug_handler(machine, dev); > + if (hotplug_ctrl) > + hotplug_handler_unplug(hotplug_ctrl, dev, errp); > } else { > assert(dc->unplug != NULL); > if (dc->unplug(dev) < 0) { /* legacy handler */
Hi Igor, On 09/04/2014 09:22 PM, Igor Mammedov wrote: > On Wed, 27 Aug 2014 16:08:35 +0800 > Tang Chen <tangchen@cn.fujitsu.com> wrote: > >> From: Hu Tao <hutao@cn.fujitsu.com> >> >> Implement bus-less device hot-remove in qdev_unplug(). It will call PCMachine >> callback introduced in previous patch. >> > subject/commit message doesn't need to mention memory hotplug/PCMachine, > it's generic handling that applies to other devices even though > pc-dimm is the only bus-less device handled here. Followed. > >> Signed-off-by: Hu Tao <hutao@cn.fujitsu.com> >> Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com> >> --- >> hw/core/qdev.c | 8 ++++++++ >> 1 file changed, 8 insertions(+) >> >> diff --git a/hw/core/qdev.c b/hw/core/qdev.c >> index da1ba48..e365a74 100644 >> --- a/hw/core/qdev.c >> +++ b/hw/core/qdev.c >> @@ -228,6 +228,14 @@ void qdev_unplug(DeviceState *dev, Error **errp) >> >> if (dev->parent_bus && dev->parent_bus->hotplug_handler) { >> hotplug_handler_unplug(dev->parent_bus->hotplug_handler, dev, errp); >> + } else if (*errp == NULL) { > what's the reason for ^^^ condition here? It should be "else if (object_dynamic_cast(qdev_get_machine(), TYPE_MACHINE)) " Just like we do in device_set_realized(). Thanks. >> + HotplugHandler *hotplug_ctrl; >> + MachineState *machine = MACHINE(qdev_get_machine()); >> + MachineClass *mc = MACHINE_GET_CLASS(machine); >> + >> + hotplug_ctrl = mc->get_hotplug_handler(machine, dev); >> + if (hotplug_ctrl) >> + hotplug_handler_unplug(hotplug_ctrl, dev, errp); >> } else { >> assert(dc->unplug != NULL); >> if (dc->unplug(dev) < 0) { /* legacy handler */ > > . >
diff --git a/hw/core/qdev.c b/hw/core/qdev.c index da1ba48..e365a74 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -228,6 +228,14 @@ void qdev_unplug(DeviceState *dev, Error **errp) if (dev->parent_bus && dev->parent_bus->hotplug_handler) { hotplug_handler_unplug(dev->parent_bus->hotplug_handler, dev, errp); + } else if (*errp == NULL) { + HotplugHandler *hotplug_ctrl; + MachineState *machine = MACHINE(qdev_get_machine()); + MachineClass *mc = MACHINE_GET_CLASS(machine); + + hotplug_ctrl = mc->get_hotplug_handler(machine, dev); + if (hotplug_ctrl) + hotplug_handler_unplug(hotplug_ctrl, dev, errp); } else { assert(dc->unplug != NULL); if (dc->unplug(dev) < 0) { /* legacy handler */