[libvirt] [PATCH V1 3/4] src/xenconfig: Introduce xen-xl on virsh command line

Kiarie Kahurani davidkiarie4 at gmail.com
Sat Sep 6 21:13:16 UTC 2014


Integrate the xl parser into the xenlight driver

Signed-off-by: Kiarie Kahurani <davidkiarie4 at gmail.com>
---
 src/libxl/libxl_driver.c | 46 ++++++++++++++++++++++++++++++++++------------
 1 file changed, 34 insertions(+), 12 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 67fd7bc6..515ea4d 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -48,6 +48,7 @@
 #include "libxl_migration.h"
 #include "xen_xm.h"
 #include "xen_sxpr.h"
+#include "xen_xl.h"
 #include "virtypedparam.h"
 #include "viruri.h"
 #include "virstring.h"
@@ -67,6 +68,7 @@ VIR_LOG_INIT("libxl.libxl_driver");
 #define LIBXL_DOM_REQ_CRASH    3
 #define LIBXL_DOM_REQ_HALT     4
 
+#define LIBXL_CONFIG_FORMAT_XL "xen-xl"
 #define LIBXL_CONFIG_FORMAT_XM "xen-xm"
 #define LIBXL_CONFIG_FORMAT_SEXPR "xen-sxpr"
 
@@ -2217,7 +2219,17 @@ libxlConnectDomainXMLFromNative(virConnectPtr conn,
     if (virConnectDomainXMLFromNativeEnsureACL(conn) < 0)
         goto cleanup;
 
-    if (STREQ(nativeFormat, LIBXL_CONFIG_FORMAT_XM)) {
+    if (STREQ(nativeFormat, LIBXL_CONFIG_FORMAT_XL)) {
+        if (!(conf = virConfReadMem(nativeConfig, strlen(nativeConfig), 0)))
+            goto cleanup;
+        if (!(def = xenParseXL(conf,
+                               cfg->caps,
+                               cfg->verInfo->xen_version_major))) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("parsing xl config failed"));
+            goto cleanup;
+        }
+    } else if (STREQ(nativeFormat, LIBXL_CONFIG_FORMAT_XM)) {
         if (!(conf = virConfReadMem(nativeConfig, strlen(nativeConfig), 0)))
             goto cleanup;
 
@@ -2244,7 +2256,7 @@ libxlConnectDomainXMLFromNative(virConnectPtr conn,
         goto cleanup;
     }
 
-    xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE);
+    xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE | VIR_DOMAIN_XML_SECURE);
 
  cleanup:
     virDomainDefFree(def);
@@ -2272,21 +2284,31 @@ libxlConnectDomainXMLToNative(virConnectPtr conn, const char * nativeFormat,
     if (virConnectDomainXMLToNativeEnsureACL(conn) < 0)
         goto cleanup;
 
-    if (STRNEQ(nativeFormat, LIBXL_CONFIG_FORMAT_XM)) {
+    if (STREQ(nativeFormat, LIBXL_CONFIG_FORMAT_XL)) {
+        if (!(def = virDomainDefParseString(domainXml,
+                                            cfg->caps, driver->xmlopt,
+                                            1 << VIR_DOMAIN_VIRT_XEN,
+                                            VIR_DOMAIN_XML_INACTIVE)))
+            goto cleanup;
+
+        if (!(conf = xenFormatXL(def, conn, cfg->verInfo->xen_version_major)))
+            goto cleanup;
+    } else if (STREQ(nativeFormat, LIBXL_CONFIG_FORMAT_XM)) {
+        if (!(def = virDomainDefParseString(domainXml,
+                                            cfg->caps, driver->xmlopt,
+                                            1 << VIR_DOMAIN_VIRT_XEN,
+                                            VIR_DOMAIN_XML_INACTIVE)))
+            goto cleanup;
+
+        if (!(conf = xenFormatXM(conn, def, cfg->verInfo->xen_version_major)))
+            goto cleanup;
+    } else {
+
         virReportError(VIR_ERR_INVALID_ARG,
                        _("unsupported config type %s"), nativeFormat);
         goto cleanup;
     }
 
-    if (!(def = virDomainDefParseString(domainXml,
-                                        cfg->caps, driver->xmlopt,
-                                        1 << VIR_DOMAIN_VIRT_XEN,
-                                        VIR_DOMAIN_XML_INACTIVE)))
-        goto cleanup;
-
-    if (!(conf = xenFormatXM(conn, def, cfg->verInfo->xen_version_major)))
-        goto cleanup;
-
     if (VIR_ALLOC_N(ret, len) < 0)
         goto cleanup;
 
-- 
1.8.4.5




More information about the libvir-list mailing list