mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
qemu: Send event on persistent config modification
Currently, libvirt doesn't send events when devices are attached, detached or updated. Thus, any services that listen to events are unaware of the change to persistent config. Signed-off-by: Fima Shevrin <efim.shevrin@virtuozzo.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
a97b428208
commit
bc06cfa1cd
@ -7209,6 +7209,7 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObj *vm,
|
||||
unsigned int flags)
|
||||
{
|
||||
qemuDomainObjPrivate *priv = vm->privateData;
|
||||
virObjectEvent *event = NULL;
|
||||
g_autoptr(virDomainDef) vmdef = NULL;
|
||||
g_autoptr(virQEMUDriverConfig) cfg = NULL;
|
||||
g_autoptr(virDomainDeviceDef) devConf = NULL;
|
||||
@ -7292,6 +7293,12 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObj *vm,
|
||||
return -1;
|
||||
|
||||
virDomainObjAssignDef(vm, &vmdef, false, NULL);
|
||||
|
||||
/* Event sending if persistent config has changed */
|
||||
event = virDomainEventLifecycleNewFromObj(vm,
|
||||
VIR_DOMAIN_EVENT_DEFINED,
|
||||
VIR_DOMAIN_EVENT_DEFINED_UPDATED);
|
||||
virObjectEventStateQueue(driver->domainEventState, event);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -7348,6 +7355,7 @@ qemuDomainUpdateDeviceFlags(virDomainPtr dom,
|
||||
virQEMUDriver *driver = dom->conn->privateData;
|
||||
virDomainObj *vm = NULL;
|
||||
qemuDomainObjPrivate *priv;
|
||||
virObjectEvent *event = NULL;
|
||||
g_autoptr(virDomainDef) vmdef = NULL;
|
||||
g_autoptr(virDomainDeviceDef) dev_config = NULL;
|
||||
g_autoptr(virDomainDeviceDef) dev_live = NULL;
|
||||
@ -7419,8 +7427,16 @@ qemuDomainUpdateDeviceFlags(virDomainPtr dom,
|
||||
/* Finally, if no error until here, we can save config. */
|
||||
if (flags & VIR_DOMAIN_AFFECT_CONFIG) {
|
||||
ret = virDomainDefSave(vmdef, driver->xmlopt, cfg->configDir);
|
||||
if (!ret)
|
||||
if (!ret) {
|
||||
virDomainObjAssignDef(vm, &vmdef, false, NULL);
|
||||
|
||||
/* Event sending if persistent config has changed */
|
||||
event = virDomainEventLifecycleNewFromObj(vm,
|
||||
VIR_DOMAIN_EVENT_DEFINED,
|
||||
VIR_DOMAIN_EVENT_DEFINED_UPDATED);
|
||||
|
||||
virObjectEventStateQueue(driver->domainEventState, event);
|
||||
}
|
||||
}
|
||||
|
||||
endjob:
|
||||
@ -7438,6 +7454,7 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriver *driver,
|
||||
unsigned int flags)
|
||||
{
|
||||
qemuDomainObjPrivate *priv = vm->privateData;
|
||||
virObjectEvent *event = NULL;
|
||||
g_autoptr(virQEMUDriverConfig) cfg = NULL;
|
||||
g_autoptr(virDomainDeviceDef) dev_config = NULL;
|
||||
g_autoptr(virDomainDeviceDef) dev_live = NULL;
|
||||
@ -7495,6 +7512,12 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriver *driver,
|
||||
return -1;
|
||||
|
||||
virDomainObjAssignDef(vm, &vmdef, false, NULL);
|
||||
|
||||
/* Event sending if persistent config has changed */
|
||||
event = virDomainEventLifecycleNewFromObj(vm,
|
||||
VIR_DOMAIN_EVENT_DEFINED,
|
||||
VIR_DOMAIN_EVENT_DEFINED_UPDATED);
|
||||
virObjectEventStateQueue(driver->domainEventState, event);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user