Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
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.
DescriptionMarkus Armbruster
2011-03-16 07:30:47 UTC
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;
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.
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.
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
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
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;