Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 688058 - Drive serial number gets truncated
Drive serial number gets truncated
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm (Show other bugs)
6.1
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: jason wang
Virtualization Bugs
: Triaged
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-03-16 03:30 EDT by Markus Armbruster
Modified: 2017-02-06 09:36 EST (History)
6 users (show)

See Also:
Fixed In Version: qemu-kvm-0.12.1.2-2.153.el6
Doc Type: Bug Fix
Doc Text:
Cause: bug in the serial number setting code inside qemu-kvm. Consequence: drive serial number got truncated to 8 characters. Fix: Fix serial number assignment code. Result: drive serial number not truncated anymore.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-05-19 07:21:11 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2011:0534 normal SHIPPED_LIVE Important: qemu-kvm security, bug fix, and enhancement update 2011-05-19 07:20:36 EDT

  None (edit)
Description Markus Armbruster 2011-03-16 03:30:47 EDT
Description of problem:
The serial number defined with -drive is truncated to sizeof(char *) characters.

How reproducible:
Always

Steps to Reproduce:
1. Give a disk a long serial number.  I use an existing VM with one IDE disk for testing, to which I add a second IDE disk with my test serial number, like this:
-drive if=none,id=foo,file=tmp.qcow2,serial=0123456789abcdef -device ide-drive,drive=foo
2. In the guest, run hdparm -i /dev/sdb
  
Actual results:
hdparm shows "SerialNo=01234567"

Expected results:
SerialNo=0123456789abcdef

Additional info:
Fix is a one-liner:

diff --git a/vl.c b/vl.c
index cda2d96..f66c05c 100644
--- a/vl.c
+++ b/vl.c
@@ -2475,7 +2475,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque,
     dinfo->on_write_error = on_write_error;
     dinfo->opts = opts;
     if (serial)
-        strncpy(dinfo->serial, serial, sizeof(serial));
+        strncpy(dinfo->serial, serial, sizeof(dinfo->serial));
     QTAILQ_INSERT_TAIL(&drives, dinfo, next);
     if (is_extboot) {
         extboot_drive = dinfo;
Comment 2 juzhang 2011-03-16 06:30:31 EDT
can reproduce this bug with qemu-kvm-0.12.1.2-2.150.el6.x86_64 using comment0 step.so mark qa_ack+ flag.
Comment 7 Shaolong Hu 2011-04-01 23:20:05 EDT
Reproduce on qemu-kvm-0.12.1.2-2.150.el6.x86_64:

Steps to Reproduce:
1. Boot guest with:
-drive file=/dev/vg_shutest2/lv_test,cache=none,format=raw,rerror=stop,werror=stop,id=test,if=none,serial=0123456789abcdefg -device ide-drive,drive=test,id=test-device,bootindex=2
2. In the guest, run hdparm -i /dev/sdb

Actual results:
hdparm shows "SerialNo=01234567"



Verify on qemu-kvm-0.12.1.2-2.153.el6.x86_64:

Actual results:
hdparm shows "SerialNo=0123456789abcdefg"



Conclusion:
According to result above, this bug has been fixed.
Comment 8 juzhang 2011-04-01 23:25:13 EDT
According to commnet7,set this issue status as verified.
Comment 9 Eduardo Habkost 2011-05-03 15:09:22 EDT
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause: bug in the serial number setting code inside qemu-kvm.

Consequence: drive serial number got truncated to 8 characters.

Fix: Fix serial number assignment code.

Result: drive serial number not truncated anymore.
Comment 10 errata-xmlrpc 2011-05-19 07:21:11 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-0534.html
Comment 11 errata-xmlrpc 2011-05-19 09:02:12 EDT
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-0534.html

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