From 046a242bd4a91472961d9e9eb533629df5661902 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Wed, 3 Oct 2018 18:53:16 -0400 Subject: [PATCH] guest: Use USB3 for x86 qemu if OS supports it Using new annotations in osinfo-db --- .../compare/virt-install-f21-kvm-remote.xml | 11 +------ .../compare/virt-install-kvm-centos7.xml | 22 ++----------- ... => virt-install-kvm-fedoralatest-url.xml} | 22 ++----------- .../compare/virt-install-kvm-rhel7.xml | 22 ++----------- .../virt-install-kvm-session-defaults.xml | 22 ++----------- .../compare/virt-install-kvm-win10.xml | 22 ++----------- .../virt-install-ppc64-machdefault-f20.xml | 1 + .../virt-install-ppc64-pseries-f20.xml | 1 + .../virt-install-ppc64le-kvm-import.xml | 1 + .../compare/virt-install-qemu-32-on-64.xml | 11 +------ .../compare/virt-install-spice-gl.xml | 11 +------ tests/clitest.py | 18 +++++----- virtinst/devices/controller.py | 4 +-- virtinst/guest.py | 33 ++++++++++--------- virtinst/osdict.py | 8 +++-- virtinst/support.py | 1 - 16 files changed, 51 insertions(+), 159 deletions(-) rename tests/cli-test-xml/compare/{virt-install-kvm-f14-url.xml => virt-install-kvm-fedoralatest-url.xml} (81%) diff --git a/tests/cli-test-xml/compare/virt-install-f21-kvm-remote.xml b/tests/cli-test-xml/compare/virt-install-f21-kvm-remote.xml index 356abdb0f..a1ef6df0c 100644 --- a/tests/cli-test-xml/compare/virt-install-f21-kvm-remote.xml +++ b/tests/cli-test-xml/compare/virt-install-f21-kvm-remote.xml @@ -37,16 +37,7 @@ - - - - - - - - - - + diff --git a/tests/cli-test-xml/compare/virt-install-kvm-centos7.xml b/tests/cli-test-xml/compare/virt-install-kvm-centos7.xml index 88a2db01d..90ae5ebb7 100644 --- a/tests/cli-test-xml/compare/virt-install-kvm-centos7.xml +++ b/tests/cli-test-xml/compare/virt-install-kvm-centos7.xml @@ -39,16 +39,7 @@ - - - - - - - - - - + @@ -116,16 +107,7 @@ - - - - - - - - - - + diff --git a/tests/cli-test-xml/compare/virt-install-kvm-f14-url.xml b/tests/cli-test-xml/compare/virt-install-kvm-fedoralatest-url.xml similarity index 81% rename from tests/cli-test-xml/compare/virt-install-kvm-f14-url.xml rename to tests/cli-test-xml/compare/virt-install-kvm-fedoralatest-url.xml index 8eee1bdd3..feb4f5214 100644 --- a/tests/cli-test-xml/compare/virt-install-kvm-f14-url.xml +++ b/tests/cli-test-xml/compare/virt-install-kvm-fedoralatest-url.xml @@ -38,16 +38,7 @@ - - - - - - - - - - + @@ -102,16 +93,7 @@ - - - - - - - - - - + diff --git a/tests/cli-test-xml/compare/virt-install-kvm-rhel7.xml b/tests/cli-test-xml/compare/virt-install-kvm-rhel7.xml index f4ad60c38..e8a6ec365 100644 --- a/tests/cli-test-xml/compare/virt-install-kvm-rhel7.xml +++ b/tests/cli-test-xml/compare/virt-install-kvm-rhel7.xml @@ -39,16 +39,7 @@ - - - - - - - - - - + @@ -116,16 +107,7 @@ - - - - - - - - - - + diff --git a/tests/cli-test-xml/compare/virt-install-kvm-session-defaults.xml b/tests/cli-test-xml/compare/virt-install-kvm-session-defaults.xml index 54c000fae..5c40bd854 100644 --- a/tests/cli-test-xml/compare/virt-install-kvm-session-defaults.xml +++ b/tests/cli-test-xml/compare/virt-install-kvm-session-defaults.xml @@ -45,16 +45,7 @@ - - - - - - - - - - + @@ -125,16 +116,7 @@ - - - - - - - - - - + diff --git a/tests/cli-test-xml/compare/virt-install-kvm-win10.xml b/tests/cli-test-xml/compare/virt-install-kvm-win10.xml index 4c54784ac..608beef96 100644 --- a/tests/cli-test-xml/compare/virt-install-kvm-win10.xml +++ b/tests/cli-test-xml/compare/virt-install-kvm-win10.xml @@ -51,16 +51,7 @@ - - - - - - - - - - + @@ -133,16 +124,7 @@ - - - - - - - - - - + diff --git a/tests/cli-test-xml/compare/virt-install-ppc64-machdefault-f20.xml b/tests/cli-test-xml/compare/virt-install-ppc64-machdefault-f20.xml index f95c1b60d..2c143cbc8 100644 --- a/tests/cli-test-xml/compare/virt-install-ppc64-machdefault-f20.xml +++ b/tests/cli-test-xml/compare/virt-install-ppc64-machdefault-f20.xml @@ -21,6 +21,7 @@ + diff --git a/tests/cli-test-xml/compare/virt-install-ppc64-pseries-f20.xml b/tests/cli-test-xml/compare/virt-install-ppc64-pseries-f20.xml index aa711502d..e7fdf2a36 100644 --- a/tests/cli-test-xml/compare/virt-install-ppc64-pseries-f20.xml +++ b/tests/cli-test-xml/compare/virt-install-ppc64-pseries-f20.xml @@ -25,6 +25,7 @@ + diff --git a/tests/cli-test-xml/compare/virt-install-ppc64le-kvm-import.xml b/tests/cli-test-xml/compare/virt-install-ppc64le-kvm-import.xml index a1d51b988..c4492fcfa 100644 --- a/tests/cli-test-xml/compare/virt-install-ppc64le-kvm-import.xml +++ b/tests/cli-test-xml/compare/virt-install-ppc64le-kvm-import.xml @@ -21,6 +21,7 @@ + diff --git a/tests/cli-test-xml/compare/virt-install-qemu-32-on-64.xml b/tests/cli-test-xml/compare/virt-install-qemu-32-on-64.xml index 6b342bab5..a44dbc889 100644 --- a/tests/cli-test-xml/compare/virt-install-qemu-32-on-64.xml +++ b/tests/cli-test-xml/compare/virt-install-qemu-32-on-64.xml @@ -29,16 +29,7 @@ /usr/bin/qemu-kvm - - - - - - - - - - + diff --git a/tests/cli-test-xml/compare/virt-install-spice-gl.xml b/tests/cli-test-xml/compare/virt-install-spice-gl.xml index d995b8ed8..8c535e174 100644 --- a/tests/cli-test-xml/compare/virt-install-spice-gl.xml +++ b/tests/cli-test-xml/compare/virt-install-spice-gl.xml @@ -32,16 +32,7 @@ /usr/bin/qemu-kvm - - - - - - - - - - + diff --git a/tests/clitest.py b/tests/clitest.py index 013953a1b..e567f9859 100644 --- a/tests/clitest.py +++ b/tests/clitest.py @@ -24,7 +24,7 @@ os.environ["DISPLAY"] = ":3.4" OLD_OSINFO = False if virtinst.OSDB.lookup_os("rhel7.0"): - OLD_OSINFO = not virtinst.OSDB.lookup_os("rhel7.0").supports_virtiorng() + OLD_OSINFO = not virtinst.OSDB.lookup_os("rhel7.0").supports_usb3() TMP_IMAGE_DIR = "/tmp/__virtinst_cli_" XMLDIR = "tests/cli-test-xml" @@ -339,7 +339,7 @@ vinst = App("virt-install") # virt-install verbose XML comparison tests # ############################################# -c = vinst.add_category("xml-comparsion", "--connect %(URI-KVM)s --noautoconsole --os-variant fedora-unknown") +c = vinst.add_category("xml-comparsion", "--connect %(URI-KVM)s --noautoconsole --os-variant fedora-unknown", skip_check=OLD_OSINFO) # Singleton element test #1, for simpler strings c.add_compare(""" \ @@ -692,12 +692,12 @@ c.add_invalid("--file /foo/bar/baz --pxe") # Trying to use unmanaged storage wi ########################### c = vinst.add_category("kvm-generic", "--connect %(URI-KVM)s --noautoconsole") -c.add_compare("--os-variant fedora-unknown --file %(EXISTIMG1)s --location %(TREEDIR)s --extra-args console=ttyS0 --cpu host --channel none --console none --sound none --redirdev none", "kvm-f14-url") # Fedora Directory tree URL install with extra-args +c.add_compare("--os-variant fedora-unknown --file %(EXISTIMG1)s --location %(TREEDIR)s --extra-args console=ttyS0 --cpu host --channel none --console none --sound none --redirdev none", "kvm-fedoralatest-url", skip_check=OLD_OSINFO) # Fedora Directory tree URL install with extra-args c.add_compare("--test-media-detection %(TREEDIR)s", "test-url-detection") # --test-media-detection -c.add_compare("--os-variant fedora20 --disk %(NEWIMG1)s,size=.01,format=vmdk --location %(TREEDIR)s --extra-args console=ttyS0 --quiet", "quiet-url") # Quiet URL install should make no noise +c.add_compare("--os-variant fedora20 --disk %(NEWIMG1)s,size=.01,format=vmdk --location %(TREEDIR)s --extra-args console=ttyS0 --quiet", "quiet-url", skip_check=OLD_OSINFO) # Quiet URL install should make no noise 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 ubuntusaucy --nodisks --boot cdrom --virt-type qemu --cpu Penryn --input tablet", "qemu-plain") # plain qemu -c.add_compare("--os-variant fedora20 --nodisks --boot network --nographics --arch i686", "qemu-32-on-64") # 32 on 64 +c.add_compare("--os-variant fedora20 --nodisks --boot network --nographics --arch i686", "qemu-32-on-64", skip_check=OLD_OSINFO) # 32 on 64 # ppc64 tests c.add_compare("--arch ppc64 --machine pseries --boot network --disk %(EXISTIMG1)s --disk device=cdrom --os-variant fedora20 --network none", "ppc64-pseries-f20") @@ -705,11 +705,11 @@ c.add_compare("--arch ppc64 --boot network --disk %(EXISTIMG1)s --os-variant fed c.add_compare("--connect %(URI-KVM-PPC64LE)s --import --disk %(EXISTIMG1)s --os-variant fedora20 --panic default", "ppc64le-kvm-import") # s390x tests -c.add_compare("--arch s390x --machine s390-ccw-virtio --connect %(URI-KVM-S390X)s --boot kernel=/kernel.img,initrd=/initrd.img --disk %(EXISTIMG1)s --disk %(EXISTIMG3)s,device=cdrom --os-variant fedora21", "s390x-cdrom") +c.add_compare("--arch s390x --machine s390-ccw-virtio --connect %(URI-KVM-S390X)s --boot kernel=/kernel.img,initrd=/initrd.img --disk %(EXISTIMG1)s --disk %(EXISTIMG3)s,device=cdrom --os-variant fedora21", "s390x-cdrom", skip_check=OLD_OSINFO) c.add_compare("--arch s390x --machine s390-ccw-virtio --connect " + utils.URIs.kvm_s390x_KVMIBM + " --boot kernel=/kernel.img,initrd=/initrd.img --disk %(EXISTIMG1)s --disk %(EXISTIMG3)s,device=cdrom --os-variant fedora21 --watchdog diag288,action=reset --panic default", "s390x-cdrom-KVMIBM") # qemu:///session tests -c.add_compare("--connect " + utils.URIs.kvm_session + " --disk size=8 --os-variant fedora21 --cdrom %(EXISTIMG1)s", "kvm-session-defaults") +c.add_compare("--connect " + utils.URIs.kvm_session + " --disk size=8 --os-variant fedora21 --cdrom %(EXISTIMG1)s", "kvm-session-defaults", skip_check=OLD_OSINFO) # misc KVM config tests c.add_compare("--disk none --location %(EXISTIMG3)s --nonetworks", "location-iso", skip_check=not find_executable("isoinfo")) # Using --location iso mounting @@ -717,12 +717,12 @@ c.add_compare("--disk %(EXISTIMG1)s --pxe --os-variant rhel5.4", "kvm-rhel5") # c.add_compare("--disk %(EXISTIMG1)s --pxe --os-variant rhel6.4", "kvm-rhel6") # RHEL6 defaults c.add_compare("--disk %(EXISTIMG1)s --pxe --os-variant rhel7.0", "kvm-rhel7", skip_check=OLD_OSINFO) # RHEL7 defaults c.add_compare("--disk %(EXISTIMG1)s --pxe --os-variant centos7.0", "kvm-centos7", skip_check=OLD_OSINFO) # Centos 7 defaults -c.add_compare("--disk %(EXISTIMG1)s --cdrom %(EXISTIMG2)s --os-variant win10", "kvm-win10") # win10 defaults +c.add_compare("--disk %(EXISTIMG1)s --cdrom %(EXISTIMG2)s --os-variant win10", "kvm-win10", skip_check=OLD_OSINFO) # win10 defaults c.add_compare("--os-variant win7 --cdrom %(EXISTIMG2)s --boot loader_type=pflash,loader=CODE.fd,nvram_template=VARS.fd --disk %(EXISTIMG1)s", "win7-uefi") # no HYPER-V with UEFI c.add_compare("--arch i686 --boot uefi --pxe --disk none", "kvm-i686-uefi") # i686 uefi c.add_compare("--machine q35 --cdrom %(EXISTIMG2)s --disk %(EXISTIMG1)s", "q35-defaults") # proper q35 disk defaults c.add_compare("--disk size=20 --os-variant solaris10", "solaris10-defaults") # test solaris OS defaults -c.add_compare("--connect " + utils.URIs.kvm_remote + " --import --disk %(EXISTIMG1)s --os-variant fedora21 --pm suspend_to_disk=yes", "f21-kvm-remote") +c.add_compare("--connect " + utils.URIs.kvm_remote + " --import --disk %(EXISTIMG1)s --os-variant fedora21 --pm suspend_to_disk=yes", "f21-kvm-remote", skip_check=OLD_OSINFO) c.add_valid("--arch aarch64 --nodisks --pxe --connect " + utils.URIs.kvm_nodomcaps) # attempt to default to aarch64 UEFI, but it fails, but should only print warnings c.add_invalid("--disk none --boot network --machine foobar") # Unknown machine type diff --git a/virtinst/devices/controller.py b/virtinst/devices/controller.py index 0aa84c1df..542552592 100644 --- a/virtinst/devices/controller.py +++ b/virtinst/devices/controller.py @@ -74,11 +74,11 @@ class DeviceController(Device): @staticmethod def get_usb3_controller(conn, guest): + ignore = guest ctrl = DeviceController(conn) ctrl.type = "usb" ctrl.model = "nec-xhci" - if ((guest.os.is_arm_machvirt() or guest.os.is_pseries()) and - conn.check_support(conn.SUPPORT_CONN_QEMU_XHCI)): + if conn.check_support(conn.SUPPORT_CONN_QEMU_XHCI): ctrl.model = "qemu-xhci" if conn.check_support(conn.SUPPORT_CONN_USB3_PORTS): ctrl.ports = 8 diff --git a/virtinst/guest.py b/virtinst/guest.py index 983dedbef..7ca87240e 100644 --- a/virtinst/guest.py +++ b/virtinst/guest.py @@ -581,32 +581,35 @@ class Guest(XMLBuilder): self.add_device(DeviceVideo(self.conn)) def _add_default_usb_controller(self): - if self.os.is_container(): - return if any([d.type == "usb" for d in self.devices.controller]): return + if not self.conn.is_qemu() and not self.conn.is_test(): + return + qemu_usb3 = self.conn.check_support(self.conn.SUPPORT_CONN_QEMU_XHCI) usb2 = False usb3 = False if self.os.is_x86(): - usb2 = True - elif (self.os.is_arm_machvirt() and - self.conn.check_support( - self.conn.SUPPORT_CONN_MACHVIRT_PCI_DEFAULT)): - usb3 = True + if self.osinfo.supports_usb3() and qemu_usb3: + usb3 = True + else: + usb2 = True + elif self.os.is_arm_machvirt(): + # For machvirt, we always assume OS supports usb3 + if (qemu_usb3 and + self.conn.check_support( + self.conn.SUPPORT_CONN_MACHVIRT_PCI_DEFAULT)): + usb3 = True + elif self.os.is_pseries(): + # For pseries, we always assume OS supports usb3 + if qemu_usb3: + usb3 = True - if not usb2 and not usb3: - return - if usb2: - if not self.conn.check_support( - self.conn.SUPPORT_CONN_DEFAULT_USB2): - return for dev in DeviceController.get_usb2_controllers(self.conn): self.add_device(dev) - - if usb3: + elif usb3: self.add_device( DeviceController.get_usb3_controller(self.conn, self)) diff --git a/virtinst/osdict.py b/virtinst/osdict.py index e4be0bbef..822c9ae3a 100644 --- a/virtinst/osdict.py +++ b/virtinst/osdict.py @@ -197,8 +197,7 @@ class _OSDB(object): # Added 2018-10-02. Maybe remove aliases in a year logging.warning( _("OS name '%s' is deprecated, using '%s' instead. " - "This alias will be removed in the future."), - (key, alias)) + "This alias will be removed in the future."), (key, alias)) key = alias return self._all_variants.get(key) @@ -407,6 +406,11 @@ class _OsVariant(object): # Remove this hack after 6 months or so return self._is_related_to("rhel6.0") + def supports_usb3(self): + # qemu-xhci + devids = ["http://pcisig.com/pci/1b36/0004"] + return bool(self._device_filter(devids=devids)) + def supports_chipset_q35(self): return False diff --git a/virtinst/support.py b/virtinst/support.py index c296319a3..dbdf758fa 100644 --- a/virtinst/support.py +++ b/virtinst/support.py @@ -234,7 +234,6 @@ SUPPORT_CONN_WORKING_XEN_EVENTS = _make(hv_version={"xen": "4.0.0", "all": 0}) # default to qcow2. It might be fine for xen or qemu older than the versions # here, but until someone tests things I'm going to be a bit conservative. SUPPORT_CONN_DEFAULT_QCOW2 = _make(hv_version={"qemu": "1.2.0", "test": 0}) -SUPPORT_CONN_DEFAULT_USB2 = _make(hv_version={"qemu": "1.0.0", "test": 0}) SUPPORT_CONN_AUTOSOCKET = _make(hv_libvirt_version={"qemu": "1.0.6"}) SUPPORT_CONN_PM_DISABLE = _make(hv_version={"qemu": "1.2.0", "test": 0}) SUPPORT_CONN_QCOW2_LAZY_REFCOUNTS = _make(