virsh maxvcpus --type kvm output is useless on PPC. Also, in commit e6806d79 we documented not rely on virConnectGetMaxVcpus output. Fix the maxvcpus to use virConnectGetDomainCapabilities now to make it useful. The call is made to use the default qemu binary and to check for the host machine and arch which is what the command intends to do anyway. Signed-off-by: Shivaprasad G Bhat <sbhat@xxxxxxxxxxxxxxxxxx> --- tools/virsh-host.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 57f0c0e..cf001c6 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -606,18 +606,43 @@ static bool cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd) { const char *type = NULL; - int vcpus; + unsigned int vcpus; + char *caps = NULL; + const unsigned int flags = 0; /* No flags so far */ + xmlDocPtr xml = NULL; + xmlXPathContextPtr ctxt = NULL; + bool ret = false; virshControlPtr priv = ctl->privData; if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0) return false; - if ((vcpus = virConnectGetMaxVcpus(priv->conn, type)) < 0) - return false; + caps = virConnectGetDomainCapabilities(priv->conn, NULL, NULL, NULL, type, flags); + if (!caps) { + vshError(ctl, "%s", _("failed to get domain capabilities")); + goto cleanup; + } + + xml = virXMLParseStringCtxt(caps, _("(domainCapabilities)"), &ctxt); + if (!xml) { + vshError(ctl, "%s", _("unable to parse domain capabilities")); + goto cleanup; + } + + if ((virXPathUInt("string(./vcpu[1]/@max)", ctxt, &vcpus)) < 0) { + vshError(ctl, "%s", _("unable to get maxvcpus")); + goto cleanup; + } vshPrint(ctl, "%d\n", vcpus); - return true; + ret = true; + cleanup: + VIR_FREE(caps); + xmlXPathFreeContext(ctxt); + xmlFreeDoc(xml); + + return ret; } /* -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list