Bug 855211

Summary: index of SCSI controller is not decremented after hot-plug scsi-hd device again
Product: Red Hat Enterprise Linux 6 Reporter: Sibiao Luo <sluo>
Component: qemu-kvmAssignee: Virtualization Maintenance <virt-maint>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.4CC: acathrow, bsarathy, chayang, dyasny, flang, juzhang, michen, mkenneth, pbonzini, qzhang, sluo, virt-maint, wdai
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-09-10 08:33:50 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Sibiao Luo 2012-09-07 01:53:29 UTC
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 08:33:50 UTC
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 10:54:04 UTC
(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