From nobody Mon Feb 9 17:56:06 2026 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 --- 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