]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
bhyve: Use new connection close callbacks API
authorPeter Krempa <pkrempa@redhat.com>
Mon, 29 Aug 2022 14:13:58 +0000 (16:13 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 6 Jan 2023 14:30:09 +0000 (15:30 +0100)
The rewrite is straightforward as bhyve registers only the
'bhyveProcessAutoDestroy' callback which by design doesn't need any
special handling (there's just one caller which can start the VM thus
implicitly there's only one possible registration for that function).

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/bhyve/bhyve_domain.c
src/bhyve/bhyve_driver.c
src/bhyve/bhyve_process.c
src/bhyve/bhyve_utils.h

index b7b2db57b8295746fc9961130753f875fbae967c..a1d1ebc706f5238061972a425dfd2458b665ed9b 100644 (file)
@@ -217,11 +217,18 @@ bhyveDomainDefAssignAddresses(virDomainDef *def,
 virDomainXMLOption *
 virBhyveDriverCreateXMLConf(struct _bhyveConn *driver)
 {
+    virDomainXMLOption *ret = NULL;
+
     virBhyveDriverDomainDefParserConfig.priv = driver;
-    return virDomainXMLOptionNew(&virBhyveDriverDomainDefParserConfig,
-                                 &virBhyveDriverPrivateDataCallbacks,
-                                 &virBhyveDriverDomainXMLNamespace,
-                                 NULL, NULL, NULL);
+
+    ret = virDomainXMLOptionNew(&virBhyveDriverDomainDefParserConfig,
+                                &virBhyveDriverPrivateDataCallbacks,
+                                &virBhyveDriverDomainXMLNamespace,
+                                NULL, NULL, NULL);
+
+    virDomainXMLOptionSetCloseCallbackAlloc(ret, virCloseCallbacksDomainAlloc);
+
+    return ret;
 }
 
 
index e0bf2a19a6967cf6b0b36455e00abc1d8b452f69..d100adeb8f6b728ddc50f043a9c9a3af0d4947a7 100644 (file)
@@ -207,7 +207,7 @@ bhyveConnectClose(virConnectPtr conn)
 {
     struct _bhyveConn *privconn = conn->privateData;
 
-    virCloseCallbacksRun(privconn->closeCallbacks, conn, privconn->domains);
+    virCloseCallbacksDomainRunForConn(privconn->domains, conn);
     conn->privateData = NULL;
 
     return 0;
@@ -1161,7 +1161,6 @@ bhyveStateCleanup(void)
     virObjectUnref(bhyve_driver->caps);
     virObjectUnref(bhyve_driver->xmlopt);
     virSysinfoDefFree(bhyve_driver->hostsysinfo);
-    virObjectUnref(bhyve_driver->closeCallbacks);
     virObjectUnref(bhyve_driver->domainEventState);
     virObjectUnref(bhyve_driver->config);
     virPortAllocatorRangeFree(bhyve_driver->remotePorts);
@@ -1203,9 +1202,6 @@ bhyveStateInitialize(bool privileged,
         return VIR_DRV_STATE_INIT_ERROR;
     }
 
-    if (!(bhyve_driver->closeCallbacks = virCloseCallbacksNew()))
-        goto cleanup;
-
     if (!(bhyve_driver->caps = virBhyveCapsBuild()))
         goto cleanup;
 
index d46786d393cfe3eef288d0402869666c78bb63b7..eee0c4bf1de3b216b7c8bd2b0f46b86574ef0ebe 100644 (file)
@@ -268,10 +268,8 @@ virBhyveProcessStart(virConnectPtr conn,
     if (bhyveProcessStartHook(vm, VIR_HOOK_BHYVE_OP_PREPARE) < 0)
         return -1;
 
-    if (flags & VIR_BHYVE_PROCESS_START_AUTODESTROY &&
-        virCloseCallbacksSet(driver->closeCallbacks, vm,
-                             conn, bhyveProcessAutoDestroy) < 0)
-        return -1;
+    if (flags & VIR_BHYVE_PROCESS_START_AUTODESTROY)
+        virCloseCallbacksDomainAdd(vm, conn, bhyveProcessAutoDestroy);
 
     if (bhyveProcessPrepareDomain(driver, vm, flags) < 0)
         return -1;
@@ -325,8 +323,7 @@ virBhyveProcessStop(struct _bhyveConn *driver,
 
     ret = 0;
 
-    virCloseCallbacksUnset(driver->closeCallbacks, vm,
-                           bhyveProcessAutoDestroy);
+    virCloseCallbacksDomainRemove(vm, NULL, bhyveProcessAutoDestroy);
 
     virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, reason);
     vm->pid = 0;
index 5d6e198b09af3374853b535e889e0adcc8a50fbe..0680ae4cd10e666a9fb40d29f4a7ead69f2b8551 100644 (file)
@@ -59,8 +59,6 @@ struct _bhyveConn {
 
     virObjectEventState *domainEventState;
 
-    virCloseCallbacks *closeCallbacks;
-
     virPortAllocatorRange *remotePorts;
 
     unsigned bhyvecaps;