All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virtio-blk: Set default serial id
@ 2013-03-20  5:56 ` Asias He
  0 siblings, 0 replies; 8+ messages in thread
From: Asias He @ 2013-03-20  5:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Stefan Hajnoczi, kvm, Asias He

If user does not specify a serial id, e.g.

   -device virtio-blk-pci,serial="serial_id"
or
   -drive serial="serial_id"

no serial id will be assigned.

Add a default serial id in this case to help identifying
the disk in guest.

Signed-off-by: Asias He <asias@redhat.com>
---
 hw/virtio-blk.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index f2143fd..c016817 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -642,6 +642,13 @@ static int virtio_blk_device_init(VirtIODevice *vdev)
     }
 
     blkconf_serial(&blk->conf, &blk->serial);
+
+    if (!blk->serial) {
+        char serial[VIRTIO_BLK_ID_BYTES];
+        snprintf(serial, VIRTIO_BLK_ID_BYTES, "ID%05d", virtio_blk_id);
+        blk->serial = g_strdup(serial);
+    }
+
     if (blkconf_geometry(&blk->conf, NULL, 65535, 255, 255) < 0) {
         return -1;
     }
-- 
1.8.1.4


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

end of thread, other threads:[~2013-03-21  9:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-20  5:56 [PATCH] virtio-blk: Set default serial id Asias He
2013-03-20  5:56 ` [Qemu-devel] " Asias He
2013-03-20  7:52 ` Stefan Hajnoczi
2013-03-20  7:52   ` [Qemu-devel] " Stefan Hajnoczi
2013-03-20  8:34   ` Asias He
2013-03-20  8:34     ` [Qemu-devel] " Asias He
2013-03-21  9:31     ` Paolo Bonzini
2013-03-21  9:31       ` [Qemu-devel] " Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.