From 9c57c72eacfc3a05de951a0bfcfa97dcc8be222c Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Wed, 2 Oct 2013 15:51:01 -0400 Subject: [PATCH] Default to adding USB2 for new enough KVM We enable this for virt-install as well. To avoid it, you can do either --controller usb,model=none or --controller usb --- tests/cli-test-xml/compare/cpuset-auto.xml | 20 +++++++++++++++++++ tests/cli-test-xml/compare/kvm-f14-url.xml | 20 +++++++++++++++++++ tests/cli-test-xml/compare/kvm-machine.xml | 10 ++++++++++ .../cli-test-xml/compare/kvm-win2k3-cdrom.xml | 3 +++ tests/cli-test-xml/compare/kvm-xenner.xml | 10 ++++++++++ tests/cli-test-xml/compare/qemu-32-on-64.xml | 10 ++++++++++ tests/cli-test-xml/compare/qemu-plain.xml | 10 ++++++++++ tests/cli-test-xml/compare/simple-pxe.xml | 20 +++++++++++++++++++ tests/cli-test-xml/compare/w2k3-cdrom.xml | 3 +++ tests/clitest.py | 4 ++-- virt-install | 7 ++++++- virtManager/create.py | 1 + virtinst/guest.py | 11 ++++++++++ virtinst/support.py | 2 ++ 14 files changed, 128 insertions(+), 3 deletions(-) diff --git a/tests/cli-test-xml/compare/cpuset-auto.xml b/tests/cli-test-xml/compare/cpuset-auto.xml index 13d39dba0..e4f53970c 100644 --- a/tests/cli-test-xml/compare/cpuset-auto.xml +++ b/tests/cli-test-xml/compare/cpuset-auto.xml @@ -19,6 +19,16 @@ destroy /usr/bin/test-hv + + + + + + + + + + @@ -47,6 +57,16 @@ restart /usr/bin/test-hv + + + + + + + + + + diff --git a/tests/cli-test-xml/compare/kvm-f14-url.xml b/tests/cli-test-xml/compare/kvm-f14-url.xml index 17df1dff2..4181ff0e8 100644 --- a/tests/cli-test-xml/compare/kvm-f14-url.xml +++ b/tests/cli-test-xml/compare/kvm-f14-url.xml @@ -43,6 +43,16 @@ + + + + + + + + + + @@ -99,6 +109,16 @@ + + + + + + + + + + diff --git a/tests/cli-test-xml/compare/kvm-machine.xml b/tests/cli-test-xml/compare/kvm-machine.xml index 42533f520..190b73d2b 100644 --- a/tests/cli-test-xml/compare/kvm-machine.xml +++ b/tests/cli-test-xml/compare/kvm-machine.xml @@ -19,6 +19,16 @@ restart /usr/bin/qemu-kvm + + + + + + + + + + diff --git a/tests/cli-test-xml/compare/kvm-win2k3-cdrom.xml b/tests/cli-test-xml/compare/kvm-win2k3-cdrom.xml index 272cf1dec..ab72b0ac1 100644 --- a/tests/cli-test-xml/compare/kvm-win2k3-cdrom.xml +++ b/tests/cli-test-xml/compare/kvm-win2k3-cdrom.xml @@ -31,6 +31,7 @@ + @@ -76,6 +77,7 @@ + @@ -121,6 +123,7 @@ + diff --git a/tests/cli-test-xml/compare/kvm-xenner.xml b/tests/cli-test-xml/compare/kvm-xenner.xml index a2ea35a92..1356cc3b7 100644 --- a/tests/cli-test-xml/compare/kvm-xenner.xml +++ b/tests/cli-test-xml/compare/kvm-xenner.xml @@ -9,6 +9,16 @@ restart restart + + + + + + + + + + diff --git a/tests/cli-test-xml/compare/qemu-32-on-64.xml b/tests/cli-test-xml/compare/qemu-32-on-64.xml index ba2a0e51a..1826c7b49 100644 --- a/tests/cli-test-xml/compare/qemu-32-on-64.xml +++ b/tests/cli-test-xml/compare/qemu-32-on-64.xml @@ -19,6 +19,16 @@ restart /usr/bin/qemu-kvm + + + + + + + + + + diff --git a/tests/cli-test-xml/compare/qemu-plain.xml b/tests/cli-test-xml/compare/qemu-plain.xml index 73152ec1e..3d2219d61 100644 --- a/tests/cli-test-xml/compare/qemu-plain.xml +++ b/tests/cli-test-xml/compare/qemu-plain.xml @@ -22,6 +22,16 @@ restart /usr/bin/qemu-system-x86_64 + + + + + + + + + + diff --git a/tests/cli-test-xml/compare/simple-pxe.xml b/tests/cli-test-xml/compare/simple-pxe.xml index 6181de94d..f1a1bca32 100644 --- a/tests/cli-test-xml/compare/simple-pxe.xml +++ b/tests/cli-test-xml/compare/simple-pxe.xml @@ -19,6 +19,16 @@ destroy /usr/bin/test-hv + + + + + + + + + + @@ -47,6 +57,16 @@ restart /usr/bin/test-hv + + + + + + + + + + diff --git a/tests/cli-test-xml/compare/w2k3-cdrom.xml b/tests/cli-test-xml/compare/w2k3-cdrom.xml index e39acaf4d..b5ae4202b 100644 --- a/tests/cli-test-xml/compare/w2k3-cdrom.xml +++ b/tests/cli-test-xml/compare/w2k3-cdrom.xml @@ -32,6 +32,7 @@ + @@ -72,6 +73,7 @@ + @@ -112,6 +114,7 @@ + diff --git a/tests/clitest.py b/tests/clitest.py index 1e767ee96..fbd8e2058 100644 --- a/tests/clitest.py +++ b/tests/clitest.py @@ -468,7 +468,7 @@ c.add_valid("--nodisks --boot hd --paravirt --arch i686") # 32 on 64 xen c = vinst.add_category("kvm", "--connect %(KVMURI)s --noautoconsole") c.add_compare("--os-variant fedora14 --file %(EXISTIMG1)s --location %(TREEDIR)s --extra-args console=ttyS0 --cpu host", "kvm-f14-url") # F14 Directory tree URL install with extra-args c.add_compare("--os-variant fedora14 --disk %(NEWIMG1)s,size=.01 --location %(TREEDIR)s --extra-args console=ttyS0 --quiet", "quiet-url") # Quiet URL install should make no noise -c.add_compare("--cdrom %(EXISTIMG2)s --file %(EXISTIMG1)s --os-variant win2k3 --wait 0 --sound", "kvm-win2k3-cdrom") # HVM windows install with disk +c.add_compare("--cdrom %(EXISTIMG2)s --file %(EXISTIMG1)s --os-variant win2k3 --wait 0 --sound --controller usb", "kvm-win2k3-cdrom") # HVM windows install with disk c.add_compare("--os-variant fedora14 --nodisks --boot hd --paravirt", "kvm-xenner") # xenner c.add_compare("--os-variant fedora14 --nodisks --boot cdrom --virt-type qemu --cpu Penryn", "qemu-plain") # plain qemu c.add_compare("--os-variant fedora14 --nodisks --boot network --nographics --arch i686", "qemu-32-on-64") # 32 on 64 @@ -486,7 +486,7 @@ c.add_invalid("--nodisks --boot network --paravirt --arch mips") # Invalid arch c = vinst.add_category("misc", "--nographics --noautoconsole") c.add_compare("", "noargs-fail") # No arguments c.add_compare("--hvm --nodisks --pxe --print-step all", "simple-pxe") # Diskless PXE install -c.add_compare("--hvm --cdrom %(EXISTIMG2)s --file %(EXISTIMG1)s --os-variant win2k3 --wait 0 --vcpus cores=4", "w2k3-cdrom") # HVM windows install with disk +c.add_compare("--hvm --cdrom %(EXISTIMG2)s --file %(EXISTIMG1)s --os-variant win2k3 --wait 0 --vcpus cores=4 --controller usb,model=none", "w2k3-cdrom") # HVM windows install with disk c.add_compare("""--hvm --pxe \ --controller usb,model=ich9-ehci1,address=0:0:4.7,index=0 \ --controller usb,model=ich9-uhci1,address=0:0:4.0,index=0,master=0 \ diff --git a/virt-install b/virt-install index 94284b2da..2d7d0b072 100755 --- a/virt-install +++ b/virt-install @@ -533,7 +533,12 @@ def build_guest_instance(conn, options): if not guest.get_devices("console") and not guest.get_devices("serial"): guest.add_default_console_device() if not guest.get_devices("video") and guest.get_devices("graphics"): - guest.add_device(virtinst.VirtualVideoDevice(guest.conn)) + guest.add_default_video_device() + + do_default_usb = all([d.type != "usb" for d in + guest.get_devices("controller")]) + if do_default_usb: + guest.add_default_usb_controller() # Install options cli.set_os_variant(guest, options.distro_type, options.distro_variant) diff --git a/virtManager/create.py b/virtManager/create.py index bff4561fe..a5adf6628 100644 --- a/virtManager/create.py +++ b/virtManager/create.py @@ -1513,6 +1513,7 @@ class vmmCreate(vmmGObjectUI): guest.add_default_console_device() if self.config.get_new_vm_sound(): guest.add_default_sound_device() + guest.add_default_usb_controller() except Exception, e: self.err.show_err(_("Error setting up default devices:") + str(e)) return None diff --git a/virtinst/guest.py b/virtinst/guest.py index fd5ceb4e5..7c4228cbe 100644 --- a/virtinst/guest.py +++ b/virtinst/guest.py @@ -531,6 +531,17 @@ class Guest(XMLBuilder): return self.add_device(virtinst.VirtualVideoDevice(self.conn)) + def add_default_usb_controller(self): + if self.os.is_container(): + return + if not self.os.is_x86(): + return + if not self.conn.check_conn_support( + self.conn.SUPPORT_CONN_DEFAULT_USB2): + return + for dev in virtinst.VirtualController.get_usb2_controllers(self.conn): + self.add_device(dev) + def _set_transient_device_defaults(self, install): def do_remove_media(d): # Keep cdrom around, but with no media attached, diff --git a/virtinst/support.py b/virtinst/support.py index ce141a704..5d306cd0b 100644 --- a/virtinst/support.py +++ b/virtinst/support.py @@ -330,6 +330,8 @@ SUPPORT_CONN_DISK_SD = _make(version=1001002) # here, but until someone tests things I'm going to be a bit conservative. SUPPORT_CONN_DEFAULT_QCOW2 = _make( version=8000, drv_version=[("qemu", 1002000), ("test", 0)]) +SUPPORT_CONN_DEFAULT_USB2 = _make( + version=9007, drv_version=[("qemu", 1000000), ("test", 0)]) # Domain checks SUPPORT_DOMAIN_GETVCPUS = _make(function="virDomain.vcpus", args=())