libvirt/tests/libxlxml2domconfigdata/moredevs-hvm.xml
Laine Stump 9363c1cb69 xen: explicitly set hostdev driver.name at runtime, not in postparse
Xen only supports a single type of PCI hostdev assignment, so it is
superfluous to have <driver name='xen'/> peppered throughout the
config. It *is* necessary to have the driver type explicitly set in
the hostdev object before calling into the hypervisor-agnostic "hostdev
manager" though (otherwise the hostdev manager doesn't know whether it
should do Xen-specific setup, or VFIO-specific setup).

Historically, the Xen driver has checked for "default" driver name
(i.e. not set in the XML), and set it to "xen', during the XML
postparse, thus guaranteeing that it will be set by the time the
object is sent to the hostdev manager at runtime, but also setting it
so early that a simple round-trip of parse-format results in the XML
always containing an explicit <driver name='xen'/>, even if that
wasn't specified in the original XML.

The QEMU driver *doesn't* set driver.name during postparse though;
instead, it waits until domain startup time (or device attach time for
hotplug), and sets the driver.name then. The result is that a
parse-format round trip of the XML in the QEMU driver *doesn't* add in
the <driver name='vfio'/>.

This patch modifies the Xen driver to behave similarly to the QEMU
driver - the PostParse just checks for a driver.name that isn't
supported by the Xen driver, and any explicit setting to "xen" is
deferred until domain runtime rather than during the postparse, thus
Xen domain XML also doesn't get extraneous <driver name='xen'/>.

This delayed setting of driver.name of course results in slightly
different xml2xml parse-format results, so the unit test data is
modified accordingly.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2024-01-07 23:59:00 -05:00

68 lines
2.0 KiB
XML

<domain type='xen'>
<name>test-hvm</name>
<description>None</description>
<uuid>2147d599-9cc6-c0dc-92ab-4064b5446e9b</uuid>
<memory>1048576</memory>
<currentMemory>1048576</currentMemory>
<vcpu>4</vcpu>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<clock offset='variable' adjustment='0' basis='utc'>
<timer name='tsc' present='yes' mode='native'/>
<timer name='hpet' present='yes'/>
</clock>
<os>
<type>hvm</type>
<loader>/usr/lib/xen/boot/hvmloader</loader>
<boot dev='hd'/>
</os>
<features>
<apic/>
<acpi/>
<pae/>
<hap/>
</features>
<devices>
<emulator>/bin/true</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='raw' cache='default'/>
<source file='/var/lib/xen/images/test-hvm.img'/>
<target dev='hda'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw' cache='default'/>
<source file='/root/boot.iso'/>
<target dev='hdb'/>
</disk>
<interface type='bridge'>
<source bridge='br0'/>
<mac address='00:16:3e:7a:35:ce'/>
<script path='/etc/xen/scripts/vif-bridge'/>
<model type='netfront'/>
</interface>
<interface type='hostdev' managed='yes'>
<mac address='00:16:3e:2e:e7:fc'/>
<source>
<address type='pci' domain='0x0000' bus='0x0a' slot='0x10' function='0x0'/>
</source>
</interface>
<hostdev mode='subsystem' type='pci' managed='yes'>
<source writeFiltering='no'>
<address domain='0x0000' bus='0x0a' slot='0x08' function='0x0'/>
</source>
</hostdev>
<graphics type='vnc'/>
<video>
<model type='cirrus' vram='8192' heads='1' primary='yes'/>
</video>
<console type='pty'>
<target port='0'/>
</console>
<input type='mouse' bus='usb'/>
<input type='tablet' bus='usb'/>
<input type='mouse' bus='ps2'/>
<input type='keyboard' bus='ps2'/>
</devices>
</domain>