>From 99b8d6ff1bef43ea6cacd544fa6158cdfb301a27 Mon Sep 17 00:00:00 2001
From: Guido Guenther <agx@sigxcpu.org>
Date: Thu, 7 Aug 2008 14:25:50 +0200
Subject: [PATCH] hostdev: add testcases

---
 .../qemuxml2argv-hostdev-usb-address.args          |    1 +
 .../qemuxml2argv-hostdev-usb-address.xml           |   27 +++++++++++++++++++
 .../qemuxml2argv-hostdev-usb-product.args          |    1 +
 .../qemuxml2argv-hostdev-usb-product.xml           |   28 ++++++++++++++++++++
 tests/qemuxml2argvtest.c                           |    3 ++
 tests/qemuxml2xmltest.c                            |    3 ++
 6 files changed, 63 insertions(+), 0 deletions(-)
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.xml

diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args
new file mode 100644
index 0000000..0b89999
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args
@@ -0,0 +1 @@
+/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -usbdevice host:014.006
\ No newline at end of file
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.xml b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.xml
new file mode 100644
index 0000000..0c044e1
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.xml
@@ -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' bus='ide'/>
+    </disk>
+    <hostdev mode='subsystem' type='usb'>
+      <source>
+        <address bus='14' device='6'/>
+      </source>
+    </hostdev>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.args
new file mode 100644
index 0000000..b993ae5
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.args
@@ -0,0 +1 @@
+/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -usbdevice host:0204:6025
\ No newline at end of file
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.xml b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.xml
new file mode 100644
index 0000000..aecad4c
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.xml
@@ -0,0 +1,28 @@
+<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' bus='ide'/>
+    </disk>
+    <hostdev mode='subsystem' type='usb'>
+      <source>
+        <vendor id='0x0204'/>
+        <product id='0x6025'/>
+      </source>
+    </hostdev>
+  </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index d136a13..458201b 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -179,6 +179,9 @@ mymain(int argc, char **argv)
     DO_TEST("console-compat", 0);
     DO_TEST("sound", 0);
 
+    DO_TEST("hostdev-usb-product", 0);
+    DO_TEST("hostdev-usb-address", 0);
+
     virCapabilitiesFree(driver.caps);
 
     return(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 9e380e4..536c9bd 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -118,6 +118,9 @@ mymain(int argc, char **argv)
     DO_TEST("parallel-tcp");
     DO_TEST("console-compat");
 
+    DO_TEST("hostdev-usb-product");
+    DO_TEST("hostdev-usb-address");
+
     virCapabilitiesFree(driver.caps);
 
     return (ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
-- 
1.5.6.3

