Bug 855211 - index of SCSI controller is not decremented after hot-plug scsi-hd device again
index of SCSI controller is not decremented after hot-plug scsi-hd device again
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm (Show other bugs)
6.4
x86_64 Linux
medium Severity medium
: rc
: ---
Assigned To: Virtualization Maintenance
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-09-06 21:53 EDT by Sibiao Luo
Modified: 2012-09-10 06:54 EDT (History)
13 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-09-10 04:33:50 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Sibiao Luo 2012-09-06 21:53:29 EDT
Description of problem:
boot a guest with scsi disk interface, and hot-plug a scsi-hd data disk to guest, and then hot-remove it, then hot-add it again, verify the index for SCSI controller of two times of hot-plug data disk, the index of SCSI controller was not decremented after hot-plug scsi-hd device again. btw, if reboot the guest, the number of the SCSI controller can drop back into the old SCSI controller correctly.

Version-Release number of selected component (if applicable):
host info:
# uname -r && rpm -q qemu-kvm
2.6.32-303.el6.x86_64
qemu-kvm-0.12.1.2-2.311.el6.x86_64
guest info:
# uname -r
2.6.32-303.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1.boot a guest.
eg: # /usr/libexec/qemu-kvm -M rhel6.4.0 -cpu SandyBridge -enable-kvm -m 2048 -smp 2,sockets=2,cores=1,threads=1 -usb -device usb-tablet,id=input0 -name virtio-scsi-pci -uuid `uuidgen` -device virtio-scsi-pci,bus=pci.0,addr=0x3,id=scsi0 -drive file=/home/RHEL-Server-6.3-64-sluo.qcow2,format=qcow2,if=none,id=drive-disk,cache=none,werror=stop,rerror=stop,aio=native -device scsi-hd,drive=drive-disk,bus=scsi0.0,scsi-id=0,lun=0,bootindex=1 -netdev tap,id=hostnet0,script=/etc/qemu-ifup -device virtio-net-pci,netdev=hostnet0,id=virtio-net-pci0,mac=98:3B:CB:2E:90:A8,bus=pci.0,addr=0x4 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 -serial unix:/tmp/ttyS1,server,nowait -vnc :2 -bios /usr/share/seabios/bios-pm.bin -qmp tcp:0:5555,server,nowait -boot menu=on -monitor stdio
2.hot-plug a scsi-hd data disk, rescan the SCSI bus and check it in guest.
(qemu) device_add virtio-scsi-pci,bus=pci.0,addr=0x6,id=scsi1
(qemu)  __com.redhat_drive_add file=/mnt/my-data-disk.qcow2,format=qcow2,id=sluo-disk,cache=none,werror=stop,rerror=stop,aio=native
(qemu) device_add  scsi-hd,drive=sluo-disk,bus=scsi1.0,scsi-id=1,lun=1,id=sluo
guest]# echo "- - -" > /sys/class/scsi_host/host3/scan
guest]# ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sdb
guest]# ls /sys/class/scsi_host/
host0  host1  host2  host3  <-----current SCSI controller is 'host3'
3.hot-remove the data disk and check it.
(qemu) device_del sluo
(qemu) device_del scsi1
guest]# ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2
guest]# ls /sys/class/scsi_host/
host0  host1  host2
4.hot-plug the scsi-hd data disk again and rescan it as step 2.
(qemu) device_add virtio-scsi-pci,bus=pci.0,addr=0x6,id=scsi1
(qemu) __com.redhat_drive_add file=/mnt/my-data-disk.qcow2,format=qcow2,id=sluo-disk,cache=none,werror=stop,rerror=stop,aio=native
(qemu) device_add  scsi-hd,drive=sluo-disk,bus=scsi1.0,scsi-id=1,lun=1,id=sluo

Actual results:
after the step 4, the index of SCSI controller is not decremented after hot-plug scsi-hd device again.
guest]# echo "- - -" > /sys/class/scsi_host/host4/scan 
guest]# ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sda2  /dev/sdb
guest]# ls /sys/class/scsi_host/
host0  host1  host2  host4  <-----it should be 'host3'

Expected results:
the index of SCSI controller can be decremented after hot-plug scsi-hd device again, hot-plug the SCSI data disk again should be in the current SCSI controller ('host3'), not in a new one ('host4').

Additional info:
Comment 2 Paolo Bonzini 2012-09-10 04:33:50 EDT
Not a bug, this is just how hosts are numbered in Linux.

Note that you do not need to delete and readd the virtio-scsi-pci device, only the scsi-hd device.  If you do so, the scsi-hd device will reside on host3.
Comment 3 Sibiao Luo 2012-09-10 06:54:04 EDT
(In reply to comment #2)
> Not a bug, this is just how hosts are numbered in Linux.
> 
> Note that you do not need to delete and readd the virtio-scsi-pci device,
> only the scsi-hd device. If you do so, the scsi-hd device will reside on
> host3.

yes, i test it as your indication. if do not delete the virtio-scsi-pci controller, noly remove the scsi-hd device, the index of the SCSI controller and partition table for the disk can be sequential.

But why cann't delete the virtio-scsi-pci controller? if hot-remove SCSI controller, then hot-add it again, the index of SCSI controller was not decremented after hot-plug it again, while the partition table can decrement to the right number. 

Paolo, could you help explain it here & thx.

Best Regards.
sluo

Note You need to log in before you can comment on or make changes to this bug.