]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Added testsuite for QEMU XML routines
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 18 Jul 2007 21:34:22 +0000 (21:34 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 18 Jul 2007 21:34:22 +0000 (21:34 +0000)
37 files changed:
ChangeLog
tests/.cvsignore
tests/Makefile.am
tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-boot-network.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-boot-network.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-clock-utc.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-clock-utc.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-disk-many.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-disk-many.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-minimal.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-minimal.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.xml [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-net-user.args [new file with mode: 0644]
tests/qemuxml2argvdata/qemuxml2argv-net-user.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c [new file with mode: 0644]
tests/qemuxml2xmltest.c [new file with mode: 0644]

index ca997200975a942a206a4d894bd81227a0e8b5d2..16cb90a583e329b667bf5b02aa8c065d02c0d1ad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Jul 18 17:15:08 EST 2007 Daniel P. Berrange <berrange@redhat.com>
+
+       * tests/Makefile.am: Added QEMU tests
+       * tests/qemuxml2argvdata/*: Data files for QEMU tests
+       * tests/qemuxml2argvtest.c: Test XML -> argv conversion
+       * tests/qemuxml2xmltest.c: Test XML -> XML roundtrip
+
 Wed Jul 18 17:11:08 EST 2007 Daniel P. Berrange <berrange@redhat.com>
 
        * src/xmlrpctest.c, src/xml2sexprtest.c: More void * to
index b8ee537d5c23fb1b7518a40fbfebcb47dbe2d4c7..a254efafa11218bf3740fc9301139fb987b1b3cd 100644 (file)
@@ -10,6 +10,8 @@ conftest
 reconnect
 xmconfigtest
 xencapstest
+qemuxml2xmltest
+qemuxml2argvtest
 *.gcda
 *.gcno
 
index f4f810c6514e6503fa939a6a70c31a9df033ba60..9eb5e8b5a35f0053baf51d203af0ee2bb195b2a2 100644 (file)
@@ -32,9 +32,10 @@ LDADDS = \
 EXTRA_DIST = xmlrpcserver.py test_conf.sh
 
 noinst_PROGRAMS = xmlrpctest xml2sexprtest sexpr2xmltest virshtest conftest \
-       reconnect xmconfigtest xencapstest
+       reconnect xmconfigtest xencapstest qemuxml2argvtest qemuxml2xmltest
 
-TESTS = xml2sexprtest sexpr2xmltest virshtest test_conf.sh xmconfigtest xencapstest
+TESTS = xml2sexprtest sexpr2xmltest virshtest test_conf.sh xmconfigtest \
+        xencapstest qemuxml2argvtest qemuxml2xmltest
 if ENABLE_XEN_TESTS
   TESTS += reconnect
 endif
@@ -70,6 +71,18 @@ xmconfigtest_SOURCES = \
 xmconfigtest_LDFLAGS =
 xmconfigtest_LDADD = $(LDADDS)
 
+qemuxml2argvtest_SOURCES = \
+       qemuxml2argvtest.c \
+       testutils.c testutils.h
+qemuxml2argvtest_LDFLAGS =
+qemuxml2argvtest_LDADD = $(LDADDS)
+
+qemuxml2xmltest_SOURCES = \
+       qemuxml2xmltest.c \
+       testutils.c testutils.h
+qemuxml2xmltest_LDFLAGS =
+qemuxml2xmltest_LDADD = $(LDADDS)
+
 virshtest_SOURCES = \
        virshtest.c \
        testutils.c testutils.h
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args b/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args
new file mode 100644 (file)
index 0000000..ed6a865
--- /dev/null
@@ -0,0 +1 @@
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot d -cdrom /dev/cdrom -net none -usb -nographic
\ No newline at end of file
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.xml b/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.xml
new file mode 100644 (file)
index 0000000..26eeb39
--- /dev/null
@@ -0,0 +1,23 @@
+<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='i686' machine='pc'>hvm</type>
+    <boot dev='cdrom'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='block' device='cdrom'>
+      <source dev='/dev/cdrom'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.args b/tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.args
new file mode 100644 (file)
index 0000000..5e387ff
--- /dev/null
@@ -0,0 +1 @@
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot a -hda /dev/HostVG/QEMUGuest1 -fda /tmp/firmware.img -net none -usb -nographic
\ No newline at end of file
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.xml b/tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.xml
new file mode 100644 (file)
index 0000000..ed00c66
--- /dev/null
@@ -0,0 +1,26 @@
+<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='i686' machine='pc'>hvm</type>
+    <boot dev='fd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda'/>
+    </disk>
+    <disk type='file' device='floppy'>
+      <source file='/tmp/firmware.img'/>
+      <target dev='fda'/>
+    </disk>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-network.args b/tests/qemuxml2argvdata/qemuxml2argv-boot-network.args
new file mode 100644 (file)
index 0000000..e1d285a
--- /dev/null
@@ -0,0 +1 @@
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot n -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic
\ No newline at end of file
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-network.xml b/tests/qemuxml2argvdata/qemuxml2argv-boot-network.xml
new file mode 100644 (file)
index 0000000..55d4e8a
--- /dev/null
@@ -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='i686' machine='pc'>hvm</type>
+    <boot dev='net'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda'/>
+    </disk>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.args b/tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.args
new file mode 100644 (file)
index 0000000..555ce35
--- /dev/null
@@ -0,0 +1 @@
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -localtime -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic
\ No newline at end of file
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.xml b/tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.xml
new file mode 100644 (file)
index 0000000..351779d
--- /dev/null
@@ -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='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='localtime'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda'/>
+    </disk>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-clock-utc.args b/tests/qemuxml2argvdata/qemuxml2argv-clock-utc.args
new file mode 100644 (file)
index 0000000..dc8e52b
--- /dev/null
@@ -0,0 +1 @@
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic
\ No newline at end of file
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-clock-utc.xml b/tests/qemuxml2argvdata/qemuxml2argv-clock-utc.xml
new file mode 100644 (file)
index 0000000..816b161
--- /dev/null
@@ -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='i686' 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</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda'/>
+    </disk>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.args
new file mode 100644 (file)
index 0000000..298cea8
--- /dev/null
@@ -0,0 +1 @@
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -cdrom /root/boot.iso -net none -usb -nographic
\ No newline at end of file
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.xml
new file mode 100644 (file)
index 0000000..e3e5fbf
--- /dev/null
@@ -0,0 +1,27 @@
+<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='i686' 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</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda'/>
+    </disk>
+    <disk type='file' device='cdrom'>
+      <source file='/root/boot.iso'/>
+      <target dev='hdc'/>
+      <readonly/>
+    </disk>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.args
new file mode 100644 (file)
index 0000000..f6dad3d
--- /dev/null
@@ -0,0 +1 @@
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -fda /dev/fd0 -fdb /tmp/firmware.img -net none -usb -nographic
\ No newline at end of file
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.xml
new file mode 100644 (file)
index 0000000..37f1433
--- /dev/null
@@ -0,0 +1,30 @@
+<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='i686' 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</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda'/>
+    </disk>
+    <disk type='block' device='floppy'>
+      <source dev='/dev/fd0'/>
+      <target dev='fda'/>
+    </disk>
+    <disk type='file' device='floppy'>
+      <source file='/tmp/firmware.img'/>
+      <target dev='fdb'/>
+    </disk>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-many.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-many.args
new file mode 100644 (file)
index 0000000..a6a957c
--- /dev/null
@@ -0,0 +1 @@
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -hdb /dev/HostVG/QEMUGuest2 -hdc /tmp/data.img -hdd /tmp/logs.img -net none -usb -nographic
\ No newline at end of file
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-many.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-many.xml
new file mode 100644 (file)
index 0000000..1ff0aa2
--- /dev/null
@@ -0,0 +1,34 @@
+<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='i686' 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</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda'/>
+    </disk>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest2'/>
+      <target dev='hdb'/>
+    </disk>
+    <disk type='file' device='disk'>
+      <source file='/tmp/data.img'/>
+      <target dev='hdc'/>
+    </disk>
+    <disk type='file' device='disk'>
+      <source file='/tmp/logs.img'/>
+      <target dev='hdd'/>
+    </disk>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.args
new file mode 100644 (file)
index 0000000..50016c4
--- /dev/null
@@ -0,0 +1 @@
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -sdl
\ No newline at end of file
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml
new file mode 100644 (file)
index 0000000..8c795d9
--- /dev/null
@@ -0,0 +1,24 @@
+<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='i686' 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</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda'/>
+    </disk>
+    <input type='mouse' bus='ps2'/>
+    <graphics type='sdl'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.args
new file mode 100644 (file)
index 0000000..42a33a4
--- /dev/null
@@ -0,0 +1 @@
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -vnc 127.0.0.1:3
\ No newline at end of file
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml
new file mode 100644 (file)
index 0000000..2528a0e
--- /dev/null
@@ -0,0 +1,24 @@
+<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='i686' 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</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda'/>
+    </disk>
+    <input type='mouse' bus='ps2'/>
+    <graphics type='vnc' port='5903' listen='127.0.0.1'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args b/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args
new file mode 100644 (file)
index 0000000..60b8bbe
--- /dev/null
@@ -0,0 +1 @@
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -usbdevice mouse -nographic
\ No newline at end of file
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.xml b/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.xml
new file mode 100644 (file)
index 0000000..1bbf890
--- /dev/null
@@ -0,0 +1,23 @@
+<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='i686' 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</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda'/>
+    </disk>
+    <input type='mouse' bus='usb'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args b/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args
new file mode 100644 (file)
index 0000000..5f6f02c
--- /dev/null
@@ -0,0 +1 @@
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -usbdevice tablet -nographic
\ No newline at end of file
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.xml b/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.xml
new file mode 100644 (file)
index 0000000..2cfc174
--- /dev/null
@@ -0,0 +1,23 @@
+<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='i686' 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</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda'/>
+    </disk>
+    <input type='tablet' bus='usb'/>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-minimal.args b/tests/qemuxml2argvdata/qemuxml2argv-minimal.args
new file mode 100644 (file)
index 0000000..dc8e52b
--- /dev/null
@@ -0,0 +1 @@
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic
\ No newline at end of file
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-minimal.xml b/tests/qemuxml2argvdata/qemuxml2argv-minimal.xml
new file mode 100644 (file)
index 0000000..816b161
--- /dev/null
@@ -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='i686' 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</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda'/>
+    </disk>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.args b/tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.args
new file mode 100644 (file)
index 0000000..600478c
--- /dev/null
@@ -0,0 +1 @@
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic
\ No newline at end of file
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.xml b/tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.xml
new file mode 100644 (file)
index 0000000..759b6cf
--- /dev/null
@@ -0,0 +1,25 @@
+<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='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <features>
+    <acpi/>
+  </features>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda'/>
+    </disk>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.args b/tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.args
new file mode 100644 (file)
index 0000000..90ade68
--- /dev/null
@@ -0,0 +1 @@
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-reboot -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -usb -nographic
\ No newline at end of file
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.xml b/tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.xml
new file mode 100644 (file)
index 0000000..8d1d4b4
--- /dev/null
@@ -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='i686' machine='pc'>hvm</type>
+    <boot dev='hd'/>
+  </os>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>destroy</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <emulator>/usr/bin/qemu</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda'/>
+    </disk>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-user.args b/tests/qemuxml2argvdata/qemuxml2argv-net-user.args
new file mode 100644 (file)
index 0000000..bf49035
--- /dev/null
@@ -0,0 +1 @@
+/usr/bin/qemu -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net nic,macaddr=00:11:22:33:44:55,vlan=0 -net user,vlan=0 -usb -nographic
\ No newline at end of file
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-user.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-user.xml
new file mode 100644 (file)
index 0000000..6a2d256
--- /dev/null
@@ -0,0 +1,25 @@
+<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='i686' 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</emulator>
+    <disk type='block' device='disk'>
+      <source dev='/dev/HostVG/QEMUGuest1'/>
+      <target dev='hda'/>
+    </disk>
+    <interface type='user'>
+      <mac address='00:11:22:33:44:55'/>
+    </interface>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
new file mode 100644 (file)
index 0000000..0cb2238
--- /dev/null
@@ -0,0 +1,188 @@
+#include <stdio.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <fcntl.h>
+
+#include "testutils.h"
+#include "qemu_conf.h"
+#include "internal.h"
+
+static char *progname;
+struct qemud_driver driver;
+
+#define MAX_FILE 4096
+
+static int testCompareXMLToArgvFiles(const char *xml, const char *cmd) {
+    char xmlData[MAX_FILE];
+    char argvData[MAX_FILE];
+    char *xmlPtr = &(xmlData[0]);
+    char *expectargv = &(argvData[0]);
+    char *actualargv = NULL;
+    char **argv = NULL;
+    char **tmp = NULL;
+    int ret = -1, len;
+    struct qemud_vm_def *vmdef;
+    struct qemud_vm vm;
+
+    if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
+        goto fail;
+
+    if (virtTestLoadFile(cmd, &expectargv, MAX_FILE) < 0)
+        goto fail;
+
+    if (!(vmdef = qemudParseVMDef(NULL, &driver, xmlData, "test")))
+        goto fail;
+
+    vm.def = vmdef;
+    vm.pid = -1;
+    vm.id = -1;
+    vmdef->vncActivePort = vmdef->vncPort;
+
+    if (qemudBuildCommandLine(NULL, &driver, &vm, &argv) < 0)
+        goto fail;
+
+    tmp = argv;
+    len = 0;
+    while (*tmp) {
+        len += strlen(*tmp) + 1;
+        tmp++;
+    }
+    actualargv = malloc(sizeof(char)*len);
+    actualargv[0] = '\0';
+    tmp = argv;
+    len = 0;
+    while (*tmp) {
+        if (actualargv[0])
+            strcat(actualargv, " ");
+        strcat(actualargv, *tmp);
+        tmp++;
+    }
+
+    if (strcmp(expectargv, actualargv)) {
+        if (getenv("DEBUG_TESTS")) {
+            printf("Expect %4d '%s'\n", (int)strlen(expectargv), expectargv);
+            printf("Actual %4d '%s'\n", (int)strlen(actualargv), actualargv);
+        }
+        goto fail;
+    }
+
+    ret = 0;
+
+ fail:
+    free(actualargv);
+    if (argv) {
+        tmp = argv;
+        while (*tmp) {
+            free(*tmp);
+            tmp++;
+        }
+        free(argv);
+    }
+
+    return ret;
+}
+
+
+static int testCompareXMLToArgvHelper(const void *data) {
+    char xml[PATH_MAX];
+    char args[PATH_MAX];
+    snprintf(xml, PATH_MAX, "qemuxml2argvdata/qemuxml2argv-%s.xml", (const char*)data);
+    snprintf(args, PATH_MAX, "qemuxml2argvdata/qemuxml2argv-%s.args", (const char*)data);
+    return testCompareXMLToArgvFiles(xml, args);
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+    int ret = 0;
+
+    progname = argv[0];
+
+    if (argc > 1) {
+        fprintf(stderr, "Usage: %s\n", progname);
+        exit(EXIT_FAILURE);
+    }
+
+    driver.qemuVersion = 0 * 1000 * 100 + (8 * 1000) + 1;
+    driver.qemuCmdFlags = QEMUD_CMD_FLAG_VNC_COLON | 
+        QEMUD_CMD_FLAG_NO_REBOOT;
+
+    if (virtTestRun("QEMU XML-2-ARGV minimal",
+                    1, testCompareXMLToArgvHelper, "minimal") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Boot CDROM",
+                    1, testCompareXMLToArgvHelper, "boot-cdrom") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Boot Network",
+                    1, testCompareXMLToArgvHelper, "boot-network") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Boot Floppy",
+                    1, testCompareXMLToArgvHelper, "boot-floppy") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Clock UTC",
+                    1, testCompareXMLToArgvHelper, "clock-utc") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Clock Localtime",
+                    1, testCompareXMLToArgvHelper, "clock-localtime") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Disk CDROM",
+                    1, testCompareXMLToArgvHelper, "disk-cdrom") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Disk Floppy",
+                    1, testCompareXMLToArgvHelper, "disk-floppy") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Disk Many",
+                    1, testCompareXMLToArgvHelper, "disk-many") < 0)
+        ret = -1;
+
+    if (0 && virtTestRun("QEMU XML-2-ARGV Graphics VNC",
+                    1, testCompareXMLToArgvHelper, "graphics-vnc") < 0)
+        ret = -1;
+
+    if (0 && virtTestRun("QEMU XML-2-ARGV Graphics SDL",
+                    1, testCompareXMLToArgvHelper, "graphics-sdl") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Input USB Mouse",
+                    1, testCompareXMLToArgvHelper, "input-usbmouse") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Input USB Tablet",
+                    1, testCompareXMLToArgvHelper, "input-usbtablet") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Misc ACPI",
+                    1, testCompareXMLToArgvHelper, "misc-acpi") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Misc No Reboot",
+                    1, testCompareXMLToArgvHelper, "misc-no-reboot") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Net User",
+                    1, testCompareXMLToArgvHelper, "net-user") < 0)
+        ret = -1;
+
+
+    exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
new file mode 100644 (file)
index 0000000..fc596b3
--- /dev/null
@@ -0,0 +1,153 @@
+#include <stdio.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <fcntl.h>
+
+#include "testutils.h"
+#include "qemu_conf.h"
+#include "internal.h"
+
+static char *progname;
+struct qemud_driver driver;
+
+#define MAX_FILE 4096
+
+
+static int testCompareXMLToXMLFiles(const char *xml) {
+    char xmlData[MAX_FILE];
+    char *xmlPtr = &(xmlData[0]);
+    char *actual = NULL;
+    int ret = -1;
+    struct qemud_vm_def *vmdef;
+    struct qemud_vm vm;
+
+    if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
+        goto fail;
+
+    if (!(vmdef = qemudParseVMDef(NULL, &driver, xmlData, "test")))
+        goto fail;
+
+    vm.def = vmdef;
+    vm.pid = -1;
+    vm.id = -1;
+    vmdef->vncActivePort = vmdef->vncPort;
+
+    if (!(actual = qemudGenerateXML(NULL, &driver, &vm, vmdef, 0)))
+        goto fail;
+
+    if (strcmp(xmlData, actual)) {
+        if (getenv("DEBUG_TESTS")) {
+            printf("Expect %4d '%s'\n", (int)strlen(xmlData), xmlData);
+            printf("Actual %4d '%s'\n", (int)strlen(actual), actual);
+        }
+        goto fail;
+    }
+
+    ret = 0;
+
+ fail:
+    free(actual);
+
+    return ret;
+}
+
+static int testCompareXMLToXMLHelper(const void *data) {
+    char xml[PATH_MAX];
+    snprintf(xml, PATH_MAX, "qemuxml2argvdata/qemuxml2argv-%s.xml", (const char*)data);
+    return testCompareXMLToXMLFiles(xml);
+}
+
+
+int
+main(int argc, char **argv)
+{
+    int ret = 0;
+
+    progname = argv[0];
+
+    if (argc > 1) {
+        fprintf(stderr, "Usage: %s\n", progname);
+        exit(EXIT_FAILURE);
+    }
+
+    driver.qemuVersion = 0 * 1000 * 100 + (8 * 1000) + 1;
+    driver.qemuCmdFlags = QEMUD_CMD_FLAG_VNC_COLON | 
+        QEMUD_CMD_FLAG_NO_REBOOT;
+
+    if (virtTestRun("QEMU XML-2-ARGV minimal",
+                    1, testCompareXMLToXMLHelper, "minimal") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Boot CDROM",
+                    1, testCompareXMLToXMLHelper, "boot-cdrom") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Boot Network",
+                    1, testCompareXMLToXMLHelper, "boot-network") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Boot Floppy",
+                    1, testCompareXMLToXMLHelper, "boot-floppy") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Clock UTC",
+                    1, testCompareXMLToXMLHelper, "clock-utc") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Clock Localtime",
+                    1, testCompareXMLToXMLHelper, "clock-localtime") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Disk CDROM",
+                    1, testCompareXMLToXMLHelper, "disk-cdrom") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Disk Floppy",
+                    1, testCompareXMLToXMLHelper, "disk-floppy") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Disk Many",
+                    1, testCompareXMLToXMLHelper, "disk-many") < 0)
+        ret = -1;
+
+    if (0 && virtTestRun("QEMU XML-2-ARGV Graphics VNC",
+                    1, testCompareXMLToXMLHelper, "graphics-vnc") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Graphics SDL",
+                    1, testCompareXMLToXMLHelper, "graphics-sdl") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Input USB Mouse",
+                    1, testCompareXMLToXMLHelper, "input-usbmouse") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Input USB Tablet",
+                    1, testCompareXMLToXMLHelper, "input-usbtablet") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Misc ACPI",
+                    1, testCompareXMLToXMLHelper, "misc-acpi") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Misc No Reboot",
+                    1, testCompareXMLToXMLHelper, "misc-no-reboot") < 0)
+        ret = -1;
+
+    if (virtTestRun("QEMU XML-2-ARGV Net User",
+                    1, testCompareXMLToXMLHelper, "net-user") < 0)
+        ret = -1;
+
+
+    exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
+}
+
+/*
+ * Local variables:
+ *  indent-tabs-mode: nil
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ *  tab-width: 4
+ * End:
+ */