Re: [PATCH 3/3] virsh: Use virNodeGetCPUMap if possible

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/26/2012 07:19 AM, Viktor Mihajlovski wrote:
> Modified the places where virNodeGetInfo was used for the purpose
> of obtaining the maximum node CPU number. Transparently falling
> back to virNodeGetInfo in case of failure.
> 
> Signed-off-by: Viktor Mihajlovski <mihajlov@xxxxxxxxxxxxxxxxxx>
> ---
>  tools/virsh-domain.c | 36 ++++++++++++++++++++++++------------
>  1 file changed, 24 insertions(+), 12 deletions(-)
> 
> diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
> index 0906267..0aa643a 100644
> --- a/tools/virsh-domain.c
> +++ b/tools/virsh-domain.c
> @@ -4508,9 +4508,14 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
>      if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
>          return false;
>  
> -    if (virNodeGetInfo(ctl->conn, &nodeinfo) != 0) {
> -        virDomainFree(dom);
> -        return false;
> +    if ((maxcpu = virNodeGetCPUMap(ctl->conn, NULL, NULL, 0)) < 0) {
> +        /* fall back to nodeinfo */
> +        if (virNodeGetInfo(ctl->conn, &nodeinfo) == 0) {
> +            maxcpu = VIR_NODEINFO_MAXCPUS(nodeinfo);
> +        } else {
> +            virDomainFree(dom);
> +            return false;
> +        }

This looks correct.  However, it may be easier to write a helper
function vshGetCPUCount, rather than copying and pasting this code into
multiple places.  I'm okay giving this an ACK, but since I've already
asked for a v2 of patch 1, you might want to do a v2 of this as well.
Oh, and I guess the same comment applies to the python code in 2/3.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]