Skip to content

Commit 107cc6f

Browse files
committed
libvirt-xml: set guivm backend for stubdomain's gui
When using a HVM with a GUI via stubdomain, that GUI agent should connect to the appropriate guivm. It is dom0 by default, so it works in a common case, but if somebody uses non-dom0 for GUI, then the parameter is missing. Passing through the parameter is already implemented in libvirt, libxl and QEMU. But setting it in the libvirt xml in the first place was missing. Fixes QubesOS/qubes-issues#9385
1 parent d2d2ad8 commit 107cc6f

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

qubes/tests/vm/qubesvm.py

+67
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,73 @@ def test_600_libvirt_xml_hvm(self):
10501050
lxml.etree.XML(libvirt_xml), lxml.etree.XML(expected)
10511051
)
10521052

1053+
def test_600_libvirt_xml_hvm_with_guivm(self):
1054+
my_uuid = "7db78950-c467-4863-94d1-af59806384ea"
1055+
expected = """<domain type="xen">
1056+
<name>test-inst-test</name>
1057+
<uuid>7db78950-c467-4863-94d1-af59806384ea</uuid>
1058+
<memory unit="MiB">400</memory>
1059+
<currentMemory unit="MiB">400</currentMemory>
1060+
<vcpu placement="static">2</vcpu>
1061+
<cpu mode='host-passthrough'>
1062+
<!-- disable nested HVM -->
1063+
<feature name='vmx' policy='disable'/>
1064+
<feature name='svm' policy='disable'/>
1065+
<!-- let the guest know the TSC is safe to use (no migration) -->
1066+
<feature name='invtsc' policy='require'/>
1067+
</cpu>
1068+
<os>
1069+
<type arch="x86_64" machine="xenfv">hvm</type>
1070+
<!--
1071+
For the libxl backend libvirt switches between OVMF (UEFI)
1072+
and SeaBIOS based on the loader type. This has nothing to
1073+
do with the hvmloader binary.
1074+
-->
1075+
<loader type="rom">hvmloader</loader>
1076+
<boot dev="cdrom" />
1077+
<boot dev="hd" />
1078+
</os>
1079+
<features>
1080+
<pae/>
1081+
<acpi/>
1082+
<apic/>
1083+
<viridian/>
1084+
</features>
1085+
<clock offset="variable" adjustment="0" basis="utc" />
1086+
<on_poweroff>destroy</on_poweroff>
1087+
<on_reboot>destroy</on_reboot>
1088+
<on_crash>destroy</on_crash>
1089+
<devices>
1090+
<!-- server_ip is the address of stubdomain. It hosts it's own DNS server. -->
1091+
<emulator type="stubdom-linux" cmdline="-qubes-audio:audiovm_xid=-1"/>
1092+
<input type="tablet" bus="usb"/>
1093+
<video>
1094+
<model type="vga"/>
1095+
</video>
1096+
<graphics type="qubes"
1097+
domain="test-inst-guivm"
1098+
log_level="2"
1099+
/>
1100+
<console type="pty">
1101+
<target type="xen" port="0"/>
1102+
</console>
1103+
</devices>
1104+
</domain>
1105+
"""
1106+
guivm = self.get_vm(name="guivm")
1107+
p = unittest.mock.patch.object(guivm, "is_running", lambda: True)
1108+
p.start()
1109+
self.addCleanup(p.stop)
1110+
vm = self.get_vm(uuid=my_uuid)
1111+
vm.netvm = None
1112+
vm.virt_mode = "hvm"
1113+
vm.guivm = guivm
1114+
vm.debug = True
1115+
libvirt_xml = vm.create_config_file()
1116+
self.assertXMLEqual(
1117+
lxml.etree.XML(libvirt_xml), lxml.etree.XML(expected)
1118+
)
1119+
10531120
def test_600_libvirt_xml_hvm_dom0_kernel(self):
10541121
my_uuid = "7db78950-c467-4863-94d1-af59806384ea"
10551122
expected = f"""<domain type="xen">

templates/libvirt/xen.xml

+9-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,15 @@
224224
</video>
225225
{% if vm.features.check_with_template('linux-stubdom', True) %}
226226
{# TODO only add qubes gui if gui-agent is not installed in HVM #}
227-
<graphics type="qubes"/>
227+
<graphics type="qubes"
228+
{% if vm.guivm and vm.guivm.is_running()
229+
and vm.guivm.name != "dom0" -%}
230+
domain="{{vm.guivm.name}}"
231+
{% endif -%}
232+
{% if vm.debug -%}
233+
log_level="2"
234+
{% endif -%}
235+
/>
228236
{% endif %}
229237
{% endif %}
230238
{% endif %}

0 commit comments

Comments
 (0)