75 lines
2.6 KiB
Diff
75 lines
2.6 KiB
Diff
Subject: tests: Add unit test coverage for #539
|
|
From: Cole Robinson crobinso@redhat.com Tue Aug 29 12:27:40 2023 -0400
|
|
Date: Tue Aug 29 12:27:40 2023 -0400:
|
|
Git: 19b0f3f446ff8fc3b98c676726ee3a42b0b00b74
|
|
|
|
Signed-off-by: Cole Robinson <crobinso@redhat.com>
|
|
|
|
diff --git a/tests/data/xmlparse/emulator-custom.xml b/tests/data/xmlparse/emulator-custom.xml
|
|
new file mode 100644
|
|
index 00000000..d39ce024
|
|
--- /dev/null
|
|
+++ b/tests/data/xmlparse/emulator-custom.xml
|
|
@@ -0,0 +1,22 @@
|
|
+<domain type='kvm'>
|
|
+ <name>manual-emulator-test</name>
|
|
+ <metadata>
|
|
+ <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
|
|
+ <libosinfo:os id="http://fedoraproject.org/fedora/unknown"/>
|
|
+ </libosinfo:libosinfo>
|
|
+ </metadata>
|
|
+ <memory unit='KiB'>8388608</memory>
|
|
+ <currentMemory unit='KiB'>8388608</currentMemory>
|
|
+ <vcpu placement='static'>8</vcpu>
|
|
+ <os>
|
|
+ <type arch='mips' machine='some-unknown-machine'>hvm</type>
|
|
+ <boot dev='hd'/>
|
|
+ </os>
|
|
+ <on_poweroff>destroy</on_poweroff>
|
|
+ <on_reboot>restart</on_reboot>
|
|
+ <on_crash>destroy</on_crash>
|
|
+ <devices>
|
|
+ <emulator>/my/manual/emulator</emulator>
|
|
+ </devices>
|
|
+</domain>
|
|
+
|
|
diff --git a/tests/test_xmlparse.py b/tests/test_xmlparse.py
|
|
index 1bf0ebe5..781680cf 100644
|
|
--- a/tests/test_xmlparse.py
|
|
+++ b/tests/test_xmlparse.py
|
|
@@ -1170,3 +1170,34 @@ def testDiskSourceAbspath():
|
|
# ...unless it's a URL
|
|
disk.set_source_path("http://example.com/foobar3")
|
|
assert disk.get_source_path() == "http://example.com/foobar3"
|
|
+
|
|
+
|
|
+def testUnknownEmulatorDomcapsLookup(monkeypatch):
|
|
+ """
|
|
+ Libvirt can handle defining a VM with a custom emulator, one not detected
|
|
+ by `virsh capabilities`. An appropriate `virsh domcapabilities` call will
|
|
+ inspect the emulator and return relevant info.
|
|
+
|
|
+ This test ensures that for parsing XML the `virsh capabilities` failure
|
|
+ isn't fatal, and we attempt to return valid `virsh domcapabilities` data
|
|
+ """
|
|
+
|
|
+ seen = False
|
|
+ def fake_build_from_params(conn, emulator, arch, machine, hvtype):
|
|
+ nonlocal seen
|
|
+ seen = True
|
|
+ assert arch == "mips"
|
|
+ assert machine == "some-unknown-machine"
|
|
+ assert emulator == "/my/manual/emulator"
|
|
+ return virtinst.DomainCapabilities(conn)
|
|
+
|
|
+ monkeypatch.setattr(
|
|
+ "virtinst.DomainCapabilities.build_from_params",
|
|
+ fake_build_from_params)
|
|
+
|
|
+ conn = utils.URIs.open_kvm()
|
|
+ xml = open(DATADIR + "emulator-custom.xml").read()
|
|
+ guest = virtinst.Guest(conn, xml)
|
|
+ assert guest.lookup_domcaps()
|
|
+ assert guest.lookup_domcaps()
|
|
+ assert seen
|