Skip to contentSkip to conversation

support identification of Xen virtual block devices

PATCH In review Ian Campbell 2 participants 5 messages Apr 16, 2009 – Apr 17, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 support identification of Xen virtual block devices

* Add xenvb_id utility to identify Xen disk and CD-ROM devices.
* Add support to path_id for Xen vbd devices

With this symlinks such as /dev/cdrom are correctly created for Xen devices configured with the "cdrom" tag and utilities which rely on ID_TYPE or ID_CDROM (such as the Debian Installer) can correctly identify the disks.

---
 configure.ac                        |    1 +
 extras/Makefile.am                  |    3 +-
 extras/path_id/path_id              |   27 ++++
 extras/xenvbd_id/.gitignore         |    1 +
 extras/xenvbd_id/60-xenvbd_id.rules |    3 +
 extras/xenvbd_id/Makefile.am        |   19 +++
 extras/xenvbd_id/xenvbd_id.8        |   37 ++++++
 extras/xenvbd_id/xenvbd_id.c        |  227 +++++++++++++++++++++++++++++++++++
 8 files changed, 317 insertions(+), 1 deletions(-)
 create mode 100644 extras/xenvbd_id/.gitignore
 create mode 100644 extras/xenvbd_id/60-xenvbd_id.rules
 create mode 100644 extras/xenvbd_id/Makefile.am
 create mode 100644 extras/xenvbd_id/xenvbd_id.8
 create mode 100644 extras/xenvbd_id/xenvbd_id.c
configure.ac +1 -0
index cbe2833..a968163 100644
@@ -100,6 +100,7 @@ AC_CONFIG_FILES([
 	extras/volume_id/Makefile
 	extras/volume_id/lib/Makefile
 	extras/volume_id/lib/libvolume_id.pc
+	extras/xenvbd_id/Makefile
 ])
 AC_OUTPUT
 
extras/Makefile.am +2 -1
index fc46668..f364631 100644
@@ -12,4 +12,5 @@ SUBDIRS = \
 	rule_generator \
 	scsi_id \
 	usb_id \
-	volume_id
+	volume_id \
+	xenvbd_id
extras/path_id/path_id +27 -0
index d21dea7..7b4973f 100755
@@ -129,6 +129,30 @@ handle_platform () {
 	RESULT=0
 }
 
+handle_xen () {
+	local DEV=$1
+	cd -P $1
+	vbd_id=${DEV##*/}
+	host_dev_path=$DEV
+	while [ ! -z "$host_dev_path" ] ; do
+		case "$host_dev_path" in
+			*/vbd*)
+				host_dev_path=${host_dev_path%/*}
+				;;
+			*)
+				break
+				;;
+		esac
+	done
+	if [ "$d" ]; then
+		d="xen-$vbd_id-$d"
+	else
+		d="xen-$vbd_id"
+	fi
+	D="$host_dev_path"
+	RESULT=0
+}
+
 handle_serio () {
 	local DEV=$1
 	cd -P $1
@@ -532,6 +556,9 @@ handle_device () {
 			*/platform/*)
 				handle_platform "$D"
 				;;
+			*/vbd-[0-9]*)
+				handle_xen "$D"
+				;;
 			*/devices)
 				D=
 				;;
extras/xenvbd_id/.gitignore new file +1 -0
new file mode 100644
index 0000000..c0ae90e
@@ -0,0 +1 @@
+xenvbd_id
extras/xenvbd_id/60-xenvbd_id.rules new file +3 -0
new file mode 100644
index 0000000..ed3aa5f
@@ -0,0 +1,3 @@
+# import Xen virtual drive properties
+
+ACTION=="add|change", KERNEL=="xvd*[!0-9]", DRIVERS=="vbd", IMPORT{program}="xenvbd_id --export $tempnode"
extras/xenvbd_id/Makefile.am new file +19 -0
new file mode 100644
index 0000000..370db2b
@@ -0,0 +1,19 @@
+include $(top_srcdir)/Makefile.am.inc
+
+udevhomedir = $(udev_prefix)/lib/udev
+udevhome_PROGRAMS = \
+	xenvbd_id
+
+udevrulesdir = $(udev_prefix)/lib/udev/rules.d
+dist_udevrules_DATA = \
+	60-xenvbd_id.rules
+
+xenvbd_id_SOURCES = \
+	xenvbd_id.c \
+	../../udev/lib/libudev.h \
+	../../udev/lib/libudev.c \
+	../../udev/lib/libudev-list.c \
+	../../udev/lib/libudev-util.c
+
+dist_man_MANS = \
+	xenvbd_id.8
extras/xenvbd_id/xenvbd_id.8 new file +37 -0
new file mode 100644
index 0000000..420a412
@@ -0,0 +1,37 @@
+.TH XENVBD_ID 8 "January 2009" "" "Linux Administrator's Manual"
+.SH NAME
+xenvbd_id \- udev callout to determine the capabilities of Xen virtual
+block devices
+.SH SYNOPSIS
+.B xenvbd_id
+[\fB--export\fP] [\fB--debug\fP] \fIdevice\fP
+.br
+.B xenvbd_id
+\fB--help\fP
+.SH "DESCRIPTION"
+.B xenvbd_id
+is normally called from a udev rule, to provide udev with the list of
+capabilities of a Xen virtual block device.
+.SH USAGE
+.B xenvbd_id
+opens the device node specified at the commandline and prints the
+discovered capabilities.
+.SH OPTIONS
+The following commandline switches are supported to specify what xenvbd_id
+should print:
+.TP
+.B -x, --export
+Print all values as environment keys. This is the default at present, so this
+option is currently redundant.
+.TP
+.B -d, --debug
+Print a debug trace.
+.TP
+.B -h, --help
+Print usage help.
+.RE
+.SH SEE ALSO
+.BR udev (7)
+.SH AUTHORS
+Developed by Ian Campbell <[email protected]> based on cdrom_id by Kay Sievers <[email protected]>.
+
extras/xenvbd_id/xenvbd_id.c new file +227 -0

227 lines not on this page · raw message

Signature · 8 lines
1.6.2.2


-- 
Ian Campbell

Consultation, n.:
	Medical term meaning "to share the wealth."
#1 lore raw
Quoted 2 lines · Ian Campbell

* Add xenvb_id utility to identify Xen disk and CD-ROM devices.

What's the reason xen optical drives don't behave like real drives, and need a xen specific tool? That sounds rather odd,

Quoted 1 line

* Add support to path_id for Xen vbd devices

Applied this part.

Thanks,
Kay

#2 lore raw
In reply to Ian Campbell
Quoted 6 lines · Kay Sievers
Quoted 2 lines · Ian Campbell

* Add xenvb_id utility to identify Xen disk and CD-ROM devices.

What's the reason xen optical drives don't behave like real drives, and need a xen specific tool? That sounds rather odd,

They aren't proper SCSI devices so you can't do SCSI inquiry like cdrom_id wants, the properties you can query from a Xen vbd are very basic, basically just TYPE=disk|cd.

I suppose I could make the SCSI INQ stuff in cdrom_id optional, since the CDROM_GET_CAPABILITY ioctl is implemented. Would that be preferred? It would be essentially making the stuff added in fd7a285e6293fddd3fbc68b519dcd367adeb72c4 optional.

Quoted 3 lines
Quoted 1 line

* Add support to path_id for Xen vbd devices

Applied this part.

Thanks,
Ian.

Signature · 5 lines
Ian Campbell

BOFH excuse #350:

paradigm shift...without a clutch
#3 lore raw
In reply to Ian Campbell
Quoted 8 lines · Ian Campbell
Quoted 6 lines · Kay Sievers
Quoted 2 lines · Ian Campbell

* Add xenvb_id utility to identify Xen disk and CD-ROM devices.

What's the reason xen optical drives don't behave like real drives, and need a xen specific tool? That sounds rather odd,

Quoted 6 lines

They aren't proper SCSI devices so you can't do SCSI inquiry like cdrom_id wants, the properties you can query from a Xen vbd are very basic, basically just TYPE=disk|cd.

I suppose I could make the SCSI INQ stuff in cdrom_id optional, since the CDROM_GET_CAPABILITY ioctl is implemented. Would that be preferred?

Please check the stuff I put in the git tree:
http://git.kernel.org/?p=linux/hotplug/udev.git;a=commit;hUd8f5e208396589476583dad8f2a7f2db3e2ef5

Kay

#4 lore raw
In reply to Ian Campbell
Quoted 13 lines · Kay Sievers
Quoted 12 lines · Ian Campbell
Quoted 6 lines · Kay Sievers
Quoted 2 lines · Ian Campbell

* Add xenvb_id utility to identify Xen disk and CD-ROM devices.

What's the reason xen optical drives don't behave like real drives, and need a xen specific tool? That sounds rather odd,

They aren't proper SCSI devices so you can't do SCSI inquiry like cdrom_id wants, the properties you can query from a Xen vbd are very basic, basically just TYPE=disk|cd.

Quoted 5 lines
Quoted 2 lines

I suppose I could make the SCSI INQ stuff in cdrom_id optional, since the CDROM_GET_CAPABILITY ioctl is implemented. Would that be preferred?

Please check the stuff I put in the git tree:
http://git.kernel.org/?p=linux/hotplug/udev.git;a=commit;h=55d8f5e208396589476583dad8f2a7f2db3e2ef5

That works fine, thanks!

Ian.

Signature · 4 lines
Ian Campbell

The world really isn't any worse.  It's just that the news coverage
is so much better.