mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 23:37:42 +00:00
bhyve: support domain undefine
Implement domainUndefine and required helper functions: - domainIsActive - domainIsPersistent
This commit is contained in:
parent
f223b96051
commit
91f396b33b
@ -256,6 +256,44 @@ cleanup:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
bhyveDomainIsActive(virDomainPtr domain)
|
||||
{
|
||||
virDomainObjPtr obj;
|
||||
int ret = -1;
|
||||
|
||||
if (!(obj = bhyveDomObjFromDomain(domain)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainIsActiveEnsureACL(domain->conn, obj->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = virDomainObjIsActive(obj);
|
||||
|
||||
cleanup:
|
||||
virObjectUnlock(obj);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
bhyveDomainIsPersistent(virDomainPtr domain)
|
||||
{
|
||||
virDomainObjPtr obj;
|
||||
int ret = -1;
|
||||
|
||||
if (!(obj = bhyveDomObjFromDomain(domain)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainIsPersistentEnsureACL(domain->conn, obj->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = obj->persistent;
|
||||
|
||||
cleanup:
|
||||
virObjectUnlock(obj);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *
|
||||
bhyveDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
|
||||
{
|
||||
@ -312,6 +350,44 @@ cleanup:
|
||||
return dom;
|
||||
}
|
||||
|
||||
static int
|
||||
bhyveDomainUndefine(virDomainPtr domain)
|
||||
{
|
||||
bhyveConnPtr privconn = domain->conn->privateData;
|
||||
virDomainObjPtr vm;
|
||||
int ret = -1;
|
||||
|
||||
if (!(vm = bhyveDomObjFromDomain(domain)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainUndefineEnsureACL(domain->conn, vm->def) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (!vm->persistent) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||
"%s", _("Cannot undefine transient domain"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (virDomainDeleteConfig(BHYVE_CONFIG_DIR,
|
||||
BHYVE_AUTOSTART_DIR,
|
||||
vm) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainObjIsActive(vm)) {
|
||||
vm->persistent = 0;
|
||||
} else {
|
||||
virDomainObjListRemove(privconn->domains, vm);
|
||||
vm = NULL;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
virObjectUnlock(vm);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
bhyveConnectListDomains(virConnectPtr conn, int *ids, int maxids)
|
||||
{
|
||||
@ -620,7 +696,10 @@ static virDriver bhyveDriver = {
|
||||
.domainLookupByUUID = bhyveDomainLookupByUUID, /* 1.2.2 */
|
||||
.domainLookupByName = bhyveDomainLookupByName, /* 1.2.2 */
|
||||
.domainDefineXML = bhyveDomainDefineXML, /* 1.2.2 */
|
||||
.domainUndefine = bhyveDomainUndefine, /* 1.2.2 */
|
||||
.domainGetXMLDesc = bhyveDomainGetXMLDesc, /* 1.2.2 */
|
||||
.domainIsActive = bhyveDomainIsActive, /* 1.2.2 */
|
||||
.domainIsPersistent = bhyveDomainIsPersistent, /* 1.2.2 */
|
||||
.nodeGetCPUStats = bhyveNodeGetCPUStats, /* 1.2.2 */
|
||||
.nodeGetMemoryStats = bhyveNodeGetMemoryStats, /* 1.2.2 */
|
||||
};
|
||||
|
@ -27,6 +27,7 @@
|
||||
# include "configmake.h"
|
||||
# include "virthread.h"
|
||||
|
||||
# define BHYVE_AUTOSTART_DIR SYSCONFDIR "/libvirt/bhyve/autostart"
|
||||
# define BHYVE_CONFIG_DIR SYSCONFDIR "/libvirt/bhyve"
|
||||
# define BHYVE_STATE_DIR LOCALSTATEDIR "/run/libvirt/bhyve"
|
||||
# define BHYVE_LOG_DIR LOCALSTATEDIR "/log/libvirt/bhyve"
|
||||
|
Loading…
x
Reference in New Issue
Block a user