Bug 947416
Summary: | fail to specify the serial number for usb storage device | ||
---|---|---|---|
Product: | Red Hat Enterprise Linux 6 | Reporter: | Sibiao Luo <sluo> |
Component: | qemu-kvm | Assignee: | Gerd Hoffmann <kraxel> |
Status: | CLOSED ERRATA | QA Contact: | Virtualization Bugs <virt-bugs> |
Severity: | medium | Docs Contact: | |
Priority: | low | ||
Version: | 6.5 | CC: | acathrow, bsarathy, chayang, juzhang, kraxel, kwolf, lnovich, michen, mkenneth, qzhang, shuang, stefanha, virt-maint, xfu |
Target Milestone: | rc | ||
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | qemu-kvm-0.12.1.2-2.370.el6 | Doc Type: | Bug Fix |
Doc Text: | Story Points: | --- | |
Clone Of: | 947411 | Environment: | |
Last Closed: | 2013-11-21 06:47:54 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: | 947411 | ||
Bug Blocks: |
Description
Sibiao Luo
2013-04-02 11:14:13 UTC
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 |