From nobody Sun Feb 8 08:22:17 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1568924869; cv=none; d=zoho.com; s=zohoarc; b=GIDibibqQoL5Q0H+rlCVT9kYX79jj3l48UocJ8zvf/uXKD9MQQeIk1Kp2C5vd3W6C2mUWe4mukPBfH2yKES39n1jT0v1GO4ZzlpaHBxziULINIFwFjchXMhrApE/GG1b3GbF0f5v+z/r4u8w2ouy/jcpJ5DspVvC5vVyywveYFM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568924869; h=Content-Type:Content-Transfer-Encoding:Cc: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:ARC-Authentication-Results; bh=mFQ0Ndus2IG3UCQysK3BEHjxnTfEmfx69kxiH9kzLoI=; b=ceyD+DY3kSp08HS+QZDxoyh3pQT9DQn0ot/5c1RqsZmmwdxoLFIJfKqGrMOT7CD9dLPh2PtVFI1oV/SO56PxVLbq/8IulaDPdiZrvWWNxXj0yMzDFab9WGCMy7idf8b+SS2qR3l6c/RFCtZP4pmU9PgBGMG6q2ciWsEto9xVHK8= 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=fail 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 1568924869655646.5210177144369; Thu, 19 Sep 2019 13:27:49 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id BF5A210CC1FB; Thu, 19 Sep 2019 20:27:47 +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 917A15D9CC; Thu, 19 Sep 2019 20:27:47 +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 D69EF180085A; Thu, 19 Sep 2019 20:27:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8JKPSMt018262 for ; Thu, 19 Sep 2019 16:25:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id EA3C75D713; Thu, 19 Sep 2019 20:25:28 +0000 (UTC) Received: from mx1.redhat.com (ext-mx14.extmail.prod.ext.phx2.redhat.com [10.5.110.43]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6067A5D6B2; Thu, 19 Sep 2019 20:25:24 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E56FD308FBA0; Thu, 19 Sep 2019 20:25:23 +0000 (UTC) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x8JKILkZ136275; Thu, 19 Sep 2019 16:25:23 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 2v4gjc89v8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Sep 2019 16:25:23 -0400 Received: from m0098410.ppops.net (m0098410.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.27/8.16.0.27) with SMTP id x8JKKibi142089; Thu, 19 Sep 2019 16:25:22 -0400 Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 2v4gjc89un-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Sep 2019 16:25:22 -0400 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x8JKPIqf012968; Thu, 19 Sep 2019 20:25:21 GMT Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by ppma04wdc.us.ibm.com with ESMTP id 2v3vc5ga70-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 19 Sep 2019 20:25:21 +0000 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x8JKPLgT48562516 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 19 Sep 2019 20:25:21 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2FAC22805A; Thu, 19 Sep 2019 20:25:21 +0000 (GMT) Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1784E2805C; Thu, 19 Sep 2019 20:25:21 +0000 (GMT) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.76]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 19 Sep 2019 20:25:21 +0000 (GMT) From: Collin Walling To: libvir-list@redhat.com Date: Thu, 19 Sep 2019 16:24:54 -0400 Message-Id: <1568924706-2311-4-git-send-email-walling@linux.ibm.com> In-Reply-To: <1568924706-2311-1-git-send-email-walling@linux.ibm.com> References: <1568924706-2311-1-git-send-email-walling@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-09-19_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1909190172 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 19 Sep 2019 20:25:24 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Thu, 19 Sep 2019 20:25:24 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'walling@linux.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.7 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.43 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: fiuczy@linux.ibm.com, bwalk@linux.ibm.com, jdenemar@redhat.com, danielhb413@gmail.com, david@redhat.com Subject: [libvirt] [PATCH v5 03/15] qemu_monitor: use cpu def instead of char for expansion 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.65]); Thu, 19 Sep 2019 20:27:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" When expanding a CPU model via query-cpu-model-expansion, any features that were a part of the original model are discarded. For exmaple, when expanding modelA with features f1, f2, a full expansion may reveal feature f3, but the expanded model will not include f1 or f2. Let's pass a virCPUDefPtr to the expansion function in preparation for taking features into consideration. Signed-off-by: Collin Walling Reviewed-by: Jiri Denemark --- src/qemu/qemu_capabilities.c | 9 +++++++-- src/qemu/qemu_monitor.c | 7 +++---- src/qemu/qemu_monitor.h | 2 +- src/qemu/qemu_monitor_json.c | 8 ++++---- src/qemu/qemu_monitor_json.h | 2 +- tests/cputest.c | 7 ++++++- 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 9b19930..bc0ac3d 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -2497,6 +2497,7 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps, qemuMonitorCPUModelInfoPtr nonMigratable =3D NULL; virHashTablePtr hash =3D NULL; const char *model; + virCPUDefPtr cpu; qemuMonitorCPUModelExpansionType type; virDomainVirtType virtType; int ret =3D -1; @@ -2512,6 +2513,9 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps, model =3D "host"; } =20 + if (VIR_ALLOC(cpu) < 0 || VIR_STRDUP(cpu->model, model) < 0) + goto cleanup; + /* Some x86_64 features defined in cpu_map.xml use spelling which diff= er * from the one preferred by QEMU. Static expansion would give us only= the * preferred spelling. With new QEMU we always use the QEMU's canonical @@ -2525,12 +2529,12 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps, else type =3D QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC; =20 - if (qemuMonitorGetCPUModelExpansion(mon, type, model, true, &modelInfo= ) < 0) + if (qemuMonitorGetCPUModelExpansion(mon, type, cpu, true, &modelInfo) = < 0) goto cleanup; =20 /* Try to check migratability of each feature. */ if (modelInfo && - qemuMonitorGetCPUModelExpansion(mon, type, model, false, + qemuMonitorGetCPUModelExpansion(mon, type, cpu, false, &nonMigratable) < 0) goto cleanup; =20 @@ -2574,6 +2578,7 @@ virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps, virHashFree(hash); qemuMonitorCPUModelInfoFree(nonMigratable); qemuMonitorCPUModelInfoFree(modelInfo); + virCPUDefFree(cpu); =20 return ret; } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index aa230b3..7b454c2 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3716,16 +3716,15 @@ qemuMonitorCPUDefInfoFree(qemuMonitorCPUDefInfoPtr = cpu) int qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon, qemuMonitorCPUModelExpansionType type, - const char *model_name, + virCPUDefPtr cpu, bool migratable, qemuMonitorCPUModelInfoPtr *model_info) { - VIR_DEBUG("type=3D%d model_name=3D%s migratable=3D%d", - type, model_name, migratable); + VIR_DEBUG("type=3D%d cpu=3D%p migratable=3D%d", type, cpu, migratable); =20 QEMU_CHECK_MONITOR(mon); =20 - return qemuMonitorJSONGetCPUModelExpansion(mon, type, model_name, + return qemuMonitorJSONGetCPUModelExpansion(mon, type, cpu, migratable, model_info); } =20 diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 70000a1..672b4f9 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1157,7 +1157,7 @@ typedef enum { =20 int qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon, qemuMonitorCPUModelExpansionType type, - const char *model_name, + virCPUDefPtr cpu, bool migratable, qemuMonitorCPUModelInfoPtr *model_info= ); =20 diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 3282593..3c6c330 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5782,7 +5782,7 @@ qemuMonitorJSONParseCPUModelProperty(const char *key, =20 =20 static virJSONValuePtr -qemuMonitorJSONMakeCPUModel(const char *model_name, +qemuMonitorJSONMakeCPUModel(virCPUDefPtr cpu, bool migratable) { virJSONValuePtr model =3D NULL; @@ -5791,7 +5791,7 @@ qemuMonitorJSONMakeCPUModel(const char *model_name, if (!(model =3D virJSONValueNewObject())) goto error; =20 - if (virJSONValueObjectAppendString(model, "name", model_name) < 0) + if (virJSONValueObjectAppendString(model, "name", cpu->model) < 0) goto error; =20 if (!migratable) { @@ -5873,7 +5873,7 @@ qemuMonitorJSONParseCPUModel(const char *cpu_name, int qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr mon, qemuMonitorCPUModelExpansionType type, - const char *model_name, + virCPUDefPtr cpu, bool migratable, qemuMonitorCPUModelInfoPtr *model_info) { @@ -5888,7 +5888,7 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr mo= n, =20 *model_info =3D NULL; =20 - if (!(model =3D qemuMonitorJSONMakeCPUModel(model_name, migratable))) + if (!(model =3D qemuMonitorJSONMakeCPUModel(cpu, migratable))) return -1; =20 retry: diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 61e64e8..bdccd36 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -390,7 +390,7 @@ int qemuMonitorJSONGetCPUDefinitions(qemuMonitorPtr mon, =20 int qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr mon, qemuMonitorCPUModelExpansionType t= ype, - const char *model_name, + virCPUDefPtr cpu, bool migratable, qemuMonitorCPUModelInfoPtr *model_= info) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(5); diff --git a/tests/cputest.c b/tests/cputest.c index 7037bcc..3c17ed4 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -481,6 +481,7 @@ cpuTestMakeQEMUCaps(const struct data *data) virQEMUCapsPtr qemuCaps =3D NULL; qemuMonitorTestPtr testMon =3D NULL; qemuMonitorCPUModelInfoPtr model =3D NULL; + virCPUDefPtr cpu =3D NULL; char *json =3D NULL; =20 if (virAsprintf(&json, "%s/cputestdata/%s-cpuid-%s.json", @@ -490,9 +491,12 @@ cpuTestMakeQEMUCaps(const struct data *data) if (!(testMon =3D qemuMonitorTestNewFromFile(json, driver.xmlopt, true= ))) goto error; =20 + if (VIR_ALLOC(cpu) < 0 || VIR_STRDUP(cpu->model, "host") < 0) + goto cleanup; + if (qemuMonitorGetCPUModelExpansion(qemuMonitorTestGetMonitor(testMon), QEMU_MONITOR_CPU_MODEL_EXPANSION_S= TATIC, - "host", true, &model) < 0) + cpu, true, &model) < 0) goto error; =20 if (!(qemuCaps =3D virQEMUCapsNew())) @@ -515,6 +519,7 @@ cpuTestMakeQEMUCaps(const struct data *data) cleanup: qemuMonitorCPUModelInfoFree(model); qemuMonitorTestFree(testMon); + virCPUDefFree(cpu); VIR_FREE(json); =20 return qemuCaps; --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list