]> xenbits.xensource.com Git - libvirt.git/commitdiff
build: fix bugs with destroyFlags patches
authorEric Blake <eblake@redhat.com>
Thu, 21 Jul 2011 19:41:15 +0000 (13:41 -0600)
committerEric Blake <eblake@redhat.com>
Thu, 21 Jul 2011 19:41:15 +0000 (13:41 -0600)
Build failure on xenapi_driver from compiler warnings (flags was unused).

Build failure on xen (incorrect number of arguments).  And in fixing
that, I obeyed the comments of struct xenUnifiedDriver that state
that we want to minimize the number of callback functions in that
struct, not add to it.

* src/xen/xen_driver.c (xenUnifiedDomainDestroyFlags): Use correct
arguments.
(xenUnifiedDomainDestroy): Simplify.
* src/xen/xen_driver.h (xenUnifiedDriver): Remove unused callback.
* src/xen/xen_hypervisor.c (xenHypervisorDestroyDomain): Likewise.
* src/xen/xend_internal.c (xenDaemonDomainDestroy): Likewise.
* src/xen/xend_internal.h (xenDaemonDomainDestroyFlags): Likewise.
* src/xen/xm_internal.c (xenXMDriver): Likewise.
* src/xen/xs_internal.c (xenStoreDriver): Likewise.
* src/xen/xen_inotify.c (xenInotifyDriver): Likewise.
* src/xenapi/xenapi_driver.c (xenapiDomainDestroyFlags): Reject
unknown flags.

src/xen/xen_driver.c
src/xen/xen_driver.h
src/xen/xen_hypervisor.c
src/xen/xen_inotify.c
src/xen/xend_internal.c
src/xen/xend_internal.h
src/xen/xm_internal.c
src/xen/xs_internal.c
src/xenapi/xenapi_driver.c

index 2a2a94e67d1041766c7a3c25cc1e1d6da901cbc5..e256c3337c88dc13d6581e0591779d63e9ff07e1 100644 (file)
@@ -901,30 +901,6 @@ xenUnifiedDomainReboot (virDomainPtr dom, unsigned int flags)
     return -1;
 }
 
