connection: Clean up stable_defaults, improve test coverage

This commit is contained in:
Cole Robinson 2015-03-23 16:48:43 -04:00
parent 2a31ff0248
commit 08a72a4aec
4 changed files with 149 additions and 11 deletions

View File

@ -0,0 +1,127 @@
<capabilities>
<host>
<uuid>b1517723-d556-41ee-8f77-ef18afe127d1</uuid>
<cpu>
<arch>x86_64</arch>
<model>qemu64</model>
<vendor>AMD</vendor>
<topology sockets='8' cores='1' threads='1'/>
<feature name='fma4'/>
<feature name='xop'/>
<feature name='3dnowprefetch'/>
<feature name='misalignsse'/>
<feature name='sse4a'/>
<feature name='abm'/>
<feature name='lahf_lm'/>
<feature name='pdpe1gb'/>
<feature name='hypervisor'/>
<feature name='avx'/>
<feature name='osxsave'/>
<feature name='xsave'/>
<feature name='aes'/>
<feature name='popcnt'/>
<feature name='sse4.2'/>
<feature name='sse4.1'/>
<feature name='ssse3'/>
<feature name='pclmuldq'/>
</cpu>
<power_management>
<suspend_mem/>
<suspend_disk/>
<suspend_hybrid/>
</power_management>
<migration_features>
<live/>
<uri_transports>
<uri_transport>tcp</uri_transport>
</uri_transports>
</migration_features>
<topology>
<cells num='1'>
<cell id='0'>
<memory unit='KiB'>4193900</memory>
<cpus num='8'>
<cpu id='0' socket_id='0' core_id='0' siblings='0'/>
<cpu id='1' socket_id='1' core_id='0' siblings='1'/>
<cpu id='2' socket_id='2' core_id='0' siblings='2'/>
<cpu id='3' socket_id='3' core_id='0' siblings='3'/>
<cpu id='4' socket_id='4' core_id='0' siblings='4'/>
<cpu id='5' socket_id='5' core_id='0' siblings='5'/>
<cpu id='6' socket_id='6' core_id='0' siblings='6'/>
<cpu id='7' socket_id='7' core_id='0' siblings='7'/>
</cpus>
</cell>
</cells>
</topology>
<secmodel>
<model>selinux</model>
<doi>0</doi>
</secmodel>
<secmodel>
<model>dac</model>
<doi>0</doi>
</secmodel>
</host>
<guest>
<os_type>hvm</os_type>
<arch name='i686'>
<wordsize>32</wordsize>
<emulator>/usr/libexec/qemu-kvm</emulator>
<machine canonical='pc-i440fx-rhel7.0.0' maxCpus='255'>pc</machine>
<machine canonical='pc-q35-rhel7.0.0' maxCpus='255'>q35</machine>
<machine maxCpus='255'>rhel6.0.0</machine>
<machine maxCpus='255'>rhel6.1.0</machine>
<machine maxCpus='255'>rhel6.2.0</machine>
<machine maxCpus='255'>rhel6.3.0</machine>
<machine maxCpus='255'>rhel6.4.0</machine>
<machine maxCpus='255'>rhel6.5.0</machine>
<machine maxCpus='1'>none</machine>
<domain type='qemu'>
</domain>
<domain type='kvm'>
<emulator>/usr/libexec/qemu-kvm</emulator>
</domain>
</arch>
<features>
<cpuselection/>
<deviceboot/>
<acpi default='on' toggle='yes'/>
<apic default='on' toggle='no'/>
<pae/>
<nonpae/>
</features>
</guest>
<guest>
<os_type>hvm</os_type>
<arch name='x86_64'>
<wordsize>64</wordsize>
<emulator>/usr/libexec/qemu-kvm</emulator>
<machine canonical='pc-i440fx-rhel7.0.0' maxCpus='255'>pc</machine>
<machine canonical='pc-q35-rhel7.0.0' maxCpus='255'>q35</machine>
<machine maxCpus='255'>rhel6.0.0</machine>
<machine maxCpus='255'>rhel6.1.0</machine>
<machine maxCpus='255'>rhel6.2.0</machine>
<machine maxCpus='255'>rhel6.3.0</machine>
<machine maxCpus='255'>rhel6.4.0</machine>
<machine maxCpus='255'>rhel6.5.0</machine>
<machine maxCpus='1'>none</machine>
<domain type='qemu'>
</domain>
<domain type='kvm'>
<emulator>/usr/libexec/qemu-kvm</emulator>
</domain>
</arch>
<features>
<cpuselection/>
<deviceboot/>
<acpi default='on' toggle='yes'/>
<apic default='on' toggle='no'/>
</features>
</guest>
</capabilities>

View File

@ -39,6 +39,7 @@ uriqemu = "%s,qemu" % testuri
urixen = "%s,xen" % testuri
urixencaps = testuri + _capsprefix + "rhel5.4-xen-caps-virt-enabled.xml,xen"
urixenia64 = testuri + _capsprefix + "xen-ia64-hvm.xml,xen"
urirhelkvm = (uriqemu + _capsprefix + "caps-libvirt-1.1.1-29.el7.xml")
urikvm_nodomcaps = (uriqemu + _capsprefix + "libvirt-1.1.2-qemu-caps.xml")
urikvm = (urikvm_nodomcaps +
_domcapsprefix + "domcapabilities-1.2.12-aavmf.xml")
@ -127,6 +128,10 @@ def open_plainkvm(connver=None, libver=None):
return openconn(_make_uri(uriqemu, connver, libver))
def open_rhelkvm(connver=None):
return openconn(_make_uri(urirhelkvm, connver))
def open_test_remote():
return openconn(uriremote)

View File

@ -285,7 +285,8 @@ class TestXMLMisc(unittest.TestCase):
Make sure device defaults are properly changed if we change OS
distro/variant mid process
"""
conn = utils.open_plainkvm(connver=12005)
# Use connver=12005 so that non-rhel displays ac97
conn = utils.open_rhelkvm(connver=12005)
g = _make_guest(conn=conn)
do_install = False
@ -299,6 +300,8 @@ class TestXMLMisc(unittest.TestCase):
cliconfig.stable_defaults = True
origemu = g.emulator
g.emulator = "/usr/libexec/qemu-kvm"
self.assertTrue(g.conn.stable_defaults())
setattr(g.conn, "_support_cache", {})
self._compare(g, "install-f11-rheldefaults", do_install)
g.emulator = origemu
@ -311,8 +314,7 @@ class TestXMLMisc(unittest.TestCase):
def test_no_vmvga_RHEL(self):
# Test that vmvga is not used on RHEL
conn = utils.open_plainkvm(connver=12005)
conn = utils.open_rhelkvm(connver=12005)
g = _make_guest(conn=conn)
try:

View File

@ -328,17 +328,21 @@ class VirtualConnection(object):
return self._conn_version
def stable_defaults(self, emulator=None):
if not cliconfig.stable_defaults:
return False
if not self.is_qemu_system():
return False
if emulator:
if not str(emulator).startswith("/usr/libexec"):
return False
else:
for guest in self.caps.guests:
for dom in guest.domains:
if dom.emulator.startswith("/usr/libexec"):
return cliconfig.stable_defaults
return cliconfig.stable_defaults
return str(emulator).startswith("/usr/libexec")
for guest in self.caps.guests:
for dom in guest.domains:
if dom.emulator.startswith("/usr/libexec"):
return True
return False
###################
# Public URI bits #