Skip to content

Commit 136045a

Browse files
committed
Merge remote-tracking branch 'origin/pr/701'
* origin/pr/701: Add "network" block in default libvirt config template Enable Windows PV drivers logging when debug is set to True New feature to add custom qemu arguments Extract common qemu options to a variable Related to QubesOS/qubes-issues#9976
2 parents 9d27f7f + c531bb1 commit 136045a

File tree

2 files changed

+79
-7
lines changed

2 files changed

+79
-7
lines changed

qubes/tests/vm/qubesvm.py

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,8 @@ def test_600_libvirt_xml_hvm_with_guivm(self):
11431143
<on_crash>destroy</on_crash>
11441144
<devices>
11451145
<!-- server_ip is the address of stubdomain. It hosts it's own DNS server. -->
1146-
<emulator type="stubdom-linux" cmdline="-qubes-audio:audiovm_xid=-1"/>
1146+
<emulator type="stubdom-linux"
1147+
cmdline="-qubes-audio:audiovm_xid=-1 -trace xen_platform_log"/>
11471148
<input type="tablet" bus="usb"/>
11481149
<video>
11491150
<model type="vga"/>
@@ -1172,6 +1173,69 @@ def test_600_libvirt_xml_hvm_with_guivm(self):
11721173
lxml.etree.XML(libvirt_xml), lxml.etree.XML(expected)
11731174
)
11741175

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

templates/libvirt/xen.xml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,11 @@
167167
{% endfor %}
168168
{% endfor %}
169169
170-
{% if vm.netvm %}
171-
{% include 'libvirt/devices/net.xml' with context %}
172-
{% endif %}
170+
{% block network %}
171+
{% if vm.netvm %}
172+
{% include 'libvirt/devices/net.xml' with context %}
173+
{% endif %}
174+
{% endblock %}
173175
174176
{% for assignment in vm.devices.pci.get_assigned_devices(True) %}
175177
{% for device in assignment.devices %}
@@ -182,6 +184,12 @@
182184
183185
{% if vm.virt_mode == 'hvm' %}
184186
<!-- server_ip is the address of stubdomain. It hosts it's own DNS server. -->
187+
{% set qemu_opts_common = "-qubes-audio:audiovm_xid=" ~
188+
audiovm_xid ~ " " ~
189+
vm.features.check_with_template('qemu-extra-args', '') -%}
190+
{% set qemu_opts_common = qemu_opts_common | trim -%}
191+
{% set qemu_opts_common = qemu_opts_common ~
192+
(" -trace xen_platform_log" if vm.debug else "") -%}
185193
<emulator
186194
{% if vm.features.check_with_template('linux-stubdom', True) %}
187195
type="stubdom-linux"
@@ -190,20 +198,20 @@
190198
{% endif %}
191199
{% if vm.netvm %}
192200
{% if vm.features.check_with_template('linux-stubdom', True) %}
193-
cmdline="-qubes-audio:audiovm_xid={{ audiovm_xid }} -qubes-net:client_ip={{ vm.ip -}}
201+
cmdline="{{ qemu_opts_common }} -qubes-net:client_ip={{ vm.ip -}}
194202
,dns_0={{ vm.dns[0] -}}
195203
,dns_1={{ vm.dns[1] -}}
196204
,gw={{ vm.netvm.gateway -}}
197205
,netmask={{ vm.netmask }}"
198206
{% else %}
199-
cmdline="-qubes-audio:audiovm_xid={{ audiovm_xid }} -net lwip,client_ip={{ vm.ip -}}
207+
cmdline="{{ qemu_opts_common }} -net lwip,client_ip={{ vm.ip -}}
200208
,server_ip={{ vm.dns[1] -}}
201209
,dns={{ vm.dns[0] -}}
202210
,gw={{ vm.netvm.gateway -}}
203211
,netmask={{ vm.netmask }}"
204212
{% endif %}
205213
{% else %}
206-
cmdline="-qubes-audio:audiovm_xid={{ audiovm_xid }}"
214+
cmdline="{{ qemu_opts_common }}"
207215
{% endif %}
208216
{% if vm.stubdom_mem %}
209217
memory="{{ vm.stubdom_mem * 1024 -}}"

0 commit comments

Comments
 (0)