From nobody Wed Apr 24 07:19:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1637326463625436.0188862094809; Fri, 19 Nov 2021 04:54:23 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-561-RmHNSuKrO_uYQILO0O-HUw-1; Fri, 19 Nov 2021 07:54:19 -0500 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 90A4687D544; Fri, 19 Nov 2021 12:54: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 75CF9197FC; Fri, 19 Nov 2021 12:54:13 +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 423014EA2F; Fri, 19 Nov 2021 12:54:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AJCmhV4004183 for ; Fri, 19 Nov 2021 07:48:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id E5745404727A; Fri, 19 Nov 2021 12:48:42 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E1C5B4047279 for ; Fri, 19 Nov 2021 12:48:42 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CA5B3185A79C for ; Fri, 19 Nov 2021 12:48:42 +0000 (UTC) Received: from mail-ua1-f47.google.com (mail-ua1-f47.google.com [209.85.222.47]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-362-iFQI-ey2Oymba_no59vSPQ-1; Fri, 19 Nov 2021 07:48:41 -0500 Received: by mail-ua1-f47.google.com with SMTP id p2so20901924uad.11 for ; Fri, 19 Nov 2021 04:48:41 -0800 (PST) Received: from rekt.ibmuc.com ([152.250.208.89]) by smtp.gmail.com with ESMTPSA id s27sm1570629vkl.24.2021.11.19.04.48.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 04:48:40 -0800 (PST) X-MC-Unique: RmHNSuKrO_uYQILO0O-HUw-1 X-MC-Unique: iFQI-ey2Oymba_no59vSPQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FYMXCMfhc1ZLxMXXd0ObSz1OUDrFxpwbtLs5efnxYnc=; b=n+VokDvkFpxXp4YmySiO7uc1firsL/OGpAwvwYxfR3UCUfyrZJf7shV+TuyAEDOobP 42+6QWLZjPOUMQmZPsxgTGMACjoLPTKJTRrdypiDqoj1QKvBojfYPNAKqWXrSi1RsvBg bccpAiwiC1K/Kh5qxySPYA9Vz7uZ1rjSJA15al+xF2NVHXqqvGntTlOlcx0AEF1NtoBX 6lSIJHSv+CdHudFGLhsbLg0gTHTxd7wgo+scY7MxbE04ci2D7RHS5jWDqjSUBJ7ozdHj 1kmFtdDwW5EHZ0TAcpZeTxhvWZnF+FmKIRUfIbyGEFQsSXPM+JAVzlidiyZ3ISyuegVD sfIg== X-Gm-Message-State: AOAM530v+i9XB6Ja4lcyaKkTMds8TfhH7mMCTMMMQksGwlzM8EYsaYk2 tZZ1tatf+jUXpxqKFsJLURq+CKlnQjuLPw== X-Google-Smtp-Source: ABdhPJzjOj3Phw4Fy3xhiv99PB92xn3iOnvrQxP9Gi1w9a8Hr4R1Fe/l0GnBZQyUMXFFAv9tUhPYTQ== X-Received: by 2002:ab0:69c5:: with SMTP id u5mr15891800uaq.92.1637326120441; Fri, 19 Nov 2021 04:48:40 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 1/8] qemu_capabilities.c: add virQEMUCapsParseFlags() Date: Fri, 19 Nov 2021 09:48:23 -0300 Message-Id: <20211119124830.569230-2-danielhb413@gmail.com> In-Reply-To: <20211119124830.569230-1-danielhb413@gmail.com> References: <20211119124830.569230-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-loop: libvir-list@redhat.com Cc: danielhb413@gmail.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-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1637326464149100001 Content-Type: text/plain; charset="utf-8" Create a new helper to remove the parse capabilities flag logic from the body of virQEMUCapsLoadCache(). Signed-off-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_capabilities.c | 61 +++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 67fae46a34..61ec0727cb 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4098,6 +4098,44 @@ virQEMUCapsParseSEVInfo(virQEMUCaps *qemuCaps, xmlXP= athContextPtr ctxt) } =20 =20 +static int +virQEMUCapsParseFlags(virQEMUCaps *qemuCaps, xmlXPathContextPtr ctxt) +{ + g_autofree xmlNodePtr *nodes =3D NULL; + size_t i; + int n; + + if ((n =3D virXPathNodeSet("./flag", ctxt, &nodes)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to parse qemu capabilities flags")); + return -1; + } + + VIR_DEBUG("Got flags %d", n); + for (i =3D 0; i < n; i++) { + g_autofree char *str =3D NULL; + int flag; + + if (!(str =3D virXMLPropString(nodes[i], "name"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing flag name in QEMU capabilities cache= ")); + return -1; + } + + flag =3D virQEMUCapsTypeFromString(str); + if (flag < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown qemu capabilities flag %s"), str); + return -1; + } + + virQEMUCapsSet(qemuCaps, flag); + } + + return 0; +} + + /* * Parsing a doc that looks like * @@ -4197,29 +4235,8 @@ virQEMUCapsLoadCache(virArch hostArch, if (virXPathLongLong("string(./qemumoddirmtime)", ctxt, &l) =3D=3D 0) qemuCaps->modDirMtime =3D (time_t)l; =20 - if ((n =3D virXPathNodeSet("./flag", ctxt, &nodes)) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("failed to parse qemu capabilities flags")); + if (virQEMUCapsParseFlags(qemuCaps, ctxt) < 0) 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); - } - VIR_FREE(nodes); =20 if (virXPathUInt("string(./version)", ctxt, &qemuCaps->version) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", --=20 2.31.1 From nobody Wed Apr 24 07:19:54 2024 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; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com 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 1637326308119184.67926175553237; Fri, 19 Nov 2021 04:51:48 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-324-lliMki5kPgKckH8CmtWh2A-1; Fri, 19 Nov 2021 07:51:43 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 516741017965; Fri, 19 Nov 2021 12:51:37 +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 585335D740; Fri, 19 Nov 2021 12:51:35 +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 572214A703; Fri, 19 Nov 2021 12:51:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AJCmis7004193 for ; Fri, 19 Nov 2021 07:48:44 -0500 Received: by smtp.corp.redhat.com (Postfix) id 27CE9404727A; Fri, 19 Nov 2021 12:48:44 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 23AC44047279 for ; Fri, 19 Nov 2021 12:48:44 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0A35A85A5A8 for ; Fri, 19 Nov 2021 12:48:44 +0000 (UTC) Received: from mail-ua1-f48.google.com (mail-ua1-f48.google.com [209.85.222.48]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-99-AyMriX9BPYeKjG9bHXnP0Q-1; Fri, 19 Nov 2021 07:48:42 -0500 Received: by mail-ua1-f48.google.com with SMTP id p2so20902008uad.11 for ; Fri, 19 Nov 2021 04:48:42 -0800 (PST) Received: from rekt.ibmuc.com ([152.250.208.89]) by smtp.gmail.com with ESMTPSA id s27sm1570629vkl.24.2021.11.19.04.48.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 04:48:41 -0800 (PST) X-MC-Unique: lliMki5kPgKckH8CmtWh2A-1 X-MC-Unique: AyMriX9BPYeKjG9bHXnP0Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oJpvLV09oBMdEAkcMZJTQwzM8o+FpowfT1ZoOBRas5c=; b=zdJ07rOXA96EEz5EdG+Xtx2CHbsPLI3jwh1t9FeNs2C4CSwLRQerqJSGqL7XtgrKVw ANJobuKQUvB1GFmeKmXUgOm1ZbKsPqbtfVQn6xhdUVfVNNStzFeU0FZamB+a69TU/pCA jo1QLyL3BhWe0Kj8d1DXEbLgv09F39327nhxpKxqpr5Wd7UvHoBtMh9py7HQMO+lOhdq p/5nBQL184bi/87bWbkrkeZKIzUaMeTLuFVD4HE8tiK7YQTFrSoFwxQPcbbF4TZzHzMD BxLw5N0LLi1io/ufNIQbJHFguF2JwvMz2c2joqN1KVSqU1v8zwQKQ3M9g4v8DHrondvv ExnQ== X-Gm-Message-State: AOAM531whZcI+1jYqPlWFTKVSrJSzs2kMtORfJ/GU+V90XBPiLyUGUBd Q58EWs6gV1zSKxwGj406VLWFdN8091qI/A== X-Google-Smtp-Source: ABdhPJwI/A1xBS978uz6IxTfpgVXcks0eJ0HLkoFjqcFmCqYc5xIb+2VnRQU15c9y78sILaVI/bEmA== X-Received: by 2002:ab0:7095:: with SMTP id m21mr49008080ual.82.1637326121619; Fri, 19 Nov 2021 04:48:41 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 2/8] qemu_capabilities.c: add virQEMUCapsParseGIC() Date: Fri, 19 Nov 2021 09:48:24 -0300 Message-Id: <20211119124830.569230-3-danielhb413@gmail.com> In-Reply-To: <20211119124830.569230-1-danielhb413@gmail.com> References: <20211119124830.569230-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-loop: libvir-list@redhat.com Cc: danielhb413@gmail.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.15 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-ZM-MESSAGEID: 1637326309681100002 Content-Type: text/plain; charset="utf-8" Create a new helper to remove the GIC parse logic from the body of virQEMUCapsLoadCache(). Signed-off-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_capabilities.c | 142 +++++++++++++++++++---------------- 1 file changed, 77 insertions(+), 65 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 61ec0727cb..38558a9ee0 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4136,6 +4136,82 @@ virQEMUCapsParseFlags(virQEMUCaps *qemuCaps, xmlXPat= hContextPtr ctxt) } =20 =20 +static int +virQEMUCapsParseGIC(virQEMUCaps *qemuCaps, xmlXPathContextPtr ctxt) +{ + g_autofree xmlNodePtr *nodes =3D NULL; + size_t i; + int n; + + if ((n =3D virXPathNodeSet("./gic", ctxt, &nodes)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to parse qemu capabilities gic")); + return -1; + } + + if (n > 0) { + unsigned int uintValue; + bool boolValue; + + qemuCaps->ngicCapabilities =3D n; + qemuCaps->gicCapabilities =3D g_new0(virGICCapability, n); + + for (i =3D 0; i < n; i++) { + virGICCapability *cap =3D &qemuCaps->gicCapabilities[i]; + g_autofree char *version =3D NULL; + g_autofree char *kernel =3D NULL; + g_autofree char *emulated =3D NULL; + + if (!(version =3D virXMLPropString(nodes[i], "version"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing GIC version " + "in QEMU capabilities cache")); + return -1; + } + if (virStrToLong_ui(version, NULL, 10, &uintValue) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("malformed GIC version " + "in QEMU capabilities cache")); + return -1; + } + cap->version =3D uintValue; + + if (!(kernel =3D virXMLPropString(nodes[i], "kernel"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing in-kernel GIC information " + "in QEMU capabilities cache")); + return -1; + } + if (!(boolValue =3D STREQ(kernel, "yes")) && STRNEQ(kernel, "n= o")) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("malformed in-kernel GIC information " + "in QEMU capabilities cache")); + return -1; + } + if (boolValue) + cap->implementation |=3D VIR_GIC_IMPLEMENTATION_KERNEL; + + if (!(emulated =3D virXMLPropString(nodes[i], "emulated"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing emulated GIC information " + "in QEMU capabilities cache")); + return -1; + } + if (!(boolValue =3D STREQ(emulated, "yes")) && STRNEQ(emulated= , "no")) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("malformed emulated GIC information " + "in QEMU capabilities cache")); + return -1; + } + if (boolValue) + cap->implementation |=3D VIR_GIC_IMPLEMENTATION_EMULATED; + } + } + + return 0; +} + + /* * Parsing a doc that looks like * @@ -4164,8 +4240,6 @@ virQEMUCapsLoadCache(virArch hostArch, { g_autoptr(xmlDoc) doc =3D NULL; int ret =3D -1; - size_t i; - int n; xmlNodePtr *nodes =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; char *str =3D NULL; @@ -4293,70 +4367,8 @@ virQEMUCapsLoadCache(virArch hostArch, virQEMUCapsLoadAccel(qemuCaps, ctxt, VIR_DOMAIN_VIRT_QEMU) < 0) goto cleanup; =20 - if ((n =3D virXPathNodeSet("./gic", ctxt, &nodes)) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("failed to parse qemu capabilities gic")); + if (virQEMUCapsParseGIC(qemuCaps, ctxt) < 0) goto cleanup; - } - if (n > 0) { - unsigned int uintValue; - bool boolValue; - - qemuCaps->ngicCapabilities =3D n; - qemuCaps->gicCapabilities =3D g_new0(virGICCapability, n); - - for (i =3D 0; i < n; i++) { - virGICCapability *cap =3D &qemuCaps->gicCapabilities[i]; - - if (!(str =3D virXMLPropString(nodes[i], "version"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing GIC version " - "in QEMU capabilities cache")); - goto cleanup; - } - if (virStrToLong_ui(str, NULL, 10, &uintValue) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("malformed GIC version " - "in QEMU capabilities cache")); - goto cleanup; - } - cap->version =3D uintValue; - VIR_FREE(str); - - if (!(str =3D virXMLPropString(nodes[i], "kernel"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing in-kernel GIC information " - "in QEMU capabilities cache")); - goto cleanup; - } - if (!(boolValue =3D STREQ(str, "yes")) && STRNEQ(str, "no")) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("malformed in-kernel GIC information " - "in QEMU capabilities cache")); - goto cleanup; - } - if (boolValue) - cap->implementation |=3D VIR_GIC_IMPLEMENTATION_KERNEL; - VIR_FREE(str); - - if (!(str =3D virXMLPropString(nodes[i], "emulated"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing emulated GIC information " - "in QEMU capabilities cache")); - goto cleanup; - } - if (!(boolValue =3D STREQ(str, "yes")) && STRNEQ(str, "no")) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("malformed emulated GIC information " - "in QEMU capabilities cache")); - goto cleanup; - } - if (boolValue) - cap->implementation |=3D VIR_GIC_IMPLEMENTATION_EMULATED; - VIR_FREE(str); - } - } - VIR_FREE(nodes); =20 if (virQEMUCapsParseSEVInfo(qemuCaps, ctxt) < 0) goto cleanup; --=20 2.31.1 From nobody Wed Apr 24 07:19:54 2024 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; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com 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 1637326327413922.8321488546651; Fri, 19 Nov 2021 04:52:07 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-498-AC-BMuMfM4q7IT-UK9oqXQ-1; Fri, 19 Nov 2021 07:51:59 -0500 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 72B1987D556; Fri, 19 Nov 2021 12:51: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 5581057CAD; Fri, 19 Nov 2021 12:51: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 26F5D4E9F5; Fri, 19 Nov 2021 12:51:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AJCmmoX004219 for ; Fri, 19 Nov 2021 07:48:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 419E81121318; Fri, 19 Nov 2021 12:48:48 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3D6641121315 for ; Fri, 19 Nov 2021 12:48:45 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 058498032EB for ; Fri, 19 Nov 2021 12:48:45 +0000 (UTC) Received: from mail-ua1-f49.google.com (mail-ua1-f49.google.com [209.85.222.49]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-52-auUwbkfrPz-oMmZsKCKe2A-1; Fri, 19 Nov 2021 07:48:43 -0500 Received: by mail-ua1-f49.google.com with SMTP id i6so20957384uae.6 for ; Fri, 19 Nov 2021 04:48:43 -0800 (PST) Received: from rekt.ibmuc.com ([152.250.208.89]) by smtp.gmail.com with ESMTPSA id s27sm1570629vkl.24.2021.11.19.04.48.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 04:48:42 -0800 (PST) X-MC-Unique: AC-BMuMfM4q7IT-UK9oqXQ-1 X-MC-Unique: auUwbkfrPz-oMmZsKCKe2A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ikR6M7S0Mr+ZNwf13RD8Jl13lsX+IlBLA3Zg9dF7FB8=; b=ViyomH1x7HMhJRRInEjJPrSxuH1eAGLVSOi7QNuH9pXfneRR7XDmUk8TJbdO4KAeFg C4pcJC1myEtdmpdVvzZT43Cb6a0Ev1QkUlJDLOGoRTbRHSOsoTl47oE1gH1cXkQ6QIsf K7rJY1iO8qIKQfXsC6UxZCPK4pQxjJTniQP/RoTztCirDYav+APT6WviTVatzGcpTAQA o5QG/skWI2nt8fCU6Ia0fj73AP8W669qCNkWu9KSpi49kPit/kl4GhAhZcWfuTzcnoxp 2nRDbkZW5O52xq+bOCtRO0zkM7Kxc3h4FvEeXNDkBCR2yDel80AsO2+gGPa0FXw3UGRm da+A== X-Gm-Message-State: AOAM530kzbv/+Pu3NuGTWg1MWYR4HJRjlj0ZUFW5PKoUVsk7sqA3xojF CZQEhYNCrKcuHC4ozQl1iprIxKKLuWPPAg== X-Google-Smtp-Source: ABdhPJxiq0imaGfhCPlctmLj4/n4Aw0iih+txV/CPHbA/g9hJ8MmXFmLOkHfHc+MXiiKdxKsL1f9LA== X-Received: by 2002:ab0:1d10:: with SMTP id j16mr49711530uak.40.1637326122764; Fri, 19 Nov 2021 04:48:42 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 3/8] qemu_capabilities.c: del 'nodes' var from virQEMUCapsLoadCache() Date: Fri, 19 Nov 2021 09:48:25 -0300 Message-Id: <20211119124830.569230-4-danielhb413@gmail.com> In-Reply-To: <20211119124830.569230-1-danielhb413@gmail.com> References: <20211119124830.569230-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: danielhb413@gmail.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-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1637326329276100005 Content-Type: text/plain; charset="utf-8" The 'nodes' var is not being used. Signed-off-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_capabilities.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 38558a9ee0..2523a369d4 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4240,7 +4240,6 @@ virQEMUCapsLoadCache(virArch hostArch, { g_autoptr(xmlDoc) doc =3D NULL; int ret =3D -1; - xmlNodePtr *nodes =3D NULL; g_autoptr(xmlXPathContext) ctxt =3D NULL; char *str =3D NULL; long long int l; @@ -4388,7 +4387,6 @@ virQEMUCapsLoadCache(virArch hostArch, ret =3D 0; cleanup: VIR_FREE(str); - VIR_FREE(nodes); return ret; } =20 --=20 2.31.1 From nobody Wed Apr 24 07:19:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1637326468783261.34876474205623; Fri, 19 Nov 2021 04:54:28 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-225-vyRZmKNtNamthF-BMwBzDg-1; Fri, 19 Nov 2021 07:54:24 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 28F3C87D546; Fri, 19 Nov 2021 12:54:19 +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 0A38C1017CE3; Fri, 19 Nov 2021 12:54:19 +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 D1E581832DD7; Fri, 19 Nov 2021 12:54:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AJCmkZw004207 for ; Fri, 19 Nov 2021 07:48:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 419EA404727A; Fri, 19 Nov 2021 12:48:46 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3DB544047279 for ; Fri, 19 Nov 2021 12:48:46 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 27153805F4A for ; Fri, 19 Nov 2021 12:48:46 +0000 (UTC) Received: from mail-ua1-f54.google.com (mail-ua1-f54.google.com [209.85.222.54]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-460-LN9OhpZ5PVaZCgrfbwElPw-1; Fri, 19 Nov 2021 07:48:44 -0500 Received: by mail-ua1-f54.google.com with SMTP id w23so20973279uao.5 for ; Fri, 19 Nov 2021 04:48:44 -0800 (PST) Received: from rekt.ibmuc.com ([152.250.208.89]) by smtp.gmail.com with ESMTPSA id s27sm1570629vkl.24.2021.11.19.04.48.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 04:48:43 -0800 (PST) X-MC-Unique: vyRZmKNtNamthF-BMwBzDg-1 X-MC-Unique: LN9OhpZ5PVaZCgrfbwElPw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=H3FADXon9mhNAfxaeqfgKig6FubnktdFoNxAuLILbJI=; b=Dahz7LiXUKUxDooDNviJJndFqp3ykHDD3ygq7ea6xZRrcYdichqD4gYLexyGfqOJLI YjtZgaiFtOBvQYb63zPZxLNX/hDlmrVf+6a2LNvzrNf80Twy1je2TytLqd8VVb9kI6uL XsJffzLhZcH5LCffHwiHjnBFHcuPpIxeuly+eBSqyNtWWD1TzNOWtgKExPebP9sFhM9C g+zFka6i+HxR1rkm+OlT9QcpQ8+j7QHge8kbwcqsDcz8eEi7z+EtS3Rs7AwdjO+qVVsc iF9G0J8CQlLfkrq8RgO/ZfvQwqMaO/XWn3mprW79LZE3lLZ3OBWlsMLkbgwL/VJ3wrfM hEWw== X-Gm-Message-State: AOAM530LmNXKqQFtHrAo92HqtfM2GielsWB1pqBEqB6SISQwuuSKazrX rbhlHw59PvbEybUFKRVL47k8jWYe8Pel5A== X-Google-Smtp-Source: ABdhPJwHePwE88Y3JVVn4u7WMZ96GxXSaaOk7wldd3mhwqG1UiKeuQZZMXOHaycHjfuhj5MT/0o4Tg== X-Received: by 2002:ab0:66cd:: with SMTP id d13mr48618237uaq.140.1637326123938; Fri, 19 Nov 2021 04:48:43 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 4/8] qemu_capabilities.c: add virQEMUCapsValidateEmulator() Date: Fri, 19 Nov 2021 09:48:26 -0300 Message-Id: <20211119124830.569230-5-danielhb413@gmail.com> In-Reply-To: <20211119124830.569230-1-danielhb413@gmail.com> References: <20211119124830.569230-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-loop: libvir-list@redhat.com Cc: danielhb413@gmail.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.84 on 10.5.11.22 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-ZM-MESSAGEID: 1637326470503100001 Content-Type: text/plain; charset="utf-8" Create a new helper to remove the emulator validation logic from the body of virQEMUCapsLoadCache(). Signed-off-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_capabilities.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2523a369d4..a0a611da53 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4212,6 +4212,28 @@ virQEMUCapsParseGIC(virQEMUCaps *qemuCaps, xmlXPathC= ontextPtr ctxt) } =20 =20 +static int +virQEMUCapsValidateEmulator(virQEMUCaps *qemuCaps, xmlXPathContextPtr ctxt) +{ + g_autofree char *str =3D NULL; + + if (!(str =3D virXPathString("string(./emulator)", ctxt))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing emulator in QEMU capabilities cache")); + return -1; + } + + if (STRNEQ(str, qemuCaps->binary)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Expected caps for '%s' but saw '%s'"), + qemuCaps->binary, str); + return -1; + } + + return 0; +} + + /* * Parsing a doc that looks like * @@ -4286,18 +4308,9 @@ virQEMUCapsLoadCache(virArch hostArch, goto cleanup; } =20 - if (!(str =3D virXPathString("string(./emulator)", ctxt))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing emulator in QEMU capabilities cache")); - goto cleanup; - } - if (STRNEQ(str, qemuCaps->binary)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Expected caps for '%s' but saw '%s'"), - qemuCaps->binary, str); + if (virQEMUCapsValidateEmulator(qemuCaps, ctxt) < 0) goto cleanup; - } - VIR_FREE(str); + if (virXPathLongLong("string(./qemuctime)", ctxt, &l) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing qemuctime in QEMU capabilities XML")); --=20 2.31.1 From nobody Wed Apr 24 07:19:54 2024 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; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com 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 1637326330725841.9520270854647; Fri, 19 Nov 2021 04:52:10 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-552-BWkv4gkJPryF0Dn3K8sIqA-1; Fri, 19 Nov 2021 07:52:08 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 029E6A40C5; Fri, 19 Nov 2021 12:52:00 +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 D7DD460C81; Fri, 19 Nov 2021 12:51:59 +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 AB7AB1832DD6; Fri, 19 Nov 2021 12:51:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AJCmokF004229 for ; Fri, 19 Nov 2021 07:48:50 -0500 Received: by smtp.corp.redhat.com (Postfix) id F06D4404727A; Fri, 19 Nov 2021 12:48:49 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EC8634047279 for ; Fri, 19 Nov 2021 12:48:49 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D5960185A7B2 for ; Fri, 19 Nov 2021 12:48:49 +0000 (UTC) Received: from mail-ua1-f51.google.com (mail-ua1-f51.google.com [209.85.222.51]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-56-YRwPXyYGOiSGyVwpd0LSxw-1; Fri, 19 Nov 2021 07:48:45 -0500 Received: by mail-ua1-f51.google.com with SMTP id j14so11171641uan.10 for ; Fri, 19 Nov 2021 04:48:45 -0800 (PST) Received: from rekt.ibmuc.com ([152.250.208.89]) by smtp.gmail.com with ESMTPSA id s27sm1570629vkl.24.2021.11.19.04.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 04:48:44 -0800 (PST) X-MC-Unique: BWkv4gkJPryF0Dn3K8sIqA-1 X-MC-Unique: YRwPXyYGOiSGyVwpd0LSxw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AGVcER1Ubc4QFE0UyPQ8TwO486gBs1iFXIZ4DqsgAsQ=; b=kQ6NY8vhdxatp3BnpqloKXbKh7ABTAseAOSGg3T20LrRQHzX5YLmv2qgXGAbHUIMs7 e+bZtrbmMM4MM0sPaaVXj9IvTOVsQCXrL0UTapZEy5i4byW3VzfTo1n8VoRbjkjSAdlU XddBNyNajqjN/Nx4czITHX+YMC6hes2moFxrFrsYCuK/ZdGv5lSEH9IpsxXK6BLavl2b B98GsdNY1kPRROSZfm5/sWXePbZiUh82bch77t0irrPaHotCF8lIkYNFvmBrfakyAE4W KjqFAC2LqQL1XBgJSDrDKLVWJr22YdDgIlietcoCSs5vRVMWhdp1Onb7m9Pespifkevr u8Ww== X-Gm-Message-State: AOAM532BZJXbYNYc8/MlhuPGPP0Xa38zQ+GZjWIOitTP32kE8ErwiIJs Dtkk/UFKiE4jVsOp3JteAKzBTkcBMrZbYA== X-Google-Smtp-Source: ABdhPJwtwJ8aYxYpKnahm6Cz0CSui3B5HZiKjuTbQebFDJl99APea4wsaVzKGOaOrY/HXyFFq7IXDw== X-Received: by 2002:a67:1ac1:: with SMTP id a184mr88797068vsa.22.1637326125213; Fri, 19 Nov 2021 04:48:45 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 5/8] qemu_capabilities.c: add virQEMUCapsValidateArch() Date: Fri, 19 Nov 2021 09:48:27 -0300 Message-Id: <20211119124830.569230-6-danielhb413@gmail.com> In-Reply-To: <20211119124830.569230-1-danielhb413@gmail.com> References: <20211119124830.569230-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-loop: libvir-list@redhat.com Cc: danielhb413@gmail.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.12 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-ZM-MESSAGEID: 1637326331575100003 Content-Type: text/plain; charset="utf-8" Create a new helper to remove the arch validation logic from the body of virQEMUCapsLoadCache(). Signed-off-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_capabilities.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index a0a611da53..6495cb028b 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4234,6 +4234,26 @@ virQEMUCapsValidateEmulator(virQEMUCaps *qemuCaps, x= mlXPathContextPtr ctxt) } =20 =20 +static int +virQEMUCapsValidateArch(virQEMUCaps *qemuCaps, xmlXPathContextPtr ctxt) +{ + g_autofree char *str =3D NULL; + + if (!(str =3D virXPathString("string(./arch)", ctxt))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing arch in QEMU capabilities cache")); + return -1; + } + if (!(qemuCaps->arch =3D virArchFromString(str))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown arch %s in QEMU capabilities cache"), st= r); + return -1; + } + + return 0; +} + + /* * Parsing a doc that looks like * @@ -4357,17 +4377,8 @@ virQEMUCapsLoadCache(virArch hostArch, goto cleanup; } =20 - if (!(str =3D virXPathString("string(./arch)", ctxt))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing arch in QEMU capabilities cache")); + if (virQEMUCapsValidateArch(qemuCaps, ctxt) < 0) goto cleanup; - } - if (!(qemuCaps->arch =3D virArchFromString(str))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown arch %s in QEMU capabilities cache"), st= r); - goto cleanup; - } - VIR_FREE(str); =20 if (virXPathBoolean("boolean(./cpudata)", ctxt) > 0) { qemuCaps->cpuData =3D virCPUDataParseNode(virXPathNode("./cpudata"= , ctxt)); --=20 2.31.1 From nobody Wed Apr 24 07:19:54 2024 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; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com 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 1637326329272520.6445189710404; Fri, 19 Nov 2021 04:52:09 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-494-FqoB-jwJOjCknIY1nop8KA-1; Fri, 19 Nov 2021 07:52:06 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7930EA40D0; Fri, 19 Nov 2021 12:51:57 +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 574425D740; Fri, 19 Nov 2021 12:51:57 +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 297EF1832DD4; Fri, 19 Nov 2021 12:51:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AJCmmvQ004224 for ; Fri, 19 Nov 2021 07:48:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id BF68E4010FFC; Fri, 19 Nov 2021 12:48:48 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BA64640CFD02 for ; Fri, 19 Nov 2021 12:48:48 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A08B980122B for ; Fri, 19 Nov 2021 12:48:48 +0000 (UTC) Received: from mail-ua1-f51.google.com (mail-ua1-f51.google.com [209.85.222.51]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-385-sfTF3gDMOS2wf5pAsdDnXQ-1; Fri, 19 Nov 2021 07:48:46 -0500 Received: by mail-ua1-f51.google.com with SMTP id n6so21043297uak.1 for ; Fri, 19 Nov 2021 04:48:46 -0800 (PST) Received: from rekt.ibmuc.com ([152.250.208.89]) by smtp.gmail.com with ESMTPSA id s27sm1570629vkl.24.2021.11.19.04.48.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 04:48:46 -0800 (PST) X-MC-Unique: FqoB-jwJOjCknIY1nop8KA-1 X-MC-Unique: sfTF3gDMOS2wf5pAsdDnXQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PEZH5hfTrSz3mOuuMp2OS8sASXoCmI05hsW83nkKc1U=; b=tr1FBRnFkesc0hS6fYaP8REVI4A2hnuy5je7D3gpR5WH08ZNa9eSaRQnGb4D3NkExw cToFNapiCDaQU3y0ECPQb3kaZf+L8N9CFvllMR+oIwG4dWWXgC+Z+36J/lkppTAwPTPB 6iwAmKazTz0TPXm2UoACCUQmuEle/S3h7sLdDT2i/ttynDSw3llSrQhAzI2Zsz6OxNNr 6TAP4htS+UdBO6t785ejlhfmCplQwmwPxypvZXbILTrFhjkAZdtdsFhgXhDKfXuY5v+V 4KX3IZWxRYlgNrcLtC4+WdNxOM77eh3eGCoBwgpliFZ1cNmIAYYzCgX2aImID0YGcPch RsNA== X-Gm-Message-State: AOAM532ZxHOrjDkNExa3vS1L8++exACpN/cE0+nlxChJfjzGd2yFo+Be O5jZiekDirN4kGCLT5QCDyJOnorxIo1Y3g== X-Google-Smtp-Source: ABdhPJy/zXWxHBcu4qyp12cAFVmRpP2J7Dkk2Pmyy38FCaMmz7E9ZESrAoTC5jhHc9iBdka1l5h8fg== X-Received: by 2002:a67:b643:: with SMTP id e3mr94975185vsm.33.1637326126294; Fri, 19 Nov 2021 04:48:46 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 6/8] qemu_capabilities.c: remove cleanup label from virQEMUCapsLoadCache() Date: Fri, 19 Nov 2021 09:48:28 -0300 Message-Id: <20211119124830.569230-7-danielhb413@gmail.com> In-Reply-To: <20211119124830.569230-1-danielhb413@gmail.com> References: <20211119124830.569230-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 X-loop: libvir-list@redhat.com Cc: danielhb413@gmail.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.15 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-ZM-MESSAGEID: 1637326331459100001 Content-Type: text/plain; charset="utf-8" 'str' is no longer being used and the 'cleanup' label can be removed together with the 'ret' variable. Signed-off-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_capabilities.c | 42 ++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 6495cb028b..9567ab7662 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4281,17 +4281,15 @@ virQEMUCapsLoadCache(virArch hostArch, bool skipInvalidation) { g_autoptr(xmlDoc) doc =3D NULL; - int ret =3D -1; g_autoptr(xmlXPathContext) ctxt =3D NULL; - char *str =3D NULL; long long int l; unsigned long lu; =20 if (!(doc =3D virXMLParseFile(filename))) - goto cleanup; + return -1; =20 if (!(ctxt =3D virXMLXPathContextNew(doc))) - goto cleanup; + return -1; =20 ctxt->node =3D xmlDocGetRootElement(doc); =20 @@ -4300,13 +4298,13 @@ virQEMUCapsLoadCache(virArch hostArch, _("unexpected root element <%s>, " "expecting "), ctxt->node->name); - goto cleanup; + return -1; } =20 if (virXPathLongLong("string(./selfctime)", ctxt, &l) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing selfctime in QEMU capabilities XML")); - goto cleanup; + return -1; } qemuCaps->libvirtCtime =3D (time_t)l; =20 @@ -4324,17 +4322,16 @@ virQEMUCapsLoadCache(virArch hostArch, (long long)virGetSelfLastChanged(), (unsigned long)qemuCaps->libvirtVersion, (unsigned long)LIBVIR_VERSION_NUMBER); - ret =3D 1; - goto cleanup; + return 1; } =20 if (virQEMUCapsValidateEmulator(qemuCaps, ctxt) < 0) - goto cleanup; + return -1; =20 if (virXPathLongLong("string(./qemuctime)", ctxt, &l) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("missing qemuctime in QEMU capabilities XML")); - goto cleanup; + return -1; } qemuCaps->ctime =3D (time_t)l; =20 @@ -4342,25 +4339,25 @@ virQEMUCapsLoadCache(virArch hostArch, qemuCaps->modDirMtime =3D (time_t)l; =20 if (virQEMUCapsParseFlags(qemuCaps, ctxt) < 0) - goto cleanup; + return -1; =20 if (virXPathUInt("string(./version)", ctxt, &qemuCaps->version) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing version in QEMU capabilities cache")); - goto cleanup; + return -1; } =20 if (virXPathUInt("string(./kvmVersion)", ctxt, &qemuCaps->kvmVersion) = < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing version in QEMU capabilities cache")); - goto cleanup; + return -1; } =20 if (virXPathUInt("string(./microcodeVersion)", ctxt, &qemuCaps->microcodeVersion) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing microcode version in QEMU capabilities c= ache")); - goto cleanup; + return -1; } =20 qemuCaps->hostCPUSignature =3D virXPathString("string(./hostCPUSignatu= re)", ctxt); @@ -4374,27 +4371,27 @@ virQEMUCapsLoadCache(virArch hostArch, if (virXPathBoolean("boolean(./kernelVersion)", ctxt) > 0) { qemuCaps->kernelVersion =3D virXPathString("string(./kernelVersion= )", ctxt); if (!qemuCaps->kernelVersion) - goto cleanup; + return -1; } =20 if (virQEMUCapsValidateArch(qemuCaps, ctxt) < 0) - goto cleanup; + return -1; =20 if (virXPathBoolean("boolean(./cpudata)", ctxt) > 0) { qemuCaps->cpuData =3D virCPUDataParseNode(virXPathNode("./cpudata"= , ctxt)); if (!qemuCaps->cpuData) - goto cleanup; + return -1; } =20 if (virQEMUCapsLoadAccel(qemuCaps, ctxt, VIR_DOMAIN_VIRT_KVM) < 0 || virQEMUCapsLoadAccel(qemuCaps, ctxt, VIR_DOMAIN_VIRT_QEMU) < 0) - goto cleanup; + return -1; =20 if (virQEMUCapsParseGIC(qemuCaps, ctxt) < 0) - goto cleanup; + return -1; =20 if (virQEMUCapsParseSEVInfo(qemuCaps, ctxt) < 0) - goto cleanup; + return -1; =20 virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_KVM); virQEMUCapsInitHostCPUModel(qemuCaps, hostArch, VIR_DOMAIN_VIRT_QEMU); @@ -4408,10 +4405,7 @@ virQEMUCapsLoadCache(virArch hostArch, if (skipInvalidation) qemuCaps->invalidation =3D false; =20 - ret =3D 0; - cleanup: - VIR_FREE(str); - return ret; + return 0; } =20 =20 --=20 2.31.1 From nobody Wed Apr 24 07:19:54 2024 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; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com 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 1637326326425216.417711982318; Fri, 19 Nov 2021 04:52:06 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-154-zouMDJUHOnutbYLymLFMkQ-1; Fri, 19 Nov 2021 07:52:00 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 72B9587D557; Fri, 19 Nov 2021 12:51:54 +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 53D0AADD9; Fri, 19 Nov 2021 12:51: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 2798D181A1D0; Fri, 19 Nov 2021 12:51:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1AJCmqWa004249 for ; Fri, 19 Nov 2021 07:48:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id DDF7551DD; Fri, 19 Nov 2021 12:48:52 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D83AE51DC for ; Fri, 19 Nov 2021 12:48:49 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BC9858027FB for ; Fri, 19 Nov 2021 12:48:49 +0000 (UTC) Received: from mail-ua1-f45.google.com (mail-ua1-f45.google.com [209.85.222.45]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-337-mb3JHMtbMW2jm_-BF1Dg2Q-1; Fri, 19 Nov 2021 07:48:48 -0500 Received: by mail-ua1-f45.google.com with SMTP id n6so21043470uak.1 for ; Fri, 19 Nov 2021 04:48:48 -0800 (PST) Received: from rekt.ibmuc.com ([152.250.208.89]) by smtp.gmail.com with ESMTPSA id s27sm1570629vkl.24.2021.11.19.04.48.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 04:48:47 -0800 (PST) X-MC-Unique: zouMDJUHOnutbYLymLFMkQ-1 X-MC-Unique: mb3JHMtbMW2jm_-BF1Dg2Q-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sQYzvEgQSUcC5EP/EUvIUJ7fRJGITusKpFwokVZiM38=; b=qFKcucOBkEJV/vW5y6WwYsOHGSkngsVwQlQQlBiU/JlWhDwh5OWvMCECwqXCfxueen HjGu8kTLLtVVaQxuxJeEv5gsfTDNIXigHr1PVazCRsddl3MUum0W24mnOVPZp++vWBTz le9C8IzPQKy8LBQc5oDmmKPcV6DnK5K68tjSprcW1BZTQdRdUl8+puVUVC17qna+ThMd FQZKA06+EX78etHE1Oy4mFDOgAXNzlAJDBUCU1HoMT9R2iQyyA/SepWp9SyBZtKvHuJ0 D6+spYrB1I+1m94GlyEtHRmC+5yh2ipbyNKocCovYw8pRdeTsPV9nS4wQwveBA5PaCKL SMnw== X-Gm-Message-State: AOAM532IVKcSnWuK3unRzfuxk1xhBlNjSXXQa9+iYj+Jaj4oUVhfOe64 U6dy1Mi916SDNF4sF61slWTRq7kJ+qbbwg== X-Google-Smtp-Source: ABdhPJzcG/q90D0vT8oG4pCma6T+UCkUyhpmm6mcjFZpZ8aO2oVSoHM/piTJY9aEcA1UC/NEYwsU4A== X-Received: by 2002:a05:6102:3709:: with SMTP id s9mr92915675vst.10.1637326127474; Fri, 19 Nov 2021 04:48:47 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 7/8] cpu_ppc64.c: remove 'guest' param from ppc64Compute() Date: Fri, 19 Nov 2021 09:48:29 -0300 Message-Id: <20211119124830.569230-8-danielhb413@gmail.com> In-Reply-To: <20211119124830.569230-1-danielhb413@gmail.com> References: <20211119124830.569230-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: danielhb413@gmail.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.14 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-ZM-MESSAGEID: 1637326327269100003 Content-Type: text/plain; charset="utf-8" ppc64Compute() is used only once, by virCPUppc64Compare(), which doesn't use the 'guest' parameter. It was last used by an API called 'cpuGuestData' that was dropped by commit 03fa904c0c0cb2. Removing the 'guest' parameter will not only remove unused code from ppc64Compute() but also remove the ppc64MakeCPUData() entirely. Signed-off-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_ppc64.c | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c index c7caaa9608..314d2f7c86 100644 --- a/src/cpu/cpu_ppc64.c +++ b/src/cpu/cpu_ppc64.c @@ -379,32 +379,15 @@ ppc64LoadMap(void) return g_steal_pointer(&map); } =20 -static virCPUData * -ppc64MakeCPUData(virArch arch, - virCPUppc64Data *data) -{ - g_autoptr(virCPUData) cpuData =3D NULL; - - cpuData =3D g_new0(virCPUData, 1); - cpuData->arch =3D arch; - - if (ppc64DataCopy(&cpuData->data.ppc64, data) < 0) - return NULL; - - return g_steal_pointer(&cpuData); -} - static virCPUCompareResult ppc64Compute(virCPUDef *host, const virCPUDef *other, - virCPUData **guestData, char **message) { g_autoptr(virCPUppc64Map) map =3D NULL; g_autoptr(virCPUppc64Model) host_model =3D NULL; g_autoptr(virCPUppc64Model) guest_model =3D NULL; g_autoptr(virCPUDef) cpu =3D NULL; - virArch arch; size_t i; =20 /* Ensure existing configurations are handled correctly */ @@ -431,9 +414,6 @@ ppc64Compute(virCPUDef *host, =20 return VIR_CPU_COMPARE_INCOMPATIBLE; } - arch =3D cpu->arch; - } else { - arch =3D host->arch; } =20 if (cpu->vendor && @@ -506,10 +486,6 @@ ppc64Compute(virCPUDef *host, return VIR_CPU_COMPARE_INCOMPATIBLE; } =20 - if (guestData) - if (!(*guestData =3D ppc64MakeCPUData(arch, &guest_model->data))) - return VIR_CPU_COMPARE_ERROR; - return VIR_CPU_COMPARE_IDENTICAL; } =20 @@ -532,7 +508,7 @@ virCPUppc64Compare(virCPUDef *host, return VIR_CPU_COMPARE_INCOMPATIBLE; } =20 - ret =3D ppc64Compute(host, cpu, NULL, &message); + ret =3D ppc64Compute(host, cpu, &message); =20 if (failIncompatible && ret =3D=3D VIR_CPU_COMPARE_INCOMPATIBLE) { ret =3D VIR_CPU_COMPARE_ERROR; --=20 2.31.1 From nobody Wed Apr 24 07:19:54 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1637326472591696.465695021245; Fri, 19 Nov 2021 04:54:32 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-91-iApjFrrsPLaj871psuMvgg-1; Fri, 19 Nov 2021 07:54:27 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9903A1927802; Fri, 19 Nov 2021 12:54:22 +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 7985A5F4ED; Fri, 19 Nov 2021 12:54:22 +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 485B44EA39; Fri, 19 Nov 2021 12:54:22 +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 1AJCmvCT004260 for ; Fri, 19 Nov 2021 07:48:57 -0500 Received: by smtp.corp.redhat.com (Postfix) id 46D4C2026D46; Fri, 19 Nov 2021 12:48:57 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3FEF12026D5D for ; Fri, 19 Nov 2021 12:48:51 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0AB48801212 for ; Fri, 19 Nov 2021 12:48:51 +0000 (UTC) Received: from mail-ua1-f43.google.com (mail-ua1-f43.google.com [209.85.222.43]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-499-UKGOoNbvO32QOpAbbcF_ww-1; Fri, 19 Nov 2021 07:48:49 -0500 Received: by mail-ua1-f43.google.com with SMTP id j14so11171985uan.10 for ; Fri, 19 Nov 2021 04:48:49 -0800 (PST) Received: from rekt.ibmuc.com ([152.250.208.89]) by smtp.gmail.com with ESMTPSA id s27sm1570629vkl.24.2021.11.19.04.48.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 04:48:48 -0800 (PST) X-MC-Unique: iApjFrrsPLaj871psuMvgg-1 X-MC-Unique: UKGOoNbvO32QOpAbbcF_ww-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o4CJwY7L56/BNhyJPlouLujoJqAciOBgWmuMZ2aJy9Y=; b=DddKCy7p2zm50aX8EW4t5cLtsaeHftEuXm4uHVJ47nJlhnZV1nEJIep/XwybDXm9RK cmyq+uucSZGS75h+WGWhAJ+RzgNOGDfxlxHS2UIqO7rcwf1TdCJcRfv1Xth3644nKaH6 bECjgmxgHzrDwtZlabnNrkwgZ++GWs2+C8MzcGqrQGc++NOOVp5l6/FDcqnX7fOMx8If +lkHBAyQPJMAwh9KV4qjGDazuswKAvtdA5XTsJtllLLZfr87hiPO+KabOK1IR27T71t0 +AFexNKXFA3GC0iOMx7/O0yGPdtlzO2h7RY34TpxNEzUaRTDRePYl8Mt66TQnkSWhfSw cy3g== X-Gm-Message-State: AOAM531S7bF+Rm+JwjYJLdIEu3epQQgr3+Z48PxHNeDSHh/eGqbHJsqj PNejwSgZiKUnJiFmOXgwDhChvTf2/oX9cw== X-Google-Smtp-Source: ABdhPJxlj0mZCJxBKXbOWXl0vgU3Xko3nTlQSj3ZZ88kGVzGYTB1qyukSLzd7kqlOllEmChq83f9GA== X-Received: by 2002:a67:e40d:: with SMTP id d13mr94201138vsf.11.1637326128874; Fri, 19 Nov 2021 04:48:48 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 8/8] qemu_capabilities.c: del 'cleanup' label in virQEMUCapsLoadHostCPUModelInfo() Date: Fri, 19 Nov 2021 09:48:30 -0300 Message-Id: <20211119124830.569230-9-danielhb413@gmail.com> In-Reply-To: <20211119124830.569230-1-danielhb413@gmail.com> References: <20211119124830.569230-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: danielhb413@gmail.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.15 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-ZM-MESSAGEID: 1637326474787100001 Content-Type: text/plain; charset="utf-8" Create extra g_autofree strings and use them in an adequate scope to eliminate the need for VIR_FREE() calls and the 'cleanup' label. Signed-off-by: Daniel Henrique Barboza Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_capabilities.c | 43 +++++++++++++++--------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 9567ab7662..71dabdadd7 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3723,20 +3723,18 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *c= aps, xmlXPathContextPtr ctxt, const char *typeStr) { - char *str =3D NULL; + g_autofree char *migratability =3D NULL; xmlNodePtr hostCPUNode; g_autofree xmlNodePtr *nodes =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) g_autoptr(qemuMonitorCPUModelInfo) hostCPU =3D NULL; g_autofree char *xpath =3D g_strdup_printf("./hostCPU[@type=3D'%s']", = typeStr); - int ret =3D -1; size_t i; int n; int val; =20 if (!(hostCPUNode =3D virXPathNode(xpath, ctxt))) { - ret =3D 0; - goto cleanup; + return 0; } =20 hostCPU =3D g_new0(qemuMonitorCPUModelInfo, 1); @@ -3745,17 +3743,16 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *c= aps, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing host CPU model name in QEMU " "capabilities cache")); - goto cleanup; + return -1; } =20 - if (!(str =3D virXMLPropString(hostCPUNode, "migratability")) || - (val =3D virTristateBoolTypeFromString(str)) <=3D 0) { + if (!(migratability =3D virXMLPropString(hostCPUNode, "migratability")= ) || + (val =3D virTristateBoolTypeFromString(migratability)) <=3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("invalid migratability value for host CPU model")= ); - goto cleanup; + return -1; } hostCPU->migratability =3D val =3D=3D VIR_TRISTATE_BOOL_YES; - VIR_FREE(str); =20 ctxt->node =3D hostCPUNode; =20 @@ -3765,6 +3762,8 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *cap= s, =20 for (i =3D 0; i < n; i++) { qemuMonitorCPUProperty *prop =3D hostCPU->props + i; + g_autofree char *type =3D NULL; + g_autofree char *migratable =3D NULL; =20 ctxt->node =3D nodes[i]; =20 @@ -3772,17 +3771,16 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *c= aps, virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing 'name' attribute for a host CPU" " model property in QEMU capabilities cac= he")); - goto cleanup; + return -1; } =20 - if (!(str =3D virXMLPropString(ctxt->node, "type")) || - (val =3D qemuMonitorCPUPropertyTypeFromString(str)) < 0) { + if (!(type =3D virXMLPropString(ctxt->node, "type")) || + (val =3D qemuMonitorCPUPropertyTypeFromString(type)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing or invalid CPU model property ty= pe " "in QEMU capabilities cache")); - goto cleanup; + return -1; } - VIR_FREE(str); =20 prop->type =3D val; switch (prop->type) { @@ -3798,7 +3796,7 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *cap= s, _("invalid string value for '%s' host C= PU " "model property in QEMU capabilities = cache"), prop->name); - goto cleanup; + return -1; } break; =20 @@ -3809,7 +3807,7 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *cap= s, _("invalid number value for '%s' host C= PU " "model property in QEMU capabilities = cache"), prop->name); - goto cleanup; + return -1; } break; =20 @@ -3817,27 +3815,22 @@ virQEMUCapsLoadHostCPUModelInfo(virQEMUCapsAccel *c= aps, break; } =20 - if ((str =3D virXMLPropString(ctxt->node, "migratable"))) { - if ((val =3D virTristateBoolTypeFromString(str)) <=3D 0) { + if ((migratable =3D virXMLPropString(ctxt->node, "migratable")= )) { + if ((val =3D virTristateBoolTypeFromString(migratable)) <= =3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unknown migratable value for '%s' ho= st " "CPU model property"), prop->name); - goto cleanup; + return -1; } =20 prop->migratable =3D val; - VIR_FREE(str); } } } =20 caps->hostCPU.info =3D g_steal_pointer(&hostCPU); - ret =3D 0; - - cleanup: - VIR_FREE(str); - return ret; + return 0; } =20 =20 --=20 2.31.1