Bug 947411

Summary: fail to specify the serial number for usb storage device
Product: Red Hat Enterprise Linux 7 Reporter: Sibiao Luo <sluo>
Component: qemu-kvmAssignee: Kevin Wolf <kwolf>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: high    
Version: 7.0CC: acathrow, chayang, hhuang, juzhang, kraxel, kwolf, michen, mrezanin, qzhang, shuang, stefanha, virt-maint, xfu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-1.5.0-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 947416 (view as bug list) Environment:
Last Closed: 2014-06-13 11:58:16 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:
Bug Depends On:    
Bug Blocks: 947416    

Description Sibiao Luo 2013-04-02 11:05:48 UTC
Description of problem:
boot a pre-installed vm and with a serial number specified usb storage, but fail to specify the serial number for usb storage correctly with '-drive .... -device usb-storage...serial=xxxx'.
I tried two ways (e.g: -drive...serial=xxxx -device usb-storage....; -drive .... -device usb-storage...serial=xxxx) to specify it, just the latter method have problem.

Version-Release number of selected component (if applicable):
host info:
kernel-3.9.0-0.rc4.45.el7.x86_64
qemu-kvm-1.4.0-1.el7.x86_64
seabios-1.7.2-0.2.gita810e4e7.el7.x86_64
guest info:
kernel-3.9.0-0.rc4.45.el7.x86_64

How reproducible:
100%

Steps to Reproduce:
1.boot a pre-installed vm and with a serial number specified two usb storages with two methods.
usb-storage1 -----> serial number: sluo-1
usb-storage2 -----> serial number: sluo-2
2.check the qtree info via HMP monitor.
(qemu) info qtree
3.check the serial number info in guest.
# scsi_id --whitelist /dev/<dev>
  
Actual results:
after step 2, the serial for "usb-storage1" display correctly, but not correctly for "usb-storage2"
(qemu) info qtree
...
        bus: ehci.0
          type usb-bus
          dev: usb-storage, id "usb-storage2"
            drive = <null>
            logical_block_size = 512
            physical_block_size = 512
            min_io_size = 0
            opt_io_size = 0
            bootindex = -1
            discard_granularity = 0
            serial = "sluo-2"
            removable = on
            port = <null>
            full-path = on
            addr 0.5, port 5, speed 480, name QEMU USB MSD, attached
            bus: usb-storage2.0
              type SCSI
              dev: scsi-disk, id ""
                drive = storage2
                logical_block_size = 512
                physical_block_size = 512
                min_io_size = 0
                opt_io_size = 0
                bootindex = -1
                discard_granularity = 0
                ver = "1.4.0"
                serial = <null>         <----------should "sluo-2"
                vendor = "QEMU"
                product = "QEMU HARDDISK"
                removable = on
                dpofua = off
                wwn = 0x0
                channel = 0
                scsi-id = 0
                lun = 0
          dev: usb-storage, id "usb-storage1"
            drive = <null>
            logical_block_size = 512
            physical_block_size = 512
            min_io_size = 0
            opt_io_size = 0
            bootindex = -1
            discard_granularity = 0
            serial = "sluo-1"
            removable = on
            port = <null>
            full-path = on
            addr 0.4, port 4, speed 480, name QEMU USB MSD, attached
            bus: usb-storage1.0
              type SCSI
              dev: scsi-disk, id ""
                drive = storage1
                logical_block_size = 512
                physical_block_size = 512
                min_io_size = 0
                opt_io_size = 0
                bootindex = -1
                discard_granularity = 0
                ver = "1.4.0"
                serial = "sluo-1"
                vendor = "QEMU"
                product = "QEMU HARDDISK"
                removable = on
                dpofua = off
                wwn = 0x0
                channel = 0
                scsi-id = 0
                lun = 0
...
after step 3, the serial for "usb-storage1" display correctly, but not correctly for "usb-storage2".
# /usr/lib/udev/scsi_id --whitelist /dev/sdc
0QEMU    QEMU HARDDISK   storage2       <-------should be sluo-2, not storage2
# /usr/lib/udev/scsi_id --whitelist /dev/sdd
0QEMU    QEMU HARDDISK   sluo-1

Expected results:

