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(a)redhat.com>
---
src/bhyve/bhyve_domain.c | 15 +++++++++++----
src/bhyve/bhyve_driver.c | 6 +-----
src/bhyve/bhyve_process.c | 9 +++------
src/bhyve/bhyve_utils.h | 2 --
4 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c
index b7b2db57b8..a1d1ebc706 100644
--- a/src/bhyve/bhyve_domain.c
+++ b/src/bhyve/bhyve_domain.c
@@ -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;
}
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index e0bf2a19a6..d100adeb8f 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -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;
diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c
index d46786d393..eee0c4bf1d 100644
--- a/src/bhyve/bhyve_process.c
+++ b/src/bhyve/bhyve_process.c
@@ -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;
diff --git a/src/bhyve/bhyve_utils.h b/src/bhyve/bhyve_utils.h
index 5d6e198b09..0680ae4cd1 100644
--- a/src/bhyve/bhyve_utils.h
+++ b/src/bhyve/bhyve_utils.h
@@ -59,8 +59,6 @@ struct _bhyveConn {
virObjectEventState *domainEventState;
- virCloseCallbacks *closeCallbacks;
-
virPortAllocatorRange *remotePorts;
unsigned bhyvecaps;
--
2.38.1