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

[libvirt] [PATCH 24/40] Simplify the Xen domain start driver method



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

Directly call either the XenD or XM driver when starting
a persistent domain

Signed-off-by: Daniel P. Berrange <berrange redhat com>
---
 src/xen/xen_driver.c    | 20 +++++++-------------
 src/xen/xen_driver.h    |  1 -
 src/xen/xend_internal.c | 20 +-------------------
 src/xen/xm_internal.c   |  4 ----
 4 files changed, 8 insertions(+), 37 deletions(-)

diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index f504539..f6c1891 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -1333,7 +1333,6 @@ static int
 xenUnifiedDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
 {
     xenUnifiedPrivatePtr priv = dom->conn->privateData;
-    int i;
     int ret = -1;
     char *name = NULL;
 
@@ -1344,21 +1343,16 @@ xenUnifiedDomainCreateWithFlags(virDomainPtr dom, unsigned int flags)
         goto cleanup;
 
     if (virFileExists(name)) {
-        if (priv->opened[XEN_UNIFIED_XEND_OFFSET]) {
-            ret = xenDaemonDomainRestore(dom->conn, name);
-            if (ret == 0)
-                unlink(name);
-        }
+        ret = xenDaemonDomainRestore(dom->conn, name);
+        if (ret == 0)
+            unlink(name);
         goto cleanup;
     }
 
-    for (i = 0; i < XEN_UNIFIED_NR_DRIVERS; ++i) {
-        if (priv->opened[i] && drivers[i]->xenDomainCreate &&
-            drivers[i]->xenDomainCreate(dom) == 0) {
-            ret = 0;
-            goto cleanup;
-        }
-    }
+    if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
+        ret = xenXMDomainCreate(dom);
+    else
+        ret = xenDaemonDomainCreate(dom);
 
 cleanup:
     VIR_FREE(name);
diff --git a/src/xen/xen_driver.h b/src/xen/xen_driver.h
index c756dde..e2c0d68 100644
--- a/src/xen/xen_driver.h
+++ b/src/xen/xen_driver.h
@@ -93,7 +93,6 @@ extern int xenRegister (void);
  * structure with direct calls in xen_unified.c.
  */
 struct xenUnifiedDriver {
-    virDrvDomainCreate xenDomainCreate;
     virDrvDomainDefineXML xenDomainDefineXML;
     virDrvDomainUndefine xenDomainUndefine;
     virDrvDomainAttachDeviceFlags xenDomainAttachDeviceFlags;
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index addc547..dcd31de 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -2899,24 +2899,7 @@ xenDaemonDomainDefineXML(virConnectPtr conn, const char *xmlDesc)
 int
 xenDaemonDomainCreate(virDomainPtr domain)
 {
-    xenUnifiedPrivatePtr priv = domain->conn->privateData;
-    int ret;
-    virDomainPtr tmp;
-
-    if (priv->xendConfigVersion < XEND_CONFIG_VERSION_3_0_4)
-        return -1;
-
-    ret = xend_op(domain->conn, domain->name, "op", "start", NULL);
-
-    if (ret != -1) {
-        /* Need to force a refresh of this object's ID */
-        tmp = virDomainLookupByName(domain->conn, domain->name);
-        if (tmp) {
-            domain->id = tmp->id;
-            virDomainFree(tmp);
-        }
-    }
-    return ret;
+    return xend_op(domain->conn, domain->name, "op", "start", NULL);
 }
 
 int
@@ -3378,7 +3361,6 @@ xenDaemonDomainBlockPeek(virDomainPtr domain,
 }
 
 struct xenUnifiedDriver xenDaemonDriver = {
-    .xenDomainCreate = xenDaemonDomainCreate,
     .xenDomainDefineXML = xenDaemonDomainDefineXML,
     .xenDomainUndefine = xenDaemonDomainUndefine,
     .xenDomainAttachDeviceFlags = xenDaemonAttachDeviceFlags,
diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c
index f5348bd..505f959 100644
--- a/src/xen/xm_internal.c
+++ b/src/xen/xm_internal.c
@@ -81,7 +81,6 @@ static int xenXMDomainDetachDeviceFlags(virDomainPtr domain, const char *xml,
 #define XM_XML_ERROR "Invalid xml"
 
 struct xenUnifiedDriver xenXMDriver = {
-    .xenDomainCreate = xenXMDomainCreate,
     .xenDomainDefineXML = xenXMDomainDefineXML,
     .xenDomainUndefine = xenXMDomainUndefine,
     .xenDomainAttachDeviceFlags = xenXMDomainAttachDeviceFlags,
@@ -923,9 +922,6 @@ xenXMDomainCreate(virDomainPtr domain)
     const char *filename;
     xenXMConfCachePtr entry;
 
-    if (domain->id != -1)
-        return -1;
-
     xenUnifiedLock(priv);
 
     if (!(filename = virHashLookup(priv->nameConfigMap, domain->name)))
-- 
1.8.1.4


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