From 82ea5bfc62ce5c7be26e470f7c450110870b5af6 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Mon, 10 Aug 2015 12:46:47 -0400 Subject: [PATCH] tests: Add qemu:///session unit tests --- .../virt-install-kvm-session-defaults.xml | 153 ++++++++++++++++++ tests/clitest.py | 6 +- tests/utils.py | 1 + virtinst/connection.py | 9 +- 4 files changed, 166 insertions(+), 3 deletions(-) create mode 100644 tests/cli-test-xml/compare/virt-install-kvm-session-defaults.xml 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 new file mode 100644 index 000000000..aa269fa47 --- /dev/null +++ b/tests/cli-test-xml/compare/virt-install-kvm-session-defaults.xml @@ -0,0 +1,153 @@ + + foobar + 00000000-1111-2222-3333-444444444444 + 65536 + 65536 + 1 + + hvm + + + + + + + + + + Opteron_G4 + + + + + + + destroy + destroy + destroy + + + + + + /usr/bin/qemu-kvm + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + foobar + 00000000-1111-2222-3333-444444444444 + 65536 + 65536 + 1 + + hvm + + + + + + + + + Opteron_G4 + + + + + + + destroy + restart + restart + + + + + + /usr/bin/qemu-kvm + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/clitest.py b/tests/clitest.py index 6c308c853..2cb25c7de 100644 --- a/tests/clitest.py +++ b/tests/clitest.py @@ -71,6 +71,7 @@ test_files = { 'URI-TEST-DEFAULT': utils.uri_test_default, 'URI-TEST-REMOTE': utils.uri_test_remote, 'URI-KVM': utils.uri_kvm, + 'URI-KVM-SESSION': utils.uri_kvm_session, 'URI-KVM-REMOTE': utils.uri_kvm + ",remote", 'URI-KVM-NODOMCAPS': utils.uri_kvm_nodomcaps, 'URI-KVM-ARMV7L' : utils.uri_kvm_armv7l, @@ -698,6 +699,10 @@ c.add_compare("--connect %(URI-KVM-PPC64LE)s --import --disk %(EXISTIMG1)s --os- # 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") +# qemu:///session tests +c.add_compare("--connect %(URI-KVM-SESSION)s --disk size=8 --os-variant fedora21 --cdrom %(EXISTIMG1)s", "kvm-session-defaults") + +# misc KVM config tests c.add_compare("--disk none --location %(EXISTIMG3)s --nonetworks", "location-iso") # Using --location iso mounting 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") # RHEL7 defaults @@ -705,7 +710,6 @@ c.add_compare("--disk %(EXISTIMG1)s --pxe --os-variant centos7.0", "kvm-centos7" 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("--machine q35 --cdrom %(EXISTIMG2)s --disk %(EXISTIMG1)s", "q35-defaults") # proper q35 disk defaults c.add_compare("--connect %(URI-KVM-REMOTE)s --import --disk %(EXISTIMG1)s --os-variant fedora21 --pm suspend_to_disk=yes", "f21-kvm-remote") - c.add_valid("--connect %(URI-KVM-NODOMCAPS)s --arch aarch64 --nodisks --pxe") # 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 c.add_invalid("--nodisks --boot network --arch mips --virt-type kvm") # Invalid domain type for arch diff --git a/tests/utils.py b/tests/utils.py index fe99155c9..95d2e5498 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -42,6 +42,7 @@ _uri_kvm_domcaps = (_uri_qemu + _domcapsprefix + "kvm-x86_64-domcaps.xml") uri_kvm_nodomcaps = (_uri_qemu + _capsprefix + "kvm-x86_64.xml") uri_kvm_rhel = (_uri_kvm_domcaps + _capsprefix + "kvm-x86_64-rhel7.xml") uri_kvm = (_uri_kvm_domcaps + _capsprefix + "kvm-x86_64.xml") +uri_kvm_session = uri_kvm + ",session" uri_kvm_armv7l = (_uri_kvm_domcaps + _capsprefix + "kvm-armv7l.xml") uri_kvm_aarch64 = (_uri_kvm_domcaps + _capsprefix + "kvm-aarch64.xml") diff --git a/virtinst/connection.py b/virtinst/connection.py index b214e204a..afa7dd019 100644 --- a/virtinst/connection.py +++ b/virtinst/connection.py @@ -360,6 +360,9 @@ class VirtualConnection(object): def is_remote(self): return (hasattr(self, "_virtinst__fake_conn_remote") or self._urisplits.hostname) + def is_session_uri(self): + return (hasattr(self, "_virtinst__fake_conn_session") or + self.get_uri_path() == "/session") def get_uri_hostname(self): return self._urisplits.hostname @@ -375,8 +378,6 @@ class VirtualConnection(object): def get_uri_driver(self): return self._urisplits.scheme - def is_session_uri(self): - return self.get_uri_path() == "/session" def is_qemu(self): return self._urisplits.scheme.startswith("qemu") def is_qemu_system(self): @@ -457,6 +458,10 @@ class VirtualConnection(object): opts.pop("remote") setattr(self, "_virtinst__fake_conn_remote", True) + if "session" in opts: + opts.pop("session") + setattr(self, "_virtinst__fake_conn_session", True) + if "prettyname" in opts: self._fake_pretty_name = opts.pop("prettyname")