From nobody Sat Feb 7 09:59:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1679499685; cv=none; d=zohomail.com; s=zohoarc; b=Gxi5GvvQXKBcpqCvab6O79926lN112LKQbzPDSHof9+twK1LfuEG6MriHbOl4Qfci+rbguEFkDF/aYsTKo4PSzpUdi6Q1qt718bNvV/6iblRmq7CaOi4ErsFX39vflC3qgk7OIxdTsb/uoRnO3Z9oIkXsCkIg1M7dyMZTu/ocJY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679499685; 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; bh=VNJkQJcpXh5L2AlXk5vsftW6q7c7NegEFdBn7yQOFLg=; b=JkxM4Mygc5MlMxUzHWzBxbILN6k5TxZbWdrFuTkIkWdsGJS3ydk3V2AygL5wc9+K9ifijOG7V1Q/Y3Wn4W1ceIoKwNdZU1l/D17FAarfXqiu9kFiEufCo8LsLAM6K4RaMx8Yd/vG25lrR7hJr+MYwFsrtixv/6ZxjrqJkA1ijak= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=reject dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 167949968521074.02752603255419; Wed, 22 Mar 2023 08:41:25 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-391-9yBnwRXBMkW8lMJ7DZl3lA-1; Wed, 22 Mar 2023 11:41:17 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 00F0D1C08966; Wed, 22 Mar 2023 15:41:13 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF05E202701E; Wed, 22 Mar 2023 15:41:12 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 938971946589; Wed, 22 Mar 2023 15:41:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 731E31946587 for ; Wed, 22 Mar 2023 15:39:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 58CD81410F1E; Wed, 22 Mar 2023 15:39:53 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5108D140E95F for ; Wed, 22 Mar 2023 15:39:53 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3547D85A5B1 for ; Wed, 22 Mar 2023 15:39:53 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-647-KeLeR0lQORC2eEYmW1ZyXA-1; Wed, 22 Mar 2023 11:39:51 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32MFCfM7017924 for ; Wed, 22 Mar 2023 15:39:49 GMT Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pg447gs2n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 Mar 2023 15:39:49 +0000 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32MFMNl5011659 for ; Wed, 22 Mar 2023 15:39:48 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([9.208.129.118]) by ppma04wdc.us.ibm.com (PPS) with ESMTPS id 3pd4x791c0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 Mar 2023 15:39:48 +0000 Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32MFdkPR12124682 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 Mar 2023 15:39:46 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D1BBD58050; Wed, 22 Mar 2023 15:39:46 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7D4C758054; Wed, 22 Mar 2023 15:39:46 +0000 (GMT) Received: from dhcp-9-57-191-246.pok.ibm.com (unknown [9.57.191.246]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 22 Mar 2023 15:39:46 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679499682; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=VNJkQJcpXh5L2AlXk5vsftW6q7c7NegEFdBn7yQOFLg=; b=bzWhrqi4V8c3UDFgKmeYbhyyPlR7tLlF96MaaEUxLx3OZvh3zXR+RpOoQ9zi47ZxRBNEPI UcBY92shgOaG4wTnV23OiawKJHemFxHldvQXm8qzoVENgR6fMgdweuKNZTOvFZwIAnLs9n GzWdoQn/Fyjd79bx3lluGNyPXG60z2U= X-MC-Unique: 9yBnwRXBMkW8lMJ7DZl3lA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: KeLeR0lQORC2eEYmW1ZyXA-1 From: Collin Walling To: libvir-list@redhat.com Subject: [PATCH v1 3/4] virsh: Introduce new hypervisor-cpu-models command Date: Wed, 22 Mar 2023 11:39:17 -0400 Message-Id: <20230322153918.96924-4-walling@linux.ibm.com> In-Reply-To: <20230322153918.96924-1-walling@linux.ibm.com> References: <20230322153918.96924-1-walling@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: sFTdWwUfpSykMJUapLcQ6vfwD5tkcLJD X-Proofpoint-ORIG-GUID: sFTdWwUfpSykMJUapLcQ6vfwD5tkcLJD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-22_12,2023-03-22_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 bulkscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 malwarescore=0 mlxscore=0 mlxlogscore=921 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303150002 definitions=main-2303220111 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fiuczy@linux.ibm.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1679499686089100001 Content-Type: text/plain; charset="utf-8"; x-default="true" This command is a virsh wrapper for virConnectGetHypervisorCPUNames. Signed-off-by: Collin Walling Reviewed-by: Boris Fiuczynski --- docs/manpages/virsh.rst | 20 ++++++++++++ tools/virsh-host.c | 70 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 26c328d390..c156e60d6e 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -1004,6 +1004,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 21d479fd01..2eedc1517b 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -1779,6 +1779,70 @@ cmdHypervisorCPUBaseline(vshControl *ctl, return ret; } =20 +/* + * "hypervisor-cpu-models" command + */ +static const vshCmdInfo info_hypervisor_cpu_models[] =3D { + {.name =3D "help", + .data =3D N_("Hypervisor reported CPU models") + }, + {.name =3D "desc", + .data =3D N_("Get the CPU models reported by the hypervisor.") + }, + {.name =3D NULL} +}; + +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; + const char *emulator =3D NULL; + const char *arch =3D NULL; + const char *machine =3D NULL; + g_autofree char *result =3D NULL; + virshControl *priv =3D ctl->privData; + + if (vshCommandOptStringReq(ctl, cmd, "virttype", &virttype) < 0 || + vshCommandOptStringReq(ctl, cmd, "emulator", &emulator) < 0 || + vshCommandOptStringReq(ctl, cmd, "arch", &arch) < 0 || + vshCommandOptStringReq(ctl, cmd, "machine", &machine) < 0) + return false; + + result =3D virConnectGetHypervisorCPUModelNames(priv->conn, emulator, = arch, + machine, virttype, 0); + + if (!result) { + vshError(ctl, "%s", _("failed to get CPU model names")); + return false; + } + + vshPrint(ctl, "%s\n", result); + return true; +} + =20 const vshCmdDef hostAndHypervisorCmds[] =3D { {.name =3D "allocpages", @@ -1847,6 +1911,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.39.0