From: Asias He <asias@redhat.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>, Asias He <asias@redhat.com>,
kvm@vger.kernel.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH] virtio-blk: Set default serial id
Date: Wed, 20 Mar 2013 13:56:08 +0800 [thread overview]
Message-ID: <1363758968-28549-1-git-send-email-asias@redhat.com> (raw)
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
next reply other threads:[~2013-03-20 5:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-20 5:56 Asias He [this message]
2013-03-20 7:52 ` [Qemu-devel] [PATCH] virtio-blk: Set default serial id Stefan Hajnoczi
2013-03-20 8:34 ` Asias He
2013-03-21 9:31 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1363758968-28549-1-git-send-email-asias@redhat.com \
--to=asias@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).