-static int
-xenUnifiedDomainDestroy (virDomainPtr dom)
-{
-    GET_PRIVATE(dom->conn);
-    int i;
-
-    /* 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]->domainDestroy &&
-            drivers[i]->domainDestroy (dom) == 0)
-            return 0;
-
-    if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET] &&
-        drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainDestroy &&
-        drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainDestroy (dom) == 0)
-        return 0;
-
-    return -1;
-}
-
 static int
 xenUnifiedDomainDestroyFlags(virDomainPtr dom,
                              unsigned int flags)
@@ -941,17 +917,24 @@ xenUnifiedDomainDestroyFlags(virDomainPtr dom,
         if (i != XEN_UNIFIED_HYPERVISOR_OFFSET &&
             priv->opened[i] &&
             drivers[i]->domainDestroyFlags &&
-            drivers[i]->domainDestroyFlags(dom) == 0)
+            drivers[i]->domainDestroyFlags(dom, flags) == 0)
             return 0;
 
     if (priv->opened[XEN_UNIFIED_HYPERVISOR_OFFSET] &&
         drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainDestroyFlags&&
-        drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainDestroyFlags(dom) == 0)
+        drivers[XEN_UNIFIED_HYPERVISOR_OFFSET]->domainDestroyFlags(dom,
+                                                                   flags) == 0)
         return 0;
 
     return -1;
 }
 
+static int
+xenUnifiedDomainDestroy(virDomainPtr dom)
+{
+    return xenUnifiedDomainDestroyFlags(dom, 0);
+}
+
 static char *
 xenUnifiedDomainGetOSType (virDomainPtr dom)
 {
index 21514276ab67fb387f8eb330b9f702cf5dc9ef0d..039aea38a245ef5e962ce1e7a897c1e045797a09 100644 (file)
@@ -94,8 +94,7 @@ struct xenUnifiedDriver {
         virDrvDomainResume             domainResume;
         virDrvDomainShutdown           domainShutdown;
         virDrvDomainReboot             domainReboot;
-        virDrvDomainDestroy            domainDestroy;
-        virDrvDomainDestroyFlags    domainDestroyFlags;
+        virDrvDomainDestroyFlags        domainDestroyFlags;
         virDrvDomainGetOSType          domainGetOSType;
         virDrvDomainGetMaxMemory       domainGetMaxMemory;
         virDrvDomainSetMaxMemory       domainSetMaxMemory;
index 9312b0edd39862c90887e54b09b6953ed4a13572..0309d8a4f277ba82eeca1ee24d4e47ba8bbe792b 100644 (file)
@@ -815,7 +815,6 @@ struct xenUnifiedDriver xenHypervisorDriver = {
     xenHypervisorResumeDomain, /* domainResume */
     NULL, /* domainShutdown */
     NULL, /* domainReboot */
-    xenHypervisorDestroyDomain, /* domainDestroy */
     xenHypervisorDestroyDomainFlags, /* domainDestroyFlags */
     xenHypervisorDomainGetOSType, /* domainGetOSType */
     xenHypervisorGetMaxMemory, /* domainGetMaxMemory */
@@ -3467,18 +3466,6 @@ xenHypervisorDestroyDomainFlags(virDomainPtr domain,
     return (0);
 }
 
-/**
- * xenHypervisorDestroyDomain:
- * @domain: pointer to the domain block
- *
- * See xenHypervisorDestroyDomainFlags
- */
-int
-xenHypervisorDestroyDomain(virDomainPtr domain)
-{
-    return xenHypervisorDestroyDomainFlags(domain, 0);
-}
-
 /**
  * xenHypervisorSetMaxMemory:
  * @domain: pointer to the domain block
index 5c5c56c091734626bbe2526e76e709fcb40baccf..1496330db54b9f5f97c6aaff905ce66f543bf177 100644 (file)
@@ -62,7 +62,6 @@ struct xenUnifiedDriver xenInotifyDriver = {
     NULL, /* domainResume */
     NULL, /* domainShutdown */
     NULL, /* domainReboot */
-    NULL, /* domainDestroy */
     NULL, /* domainDestroyFlags */
     NULL, /* domainGetOSType */
     NULL, /* domainGetMaxMemory */
index 7cd6868cf6c0fef7deb947031c6de52b3ff6a927..cec2e01f56ea81aaa87e73c9d98b12abca3d6e40 100644 (file)
@@ -1545,18 +1545,6 @@ xenDaemonDomainDestroyFlags(virDomainPtr domain,
     return xend_op(domain->conn, domain->name, "op", "destroy", NULL);
 }
 
-/**
- * xenDaemonDomainDestroy:
- * @domain: pointer to the Domain block
- *
- * See xenDaemonDomainDestroyFlags
- */
-int
-xenDaemonDomainDestroy(virDomainPtr dom)
-{
-    return xenDaemonDomainDestroyFlags(dom, 0);
-}
-
 /**
  * xenDaemonDomainGetOSType:
  * @domain: a domain object
@@ -2667,7 +2655,7 @@ xenDaemonCreateXML(virConnectPtr conn, const char *xmlDesc,
   error:
     /* Make sure we don't leave a still-born domain around */
     if (dom != NULL) {
-        xenDaemonDomainDestroy(dom);
+        xenDaemonDomainDestroyFlags(dom, 0);
         virUnrefDomain(dom);
     }
     virDomainDefFree(def);
@@ -3959,7 +3947,6 @@ struct xenUnifiedDriver xenDaemonDriver = {
     xenDaemonDomainResume,       /* domainResume */
     xenDaemonDomainShutdown,     /* domainShutdown */
     xenDaemonDomainReboot,       /* domainReboot */
-    xenDaemonDomainDestroy,      /* domainDestroy */
     xenDaemonDomainDestroyFlags, /* domainDestroyFlags */
     xenDaemonDomainGetOSType,    /* domainGetOSType */
     xenDaemonDomainGetMaxMemory, /* domainGetMaxMemory */
index 4a0cd69f91f9dc3b030ad9bf5b38ae62d2b2c1aa..a5dd3590e066767414aa5c7ca37f18ae503884ce 100644 (file)
@@ -105,7 +105,7 @@ int xenDaemonDomainSuspend(virDomainPtr domain);
 int xenDaemonDomainResume(virDomainPtr domain);
 int xenDaemonDomainShutdown(virDomainPtr domain);
 int xenDaemonDomainReboot(virDomainPtr domain, unsigned int flags);
-int xenDaemonDomainDestroy(virDomainPtr domain);
+int xenDaemonDomainDestroyFlags(virDomainPtr domain, unsigned int flags);
 int xenDaemonDomainSave(virDomainPtr domain, const char *filename);
 int xenDaemonDomainRestore(virConnectPtr conn, const char *filename);
 int xenDaemonDomainSetMemory(virDomainPtr domain, unsigned long memory);
index 7929393b02c8fcb2f6d5bfadb986662d20e4fb87..185303bcc9278c99aa23c434ffa70b15a0b4b8ac 100644 (file)
@@ -94,7 +94,6 @@ struct xenUnifiedDriver xenXMDriver = {
     NULL, /* domainResume */
     NULL, /* domainShutdown */
     NULL, /* domainReboot */
-    NULL, /* domainDestroy */
     NULL, /* domainDestroyFlags */
     NULL, /* domainGetOSType */
     xenXMDomainGetMaxMemory, /* domainGetMaxMemory */
@@ -1083,7 +1082,7 @@ int xenXMDomainCreate(virDomainPtr domain) {
 
  error:
     if (domain->id != -1) {
-        xenDaemonDomainDestroy(domain);
+        xenDaemonDomainDestroyFlags(domain, 0);
         domain->id = -1;
     }
     xenUnifiedUnlock(priv);
index a08187d5940594a0cc7a70d0f77229a7c9c3fd74..c1b00e5435ba742a9076a46e4b2dbe34c90331b6 100644 (file)
@@ -55,7 +55,6 @@ struct xenUnifiedDriver xenStoreDriver = {
     NULL, /* domainResume */
     xenStoreDomainShutdown, /* domainShutdown */
     xenStoreDomainReboot, /* domainReboot */
-    NULL, /* domainDestroy */
     NULL, /* domainDestroyFlags */
     xenStoreDomainGetOSType, /* domainGetOSType */
     xenStoreDomainGetMaxMemory, /* domainGetMaxMemory */
index 69aab07d02c4b0a65e2408020cce5a85e2ccecc2..dae7e268c146999a6d10650d5b034c8e43d88903 100644 (file)
@@ -857,6 +857,9 @@ xenapiDomainDestroyFlags(virDomainPtr dom,
     xen_vm vm;
     struct xen_vm_set *vms;
     xen_session *session = ((struct _xenapiPrivate *)(dom->conn->privateData))->session;
+
+    virCheckFlags(0, -1);
+
     if (xen_vm_get_by_name_label(session, &vms, dom->name) && vms->size > 0) {
         if (vms->size != 1) {
             xenapiSessionErrorHandler(dom->conn, VIR_ERR_INTERNAL_ERROR,