From nobody Tue Feb 10 05:27:13 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=pass(p=none dis=none) header.from=redhat.com 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 1656432665697433.84024863537286; Tue, 28 Jun 2022 09:11:05 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-375-N1pD8ofRMVeB8dx-bCegYA-1; Tue, 28 Jun 2022 12:10:03 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5E913185A7BA; Tue, 28 Jun 2022 16:09:53 +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 14B8E40CF8E4; Tue, 28 Jun 2022 16:09:53 +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 E18FA1947054; Tue, 28 Jun 2022 16:09:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9775F1947056 for ; Tue, 28 Jun 2022 16:09:51 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7DE7D2166B29; Tue, 28 Jun 2022 16:09:51 +0000 (UTC) Received: from work.fritz.box (unknown [10.39.193.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C1792166B2C; Tue, 28 Jun 2022 16:09:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656432664; 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=7XDCMxo1cMgbzDIdQuxrkJomwXUsWXaoJ8WZm3glL9o=; b=Dlw+gJ5x27DtddJJc+mKPqwd24fc4A/vu5/jwhaNhhvtxPWnKgUneXKnhMKjkJfNQ4Itec 81LQbh1VYCGsVQduv4CXaJGT8z/JlS0VEihfsiSbw8aZYUifLqdhkeNltQR2kUK1wNIPBt UfImx8xx62rE6aY/C+lybMuqobSV9+Y= X-MC-Unique: N1pD8ofRMVeB8dx-bCegYA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 5/9] tools: Report hypervisor cpu model names Date: Tue, 28 Jun 2022 18:09:42 +0200 Message-Id: <20220628160946.61028-6-twiederh@redhat.com> In-Reply-To: <20220628160946.61028-1-twiederh@redhat.com> References: <20220628160946.61028-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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: Tim Wiederhake Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1656432667482100001 Content-Type: text/plain; charset="utf-8"; x-default="true" $ virsh hypervisor-cpu-models --arch x86_64 Name Alias ---------------------------------------------------- max host base qemu64-v1 qemu64 qemu64-v1 qemu32-v1 qemu32 qemu32-v1 phenom-v1 phenom phenom-v1 (...) Note that this includes alias names and cpu models that currently do not exist in libvirt, e.g. Denverton and Knights Mill. Signed-off-by: Tim Wiederhake --- docs/manpages/virsh.rst | 14 +++++++++ tools/virsh-host.c | 67 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 45469f2f35..a55792b0e2 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -955,6 +955,20 @@ If *--validate* is specified, validates the format of = the XML document against an internal RNG schema. =20 =20 +hypervisor-cpu-models +--------------------- + +**Syntax:** + +:: + + hypervisor-cpu-models [arch] + +List the names of cpu models known to the hypervisor. A hypervisor may def= ine +alias names for some or all cpu models. Note that the cpu models may differ +from libvirt, even if named identically. + + hypervisor-cpu-baseline ----------------------- =20 diff --git a/tools/virsh-host.c b/tools/virsh-host.c index ead966b500..cb8e1e8c6d 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -32,6 +32,7 @@ #include "virstring.h" #include "virfile.h" #include "virenum.h" +#include "vsh-table.h" =20 /* * "capabilities" command @@ -1674,6 +1675,65 @@ cmdHypervisorCPUCompare(vshControl *ctl, } =20 =20 +/* + * "hypervisor-cpu-models" command + */ +static const vshCmdInfo info_hypervisor_cpu_models[] =3D { + {.name =3D "help", + .data =3D N_("return list of CPU models supported by a specific hyper= visor") + }, + {.name =3D "desc", + .data =3D N_("Return list of CPU models supported by a specific hyper= visor") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_hypervisor_cpu_models[] =3D { + {.name =3D "arch", + .type =3D VSH_OT_STRING, + .completer =3D virshArchCompleter, + .help =3D N_("CPU architecture (/domain/os/type/@arch)"), + }, + {.name =3D NULL} +}; + +static bool +cmdHypervisorCPUModels(vshControl *ctl, + const vshCmd *cmd) +{ + virshControl *priv =3D ctl->privData; + bool ret =3D false; + const char *arch =3D NULL; + char **name =3D NULL; + char **alias =3D NULL; + int nresults; + g_autoptr(vshTable) table =3D vshTableNew(_("Name"), _("Alias"), NULL); + + if (!table) + return ret; + + if (vshCommandOptStringReq(ctl, cmd, "arch", &arch) < 0) + return false; + + nresults =3D virConnectGetHypervisorCPUModelNames(priv->conn, arch, &n= ame, + &alias, 0); + if (nresults >=3D 0) { + size_t index; + for (index =3D 0; index < nresults; ++index) { + if (vshTableRowAppend(table, name[index], alias[index], NULL) = < 0) + return ret; + g_free(name[index]); + g_free(alias[index]); + } + ret =3D true; + } + vshTablePrintToStdout(table, ctl); + g_free(name); + g_free(alias); + + return ret; +} + /* * "hypervisor-cpu-baseline" command */ @@ -1819,6 +1879,13 @@ const vshCmdDef hostAndHypervisorCmds[] =3D { .info =3D info_hostname, .flags =3D 0 }, + { + .name =3D "hypervisor-cpu-models", + .handler =3D cmdHypervisorCPUModels, + .opts =3D opts_hypervisor_cpu_models, + .info =3D info_hypervisor_cpu_models, + .flags =3D 0 + }, {.name =3D "hypervisor-cpu-baseline", .handler =3D cmdHypervisorCPUBaseline, .opts =3D opts_hypervisor_cpu_baseline, --=20 2.31.1