From nobody Tue Jan 21 07:32:45 2025 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 1736937340309398.50228972730315; Wed, 15 Jan 2025 02:35:40 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id A21F8190F; Wed, 15 Jan 2025 05:35:39 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 6DAE31996; Wed, 15 Jan 2025 05:34:23 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 976BC15FE; Wed, 15 Jan 2025 05:34:16 -0500 (EST) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 EF28915F8 for ; Wed, 15 Jan 2025 05:34:15 -0500 (EST) Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50ENwKxh014643 for ; Wed, 15 Jan 2025 10:34:15 GMT Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 44622ht7cf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 15 Jan 2025 10:34:14 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 50F86bI5016499 for ; Wed, 15 Jan 2025 10:34:13 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4445p1qfpb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 15 Jan 2025 10:34:13 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 50FAYAMC38011298 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Jan 2025 10:34:10 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 72F0C20043; Wed, 15 Jan 2025 10:34:10 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5C7AA20063; Wed, 15 Jan 2025 10:34:10 +0000 (GMT) Received: from fiuczyvm.. (unknown [9.152.222.247]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Jan 2025 10:34:10 +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=-3.0 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,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=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=gkepbmcoKOg1VYowq c784N4XCtbhSk5jsSVQED1wz1g=; b=NbnHAomub+e3NiuwjpC4L4h+SiWlhWWQ0 RPFTeLYAgUaj60ws6Ni0pircBwQHSYs2xA+mJ4993k8vYQQ88sVPkAkc4yFtkLT7 5DM+51jtszITC/JB281fPDJVSJZ3iv1lUQeo9PrjF7tMgb5DhNRo94pH8DuhrtH8 aP84lGw3vXPpI2TwizScpibIS1JuxiItdx6ZTg9J4Z4jVrZc/636TjaPMm+Hlhsv S/MuzRMTuNWMQ23konvWa0dmnwcNM6dAuWopQIBlPu/LF5S2rbsYrjtd4UMKFzeQ PXlsTZovOWw7VsxgrGwJEYPEmo0Cz3AdeVVSMbEMU0KNnn5tyV6cw== From: Boris Fiuczynski To: devel@lists.libvirt.org Subject: [PATCH 4/4] virsh: Introduce new hypervisor-cpu-models command Date: Wed, 15 Jan 2025 11:34:09 +0100 Message-ID: <20250115103409.31064-5-fiuczy@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250115103409.31064-1-fiuczy@linux.ibm.com> References: <20250115103409.31064-1-fiuczy@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: JNuEliRWxPpmUlnjfpjndKTcuHkylrHy X-Proofpoint-ORIG-GUID: JNuEliRWxPpmUlnjfpjndKTcuHkylrHy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-15_04,2025-01-15_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 impostorscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 suspectscore=0 priorityscore=1501 mlxlogscore=817 malwarescore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501150079 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: CJKC6ZXZQR7HSG3LEOE5OIOLH7UVKZRX X-Message-ID-Hash: CJKC6ZXZQR7HSG3LEOE5OIOLH7UVKZRX X-MailFrom: fiuczy@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 CC: djudkovi@linux.ibm.com, walling@linux.ibm.com 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: 1736937342008019000 Content-Type: text/plain; charset="utf-8" From: David Judkovics Add new virsh 'host' group command 'hypervisor-cpu-models' to virsh. Signed-off-by: David Judkovics Reviewed-by: Boris Fiuczynski Signed-off-by: Boris Fiuczynski --- docs/manpages/virsh.rst | 20 +++++++++++ tools/virsh-host.c | 74 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index e801037c04..0f165944eb 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -1023,6 +1023,26 @@ listed in the XML description. If *--migratable* is = specified, features that block migration will not be included in the resulting CPU. =20 =20 +hypervisor-cpu-models +--------------------- + +**Syntax:** + +:: + + hypervisor-cpu-models [virttype] [emulator] [arch] [machine] + +Print the list of CPU models known by the hypervisor for the specified arc= hitecture. +It is not guaranteed that a listed CPU will run on the host. To determine = CPU +model compatibility with the host, see ``virsh hypervisor-cpu-baseline`` a= nd +``virsh hypervisor-cpu-compare``. + +The *virttype* option specifies the virtualization type (usable in the 'ty= pe' +attribute of the top level element from the domain XML). *emulato= r* +specifies the path to the emulator, *arch* specifies the CPU architecture,= and +*machine* specifies the machine type. + + DOMAIN COMMANDS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 diff --git a/tools/virsh-host.c b/tools/virsh-host.c index f4e7324f42..7d52f22baa 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -1758,6 +1758,74 @@ cmdHypervisorCPUBaseline(vshControl *ctl, } =20 =20 +/* + * "hypervisor-cpu-models" command + */ +static const vshCmdInfo info_hypervisor_cpu_models =3D { + .help =3D N_("Hypervisor reported CPU models"), + .desc =3D N_("Get the CPU models reported by the hypervisor."), +}; + +static const vshCmdOptDef opts_hypervisor_cpu_models[] =3D { + {.name =3D "virttype", + .type =3D VSH_OT_STRING, + .completer =3D virshDomainVirtTypeCompleter, + .help =3D N_("virtualization type (/domain/@type)"), + }, + {.name =3D "emulator", + .type =3D VSH_OT_STRING, + .help =3D N_("path to emulator binary (/domain/devices/emulator)"), + }, + {.name =3D "arch", + .type =3D VSH_OT_STRING, + .completer =3D virshArchCompleter, + .help =3D N_("CPU architecture (/domain/os/type/@arch)"), + }, + {.name =3D "machine", + .type =3D VSH_OT_STRING, + .help =3D N_("machine type (/domain/os/type/@machine)"), + }, + {.name =3D NULL} +}; + +static bool +cmdHypervisorCPUModelNames(vshControl *ctl, + const vshCmd *cmd) +{ + const char *virttype =3D NULL; + char **models =3D NULL; + const char *emulator =3D NULL; + const char *arch =3D NULL; + const char *machine =3D NULL; + virshControl *priv =3D ctl->privData; + size_t i; + int nmodels; + + if (vshCommandOptString(ctl, cmd, "virttype", &virttype) < 0 || + vshCommandOptString(ctl, cmd, "emulator", &emulator) < 0 || + vshCommandOptString(ctl, cmd, "arch", &arch) < 0 || + vshCommandOptString(ctl, cmd, "machine", &machine) < 0) + return false; + + nmodels =3D virConnectGetHypervisorCPUModelNames(priv->conn, emulator,= arch, + machine, virttype, &mod= els, 0); + + if (nmodels < 0) { + vshError(ctl, "%s", _("failed to get Hypervisor CPU model names")); + return false; + } + + for (i =3D 0; i < nmodels; i++) { + vshPrint(ctl, "%s\n", models[i]); + VIR_FREE(models[i]); + } + + VIR_FREE(models); + + return true; +} + + const vshCmdDef hostAndHypervisorCmds[] =3D { {.name =3D "allocpages", .handler =3D cmdAllocpages, @@ -1825,6 +1893,12 @@ const vshCmdDef hostAndHypervisorCmds[] =3D { .info =3D &info_hypervisor_cpu_compare, .flags =3D 0 }, + {.name =3D "hypervisor-cpu-models", + .handler =3D cmdHypervisorCPUModelNames, + .opts =3D opts_hypervisor_cpu_models, + .info =3D &info_hypervisor_cpu_models, + .flags =3D 0 + }, {.name =3D "maxvcpus", .handler =3D cmdMaxvcpus, .opts =3D opts_maxvcpus, --=20 2.47.0