[libvirt] [PATCH 05/10] Test qemu machine aliases

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* tests/testutilsqemu.c: make 'pc' an alias for qemu-system-x86_64

* tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.*,
  tests/qemuxml2argvtest.c: add a test which uses qemu-system-x86_64
  and make sure the machine type is canonicalized.
---
 .../qemuxml2argv-machine-aliases1.args             |    1 +
 .../qemuxml2argv-machine-aliases1.xml              |   22 ++++++++++++++
 tests/qemuxml2argvtest.c                           |    1 +
 tests/testutilsqemu.c                              |   31 +++++++++++++++++++-
 4 files changed, 54 insertions(+), 1 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.xml

diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.args b/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.args
new file mode 100644
index 0000000..4f62cb1
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.args
@@ -0,0 +1 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test /usr/bin/qemu-system-x86_64 -S -M pc-0.11 -m 214 -smp 1 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.xml b/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.xml
new file mode 100644
index 0000000..039abfd
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-aliases1.xml
@@ -0,0 +1,22 @@
+<domain type='qemu'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory>219200</memory>
+  <currentMemory>219200</currentMemory>
+  <vcpu>1</vcpu>
+  <os>
+    <type arch='x86_64' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda' bus='ide'/>
+    </disk>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index edd3744..afaf392 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -190,6 +190,7 @@ mymain(int argc, char **argv)
     unsetenv("LD_LIBRARY_PATH");
 
     DO_TEST("minimal", QEMUD_CMD_FLAG_NAME);
+    DO_TEST("machine-aliases1", 0);
     DO_TEST("boot-cdrom", 0);
     DO_TEST("boot-network", 0);
     DO_TEST("boot-floppy", 0);
diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index d85e4c7..ad58010 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -24,6 +24,35 @@ static virCapsGuestMachinePtr *testQemuAllocMachines(int *nmachines)
     return machines;
 }
 
+/* Newer versions of qemu have versioned machine types to allow
+ * compatibility with older releases.
+ * The 'pc' machine type is an alias of the newest machine type.
+ */
+static virCapsGuestMachinePtr *testQemuAllocNewerMachines(int *nmachines)
+{
+    virCapsGuestMachinePtr *machines;
+    char *canonical;
+    static const char *const x86_machines[] = {
+        "pc-0.11", "pc", "pc-0.10", "isapc"
+    };
+
+    if ((canonical = strdup(x86_machines[0])) == NULL)
+        return NULL;
+
+    machines = virCapabilitiesAllocMachines(x86_machines,
+                                            ARRAY_CARDINALITY(x86_machines));
+    if (machines == NULL) {
+        VIR_FREE(canonical);
+        return NULL;
+    }
+
+    machines[1]->canonical = canonical;
+
+    *nmachines = ARRAY_CARDINALITY(x86_machines);
+
+    return machines;
+}
+
 virCapsPtr testQemuCapsInit(void) {
     struct utsname utsname;
     virCapsPtr caps;
@@ -56,7 +85,7 @@ virCapsPtr testQemuCapsInit(void) {
                                       NULL) == NULL)
         goto cleanup;
 
-    if ((machines = testQemuAllocMachines(&nmachines)) == NULL)
+    if ((machines = testQemuAllocNewerMachines(&nmachines)) == NULL)
         goto cleanup;
 
     if ((guest = virCapabilitiesAddGuest(caps, "hvm", "x86_64", 64,
-- 
1.6.2.5

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

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]