$ virsh hypervisor-cpu-definition --machine pc --arch x86_64 qemu64
<cpu>
<model>qemu64</model>
<feature name='cmov'/>
<feature name='mmx'/>
<feature name='xd'/>
<feature name='x-intel-pt-auto-level'/>
<feature name='kvm_asyncpf'/>
<feature name='kvm-asyncpf'/>
<feature name='legacy-cache'/>
<feature name='vmware-cpuid-freq'/>
<feature name='mce'/>
<feature name='mca'/>
<feature name='msr'/>
<feature name='fxsr'/>
<feature name='cpuid-0xb'/>
<feature name='kvm_pv_eoi'/>
<feature name='pni'/>
<feature name='x2apic'/>
<feature name='i64'/>
<feature name='pae'/>
<feature name='pat'/>
<feature name='sse'/>
<feature name='kvm_nopiodelay'/>
<feature name='kvm-nopiodelay'/>
<feature name='kvmclock-stable-bit'/>
<feature name='hypervisor'/>
<feature name='syscall'/>
<feature name='x-migrate-smi-count'/>
<feature name='full-cpuid-auto-level'/>
<feature name='sse3'/>
<feature name='sse2'/>
<feature name='kvm-pv-eoi'/>
<feature name='cx8'/>
<feature name='pge'/>
<feature name='fill-mtrr-mask'/>
<feature name='cx16'/>
<feature name='de'/>
<feature name='clflush'/>
<feature name='tsc'/>
<feature name='fpu'/>
<feature name='check'/>
<feature name='apic'/>
<feature name='kvm-steal-time'/>
<feature name='kvm_steal_time'/>
<feature name='kvmclock'/>
<feature name='l3-cache'/>
<feature name='nx'/>
<feature name='tcg-cpuid'/>
<feature name='lm'/>
<feature name='pse'/>
<feature name='sep'/>
<feature name='kvm'/>
<feature name='lahf-lm'/>
<feature name='lahf_lm'/>
<feature name='mtrr'/>
<feature name='pse36'/>
</cpu>
Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
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.
+hypervisor-cpu-definition
+-------------------------
+
+**Syntax:**
+
+::
+
+ hypervisor-cpu-definition name [arch] [machine]
+
+Retrieve the named CPU model as defined by the hypervisor. Note that the cpu
+model may differ from libvirt, even if named identically.
+
+
hypervisor-cpu-baseline
-----------------------
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;
}
+/*
+ * "hypervisor-cpu-definition" command
+ */
+static const vshCmdInfo info_hypervisor_cpu_definition[] = {
+ {.name = "help",
+ .data = N_("return CPU model as defined by hypervisor")
+ },
+ {.name = "desc",
+ .data = N_("Return CPU model as defined by hypervisor")
+ },
+ {.name = NULL}
+};
+
+static const vshCmdOptDef opts_hypervisor_cpu_definition[] = {
+ {.name = "name",
+ .type = VSH_OT_DATA,
+ .flags = VSH_OFLAG_REQ,
+ .help = N_("CPU name"),
+ },
+ {.name = "arch",
+ .type = VSH_OT_STRING,
+ .completer = virshArchCompleter,
+ .help = N_("CPU architecture (/domain/os/type/@arch)"),
+ },
+ {.name = "machine",
+ .type = VSH_OT_STRING,
+ .help = N_("machine type (/domain/os/type/@machine)"),
+ },
+ {.name = NULL}
+};
+
+static bool
+cmdHypervisorCPUDefinition(vshControl *ctl,
+ const vshCmd *cmd)
+{
+ virshControl *priv = ctl->privData;
+ const char *arch = NULL;
+ const char *machine = NULL;
+ const char *name = NULL;
+ g_autofree char *xml = 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, machine,
+ name, &xml, 0) < 0)
+ return false;
+
+ vshPrint(ctl, "%s", xml);
+ return true;
+}
+
/*
* "hypervisor-cpu-baseline" command
*/
@@ -1886,6 +1944,13 @@ const vshCmdDef hostAndHypervisorCmds[] = {
.info = info_hypervisor_cpu_models,
.flags = 0
},
+ {
+ .name = "hypervisor-cpu-definition",
+ .handler = cmdHypervisorCPUDefinition,
+ .opts = opts_hypervisor_cpu_definition,
+ .info = info_hypervisor_cpu_definition,
+ .flags = 0
+ },
{.name = "hypervisor-cpu-baseline",
.handler = cmdHypervisorCPUBaseline,
.opts = opts_hypervisor_cpu_baseline,
--
2.31.1