From nobody Fri Dec 27 12:59:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=reject dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1731433445520406.4244386515137; Tue, 12 Nov 2024 09:44:05 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 766B4188E; Tue, 12 Nov 2024 12:44:04 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 39A1D1939; Tue, 12 Nov 2024 12:43:07 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 7B1B71461; Tue, 12 Nov 2024 12:43:02 -0500 (EST) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id A59ED145B for ; Tue, 12 Nov 2024 12:43:01 -0500 (EST) Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4ACGeHTm002610 for ; Tue, 12 Nov 2024 17:43:01 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 42var408je-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 12 Nov 2024 17:43:00 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4ACGFsGK010521 for ; Tue, 12 Nov 2024 17:43:00 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 42tj2s4r4m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 12 Nov 2024 17:43:00 +0000 Received: from smtpav05.dal12v.mail.ibm.com (smtpav05.dal12v.mail.ibm.com [10.241.53.104]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4ACHgxGs51184070 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 12 Nov 2024 17:43:00 GMT Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E1A0258056 for ; Tue, 12 Nov 2024 17:42:59 +0000 (GMT) Received: from smtpav05.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B1AB45805D for ; Tue, 12 Nov 2024 17:42:59 +0000 (GMT) Received: from li-d664314c-3171-11b2-a85c-fa8047ef35bd.ibm.com.com (unknown [9.67.103.128]) by smtpav05.dal12v.mail.ibm.com (Postfix) with ESMTP for ; Tue, 12 Nov 2024 17:42:59 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h= content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=mOHe9sbTEg8oN+2hO 8+gkfy0EsSw3/keL8hTk3jwx18=; b=OeG98akT3xqzMp5ki8wWAxB42X4k9c9Wf dHrCFYDxICAy/mnCguz0ZBKRi80rLwac2dz4KGd+l4aB3kOMTeidmTykiWNPllGL 3uqaPGSyu4UIx9YcMKFjglNhxj67LbbGxHws8gp/PYaj6MjPN3UOX/yI0iBmt63g yhrAZURc8/+iX/J2S6R/BF6ixU74gok+SfbGeWxAeU93HIFDd6NCZiVwtvIDrZNi btXiywpaFfNFtOfpLfnoNUHPqQ02cvGoKUtlLYgPCjiaItlxcF66vKWrtkNI7ixz oWyysvb28mTVUlq0ELMCMddC9xLzlAANOHUGsrFy+rlIn0sn+3QNg== From: Collin Walling To: devel@lists.libvirt.org Subject: [PATCH v1 4/5] virsh: add --disable-deprecated-features flag to domcapabilities Date: Tue, 12 Nov 2024 12:39:59 -0500 Message-ID: <20241112174000.27518-5-walling@linux.ibm.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20241112174000.27518-1-walling@linux.ibm.com> References: <20241112174000.27518-1-walling@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 75eE_BDOAF2HKpvFLrPa9X-mJFQGB0kQ X-Proofpoint-ORIG-GUID: 75eE_BDOAF2HKpvFLrPa9X-mJFQGB0kQ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 phishscore=0 priorityscore=1501 mlxscore=0 suspectscore=0 clxscore=1015 lowpriorityscore=0 mlxlogscore=919 bulkscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2411120141 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ALW3HP6IKNVAXDDS4XIDVPXZF5ER63PH X-Message-ID-Hash: ALW3HP6IKNVAXDDS4XIDVPXZF5ER63PH X-MailFrom: walling@linux.ibm.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1731433446155116600 Content-Type: text/plain; charset="utf-8" Add a new flag, --disable-deprecated-features, to the domcapabilities command. This will modify the output to show the 'host-model' CPU with features flagged as deprecated paired with the 'disable' policy. virsh domcapabilities --disable-deprecated-features Signed-off-by: Collin Walling --- docs/manpages/virsh.rst | 6 ++++++ include/libvirt/libvirt-domain.h | 12 ++++++++++++ src/libvirt-domain.c | 2 +- src/qemu/qemu_capabilities.c | 20 ++++++++++++++++++++ src/qemu/qemu_capabilities.h | 3 +++ src/qemu/qemu_driver.c | 8 +++++++- tools/virsh-host.c | 9 ++++++++- 7 files changed, 57 insertions(+), 3 deletions(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 6776ea53d0..2700434dc4 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -568,6 +568,7 @@ domcapabilities =20 domcapabilities [virttype] [emulatorbin] [arch] [machine] [--xpath EXPRESSION] [--wrap] + [--disabled-deprecated-features] =20 =20 Print an XML document describing the domain capabilities for the @@ -609,6 +610,11 @@ a standalone document, however, for ease of additional= processing, the **--wrap** argument will cause the matching node to be wrapped in a common root node. =20 +The **--disabled-deprecated-features** argument will modify the contents +of host-model CPU XML, updating the features list with any features +flagged as deprecated for the CPU model by the hypervisor. These +features will be paired with the "disable" policy. + =20 pool-capabilities ----------------- diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 9232ce2e6b..47e06fe68e 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -1478,6 +1478,18 @@ int virDomainMigrateGetMaxSpeed(virDomainPtr domain, int virDomainMigrateStartPostCopy(virDomainPtr domain, unsigned int flags); =20 +/** + * virConnectGetDomainCapabilitiesFlags: + * + * Domain capabilities flags. + * + * Since: 10.10.0 + */ +typedef enum { + /* Report host model with deprecated features disabled. (Since: 10.10.= 0) */ + VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEATURES =3D (1= << 0), +} virConnectGetDomainCapabilitiesFlags; + char * virConnectGetDomainCapabilities(virConnectPtr conn, const char *emulatorbin, const char *arch, diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 7c6b93963c..e8e5379672 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -12166,7 +12166,7 @@ virDomainSetUserPassword(virDomainPtr dom, * @arch: domain architecture * @machine: machine type * @virttype: virtualization type - * @flags: extra flags; not used yet, so callers should always pass 0 + * @flags: extra flags; bitwise-OR of virConnectGetDomainCapabilitiesFlags * * Prior creating a domain (for instance via virDomainCreateXML * or virDomainDefineXML) it may be suitable to know what the diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 8a10816757..8f2c0c8f93 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -3324,6 +3324,26 @@ virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps, } =20 =20 +void +virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, + virDomainVirtType virtType, + virCPUDef *cpu) +{ + qemuMonitorCPUModelInfo *modelInfo; + size_t i; + + modelInfo =3D virQEMUCapsGetCPUModelInfo(qemuCaps, virtType); + + if (!modelInfo || !modelInfo->deprecated_props) + return; + + for (i =3D 0; i < g_strv_length(modelInfo->deprecated_props); i++) { + virCPUDefUpdateFeature(cpu, modelInfo->deprecated_props[i], + VIR_CPU_FEATURE_DISABLE); + } +} + + struct tpmTypeToCaps { int type; virQEMUCapsFlags caps; diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 3acb903478..735db2b9af 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -763,6 +763,9 @@ int virQEMUCapsGetCPUFeatures(virQEMUCaps *qemuCaps, virDomainVirtType virtType, bool migratable, char ***features); +void virQEMUCapsUpdateCPUDeprecatedFeatures(virQEMUCaps *qemuCaps, + virDomainVirtType virtType, + virCPUDef *cpu); =20 virDomainVirtType virQEMUCapsGetVirtType(virQEMUCaps *qemuCaps); =20 diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 72a9542c0b..57e553cef3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16524,7 +16524,8 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn, virDomainVirtType virttype; g_autoptr(virDomainCaps) domCaps =3D NULL; =20 - virCheckFlags(0, NULL); + virCheckFlags(VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_F= EATURES, + NULL); =20 if (virConnectGetDomainCapabilitiesEnsureACL(conn) < 0) return NULL; @@ -16543,6 +16544,11 @@ qemuConnectGetDomainCapabilities(virConnectPtr con= n, arch, virttype))) return NULL; =20 + if (flags & VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_FEA= TURES) { + virQEMUCapsUpdateCPUDeprecatedFeatures(qemuCaps, virttype, + domCaps->cpu.hostModel); + } + return virDomainCapsFormat(domCaps); } =20 diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 2fe64e415f..f4e7324f42 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -114,6 +114,10 @@ static const vshCmdOptDef opts_domcapabilities[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("wrap xpath results in an common root element"), }, + {.name =3D "disable-deprecated-features", + .type =3D VSH_OT_BOOL, + .help =3D N_("report host CPU model with deprecated features disabled= "), + }, {.name =3D NULL} }; =20 @@ -126,10 +130,13 @@ cmdDomCapabilities(vshControl *ctl, const vshCmd *cmd) const char *arch =3D NULL; const char *machine =3D NULL; const char *xpath =3D NULL; - const unsigned int flags =3D 0; /* No flags so far */ + unsigned int flags =3D 0; bool wrap =3D vshCommandOptBool(cmd, "wrap"); virshControl *priv =3D ctl->privData; =20 + if (vshCommandOptBool(cmd, "disable-deprecated-features")) + flags |=3D VIR_CONNECT_GET_DOMAIN_CAPABILITIES_DISABLE_DEPRECATED_= FEATURES; + if (vshCommandOptString(ctl, cmd, "virttype", &virttype) < 0 || vshCommandOptString(ctl, cmd, "emulatorbin", &emulatorbin) < 0 || vshCommandOptString(ctl, cmd, "arch", &arch) < 0 || --=20 2.45.1