2

my devices xml define:

first vm only has a root volume,

<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>

then I hot plug two disks on 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>

the device name order in guest vm match the plug order: separate by disk size.

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

But after reboot vm by virsh, the disk name ordering is reversed. xml define is not changed. how can I fix the devices name ordering?

  • That's a FAQ: You can't "order" devices, names will be assigned in whatever order the kernel initializes them. Use the symlinks in /dev/disk/... instead of /dev/sda etc. for names that do not change. Or write your own udev rules, if the available symlinks don't match your taste. – dirkt Dec 13 '18 at 9:47
  • udev should work, but I hope fix it without operation in guest vm. I has found that the device order is associated with address controller, unit and target dev name in xml. But it is hack and instable. So I am looking for a simple and direct way – MaximJ Dec 14 '18 at 8:56
  • So which of the pre-existing symlinks in /dev/disk/... don't work for you, and why? And no, there's no way you can "force" the device order for the Linux kernel. It all depends on the timing of the Linux kernel in the VM. As you found out, your attempts are "instable". (Why do people always think they need to force the order? You are not the first one.) – dirkt Dec 14 '18 at 9:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.