]> git.proxmox.com Git - qemu.git/commitdiff
blockdev: Don't limit DriveInfo serial to 20 characters
authorMarkus Armbruster <armbru@redhat.com>
Wed, 11 Jul 2012 13:08:38 +0000 (15:08 +0200)
committerKevin Wolf <kwolf@redhat.com>
Tue, 17 Jul 2012 14:48:32 +0000 (16:48 +0200)
All current users (IDE, SCSI and virtio-blk) happen to share this 20
characters limit.  Still, it should be left to device models.  They
already enforce their limits.  They have to, as the DriveInfo limit
only affects legacy -drive serial=..., not the qdev properties.

usb-storage, which doesn't limit serial number length, also uses
DriveInfo for -usbdevice.  But that doesn't provide access to
DriveInfo serial.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
blockdev.c
blockdev.h
hw/block-common.c
hw/ide/core.c

index 5f8677ef05f02b478e0d8b83d3ee9e6b9f1325ef..3d7501565d7006ff5a510663523bbb24d29a8ebe 100644 (file)
@@ -536,9 +536,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
     dinfo->trans = translation;
     dinfo->opts = opts;
     dinfo->refcount = 1;
-    if (serial) {
-        pstrcpy(dinfo->serial, sizeof(dinfo->serial), serial);
-    }
+    dinfo->serial = serial;
     QTAILQ_INSERT_TAIL(&drives, dinfo, next);
 
     bdrv_set_on_error(dinfo->bdrv, on_read_error, on_write_error);
index 9c29948128cd4a99c67d7c314ab004415b349b03..5f27b643be7b9f550a355e9d89863f1b65d203e9 100644 (file)
@@ -17,8 +17,6 @@
 void blockdev_mark_auto_del(BlockDriverState *bs);
 void blockdev_auto_del(BlockDriverState *bs);
 
-#define BLOCK_SERIAL_STRLEN 20
-
 typedef enum {
     IF_DEFAULT = -1,            /* for use with drive_add() only */
     IF_NONE,
@@ -37,7 +35,7 @@ struct DriveInfo {
     int media_cd;
     int cyls, heads, secs, trans;
     QemuOpts *opts;
-    char serial[BLOCK_SERIAL_STRLEN + 1];
+    const char *serial;
     QTAILQ_ENTRY(DriveInfo) next;
     int refcount;
 };
index 036334b1ece788169797b0e44eaf830f5db09ad2..0a0542a650bb893a2b7f0535ded0fa996d6b4745 100644 (file)
@@ -17,7 +17,7 @@ void blkconf_serial(BlockConf *conf, char **serial)
     if (!*serial) {
         /* try to fall back to value set with legacy -drive serial=... */
         dinfo = drive_get_by_blockdev(conf->bs);
-        if (*dinfo->serial) {
+        if (dinfo->serial) {
             *serial = g_strdup(dinfo->serial);
         }
     }
index 58a454fde57f0476b2784f2bba385e8c427bebae..5378fc39fe455a3a14de003ff4c14f1f5ad369b9 100644 (file)
@@ -2095,9 +2095,9 @@ void ide_init2_with_non_qdev_drives(IDEBus *bus, DriveInfo *hd0,
                 trans = hd_bios_chs_auto_trans(cyls, heads, secs);
             }
             if (ide_init_drive(&bus->ifs[i], dinfo->bdrv,
-                               dinfo->media_cd ? IDE_CD : IDE_HD, NULL,
-                               *dinfo->serial ? dinfo->serial : NULL,
-                               NULL, 0, cyls, heads, secs, trans) < 0) {
+                               dinfo->media_cd ? IDE_CD : IDE_HD,
+                               NULL, dinfo->serial, NULL, 0,
+                               cyls, heads, secs, trans) < 0) {
                 error_report("Can't set up IDE drive %s", dinfo->id);
                 exit(1);
             }