
From: Michal Privoznik <mprivozn@redhat.com> When a device is attached to a running guest we ought to emit the VIR_DOMAIN_EVENT_ID_DEVICE_ADDED event. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/ch/ch_hotplug.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/ch/ch_hotplug.c b/src/ch/ch_hotplug.c index 0a55a57069..e7734e2ff0 100644 --- a/src/ch/ch_hotplug.c +++ b/src/ch/ch_hotplug.c @@ -52,23 +52,26 @@ chDomainAddDisk(virCHMonitor *mon, } static int -chDomainAttachDeviceLive(virDomainObj *vm, +chDomainAttachDeviceLive(virCHDriver *driver, + virDomainObj *vm, virDomainDeviceDef *dev) { int ret = -1; virCHDomainObjPrivate *priv = vm->privateData; virCHMonitor *mon = priv->monitor; + const char *alias = NULL; switch (dev->type) { - case VIR_DOMAIN_DEVICE_DISK: { + case VIR_DOMAIN_DEVICE_DISK: if (chDomainAddDisk(mon, vm, dev->data.disk) < 0) { break; } + alias = dev->data.disk->info.alias; dev->data.disk = NULL; ret = 0; break; - } + case VIR_DOMAIN_DEVICE_NET: case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: @@ -104,6 +107,13 @@ chDomainAttachDeviceLive(virDomainObj *vm, break; } + if (alias) { + virObjectEvent *event; + + event = virDomainEventDeviceAddedNewFromObj(vm, alias); + virObjectEventStateQueue(driver->domainEventState, event); + } + return ret; } @@ -148,7 +158,7 @@ chDomainAttachDeviceLiveAndUpdateConfig(virDomainObj *vm, return -1; } - if (chDomainAttachDeviceLive(vm, devLive) < 0) { + if (chDomainAttachDeviceLive(driver, vm, devLive) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Failed to add device")); return -1; -- 2.49.1