]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix autostart of domains with virtual networks used
authorDaniel P. Berrange <berrange@redhat.com>
Mon, 8 Dec 2008 11:18:47 +0000 (11:18 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Mon, 8 Dec 2008 11:18:47 +0000 (11:18 +0000)
ChangeLog
src/qemu_driver.c
src/uml_driver.c

index c8c77fa51f0a80eb3962d8ee013f2b0eaa1bedd9..acb71de7d14358dc5a397329ef8b96ff2e8af17c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Mon Dec  8 11:17:53 GMT 2008 Daniel P. Berrange <berrange@redhat.com>
+
+       * src/qemu_driver.c, src/uml_driver.c: Fix guest autostart
+       to have a virConnect object available to allow query of
+       virtual networks
+
 Sun Dec  7 20:44:53 GMT 2008 Daniel P. Berrange <berrange@redhat.com>
 
        * src/test.c: Fix integer long long overflow. Fix NULL defernce
index 769085bbfd81ac87e204a887f69e00c7f199e1fd..31c4886622b92aa10a6636a77a969c6a0821c9b2 100644 (file)
@@ -146,13 +146,22 @@ static struct qemud_driver *qemu_driver = NULL;
 static void
 qemudAutostartConfigs(struct qemud_driver *driver) {
     unsigned int i;
+    /* XXX: Figure out a better way todo this. The domain
+     * startup code needs a connection handle in order
+     * to lookup the bridge associated with a virtual
+     * network
+     */
+    virConnectPtr conn = virConnectOpen(getuid() ?
+                                        "qemu:///session" :
+                                        "qemu:///system");
+    /* Ignoring NULL conn which is mostly harmless here */
 
     for (i = 0 ; i < driver->domains.count ; i++) {
         virDomainObjPtr vm = driver->domains.objs[i];
         virDomainObjLock(vm);
         if (vm->autostart &&
             !virDomainIsActive(vm)) {
-            int ret = qemudStartVMDaemon(NULL, driver, vm, NULL);
+            int ret = qemudStartVMDaemon(conn, driver, vm, NULL);
             if (ret < 0) {
                 virErrorPtr err = virGetLastError();
                 qemudLog(QEMUD_ERR, _("Failed to autostart VM '%s': %s\n"),
@@ -169,6 +178,8 @@ qemudAutostartConfigs(struct qemud_driver *driver) {
         }
         virDomainObjUnlock(vm);
     }
+
+    virConnectClose(conn);
 }
 
 /**
index 61f07331b7408e110c081091117b17875f7b3c28..9c0d9c4c1c201865242f80ea357b5c8067126c60 100644 (file)
@@ -126,16 +126,27 @@ static struct uml_driver *uml_driver = NULL;
 static void
 umlAutostartConfigs(struct uml_driver *driver) {
     unsigned int i;
+    /* XXX: Figure out a better way todo this. The domain
+     * startup code needs a connection handle in order
+     * to lookup the bridge associated with a virtual
+     * network
+     */
+    virConnectPtr conn = virConnectOpen(getuid() ?
+                                        "uml:///session" :
+                                        "uml:///system");
+    /* Ignoring NULL conn which is mostly harmless here */
 
     for (i = 0 ; i < driver->domains.count ; i++) {
         if (driver->domains.objs[i]->autostart &&
             !virDomainIsActive(driver->domains.objs[i]) &&
-            umlStartVMDaemon(NULL, driver, driver->domains.objs[i]) < 0) {
+            umlStartVMDaemon(conn, driver, driver->domains.objs[i]) < 0) {
             virErrorPtr err = virGetLastError();
             umlLog(UML_ERR, _("Failed to autostart VM '%s': %s\n"),
                      driver->domains.objs[i]->def->name, err->message);
         }
     }
+
+    virConnectClose(conn);
 }