mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
test: introduce a function in test driver to check get vcpupin info
As there is a regression in use vcpupin get info, introduce a new function to test the virsh client. Signed-off-by: Luyao Huang <lhuang@redhat.com>
This commit is contained in:
parent
03b6bdcab3
commit
b70b5ff41a
@ -2518,6 +2518,60 @@ static int testDomainPinVcpu(virDomainPtr domain,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
testDomainGetVcpuPinInfo(virDomainPtr dom,
|
||||
int ncpumaps,
|
||||
unsigned char *cpumaps,
|
||||
int maplen,
|
||||
unsigned int flags)
|
||||
{
|
||||
testDriverPtr privconn = dom->conn->privateData;
|
||||
virDomainObjPtr privdom;
|
||||
virDomainDefPtr def;
|
||||
int ret = -1, hostcpus, vcpu;
|
||||
virBitmapPtr allcpumap = NULL;
|
||||
|
||||
if (!(privdom = testDomObjFromDomain(dom)))
|
||||
return -1;
|
||||
|
||||
if (!(def = virDomainObjGetOneDef(privdom, flags)))
|
||||
goto cleanup;
|
||||
|
||||
hostcpus = VIR_NODEINFO_MAXCPUS(privconn->nodeInfo);
|
||||
|
||||
if (!(allcpumap = virBitmapNew(hostcpus)))
|
||||
goto cleanup;
|
||||
|
||||
virBitmapSetAll(allcpumap);
|
||||
|
||||
/* Clamp to actual number of vcpus */
|
||||
if (ncpumaps > def->vcpus)
|
||||
ncpumaps = def->vcpus;
|
||||
|
||||
for (vcpu = 0; vcpu < ncpumaps; vcpu++) {
|
||||
virDomainPinDefPtr pininfo;
|
||||
virBitmapPtr bitmap = NULL;
|
||||
|
||||
pininfo = virDomainPinFind(def->cputune.vcpupin,
|
||||
def->cputune.nvcpupin,
|
||||
vcpu);
|
||||
|
||||
if (pininfo && pininfo->cpumask)
|
||||
bitmap = pininfo->cpumask;
|
||||
else
|
||||
bitmap = allcpumap;
|
||||
|
||||
virBitmapToDataBuf(bitmap, VIR_GET_CPUMAP(cpumaps, maplen, vcpu), maplen);
|
||||
}
|
||||
|
||||
ret = ncpumaps;
|
||||
|
||||
cleanup:
|
||||
virBitmapFree(allcpumap);
|
||||
virDomainObjEndAPI(&privdom);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *testDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
|
||||
{
|
||||
virDomainDefPtr def;
|
||||
@ -6598,6 +6652,7 @@ static virHypervisorDriver testHypervisorDriver = {
|
||||
.domainGetVcpusFlags = testDomainGetVcpusFlags, /* 0.8.5 */
|
||||
.domainPinVcpu = testDomainPinVcpu, /* 0.7.3 */
|
||||
.domainGetVcpus = testDomainGetVcpus, /* 0.7.3 */
|
||||
.domainGetVcpuPinInfo = testDomainGetVcpuPinInfo, /* 1.2.18 */
|
||||
.domainGetMaxVcpus = testDomainGetMaxVcpus, /* 0.7.3 */
|
||||
.domainGetXMLDesc = testDomainGetXMLDesc, /* 0.1.4 */
|
||||
.connectListDefinedDomains = testConnectListDefinedDomains, /* 0.1.11 */
|
||||
|
@ -66,12 +66,38 @@ error: vcpupin: Missing vCPU number in pin mode.
|
||||
EOF
|
||||
compare exp out || fail=1
|
||||
|
||||
# without arguments. This should succeed but the backend function in the
|
||||
# test driver isn't implemented
|
||||
$abs_top_builddir/tools/virsh --connect test:///default vcpupin test > out 2>&1
|
||||
# An out-of-range vCPU number when get information with live flag
|
||||
$abs_top_builddir/tools/virsh --connect test:///default vcpupin test 100 --live > out 2>&1
|
||||
test $? = 1 || fail=1
|
||||
cat <<\EOF > exp || fail=1
|
||||
error: this function is not supported by the connection driver: virDomainGetVcpuPinInfo
|
||||
error: vcpu 100 is out of range of live cpu count 2
|
||||
|
||||
EOF
|
||||
compare exp out || fail=1
|
||||
|
||||
# An out-of-range vCPU number when get information without flag
|
||||
$abs_top_builddir/tools/virsh --connect test:///default vcpupin test 100 > out 2>&1
|
||||
test $? = 1 || fail=1
|
||||
cat <<\EOF > exp || fail=1
|
||||
error: vcpu 100 is out of range of live cpu count 2
|
||||
|
||||
EOF
|
||||
compare exp out || fail=1
|
||||
|
||||
# An out-of-range vCPU number when get information with config flag
|
||||
$abs_top_builddir/tools/virsh --connect test:///default vcpupin test 100 --config > out 2>&1
|
||||
test $? = 1 || fail=1
|
||||
cat <<\EOF > exp || fail=1
|
||||
error: vcpu 100 is out of range of persistent cpu count 2
|
||||
|
||||
EOF
|
||||
compare exp out || fail=1
|
||||
|
||||
# An out-of-range vCPU number when get information with current flag
|
||||
$abs_top_builddir/tools/virsh --connect test:///default vcpupin test 100 --current > out 2>&1
|
||||
test $? = 1 || fail=1
|
||||
cat <<\EOF > exp || fail=1
|
||||
error: vcpu 100 is out of range of live cpu count 2
|
||||
|
||||
EOF
|
||||
compare exp out || fail=1
|
||||
|
Loading…
Reference in New Issue
Block a user