From: Daniel P. Berrangé Date: Mon, 3 Feb 2025 15:11:32 +0000 (+0000) Subject: bhyve: stop opening & passing connection to bhyveProcessStart X-Git-Tag: v11.1.0-rc1~77 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=354b455ec666e9e388233ab9da756d4318626d2c;p=thirdparty%2Flibvirt.git bhyve: stop opening & passing connection to bhyveProcessStart 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é --- 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; -};