From nobody Sun Feb 8 21:29:14 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600885293; cv=none; d=zohomail.com; s=zohoarc; b=kXIYclZOfdkfRzMUIUZdW7rhLXH9PvyqmcjZYSHa6e88ATKrSvWNZtn8CjuJXtQ1/VaJyn1DXexEToLOdiAoUCYHfhQa00r8COz//1BTj1FOQFLL51q2dDv13f/g2ZPpehgm3rev//d4aDGdBCZJm6KwCpKVzpHZ0KJ2QyDdJB8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600885293; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CCL5DgNodpQ4keVvLw0F8VIPhmapGLLwfQn8ZVY3vIs=; b=Czz1CMy9Ih+8HnCpDmbXT4tT4o0VKu8RKNBZ6ScMtX1LDJWorerPpu55XlVRXzzF3jnm0SrU75wUSgnpcf1o1FNh3vjlEE15/PGAzFw5SXeHYxRxF3NhlZxVMkJ8SjacIzI7IWO2PI65JNJe2Onwg+/D76k7MeeUSpsXLRBGq5c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1600885293053698.8676177713322; Wed, 23 Sep 2020 11:21:33 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-488-zJAhP_RbPoSfJINCoC97hg-1; Wed, 23 Sep 2020 14:21:29 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C3C8C801001; Wed, 23 Sep 2020 18:21:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9FDBD78816; Wed, 23 Sep 2020 18:21:23 +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 4DF27183D044; Wed, 23 Sep 2020 18:21:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08NILK7k018969 for ; Wed, 23 Sep 2020 14:21:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8E18D5C1DC; Wed, 23 Sep 2020 18:21:20 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 15A895C1C7 for ; Wed, 23 Sep 2020 18:21:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600885291; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=CCL5DgNodpQ4keVvLw0F8VIPhmapGLLwfQn8ZVY3vIs=; b=ZHOk59ojnjo5VUYwxCBIkXgCC2UQOBd2fMgL3ZKKwip7S78YLYRrL/76Mx0bqEmw/saW9u V2YOApWboITA6rl+zuBbqXPs+WViR1bky+K/fkoZcaE3FW9G3oH3sQxlDcviK8pnUnEO8/ NYI6HtJn5HyTUTvFGXCWGN3aK8LIV3I= X-MC-Unique: zJAhP_RbPoSfJINCoC97hg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 3/6] conf: introduce virDomainDefTunablesParse Date: Wed, 23 Sep 2020 20:21:09 +0200 Message-Id: <4c32063535f78edf19141ec0ae023c5142d0a1ed.1600885173.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 129 ++++++++++++++++++++++++----------------- 1 file changed, 75 insertions(+), 54 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2d420458c6..c12cc1f216 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21401,64 +21401,16 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, } =20 =20 -static virDomainDefPtr -virDomainDefParseXML(xmlDocPtr xml, - xmlXPathContextPtr ctxt, - virDomainXMLOptionPtr xmlopt, - unsigned int flags) +static int +virDomainDefTunablesParse(virDomainDefPtr def, + xmlXPathContextPtr ctxt, + virDomainXMLOptionPtr xmlopt, + unsigned int flags) { - xmlNodePtr node =3D NULL; + g_autofree xmlNodePtr *nodes =3D NULL; size_t i, j; int n; - virDomainDefPtr def; - bool uuid_generated =3D false; - bool usb_none =3D false; - bool usb_other =3D false; - bool usb_master =3D false; - g_autofree xmlNodePtr *nodes =3D NULL; - g_autofree char *tmp =3D NULL; =20 - if (flags & VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA) { - g_autofree char *schema =3D NULL; - - schema =3D virFileFindResource("domain.rng", - abs_top_srcdir "/docs/schemas", - PKGDATADIR "/schemas"); - if (!schema) - return NULL; - if (virXMLValidateAgainstSchema(schema, xml) < 0) - return NULL; - } - - if (!(def =3D virDomainDefNew())) - return NULL; - - if (virDomainDefParseIDs(def, ctxt, flags, &uuid_generated) < 0) - goto error; - - if (virDomainDefParseCaps(def, ctxt, xmlopt) < 0) - goto error; - - /* Extract short description of domain (title) */ - def->title =3D virXPathString("string(./title[1])", ctxt); - if (def->title && strchr(def->title, '\n')) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Domain title can't contain newlines")); - goto error; - } - - /* Extract documentation if present */ - def->description =3D virXPathString("string(./description[1])", ctxt); - - /* analysis of security label, done early even though we format it - * late, so devices can refer to this for defaults */ - if (!(flags & VIR_DOMAIN_DEF_PARSE_SKIP_SECLABEL)) { - if (virSecurityLabelDefsParseXML(def, ctxt, xmlopt, flags) =3D=3D = -1) - goto error; - } - - if (virDomainDefParseMemory(def, ctxt) < 0) - goto error; /* Extract blkio cgroup tunables */ if (virXPathUInt("string(./blkiotune/weight)", ctxt, &def->blkio.weight) < 0) @@ -21687,6 +21639,75 @@ virDomainDefParseXML(xmlDocPtr xml, } VIR_FREE(nodes); =20 + return 0; + + error: + return -1; +} + + +static virDomainDefPtr +virDomainDefParseXML(xmlDocPtr xml, + xmlXPathContextPtr ctxt, + virDomainXMLOptionPtr xmlopt, + unsigned int flags) +{ + xmlNodePtr node =3D NULL; + size_t i, j; + int n; + virDomainDefPtr def; + bool uuid_generated =3D false; + bool usb_none =3D false; + bool usb_other =3D false; + bool usb_master =3D false; + g_autofree xmlNodePtr *nodes =3D NULL; + g_autofree char *tmp =3D NULL; + + if (flags & VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA) { + g_autofree char *schema =3D NULL; + + schema =3D virFileFindResource("domain.rng", + abs_top_srcdir "/docs/schemas", + PKGDATADIR "/schemas"); + if (!schema) + return NULL; + if (virXMLValidateAgainstSchema(schema, xml) < 0) + return NULL; + } + + if (!(def =3D virDomainDefNew())) + return NULL; + + if (virDomainDefParseIDs(def, ctxt, flags, &uuid_generated) < 0) + goto error; + + if (virDomainDefParseCaps(def, ctxt, xmlopt) < 0) + goto error; + + /* Extract short description of domain (title) */ + def->title =3D virXPathString("string(./title[1])", ctxt); + if (def->title && strchr(def->title, '\n')) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Domain title can't contain newlines")); + goto error; + } + + /* Extract documentation if present */ + def->description =3D virXPathString("string(./description[1])", ctxt); + + /* analysis of security label, done early even though we format it + * late, so devices can refer to this for defaults */ + if (!(flags & VIR_DOMAIN_DEF_PARSE_SKIP_SECLABEL)) { + if (virSecurityLabelDefsParseXML(def, ctxt, xmlopt, flags) =3D=3D = -1) + goto error; + } + + if (virDomainDefParseMemory(def, ctxt) < 0) + goto error; + + if (virDomainDefTunablesParse(def, ctxt, xmlopt, flags) < 0) + goto error; + if (virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST, &def->cpu)= < 0) goto error; =20 --=20 2.26.2