Skip to content

Commit 5a752a8

Browse files
committed
New feature to add custom qemu arguments
Implement qemu-extra-args feature that allows adding extra qemu options. This is useful mostly for debugging.
1 parent 38658eb commit 5a752a8

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

qubes/tests/vm/qubesvm.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,6 +1172,68 @@ def test_600_libvirt_xml_hvm_with_guivm(self):
11721172
lxml.etree.XML(libvirt_xml), lxml.etree.XML(expected)
11731173
)
11741174

1175+
def test_600_libvirt_xml_hvm_with_qemu_args(self):
1176+
my_uuid = "7db78950-c467-4863-94d1-af59806384ea"
1177+
expected = """<domain type="xen">
1178+
<name>test-inst-test</name>
1179+
<uuid>7db78950-c467-4863-94d1-af59806384ea</uuid>
1180+
<memory unit="MiB">400</memory>
1181+
<currentMemory unit="MiB">400</currentMemory>
1182+
<vcpu placement="static">2</vcpu>
1183+
<cpu mode='host-passthrough'>
1184+
<!-- disable nested HVM -->
1185+
<feature name='vmx' policy='disable'/>
1186+
<feature name='svm' policy='disable'/>
1187+
<!-- let the guest know the TSC is safe to use (no migration) -->
1188+
<feature name='invtsc' policy='require'/>
1189+
</cpu>
1190+
<os>
1191+
<type arch="x86_64" machine="xenfv">hvm</type>
1192+
<!--
1193+
For the libxl backend libvirt switches between OVMF (UEFI)
1194+
and SeaBIOS based on the loader type. This has nothing to
1195+
do with the hvmloader binary.
1196+
-->
1197+
<loader type="rom">hvmloader</loader>
1198+
<boot dev="cdrom" />
1199+
<boot dev="hd" />
1200+
</os>
1201+
<features>
1202+
<pae/>
1203+
<acpi/>
1204+
<apic/>
1205+
<viridian/>
1206+
</features>
1207+
<clock offset="variable" adjustment="0" basis="utc" />
1208+
<on_poweroff>destroy</on_poweroff>
1209+
<on_reboot>destroy</on_reboot>
1210+
<on_crash>destroy</on_crash>
1211+
<devices>
1212+
<!-- server_ip is the address of stubdomain. It hosts it's own DNS server. -->
1213+
<emulator type="stubdom-linux" cmdline="-qubes-audio:audiovm_xid=-1 -some-option"/>
1214+
<input type="tablet" bus="usb"/>
1215+
<video>
1216+
<model type="vga"/>
1217+
</video>
1218+
<graphics type="qubes"
1219+
log_level="2"
1220+
/>
1221+
<console type="pty">
1222+
<target type="xen" port="0"/>
1223+
</console>
1224+
</devices>
1225+
</domain>
1226+
"""
1227+
vm = self.get_vm(uuid=my_uuid)
1228+
vm.netvm = None
1229+
vm.virt_mode = "hvm"
1230+
vm.debug = True
1231+
vm.features['qemu-extra-args'] = '-some-option'
1232+
libvirt_xml = vm.create_config_file()
1233+
self.assertXMLEqual(
1234+
lxml.etree.XML(libvirt_xml), lxml.etree.XML(expected)
1235+
)
1236+
11751237
def test_600_libvirt_xml_hvm_dom0_kernel(self):
11761238
my_uuid = "7db78950-c467-4863-94d1-af59806384ea"
11771239
expected = f"""<domain type="xen">

templates/libvirt/xen.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@
183183
{% if vm.virt_mode == 'hvm' %}
184184
<!-- server_ip is the address of stubdomain. It hosts it's own DNS server. -->
185185
{% set qemu_opts_common = "-qubes-audio:audiovm_xid=" ~
186-
audiovm_xid -%}
186+
audiovm_xid ~ " " ~
187+
vm.features.check_with_template('qemu-extra-args', '') -%}
188+
{% set qemu_opts_common = qemu_opts_common | trim -%}
187189
<emulator
188190
{% if vm.features.check_with_template('linux-stubdom', True) %}
189191
type="stubdom-linux"

0 commit comments

Comments
 (0)