mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
bhyve: Use new connection close callbacks API
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>
This commit is contained in:
parent
e74bb402e4
commit
ba6f53d778
@ -217,11 +217,18 @@ bhyveDomainDefAssignAddresses(virDomainDef *def,
|
|||||||
virDomainXMLOption *
|
virDomainXMLOption *
|
||||||
virBhyveDriverCreateXMLConf(struct _bhyveConn *driver)
|
virBhyveDriverCreateXMLConf(struct _bhyveConn *driver)
|
||||||
{
|
{
|
||||||
|
virDomainXMLOption *ret = NULL;
|
||||||
|
|
||||||
virBhyveDriverDomainDefParserConfig.priv = driver;
|
virBhyveDriverDomainDefParserConfig.priv = driver;
|
||||||
return virDomainXMLOptionNew(&virBhyveDriverDomainDefParserConfig,
|
|
||||||
&virBhyveDriverPrivateDataCallbacks,
|
ret = virDomainXMLOptionNew(&virBhyveDriverDomainDefParserConfig,
|
||||||
&virBhyveDriverDomainXMLNamespace,
|
&virBhyveDriverPrivateDataCallbacks,
|
||||||
NULL, NULL, NULL);
|
&virBhyveDriverDomainXMLNamespace,
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
|
||||||
|
virDomainXMLOptionSetCloseCallbackAlloc(ret, virCloseCallbacksDomainAlloc);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ bhyveConnectClose(virConnectPtr conn)
|
|||||||
{
|
{
|
||||||
struct _bhyveConn *privconn = conn->privateData;
|
struct _bhyveConn *privconn = conn->privateData;
|
||||||
|
|
||||||
virCloseCallbacksRun(privconn->closeCallbacks, conn, privconn->domains);
|
virCloseCallbacksDomainRunForConn(privconn->domains, conn);
|
||||||
conn->privateData = NULL;
|
conn->privateData = NULL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -1161,7 +1161,6 @@ bhyveStateCleanup(void)
|
|||||||
virObjectUnref(bhyve_driver->caps);
|
virObjectUnref(bhyve_driver->caps);
|
||||||
virObjectUnref(bhyve_driver->xmlopt);
|
virObjectUnref(bhyve_driver->xmlopt);
|
||||||
virSysinfoDefFree(bhyve_driver->hostsysinfo);
|
virSysinfoDefFree(bhyve_driver->hostsysinfo);
|
||||||
virObjectUnref(bhyve_driver->closeCallbacks);
|
|
||||||
virObjectUnref(bhyve_driver->domainEventState);
|
virObjectUnref(bhyve_driver->domainEventState);
|
||||||
virObjectUnref(bhyve_driver->config);
|
virObjectUnref(bhyve_driver->config);
|
||||||
virPortAllocatorRangeFree(bhyve_driver->remotePorts);
|
virPortAllocatorRangeFree(bhyve_driver->remotePorts);
|
||||||
@ -1203,9 +1202,6 @@ bhyveStateInitialize(bool privileged,
|
|||||||
return VIR_DRV_STATE_INIT_ERROR;
|
return VIR_DRV_STATE_INIT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(bhyve_driver->closeCallbacks = virCloseCallbacksNew()))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
if (!(bhyve_driver->caps = virBhyveCapsBuild()))
|
if (!(bhyve_driver->caps = virBhyveCapsBuild()))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -268,10 +268,8 @@ virBhyveProcessStart(virConnectPtr conn,
|
|||||||
if (bhyveProcessStartHook(vm, VIR_HOOK_BHYVE_OP_PREPARE) < 0)
|
if (bhyveProcessStartHook(vm, VIR_HOOK_BHYVE_OP_PREPARE) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (flags & VIR_BHYVE_PROCESS_START_AUTODESTROY &&
|
if (flags & VIR_BHYVE_PROCESS_START_AUTODESTROY)
|
||||||
virCloseCallbacksSet(driver->closeCallbacks, vm,
|
virCloseCallbacksDomainAdd(vm, conn, bhyveProcessAutoDestroy);
|
||||||
conn, bhyveProcessAutoDestroy) < 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (bhyveProcessPrepareDomain(driver, vm, flags) < 0)
|
if (bhyveProcessPrepareDomain(driver, vm, flags) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -325,8 +323,7 @@ virBhyveProcessStop(struct _bhyveConn *driver,
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
virCloseCallbacksUnset(driver->closeCallbacks, vm,
|
virCloseCallbacksDomainRemove(vm, NULL, bhyveProcessAutoDestroy);
|
||||||
bhyveProcessAutoDestroy);
|
|
||||||
|
|
||||||
virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, reason);
|
virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, reason);
|
||||||
vm->pid = 0;
|
vm->pid = 0;
|
||||||
|
@ -59,8 +59,6 @@ struct _bhyveConn {
|
|||||||
|
|
||||||
virObjectEventState *domainEventState;
|
virObjectEventState *domainEventState;
|
||||||
|
|
||||||
virCloseCallbacks *closeCallbacks;
|
|
||||||
|
|
||||||
virPortAllocatorRange *remotePorts;
|
virPortAllocatorRange *remotePorts;
|
||||||
|
|
||||||
unsigned bhyvecaps;
|
unsigned bhyvecaps;
|
||||||
|
Loading…
Reference in New Issue
Block a user