Re: [libvirt] [PATCH 2/2] test: introduce a function in test driver to check get vcpupin info

2015-07-26 Thread lhuang


On 07/24/2015 06:52 PM, John Ferlan wrote:


On 07/14/2015 09:10 AM, Luyao Huang wrote:

As there is a regression in use vcpupin get info, introduce a new function
to test the virsh client.

Signed-off-by: Luyao Huang lhu...@redhat.com
---
  src/test/test_driver.c | 55 ++
  tests/vcpupin  | 34 +++
  2 files changed, 85 insertions(+), 4 deletions(-)


ACK and pushed the test (since 1/2 was fixed by a different commit)


Thanks a lot for your review.


John


Luyao

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH 2/2] test: introduce a function in test driver to check get vcpupin info

2015-07-24 Thread John Ferlan


On 07/14/2015 09:10 AM, Luyao Huang wrote:
 As there is a regression in use vcpupin get info, introduce a new function
 to test the virsh client.
 
 Signed-off-by: Luyao Huang lhu...@redhat.com
 ---
  src/test/test_driver.c | 55 
 ++
  tests/vcpupin  | 34 +++
  2 files changed, 85 insertions(+), 4 deletions(-)
 

ACK and pushed the test (since 1/2 was fixed by a different commit)

John

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] [PATCH 2/2] test: introduce a function in test driver to check get vcpupin info

2015-07-14 Thread Luyao Huang
As there is a regression in use vcpupin get info, introduce a new function
to test the virsh client.

Signed-off-by: Luyao Huang lhu...@redhat.com
---
 src/test/test_driver.c | 55 ++
 tests/vcpupin  | 34 +++
 2 files changed, 85 insertions(+), 4 deletions(-)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index d38006f..213a9a1 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -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 */
diff --git a/tests/vcpupin b/tests/vcpupin
index b6b8b31..213db93 100755
--- a/tests/vcpupin
+++ b/tests/vcpupin
@@ -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 21
+# 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 21
 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 
21
+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 21
+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 21
+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
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list