mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
virsh: use virConnectGetDomainCapabilities with maxvcpus
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 emulator
binary and to check for the host machine and arch which is what the
command intends to show anyway.
Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
This commit is contained in:
parent
8563560026
commit
1ec22be550
@ -606,18 +606,40 @@ static bool
|
|||||||
cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd)
|
cmdMaxvcpus(vshControl *ctl, const vshCmd *cmd)
|
||||||
{
|
{
|
||||||
const char *type = NULL;
|
const char *type = NULL;
|
||||||
int vcpus;
|
int vcpus = -1;
|
||||||
|
char *caps = NULL;
|
||||||
|
xmlDocPtr xml = NULL;
|
||||||
|
xmlXPathContextPtr ctxt = NULL;
|
||||||
virshControlPtr priv = ctl->privData;
|
virshControlPtr priv = ctl->privData;
|
||||||
|
bool ret = false;
|
||||||
|
|
||||||
if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0)
|
if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ((vcpus = virConnectGetMaxVcpus(priv->conn, type)) < 0)
|
if ((caps = virConnectGetDomainCapabilities(priv->conn, NULL, NULL, NULL,
|
||||||
return false;
|
type, 0))) {
|
||||||
|
if (!(xml = virXMLParseStringCtxt(caps, _("(domainCapabilities)"), &ctxt)))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
ignore_value(virXPathInt("string(./vcpu[1]/@max)", ctxt, &vcpus));
|
||||||
|
} else {
|
||||||
|
if (last_error && last_error->code != VIR_ERR_NO_SUPPORT)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
vshResetLibvirtError();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vcpus < 0 && (vcpus = virConnectGetMaxVcpus(priv->conn, type)) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
vshPrint(ctl, "%d\n", vcpus);
|
vshPrint(ctl, "%d\n", vcpus);
|
||||||
|
ret = true;
|
||||||
|
|
||||||
return true;
|
cleanup:
|
||||||
|
xmlXPathFreeContext(ctxt);
|
||||||
|
xmlFreeDoc(xml);
|
||||||
|
VIR_FREE(caps);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user