diff mbox

[AUTOTEST,5/7] usb: cdrom support

Message ID 1307348175-27830-6-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 cdrom drives.

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

Patch

diff --git a/client/virt/kvm_vm.py b/client/virt/kvm_vm.py
index 948d14f..ce7cec9 100644
--- a/client/virt/kvm_vm.py
+++ b/client/virt/kvm_vm.py
@@ -196,6 +196,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',media=cdrom" % filename
                 if index is not None:
                     cmd += ",index=%s" % index
@@ -375,6 +381,7 @@  class VM(virt_vm.BaseVM):
             root_dir = self.root_dir
 
         have_ahci = False
+        have_usb2 = False
 
         # Clone this VM using the new params
         vm = self.clone(name, params, root_dir, copy_state=True)
@@ -483,6 +490,9 @@  class VM(virt_vm.BaseVM):
             if cdrom_params.get("cd_format") == "ahci" and not have_ahci:
                 qemu_cmd += " -device ahci,id=ahci"
                 have_ahci = True
+            if cdrom_params.get("cd_format") == "usb2" and not have_usb2:
+                qemu_cmd += " -device usb-ehci,id=ehci"
+                have_usb2 = True
             if iso:
                 qemu_cmd += add_cdrom(help, virt_utils.get_path(root_dir, iso),
                                       cdrom_params.get("drive_index"),