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

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



On Wed, Oct 31, 2012 at 06:20:58PM +0100, 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 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.
> 
>  tools/virsh-domain.c | 32 +++++++++++++++++++++++---------
>  1 file changed, 23 insertions(+), 9 deletions(-)
> 
> diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
> index 255669f..59289f1 100644
> --- a/tools/virsh-domain.c
> +++ b/tools/virsh-domain.c
> @@ -126,6 +126,26 @@ vshDomainVcpuStateToString(int state)
>  }
>  
>  /*
> + * Determine number of CPU nodes present by trying
> + * virNodeGetCPUMap and falling back to virNodeGetInfo
> + * if needed.
> + */
> +static int
> +vshNodeGetCPUCount(virConnectPtr conn)
> +{
> +    int ret;
> +    virNodeInfo nodeinfo;
> +
> +    if ((ret = virNodeGetCPUMap(conn, NULL, NULL, 0)) < 0) {
> +        /* fall back to nodeinfo */
> +        if (virNodeGetInfo(conn, &nodeinfo) == 0) {
> +            ret = VIR_NODEINFO_MAXCPUS(nodeinfo);
> +        }

Isn't VIR_NODEINFO_MAXCPUS buggy? Either don't fall back to nodeinfo
or fix it.


-- 
Thanks,
Hu Tao


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