libvirt patch in master, [PATCH] Send event on persistent config modification

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

 



>From 32dbfbf9857ea72b69ea175ea7f8b21210f4e5d2 Mon Sep 17 00:00:00 2001
From: Efim Shevrin <efim.shevrin@xxxxxxxxxxxxx>
Date: Tue, 10 May 2022 17:03:11 +0300
Subject: [PATCH] Send event on persistent config modification

Libvirt is not sending events in case of a device update, thus any services
listening to events are unaware of the changes.This patch suggests to send event in
case of a persistent config modification, it should keep subscribed services in sync with VM configuration.

Signed-off-by: Efim Shevrin <efim.shevrin@xxxxxxxxxxxxx>
---
 src/qemu/qemu_driver.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e3582f62a7..6008a4c8f3 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7942,6 +7942,7 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
     virQEMUDriver *driver = dom->conn->privateData;
     virDomainObj *vm = NULL;
     qemuDomainObjPrivate *priv;
+    virObjectEvent *event = NULL;
     g_autoview.settings().get('font_face')ptr(virDomainDef) vmdef = NULL;
     g_autoptr(virDomainDeviceDef) dev = NULL;
     virDomainDeviceDef *dev_copy = NULL;
@@ -8019,8 +8020,16 @@ static int 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:
-- 
2.31.1





[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