From patchwork Tue Jul 24 21:23:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 142823 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp55708ljj; Tue, 24 Jul 2018 14:23:56 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdaXUTGyJdtEOpm6IjZeCWWmlo/47Qe3OIGsgOZZe8W9vdjU4yMMYxOGYZ5kVl9SorgstpW X-Received: by 2002:ae9:e64c:: with SMTP id x12-v6mr17170321qkl.41.1532467436445; Tue, 24 Jul 2018 14:23:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532467436; cv=none; d=google.com; s=arc-20160816; b=BqIVTkN+0/DfgWtFNOBriP1bZFQergS0746eebQfU9p+GyLNFAIWtSN6E5ihfW94n3 VeypyGtajv5co8+DaQ5CkjcgKFl91DWIa3+eM0xXjAbsSOlgPkUKWAUi72Vv3ci/6OAE aIXiY9GEbW9/lCsXwFW1eA3qXZbmKrwH2MIOSiNpmHBNHo78jusz2XtIFKWpYFbsBnTA 38J2e1cRwNL9kXdB/yCFIPIA4mJTh4BD1tgAKag7GOMLdFgl2+/6ZW2Ao2hwXlXOgYkD sHX2/7fD1mX/9g3uUqxduYCR+paVRglrH0gzdaBAS5qP0UfHLQpsXYLEMFaRfNjr0H+7 rOdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:references :in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=Q3XBH8KytM9Ia6OWcaeWPsLmtQllCevTKUnJVerN47k=; b=pb6NTr7AqE+jwGx3C7f43nn0g2yL6cZTqzMLbj7uNI4eOdNYUY7QyOIXJ1lT81pXKl q6Tk6QKn4fFol0hMzdFMM1L2Ys66a7v0ojkO3S85nC4IP6P+7YqiScLuRnd167DwZd2A eqgcPB9Qz5Hwh2prW5zYcWJwIsR618TxOs90Py3ItwJF5xKD1i5ukJ4Yc0pRTePt1ImC g3B6XNMaAT5mpdNeE6Gwe/CjOwm6hHECbm5XFXoPIxrgQo9XWX3cd0dpvT3rgZ3p2Bmb wGjTkL90VOmMu09KI/+rfyaoT5XItIoH8F/UXNPApkykAUk3tHqCs2w9DF58v1OGH2L0 N2jQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id s82-v6si9059217qkl.76.2018.07.24.14.23.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jul 2018 14:23:56 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CF3053084036; Tue, 24 Jul 2018 21:23:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6B5895DA60; Tue, 24 Jul 2018 21:23:54 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CE5404A460; Tue, 24 Jul 2018 21:23:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6OLNpVC018717 for ; Tue, 24 Jul 2018 17:23:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 626D62026E0E; Tue, 24 Jul 2018 21:23:51 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.bos.redhat.com (wlan-196-187.bos.redhat.com [10.16.196.187]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48AAF2026D68; Tue, 24 Jul 2018 21:23:51 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Tue, 24 Jul 2018 17:23:42 -0400 Message-Id: <005b16b12e4cda51ddc497fa4962a1b794d723d9.1532467269.git.crobinso@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/7] conf: Break out virDomainDefParseCaps X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Tue, 24 Jul 2018 21:23:55 +0000 (UTC) Handles parse virtType, os.type, bootloader bits, arch, machine, emulator Signed-off-by: Cole Robinson --- src/conf/domain_conf.c | 96 +++++++++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 38 deletions(-) -- 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 178c6d2711..7eb5ffc718 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -19114,46 +19114,15 @@ virDomainCachetuneDefParse(virDomainDefPtr def, } -static virDomainDefPtr -virDomainDefParseXML(xmlDocPtr xml, - xmlNodePtr root, - xmlXPathContextPtr ctxt, - virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, - unsigned int flags) +static int +virDomainDefParseCaps(virDomainDefPtr def, + xmlXPathContextPtr ctxt, + virCapsPtr caps, + unsigned int flags) { - xmlNodePtr *nodes = NULL, node = NULL; + int ret = -1; + int virtType; char *tmp = NULL; - size_t i, j; - int n, virtType, gic_version; - long id = -1; - virDomainDefPtr def; - bool uuid_generated = false; - bool usb_none = false; - bool usb_other = false; - bool usb_master = false; - char *netprefix = NULL; - - if (flags & VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA) { - char *schema = virFileFindResource("domain.rng", - abs_topsrcdir "/docs/schemas", - PKGDATADIR "/schemas"); - if (!schema) - return NULL; - if (virXMLValidateAgainstSchema(schema, xml) < 0) { - VIR_FREE(schema); - return NULL; - } - VIR_FREE(schema); - } - - if (!(def = virDomainDefNew())) - return NULL; - - if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) - if (virXPathLong("string(./@id)", ctxt, &id) < 0) - id = -1; - def->id = (int)id; /* Find out what type of virtualization to use */ if (!(tmp = virXMLPropString(ctxt->node, "type"))) { @@ -19239,6 +19208,57 @@ virDomainDefParseXML(xmlDocPtr xml, VIR_FREE(capsdata); } + ret = 0; + error: + VIR_FREE(tmp); + return ret; +} + + +static virDomainDefPtr +virDomainDefParseXML(xmlDocPtr xml, + xmlNodePtr root, + xmlXPathContextPtr ctxt, + virCapsPtr caps, + virDomainXMLOptionPtr xmlopt, + unsigned int flags) +{ + xmlNodePtr *nodes = NULL, node = NULL; + char *tmp = NULL; + size_t i, j; + int n, gic_version; + long id = -1; + virDomainDefPtr def; + bool uuid_generated = false; + bool usb_none = false; + bool usb_other = false; + bool usb_master = false; + char *netprefix = NULL; + + if (flags & VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA) { + char *schema = virFileFindResource("domain.rng", + abs_topsrcdir "/docs/schemas", + PKGDATADIR "/schemas"); + if (!schema) + return NULL; + if (virXMLValidateAgainstSchema(schema, xml) < 0) { + VIR_FREE(schema); + return NULL; + } + VIR_FREE(schema); + } + + if (!(def = virDomainDefNew())) + return NULL; + + if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) + if (virXPathLong("string(./@id)", ctxt, &id) < 0) + id = -1; + def->id = (int)id; + + if (virDomainDefParseCaps(def, ctxt, caps, flags) < 0) + goto error; + /* Extract domain name */ if (!(def->name = virXPathString("string(./name[1])", ctxt))) { virReportError(VIR_ERR_NO_NAME, NULL);