[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] build: fix bugs with destroyFlags patches



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.
---

I'm pushing this under the build-breaker rule as well, even though
it turned into somewhat of a bigger patch than I had planned.

 src/xen/xen_driver.c       |   35 +++++++++--------------------------
 src/xen/xen_driver.h       |    3 +--
 src/xen/xen_hypervisor.c   |   13 -------------
 src/xen/xen_inotify.c      |    1 -
 src/xen/xend_internal.c    |   15 +--------------
 src/xen/xend_internal.h    |    2 +-
 src/xen/xm_internal.c      |    3 +--
 src/xen/xs_internal.c      |    1 -
 src/xenapi/xenapi_driver.c |    3 +++
 9 files changed, 16 insertions(+), 60 deletions(-)

diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index 2a2a94e..e256c33 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -902,30 +902,6 @@ xenUnifiedDomainReboot (virDomainPtr dom, unsigned int flags)
 }

 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)
 {
diff --git a/src/xen/xen_driver.h b/src/xen/xen_driver.h
index 2151427..039aea3 100644
--- a/src/xen/xen_driver.h
+++ b/src/xen/xen_driver.h
@@ -94,8 +94,7 @@ struct xenUnifiedDriver {
         virDrvDomainResume		domainResume;
         virDrvDomainShutdown		domainShutdown;
         virDrvDomainReboot		domainReboot;
-        virDrvDomainDestroy		domainDestroy;
-        virDrvDomainDestroyFlags    domainDestroyFlags;
+        virDrvDomainDestroyFlags        domainDestroyFlags;
         virDrvDomainGetOSType		domainGetOSType;
         virDrvDomainGetMaxMemory	domainGetMaxMemory;
         virDrvDomainSetMaxMemory	domainSetMaxMemory;
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index 9312b0e..0309d8a 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -815,7 +815,6 @@ struct xenUnifiedDriver xenHypervisorDriver = {
     xenHypervisorResumeDomain, /* domainResume */
     NULL, /* domainShutdown */
     NULL, /* domainReboot */
-    xenHypervisorDestroyDomain, /* domainDestroy */
     xenHypervisorDestroyDomainFlags, /* domainDestroyFlags */
     xenHypervisorDomainGetOSType, /* domainGetOSType */
     xenHypervisorGetMaxMemory, /* domainGetMaxMemory */
@@ -3468,18 +3467,6 @@ xenHypervisorDestroyDomainFlags(virDomainPtr domain,
 }

 /**
- * xenHypervisorDestroyDomain:
- * @domain: pointer to the domain block
- *
- * See xenHypervisorDestroyDomainFlags
- */
-int
-xenHypervisorDestroyDomain(virDomainPtr domain)
-{
-    return xenHypervisorDestroyDomainFlags(domain, 0);
-}
-
-/**
  * xenHypervisorSetMaxMemory:
  * @domain: pointer to the domain block
  * @memory: the max memory size in kilobytes.
diff --git a/src/xen/xen_inotify.c b/src/xen/xen_inotify.c
index 5c5c56c..1496330 100644
--- a/src/xen/xen_inotify.c
+++ b/src/xen/xen_inotify.c
@@ -62,7 +62,6 @@ struct xenUnifiedDriver xenInotifyDriver = {
     NULL, /* domainResume */
     NULL, /* domainShutdown */
     NULL, /* domainReboot */
-    NULL, /* domainDestroy */
     NULL, /* domainDestroyFlags */
     NULL, /* domainGetOSType */
     NULL, /* domainGetMaxMemory */
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 7cd6868..cec2e01 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -1546,18 +1546,6 @@ xenDaemonDomainDestroyFlags(virDomainPtr domain,
 }

 /**
- * 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 */
diff --git a/src/xen/xend_internal.h b/src/xen/xend_internal.h
index 4a0cd69..a5dd359 100644
--- a/src/xen/xend_internal.h
+++ b/src/xen/xend_internal.h
@@ -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);
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 7929393..185303b 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -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);
diff --git a/src/xen/xs_internal.c b/src/xen/xs_internal.c
index a08187d..c1b00e5 100644
--- a/src/xen/xs_internal.c
+++ b/src/xen/xs_internal.c
@@ -55,7 +55,6 @@ struct xenUnifiedDriver xenStoreDriver = {
     NULL, /* domainResume */
     xenStoreDomainShutdown, /* domainShutdown */
     xenStoreDomainReboot, /* domainReboot */
-    NULL, /* domainDestroy */
     NULL, /* domainDestroyFlags */
     xenStoreDomainGetOSType, /* domainGetOSType */
     xenStoreDomainGetMaxMemory, /* domainGetMaxMemory */
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 69aab07..dae7e26 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -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,
-- 
1.7.4.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]