[PATCH 15/17] qemu: Reload virUdevMgr on start

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

 



If the daemon is restarted, the virUdevMgr loses its internal
state. This is because entries to its internal DB are added
whilst setting security labels. This obviously doesn't happen
when the daemon is restarted.
It's not wise to start with a fresh internal state and possibly
leave behind previous one.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index cc34782..51122d0 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -377,10 +377,20 @@ qemuSecurityInit(virQEMUDriverPtr driver)
     virSecurityManagerPtr stack = NULL;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
     unsigned int flags = 0;
+    char *file = NULL;
 
-    if (cfg->writeUdev &&
-        !(driver->udevMgr = virUdevMgrNew()))
-        goto error;
+    if (cfg->writeUdev) {
+        if (!(file = qemuProcessGetUdevPath(driver)))
+            goto error;
+
+        if (virFileExists(file)) {
+            if (!(driver->udevMgr = virUdevMgrNewFromFile(file)))
+                goto error;
+        } else {
+            if (!(driver->udevMgr = virUdevMgrNew()))
+                goto error;
+        }
+    }
 
     if (cfg->allowDiskFormatProbing)
         flags |= VIR_SECURITY_MANAGER_ALLOW_DISK_PROBE;
@@ -442,12 +452,14 @@ qemuSecurityInit(virQEMUDriverPtr driver)
     }
 
     driver->securityManager = stack;
+    VIR_FREE(file);
     virObjectUnref(cfg);
     return 0;
 
  error:
     virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                    _("Failed to initialize security drivers"));
+    VIR_FREE(file);
     virObjectUnref(stack);
     virObjectUnref(mgr);
     virObjectUnref(cfg);
-- 
2.8.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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]