[arch-releng] [PATCH] Fix detection of virtio block devices

Kevin Shanahan kmshanah at disenchant.net
Thu Feb 16 19:41:04 EST 2012


When installing on a KVM guest with virtio block devices, the disk
detection fails because of missing 'type' file in sysfs for these
devices. Try identifying via the 'vendor' file if 'type' is missing.

Signed-off-by: Kevin Shanahan <kmshanah at disenchant.net>
---
 src/core/libs/lib-blockdevices-filesystems.sh |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh
index 84a6b34..8f67e65 100644
--- a/src/core/libs/lib-blockdevices-filesystems.sh
+++ b/src/core/libs/lib-blockdevices-filesystems.sh
@@ -225,6 +225,16 @@ finddisks() {
 				echo -ne "/dev/$DEVNAME $1"
 				unset DEVNAME
 			fi
+		elif [[ -f $dev/device/vendor ]]; then
+			local vendor
+			read vendor < /sys/block/${dev##*/}/device/vendor
+			# Virtio disks (/dev/vd*) don't have a the 'type' file in sysfs
+			# but seem to have a vendor file with a unique value
+			if [[ "$vendor" = "0x1af4" ]]; then
+				source "$dev/uevent"
+				echo -ne "/dev/$DEVNAME $1"
+				unset DEVNAME
+			fi
 		fi
 	done
 
-- 
1.7.9.1



More information about the arch-releng mailing list