From nobody Sun Feb 8 14:06:37 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 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=1572960551; cv=none; d=zoho.com; s=zohoarc; b=ST0SpMR6ob5d2Z6OfWssP83ksPsVf8QPG6r1JHdVvC0w1/5t6x+T7n7lzO1cCo5fU27c9GblS4CCyqBiDcT5NtGx5mnjmhtF0IjAmKA05hUdi7OBzPOU7Lwd/TuQ6qpItHFEYzET0ZIpmZPXUQbwWm8tbP3S9Fpx8OimxFla2aI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572960551; 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=mhyeTyTQ6jVX8WMn4A8G7iqsUcE79+YYzBOav82SeaY=; b=GfJRyvLwkPRQkI1ZycaextYswUDSYDhHotuvy6mM1PO762SxENPouotpgLLZ3jTHv/gnkj8tjb1gj2qxY4WasNANzoHkl1uZSV1MeZZTFYAjET9/luR8AE5JSBTLIzzGSJu+cNvZR7O0LzXUIgBmcNII81ysKTTBUq1pKDpdKwM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1572960551006540.2151615537638; Tue, 5 Nov 2019 05:29:11 -0800 (PST) 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-210-yIbSRW9wNvGGnOYyhc8DqA-1; Tue, 05 Nov 2019 08:29: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 838D8100551A; Tue, 5 Nov 2019 13:29:02 +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 47E4D60C88; Tue, 5 Nov 2019 13:29:02 +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 E94E24E9F6; Tue, 5 Nov 2019 13:29:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xA5DS13X004059 for ; Tue, 5 Nov 2019 08:28:01 -0500 Received: by smtp.corp.redhat.com (Postfix) id 47483608B6; Tue, 5 Nov 2019 13:28:01 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EC437608B7 for ; Tue, 5 Nov 2019 13:28:00 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 086AE105D7D; Tue, 5 Nov 2019 14:27:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572960550; 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=mhyeTyTQ6jVX8WMn4A8G7iqsUcE79+YYzBOav82SeaY=; b=asTh2eh7uswwq0fnr66/S/OKzapE8kFFW4BDKod6jeflRI+VM56BwInkyf39P/zGJGrWNK kifcMn4jplaMXSFgvdqLHVNexAX9aGoR1In6KaZCjp6A7rYHVOTBlSs1iKCSpzEOYCSwM3 Dvb5FyRhj7r9M5ygex4Z1Pyd+0TJ4Ug= From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 5 Nov 2019 14:27:33 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 35/52] qemu: Refactor virQEMUCapsLoadCache a bit 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 X-MC-Unique: yIbSRW9wNvGGnOYyhc8DqA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" All the code for loading machine type data was moved to a standalone virQEMUCapsLoadMachines function. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- Notes: Version 3: - new patch src/qemu/qemu_capabilities.c | 93 +++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 38 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 0f3c061003..4c0cba6a62 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3554,6 +3554,60 @@ virQEMUCapsLoadCPUModels(virQEMUCapsAccelPtr caps, } =20 =20 +static int +virQEMUCapsLoadMachines(virQEMUCapsPtr qemuCaps, + xmlXPathContextPtr ctxt) +{ + g_autofree xmlNodePtr *nodes =3D NULL; + char *str =3D NULL; + size_t i; + int n; + + if ((n =3D virXPathNodeSet("./machine", ctxt, &nodes)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("failed to parse qemu capabilities machines")); + return -1; + } + + if (n =3D=3D 0) + return 0; + + qemuCaps->nmachineTypes =3D n; + if (VIR_ALLOC_N(qemuCaps->machineTypes, qemuCaps->nmachineTypes) < 0) + return -1; + + for (i =3D 0; i < n; i++) { + if (!(qemuCaps->machineTypes[i].name =3D virXMLPropString(nodes[i]= , "name"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing machine name in QEMU capabilities ca= che")); + return -1; + } + qemuCaps->machineTypes[i].alias =3D virXMLPropString(nodes[i], "al= ias"); + + str =3D virXMLPropString(nodes[i], "maxCpus"); + if (str && + virStrToLong_ui(str, NULL, 10, &(qemuCaps->machineTypes[i].max= Cpus)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("malformed machine cpu count in QEMU capabili= ties cache")); + return -1; + } + VIR_FREE(str); + + str =3D virXMLPropString(nodes[i], "hotplugCpus"); + if (STREQ_NULLABLE(str, "yes")) + qemuCaps->machineTypes[i].hotplugCpus =3D true; + VIR_FREE(str); + + str =3D virXMLPropString(nodes[i], "default"); + if (STREQ_NULLABLE(str, "yes")) + qemuCaps->machineTypes[i].qemuDefault =3D true; + VIR_FREE(str); + } + + return 0; +} + + static int virQEMUCapsLoadAccel(virQEMUCapsPtr qemuCaps, xmlXPathContextPtr ctxt, @@ -3787,45 +3841,8 @@ virQEMUCapsLoadCache(virArch hostArch, virQEMUCapsLoadAccel(qemuCaps, ctxt, VIR_DOMAIN_VIRT_QEMU) < 0) goto cleanup; =20 - if ((n =3D virXPathNodeSet("./machine", ctxt, &nodes)) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("failed to parse qemu capabilities machines")); + if (virQEMUCapsLoadMachines(qemuCaps, ctxt) < 0) goto cleanup; - } - if (n > 0) { - qemuCaps->nmachineTypes =3D n; - if (VIR_ALLOC_N(qemuCaps->machineTypes, qemuCaps->nmachineTypes) <= 0) - goto cleanup; - - for (i =3D 0; i < n; i++) { - if (!(qemuCaps->machineTypes[i].name =3D virXMLPropString(node= s[i], "name"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing machine name in QEMU capabilitie= s cache")); - goto cleanup; - } - qemuCaps->machineTypes[i].alias =3D virXMLPropString(nodes[i],= "alias"); - - str =3D virXMLPropString(nodes[i], "maxCpus"); - if (str && - virStrToLong_ui(str, NULL, 10, &(qemuCaps->machineTypes[i]= .maxCpus)) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("malformed machine cpu count in QEMU capa= bilities cache")); - goto cleanup; - } - VIR_FREE(str); - - str =3D virXMLPropString(nodes[i], "hotplugCpus"); - if (STREQ_NULLABLE(str, "yes")) - qemuCaps->machineTypes[i].hotplugCpus =3D true; - VIR_FREE(str); - - str =3D virXMLPropString(nodes[i], "default"); - if (STREQ_NULLABLE(str, "yes")) - qemuCaps->machineTypes[i].qemuDefault =3D true; - VIR_FREE(str); - } - } - VIR_FREE(nodes); =20 if ((n =3D virXPathNodeSet("./gic", ctxt, &nodes)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list