blockdev: Don't limit DriveInfo serial to 20 characters

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>
This commit is contained in:
Markus Armbruster 2012-07-11 15:08:38 +02:00 committed by Kevin Wolf
parent 911525dba9
commit 577d0a3807
4 changed files with 6 additions and 10 deletions

View File

@ -536,9 +536,7 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
dinfo->trans = translation; dinfo->trans = translation;
dinfo->opts = opts; dinfo->opts = opts;
dinfo->refcount = 1; dinfo->refcount = 1;
if (serial) { dinfo->serial = serial;
pstrcpy(dinfo->serial, sizeof(dinfo->serial), serial);
}
QTAILQ_INSERT_TAIL(&drives, dinfo, next); QTAILQ_INSERT_TAIL(&drives, dinfo, next);
bdrv_set_on_error(dinfo->bdrv, on_read_error, on_write_error); bdrv_set_on_error(dinfo->bdrv, on_read_error, on_write_error);

View File

@ -17,8 +17,6 @@
void blockdev_mark_auto_del(BlockDriverState *bs); void blockdev_mark_auto_del(BlockDriverState *bs);
void blockdev_auto_del(BlockDriverState *bs); void blockdev_auto_del(BlockDriverState *bs);
#define BLOCK_SERIAL_STRLEN 20
typedef enum { typedef enum {
IF_DEFAULT = -1, /* for use with drive_add() only */ IF_DEFAULT = -1, /* for use with drive_add() only */
IF_NONE, IF_NONE,
@ -37,7 +35,7 @@ struct DriveInfo {
int media_cd; int media_cd;
int cyls, heads, secs, trans; int cyls, heads, secs, trans;
QemuOpts *opts; QemuOpts *opts;
char serial[BLOCK_SERIAL_STRLEN + 1]; const char *serial;
QTAILQ_ENTRY(DriveInfo) next; QTAILQ_ENTRY(DriveInfo) next;
int refcount; int refcount;
}; };

View File

@ -17,7 +17,7 @@ void blkconf_serial(BlockConf *conf, char **serial)
if (!*serial) { if (!*serial) {
/* try to fall back to value set with legacy -drive serial=... */ /* try to fall back to value set with legacy -drive serial=... */
dinfo = drive_get_by_blockdev(conf->bs); dinfo = drive_get_by_blockdev(conf->bs);
if (*dinfo->serial) { if (dinfo->serial) {
*serial = g_strdup(dinfo->serial); *serial = g_strdup(dinfo->serial);
} }
} }

View 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); trans = hd_bios_chs_auto_trans(cyls, heads, secs);
} }
if (ide_init_drive(&bus->ifs[i], dinfo->bdrv, if (ide_init_drive(&bus->ifs[i], dinfo->bdrv,
dinfo->media_cd ? IDE_CD : IDE_HD, NULL, dinfo->media_cd ? IDE_CD : IDE_HD,
*dinfo->serial ? dinfo->serial : NULL, NULL, dinfo->serial, NULL, 0,
NULL, 0, cyls, heads, secs, trans) < 0) { cyls, heads, secs, trans) < 0) {
error_report("Can't set up IDE drive %s", dinfo->id); error_report("Can't set up IDE drive %s", dinfo->id);
exit(1); exit(1);
} }