Additional info:
# /usr/libexec/qemu-kvm -S -M q35 -cpu SandyBridge -enable-kvm -m 4096 -smp 2,sockets=2,cores=1,threads=1 -no-kvm-pit-reinjection -name sluo-test -uuid ed09fa10-6ffe-4811-a42f-0294afcb5a42 -rtc base=localtime,clock=host,driftfix=slew -device virtio-serial-pci,id=virtio-serial0,max_ports=16,vectors=0,bus=pcie.0,addr=0x3 -chardev socket,id=channel1,path=/tmp/helloworld1,server,nowait -device virtserialport,chardev=channel1,name=com.redhat.rhevm.vdsm,bus=virtio-serial0.0,id=port1 -chardev socket,id=channel2,path=/tmp/helloworld2,server,nowait -device virtserialport,chardev=channel2,name=com.redhat.rhevm.vdsm,bus=virtio-serial0.0,id=port2 -drive file=/home/RHEL-Server-7.0-64-scsi.qcow2,if=none,id=drive-system-disk,format=qcow2,cache=none,aio=native,werror=stop,rerror=stop,serial=QEMU-DISK1 -device virtio-scsi-pci,bus=pcie.0,addr=0x4,id=scsi0 -device scsi-hd,bus=scsi0.0,drive=drive-system-disk,id=system-disk,bootindex=1 -netdev tap,id=hostnet0,vhost=off,script=/etc/qemu-ifup -device virtio-net-pci,netdev=hostnet0,id=virtio-net-pci0,mac=08:2e:5f:0a:0d:b1,bus=pcie.0,addr=0x5,bootindex=2 -device virtio-balloon-pci,id=ballooning,bus=pcie.0,addr=0x6 -drive file=/home/my-data-disk.raw,if=none,id=drive-data-disk,format=raw,cache=none,aio=native,werror=stop,rerror=stop -device virtio-scsi-pci,bus=pcie.0,addr=0x7,id=scsi1 -device scsi-hd,bus=scsi1.0,drive=drive-data-disk,id=data-disk,serial=QEMU-DISK2 -readconfig /home/ich9-ehci-uhci.cfg -device usb-tablet,id=input0 -device usb-mouse,id=mouse -chardev spicevmc,name=usbredir,id=usbredirchardev1 -device usb-redir,chardev=usbredirchardev1,id=usbredirdev1,bus=ehci.0,debug=2 -drive file=/home/my-usb-storage1.qcow2,if=none,id=storage1,media=disk,cache=none,format=qcow2,serial=sluo-1 -device usb-storage,drive=storage1,id=usb-storage1,bus=ehci.0,removable=on -drive file=/home/my-usb-storage2.qcow2,if=none,id=storage2,media=disk,cache=none,format=qcow2 -device usb-storage,drive=storage2,id=usb-storage2,bus=ehci.0,removable=on,serial=sluo-2 -global PIIX4_PM.disable_s3=0 -global PIIX4_PM.disable_s4=0 -serial unix:/tmp/ttyS0,server,nowait -qmp tcp:0:4444,server,nowait -k en-us -boot menu=on -vnc :1 -spice disable-ticketing,port=5931 -monitor stdio

Comment 1 Sibiao Luo 2013-04-02 11:12:45 UTC
Btw, rhel6.4 host also hit this problem, I clone it to rhel6.5. please correct me if mistake.

Comment 2 Gerd Hoffmann 2013-04-02 13:04:02 UTC
Yea, usb-storage is icky, the automatic creation of scsi-{hd,cd} devices creates this kind of problems.

With qemu-1.4+ there is a way out: use usb-bot instead (which is almost identical to usb-storage, but is configured like all other scsi host adapters):

qemu -drive if=none,id=usbstick,... \
  -device usb-bot,id=bot \
  -device scsi-hd,bus=bot.0,drive=usbstick,serial=whatever,...


Kevin, do you see an easy way to fix the block serial issue with usb-storage?
If not I'm tempted to close this WONTFIX and deprecate usb-storage ...

Comment 3 Kevin Wolf 2013-04-03 11:10:37 UTC
Posted a patch upstream:
http://lists.gnu.org/archive/html/qemu-devel/2013-04/msg00590.html

Comment 4 Miroslav Rezanina 2013-05-23 12:08:02 UTC
Build in qemu-kvm-1.5.0-1.el7

Comment 5 Sibiao Luo 2013-07-05 09:00:33 UTC
verify this issue with qemu-kvm-1.5.1-2.el7.x86_64.
host info:
3.10.0-0.rc7.64.el7.x86_64
qemu-kvm-1.5.1-2.el7.x86_64

Steps:
the same to comment #0.
e.g:...-device nec-usb-xhci,id=xhci,bus=bridge1,addr=0x8 -drive file=/home/my-usb-storage1.qcow3,if=none,id=drive-usb-storage1,media=disk,format=qcow2,cache=none -device usb-storage,drive=drive-usb-storage1,id=usb-storage1,bus=xhci.0,serial=sluo-123456 -drive file=/home/my-usb-storage2.qcow3,if=none,id=drive-usb-storage2,media=disk,format=qcow2,cache=none -device usb-storage,drive=drive-usb-storage2,id=usb-storage2,bus=xhci.0,serial=zxcd-123456 -drive file=/home/my-usb-storage3.qcow3,if=none,id=drive-usb-storage3,media=disk,format=qcow2,cache=none -device usb-storage,drive=drive-usb-storage3,id=usb-storage3,bus=xhci.0,serial=abcd-123456

Results:
guest]# /usr/lib/udev/scsi_id --whitelist /dev/sdb
0QEMU    QEMU HARDDISK   sluo-123456
guest]# /usr/lib/udev/scsi_id --whitelist /dev/sdc
0QEMU    QEMU HARDDISK   zxcd-123456
guest]# /usr/lib/udev/scsi_id --whitelist /dev/sdd
0QEMU    QEMU HARDDISK   abcd-123456

Base on above, this issue has been fixed correctly, set verified status.

Comment 7 Ludek Smid 2014-06-13 11:58:16 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.