mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
Emit VIR_DOMAIN_EVENT_ID_DEVICE_ADDED in the QEMU driver
Only for devices that have an alias.
This commit is contained in:
parent
1882c0bd8d
commit
b693b2fb73
@ -7661,19 +7661,24 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm,
|
||||
{
|
||||
virQEMUDriverPtr driver = dom->conn->privateData;
|
||||
int ret = -1;
|
||||
const char *alias = NULL;
|
||||
|
||||
switch ((virDomainDeviceType) dev->type) {
|
||||
case VIR_DOMAIN_DEVICE_DISK:
|
||||
qemuDomainObjCheckDiskTaint(driver, vm, dev->data.disk, -1);
|
||||
ret = qemuDomainAttachDeviceDiskLive(dom->conn, driver, vm, dev);
|
||||
if (!ret)
|
||||
if (!ret) {
|
||||
alias = dev->data.disk->info.alias;
|
||||
dev->data.disk = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_CONTROLLER:
|
||||
ret = qemuDomainAttachDeviceControllerLive(driver, vm, dev);
|
||||
if (!ret)
|
||||
if (!ret) {
|
||||
alias = dev->data.controller->info.alias;
|
||||
dev->data.controller = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_LEASE:
|
||||
@ -7687,41 +7692,52 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm,
|
||||
qemuDomainObjCheckNetTaint(driver, vm, dev->data.net, -1);
|
||||
ret = qemuDomainAttachNetDevice(dom->conn, driver, vm,
|
||||
dev->data.net);
|
||||
if (!ret)
|
||||
if (!ret) {
|
||||
alias = dev->data.net->info.alias;
|
||||
dev->data.net = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_HOSTDEV:
|
||||
qemuDomainObjCheckHostdevTaint(driver, vm, dev->data.hostdev, -1);
|
||||
ret = qemuDomainAttachHostDevice(dom->conn, driver, vm,
|
||||
dev->data.hostdev);
|
||||
if (!ret)
|
||||
if (!ret) {
|
||||
alias = dev->data.hostdev->info->alias;
|
||||
dev->data.hostdev = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_REDIRDEV:
|
||||
ret = qemuDomainAttachRedirdevDevice(driver, vm,
|
||||
dev->data.redirdev);
|
||||
if (!ret)
|
||||
if (!ret) {
|
||||
alias = dev->data.redirdev->info.alias;
|
||||
dev->data.redirdev = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_CHR:
|
||||
ret = qemuDomainAttachChrDevice(driver, vm,
|
||||
dev->data.chr);
|
||||
if (!ret)
|
||||
if (!ret) {
|
||||
alias = dev->data.chr->info.alias;
|
||||
dev->data.chr = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_RNG:
|
||||
ret = qemuDomainAttachRNGDevice(driver, vm,
|
||||
dev->data.rng);
|
||||
if (!ret)
|
||||
if (!ret) {
|
||||
alias = dev->data.rng->info.alias;
|
||||
dev->data.rng = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_MEMORY:
|
||||
/* note that qemuDomainAttachMemory always consumes dev->data.memory */
|
||||
/* note that qemuDomainAttachMemory always consumes dev->data.memory
|
||||
* and dispatches DeviceAdded event on success */
|
||||
ret = qemuDomainAttachMemory(driver, vm,
|
||||
dev->data.memory);
|
||||
dev->data.memory = NULL;
|
||||
@ -7748,6 +7764,16 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm,
|
||||
break;
|
||||
}
|
||||
|
||||
if (alias) {
|
||||
/* queue the event before the alias has a chance to get freed
|
||||
* if the domain disappears while qemuDomainUpdateDeviceList
|
||||
* is in monitor */
|
||||
virObjectEventPtr event;
|
||||
event = virDomainEventDeviceAddedNewFromObj(vm, alias);
|
||||
if (event)
|
||||
qemuDomainEventQueue(driver, event);
|
||||
}
|
||||
|
||||
if (ret == 0)
|
||||
ret = qemuDomainUpdateDeviceList(driver, vm, QEMU_ASYNC_JOB_NONE);
|
||||
|
||||
|
@ -1726,6 +1726,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
|
||||
char *objalias = NULL;
|
||||
const char *backendType;
|
||||
virJSONValuePtr props = NULL;
|
||||
virObjectEventPtr event;
|
||||
int id;
|
||||
int ret = -1;
|
||||
|
||||
@ -1769,6 +1770,10 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
event = virDomainEventDeviceAddedNewFromObj(vm, objalias);
|
||||
if (event)
|
||||
qemuDomainEventQueue(driver, event);
|
||||
|
||||
/* mem is consumed by vm->def */
|
||||
mem = NULL;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user