[libvirt] [PATCH 3/3] virsh: Use virNodeGetCPUMap if possible
Eric Blake
eblake at redhat.com
Wed Oct 31 01:30:37 UTC 2012
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 at 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 at redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 617 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20121030/987c2bc6/attachment-0001.sig>
More information about the libvir-list
mailing list