From nobody Mon Feb 9 12:43:21 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 1656432666566188.30995058781718; Tue, 28 Jun 2022 09:11:06 -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-348-KPeO48_7MBST5LlOyqSdYQ-1; Tue, 28 Jun 2022 12:10:06 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9B4423821C27; Tue, 28 Jun 2022 16:09:55 +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 85F5A1415108; Tue, 28 Jun 2022 16:09:55 +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 57142194705E; Tue, 28 Jun 2022 16:09:55 +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 5E5061947061 for ; Tue, 28 Jun 2022 16:09:54 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4F1482166B2A; Tue, 28 Jun 2022 16:09:54 +0000 (UTC) Received: from work.fritz.box (unknown [10.39.193.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB30A2166B29; Tue, 28 Jun 2022 16:09:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656432665; 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=+UEO7WoOCoOTEpBLIZ6XYPVVWYJtVeOyhfhJSvfSchY=; b=jRn/URkMDT9tRQmwxHh8+DqeeFtl7rDDKqcAAPPCetJyl3n/AL2r0C/rtB15BmXsLkl1pK RlmkYPMgeBRZCbCXHH2z52siuOScusU0buKXMZYKni4PV7B3xaSxXEI89Hatzuq60dDM2+ RjFzNUUTGNOs6lskW+Y+rfJK9IMvuV0= X-MC-Unique: KPeO48_7MBST5LlOyqSdYQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 9/9] tools: Report hypervisor cpu model definitions Date: Tue, 28 Jun 2022 18:09:46 +0200 Message-Id: <20220628160946.61028-10-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.85 on 10.11.54.7 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: 1656432667531100002 Content-Type: text/plain; charset="utf-8"; x-default="true" $ virsh hypervisor-cpu-definition --machine pc --arch x86_64 qemu64 qemu64 Signed-off-by: Tim Wiederhake --- docs/manpages/virsh.rst | 13 +++++++++ tools/virsh-host.c | 65 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index a55792b0e2..aa6c732fd0 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -969,6 +969,19 @@ alias names for some or all cpu models. Note that the = cpu models may differ from libvirt, even if named identically. =20 =20 +hypervisor-cpu-definition +------------------------- + +**Syntax:** + +:: + + hypervisor-cpu-definition name [arch] [machine] + +Retrieve the named CPU model as defined by the hypervisor. Note that the c= pu +model 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 cb8e1e8c6d..75b439d04b 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -1734,6 +1734,64 @@ cmdHypervisorCPUModels(vshControl *ctl, return ret; } =20 +/* + * "hypervisor-cpu-definition" command + */ +static const vshCmdInfo info_hypervisor_cpu_definition[] =3D { + {.name =3D "help", + .data =3D N_("return CPU model as defined by hypervisor") + }, + {.name =3D "desc", + .data =3D N_("Return CPU model as defined by hypervisor") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_hypervisor_cpu_definition[] =3D { + {.name =3D "name", + .type =3D VSH_OT_DATA, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("CPU name"), + }, + {.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 +cmdHypervisorCPUDefinition(vshControl *ctl, + const vshCmd *cmd) +{ + virshControl *priv =3D ctl->privData; + const char *arch =3D NULL; + const char *machine =3D NULL; + const char *name =3D NULL; + g_autofree char *xml =3D NULL; + + if (vshCommandOptStringReq(ctl, cmd, "arch", &arch) < 0) + return false; + + if (vshCommandOptStringReq(ctl, cmd, "machine", &machine) < 0) + return false; + + if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0) + return false; + + if (virConnectGetHypervisorCPUModelDefinition(priv->conn, arch, machin= e, + name, &xml, 0) < 0) + return false; + + vshPrint(ctl, "%s", xml); + return true; +} + /* * "hypervisor-cpu-baseline" command */ @@ -1886,6 +1944,13 @@ const vshCmdDef hostAndHypervisorCmds[] =3D { .info =3D info_hypervisor_cpu_models, .flags =3D 0 }, + { + .name =3D "hypervisor-cpu-definition", + .handler =3D cmdHypervisorCPUDefinition, + .opts =3D opts_hypervisor_cpu_definition, + .info =3D info_hypervisor_cpu_definition, + .flags =3D 0 + }, {.name =3D "hypervisor-cpu-baseline", .handler =3D cmdHypervisorCPUBaseline, .opts =3D opts_hypervisor_cpu_baseline, --=20 2.31.1