From nobody Sun Feb 8 16:35:52 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 155076378781145.18817493721838; Thu, 21 Feb 2019 07:43:07 -0800 (PST) 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 mx1.redhat.com (Postfix) with ESMTPS id E0A67309D2A3; Thu, 21 Feb 2019 15:43:05 +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 8F98F6049E; Thu, 21 Feb 2019 15:43:05 +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 2D0D11819AFE; Thu, 21 Feb 2019 15:43:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1LFgbYF008289 for ; Thu, 21 Feb 2019 10:42:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id 97CBC1A837; Thu, 21 Feb 2019 15:42:37 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 20AB227CA3 for ; Thu, 21 Feb 2019 15:42:36 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Thu, 21 Feb 2019 16:42:25 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/8] Split out virQEMUCapsSetFromNodes 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 21 Feb 2019 15:43:06 +0000 (UTC) Add a function that will convert the "name" attributes from the passed nodes to QEMU capabilities. Signed-off-by: J=C3=A1n Tomko --- src/qemu/qemu_capabilities.c | 51 +++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 7160860ab4..a355ee2e37 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3442,6 +3442,38 @@ virQEMUCapsParseSEVInfo(virQEMUCapsPtr qemuCaps, xml= XPathContextPtr ctxt) } =20 =20 +static int +virQEMUCapsSetFromNodes(virQEMUCapsPtr qemuCaps, + xmlNodePtr *nodes, + size_t n) +{ + size_t i; + char *str =3D NULL; + int ret =3D -1; + + for (i =3D 0; i < n; i++) { + int flag; + if (!(str =3D virXMLPropString(nodes[i], "name"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing flag name in QEMU capabilities cache= ")); + goto cleanup; + } + flag =3D virQEMUCapsTypeFromString(str); + if (flag < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown qemu capabilities flag %s"), str); + goto cleanup; + } + VIR_FREE(str); + virQEMUCapsSet(qemuCaps, flag); + } + ret =3D 0; + cleanup: + VIR_FREE(str); + return ret; +} + + /* * Parsing a doc that looks like * @@ -3515,22 +3547,9 @@ virQEMUCapsLoadCache(virArch hostArch, goto cleanup; } VIR_DEBUG("Got flags %d", n); - for (i =3D 0; i < n; i++) { - int flag; - if (!(str =3D virXMLPropString(nodes[i], "name"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing flag name in QEMU capabilities cache= ")); - goto cleanup; - } - flag =3D virQEMUCapsTypeFromString(str); - if (flag < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown qemu capabilities flag %s"), str); - goto cleanup; - } - VIR_FREE(str); - virQEMUCapsSet(qemuCaps, flag); - } + + if (virQEMUCapsSetFromNodes(qemuCaps, nodes, n) < 0) + goto cleanup; VIR_FREE(nodes); =20 if (virXPathUInt("string(./version)", ctxt, &qemuCaps->version) < 0) { --=20 2.19.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list