On Mon, 12 Oct 2015 11:00:13 +0200 Greg Kurz <gk...@linux.vnet.ibm.com> wrote:
> This handler allows to ask a device instance if it can be hot-unplugged. It > is to be defined in device classes where hot-unpluggability depends on the > device state (for example, virtio-9p devices cannot be unplugged if the 9p > share is mounted in the guest). > > Signed-off-by: Greg Kurz <gk...@linux.vnet.ibm.com> > --- > hw/core/qdev.c | 4 ++++ > include/hw/qdev-core.h | 4 ++++ > 2 files changed, 8 insertions(+) > > diff --git a/hw/core/qdev.c b/hw/core/qdev.c > index 4ab04aa31e78..2b2339c7c6ad 100644 > --- a/hw/core/qdev.c > +++ b/hw/core/qdev.c > @@ -287,6 +287,10 @@ void qdev_unplug(DeviceState *dev, Error **errp) > return; > } > > + if (dc->unpluggable && !dc->unpluggable(dev, errp)) { I think I'd prefer something like "unplug_is_blocked" or so. Makes it more obvious that this is something that is rather the exception. > + return; > + } > + > qdev_hot_removed = true; > > hotplug_ctrl = qdev_get_hotplug_handler(dev);