Subject: uri: Mock domcaps returning NO_SUPPORT From: Cole Robinson crobinso@redhat.com Mon Jan 22 17:07:31 2024 -0500 Date: Mon Jan 22 17:07:31 2024 -0500: Git: 2e3db754d1d596f8fed6b327017ace922838eb49 With libvirt 9.8.0, the test driver now has a stub getDomainCapabilities implementation. But we still have some code that needs to handle a driver with missing domcaps. Make our magicuri mock return NO_SUPPORT for domcaps, when the URI doesn't have any domcaps XML passed in. This is enough for our test purposes. Signed-off-by: Cole Robinson diff --git a/virtinst/uri.py b/virtinst/uri.py index c83aaa78..c4be1960 100644 --- a/virtinst/uri.py +++ b/virtinst/uri.py @@ -173,23 +173,39 @@ class MagicURI(object): capsxml = open(self.capsfile).read() conn.getCapabilities = lambda: capsxml + def _raise_nosupport_error(msg): + import libvirt + err = [libvirt.VIR_ERR_NO_SUPPORT, None, msg, None, None, None] + exc = libvirt.libvirtError(msg) + exc.err = err + raise exc + # Fake domcapabilities. This is insufficient since output should # vary per type/arch/emulator combo, but it can be expanded later # if needed + domcapsxml = None if self.domcapsfile: domcapsxml = open(self.domcapsfile).read() - def fake_domcaps(emulator, arch, machine, virttype, flags=0): - ignore = emulator - ignore = flags - ignore = machine - ignore = virttype + def fake_domcaps(emulator, arch, machine, virttype, flags=0): + ignore = emulator + ignore = flags + ignore = machine + ignore = virttype + + if domcapsxml: ret = domcapsxml if arch: ret = re.sub("arch>.+%s