[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 34/41] blockdev: Don't limit DriveInfo serial to 20
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 34/41] blockdev: Don't limit DriveInfo serial to 20 characters |
Date: |
Tue, 17 Jul 2012 18:00:31 +0200 |
From: Markus Armbruster <address@hidden>
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 <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
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 9c29948..5f27b64 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
- [Qemu-devel] [PATCH 31/41] Relax IDE CHS limits from 16383, 16, 63 to 65535, 16, 255, (continued)
- [Qemu-devel] [PATCH 31/41] Relax IDE CHS limits from 16383, 16, 63 to 65535, 16, 255, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 41/41] fdc-test: Clean up a bit, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 37/41] coroutine-ucontext: Help valgrind understand coroutines, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 24/41] ide: qdev property for BIOS CHS translation, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 25/41] qtest: Cover qdev property for BIOS CHS translation, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 18/41] scsi-hd: qdev properties for disk geometry, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 26/41] block: Geometry and translation hints are now useless, purge them, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 32/41] hw/block-common: Move BlockConf & friends from block.h, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 38/41] qemu-iotests: Valgrind support, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 28/41] qtest: Test we don't put hard disk info into CMOS for a CD-ROM, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 34/41] blockdev: Don't limit DriveInfo serial to 20 characters,
Kevin Wolf <=
- [Qemu-devel] [PATCH 12/41] hd-geometry: Clean up confusing use of prior translation hint, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 21/41] qtest: Cover qdev properties for disk geometry, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 23/41] qdev: New property type chs-translation, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 17/41] hd-geometry: Switch to uint32_t to match BlockConf, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 40/41] fdc-test: introduce test_relative_seek, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 36/41] qemu-io: Fix memory leaks, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 19/41] virtio-blk: qdev properties for disk geometry, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 20/41] ide: qdev properties for disk geometry, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 39/41] fdc: fix relative seek, Kevin Wolf, 2012/07/17
- [Qemu-devel] [PATCH 35/41] hw/block-common: Factor out fall back to legacy -drive cyls=..., Kevin Wolf, 2012/07/17