From nobody Wed May 14 02:53:41 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526460027418355.7886751477075; Wed, 16 May 2018 01:40:27 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 19BF430C1325; Wed, 16 May 2018 08:40:24 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D0CED2B472; Wed, 16 May 2018 08:40:23 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6A8B9180BAD1; Wed, 16 May 2018 08:40:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4G8dmaf018447 for ; Wed, 16 May 2018 04:39:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4793210AF9F6; Wed, 16 May 2018 08:39:48 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E15211142374 for ; Wed, 16 May 2018 08:39:46 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id D1AB9102EDA; Wed, 16 May 2018 10:39:42 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 16 May 2018 10:39:33 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 14/22] virsh: Introduce new hypervisor-cpu-baseline command X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 16 May 2018 08:40:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This command is a virsh wrapper for virConnectBaselineHypervisorCPU. Signed-off-by: Jiri Denemark Reviewed-by: J=EF=BF=BDn Tomko --- tools/virsh-host.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++ tools/virsh.pod | 47 ++++++++++++++++++++--- 2 files changed, 137 insertions(+), 6 deletions(-) diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 1e7cfcbd5e..8fde5da50e 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -1702,6 +1702,96 @@ cmdHypervisorCPUCompare(vshControl *ctl, } =20 =20 +/* + * "hypervisor-cpu-baseline" command + */ +static const vshCmdInfo info_hypervisor_cpu_baseline[] =3D { + {.name =3D "help", + .data =3D N_("compute baseline CPU usable by a specific hypervisor") + }, + {.name =3D "desc", + .data =3D N_("Compute baseline CPU for a set of given CPUs. The resul= t " + "will be tailored to the specified hypervisor.") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_hypervisor_cpu_baseline[] =3D { + VIRSH_COMMON_OPT_FILE(N_("file containing XML CPU descriptions")), + {.name =3D "virttype", + .type =3D VSH_OT_STRING, + .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, + .help =3D N_("domain architecture (/domain/os/type/@arch)"), + }, + {.name =3D "machine", + .type =3D VSH_OT_STRING, + .help =3D N_("machine type (/domain/os/type/@machine)"), + }, + {.name =3D "features", + .type =3D VSH_OT_BOOL, + .help =3D N_("Show features that are part of the CPU model type") + }, + {.name =3D "migratable", + .type =3D VSH_OT_BOOL, + .help =3D N_("Do not include features that block migration") + }, + {.name =3D NULL} +}; + +static bool +cmdHypervisorCPUBaseline(vshControl *ctl, + const vshCmd *cmd) +{ + const char *from =3D NULL; + const char *virttype =3D NULL; + const char *emulator =3D NULL; + const char *arch =3D NULL; + const char *machine =3D NULL; + bool ret =3D false; + char *result =3D NULL; + char **list =3D NULL; + unsigned int flags =3D 0; + virshControlPtr priv =3D ctl->privData; + + if (vshCommandOptBool(cmd, "features")) + flags |=3D VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES; + if (vshCommandOptBool(cmd, "migratable")) + flags |=3D VIR_CONNECT_BASELINE_CPU_MIGRATABLE; + + if (vshCommandOptStringReq(ctl, cmd, "file", &from) < 0 || + 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; + + if (!(list =3D vshExtractCPUDefXMLs(ctl, from))) + return false; + + result =3D virConnectBaselineHypervisorCPU(priv->conn, emulator, arch, + machine, virttype, + (const char **)list, + virStringListLength((const ch= ar **)list), + flags); + + if (result) { + vshPrint(ctl, "%s", result); + ret =3D true; + } + + VIR_FREE(result); + virStringListFree(list); + return ret; +} + + const vshCmdDef hostAndHypervisorCmds[] =3D { {.name =3D "allocpages", .handler =3D cmdAllocpages, @@ -1757,6 +1847,12 @@ const vshCmdDef hostAndHypervisorCmds[] =3D { .info =3D info_hostname, .flags =3D 0 }, + {.name =3D "hypervisor-cpu-baseline", + .handler =3D cmdHypervisorCPUBaseline, + .opts =3D opts_hypervisor_cpu_baseline, + .info =3D info_hypervisor_cpu_baseline, + .flags =3D 0 + }, {.name =3D "hypervisor-cpu-compare", .handler =3D cmdHypervisorCPUCompare, .opts =3D opts_hypervisor_cpu_compare, diff --git a/tools/virsh.pod b/tools/virsh.pod index 1a55092efd..d57ebadee6 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -574,12 +574,13 @@ I<--all> which executes the modification on all NUMA = cells. =3Ditem B I [I<--features>] [I<--migratable>] =20 Compute baseline CPU which will be supported by all host CPUs given in . -The list of host CPUs is built by extracting all elements from the -. Thus, the can contain either a set of elements separa= ted -by new lines or even a set of complete elements printed by -B command. If I<--features> is specified then the -resulting XML description will explicitly include all features that make -up the CPU, without this option features that are part of the CPU model +(See B command to get a CPU which can be provided= by a +specific hypervisor.) The list of host CPUs is built by extracting all +elements from the . Thus, the can contain either a set of +elements separated by new lines or even a set of complete +elements printed by B command. If I<--features> is specified +then the resulting XML description will explicitly include all features th= at +make up the CPU, without this option features that are part of the CPU mod= el will not be listed in the XML description. If I<--migratable> is specifi= ed, features that block migration will not be included in the resulting CPU. =20 @@ -643,6 +644,40 @@ I specifies the machine type. If I<--error> i= s specified, the command will return an error when the given CPU is incompatible with host CPU and a message providing more details about the incompatibility will be printed o= ut. =20 +=3Ditem B I [I] [I] [I<= arch>] +[I] [I<--features>] [I<--migratable>] + +Compute baseline CPU which will be compatible with all CPUs given in I +and can be provided by the specified hypervisor. (This is different from +B which does not consider any hypervisor abilities when comp= uting +the baseline CPU.) + +The XML I may contain either host or guest CPU definitions describin= g the +host CPU model. The host CPU definition is the element and its conte= nts +as printed by B command. The guest CPU definition may be cre= ated +from the host CPU model found in domain capabilities XML (printed by +B command). In addition to the elements, this comma= nd +accepts full capabilities XMLs, or domain capabilities XMLs containing the= CPU +definitions. For best results, use only the CPU definitions from domain +capabilities. + +When I contains only a single CPU definition, the command will print= the +same CPU updated according to additional options and restricted to the +capabilities of the specified hypervisor. Specifically, running +B command with no additional options on the +result of B will return transform the host CPU model +from domain capabilities XML to the form directly usable in domain XML. + +The I option specifies the virtualization type (usable in the 't= ype' +attribute of the top level element from the domain XML). I +specifies the path to the emulator, I specifies the CPU architecture= , and +I specifies the machine type. If I<--features> is specified then = the +resulting XML description will explicitly include all features that make u= p the +CPU, without this option features that are part of the CPU model will not = be +listed in the XML description. If I<--migratable> is specified, features t= hat +block migration will not be included in the resulting CPU. + + =3Dback =20 =3Dhead1 DOMAIN COMMANDS --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list