[PATCH 25/40] Simplify the Xen domain define/undefine driver methods

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

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

Make the domain define/undefine driver methods directly call
into either the XenD or XM drivers

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 src/xen/xen_driver.c    | 24 ++++++++----------------
 src/xen/xen_driver.h    |  2 --
 src/xen/xend_internal.c | 10 ----------
 src/xen/xm_internal.c   |  5 -----
 4 files changed, 8 insertions(+), 33 deletions(-)

diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index f6c1891..6643a97 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -1369,31 +1369,23 @@ static virDomainPtr
 xenUnifiedDomainDefineXML(virConnectPtr conn, const char *xml)
 {
     xenUnifiedPrivatePtr priv = conn->privateData;
-    int i;
-    virDomainPtr ret;
-
-    for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
-        if (priv->opened[i] && drivers[i]->xenDomainDefineXML) {
-            ret = drivers[i]->xenDomainDefineXML(conn, xml);
-            if (ret) return ret;
-        }
 
-    return NULL;
+    if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
+        return xenXMDomainDefineXML(conn, xml);
+    else
+        return xenDaemonDomainDefineXML(conn, xml);
 }
 
 static int
 xenUnifiedDomainUndefineFlags(virDomainPtr dom, unsigned int flags)
 {
     xenUnifiedPrivatePtr priv = dom->conn->privateData;
-    int i;
 
     virCheckFlags(0, -1);
-    for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i)
-        if (priv->opened[i] && drivers[i]->xenDomainUndefine &&
-            drivers[i]->xenDomainUndefine(dom) == 0)
-            return 0;
-
-    return -1;
+    if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
+        return xenXMDomainUndefine(dom);
+    else
+        return xenDaemonDomainUndefine(dom);
 }
 
 static int
diff --git a/src/xen/xen_driver.h b/src/xen/xen_driver.h
index e2c0d68..254c2f5 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 {
-    virDrvDomainDefineXML xenDomainDefineXML;
-    virDrvDomainUndefine xenDomainUndefine;
     virDrvDomainAttachDeviceFlags xenDomainAttachDeviceFlags;
     virDrvDomainDetachDeviceFlags xenDomainDetachDeviceFlags;
     virDrvDomainGetSchedulerType xenDomainGetSchedulerType;
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index dcd31de..f9b43b8 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -2860,9 +2860,6 @@ xenDaemonDomainDefineXML(virConnectPtr conn, const char *xmlDesc)
     xenUnifiedPrivatePtr priv = conn->privateData;
     virDomainDefPtr def;
 
-    if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
-        return NULL;
-
     if (!(def = virDomainDefParseString(xmlDesc, priv->caps, priv->xmlopt,
                                         1 << VIR_DOMAIN_VIRT_XEN,
                                         VIR_DOMAIN_XML_INACTIVE))) {
@@ -2905,11 +2902,6 @@ xenDaemonDomainCreate(virDomainPtr domain)
 int
 xenDaemonDomainUndefine(virDomainPtr domain)
 {
-    xenUnifiedPrivatePtr priv = domain->conn->privateData;
-
-    if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
-        return -1;
-
     return xend_op(domain->conn, domain->name, "op", "delete", NULL);
 }
 
@@ -3361,8 +3353,6 @@ xenDaemonDomainBlockPeek(virDomainPtr domain,
 }
 
 struct xenUnifiedDriver xenDaemonDriver = {
-    .xenDomainDefineXML = xenDaemonDomainDefineXML,
-    .xenDomainUndefine = xenDaemonDomainUndefine,
     .xenDomainAttachDeviceFlags = xenDaemonAttachDeviceFlags,
     .xenDomainDetachDeviceFlags = xenDaemonDetachDeviceFlags,
     .xenDomainGetSchedulerType = xenDaemonGetSchedulerType,
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index 505f959..bb79c63 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 = {
-    .xenDomainDefineXML = xenXMDomainDefineXML,
-    .xenDomainUndefine = xenXMDomainUndefine,
     .xenDomainAttachDeviceFlags = xenXMDomainAttachDeviceFlags,
     .xenDomainDetachDeviceFlags = xenXMDomainDetachDeviceFlags,
 };
@@ -1108,9 +1106,6 @@ xenXMDomainUndefine(virDomainPtr domain)
     xenXMConfCachePtr entry;
     int ret = -1;
 
-    if (domain->id != -1)
-        return -1;
-
     xenUnifiedLock(priv);
 
     if (!(filename = virHashLookup(priv->nameConfigMap, domain->name)))
-- 
1.8.1.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]