]> xenbits.xensource.com Git - libvirt.git/commitdiff
Simplify the Xen domain destroy driver method
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 30 Apr 2013 14:41:52 +0000 (15:41 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 9 May 2013 12:16:19 +0000 (13:16 +0100)
Unconditionally call the xenDaemonDomainDestroyFlags API
since the XenD driver is always available.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/xen/xen_driver.c
src/xen/xen_driver.h
src/xen/xen_hypervisor.c
src/xen/xen_hypervisor.h
src/xen/xend_internal.c
src/xen/xend_internal.h
src/xen/xm_internal.c

index 1ae27e852d6a1d18d5a474384f0d092c96385bf5..6db983176d91056e9013150a7916a519d5d278f9 100644 (file)
@@ -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
index b77067d6fb91297749f2d80e17f6327c531d14a4..aff68f2ea3ff357f68c0b81e607758e351dc8a86 100644 (file)
@@ -94,7 +94,6 @@ extern int xenRegister (void);
  */
 struct xenUnifiedDriver {
     virDrvConnectGetHostname xenGetHostname;
-    virDrvDomainDestroyFlags xenDomainDestroyFlags;
     virDrvDomainGetOSType xenDomainGetOSType;
     virDrvDomainGetMaxMemory xenDomainGetMaxMemory;
     virDrvDomainSetMaxMemory xenDomainSetMaxMemory;
index bc636488002480e811ff38160b43a3d9da3398a8..808fc3a54c853236ceb5e5ee1648230c4159bc85 100644 (file)
@@ -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
index 812816d9ad585a59b595ad1fa6affc8b43125bfb..450b4f1c1ccc97b6f4e74d18737839bea9d8defb 100644 (file)
@@ -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);
index 8f9e624d9d12bf0836b90e6b9094dd194307b753..541c7afa034ba4b5fbe07430bebdf7b062500531 100644 (file)
@@ -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,
index 27e8fbdc79aa81cb63bddef7ca1c21f80c6cb12f..d393ec8af876d9e50437913d787155c7bb758f1a 100644 (file)
@@ -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);
index 3ed749e1a5e04c056ac0d5260e16021078e1c348..39b031038bf07875a8c455b9a66809f169d106a1 100644 (file)
@@ -970,7 +970,7 @@ xenXMDomainCreate(virDomainPtr domain)
 
  error:
     if (domain->id != -1) {
-        xenDaemonDomainDestroyFlags(domain, 0);
+        xenDaemonDomainDestroy(domain);
         domain->id = -1;
     }
     xenUnifiedUnlock(priv);