Re: [PATCHv3 4/4] virsh: Use virNodeGetCPUMap if possible

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

 



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 <mihajlov@xxxxxxxxxxxxxxxxxx>
> ---
> 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   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]