virt: don't add spicevmc channel to Xen VMs

Xen fully virtualized VMs with spicevmc channel fail to start, so better
not write it out in such cases.
This commit is contained in:
Cédric Bosdonnat 2021-02-04 11:56:05 +01:00 committed by Megan Wilhite
parent 5c6f05909d
commit 39207dd38d
3 changed files with 12 additions and 3 deletions

1
changelog/59416.fixed Normal file
View file

@ -0,0 +1 @@
Don't create spicevmc channel for Xen virtual machines

View file

@ -285,7 +285,7 @@
autoport='{{ yesno(not graphics.port and not graphics.tls_port) }}'>
<listen type='{{ graphics.listen.type }}'{{ opt_attribute(graphics.listen, "address") }}/>
</graphics>
{%- if graphics.type == "spice" %}
{%- if graphics.type == "spice" and hypervisor in ["qemu", "kvm"] %}
<channel type='spicevmc'>
<target type='virtio' name='com.redhat.spice.0'/>
</channel>

View file

@ -2130,7 +2130,8 @@ def test_update_failure(make_mock_vm):
}
def test_gen_xml_spice_default():
@pytest.mark.parametrize("hypervisor", ["kvm", "xen"])
def test_gen_xml_spice_default(hypervisor):
"""
Test virt._gen_xml() with default spice graphics device
"""
@ -2141,7 +2142,7 @@ def test_gen_xml_spice_default():
512,
{},
{},
"kvm",
hypervisor,
"hvm",
"x86_64",
graphics={"type": "spice"},
@ -2152,6 +2153,13 @@ def test_gen_xml_spice_default():
assert root.find("devices/graphics").attrib["listen"] == "0.0.0.0"
assert root.find("devices/graphics/listen").attrib["type"] == "address"
assert root.find("devices/graphics/listen").attrib["address"] == "0.0.0.0"
if hypervisor == "kvm":
assert (
root.find(".//channel[@type='spicevmc']/target").get("name")
== "com.redhat.spice.0"
)
else:
assert root.find(".//channel[@type='spicevmc']") is None
def test_gen_xml_spice():