Add aliases for devices (#1374)

It is more reliable to identify disk and network devices by use of
aliases, in addition to being able to establish in the absence of
information the purpose of such devices.

There is a possibility that in some cases this will also resolve issues
where the same device attach issued twice with the same details will
fail due to the second request not appearing to be honoured.

Additionally when destroying domains, may not have the relevant details
on how many disks are provided by the box, for those that support
multiple disks. Being able to traverse the domain XML and destroy the
appropriate volumes based on aliases names will remove the need to have
predictable device identifiers during the destroy and allow for an
improved resolver.

Relates: #1342
This commit is contained in:
Darragh Bailey
2021-10-08 18:00:01 +01:00
committed by GitHub
parent 56282b965c
commit b3e445a8b0
6 changed files with 13 additions and 2 deletions

View File

@@ -27,11 +27,13 @@
</clock>
<devices>
<disk type='file' device='disk'>
<alias name='ua-box-volume-0'/>
<driver name='qemu' type='qcow2' cache='default'/>
<source file='/var/lib/libvirt/images/vagrant-test_default.img'/>
<target dev='vda' bus='virtio'/>
</disk>
<disk type='file' device='disk'>
<alias name='ua-disk-volume-0'/>
<driver name='qemu' type='qcow2' cache='default'/>
<source file='/var/lib/libvirt/images/vagrant-test_default-vdb.qcow2'/>
<target dev='vdb' bus='virtio'/>

View File

@@ -27,6 +27,7 @@
</clock>
<devices>
<disk type='file' device='disk'>
<alias name='ua-box-volume-0'/>
<driver name='qemu' type='qcow2' cache='default'/>
<source file='/var/lib/libvirt/images/vagrant-test_default.img'/>
<target dev='vda' bus='virtio'/>

View File

@@ -44,21 +44,25 @@
<devices>
<emulator>/usr/bin/kvm-spice</emulator>
<disk type='file' device='disk'>
<alias name='ua-box-volume-0'/>
<driver name='qemu' type='qcow2' cache='unsafe' io='threads' copy_on_read='on' discard='unmap' detect_zeroes='on'/>
<source file='/var/lib/libvirt/images/test.qcow2'/>
<target dev='vda' bus='ide'/>
</disk>
<disk type='file' device='disk'>
<alias name='ua-box-volume-1'/>
<driver name='qemu' type='qcow2' cache='unsafe' io='threads' copy_on_read='on' discard='unmap' detect_zeroes='on'/>
<source file='/var/lib/libvirt/images/test2.qcow2'/>
<target dev='vdb' bus='ide'/>
</disk>
<disk type='file' device='disk'>
<alias name='ua-disk-volume-0'/>
<driver name='qemu' type='qcow2' cache='default'/>
<source file='/var/lib/libvirt/images/test-disk1.qcow2'/>
<target dev='vdb' bus='virtio'/>
</disk>
<disk type='file' device='disk'>
<alias name='ua-disk-volume-1'/>
<driver name='qemu' type='qcow2' cache='default' io='threads' copy_on_read='on' discard='unmap' detect_zeroes='on'/>
<source file='/var/lib/libvirt/images/test-disk2.qcow2'/>
<target dev='vdc' bus='virtio'/>