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

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



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 linux vnet ibm com>
> ---
>  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 redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


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