Re: [PATCH] Send event on persistent config modification

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/19/23 16:20, Fima Shevrin wrote:
> 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@xxxxxxxxxxxxx>
> ---
>  src/qemu/qemu_driver.c | 25 ++++++++++++++++++++++++-
>  1 file changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 43d96739d5..86da8da777 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -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);

Yeah, this is definitely better, but we have a more specific event:
VIR_DOMAIN_EVENT_ID_DEVICE_ADDED (virDomainEventDeviceAddedNewFromObj()).

Simirarly, we do have VIR_DOMAIN_EVENT_ID_DEVICE_REMOVED
(virDomainEventDeviceRemovedNewFromObj()).

OTOH, both events assume device alias to be present (which is usually
not the case for inactive XML (except for user defined device aliases)).

In the end, your change makes sense.

Reviewed-by: Michal Privoznik <mprivozn@xxxxxxxxxx>

and pushed. Congratulations on your first libvirt contribution!

Michal




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux