On 11/13/2012 05:54 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.
> Wrote utility function vshNodeGetCPUCount to compute node CPU
> number.
> 
> Signed-off-by: Viktor Mihajlovski <mihaj...@linux.vnet.ibm.com>
> ---
> V2 Changes:
> Implemented Eric Blake's suggestion to remove code bloat 
> introduced by first patch version.
> New helper function vshNodeGetCPUCount is now used to calculate
> the number of node CPUs.
> 
> +static int
> +vshNodeGetCPUCount(virConnectPtr conn)
> +{
> +    int ret;
> +    virNodeInfo nodeinfo;
> +
> +    if ((ret = virNodeGetCPUMap(conn, NULL, NULL, 0)) < 0) {

Probably worth clearing out the error here, so that the rest of virsh
doesn't leak an error message that we ignored.

> +        /* fall back to nodeinfo */
> +        if (virNodeGetInfo(conn, &nodeinfo) == 0) {
> +            ret = VIR_NODEINFO_MAXCPUS(nodeinfo);
> +        }
> +    }
> +    return ret;
> +}
> +

ACK with that fixed, and pushed.

diff --git i/tools/virsh-domain.c w/tools/virsh-domain.c
index 183a598..d483f3f 100644
--- i/tools/virsh-domain.c
+++ w/tools/virsh-domain.c
@@ -138,6 +138,7 @@ vshNodeGetCPUCount(virConnectPtr conn)

     if ((ret = virNodeGetCPUMap(conn, NULL, NULL, 0)) < 0) {
         /* fall back to nodeinfo */
+        vshResetLibvirtError();
         if (virNodeGetInfo(conn, &nodeinfo) == 0) {
             ret = VIR_NODEINFO_MAXCPUS(nodeinfo);
         }

-- 
Eric Blake   ebl...@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

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

Reply via email to