connection: Add domain caps handling for fake URIs

Allows us to pass in custom domcaps content for testing purposes
This commit is contained in:
Cole Robinson 2015-02-18 14:49:53 -05:00
parent 6e2e43b178
commit 4efc814d7f
3 changed files with 74 additions and 1 deletions

View File

@ -0,0 +1,60 @@
<domainCapabilities>
<path>/bin/qemu-system-x86_64</path>
<domain>kvm</domain>
<machine>pc-i440fx-2.1</machine>
<arch>x86_64</arch>
<vcpu max='255'/>
<os supported='yes'>
<loader supported='yes'>
<value>/usr/share/AAVMF/AAVMF_CODE.fd</value>
<value>/usr/share/OVMF/OVMF_CODE.fd</value>
<enum name='type'>
<value>rom</value>
<value>pflash</value>
</enum>
<enum name='readonly'>
<value>yes</value>
<value>no</value>
</enum>
</loader>
</os>
<devices>
<disk supported='yes'>
<enum name='diskDevice'>
<value>disk</value>
<value>cdrom</value>
<value>floppy</value>
<value>lun</value>
</enum>
<enum name='bus'>
<value>ide</value>
<value>fdc</value>
<value>scsi</value>
<value>virtio</value>
<value>usb</value>
</enum>
</disk>
<hostdev supported='yes'>
<enum name='mode'>
<value>subsystem</value>
</enum>
<enum name='startupPolicy'>
<value>default</value>
<value>mandatory</value>
<value>requisite</value>
<value>optional</value>
</enum>
<enum name='subsysType'>
<value>usb</value>
<value>pci</value>
<value>scsi</value>
</enum>
<enum name='capsType'/>
<enum name='pciBackend'>
<value>default</value>
<value>kvm</value>
<value>vfio</value>
</enum>
</hostdev>
</devices>
</domainCapabilities>

View File

@ -31,6 +31,7 @@ REGENERATE_OUTPUT = False
# Access to protected member, needed to unittest stuff
_capsprefix = ",caps=%s/tests/capabilities-xml/" % os.getcwd()
_domcapsprefix = ",domcaps=%s/tests/capabilities-xml/" % os.getcwd()
defaulturi = "__virtinst_test__test:///default,predictable"
testuri = "__virtinst_test__test:///%s/tests/testdriver.xml,predictable" % os.getcwd()
uriremote = testuri + ",remote"
@ -38,7 +39,8 @@ 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"
urikvm = uriqemu + _capsprefix + "libvirt-1.1.2-qemu-caps.xml"
urikvm = (uriqemu + _capsprefix + "libvirt-1.1.2-qemu-caps.xml" +
_domcapsprefix + "domcapabilities-1.2.12-aavmf.xml")
urilxc = testuri + _capsprefix + "capabilities-lxc.xml,lxc"

View File

@ -452,6 +452,17 @@ class VirtualConnection(object):
capsxml = file(opts.pop("caps")).read()
conn.getCapabilities = lambda: capsxml
# Fake domcapabilities. This is insufficient since output should
# vary per type/arch/emulator combo, but it can be expanded later
# if needed
if "domcaps" in opts:
domcapsxml = file(opts.pop("domcaps")).read()
def fake_domcaps(*args, **kwargs):
ignore = args
ignore = kwargs
return domcapsxml
conn.getDomainCapabilities = fake_domcaps
if ("qemu" in opts) or ("xen" in opts) or ("lxc" in opts):
opts.pop("qemu", None)
opts.pop("xen", None)