From 354b455ec666e9e388233ab9da756d4318626d2c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Mon, 3 Feb 2025 15:11:32 +0000 Subject: [PATCH] bhyve: stop opening & passing connection to bhyveProcessStart MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Daniel P. Berrangé --- src/bhyve/bhyve_driver.c | 18 +++--------------- src/bhyve/bhyve_utils.h | 5 ----- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 1b3fe075c1..450bb2c902 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -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); } /** diff --git a/src/bhyve/bhyve_utils.h b/src/bhyve/bhyve_utils.h index 0680ae4cd1..6c6fd12dbe 100644 --- a/src/bhyve/bhyve_utils.h +++ b/src/bhyve/bhyve_utils.h @@ -66,8 +66,3 @@ struct _bhyveConn { }; typedef struct _bhyveConn bhyveConn; - -struct bhyveAutostartData { - struct _bhyveConn *driver; - virConnectPtr conn; -}; -- 2.47.3