如何修复来宾虚拟机中的设备名称顺序(virsh 重新启动虚拟机后设备名称顺序发生了变化)

如何修复来宾虚拟机中的设备名称顺序(virsh 重新启动虚拟机后设备名称顺序发生了变化)

我的设备 xml 定义:

第一个虚拟机只有一个根卷,

<disk type='file' device='disk' snapshot='external'>
  <driver name='qemu' type='qcow2' cache='none'/>
  <source file='/dev/967b07c5ca8f429b9647785e942cbb4b/70395cacf62e49ec95246a919d449f64'/>
  <backingStore type='block' index='1'>
    <format type='qcow2'/>
    <source dev='/dev/967b07c5ca8f429b9647785e942cbb4b/ce7774f0634a4d098a8d4e37838f4b6f'/>
    <backingStore/>
  </backingStore>
  <target dev='vda' bus='virtio'/>
  <boot order='1'/>
  <alias name='virtio-disk0'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
</disk>

然后我在scsi上热插拔两个磁盘。

<disk type='file' device='disk' snapshot='external'>
  <driver name='qemu' type='qcow2' cache='none'/>
  <source file='/dev/967b07c5ca8f429b9647785e942cbb4b/6d38ee3091f64ca2bcb47b9dbd3c5901'/>
  <backingStore/>
  <target dev='sdb' bus='scsi'/>
  <wwn>0x000fefc4071262fb</wwn>
  <alias name='scsi0-0-0-1'/>
  <address type='drive' controller='0' bus='0' target='0' unit='1'/>
</disk>
<disk type='file' device='disk' snapshot='external'>
  <driver name='qemu' type='qcow2' cache='none'/>
  <source file='/dev/967b07c5ca8f429b9647785e942cbb4b/b1dcd7497e544284aba954b52ffc4754'/>
  <backingStore/>
  <target dev='sdd' bus='scsi'/>
  <wwn>0x000f0683ab0ad875</wwn>
  <alias name='scsi0-0-0-2'/>
  <address type='drive' controller='0' bus='0' target='0' unit='2'/>
</disk>

来宾虚拟机中的设备名称顺序与插头顺序匹配:按磁盘大小分隔。

Disk /dev/sda: 6 MB, 6291456 bytes
1 heads, 12 sectors/track, 1024 cylinders
Units = cylinders of 12 * 512 = 6144 bytes
.
Disk /dev/sdb: 7 MB, 7340032 bytes
1 heads, 14 sectors/track, 1024 cylinders
Units = cylinders of 14 * 512 = 7168 bytes

但是通过 virsh 重新启动虚拟机后,磁盘名称顺序会颠倒。 xml 定义未更改。如何修复设备名称排序?

相关内容