Red Hat Bugzilla – Bug 947416
fail to specify the serial number for usb storage device
Last modified: 2013-11-21 01:47:54 EST
+++ This bug was initially created as a clone of Bug #947411 +++ 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 --- Additional comment from Sibiao Luo on 2013-04-02 07:12:45 EDT --- Btw, rhel6.4 host also hit this problem, I clone it to rhel6.5. please correct me if mistake.
I test it in rhel6.4 also hit this issue. host info: kernel-2.6.32-356.el6.x86_64 qemu-kvm-0.12.1.2-2.355.el6.x86_64 seabios-0.6.1.2-26.el6.x86_64 guest info: kernel-2.6.32-356.el6.x86_64 Best Regards. sluo
patches posted.
Steps to reproduce and verify this bug: 1. launch a guest with serial specified in -drive option: /usr/libexec/qemu-kvm -M rhel6.4.0 -enable-kvm -m 2048 -smp 2,sockets=1,cores=2,threads=1 -device usb-ehci,id=ehci_1 -drive file=/home/rhel6.4.bak.qcow2,if=none,id=drive-virtio-disk0,format=qcow2,cache=none,werror=stop,rerror=stop,aio=native -device usb-storage,bus=ehci_1.0,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1,serial=abcdefgh-520c-469b-90c2-663277e90438 -net none -nodefaults -spice port=8000,disable-ticketing -k en-us -vga qxl -global qxl-vga.vram_size=67108864 -monitor stdio -device virtio-scsi-pci,id=scsi_1 -drive file=/home/test.qcow2,if=none,id=drive-virtio-disk1,format=qcow2,cache=none,werror=stop,rerror=stop,aio=native -device scsi-hd,bus=scsi_1.0,drive=drive-virtio-disk1,id=virtio-disk1,serial=qwertui-520c-469b-90c2-663277e90448 2. observe the output of info qtree as well as in guest through scsi_id 3. hot plug a disk into guest with serial specified and repeat step 2. Reproduction: ------------ Reproduced with 2.6.32-391.el6.x86_64, qemu-kvm-0.12.1.2-2.355.el6.x86_64. info qtree didn't tell the serial specified in -drive option. (qemu) info qtree bus: main-system-bus ... dev: usb-ehci, id "ehci_1" dev-prop: freq = 1000 dev-prop: maxframes = 128 bus-prop: addr = 03.0 bus-prop: romfile = <null> bus-prop: rombar = 1 bus-prop: multifunction = off class USB controller, addr 00:03.0, pci id 8086:24cd (sub 1af4:1100) bar 0: mem at 0xf4020000 [0xf4020fff] bus: ehci_1.0 type USB dev: usb-storage, id "virtio-disk0" dev-prop: drive = <null> dev-prop: logical_block_size = 512 dev-prop: physical_block_size = 512 dev-prop: min_io_size = 0 dev-prop: opt_io_size = 0 dev-prop: bootindex = 1 dev-prop: discard_granularity = 0 dev-prop: serial = "abcdefgh-520c-469b-90c2-663277e90438" dev-prop: removable = off bus-prop: port = <null> bus-prop: create_unique_serial = 1 addr 0.1, port 1, speed 480, name QEMU USB MSD, attached bus: virtio-disk0.0 type SCSI dev: scsi-disk, id "" dev-prop: drive = drive-virtio-disk0 dev-prop: logical_block_size = 512 dev-prop: physical_block_size = 512 dev-prop: min_io_size = 0 dev-prop: opt_io_size = 0 dev-prop: bootindex = 1 dev-prop: discard_granularity = 0 dev-prop: ver = "0.12.1" dev-prop: serial = <null> ^^^^^^^^^^^^^^^ shouldn't be null dev-prop: wwn = 0x0 dev-prop: removable = off bus-prop: channel = 0 bus-prop: scsi-id = 0 bus-prop: lun = 0 In guest: scsi_id --whitelisted --device=/dev/sdb 0QEMU QEMU HARDDISK drive-virtio-disk0 ^^^^^^^^^^^^^^^^^^ shouldn't be this scsi_id --whitelisted --device=/dev/sda 0QEMU QEMU HARDDISK qwertui-520c-469b-90 Verification: ------------ Verified with 2.6.32-391.el6.x86_64, qemu-kvm-0.12.1.2-2.376.el6.x86_64. After step 2: dev: usb-ehci, id "ehci_1" dev-prop: freq = 1000 dev-prop: maxframes = 128 bus-prop: addr = 03.0 bus-prop: romfile = <null> bus-prop: rombar = 1 bus-prop: multifunction = off class USB controller, addr 00:03.0, pci id 8086:24cd (sub 1af4:1100) bar 0: mem at 0xf4020000 [0xf4020fff] bus: ehci_1.0 type USB dev: usb-storage, id "virtio-disk0" dev-prop: drive = <null> dev-prop: logical_block_size = 512 dev-prop: physical_block_size = 512 dev-prop: min_io_size = 0 dev-prop: opt_io_size = 0 dev-prop: bootindex = 1 dev-prop: discard_granularity = 0 dev-prop: serial = "abcdefgh-520c-469b-90c2-663277e90438" dev-prop: removable = off bus-prop: port = <null> bus-prop: create_unique_serial = 1 addr 0.1, port 1, speed 480, name QEMU USB MSD, attached bus: virtio-disk0.0 type SCSI dev: scsi-disk, id "" dev-prop: drive = drive-virtio-disk0 dev-prop: logical_block_size = 512 dev-prop: physical_block_size = 512 dev-prop: min_io_size = 0 dev-prop: opt_io_size = 0 dev-prop: bootindex = 1 dev-prop: discard_granularity = 0 dev-prop: ver = "0.12.1" dev-prop: serial = "abcdefgh-520c-469b-90c2-663277e90438" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dev-prop: wwn = 0x0 dev-prop: removable = off bus-prop: channel = 0 bus-prop: scsi-id = 0 bus-prop: lun = 0 In guest: # scsi_id --whitelisted --device=/dev/sdb 0QEMU QEMU HARDDISK abcdefgh-520c-469b-9 After step 3: (qemu) __com.redhat_drive_add file=/home/usb_data.qcow2,id=drive-virtio-disk2,format=qcow2,cache=none,werror=stop,rerror=stop,aio=native (qemu) device_add usb-storage,bus=ehci_1.0,drive=drive-virtio-disk2,id=virtio-disk2,serial=zxcvbnm1-520c-469b-90c2-663277e90438 ... bus: virtio-disk2.0 type SCSI dev: scsi-disk, id "" dev-prop: drive = drive-virtio-disk2 dev-prop: logical_block_size = 512 dev-prop: physical_block_size = 512 dev-prop: min_io_size = 0 dev-prop: opt_io_size = 0 dev-prop: bootindex = -1 dev-prop: discard_granularity = 0 dev-prop: ver = "0.12.1" dev-prop: serial = "zxcvbnm1-520c-469b-90c2-663277e90438" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dev-prop: wwn = 0x0 dev-prop: removable = off bus-prop: channel = 0 bus-prop: scsi-id = 0 bus-prop: lun = 0 In guest: # scsi_id --whitelisted --device=/dev/sdc 0QEMU QEMU HARDDISK zxcvbnm1-520c-469b-9 Conclusion: ---------- This issue has been fixed as per above.
Hi Gerd, The behaviour of serial is different between -drive option and -device option. The difference is that serial is truncated to 20 bytes from output of 'info qtree' if it gets specified in -drive, but this truncation doesn't happen in -device. Is this expected? BTW, the common behaviour is both got truncated to 20 bytes in guest from output of scsi_id and hdparm.
(In reply to chayang from comment #9) > Hi Gerd, > The behaviour of serial is different between -drive option and -device > option. The difference is that serial is truncated to 20 bytes from output > of 'info qtree' if it gets specified in -drive, but this truncation doesn't > happen in -device. Is this expected? > BTW, the common behaviour is both got truncated to 20 bytes in guest from > output of scsi_id and hdparm. I guess the scsi guest interface is limited to 20 bytes, and therefore -drive will limit the serial number to that length (or simply have 20 bytes storage and ignores anything longer). Kevin? The serial property for -device is simply declared as string property which is stored as-is, nobody cuts it down in length. And specifically in case of usb-storage it also shows up in 'lsusb -v -s $device' in the guest, in full length, so I don't think we should apply limits here.
(In reply to Gerd Hoffmann from comment #10) > I guess the scsi guest interface is limited to 20 bytes, and therefore > -drive will limit the serial number to that length (or simply have 20 bytes > storage and ignores anything longer). Kevin? The RHEL 6 SCSI code indeed limits to 20 characters when passing the information, but I think the real limit for 'info qtree' may be DriveInfo.serial, which is char[21]. Maybe scsi_initfn() should truncate the string so that the 'info qtree' output is consistent with what the guest sees, but then, probably nobody cares and I've already wasted more time with this than it's worth. Upstream is doing different, but not less weird things with the serial number. I don't really understand that code: const char *str = s->serial ?: bdrv_get_device_name(s->qdev.conf.bs); int max_len = s->serial ? 20 : 255 - 8; So it seems to be explicitly limited to 20 bytes for the -device property, but not if it gets the value from -drive (which is now unlimited in length in upstream).
> Upstream is doing different, but not less weird things with the serial > number. > I don't really understand that code: > > const char *str = s->serial ?: bdrv_get_device_name(s->qdev.conf.bs); > int max_len = s->serial ? 20 : 255 - 8; > > So it seems to be explicitly limited to 20 bytes for the -device property, > but > not if it gets the value from -drive (which is now unlimited in length in > upstream). I guess someone was overly careful when killing the 20 bytes limit for -drive. Simply going for "max_len = 255 - 8" should be correct I think: 255 bytes == max mode page size, minus some space for fixed fields ...
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHSA-2013-1553.html