From nobody Mon Apr 29 10:54:46 2024 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=1556310281; cv=none; d=zoho.com; s=zohoarc; b=U6rr9vAFKw91FdVDsygEV2SwTigHD//l9lKQqosA8I7vloY7LeoSA0FmqDjAur0TrEgag3OptunE+CihWv3d72TPB6lSlPOXLHMB9PGbtMFFtRQ6+BEKuXJg+Q7NH6OGkeqltz080pu2amoU0pwhB+16BRLcv1rGfRDQPcb4WGw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556310281; 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=BZ709OEdx1D/KdUr5BKnuhoXzmDXFvtuey78C+HSP78=; b=gNSXa5CXJ7SJItE5h0G/zt7ClZzrBk2vZRTd104ET5R7qBNpbninr8Biz+NWimU8d3XyBzAdWBshrnWiZBOIfVvvnuL1pjLzMAAeLTY6nT49QM+2A23b9/M4dER8XkVgc3AQIY25q5j4/GKv8xcPpaltd7WYDbROJZynR7DgtaA= 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 1556310281164955.1773014890013; Fri, 26 Apr 2019 13:24:41 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D756130BDBD0; Fri, 26 Apr 2019 20:24:39 +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 A7AF1171E6; Fri, 26 Apr 2019 20:24:39 +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 526F93FB14; Fri, 26 Apr 2019 20:24:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x3QKOIsM025031 for ; Fri, 26 Apr 2019 16:24:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 163641001DDD; Fri, 26 Apr 2019 20:24:18 +0000 (UTC) Received: from mx1.redhat.com (ext-mx07.extmail.prod.ext.phx2.redhat.com [10.5.110.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 10F1C1001E71 for ; Fri, 26 Apr 2019 20:24:15 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 4079CC0B2C60 for ; Fri, 26 Apr 2019 20:24:15 +0000 (UTC) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3QKImbU006153 for ; Fri, 26 Apr 2019 16:24:14 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0b-001b2d01.pphosted.com with ESMTP id 2s48wfg6e3-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 26 Apr 2019 16:24:14 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 26 Apr 2019 21:24:13 +0100 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 26 Apr 2019 21:24:10 +0100 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x3QKO9649437508 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 26 Apr 2019 20:24:09 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1574F6A04D; Fri, 26 Apr 2019 20:24:09 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 778736A047; Fri, 26 Apr 2019 20:24:08 +0000 (GMT) Received: from collin-T470p.pok.ibm.com (unknown [9.56.58.88]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 26 Apr 2019 20:24:08 +0000 (GMT) From: walling@linux.ibm.com To: libvir-list@redhat.com Date: Fri, 26 Apr 2019 16:22:49 -0400 In-Reply-To: <1556310176-27835-1-git-send-email-walling@linux.ibm.com> References: <1556310176-27835-1-git-send-email-walling@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19042620-0004-0000-0000-0000150478E2 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011000; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000285; SDB=6.01194795; UDB=6.00626450; IPR=6.00975631; MB=3.00026612; MTD=3.00000008; XFM=3.00000015; UTC=2019-04-26 20:24:12 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19042620-0005-0000-0000-00008B6AC1AD Message-Id: <1556310176-27835-2-git-send-email-walling@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-04-26_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 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-1810050000 definitions=main-1904260135 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 26 Apr 2019 20:24:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 26 Apr 2019 20:24:15 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'walling@linux.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.346 (KHOP_DYNAMIC, RCVD_IN_DNSWL_LOW, SPF_PASS) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.31 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: bwalk@linux.ibm.com, jdenemar@redhat.com, danielhb413@gmail.com, Collin Walling , david@redhat.com Subject: [libvirt] [PATCH v2 1/8] qemu_monitor: helper functions for CPU models 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 26 Apr 2019 20:24:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" From: Collin Walling Refactor some code in qemuMonitorJSONGetCPUModelExpansion to be later used for the comparison and baseline functions. This does not alter any functionality. Signed-off-by: Collin Walling Reviewed-by: Bjoern Walk Tested-by: Daniel Henrique Barboza --- src/qemu/qemu_monitor_json.c | 170 ++++++++++++++++++++++++++++++---------= ---- 1 file changed, 118 insertions(+), 52 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 908967f..9618d8e 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5513,6 +5513,118 @@ qemuMonitorJSONParseCPUModelProperty(const char *ke= y, return 0; } =20 + +static virJSONValuePtr +qemuMonitorJSONMakeCPUModel(const char *model_name, + size_t nprops, + virCPUFeatureDefPtr props, + bool migratable) +{ + virJSONValuePtr value; + virJSONValuePtr feats =3D NULL; + size_t i; + + if (!(value =3D virJSONValueNewObject())) + goto cleanup; + + if (virJSONValueObjectAppendString(value, "name", model_name) < 0) + goto cleanup; + + if (nprops || !migratable) { + if (!(feats =3D virJSONValueNewObject())) + goto cleanup; + + for (i =3D 0; i < nprops; i++) { + char *name =3D props[i].name; + bool enabled =3D false; + + if (props[i].policy =3D=3D VIR_CPU_FEATURE_REQUIRE || + props[i].policy =3D=3D VIR_CPU_FEATURE_FORCE) + enabled =3D true; + + if (virJSONValueObjectAppendBoolean(feats, name, enabled) < 0) + goto cleanup; + } + + if (!migratable) { + if (virJSONValueObjectAppendBoolean(feats, "migratable", false= ) < 0) + goto cleanup; + } + + if (virJSONValueObjectAppend(value, "props", feats) < 0) + goto cleanup; + } + + return value; + + cleanup: + virJSONValueFree(value); + virJSONValueFree(feats); + return NULL; +} + + +static int +qemuMonitorJSONParseCPUModelData(virJSONValuePtr data, + virJSONValuePtr *cpu_model, + virJSONValuePtr *cpu_props, + const char **cpu_name) +{ + if (!(*cpu_model =3D virJSONValueObjectGetObject(data, "model"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("QMP command reply data was missing 'model'")); + return -1; + } + + if (!(*cpu_name =3D virJSONValueObjectGetString(*cpu_model, "name"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("QMP command reply data was missing 'name'")); + return -1; + } + + if (!(*cpu_props =3D virJSONValueObjectGetObject(*cpu_model, "props"))= ) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("QMP command reply data was missing 'props'")); + return -1; + } + + return 0; +} + + +static int +qemuMonitorJSONParseCPUModel(const char *cpu_name, + virJSONValuePtr cpu_props, + qemuMonitorCPUModelInfoPtr *model_info) +{ + qemuMonitorCPUModelInfoPtr machine_model =3D NULL; + int ret =3D -1; + + if (VIR_ALLOC(machine_model) < 0) + goto cleanup; + + if (VIR_STRDUP(machine_model->name, cpu_name) < 0) + goto cleanup; + + if (cpu_props) { + if (VIR_ALLOC_N(machine_model->props, virJSONValueObjectKeysNumber= (cpu_props)) < 0) + goto cleanup; + + if (virJSONValueObjectForeachKeyValue(cpu_props, + qemuMonitorJSONParseCPUModel= Property, + machine_model) < 0) + goto cleanup; + } + + VIR_STEAL_PTR(*model_info, machine_model); + ret =3D 0; + + cleanup: + qemuMonitorCPUModelInfoFree(machine_model); + return ret; +} + + int qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr mon, qemuMonitorCPUModelExpansionType type, @@ -5521,33 +5633,20 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr = mon, qemuMonitorCPUModelInfoPtr *model_info) { int ret =3D -1; - virJSONValuePtr model =3D NULL; - virJSONValuePtr props =3D NULL; + virJSONValuePtr model; virJSONValuePtr cmd =3D NULL; virJSONValuePtr reply =3D NULL; virJSONValuePtr data; virJSONValuePtr cpu_model; - virJSONValuePtr cpu_props; - qemuMonitorCPUModelInfoPtr machine_model =3D NULL; - char const *cpu_name; + virJSONValuePtr cpu_props =3D NULL; + const char *cpu_name =3D ""; const char *typeStr =3D ""; =20 *model_info =3D NULL; =20 - if (!(model =3D virJSONValueNewObject())) + if (!(model =3D qemuMonitorJSONMakeCPUModel(model_name, 0, NULL, migra= table))) goto cleanup; =20 - if (virJSONValueObjectAppendString(model, "name", model_name) < 0) - goto cleanup; - - if (!migratable) { - if (!(props =3D virJSONValueNewObject()) || - virJSONValueObjectAppendBoolean(props, "migratable", false) < = 0 || - virJSONValueObjectAppend(model, "props", props) < 0) - goto cleanup; - props =3D NULL; - } - retry: switch (type) { case QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC: @@ -5583,11 +5682,8 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr m= on, =20 data =3D virJSONValueObjectGetObject(reply, "return"); =20 - if (!(cpu_model =3D virJSONValueObjectGetObject(data, "model"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("query-cpu-model-expansion reply data was missing= 'model'")); + if (qemuMonitorJSONParseCPUModelData(data, &cpu_model, &cpu_props, &cp= u_name) < 0) goto cleanup; - } =20 /* QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL requests "full" expans= ion * on the result of the initial "static" expansion. @@ -5602,42 +5698,12 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr = mon, goto retry; } =20 - if (!(cpu_name =3D virJSONValueObjectGetString(cpu_model, "name"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("query-cpu-model-expansion reply data was missing= 'name'")); - goto cleanup; - } - - if (!(cpu_props =3D virJSONValueObjectGetObject(cpu_model, "props"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("query-cpu-model-expansion reply data was missing= 'props'")); - goto cleanup; - } - - if (VIR_ALLOC(machine_model) < 0) - goto cleanup; - - if (VIR_STRDUP(machine_model->name, cpu_name) < 0) - goto cleanup; - - if (VIR_ALLOC_N(machine_model->props, virJSONValueObjectKeysNumber(cpu= _props)) < 0) - goto cleanup; - - if (virJSONValueObjectForeachKeyValue(cpu_props, - qemuMonitorJSONParseCPUModelProp= erty, - machine_model) < 0) - goto cleanup; - - ret =3D 0; - *model_info =3D machine_model; - machine_model =3D NULL; + ret =3D qemuMonitorJSONParseCPUModel(cpu_name, cpu_props, model_info); =20 cleanup: - qemuMonitorCPUModelInfoFree(machine_model); virJSONValueFree(cmd); virJSONValueFree(reply); virJSONValueFree(model); - virJSONValueFree(props); return ret; } =20 --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 10:54:46 2024 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=1556310277; cv=none; d=zoho.com; s=zohoarc; b=hhXPv5PRRfj8VaK0CQK7v66Wf0/reeqyu5hayDC+mozZALDhPesxeRkZTQDsbDGpK9OjMy+sODZdfvrPAwjtGMIjpIqfMwacdRZAPbkPT5zHhhi0yPbozgfAgJQm9Kz4xm00PHRc4iErdht+mD7smqx+59OXyGo2MpVPp9S+Ssw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556310277; 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=UIPDHaI5h+a946yric4g9simvok7Sj9hH9dWuFoI7kI=; b=CRa/aknToB97opO+6Nus0Ta1VaF2iNi7JcQI6o9zPBmH4eCyP3seZz/iX9mZCs0wiv6AQAfB2sahvc5LXGdk7zzULe6rqmQchUUyLgLOx3pCa+eQ4E3VoyxoSvrJnQv6tVjE3DigcNEg7LtKm33Ox5IgR+uA5F4m8lN7XbqbFNo= 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 1556310277522564.7580398166454; Fri, 26 Apr 2019 13:24:37 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 760603088B87; Fri, 26 Apr 2019 20:24:36 +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 510761001DDB; Fri, 26 Apr 2019 20:24:36 +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 0C20D8E1F; Fri, 26 Apr 2019 20:24:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x3QKOIAh025032 for ; Fri, 26 Apr 2019 16:24:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 16C891001E81; Fri, 26 Apr 2019 20:24:18 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 111E11001E87 for ; Fri, 26 Apr 2019 20:24:16 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 E8146C0885F3 for ; Fri, 26 Apr 2019 20:24:15 +0000 (UTC) Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3QKJj7c060943 for ; Fri, 26 Apr 2019 16:24:15 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0b-001b2d01.pphosted.com with ESMTP id 2s46kfevux-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 26 Apr 2019 16:24:15 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 26 Apr 2019 21:24:14 +0100 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 26 Apr 2019 21:24:11 +0100 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x3QKO9dh12058902 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 26 Apr 2019 20:24:10 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CD1EB6A047; Fri, 26 Apr 2019 20:24:09 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3C3A26A04F; Fri, 26 Apr 2019 20:24:09 +0000 (GMT) Received: from collin-T470p.pok.ibm.com (unknown [9.56.58.88]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 26 Apr 2019 20:24:09 +0000 (GMT) From: walling@linux.ibm.com To: libvir-list@redhat.com Date: Fri, 26 Apr 2019 16:22:50 -0400 In-Reply-To: <1556310176-27835-1-git-send-email-walling@linux.ibm.com> References: <1556310176-27835-1-git-send-email-walling@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19042620-0020-0000-0000-00000EDD7B2C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011000; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000285; SDB=6.01194795; UDB=6.00626450; IPR=6.00975631; MB=3.00026612; MTD=3.00000008; XFM=3.00000015; UTC=2019-04-26 20:24:13 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19042620-0021-0000-0000-00006594AA57 Message-Id: <1556310176-27835-3-git-send-email-walling@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-04-26_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 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-1810050000 definitions=main-1904260135 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 26 Apr 2019 20:24:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 26 Apr 2019 20:24:16 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'walling@linux.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.346 (KHOP_DYNAMIC, RCVD_IN_DNSWL_LOW, SPF_PASS) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: bwalk@linux.ibm.com, jdenemar@redhat.com, danielhb413@gmail.com, Collin Walling , david@redhat.com Subject: [libvirt] [PATCH v2 2/8] qemu_monitor: implement query-cpu-model-baseline 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 26 Apr 2019 20:24:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" From: Collin Walling Interfaces with QEMU to baseline CPU models. The command takes two CPU models, A and B, that are given a model name and an optional list of CPU features. Through the query-cpu-model-baseline command issued via QMP, a result is produced that contains a new baselined CPU model that is guaranteed to run on both A and B. Signed-off-by: Collin Walling Reviewed-by: Daniel Henrique Barboza Tested-by: Daniel Henrique Barboza --- src/qemu/qemu_monitor.c | 22 +++++++++++++++++ src/qemu/qemu_monitor.h | 9 +++++++ src/qemu/qemu_monitor_json.c | 58 ++++++++++++++++++++++++++++++++++++++++= ++++ src/qemu/qemu_monitor_json.h | 10 ++++++++ 4 files changed, 99 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index e1fcbac..10e312c 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3684,6 +3684,28 @@ qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon, } =20 =20 +int +qemuMonitorGetCPUModelBaseline(qemuMonitorPtr mon, + const char *model_a_name, + int model_a_nprops, + virCPUFeatureDefPtr model_a_props, + const char *model_b_name, + int model_b_nprops, + virCPUFeatureDefPtr model_b_props, + qemuMonitorCPUModelInfoPtr *model_result) +{ + VIR_DEBUG("model_a_name=3D%s model_a_nprops=3D%d model_b_name=3D%s mod= el_b_nprops=3D%d", + model_a_name, model_a_nprops, model_b_name, model_b_nprops); + + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONGetCPUModelBaseline(mon, model_a_name, model_a_n= props, + model_a_props, model_b_name, + model_b_nprops, model_b_prop= s, + model_result); +} + + void qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info) { diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 9242d37..637a6c6 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1066,6 +1066,15 @@ int qemuMonitorGetCPUModelExpansion(qemuMonitorPtr m= on, =20 void qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info); =20 +int qemuMonitorGetCPUModelBaseline(qemuMonitorPtr mon, + const char *model_a_name, + int model_a_nprops, + virCPUFeatureDefPtr model_a_props, + const char *model_b_name, + int model_b_nprops, + virCPUFeatureDefPtr model_b_props, + qemuMonitorCPUModelInfoPtr *model_resul= t); + qemuMonitorCPUModelInfoPtr qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig); =20 diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 9618d8e..6c17913 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5708,6 +5708,64 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr m= on, } =20 =20 +int +qemuMonitorJSONGetCPUModelBaseline(qemuMonitorPtr mon, + const char *model_a_name, + int model_a_nprops, + virCPUFeatureDefPtr model_a_props, + const char *model_b_name, + int model_b_nprops, + virCPUFeatureDefPtr model_b_props, + qemuMonitorCPUModelInfoPtr *model_resul= t) +{ + int ret =3D -1; + virJSONValuePtr model_a; + virJSONValuePtr model_b =3D NULL; + virJSONValuePtr cmd =3D NULL; + virJSONValuePtr reply =3D NULL; + virJSONValuePtr data; + virJSONValuePtr cpu_model; + virJSONValuePtr cpu_props =3D NULL; + const char *cpu_name =3D ""; + qemuMonitorCPUModelInfoPtr baseline =3D NULL; + + if (!(model_a =3D qemuMonitorJSONMakeCPUModel(model_a_name, model_a_np= rops, model_a_props, true)) || + !(model_b =3D qemuMonitorJSONMakeCPUModel(model_b_name, model_b_np= rops, model_b_props, true))) + goto cleanup; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("query-cpu-model-baseline", + "a:modela", &model_a, + "a:modelb", &model_b, + NULL))) + goto cleanup; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + goto cleanup; + + if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0) + goto cleanup; + + data =3D virJSONValueObjectGetObject(reply, "return"); + + if (qemuMonitorJSONParseCPUModelData(data, &cpu_model, &cpu_props, &cp= u_name) < 0) + goto cleanup; + + if (qemuMonitorJSONParseCPUModel(cpu_name, cpu_props, &baseline) < 0) + goto cleanup; + + VIR_STEAL_PTR(*model_result, baseline); + ret =3D 0; + + cleanup: + qemuMonitorCPUModelInfoFree(baseline); + virJSONValueFree(cmd); + virJSONValueFree(reply); + virJSONValueFree(model_a); + virJSONValueFree(model_b); + return ret; +} + + int qemuMonitorJSONGetCommands(qemuMonitorPtr mon, char ***commands) { diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 746b707..77b69af 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -367,6 +367,16 @@ int qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr= mon, qemuMonitorCPUModelInfoPtr *model_= info) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(5); =20 +int qemuMonitorJSONGetCPUModelBaseline(qemuMonitorPtr mon, + const char *model_a_name, + int model_a_nprops, + virCPUFeatureDefPtr model_a_props, + const char *model_b_name, + int model_b_nprops, + virCPUFeatureDefPtr model_b_props, + qemuMonitorCPUModelInfoPtr *model_r= esult) + ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5) ATTRIBUTE_NONNULL(8); + int qemuMonitorJSONGetCommands(qemuMonitorPtr mon, char ***commands) ATTRIBUTE_NONNULL(2); --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 10:54:46 2024 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=1556310494; cv=none; d=zoho.com; s=zohoarc; b=jchftCjSH7iAehLsatclZJvNpjH9g2KAoXOICNJyCU7KBuSd5/VvPRPcWFTkeSECpnI4DF6y8HqfFwver547kVKu8VWVaQE71MfojLBQBneWBjLOAYI9m+/fx6jJiRlajVnzwMNmJiZTik9TYiwHftW1yoSBFEXhI4+1BY2JXvI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556310494; 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=xKFfJDwQgHsyEOLnLi/gLkZyFmfcL5FjUXsIYOp+I4s=; b=LpJ72digWhqAIF1bK5cbR9aRO0iB8WEOzG9URH9SO9SxsN7oI+sDzxmnn1ULH4iKayQkGYcL7A65N6brXAFvJehnqOHPfHU5up8lEIyU58yZrBGXJ6WEvquVQSjhCs0sMEMAu9019Xn9T6ntpZTpeAKAZXCs6O/I8XuKLQ65zTk= 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 1556310494676310.2153829039464; Fri, 26 Apr 2019 13:28:14 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6058030B4A18; Fri, 26 Apr 2019 20:28:13 +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 E3504608AC; Fri, 26 Apr 2019 20:28: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 A03B4181AC92; Fri, 26 Apr 2019 20:28:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x3QKOZZL025198 for ; Fri, 26 Apr 2019 16:24:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id EE91E5DEC7; Fri, 26 Apr 2019 20:24:35 +0000 (UTC) Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E94805D9D1 for ; Fri, 26 Apr 2019 20:24:33 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 CCBF230BE668 for ; Fri, 26 Apr 2019 20:24:32 +0000 (UTC) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3QKIfej135410 for ; Fri, 26 Apr 2019 16:24:25 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0b-001b2d01.pphosted.com with ESMTP id 2s460kgdnd-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 26 Apr 2019 16:24:21 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 26 Apr 2019 21:24:14 +0100 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 26 Apr 2019 21:24:12 +0100 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x3QKOAbO52232228 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 26 Apr 2019 20:24:10 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 906A46A04D; Fri, 26 Apr 2019 20:24:10 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F3B856A05F; Fri, 26 Apr 2019 20:24:09 +0000 (GMT) Received: from collin-T470p.pok.ibm.com (unknown [9.56.58.88]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 26 Apr 2019 20:24:09 +0000 (GMT) From: walling@linux.ibm.com To: libvir-list@redhat.com Date: Fri, 26 Apr 2019 16:22:51 -0400 In-Reply-To: <1556310176-27835-1-git-send-email-walling@linux.ibm.com> References: <1556310176-27835-1-git-send-email-walling@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19042620-0020-0000-0000-00000EDD7B2E X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011000; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000285; SDB=6.01194795; UDB=6.00626450; IPR=6.00975631; MB=3.00026612; MTD=3.00000008; XFM=3.00000015; UTC=2019-04-26 20:24:14 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19042620-0021-0000-0000-00006594AA58 Message-Id: <1556310176-27835-4-git-send-email-walling@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-04-26_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 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-1810050000 definitions=main-1904260135 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 26 Apr 2019 20:24:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 26 Apr 2019 20:24:33 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'walling@linux.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.346 (KHOP_DYNAMIC, RCVD_IN_DNSWL_LOW, SPF_PASS) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: bwalk@linux.ibm.com, jdenemar@redhat.com, danielhb413@gmail.com, Collin Walling , david@redhat.com Subject: [libvirt] [PATCH v2 3/8] qemu_capabilities: introduce QEMU_CAPS_QUERY_CPU_MODEL_BASELINE 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 26 Apr 2019 20:28:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" From: Collin Walling This capability enables CPU model baselining between two CPU definitions via QMP. Signed-off-by: Collin Walling Reviewed-by: Daniel Henrique Barboza Tested-by: Daniel Henrique Barboza --- src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml | 1 + 8 files changed, 9 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index a0b2ca7..0835f65 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -525,6 +525,7 @@ VIR_ENUM_IMPL(virQEMUCaps, "virtio-pci-non-transitional", "overcommit", "query-current-machine", + "query-cpu-model-baseline", ); =20 =20 @@ -971,6 +972,7 @@ struct virQEMUCapsStringFlags virQEMUCapsCommands[] =3D= { { "qom-list-properties", QEMU_CAPS_QOM_LIST_PROPERTIES }, { "blockdev-del", QEMU_CAPS_BLOCKDEV_DEL }, { "query-current-machine", QEMU_CAPS_QUERY_CURRENT_MACHINE }, + { "query-cpu-model-baseline", QEMU_CAPS_QUERY_CPU_MODEL_BASELINE }, }; =20 struct virQEMUCapsStringFlags virQEMUCapsMigration[] =3D { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 67c8e80..102f259 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -507,6 +507,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL, /* virtio *-pci-{non-}transitional = devices */ QEMU_CAPS_OVERCOMMIT, /* -overcommit */ QEMU_CAPS_QUERY_CURRENT_MACHINE, /* query-current-machine command */ + QEMU_CAPS_QUERY_CPU_MODEL_BASELINE, /* qmp query-cpu-model-baseline */ =20 QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml b/tests/qemuc= apabilitiesdata/caps_2.10.0.s390x.xml index 21b918f..e6f7e28 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml @@ -103,6 +103,7 @@ + 2010000 0 39100805 diff --git a/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml b/tests/qemuc= apabilitiesdata/caps_2.11.0.s390x.xml index 6cb997d..48d7742 100644 --- a/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml @@ -110,6 +110,7 @@ + 2011000 0 39100806 diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml b/tests/qemuc= apabilitiesdata/caps_2.12.0.s390x.xml index 2930381..381abd5 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml @@ -121,6 +121,7 @@ + 2012000 0 39100807 diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_2.8.0.s390x.xml index 5a2b740..9516a3b 100644 --- a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml @@ -92,6 +92,7 @@ + 2007093 0 39100764 diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_2.9.0.s390x.xml index 72ae100..cf8bbb2 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml @@ -97,6 +97,7 @@ + 2009000 0 39100765 diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_3.0.0.s390x.xml index d511377..40b4a2b 100644 --- a/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml @@ -123,6 +123,7 @@ + 3000000 0 39100757 --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 10:54:46 2024 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=1556310264; cv=none; d=zoho.com; s=zohoarc; b=YO9v954EYXLybQg+59qrYO7eB4YOcFi8ScekDnDwTCxubE2M67qDmTnYvSfOkDAjGz5ei0loTE8zZrtxxRZSRMgMA6H+ezPTCBGwISNsY7uP9OleOapsVJlnOZbQJOLW9I9wpwoEUGxrieae0J7HstzxBU94i0etRejZAlvzFNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556310264; 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=YJUMeLVVsDYm1dt6bcFo1DME0hcEFqk9yw7BbGvRwCY=; b=bZ4YqhYuv6ZRph90OZkcdQhLTpFAd/VbpDNEFos+XqYVOJyME5U8sjNnGn4xjaxvJ/8ojCNHoyp/AzIWemNhj5xBFMX2HvS5qn9fTHEtnA2ngmWk/PxHURlwiBGJLxuJdQHZVXFfNVIQWlHhp9UY+x2OkVJ8oRcsl7IXv4L6vcI= 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 1556310264175225.67208317785662; Fri, 26 Apr 2019 13:24:24 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 9364B30BE497; Fri, 26 Apr 2019 20:24:22 +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 2295F5D71B; Fri, 26 Apr 2019 20:24:21 +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 AD421181AC92; Fri, 26 Apr 2019 20:24:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x3QKOIfZ025030 for ; Fri, 26 Apr 2019 16:24:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0F95988FC; Fri, 26 Apr 2019 20:24:18 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0A2E24108 for ; Fri, 26 Apr 2019 20:24:18 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 39E254AD69 for ; Fri, 26 Apr 2019 20:24:17 +0000 (UTC) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3QKIfoV005984 for ; Fri, 26 Apr 2019 16:24:16 -0400 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0b-001b2d01.pphosted.com with ESMTP id 2s48wfg6fh-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 26 Apr 2019 16:24:16 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 26 Apr 2019 21:24:15 +0100 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 26 Apr 2019 21:24:12 +0100 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x3QKOBhe10486180 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 26 Apr 2019 20:24:11 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 499056A051; Fri, 26 Apr 2019 20:24:11 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B6D966A04D; Fri, 26 Apr 2019 20:24:10 +0000 (GMT) Received: from collin-T470p.pok.ibm.com (unknown [9.56.58.88]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 26 Apr 2019 20:24:10 +0000 (GMT) From: walling@linux.ibm.com To: libvir-list@redhat.com Date: Fri, 26 Apr 2019 16:22:52 -0400 In-Reply-To: <1556310176-27835-1-git-send-email-walling@linux.ibm.com> References: <1556310176-27835-1-git-send-email-walling@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19042620-0036-0000-0000-00000AAF7A50 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011000; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000285; SDB=6.01194796; UDB=6.00626450; IPR=6.00975630; MB=3.00026612; MTD=3.00000008; XFM=3.00000015; UTC=2019-04-26 20:24:14 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19042620-0037-0000-0000-00004B8BC01D Message-Id: <1556310176-27835-5-git-send-email-walling@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-04-26_13:, , 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-1810050000 definitions=main-1904260135 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 26 Apr 2019 20:24:17 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 26 Apr 2019 20:24:17 +0000 (UTC) for IP:'148.163.158.5' DOMAIN:'mx0b-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'walling@linux.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.346 (KHOP_DYNAMIC, RCVD_IN_DNSWL_LOW, SPF_PASS) 148.163.158.5 mx0b-001b2d01.pphosted.com 148.163.158.5 mx0b-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: bwalk@linux.ibm.com, jdenemar@redhat.com, danielhb413@gmail.com, Collin Walling , david@redhat.com Subject: [libvirt] [PATCH v2 4/8] qemu_driver: hook up query-cpu-model-baseline 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 26 Apr 2019 20:24:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" From: Collin Walling This command is hooked into the virsh hypervisor-cpu-baseline command. As such, the CPU models provided in the XML sent to the command will be baselined with the CPU contained in the QEMU capabilities file for the appropriate QEMU binary (for s390x, this CPU definition can be observed via virsh domcapabilities). Signed-off-by: Collin Walling Reviewed-by: Daniel Henrique Barboza Tested-by: Daniel Henrique Barboza --- src/qemu/qemu_capabilities.c | 102 +++++++++++++++++++++++++++++++++++++++= ++++ src/qemu/qemu_capabilities.h | 7 +++ src/qemu/qemu_driver.c | 28 ++++++++++++ 3 files changed, 137 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 0835f65..e3f3d0b 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5402,3 +5402,105 @@ virQEMUCapsStripMachineAliases(virQEMUCapsPtr qemuC= aps) for (i =3D 0; i < qemuCaps->nmachineTypes; i++) VIR_FREE(qemuCaps->machineTypes[i].alias); } + + +static void +virQEMUCapsFixFeatPolicy(virCPUDefPtr cpu) +{ + size_t i; + + /* Features reported by QMP are either on or off. If the feature is + * off, let's set the policy to disabled. Otherwise set it to required. + */ + for (i =3D 0; i < cpu->nfeatures; i++) { + if (cpu->features[i].policy =3D=3D 0) + cpu->features[i].policy =3D VIR_CPU_FEATURE_DISABLE; + else + cpu->features[i].policy =3D VIR_CPU_FEATURE_REQUIRE; + } +} + + +static int +virQEMUCapsStealCPUModelFromInfo(qemuMonitorCPUModelInfoPtr info, + virCPUDefPtr cpu) +{ + size_t i; + + virCPUDefFreeModel(cpu); + + VIR_STEAL_PTR(cpu->model, info->name); + + for (i =3D 0; i < info->nprops; i++) { + char *name =3D info->props[i].name; + int policy =3D 0; + + /* If monitor prop type is boolean and is true, force the feat on = */ + if (info->props[i].type =3D=3D QEMU_MONITOR_CPU_PROPERTY_BOOLEAN) + policy =3D info->props[i].value.boolean; + + if (virCPUDefAddFeature(cpu, name, policy) < 0) + goto error; + } + + qemuMonitorCPUModelInfoFree(info); + return 0; + + error: + virCPUDefFree(cpu); + return -1; +} + + +virCPUDefPtr +virQEMUCapsCPUModelBaseline(virQEMUCapsPtr qemuCaps, + const char *libDir, + uid_t runUid, + gid_t runGid, + int ncpus, + virCPUDefPtr *cpus) +{ + qemuMonitorCPUModelInfoPtr result =3D NULL; + qemuProcessQMPPtr proc =3D NULL; + virCPUDefPtr cpu =3D NULL; + virCPUDefPtr baseline =3D NULL; + size_t i; + + if (VIR_ALLOC(cpu) < 0) + goto cleanup; + + if (virCPUDefCopyModel(cpu, cpus[0], false)) + goto cleanup; + + if (!(proc =3D qemuProcessQMPNew(qemuCaps->binary, libDir, + runUid, runGid, false))) + goto cleanup; + + if (qemuProcessQMPStart(proc) < 0) + goto cleanup; + + for (i =3D 1; i < ncpus; i++) { + if (qemuMonitorGetCPUModelBaseline(proc->mon, cpu->model, + cpu->nfeatures, cpu->features, + cpus[i]->model, cpus[i]->nfeatu= res, + cpus[i]->features, &result) < 0) + goto cleanup; + + if (virQEMUCapsStealCPUModelFromInfo(result, cpu) < 0) + goto cleanup; + + result =3D NULL; + } + + virQEMUCapsFixFeatPolicy(cpu); + VIR_STEAL_PTR(baseline, cpu); + + cleanup: + if (!baseline) + virQEMUCapsLogProbeFailure(qemuCaps->binary); + + qemuMonitorCPUModelInfoFree(result); + qemuProcessQMPFree(proc); + virCPUDefFree(cpu); + return baseline; +} diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 102f259..08fd555 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -648,4 +648,11 @@ virQEMUCapsGetSEVCapabilities(virQEMUCapsPtr qemuCaps); virArch virQEMUCapsArchFromString(const char *arch); const char *virQEMUCapsArchToString(virArch arch); =20 +virCPUDefPtr virQEMUCapsCPUModelBaseline(virQEMUCapsPtr qemuCaps, + const char *libDir, + uid_t runUid, + gid_t runGid, + int ncpus, + virCPUDefPtr *cpus); + #endif /* LIBVIRT_QEMU_CAPABILITIES_H */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index f48d925..e1e1fea 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13576,6 +13576,7 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, unsigned int flags) { virQEMUDriverPtr driver =3D conn->privateData; + virQEMUDriverConfigPtr config =3D driver->config; virCPUDefPtr *cpus =3D NULL; virQEMUCapsPtr qemuCaps =3D NULL; virArch arch; @@ -13630,6 +13631,33 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr con= n, if (!(cpu =3D virCPUBaseline(arch, cpus, ncpus, cpuModels, (const char **)features, migratable))) goto cleanup; + } else if (ARCH_IS_S390(arch) && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_BASELINE= )) { + /* Add the hypervisor CPU to the list */ + virCPUDefPtr hvCPU; + size_t alloc =3D ncpus + 1; + + if (VIR_RESIZE_N(cpus, alloc, ncpus, 1) < 0) + goto cleanup; + + if (VIR_ALLOC(cpus[ncpus]) < 0) + goto cleanup; + + hvCPU =3D virQEMUCapsGetHostModel(qemuCaps, virttype, + VIR_QEMU_CAPS_HOST_CPU_REPORTED); + + if (virCPUDefCopyModel(cpus[ncpus], hvCPU, false) < 0) + goto cleanup; + + ncpus++; + + if (!(cpu =3D virQEMUCapsCPUModelBaseline(qemuCaps, config->libDir, + config->user, config->grou= p, + ncpus, cpus))) + goto cleanup; + + if (!(flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES)) + virCPUDefFreeFeatures(cpu); } else { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("computing baseline hypervisor CPU is not support= ed " --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 10:54:46 2024 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=1556310264; cv=none; d=zoho.com; s=zohoarc; b=bGH1ZZcJ2+DyKu5JMTGasARvVp3nWPM+v/LcnQAULW+LIctRMJ7wKb+9Bd6CKJtsOZD5PG6aW82cLIAZQr4nx04tLtXQeQ7E0Dk70PTIDt/xL4Ba1cyvNRleeNUBrQEU8lX3phqVFRnZqSf22Z5ls1uk/gCcPWjpvGfURRhwHv0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556310264; 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=QuUiDYmXbfAw6RNyWNvLf7FziAL+Ymw9Z8ejNTZg+34=; b=jrb/RG8u6GuHpIFRcnQKTTwCgZYpjJ3yrzEcqZ5N0ETaCccPqyExfkQWfTgrEf+eK0QJIE7i4ekN7/HWl9VCfjvCr4yzTBL7C+0UhecZcFtyzS17Py2YdWg5d8AuxWGgZJTP3zR6xcUC6ylvqkwIjaA58QoVNZumQ2Ovhai5qlk= 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 155631026496175.03565984150862; Fri, 26 Apr 2019 13:24:24 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id C848A3086200; Fri, 26 Apr 2019 20:24:23 +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 9747B101E7E1; Fri, 26 Apr 2019 20:24:23 +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 5741A181B9E6; Fri, 26 Apr 2019 20:24:23 +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 x3QKOKat025064 for ; Fri, 26 Apr 2019 16:24:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id A3B91608CA; Fri, 26 Apr 2019 20:24:20 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9DAFF608AC for ; Fri, 26 Apr 2019 20:24:18 +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 C6B857C0B0 for ; Fri, 26 Apr 2019 20:24:17 +0000 (UTC) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3QKK0JA091221 for ; Fri, 26 Apr 2019 16:24:17 -0400 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 2s46c0en4w-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 26 Apr 2019 16:24:17 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 26 Apr 2019 21:24:16 +0100 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 26 Apr 2019 21:24:13 +0100 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x3QKOCsi6554078 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 26 Apr 2019 20:24:12 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1F8806A04D; Fri, 26 Apr 2019 20:24:12 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 792026A054; Fri, 26 Apr 2019 20:24:11 +0000 (GMT) Received: from collin-T470p.pok.ibm.com (unknown [9.56.58.88]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 26 Apr 2019 20:24:11 +0000 (GMT) From: walling@linux.ibm.com To: libvir-list@redhat.com Date: Fri, 26 Apr 2019 16:22:53 -0400 In-Reply-To: <1556310176-27835-1-git-send-email-walling@linux.ibm.com> References: <1556310176-27835-1-git-send-email-walling@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19042620-0016-0000-0000-000009A77BF6 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011000; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000285; SDB=6.01194795; UDB=6.00626450; IPR=6.00975630; MB=3.00026612; MTD=3.00000008; XFM=3.00000015; UTC=2019-04-26 20:24:14 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19042620-0017-0000-0000-000042F8C76D Message-Id: <1556310176-27835-6-git-send-email-walling@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-04-26_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 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-1810050000 definitions=main-1904260135 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 26 Apr 2019 20:24:17 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Fri, 26 Apr 2019 20:24:17 +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.346 (KHOP_DYNAMIC, RCVD_IN_DNSWL_LOW, SPF_PASS) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: bwalk@linux.ibm.com, jdenemar@redhat.com, danielhb413@gmail.com, Collin Walling , david@redhat.com Subject: [libvirt] [PATCH v2 5/8] qemu_monitor: implement query-cpu-model-comparison 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Fri, 26 Apr 2019 20:24:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" From: Collin Walling Interfaces with QEMU to compare CPU models. The command takes two CPU models, A and B, that are given a model name and an optional list of CPU features. Through the query-cpu-model-comparison command issued via QMP, a result is produced that contains the comparison evaluation string (identical, superset, subset, incompatible) as well as a list of properties (aka CPU features) responsible for the subset or superset result. Signed-off-by: Collin Walling Tested-by: Daniel Henrique Barboza Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_monitor.c | 22 +++++++++++ src/qemu/qemu_monitor.h | 9 +++++ src/qemu/qemu_monitor_json.c | 89 ++++++++++++++++++++++++++++++++++++++++= ++++ src/qemu/qemu_monitor_json.h | 10 +++++ 4 files changed, 130 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 10e312c..176c070 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3706,6 +3706,28 @@ qemuMonitorGetCPUModelBaseline(qemuMonitorPtr mon, } =20 =20 +int +qemuMonitorGetCPUModelComparison(qemuMonitorPtr mon, + const char *model_a_name, + int model_a_nprops, + virCPUFeatureDefPtr model_a_props, + const char *model_b_name, + int model_b_nprops, + virCPUFeatureDefPtr model_b_props, + qemuMonitorCPUModelInfoPtr *model_result) +{ + VIR_DEBUG("model_a_name=3D%s model_a_nprops=3D%d model_b_name=3D%s mod= el_b_nprops=3D%d", + model_a_name, model_a_nprops, model_b_name, model_b_nprops); + + QEMU_CHECK_MONITOR(mon); + + return qemuMonitorJSONGetCPUModelComparison(mon, model_a_name, model_a= _nprops, + model_a_props, model_b_nam= e, + model_b_nprops, model_b_pr= ops, + model_result); +} + + void qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info) { diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 637a6c6..03a45a1 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1075,6 +1075,15 @@ int qemuMonitorGetCPUModelBaseline(qemuMonitorPtr mo= n, virCPUFeatureDefPtr model_b_props, qemuMonitorCPUModelInfoPtr *model_resul= t); =20 +int qemuMonitorGetCPUModelComparison(qemuMonitorPtr mon, + const char *model_a_name, + int model_a_nprops, + virCPUFeatureDefPtr model_a_props, + const char *model_b_name, + int model_b_nprops, + virCPUFeatureDefPtr model_b_props, + qemuMonitorCPUModelInfoPtr *model_res= ult); + qemuMonitorCPUModelInfoPtr qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig); =20 diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 6c17913..017c65a 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5766,6 +5766,95 @@ qemuMonitorJSONGetCPUModelBaseline(qemuMonitorPtr mo= n, } =20 =20 +static int +qemuMonitorJSONParseCPUModelPropName(size_t pos ATTRIBUTE_UNUSED, + virJSONValuePtr item, + void *opaque) +{ + return qemuMonitorJSONParseCPUModelProperty(virJSONValueGetString(item= ), + item, opaque); +} + + +int +qemuMonitorJSONGetCPUModelComparison(qemuMonitorPtr mon, + const char *model_a_name, + int model_a_nprops, + virCPUFeatureDefPtr model_a_props, + const char *model_b_name, + int model_b_nprops, + virCPUFeatureDefPtr model_b_props, + qemuMonitorCPUModelInfoPtr *model_res= ult) +{ + int ret =3D -1; + virJSONValuePtr model_a; + virJSONValuePtr model_b =3D NULL; + virJSONValuePtr cmd =3D NULL; + virJSONValuePtr reply =3D NULL; + virJSONValuePtr data; + const char *result_name; + virJSONValuePtr props; + qemuMonitorCPUModelInfoPtr compare =3D NULL; + + if (!(model_a =3D qemuMonitorJSONMakeCPUModel(model_a_name, model_a_np= rops, model_a_props, true)) || + !(model_b =3D qemuMonitorJSONMakeCPUModel(model_b_name, model_b_np= rops, model_b_props, true))) + goto cleanup; + + if (!(cmd =3D qemuMonitorJSONMakeCommand("query-cpu-model-comparison", + "a:modela", &model_a, + "a:modelb", &model_b, + NULL))) + goto cleanup; + + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) + goto cleanup; + + if (qemuMonitorJSONCheckError(cmd, reply) < 0) + goto cleanup; + + data =3D virJSONValueObjectGetObject(reply, "return"); + + if (!(result_name =3D virJSONValueObjectGetString(data, "result"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-cpu-model-comparison reply data was missin= g " + "'result'")); + goto cleanup; + } + + if (!(props =3D virJSONValueObjectGetArray(data, "responsible-properti= es"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("query-cpu-model-comparison reply data was missin= g " + "'responsible-properties'")); + goto cleanup; + } + + if (VIR_ALLOC(compare) < 0) + goto cleanup; + + if (VIR_STRDUP(compare->name, result_name) < 0) + goto cleanup; + + if (VIR_ALLOC_N(compare->props, virJSONValueArraySize(props)) < 0) + goto cleanup; + + if (virJSONValueArrayForeachSteal(props, + qemuMonitorJSONParseCPUModelPropName, + compare) < 0) + goto cleanup; + + VIR_STEAL_PTR(*model_result, compare); + ret =3D 0; + + cleanup: + qemuMonitorCPUModelInfoFree(compare); + virJSONValueFree(cmd); + virJSONValueFree(reply); + virJSONValueFree(model_a); + virJSONValueFree(model_b); + return ret; +} + + int qemuMonitorJSONGetCommands(qemuMonitorPtr mon, char ***commands) { diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 77b69af..9959426 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -377,6 +377,16 @@ int qemuMonitorJSONGetCPUModelBaseline(qemuMonitorPtr = mon, qemuMonitorCPUModelInfoPtr *model_r= esult) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5) ATTRIBUTE_NONNULL(8); =20 +int qemuMonitorJSONGetCPUModelComparison(qemuMonitorPtr mon, + const char *model_a_name, + int model_a_nprops, + virCPUFeatureDefPtr model_a_props, + const char *model_b_name, + int model_b_nprops, + virCPUFeatureDefPtr model_b_props, + qemuMonitorCPUModelInfoPtr *model= _result) + ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(5) ATTRIBUTE_NONNULL(8); + int qemuMonitorJSONGetCommands(qemuMonitorPtr mon, char ***commands) ATTRIBUTE_NONNULL(2); --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 10:54:46 2024 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=1556310277; cv=none; d=zoho.com; s=zohoarc; b=iH6Fwd6SjLUJFBypHPFt58m9qf1szNc9da5eq7WfEgwNvdge7NwiiodPnS45xlQXqRlufub+0glWq0jx7u0A9wsyyvo+YRs0EYCsZVDOipzsyng5ST1XaHOBO8Y3Wr3+4B34S8a6/tnsVE7qjyqmv9SFsQukUEGpp5j9gLMmkzI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556310277; 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=9N/xAot6Qf+uVm/GHrCR0ifmPybD/YEtHh7TkjoofyE=; b=GIpCzOT64Wxaw1sfkV5bargQRme3Xm1F6qetcIH0qdI8r+l9LFhmbUGOg9HYg6p3Xdg8AXFIwov4C5u2EwalOqo6G1XPujxMWL9CHDJqNCyvC2faiLy5mePpF5JM1UlC9izTZr4JS5xR3CE2sxyz18BLL6hfCAUTCino0CI00o8= 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 1556310277314422.7593687357952; Fri, 26 Apr 2019 13:24:37 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 1E5868C0CC; Fri, 26 Apr 2019 20:24:36 +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 E96CA5D70A; Fri, 26 Apr 2019 20:24: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 B334C41F3D; Fri, 26 Apr 2019 20:24:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x3QKOL09025076 for ; Fri, 26 Apr 2019 16:24:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4B00E60E3D; Fri, 26 Apr 2019 20:24:21 +0000 (UTC) Received: from mx1.redhat.com (ext-mx18.extmail.prod.ext.phx2.redhat.com [10.5.110.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 45E2360BF3 for ; Fri, 26 Apr 2019 20:24:19 +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 656D7308950C for ; Fri, 26 Apr 2019 20:24:18 +0000 (UTC) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3QKJgxn117868 for ; Fri, 26 Apr 2019 16:24:18 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 2s48uh09j0-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 26 Apr 2019 16:24:17 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 26 Apr 2019 21:24:17 +0100 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 26 Apr 2019 21:24:14 +0100 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x3QKOCan8061244 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 26 Apr 2019 20:24:13 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D61466A04D; Fri, 26 Apr 2019 20:24:12 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 466296A04F; Fri, 26 Apr 2019 20:24:12 +0000 (GMT) Received: from collin-T470p.pok.ibm.com (unknown [9.56.58.88]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 26 Apr 2019 20:24:12 +0000 (GMT) From: walling@linux.ibm.com To: libvir-list@redhat.com Date: Fri, 26 Apr 2019 16:22:54 -0400 In-Reply-To: <1556310176-27835-1-git-send-email-walling@linux.ibm.com> References: <1556310176-27835-1-git-send-email-walling@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19042620-0004-0000-0000-0000150478E3 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011000; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000285; SDB=6.01194795; UDB=6.00626450; IPR=6.00975631; MB=3.00026612; MTD=3.00000008; XFM=3.00000015; UTC=2019-04-26 20:24:16 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19042620-0005-0000-0000-00008B6AC1B1 Message-Id: <1556310176-27835-7-git-send-email-walling@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-04-26_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 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-1810050000 definitions=main-1904260135 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 26 Apr 2019 20:24:18 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Fri, 26 Apr 2019 20:24:18 +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.346 (KHOP_DYNAMIC, RCVD_IN_DNSWL_LOW, 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.47 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: bwalk@linux.ibm.com, jdenemar@redhat.com, danielhb413@gmail.com, Collin Walling , david@redhat.com Subject: [libvirt] [PATCH v2 6/8] qemu_capabilities: introduce QEMU_CAPS_QUERY_CPU_MODEL_COMPARISON 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 26 Apr 2019 20:24:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" From: Collin Walling This capability enables CPU model comparison between two CPU definitions via QMP. Signed-off-by: Collin Walling Tested-by: Daniel Henrique Barboza Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_capabilities.c | 4 ++++ src/qemu/qemu_capabilities.h | 3 +++ tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml | 1 + tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml | 1 + 8 files changed, 13 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index e3f3d0b..374a7c1 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -526,6 +526,9 @@ VIR_ENUM_IMPL(virQEMUCaps, "overcommit", "query-current-machine", "query-cpu-model-baseline", + + /* 330 */ + "query-cpu-model-comparison", ); =20 =20 @@ -973,6 +976,7 @@ struct virQEMUCapsStringFlags virQEMUCapsCommands[] =3D= { { "blockdev-del", QEMU_CAPS_BLOCKDEV_DEL }, { "query-current-machine", QEMU_CAPS_QUERY_CURRENT_MACHINE }, { "query-cpu-model-baseline", QEMU_CAPS_QUERY_CPU_MODEL_BASELINE }, + { "query-cpu-model-comparison", QEMU_CAPS_QUERY_CPU_MODEL_COMPARISON }, }; =20 struct virQEMUCapsStringFlags virQEMUCapsMigration[] =3D { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 08fd555..47612e9 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -509,6 +509,9 @@ typedef enum { /* virQEMUCapsFlags grouping marker for = syntax-check */ QEMU_CAPS_QUERY_CURRENT_MACHINE, /* query-current-machine command */ QEMU_CAPS_QUERY_CPU_MODEL_BASELINE, /* qmp query-cpu-model-baseline */ =20 + /* 330 */ + QEMU_CAPS_QUERY_CPU_MODEL_COMPARISON, /* qmp query-cpu-model-compariso= n */ + QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; =20 diff --git a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml b/tests/qemuc= apabilitiesdata/caps_2.10.0.s390x.xml index e6f7e28..058eb32 100644 --- a/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.10.0.s390x.xml @@ -104,6 +104,7 @@ + 2010000 0 39100805 diff --git a/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml b/tests/qemuc= apabilitiesdata/caps_2.11.0.s390x.xml index 48d7742..4256131 100644 --- a/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.11.0.s390x.xml @@ -111,6 +111,7 @@ + 2011000 0 39100806 diff --git a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml b/tests/qemuc= apabilitiesdata/caps_2.12.0.s390x.xml index 381abd5..48be96d 100644 --- a/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.12.0.s390x.xml @@ -122,6 +122,7 @@ + 2012000 0 39100807 diff --git a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_2.8.0.s390x.xml index 9516a3b..5b04416 100644 --- a/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.8.0.s390x.xml @@ -93,6 +93,7 @@ + 2007093 0 39100764 diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_2.9.0.s390x.xml index cf8bbb2..d5feb7b 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.s390x.xml @@ -98,6 +98,7 @@ + 2009000 0 39100765 diff --git a/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml b/tests/qemuca= pabilitiesdata/caps_3.0.0.s390x.xml index 40b4a2b..27befc4 100644 --- a/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml +++ b/tests/qemucapabilitiesdata/caps_3.0.0.s390x.xml @@ -124,6 +124,7 @@ + 3000000 0 39100757 --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 10:54:46 2024 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=1556310280; cv=none; d=zoho.com; s=zohoarc; b=X2qBCtGcTO/6SI9/n5UYIqvBElMK4uEWqlzHfBp3dtmoJ9E23ZI2Ev0s68NHTmf3XP1yTAEPYfvbVBopWZ4rCDelEaIS4aR0XJSxnRXm9MBEEWg3zMsyFx6TIrzXmIjfs23tdQrm2D/v2pssX80qaaig+pLQHyyWHAoQkXShgoQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556310280; 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=pX4eYLhKLY9f6gHznT4dQu/HST38GfEGwbTAudWOPAQ=; b=WJ4u0Die5Z14nUw/0nzi34os3W47dPKoFTzVF9/VQcUIO/GO7rbKUxp79hnYF/U0f0Fm9QhowKKoOGesf8c20bXZkA4ggpy+S0KUSVhZ6+91ArI9UWUs7ggfiJoaBimp1T4uy47FprSDDLGEw4dOK0Ock8KunOWOH4JQjI0SMqs= 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 1556310280549698.7363117142596; Fri, 26 Apr 2019 13:24:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 42F8312F8F5; Fri, 26 Apr 2019 20:24:39 +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 199A5183EB; Fri, 26 Apr 2019 20:24:39 +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 CFCFC181B9EC; Fri, 26 Apr 2019 20:24:38 +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 x3QKOMku025095 for ; Fri, 26 Apr 2019 16:24:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9CE1F600C5; Fri, 26 Apr 2019 20:24:22 +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 959B7600C7 for ; Fri, 26 Apr 2019 20:24:20 +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 9C9983078DC9 for ; Fri, 26 Apr 2019 20:24:19 +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 x3QKKGV1001990 for ; Fri, 26 Apr 2019 16:24:19 -0400 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 2s47qhudft-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 26 Apr 2019 16:24:19 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 26 Apr 2019 21:24:18 +0100 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 26 Apr 2019 21:24:15 +0100 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x3QKODZV11927938 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 26 Apr 2019 20:24:13 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9D4586A051; Fri, 26 Apr 2019 20:24:13 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 097A16A04F; Fri, 26 Apr 2019 20:24:13 +0000 (GMT) Received: from collin-T470p.pok.ibm.com (unknown [9.56.58.88]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 26 Apr 2019 20:24:12 +0000 (GMT) From: walling@linux.ibm.com To: libvir-list@redhat.com Date: Fri, 26 Apr 2019 16:22:55 -0400 In-Reply-To: <1556310176-27835-1-git-send-email-walling@linux.ibm.com> References: <1556310176-27835-1-git-send-email-walling@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19042620-0016-0000-0000-000009A77BF8 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011000; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000285; SDB=6.01194795; UDB=6.00626450; IPR=6.00975630; MB=3.00026612; MTD=3.00000008; XFM=3.00000015; UTC=2019-04-26 20:24:16 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19042620-0017-0000-0000-000042F8C772 Message-Id: <1556310176-27835-8-git-send-email-walling@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-04-26_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 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-1810050000 definitions=main-1904260135 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 26 Apr 2019 20:24:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Fri, 26 Apr 2019 20:24:19 +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.346 (KHOP_DYNAMIC, RCVD_IN_DNSWL_LOW, 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.11 X-loop: libvir-list@redhat.com Cc: bwalk@linux.ibm.com, jdenemar@redhat.com, danielhb413@gmail.com, Collin Walling , david@redhat.com Subject: [libvirt] [PATCH v2 7/8] cpu_conf: xml to cpu definition parse helper 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 26 Apr 2019 20:24:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" From: Collin Walling Implement an XML to virCPUDefPtr helper that handles the ctxt prerequisite for virCPUDefParseXML. This does not alter any functionality. Signed-off-by: Collin Walling Reviewed-by: Bjoern Walk Reviewed-by: Daniel Henrique Barboza Tested-by: Daniel Henrique Barboza --- src/conf/cpu_conf.c | 30 ++++++++++++++++++++++++++++++ src/conf/cpu_conf.h | 6 ++++++ src/cpu/cpu.c | 14 +------------- src/libvirt_private.syms | 1 + 4 files changed, 38 insertions(+), 13 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index bd2beab..d5f6fa1 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -260,6 +260,36 @@ virCPUDefCopy(const virCPUDef *cpu) } =20 =20 +int +virCPUDefParseXMLHelper(const char *xml, + const char *xpath, + virCPUType type, + virCPUDefPtr *cpu) +{ + xmlDocPtr doc =3D NULL; + xmlXPathContextPtr ctxt =3D NULL; + int ret =3D -1; + + if (!xml) { + virReportError(VIR_ERR_INVALID_ARG, "%s", _("missing CPU definitio= n")); + goto cleanup; + } + + if (!(doc =3D virXMLParseStringCtxt(xml, _("(CPU_definition)"), &ctxt)= )) + goto cleanup; + + if (virCPUDefParseXML(ctxt, xpath, type, cpu) < 0) + goto cleanup; + + ret =3D 0; + + cleanup: + xmlFreeDoc(doc); + xmlXPathFreeContext(ctxt); + return ret; +} + + /* * Parses CPU definition XML from a node pointed to by @xpath. If @xpath is * NULL, the current node of @ctxt is used (i.e., it is a shortcut to "."). diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h index c98db65..8d06b6f 100644 --- a/src/conf/cpu_conf.h +++ b/src/conf/cpu_conf.h @@ -182,6 +182,12 @@ virCPUDefPtr virCPUDefCopyWithoutModel(const virCPUDef *cpu); =20 int +virCPUDefParseXMLHelper(const char *xml, + const char *xpath, + virCPUType type, + virCPUDefPtr *cpu); + +int virCPUDefParseXML(xmlXPathContextPtr ctxt, const char *xpath, virCPUType mode, diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index a223ff0..6eca956 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -111,31 +111,19 @@ virCPUCompareXML(virArch arch, const char *xml, bool failIncompatible) { - xmlDocPtr doc =3D NULL; - xmlXPathContextPtr ctxt =3D NULL; virCPUDefPtr cpu =3D NULL; virCPUCompareResult ret =3D VIR_CPU_COMPARE_ERROR; =20 VIR_DEBUG("arch=3D%s, host=3D%p, xml=3D%s", virArchToString(arch), host, NULLSTR(xml)); =20 - if (!xml) { - virReportError(VIR_ERR_INVALID_ARG, "%s", _("missing CPU definitio= n")); - goto cleanup; - } - - if (!(doc =3D virXMLParseStringCtxt(xml, _("(CPU_definition)"), &ctxt)= )) - goto cleanup; - - if (virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_AUTO, &cpu) < 0) + if (virCPUDefParseXMLHelper(xml, NULL, VIR_CPU_TYPE_AUTO, &cpu) < 0) goto cleanup; =20 ret =3D virCPUCompare(arch, host, cpu, failIncompatible); =20 cleanup: virCPUDefFree(cpu); - xmlXPathFreeContext(ctxt); - xmlFreeDoc(doc); =20 return ret; } diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index a03cf0b..1308c7b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -88,6 +88,7 @@ virCPUDefIsEqual; virCPUDefListFree; virCPUDefListParse; virCPUDefParseXML; +virCPUDefParseXMLHelper; virCPUDefStealModel; virCPUDefUpdateFeature; virCPUModeTypeToString; --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 10:54:46 2024 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=1556310285; cv=none; d=zoho.com; s=zohoarc; b=J7FzUCglYP4JF6FoU51IBZWHStSwLdyF6e9ESBR+piKhRyGD18hKZSzKWutvUrckQh3dnUZJ+NH8AYxis2w4jxHcm56WXyYZBpBJgfY3FrPOKdmLeNu7MiNdO6iuVHWjuSAAxrGN7jBMuI4YU7z6SU6wtEe6cWajpjUKtswOFY8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556310285; 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=Q1eOj16SJwvD3oh8Nbk61PUP4WEKVN8dc4DaWL4GU2s=; b=MrCBoKwCiBZ6ys2LgYSbDHG9HTQYFh1BsSBOHpyZ7is59XuGVpGbjwZwOkRPCa5wP5EVlDEKBGyqbTF1DHEjmgekxjPHGHIAjAZUeyKPuWGlDPoRPPEsYIvCSEqokP7TPc7XKLl3hPKTBE1pSJzQ2Mnuct0HllfowaIrixDEtBw= 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 1556310285223722.3889912824613; Fri, 26 Apr 2019 13:24:45 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id D2DED3DBF8; Fri, 26 Apr 2019 20:24:43 +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 AB7AB5D71C; Fri, 26 Apr 2019 20:24:43 +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 6D5263FAF5; Fri, 26 Apr 2019 20:24:43 +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 x3QKOM45025094 for ; Fri, 26 Apr 2019 16:24:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9ABBC600C8; Fri, 26 Apr 2019 20:24:22 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 94C1F600C5 for ; Fri, 26 Apr 2019 20:24:20 +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 5BBF9314E272 for ; Fri, 26 Apr 2019 20:24:19 +0000 (UTC) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3QKJgOk117990 for ; Fri, 26 Apr 2019 16:24:19 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0a-001b2d01.pphosted.com with ESMTP id 2s48uh09jk-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 26 Apr 2019 16:24:18 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 26 Apr 2019 21:24:18 +0100 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 26 Apr 2019 21:24:15 +0100 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x3QKOEiJ57344226 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 26 Apr 2019 20:24:14 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5EECA6A05F; Fri, 26 Apr 2019 20:24:14 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C40706A04F; Fri, 26 Apr 2019 20:24:13 +0000 (GMT) Received: from collin-T470p.pok.ibm.com (unknown [9.56.58.88]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 26 Apr 2019 20:24:13 +0000 (GMT) From: walling@linux.ibm.com To: libvir-list@redhat.com Date: Fri, 26 Apr 2019 16:22:56 -0400 In-Reply-To: <1556310176-27835-1-git-send-email-walling@linux.ibm.com> References: <1556310176-27835-1-git-send-email-walling@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19042620-0020-0000-0000-00000EDD7B2F X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011000; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000285; SDB=6.01194795; UDB=6.00626450; IPR=6.00975631; MB=3.00026612; MTD=3.00000008; XFM=3.00000015; UTC=2019-04-26 20:24:17 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19042620-0021-0000-0000-00006594AA5C Message-Id: <1556310176-27835-9-git-send-email-walling@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-04-26_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=863 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1904260135 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 26 Apr 2019 20:24:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Fri, 26 Apr 2019 20:24:19 +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.346 (KHOP_DYNAMIC, RCVD_IN_DNSWL_LOW, 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.49 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: bwalk@linux.ibm.com, jdenemar@redhat.com, danielhb413@gmail.com, Collin Walling , david@redhat.com Subject: [libvirt] [PATCH v2 8/8] qemu_driver: hook up query-cpu-model-comparison 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 26 Apr 2019 20:24:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" From: Collin Walling This command is hooked into the virsh hypervisor-cpu-compare command. As such, the CPU model XML provided to the command will be compared to the hypervisor CPU contained in the QEMU capabilities file for the appropriate QEMU binary (for s390x, this CPU definition can be observed via virsh domcapabilities). s390x can report that the first model (A) is a subset of the second (B). If A is the hypervisor CPU and a subset of B (the CPU contained in the XML), then B would not be able to run on this machine and thus we will report that CPU model B is incompatible. Signed-off-by: Collin Walling Tested-by: Daniel Henrique Barboza Reviewed-by: Daniel Henrique Barboza --- src/qemu/qemu_capabilities.c | 48 ++++++++++++++++++++++++++++++++++++++++= ++++ src/qemu/qemu_capabilities.h | 9 +++++++++ src/qemu/qemu_driver.c | 10 +++++++++ 3 files changed, 67 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 374a7c1..bd8c7a1 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5508,3 +5508,51 @@ virQEMUCapsCPUModelBaseline(virQEMUCapsPtr qemuCaps, virCPUDefFree(cpu); return baseline; } + +virCPUCompareResult +virQEMUCapsCPUModelComparison(virQEMUCapsPtr qemuCaps, + const char *libDir, + uid_t runUid, + gid_t runGid, + virCPUDefPtr cpu_a, + virCPUDefPtr cpu_b, + bool failIncompatible) +{ + qemuProcessQMPPtr proc =3D NULL; + qemuMonitorCPUModelInfoPtr result; + int ret =3D -1; + + if (!(proc =3D qemuProcessQMPNew(qemuCaps->binary, libDir, + runUid, runGid, false))) + goto cleanup; + + if (qemuProcessQMPStart(proc) < 0) + goto cleanup; + + if (qemuMonitorGetCPUModelComparison(proc->mon, cpu_a->model, + cpu_a->nfeatures, cpu_a->features, + cpu_b->model, cpu_b->nfeatures, + cpu_b->features, &result) < 0) + goto cleanup; + + if (STREQ(result->name, "incompatible") || + STREQ(result->name, "subset")) + ret =3D VIR_CPU_COMPARE_INCOMPATIBLE; + else if (STREQ(result->name, "identical")) + ret =3D VIR_CPU_COMPARE_IDENTICAL; + else if (STREQ(result->name, "superset")) + ret =3D VIR_CPU_COMPARE_SUPERSET; + + if (failIncompatible && ret =3D=3D VIR_CPU_COMPARE_INCOMPATIBLE) { + ret =3D VIR_CPU_COMPARE_ERROR; + virReportError(VIR_ERR_CPU_INCOMPATIBLE, NULL); + } + + cleanup: + if (ret < 0) + virQEMUCapsLogProbeFailure(qemuCaps->binary); + + qemuMonitorCPUModelInfoFree(result); + qemuProcessQMPFree(proc); + return ret; +} diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 47612e9..01aecc0 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -658,4 +658,13 @@ virCPUDefPtr virQEMUCapsCPUModelBaseline(virQEMUCapsPt= r qemuCaps, int ncpus, virCPUDefPtr *cpus); =20 +virCPUCompareResult +virQEMUCapsCPUModelComparison(virQEMUCapsPtr qemuCaps, + const char *libDir, + uid_t runUid, + gid_t runGid, + virCPUDefPtr cpu_a, + virCPUDefPtr cpu_b, + bool failIncompatible); + #endif /* LIBVIRT_QEMU_CAPABILITIES_H */ diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index e1e1fea..fdf8a53 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13469,9 +13469,11 @@ qemuConnectCompareHypervisorCPU(virConnectPtr conn, { int ret =3D VIR_CPU_COMPARE_ERROR; virQEMUDriverPtr driver =3D conn->privateData; + virQEMUDriverConfigPtr config =3D driver->config; virQEMUCapsPtr qemuCaps =3D NULL; bool failIncompatible; virCPUDefPtr hvCPU; + virCPUDefPtr cpu; virArch arch; virDomainVirtType virttype; =20 @@ -13506,6 +13508,14 @@ qemuConnectCompareHypervisorCPU(virConnectPtr conn, =20 if (ARCH_IS_X86(arch)) { ret =3D virCPUCompareXML(arch, hvCPU, xmlCPU, failIncompatible); + } else if (ARCH_IS_S390(arch) && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_COMPARIS= ON)) { + if (virCPUDefParseXMLHelper(xmlCPU, NULL, VIR_CPU_TYPE_AUTO, &cpu)= < 0) + goto cleanup; + + ret =3D virQEMUCapsCPUModelComparison(qemuCaps, config->libDir, + config->user, config->group, + hvCPU, cpu, failIncompatible); } else { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("comparing with the hypervisor CPU is not support= ed " --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list