diff mbox

[AUTOTEST,6/7] usb: disk support

Message ID 1307348175-27830-7-git-send-email-kraxel@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Gerd Hoffmann June 6, 2011, 8:16 a.m. UTC
This patch adds support for virtual usb sticks.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 client/virt/kvm_vm.py |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/client/virt/kvm_vm.py b/client/virt/kvm_vm.py
index ce7cec9..157036d 100644
--- a/client/virt/kvm_vm.py
+++ b/client/virt/kvm_vm.py
@@ -222,6 +222,12 @@  class VM(virt_vm.BaseVM):
                 dev += " -device ide-drive,bus=ahci.%s,drive=%s" % (index, name)
                 format = "none"
                 index = None
+            if format == "usb2":
+                name = "usb2.%s" % index
+                dev += " -device usb-storage,bus=ehci.0,drive=%s" % name
+                dev += ",port=%d" % (int(index) + 1)
+                format = "none"
+                index = None
             cmd = " -drive file='%s'" % filename
             if index is not None:
                 cmd += ",index=%s" % index
@@ -425,6 +431,9 @@  class VM(virt_vm.BaseVM):
             if image_params.get("drive_format") == "ahci" and not have_ahci:
                 qemu_cmd += " -device ahci,id=ahci"
                 have_ahci = True
+            if image_params.get("drive_format") == "usb2" and not have_usb2:
+                qemu_cmd += " -device usb-ehci,id=ehci"
+                have_usb2 = True
             qemu_cmd += add_drive(help,
                              virt_vm.get_image_filename(image_params, root_dir),
                                   image_params.get("drive_index"),