Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 65 additions & 1 deletion qubes/tests/vm/qubesvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,8 @@ def test_600_libvirt_xml_hvm_with_guivm(self):
<on_crash>destroy</on_crash>
<devices>
<!-- server_ip is the address of stubdomain. It hosts it's own DNS server. -->
<emulator type="stubdom-linux" cmdline="-qubes-audio:audiovm_xid=-1"/>
<emulator type="stubdom-linux"
cmdline="-qubes-audio:audiovm_xid=-1 -trace xen_platform_log"/>
<input type="tablet" bus="usb"/>
<video>
<model type="vga"/>
Expand Down Expand Up @@ -1172,6 +1173,69 @@ def test_600_libvirt_xml_hvm_with_guivm(self):
lxml.etree.XML(libvirt_xml), lxml.etree.XML(expected)
)

def test_600_libvirt_xml_hvm_with_qemu_args(self):
my_uuid = "7db78950-c467-4863-94d1-af59806384ea"
expected = """<domain type="xen">
<name>test-inst-test</name>
<uuid>7db78950-c467-4863-94d1-af59806384ea</uuid>
<memory unit="MiB">400</memory>
<currentMemory unit="MiB">400</currentMemory>
<vcpu placement="static">2</vcpu>
<cpu mode='host-passthrough'>
<!-- disable nested HVM -->
<feature name='vmx' policy='disable'/>
<feature name='svm' policy='disable'/>
<!-- let the guest know the TSC is safe to use (no migration) -->
<feature name='invtsc' policy='require'/>
</cpu>
<os>
<type arch="x86_64" machine="xenfv">hvm</type>
<!--
For the libxl backend libvirt switches between OVMF (UEFI)
and SeaBIOS based on the loader type. This has nothing to
do with the hvmloader binary.
-->
<loader type="rom">hvmloader</loader>
<boot dev="cdrom" />
<boot dev="hd" />
</os>
<features>
<pae/>
<acpi/>
<apic/>
<viridian/>
</features>
<clock offset="variable" adjustment="0" basis="utc" />
<on_poweroff>destroy</on_poweroff>
<on_reboot>destroy</on_reboot>
<on_crash>destroy</on_crash>
<devices>
<!-- server_ip is the address of stubdomain. It hosts it's own DNS server. -->
<emulator type="stubdom-linux"
cmdline="-qubes-audio:audiovm_xid=-1 -some-option -trace xen_platform_log"/>
<input type="tablet" bus="usb"/>
<video>
<model type="vga"/>
</video>
<graphics type="qubes"
log_level="2"
/>
<console type="pty">
<target type="xen" port="0"/>
</console>
</devices>
</domain>
"""
vm = self.get_vm(uuid=my_uuid)
vm.netvm = None
vm.virt_mode = "hvm"
vm.debug = True
vm.features['qemu-extra-args'] = '-some-option'
libvirt_xml = vm.create_config_file()
self.assertXMLEqual(
lxml.etree.XML(libvirt_xml), lxml.etree.XML(expected)
)

def test_600_libvirt_xml_hvm_dom0_kernel(self):
my_uuid = "7db78950-c467-4863-94d1-af59806384ea"
expected = f"""<domain type="xen">
Expand Down
20 changes: 14 additions & 6 deletions templates/libvirt/xen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,11 @@
{% endfor %}
{% endfor %}

{% if vm.netvm %}
{% include 'libvirt/devices/net.xml' with context %}
{% endif %}
{% block network %}
{% if vm.netvm %}
{% include 'libvirt/devices/net.xml' with context %}
{% endif %}
{% endblock %}

{% for assignment in vm.devices.pci.get_assigned_devices(True) %}
{% for device in assignment.devices %}
Expand All @@ -182,6 +184,12 @@

{% if vm.virt_mode == 'hvm' %}
<!-- server_ip is the address of stubdomain. It hosts it's own DNS server. -->
{% set qemu_opts_common = "-qubes-audio:audiovm_xid=" ~
audiovm_xid ~ " " ~
vm.features.check_with_template('qemu-extra-args', '') -%}
{% set qemu_opts_common = qemu_opts_common | trim -%}
{% set qemu_opts_common = qemu_opts_common ~
(" -trace xen_platform_log" if vm.debug else "") -%}
<emulator
{% if vm.features.check_with_template('linux-stubdom', True) %}
type="stubdom-linux"
Expand All @@ -190,20 +198,20 @@
{% endif %}
{% if vm.netvm %}
{% if vm.features.check_with_template('linux-stubdom', True) %}
cmdline="-qubes-audio:audiovm_xid={{ audiovm_xid }} -qubes-net:client_ip={{ vm.ip -}}
cmdline="{{ qemu_opts_common }} -qubes-net:client_ip={{ vm.ip -}}
,dns_0={{ vm.dns[0] -}}
,dns_1={{ vm.dns[1] -}}
,gw={{ vm.netvm.gateway -}}
,netmask={{ vm.netmask }}"
{% else %}
cmdline="-qubes-audio:audiovm_xid={{ audiovm_xid }} -net lwip,client_ip={{ vm.ip -}}
cmdline="{{ qemu_opts_common }} -net lwip,client_ip={{ vm.ip -}}
,server_ip={{ vm.dns[1] -}}
,dns={{ vm.dns[0] -}}
,gw={{ vm.netvm.gateway -}}
,netmask={{ vm.netmask }}"
{% endif %}
{% else %}
cmdline="-qubes-audio:audiovm_xid={{ audiovm_xid }}"
cmdline="{{ qemu_opts_common }}"
{% endif %}
{% if vm.stubdom_mem %}
memory="{{ vm.stubdom_mem * 1024 -}}"
Expand Down