From 13c9ef29c0ffccc9e8b0fed65d58b0c36958728f Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Tue, 30 Apr 2013 15:41:52 +0100 Subject: [PATCH] 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 --- src/xen/xen_driver.c | 19 +--------- src/xen/xen_driver.h | 1 - src/xen/xen_hypervisor.c | 76 ---------------------------------------- src/xen/xen_hypervisor.h | 5 --- src/xen/xend_internal.c | 13 ++----- src/xen/xend_internal.h | 2 +- src/xen/xm_internal.c | 2 +- 7 files changed, 6 insertions(+), 112 deletions(-) diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 1ae27e852d..6db983176d 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -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 diff --git a/src/xen/xen_driver.h b/src/xen/xen_driver.h index b77067d6fb..aff68f2ea3 100644 --- a/src/xen/xen_driver.h +++ b/src/xen/xen_driver.h @@ -94,7 +94,6 @@ extern int xenRegister (void); */ struct xenUnifiedDriver { virDrvConnectGetHostname xenGetHostname; - virDrvDomainDestroyFlags xenDomainDestroyFlags; virDrvDomainGetOSType xenDomainGetOSType; virDrvDomainGetMaxMemory xenDomainGetMaxMemory; virDrvDomainSetMaxMemory xenDomainSetMaxMemory; diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c index bc63648800..808fc3a54c 100644 --- a/src/xen/xen_hypervisor.c +++ b/src/xen/xen_hypervisor.c @@ -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 diff --git a/src/xen/xen_hypervisor.h b/src/xen/xen_hypervisor.h index 812816d9ad..450b4f1c1c 100644 --- a/src/xen/xen_hypervisor.h +++ b/src/xen/xen_hypervisor.h @@ -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); diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index 8f9e624d9d..541c7afa03 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -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, diff --git a/src/xen/xend_internal.h b/src/xen/xend_internal.h index 27e8fbdc79..d393ec8af8 100644 --- a/src/xen/xend_internal.h +++ b/src/xen/xend_internal.h @@ -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); diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c index 3ed749e1a5..39b031038b 100644 --- a/src/xen/xm_internal.c +++ b/src/xen/xm_internal.c @@ -970,7 +970,7 @@ xenXMDomainCreate(virDomainPtr domain) error: if (domain->id != -1) { - xenDaemonDomainDestroyFlags(domain, 0); + xenDaemonDomainDestroy(domain); domain->id = -1; } xenUnifiedUnlock(priv);