]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: Teach qemuxml2argvtest about spapr-vio addresses
authorMichael Ellerman <michael@ellerman.id.au>
Fri, 13 Jan 2012 03:39:24 +0000 (14:39 +1100)
committerEric Blake <eblake@redhat.com>
Fri, 13 Jan 2012 23:08:22 +0000 (16:08 -0700)
We can't call qemuCapsExtractVersionInfo() from test code, because it
expects to be able to call the emulator, and for testing we have fake
emulators that can't be executed. For that reason qemuxml2argvtest.c
doesn't call qemuDomainAssignPCIAddresses(), instead it open codes its
own version.

That means we can't call qemuDomainAssignAddresses() from the test code,
instead we need to manually call qemuDomainAssignSpaprVioAddresses().

Also add logic to cope with qemuDomainAssignSpaprVioAddresses() failing,
so that we can write a test that checks for a known failure in there.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
src/qemu/qemu_command.c
src/qemu/qemu_command.h
tests/qemuxml2argvtest.c

index 00da72e5e6114a91e634981b1e3ac7e915d3d220..98824ac95abb279d07aae53c147e067a8f4c3073 100644 (file)
@@ -735,7 +735,7 @@ qemuAssignSpaprVIOAddress(virDomainDefPtr def, virDomainDeviceInfoPtr info,
     return 0;
 }
 
-static int qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def)
+int qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def)
 {
     int i, rc;
 
index de61cf30de7f0f9ec8d3e48b4b3a292314b6d44b..2f8b5bac7afac7bed3b51fdfa8de5833c1cab7e0 100644 (file)
@@ -175,6 +175,7 @@ virDomainDefPtr qemuParseCommandLinePid(virCapsPtr caps,
                                         bool *monJSON);
 
 int qemuDomainAssignAddresses(virDomainDefPtr def);
+int qemuDomainAssignSpaprVIOAddresses(virDomainDefPtr def);
 
 int qemuDomainAssignPCIAddresses(virDomainDefPtr def);
 qemuDomainPCIAddressSetPtr qemuDomainPCIAddressSetCreate(virDomainDefPtr def);
index 7d09fb80165ed8bf214f9f7683f1b13763018186..74d4f1748452df82a14170ccdeab3e13b82a7cb3 100644 (file)
@@ -153,6 +153,13 @@ static int testCompareXMLToArgvFiles(const char *xml,
 
     if (qemuCapsGet(extraFlags, QEMU_CAPS_DEVICE)) {
         qemuDomainPCIAddressSetPtr pciaddrs;
+
+        if (qemuDomainAssignSpaprVIOAddresses(vmdef)) {
+            if (expectError)
+                goto ok;
+            goto fail;
+        }
+
         if (!(pciaddrs = qemuDomainPCIAddressSetCreate(vmdef)))
             goto fail;
 
@@ -190,11 +197,6 @@ static int testCompareXMLToArgvFiles(const char *xml,
         goto fail;
     }
 
-    if (expectError) {
-        /* need to suppress the errors */
-        virResetLastError();
-    }
-
     if (!(actualargv = virCommandToString(cmd)))
         goto fail;
 
@@ -212,6 +214,12 @@ static int testCompareXMLToArgvFiles(const char *xml,
         goto fail;
     }
 
+ ok:
+    if (expectError) {
+        /* need to suppress the errors */
+        virResetLastError();
+    }
+
     ret = 0;
 
  fail: