qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Ryan Harper <ryanh@us.ibm.com>
To: linux-hotplug@vger.kernel.org
Cc: john cooper <john.cooper@redhat.com>,
	Rusty Russell <rusty@rustcorp.com.au>,
	qemu-devel@nongnu.org, Ryan Harper <ryanh@us.ibm.com>
Subject: [Qemu-devel] [PATCH 2/2] Add virtio-blk by-id rules based on 'serial' attribute
Date: Fri, 25 Jun 2010 08:59:23 -0500	[thread overview]
Message-ID: <1277474363-6534-3-git-send-email-ryanh@us.ibm.com> (raw)
In-Reply-To: <1277474363-6534-1-git-send-email-ryanh@us.ibm.com>

Using virtio-blk serial attributes add rules to extract drive serial numbers and
generate by-id links for the block device and partitions.

With these rules added, we now see the following symlinks in disk/by-id

% ls -al /dev/disk/by-id | grep vdb
lrwxrwxrwx. 1 root root   9 Jun  1 22:09 virtio-QM00001 -> ../../vda
lrwxrwxrwx. 1 root root  10 Jun  1 22:09 virtio-QM00001-part1 -> ../../vda1

Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
---
 rules/rules.d/60-persistent-storage.rules |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/rules/rules.d/60-persistent-storage.rules b/rules/rules.d/60-persistent-storage.rules
index 1f46041..6449e07 100644
--- a/rules/rules.d/60-persistent-storage.rules
+++ b/rules/rules.d/60-persistent-storage.rules
@@ -18,6 +18,10 @@ TEST=="whole_disk", GOTO="persistent_storage_end"
 # for partitions import parent information
 ENV{DEVTYPE}=="partition", IMPORT{parent}="ID_*"
 
+# virtio-blk
+KERNEL=="vd*[!0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/virtio-$env{ID_SERIAL}"
+KERNEL=="vd*[0-9]", ATTRS{serial}=="?*", ENV{ID_SERIAL}="$attr{serial}", SYMLINK+="disk/by-id/virtio-$env{ID_SERIAL}-part%n"
+
 # USB devices use their own serial number
 KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", IMPORT{program}="usb_id --export %p"
 # ATA devices with their own "ata" kernel subsystem
-- 
1.6.3.3

  parent reply	other threads:[~2010-06-25 17:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-25 13:59 [Qemu-devel] [PATCH v3 0/2] Add virtio-blk support to persistent-storage rules Ryan Harper
2010-06-25 13:59 ` [Qemu-devel] [PATCH 1/2] Add virtio-blk support to path_id Ryan Harper
2010-06-25 13:59 ` Ryan Harper [this message]
2010-06-29 15:29 ` [Qemu-devel] Re: [PATCH v3 0/2] Add virtio-blk support to persistent-storage rules Kay Sievers

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=1277474363-6534-3-git-send-email-ryanh@us.ibm.com \
    --to=ryanh@us.ibm.com \
    --cc=john.cooper@redhat.com \
    --cc=linux-hotplug@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rusty@rustcorp.com.au \
    /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).