mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
Simplify the Xen domain destroy driver method
Unconditionally call the xenDaemonDomainDestroyFlags API since the XenD driver is always available. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
6d0d1ecce9
commit
13c9ef29c0
@ -778,26 +778,9 @@ static int
|
||||
xenUnifiedDomainDestroyFlags(virDomainPtr dom,
|
||||
unsigned int flags)
|
||||
{
|
||||
xenUnifiedPrivatePtr priv = dom->conn->privateData;
|
||||
int i;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
|
||||
/* Try non-hypervisor methods first, then hypervisor direct method
|
||||
* as a last resort.
|
||||
*/
|
||||
for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
|
||||
if (i != XEN_UNIFIED_HYPERVISOR_OFFSET &&
|
||||
priv->opened[i] &&
|
||||
drivers[i]->xenDomainDestroyFlags &&
|
||||
drivers[i]->xenDomainDestroyFlags(dom, flags) == 0)
|
||||
return 0;
|
||||
|
||||
if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET] &&
|
||||
xenHypervisorDestroyDomainFlags(dom, flags) == 0)
|
||||
return 0;
|
||||
|
||||
return -1;
|
||||
return xenDaemonDomainDestroy(dom);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -94,7 +94,6 @@ extern int xenRegister (void);
|
||||
*/
|
||||
struct xenUnifiedDriver {
|
||||
virDrvConnectGetHostname xenGetHostname;
|
||||
virDrvDomainDestroyFlags xenDomainDestroyFlags;
|
||||
virDrvDomainGetOSType xenDomainGetOSType;
|
||||
virDrvDomainGetMaxMemory xenDomainGetMaxMemory;
|
||||
virDrvDomainSetMaxMemory xenDomainSetMaxMemory;
|
||||
|
@ -608,13 +608,6 @@ struct xen_v0_domainop {
|
||||
};
|
||||
typedef struct xen_v0_domainop xen_v0_domainop;
|
||||
|
||||
/*
|
||||
* The information for a destroydomain system hypercall
|
||||
*/
|
||||
#define XEN_V0_OP_DESTROYDOMAIN 9
|
||||
#define XEN_V1_OP_DESTROYDOMAIN 9
|
||||
#define XEN_V2_OP_DESTROYDOMAIN 2
|
||||
|
||||
/*
|
||||
* The information for a pausedomain system hypercall
|
||||
*/
|
||||
@ -880,7 +873,6 @@ typedef struct xen_op_v2_dom xen_op_v2_dom;
|
||||
static unsigned long long xenHypervisorGetMaxMemory(virDomainPtr domain);
|
||||
|
||||
struct xenUnifiedDriver xenHypervisorDriver = {
|
||||
.xenDomainDestroyFlags = xenHypervisorDestroyDomainFlags,
|
||||
.xenDomainGetOSType = xenHypervisorDomainGetOSType,
|
||||
.xenDomainGetMaxMemory = xenHypervisorGetMaxMemory,
|
||||
.xenDomainSetMaxMemory = xenHypervisorSetMaxMemory,
|
||||
@ -1485,45 +1477,6 @@ xenHypervisorDomainInterfaceStats(virDomainPtr dom,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virXen_destroydomain:
|
||||
* @handle: the hypervisor handle
|
||||
* @id: the domain id
|
||||
*
|
||||
* Do a low level hypercall to destroy the domain
|
||||
*
|
||||
* Returns 0 or -1 in case of failure
|
||||
*/
|
||||
static int
|
||||
virXen_destroydomain(int handle, int id)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (hv_versions.hypervisor > 1) {
|
||||
xen_op_v2_dom op;
|
||||
|
||||
memset(&op, 0, sizeof(op));
|
||||
op.cmd = XEN_V2_OP_DESTROYDOMAIN;
|
||||
op.domain = (domid_t) id;
|
||||
ret = xenHypervisorDoV2Dom(handle, &op);
|
||||
} else if (hv_versions.hypervisor == 1) {
|
||||
xen_op_v1 op;
|
||||
|
||||
memset(&op, 0, sizeof(op));
|
||||
op.cmd = XEN_V1_OP_DESTROYDOMAIN;
|
||||
op.u.domain.domain = (domid_t) id;
|
||||
ret = xenHypervisorDoV1Op(handle, &op);
|
||||
} else if (hv_versions.hypervisor == 0) {
|
||||
xen_op_v0 op;
|
||||
|
||||
memset(&op, 0, sizeof(op));
|
||||
op.cmd = XEN_V0_OP_DESTROYDOMAIN;
|
||||
op.u.domain.domain = (domid_t) id;
|
||||
ret = xenHypervisorDoV0Op(handle, &op);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* virXen_setmaxmem:
|
||||
* @handle: the hypervisor handle
|
||||
@ -3063,35 +3016,6 @@ xenHypervisorNodeGetCellsFreeMemory(virConnectPtr conn,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* xenHypervisorDestroyDomainFlags:
|
||||
* @domain: pointer to the domain block
|
||||
* @flags: an OR'ed set of virDomainDestroyFlagsValues
|
||||
*
|
||||
* Do a hypervisor call to destroy the given domain
|
||||
*
|
||||
* Calling this function with no @flags set (equal to zero)
|
||||
* is equivalent to calling xenHypervisorDestroyDomain.
|
||||
*
|
||||
* Returns 0 in case of success, -1 in case of error.
|
||||
*/
|
||||
int
|
||||
xenHypervisorDestroyDomainFlags(virDomainPtr domain, unsigned int flags)
|
||||
{
|
||||
int ret;
|
||||
xenUnifiedPrivatePtr priv = domain->conn->privateData;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
|
||||
if (domain->id < 0)
|
||||
return -1;
|
||||
|
||||
ret = virXen_destroydomain(priv->handle, domain->id);
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* xenHypervisorSetMaxMemory:
|
||||
* @domain: pointer to the domain block
|
||||
|
@ -72,11 +72,6 @@ unsigned long
|
||||
int id);
|
||||
int xenHypervisorGetMaxVcpus (virConnectPtr conn,
|
||||
const char *type);
|
||||
int xenHypervisorDestroyDomain (virDomainPtr domain)
|
||||
ATTRIBUTE_NONNULL (1);
|
||||
int xenHypervisorDestroyDomainFlags (virDomainPtr domain,
|
||||
unsigned int flags)
|
||||
ATTRIBUTE_NONNULL (1);
|
||||
int xenHypervisorGetDomainInfo (virDomainPtr domain,
|
||||
virDomainInfoPtr info)
|
||||
ATTRIBUTE_NONNULL (1);
|
||||
|
@ -1340,9 +1340,8 @@ xenDaemonDomainReboot(virDomainPtr domain)
|
||||
}
|
||||
|
||||
/**
|
||||
* xenDaemonDomainDestroyFlags:
|
||||
* xenDaemonDomainDestroy:
|
||||
* @domain: pointer to the Domain block
|
||||
* @flags: an OR'ed set of virDomainDestroyFlagsValues
|
||||
*
|
||||
* Abruptly halt the domain, the OS is not properly shutdown and the
|
||||
* resources allocated for the domain are immediately freed, mounted
|
||||
@ -1351,16 +1350,11 @@ xenDaemonDomainReboot(virDomainPtr domain)
|
||||
* dying and will go away completely once all of the resources have been
|
||||
* unmapped (usually from the backend devices).
|
||||
*
|
||||
* Calling this function with no @flags set (equal to zero)
|
||||
* is equivalent to calling xenDaemonDomainDestroy.
|
||||
*
|
||||
* Returns 0 in case of success, -1 (with errno) in case of error.
|
||||
*/
|
||||
int
|
||||
xenDaemonDomainDestroyFlags(virDomainPtr domain, unsigned int flags)
|
||||
xenDaemonDomainDestroy(virDomainPtr domain)
|
||||
{
|
||||
virCheckFlags(0, -1);
|
||||
|
||||
if (domain->id < 0) {
|
||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||
_("Domain %s isn't running."), domain->name);
|
||||
@ -2237,7 +2231,7 @@ xenDaemonCreateXML(virConnectPtr conn, const char *xmlDesc)
|
||||
error:
|
||||
/* Make sure we don't leave a still-born domain around */
|
||||
if (dom != NULL) {
|
||||
xenDaemonDomainDestroyFlags(dom, 0);
|
||||
xenDaemonDomainDestroy(dom);
|
||||
virObjectUnref(dom);
|
||||
}
|
||||
virDomainDefFree(def);
|
||||
@ -3447,7 +3441,6 @@ xenDaemonDomainBlockPeek(virDomainPtr domain,
|
||||
}
|
||||
|
||||
struct xenUnifiedDriver xenDaemonDriver = {
|
||||
.xenDomainDestroyFlags = xenDaemonDomainDestroyFlags,
|
||||
.xenDomainGetOSType = xenDaemonDomainGetOSType,
|
||||
.xenDomainGetMaxMemory = xenDaemonDomainGetMaxMemory,
|
||||
.xenDomainSetMaxMemory = xenDaemonDomainSetMaxMemory,
|
||||
|
@ -91,7 +91,7 @@ int xenDaemonDomainSuspend(virDomainPtr domain);
|
||||
int xenDaemonDomainResume(virDomainPtr domain);
|
||||
int xenDaemonDomainShutdown(virDomainPtr domain);
|
||||
int xenDaemonDomainReboot(virDomainPtr domain);
|
||||
int xenDaemonDomainDestroyFlags(virDomainPtr domain, unsigned int flags);
|
||||
int xenDaemonDomainDestroy(virDomainPtr domain);
|
||||
int xenDaemonDomainSave(virDomainPtr domain, const char *filename);
|
||||
int xenDaemonDomainCoreDump(virDomainPtr domain, const char *filename,
|
||||
unsigned int flags);
|
||||
|
@ -970,7 +970,7 @@ xenXMDomainCreate(virDomainPtr domain)
|
||||
|
||||
error:
|
||||
if (domain->id != -1) {
|
||||
xenDaemonDomainDestroyFlags(domain, 0);
|
||||
xenDaemonDomainDestroy(domain);
|
||||
domain->id = -1;
|
||||
}
|
||||
xenUnifiedUnlock(priv);
|
||||
|
Loading…
x
Reference in New Issue
Block a user