From: Ryan Harper <ryanh@us.ibm.com>
To: qemu-devel@nongnu.org
Cc: john cooper <john.cooper@redhat.com>
Subject: [Qemu-devel] [PATCH] virtio-blk: assign a default serial number if none provided
Date: Tue, 1 Jun 2010 20:48:54 -0500 [thread overview]
Message-ID: <20100602014854.GB16406@us.ibm.com> (raw)
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
next reply other threads:[~2010-06-02 1:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-02 1:48 Ryan Harper [this message]
2010-06-02 6:56 ` [Qemu-devel] [PATCH] virtio-blk: assign a default serial number if none provided 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
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=20100602014854.GB16406@us.ibm.com \
--to=ryanh@us.ibm.com \
--cc=john.cooper@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).