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

[libvirt] [PATCH 23/40] Simplify the Xen driver define domain driver methods



From: "Daniel P. Berrange" <berrange redhat com>

Directly call either XenD or the XM driver for handling
domain define operations.

Signed-off-by: Daniel P. Berrange <berrange redhat com>
---
 src/xen/xen_driver.c    | 28 ++++++++++------------------
 src/xen/xen_driver.h    |  2 --
 src/xen/xend_internal.c | 18 +++---------------
 src/xen/xend_internal.h |  6 ++++++
 src/xen/xm_internal.c   |  2 --
 5 files changed, 19 insertions(+), 37 deletions(-)

diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index cfdc940..f504539 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -1309,32 +1309,24 @@ xenUnifiedConnectListDefinedDomains(virConnectPtr conn, char **const names,
                                     int maxnames)
 {
     xenUnifiedPrivatePtr priv = conn->privateData;
-    int i;
-    int ret;
-
-    for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
-        if (priv->opened[i] && drivers[i]->xenListDefinedDomains) {
-            ret = drivers[i]->xenListDefinedDomains(conn, names, maxnames);
-            if (ret >= 0) return ret;
-        }
 
-    return -1;
+    if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
+        return xenXMListDefinedDomains(conn, names, maxnames);
+    } else {
+        return xenDaemonListDefinedDomains(conn, names, maxnames);
+    }
 }
 
 static int
 xenUnifiedConnectNumOfDefinedDomains(virConnectPtr conn)
 {
     xenUnifiedPrivatePtr priv = conn->privateData;
-    int i;
-    int ret;
-
-    for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
-        if (priv->opened[i] && drivers[i]->xenNumOfDefinedDomains) {
-            ret = drivers[i]->xenNumOfDefinedDomains(conn);
-            if (ret >= 0) return ret;
-        }
 
-    return -1;
+    if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4) {
+        return xenXMNumOfDefinedDomains(conn);
+    } else {
+        return xenDaemonNumOfDefinedDomains(conn);
+    }
 }
 
 static int
diff --git a/src/xen/xen_driver.h b/src/xen/xen_driver.h
index 4b18b4d..c756dde 100644
--- a/src/xen/xen_driver.h
+++ b/src/xen/xen_driver.h
@@ -93,8 +93,6 @@ extern int xenRegister (void);
  * structure with direct calls in xen_unified.c.
  */
 struct xenUnifiedDriver {
-    virDrvConnectListDefinedDomains xenListDefinedDomains;
-    virDrvConnectNumOfDefinedDomains xenNumOfDefinedDomains;
     virDrvDomainCreate xenDomainCreate;
     virDrvDomainDefineXML xenDomainDefineXML;
     virDrvDomainUndefine xenDomainUndefine;
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 930b882..addc547 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -2938,19 +2938,12 @@ xenDaemonDomainUndefine(virDomainPtr domain)
  *
  * Returns the number of domain found or -1 in case of error
  */
-static int
+int
 xenDaemonNumOfDefinedDomains(virConnectPtr conn)
 {
     struct sexpr *root = NULL;
     int ret = -1;
     struct sexpr *_for_i, *node;
-    xenUnifiedPrivatePtr priv = conn->privateData;
-
-    /* xm_internal.c (the support for defined domains from /etc/xen
-     * config files used by old Xen) will handle this.
-     */
-    if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
-        return -1;
 
     root = sexpr_get(conn, "/xend/domain?state=halted");
     if (root == NULL)
@@ -2971,7 +2964,8 @@ error:
     return ret;
 }
 
-static int
+
+int
 xenDaemonListDefinedDomains(virConnectPtr conn,
                             char **const names,
                             int maxnames)
@@ -2979,10 +2973,6 @@ xenDaemonListDefinedDomains(virConnectPtr conn,
     struct sexpr *root = NULL;
     int i, ret = -1;
     struct sexpr *_for_i, *node;
-    xenUnifiedPrivatePtr priv = conn->privateData;
-
-    if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
-        return -1;
 
     if (maxnames == 0)
         return 0;
@@ -3388,8 +3378,6 @@ xenDaemonDomainBlockPeek(virDomainPtr domain,
 }
 
 struct xenUnifiedDriver xenDaemonDriver = {
-    .xenListDefinedDomains = xenDaemonListDefinedDomains,
-    .xenNumOfDefinedDomains = xenDaemonNumOfDefinedDomains,
     .xenDomainCreate = xenDaemonDomainCreate,
     .xenDomainDefineXML = xenDaemonDomainDefineXML,
     .xenDomainUndefine = xenDaemonDomainUndefine,
diff --git a/src/xen/xend_internal.h b/src/xen/xend_internal.h
index fd661c9..d773ef9 100644
--- a/src/xen/xend_internal.h
+++ b/src/xen/xend_internal.h
@@ -109,6 +109,12 @@ char **xenDaemonListDomainsOld(virConnectPtr xend);
 
 char *xenDaemonDomainGetOSType(virDomainPtr domain);
 
+int xenDaemonNumOfDefinedDomains(virConnectPtr conn);
+int xenDaemonListDefinedDomains(virConnectPtr conn,
+                                char **const names,
+                                int maxnames);
+
+
 virDomainPtr xenDaemonDomainDefineXML(virConnectPtr xend, const char *sexpr);
 int xenDaemonDomainCreate(virDomainPtr domain);
 int xenDaemonDomainUndefine(virDomainPtr domain);
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index fed721a..f5348bd 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -81,8 +81,6 @@ static int xenXMDomainDetachDeviceFlags(virDomainPtr domain, const char *xml,
 #define XM_XML_ERROR "Invalid xml"
 
 struct xenUnifiedDriver xenXMDriver = {
-    .xenListDefinedDomains = xenXMListDefinedDomains,
-    .xenNumOfDefinedDomains = xenXMNumOfDefinedDomains,
     .xenDomainCreate = xenXMDomainCreate,
     .xenDomainDefineXML = xenXMDomainDefineXML,
     .xenDomainUndefine = xenXMDomainUndefine,
-- 
1.8.1.4


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