From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:57686) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sowex-0005mn-DG for qemu-devel@nongnu.org; Wed, 11 Jul 2012 09:08:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sower-0002Bi-8t for qemu-devel@nongnu.org; Wed, 11 Jul 2012 09:08:50 -0400 Received: from oxygen.pond.sub.org ([78.46.104.156]:42132) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sower-0002BM-0H for qemu-devel@nongnu.org; Wed, 11 Jul 2012 09:08:45 -0400 Received: from blackfin.pond.sub.org (p57B0F3EA.dip.t-dialin.net [87.176.243.234]) by oxygen.pond.sub.org (Postfix) with ESMTPA id D0DC5A401B for ; Wed, 11 Jul 2012 15:08:40 +0200 (CEST) From: Markus Armbruster Date: Wed, 11 Jul 2012 15:08:38 +0200 Message-Id: <1342012119-27088-4-git-send-email-armbru@redhat.com> In-Reply-To: <1342012119-27088-1-git-send-email-armbru@redhat.com> References: <1342012119-27088-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH 3/4] blockdev: Don't limit DriveInfo serial to 20 characters List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com 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 --- blockdev.c | 4 +--- blockdev.h | 4 +--- hw/block-common.c | 2 +- hw/ide/core.c | 6 +++--- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/blockdev.c b/blockdev.c index 5f8677e..3d75015 100644 --- a/blockdev.c +++ b/blockdev.c @@ -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); diff --git a/blockdev.h b/blockdev.h index bc8c2dc..33b5772 100644 --- a/blockdev.h +++ b/blockdev.h @@ -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; }; diff --git a/hw/block-common.c b/hw/block-common.c index 036334b..0a0542a 100644 --- a/hw/block-common.c +++ b/hw/block-common.c @@ -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); } } diff --git a/hw/ide/core.c b/hw/ide/core.c index 58a454f..5378fc3 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -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); } -- 1.7.6.5