From nobody Tue Feb 10 12:57:43 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1619535925; cv=none; d=zohomail.com; s=zohoarc; b=JqBaRsN4wydEGT1B1oSTBXhaa4wqHr1H4uD2hqeN+6c+BUeMCIsjLHHt0xqdkbGgk9JUY4dRy6UL1X67s2kGxyaBZh52ueD3TBsgME7mLfhwEznOY/fmd/nqN3JxSMQ0+HyNNs5zrBJEuECzUGV/7LklWhnU5IDcOqCXE6HGX88= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619535925; h=Content-Type:Content-Transfer-Encoding:Cc: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=XnqUu/htgWDo+Q7v1HqVPDUdb0Wsh428JAP/aUffgBU=; b=oLeJy29WHYBA6Sll7mO4qSzRu/wrzjm1P9pM3TJW+CDGnezA5whzbwHM1U2kAyv9KAEfwLkxvUOGbSKB2QsygZhpZSO0WggxepXYHSP5/T/6Z8C1gMrs+sQKFKmpUl11ADcXij5B43mCAH4PBJNduoE750z7gXiVaVq7uHNDCxU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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 [170.10.133.124]) by mx.zohomail.com with SMTPS id 1619535925530852.5918271024308; Tue, 27 Apr 2021 08:05:25 -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-592-955KVkcON-Wz82lr2up-Fw-1; Tue, 27 Apr 2021 11:05:19 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 18D20100962D; Tue, 27 Apr 2021 15:05:13 +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 E6FFF4D73A; Tue, 27 Apr 2021 15:05:12 +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 AB3E944A65; Tue, 27 Apr 2021 15:05:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13RF4vh6031932 for ; Tue, 27 Apr 2021 11:04:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id E6D6060CC9; Tue, 27 Apr 2021 15:04:57 +0000 (UTC) Received: from work.redhat.com (ovpn-113-91.ams2.redhat.com [10.36.113.91]) by smtp.corp.redhat.com (Postfix) with ESMTP id 324B860C0F; Tue, 27 Apr 2021 15:04:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619535923; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=XnqUu/htgWDo+Q7v1HqVPDUdb0Wsh428JAP/aUffgBU=; b=G+aKHDeyOrURqQEIbQKmvr5Rlkq4wAENGmxsfwUIG7Dfq3gEJ07IVM8SOgfRr/UCDmQtHF gXhzhxWq81O5iQPO7yXFPTqs355K65h59/R9PT2FQltLFRq13C6M9BVKcWuZdHP8gPnu1c 8bhCgcdMJDKcfPst5wf7CMr1XQrT3FI= X-MC-Unique: 955KVkcON-Wz82lr2up-Fw-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 07/10] virDomainShmemDefParseXML: Use virXMLProp* Date: Tue, 27 Apr 2021 17:04:38 +0200 Message-Id: <20210427150441.206606-8-twiederh@redhat.com> In-Reply-To: <20210427150441.206606-1-twiederh@redhat.com> References: <20210427150441.206606-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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.16 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-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Tim Wiederhake Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 52 ++++++++++-------------------------------- 1 file changed, 12 insertions(+), 40 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 8b2a6dcf58..a6547cad8e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13987,26 +13987,20 @@ virDomainShmemDefParseXML(virDomainXMLOption *xml= opt, xmlNodePtr msi =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) xmlNodePtr server =3D NULL; + xmlNodePtr model; g_autofree char *tmp =3D NULL; =20 def =3D g_new0(virDomainShmemDef, 1); =20 ctxt->node =3D node; =20 - tmp =3D virXPathString("string(./model/@type)", ctxt); - if (tmp) { - int model; + if ((model =3D virXPathNode("./model", ctxt))) { /* If there's none, we will automatically have the first one * (as default). Unfortunately this has to be done for * compatibility reasons. */ - if ((model =3D virDomainShmemModelTypeFromString(tmp)) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Unknown shmem model type '%s'"), tmp); + if (virXMLPropEnum(model, "type", virDomainShmemModelTypeFromStrin= g, + VIR_XML_PROP_NONE, &def->model) < 0) goto cleanup; - } - - def->model =3D model; - VIR_FREE(tmp); } =20 if (!(def->name =3D virXMLPropString(node, "name"))) { @@ -14016,18 +14010,9 @@ virDomainShmemDefParseXML(virDomainXMLOption *xmlo= pt, } =20 if (def->model !=3D VIR_DOMAIN_SHMEM_MODEL_IVSHMEM) { - tmp =3D virXMLPropString(node, "role"); - if (tmp) { - int role; - if ((role =3D virDomainShmemRoleTypeFromString(tmp)) <=3D 0) { - virReportError(VIR_ERR_XML_ERROR, - _("Unknown shmem role type '%s'"), tmp); - goto cleanup; - } - - def->role =3D role; - VIR_FREE(tmp); - } + if (virXMLPropEnum(node, "role", virDomainShmemRoleTypeFromString, + VIR_XML_PROP_NONZERO, &def->role) < 0) + goto cleanup; } =20 if (virParseScaledValue("./size[1]", NULL, ctxt, @@ -14047,26 +14032,13 @@ virDomainShmemDefParseXML(virDomainXMLOption *xml= opt, if ((msi =3D virXPathNode("./msi[1]", ctxt))) { def->msi.enabled =3D true; =20 - if ((tmp =3D virXMLPropString(msi, "vectors")) && - virStrToLong_uip(tmp, NULL, 0, &def->msi.vectors) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("invalid number of vectors for shmem: '%s'"), - tmp); + if (virXMLPropUInt(msi, "vectors", 0, VIR_XML_PROP_NONE, + &def->msi.vectors) < 0) goto cleanup; - } - VIR_FREE(tmp); - - if ((tmp =3D virXMLPropString(msi, "ioeventfd"))) { - int val; =20 - if ((val =3D virTristateSwitchTypeFromString(tmp)) <=3D 0) { - virReportError(VIR_ERR_XML_ERROR, - _("invalid msi ioeventfd setting for shmem:= '%s'"), - tmp); - goto cleanup; - } - def->msi.ioeventfd =3D val; - } + if (virXMLPropTristateSwitch(msi, "ioeventfd", VIR_XML_PROP_NONE, + &def->msi.ioeventfd) < 0) + goto cleanup; } =20 /* msi option is only relevant with a server */ --=20 2.26.3