From nobody Fri Dec 19 02:49:59 2025 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 ARC-Seal: i=1; a=rsa-sha256; t=1571153774; cv=none; d=zoho.com; s=zohoarc; b=cNbdzZyHYw/bE+P3nMnwqwXuXmQEd3qhbyUk18l5g+kveUTbp3N6WfRpHoPKJD0IWz8DmeHCFuxmXiEJ9qsxebuPcfB47cE7EtXctcotKcCA8YeFyMZCZVnrAx3tt4fuIB4cKsrXAuYPTr9c+73El7WCNTXz1RbDs9nb4s1bidM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571153774; 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=xS47ymss6t+7+Zw1+vuyelreFQOchNQHBtp1+AGj/Kw=; b=lPMdul4vF0bfELX99+0dlZ93ggGCukxdzu2NOhZCCDI0Jvp8Qgaqjz4jbpaid546qoNzjDjKi3oxtHlYn7b6fteIqutMKmqZgr8NzD5wtlPhw9wZ8LrnW9999cGK++mTqqVwlGa82ViQJP9n4FFUE6KyhKqxZbaV+XR4dq3thcA= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1571153774139943.6603497492862; Tue, 15 Oct 2019 08:36:14 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3880911A1F; Tue, 15 Oct 2019 15:36:12 +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 02B55194BB; Tue, 15 Oct 2019 15:36: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 A0136180BAA9; Tue, 15 Oct 2019 15:36:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9FFZIWK024748 for ; Tue, 15 Oct 2019 11:35:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2404360127; Tue, 15 Oct 2019 15:35:18 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A0A806012E for ; Tue, 15 Oct 2019 15:35:17 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id A6354101CE3; Tue, 15 Oct 2019 17:35:09 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 15 Oct 2019 17:34:58 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 22/31] qemu: Probe for default CPU types 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-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 15 Oct 2019 15:36:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" QEMU 4.2.0 will report default CPU types used by each machine type and we will want to start using it. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- Notes: Version 2: - no change except for updated test results src/qemu/qemu_capabilities.c | 15 ++- src/qemu/qemu_monitor.c | 1 + src/qemu/qemu_monitor.h | 1 + src/qemu/qemu_monitor_json.c | 12 +++ .../caps_4.2.0.aarch64.xml | 94 +++++++++---------- .../qemucapabilitiesdata/caps_4.2.0.ppc64.xml | 58 ++++++------ .../qemucapabilitiesdata/caps_4.2.0.s390x.xml | 28 +++--- .../caps_4.2.0.x86_64.xml | 92 +++++++++--------- 8 files changed, 163 insertions(+), 138 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 2a32d575c9..33cd3491b2 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -556,6 +556,7 @@ struct virQEMUCapsMachineType { unsigned int maxCpus; bool hotplugCpus; bool qemuDefault; + char *defaultCPU; }; =20 typedef struct _virQEMUCapsHostCPUData virQEMUCapsHostCPUData; @@ -1638,7 +1639,8 @@ virQEMUCapsPtr virQEMUCapsNewCopy(virQEMUCapsPtr qemu= Caps) ret->nmachineTypes =3D qemuCaps->nmachineTypes; for (i =3D 0; i < qemuCaps->nmachineTypes; i++) { if (VIR_STRDUP(ret->machineTypes[i].name, qemuCaps->machineTypes[i= ].name) < 0 || - VIR_STRDUP(ret->machineTypes[i].alias, qemuCaps->machineTypes[= i].alias) < 0) + VIR_STRDUP(ret->machineTypes[i].alias, qemuCaps->machineTypes[= i].alias) < 0 || + VIR_STRDUP(ret->machineTypes[i].defaultCPU, qemuCaps->machineT= ypes[i].defaultCPU) < 0) goto error; ret->machineTypes[i].maxCpus =3D qemuCaps->machineTypes[i].maxCpus; ret->machineTypes[i].hotplugCpus =3D qemuCaps->machineTypes[i].hot= plugCpus; @@ -1673,6 +1675,7 @@ void virQEMUCapsDispose(void *obj) for (i =3D 0; i < qemuCaps->nmachineTypes; i++) { VIR_FREE(qemuCaps->machineTypes[i].name); VIR_FREE(qemuCaps->machineTypes[i].alias); + VIR_FREE(qemuCaps->machineTypes[i].defaultCPU); } VIR_FREE(qemuCaps->machineTypes); =20 @@ -2406,7 +2409,8 @@ virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCa= ps, mach =3D &(qemuCaps->machineTypes[qemuCaps->nmachineTypes++]); =20 if (VIR_STRDUP(mach->alias, machines[i]->alias) < 0 || - VIR_STRDUP(mach->name, machines[i]->name) < 0) + VIR_STRDUP(mach->name, machines[i]->name) < 0 || + VIR_STRDUP(mach->defaultCPU, machines[i]->defaultCPU) < 0) goto cleanup; =20 mach->maxCpus =3D machines[i]->maxCpus; @@ -3843,6 +3847,8 @@ virQEMUCapsLoadCache(virArch hostArch, if (STREQ_NULLABLE(str, "yes")) qemuCaps->machineTypes[i].qemuDefault =3D true; VIR_FREE(str); + + qemuCaps->machineTypes[i].defaultCPU =3D virXMLPropString(node= s[i], "defaultCPU"); } } VIR_FREE(nodes); @@ -4116,6 +4122,11 @@ virQEMUCapsFormatCache(virQEMUCapsPtr qemuCaps) qemuCaps->machineTypes[i].maxCpus); if (qemuCaps->machineTypes[i].qemuDefault) virBufferAddLit(&buf, " default=3D'yes'"); + + if (qemuCaps->machineTypes[i].defaultCPU) + virBufferEscapeString(&buf, " defaultCPU=3D'%s'", + qemuCaps->machineTypes[i].defaultCPU); + virBufferAddLit(&buf, "/>\n"); } =20 diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 6056219674..6f2d759a78 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3532,6 +3532,7 @@ qemuMonitorMachineInfoFree(qemuMonitorMachineInfoPtr = machine) return; VIR_FREE(machine->name); VIR_FREE(machine->alias); + VIR_FREE(machine->defaultCPU); VIR_FREE(machine); } =20 diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index f2af1badd4..c099321ad1 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1085,6 +1085,7 @@ struct _qemuMonitorMachineInfo { char *alias; unsigned int maxCpus; bool hotplugCpus; + char *defaultCPU; }; =20 int qemuMonitorGetMachines(qemuMonitorPtr mon, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index bc30884223..1309b6a781 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5504,6 +5504,18 @@ int qemuMonitorJSONGetMachines(qemuMonitorPtr mon, =20 ignore_value(virJSONValueObjectGetBoolean(child, "hotpluggable-cpu= s", &info->hotplugCpus)); + + if (virJSONValueObjectHasKey(child, "default-cpu-type")) { + if (!(tmp =3D virJSONValueObjectGetString(child, "default-cpu-= type"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-machines reply has malformed " + "'default-cpu-type' data")); + goto cleanup; + } + + if (VIR_STRDUP(info->defaultCPU, tmp) < 0) + goto cleanup; + } } =20 ret =3D n; diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml b/tests/qemu= capabilitiesdata/caps_4.2.0.aarch64.xml index a416defca0..8addadb564 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.aarch64.xml @@ -246,76 +246,76 @@ - + - - - - + + + + - + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - + + + - - - - - - + + + + + + - + - - - + + + - + - - - - - - + + + + + + - + - - - - + + + + - + - + - + diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml b/tests/qemuca= pabilitiesdata/caps_4.2.0.ppc64.xml index 3ec7686b12..b4ceb6a1e8 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.ppc64.xml @@ -1053,35 +1053,35 @@ - + - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_4.2.0.s390x.xml index 14783c8d1d..3d2ba7983b 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml @@ -3328,18 +3328,18 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml b/tests/qemuc= apabilitiesdata/caps_4.2.0.x86_64.xml index 176613fa2a..e87bb84a9e 100644 --- a/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_4.2.0.x86_64.xml @@ -1904,50 +1904,50 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list