From: Jim Fehlig Subject: [PATCH V5 3/3] libxl: Add support for parsing/formating Xen XL config Date: Wed, 14 Jan 2015 08:50:53 -0700 Message-ID: <1421250653-22543-4-git-send-email-jfehlig@suse.com> References: <1421250653-22543-1-git-send-email-jfehlig@suse.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1421250653-22543-1-git-send-email-jfehlig@suse.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: libvir-list@redhat.com Cc: Kiarie Kahurani , Jim Fehlig , xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org From: Kiarie Kahurani Now that xenconfig supports parsing and formatting Xen's XL config format, integrate it into the libxl driver's connectDomainXML{From,To}Native functions. Signed-off-by: Kiarie Kahurani Signed-off-by: Jim Fehlig --- No change from V4. src/libxl/libxl_driver.c | 32 ++++++++++++++++++++++++-------- tools/virsh.pod | 8 ++++---- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 82e476a..cad5101 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" @@ -2215,7 +2217,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; @@ -2270,20 +2282,24 @@ libxlConnectDomainXMLToNative(virConnectPtr conn, const char * nativeFormat, if (virConnectDomainXMLToNativeEnsureACL(conn) < 0) goto cleanup; - if (STRNEQ(nativeFormat, LIBXL_CONFIG_FORMAT_XM)) { - 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_DEF_PARSE_INACTIVE))) goto cleanup; - if (!(conf = xenFormatXM(conn, def, cfg->verInfo->xen_version_major))) + if (STREQ(nativeFormat, LIBXL_CONFIG_FORMAT_XL)) { + if (!(conf = xenFormatXL(def, conn, cfg->verInfo->xen_version_major))) + goto cleanup; + } else if (STREQ(nativeFormat, LIBXL_CONFIG_FORMAT_XM)) { + 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 (VIR_ALLOC_N(ret, len) < 0) goto cleanup; diff --git a/tools/virsh.pod b/tools/virsh.pod index 56fe896..abe80c2 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1272,16 +1272,16 @@ in order to get or set the guest time. Convert the file I in the native guest configuration format named by I to a domain XML format. For QEMU/KVM hypervisor, the I argument must be B. For Xen hypervisor, the -I argument may be B or B. For LXC hypervisor, -the I argument must be B. +I argument may be B, B, or B. For +LXC hypervisor, the I argument must be B. =item B I I Convert the file I in domain XML format to the native guest configuration format named by I. For QEMU/KVM hypervisor, the I argument must be B. For Xen hypervisor, the -I argument may be B or B. For LXC hypervisor, -the I argument must be B. +I argument may be B, B, or B. For +LXC hypervisor, the I argument must be B. =item B I I [I<--bypass-cache>] { [I<--live>] | [I<--crash>] | [I<--reset>] } [I<--verbose>] [I<--memory-only>] -- 1.8.4.5