Hide Forgot
Description of problem: Creating a RHEL6.8 guest with scsi disk as sdb by virsh command on xen host, check the disks by fdisk or df, you will find the scsi disk is recognized as /dev/sda and the defined sda disk in xml file is recognized as /dev/sdb. If there are several scsi disks, the scsi disks always use the front devices, the front ide disks defined in the xml file use the left devices. Version-Release number of selected component (if applicable): Host Fedora23 with: kernel-4.4.5-300.fc23.x86_64 xen-4.5.2-9.fc23.x86_64 libvirt-1.2.18.2-2.fc23.x86_64 Guest RHEL6.8 with: kernel-2.6.32-627.el6.x86_64 How reproducible: Always Steps to Reproduce: 1. Create a RHEL6.8 hvm guest on Fedora23 Xen, with virsh command and the xml configure file including below lines: <devices> <emulator>/usr/lib64/xen/bin/qemu-dm</emulator> <disk type='file' device='disk'> <source file='/root/RHEL-Server-6.8-64-hvm.raw'/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> <disk type='file' device='disk'> <source file='/root/test.img'/> <target dev='sdb' bus='scsi'/> </disk> 2. Login to guest and make sure there is parameter "xen_emul_unplug=never" in kernel line, if not, add this parameter and reboot guest. 3. Check guest disks by ls /dev/sd* and df. Actual results: The /dev/sda (system) disk displays as /dev/sdb and scsi disk /dev/sdb displays as /dev/sda, and no error message in boot log. [root@dhcp-8-181 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 6.5G 1.6G 4.7G 25% / tmpfs 478M 0 478M 0% /dev/shm /dev/sdb1 477M 34M 418M 8% /boot [root@dhcp-8-181 ~]# ls /dev/sd* /dev/sda /dev/sda1 /dev/sdb /dev/sdb1 /dev/sdb2 Expected results: The disks should display as the sort as defined in xml file. Additional info: 1. Can not boot up a guest with the SCSI disk as the first disk, so only add the SCSI disks from the second disks. 2. Test with RHEL6.7 guest, the disks display as normal. 3. Test with xl command and xl config file, the disks display as normal. 4. Test with RHEL6.8 guest on RHEL5.11 xen host both with xm and virsh command, the disks display as normal. 5. If the kernel parameter includes "xen_emul_unplug=unnecessary", there is an error message when booting: Setting up Logical Volume Management: Found duplicate PV giPSwb08c4OzbGWp8EtEcOz0nb1hwQ0y: using /dev/xvda2 not /dev/sdb2 Using duplicate PV /dev/xvda2 without holders, ignoring /dev/sdb2 And the scsi disk uses /dev/sda device, RHEL6.7 and RHEL6.8 guests both act as this, and this behavior is normal. 6. a. Create a RHEL6.8 hvm guest on Fedora23 Xen, with virsh command and the xml configure file including below lines: <devices> <emulator>/usr/lib64/xen/bin/qemu-dm</emulator> <disk type='file' device='disk'> <source file='/root/RHEL-Server-6.8-64-hvm.raw'/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> <disk type='file' device='disk'> <source file='/root/test.img'/> <target dev='sdb' bus='scsi'/> </disk> <disk type='file' device='disk'> <source file='/root/test1.img'/> <target dev='sdc' bus='scsi'/> </disk> The first (system) disk is recognized as /dev/sdc. [root@dhcp-8-181 ~]# ls /dev/sd* /dev/sda /dev/sda1 /dev/sdb /dev/sdc /dev/sdc1 /dev/sdc2 [root@dhcp-8-181 ~]# ls /dev/xvd* ls: cannot access /dev/xvd*: No such file or directory [root@dhcp-8-181 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 6.5G 1.6G 4.7G 25% / tmpfs 478M 0 478M 0% /dev/shm /dev/sdc1 477M 34M 418M 8% /boot b. Change the second device from sdb-scsi to hdb-ide, then the last scsi disk will use /dev/sda, and the first (system) disk is recognized as /dev/sdb: [root@dhcp-8-181 ~]# ls /dev/sd* /dev/sda /dev/sdb /dev/sdb1 /dev/sdb2 /dev/sdc /dev/sdc1 [root@dhcp-8-181 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 6.5G 1.6G 4.7G 25% / tmpfs 478M 0 478M 0% /dev/shm /dev/sdb1 477M 34M 418M 8% /boot
The libvirt target=sdb value is _not_ actually going to map to the guest /dev name. The XML target value is just to describe the relative ordering in which the disks are attached to the VM. Yes this is confusing but it was a historical libvirt mistake that we are stuck with at this point. Basically the guest /dev/sd* will generally be allocated sequentially by the order of the relevant disks in the XML. So since you only have one scsi disk in your XML, you could have target=sdz but it will still show up in the guest as /dev/sda Closing as NOTABUG but please reopen if I've misunderstood