]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
bhyve: stop opening & passing connection to bhyveProcessStart
authorDaniel P. Berrangé <berrange@redhat.com>
Mon, 3 Feb 2025 15:11:32 +0000 (15:11 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Wed, 12 Feb 2025 18:05:35 +0000 (18:05 +0000)
A connection object is not required because autostarted domains are
never marked for autodestroy.

The comment about needing a connection for the network driver is
obsolete since we can auto-open a connection on demand.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/bhyve/bhyve_driver.c
src/bhyve/bhyve_utils.h

index 1b3fe075c1ab3f3968afc160410ce42e7db5df12..450bb2c902e6c4b87093942cd27b1241a517fb9e 100644 (file)
@@ -73,13 +73,13 @@ struct _bhyveConn *bhyve_driver = NULL;
 static int
 bhyveAutostartDomain(virDomainObj *vm, void *opaque)
 {
-    const struct bhyveAutostartData *data = opaque;
+    bhyveConn *driver = opaque;
     int ret = 0;
     VIR_LOCK_GUARD lock = virObjectLockGuard(vm);
 
     if (vm->autostart && !virDomainObjIsActive(vm)) {
         virResetLastError();
-        ret = virBhyveProcessStart(data->driver, data->conn, vm,
+        ret = virBhyveProcessStart(driver, NULL, vm,
                                    VIR_DOMAIN_RUNNING_BOOTED, 0);
         if (ret < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -93,19 +93,7 @@ bhyveAutostartDomain(virDomainObj *vm, void *opaque)
 static void
 bhyveAutostartDomains(struct _bhyveConn *driver)
 {
-    /* 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("bhyve:///system");
-    /* Ignoring NULL conn which is mostly harmless here */
-
-    struct bhyveAutostartData data = { driver, conn };
-
-    virDomainObjListForEach(driver->domains, false, bhyveAutostartDomain, &data);
-
-    virObjectUnref(conn);
+    virDomainObjListForEach(driver->domains, false, bhyveAutostartDomain, driver);
 }
 
 /**
index 0680ae4cd10e666a9fb40d29f4a7ead69f2b8551..6c6fd12dbe89e9dffb3b98d8d6b5ed2379e0807b 100644 (file)
@@ -66,8 +66,3 @@ struct _bhyveConn {
 };
 
 typedef struct _bhyveConn bhyveConn;
-
-struct bhyveAutostartData {
-    struct _bhyveConn *driver;
-    virConnectPtr conn;
-};