qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] virtio-blk: assign a default serial number if none provided
@ 2010-06-02  1:48 Ryan Harper
  2010-06-02  6:56 ` Michael Tokarev
  2010-06-02  9:00 ` [Qemu-devel] " Michael S. Tsirkin
  0 siblings, 2 replies; 8+ messages in thread
From: Ryan Harper @ 2010-06-02  1:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: john cooper

This patch applies on-top of John's virtio-blk serial patches.

Generate default serial numbers for virtio drives based on DriveInfo.unit which is
incremented for each additional virtio-blk device.  This provides a
per-virtio-blk number to use in the default string: QM%05d that is used in
hw/ide/core.c.  The resulting serial number looks like: QM00001, etc.

Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
---
 hw/virtio-blk.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index 98c62f2..e5c6e7c 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -518,6 +518,9 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf)
     bdrv_guess_geometry(s->bs, &cylinders, &heads, &secs);
 
     strncpy(s->sn, drive_get_serial(s->bs), sizeof (s->sn));
+    if (strlen(s->sn) == 0) {
+        snprintf(s->sn, sizeof(s->sn), "QM%05d", conf->dinfo->unit);
+    }
 
     s->vq = virtio_add_queue(&s->vdev, 128, virtio_blk_handle_output);
 
-- 
1.6.3.3


-- 
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
ryanh@us.ibm.com

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-06-02 12:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-02  1:48 [Qemu-devel] [PATCH] virtio-blk: assign a default serial number if none provided Ryan Harper
2010-06-02  6:56 ` Michael Tokarev
2010-06-02 11:42   ` Ryan Harper
2010-06-02 12:32     ` Markus Armbruster
2010-06-02  9:00 ` [Qemu-devel] " Michael S. Tsirkin
2010-06-02 11:45   ` Ryan Harper
2010-06-02 11:54     ` Michael S. Tsirkin
2010-06-02 12:26       ` Ryan Harper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).