[libvirt] [PATCH 4/4] vcpupin: add the new options to "virsh vcpupin" command

Osier Yang jyang at redhat.com
Thu Mar 31 07:41:18 UTC 2011


于 2011年03月31日 13:41, Taku Izumi 写道:
>
> This patch adds the new option (--live and --config) to "virsh vcpupin"
> command. The behavior of above aption is the same as that of "virsh setmem",
> "virsh setvcpus", and whatnot. When the --config option is specified, the
> command affects a persistent domain, while --live option is specified,
> it affects a running (live) domain.
>
> Signed-off-by: Taku Izumi<izumi.taku at jp.fujitsu.com>
> ---
>   tools/virsh.c   |   22 ++++++++++++++++++++--
>   tools/virsh.pod |    5 ++++-
>   2 files changed, 24 insertions(+), 3 deletions(-)
>
> Index: libvirt/tools/virsh.c
> ===================================================================
> --- libvirt.orig/tools/virsh.c
> +++ libvirt/tools/virsh.c
> @@ -2712,6 +2712,8 @@ static const vshCmdOptDef opts_vcpupin[]
>       {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
>       {"vcpu", VSH_OT_INT, VSH_OFLAG_REQ, N_("vcpu number")},
>       {"cpulist", VSH_OT_DATA, VSH_OFLAG_REQ, N_("host cpu number(s) (comma separated)")},
> +    {"config", VSH_OT_BOOL, 0, N_("affect next boot")},
> +    {"live", VSH_OT_BOOL, 0, N_("affect running domain")},
>       {NULL, 0, 0, NULL}
>   };
>
> @@ -2728,6 +2730,16 @@ cmdVcpupin(vshControl *ctl, const vshCmd
>       int cpumaplen;
>       int i;
>       enum { expect_num, expect_num_or_comma } state;
> +    int config = vshCommandOptBool(cmd, "config");
> +    int live = vshCommandOptBool(cmd, "live");
> +    int flags = 0;
> +
> +    if (config)
> +        flags |= VIR_DOMAIN_VCPU_CONFIG;
> +    if (live)
> +        flags |= VIR_DOMAIN_VCPU_LIVE;
> +    if (!live&&  !config)
> +        flags = -1;
>
>       if (!vshConnectionUsability(ctl, ctl->conn))
>           return FALSE;
> @@ -2824,8 +2836,14 @@ cmdVcpupin(vshControl *ctl, const vshCmd
>               cpulist++;
>       } while (cpulist);
>
> -    if (virDomainPinVcpu(dom, vcpu, cpumap, cpumaplen) != 0) {
> -        ret = FALSE;
> +    if (flags == -1) {
> +        if (virDomainPinVcpu(dom, vcpu, cpumap, cpumaplen) != 0) {
> +            ret = FALSE;
> +        }
> +    } else {
> +        if (virDomainPinVcpuFlags(dom, vcpu, cpumap, cpumaplen, flags) != 0) {
> +            ret = FALSE;
> +        }
>       }
>
>       VIR_FREE(cpumap);
> Index: libvirt/tools/virsh.pod
> ===================================================================
> --- libvirt.orig/tools/virsh.pod
> +++ libvirt/tools/virsh.pod
> @@ -711,10 +711,13 @@ values; these two flags cannot both be s
>   Returns basic information about the domain virtual CPUs, like the number of
>   vCPUs, the running time, the affinity to physical processors.
>
> -=item B<vcpupin>  I<domain-id>  I<vcpu>  I<cpulist>
> +=item B<vcpupin>  I<domain-id>  I<vcpu>  I<cpulist>  optional I<--live>  I<--config>
>
>   Pin domain VCPUs to host physical CPUs. The I<vcpu>  number must be provided
>   and I<cpulist>  is a comma separated list of physical CPU numbers.
> +If I<--live>  is specified, affect a running guest.
> +If I<--config>  is specified, affect the next boot of a persistent guest.
> +Both flags may be given.

Oh, yeah, get your sense here, forget about the previous doubt on
2/4 patch. :-)

Looks good to me

>
>   =item B<vncdisplay>  I<domain-id>
>
>
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list




More information about the libvir-list mailing list