Skip to contentSkip to conversation

linux/blkfront: Add "media" file to vbd sysfs directory

PATCH New Pat Campbell 1 participant 1 message Jul 29, 2008 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux/blkfront: Add "media" file to vbd sysfs directory

Patch adds "media" file to the vbd sysfs directory. File contains a string, cdrom or disk.

Currently all PV vbd devices are seen by HAL as "disk". Applications that query HAL info.capabilities attribute to determine a block devices capabilities fail to see a PV cdrom as having CDROM capabilities. With the attached patch and a small corresponding patch to HAL, applications that query HAL for the storage type of the block device will see it as a disk or a cdrom. Standard Linux IDE devices use this same mechanism.

lshal of vbd without patches:
info.capabilities = {'storage', 'block'} (string list)
lshal of vbd with patches:
info.capabilities = {'storage', 'block', 'storage.cdrom'} (string list)

Please apply to tip of linux-2.6.18-xen.hg

drivers/xen/blkfront/blkfront.c +9 -0
diff -r 2f1355579c9c drivers/xen/blkfront/blkfront.c
@@ -352,6 +352,13 @@
 		return;
 	}
 
+	err = xlvbd_sysfs_addif(info);
+	if (err) {
+		xenbus_dev_fatal(info->xbdev, err, "xlvbd_sysfs_addif at %s",
+				 info->xbdev->otherend);
+		return;
+	}
+
 	(void)xenbus_switch_state(info->xbdev, XenbusStateConnected);
 
 	/* Kick pending requests. */
@@ -390,6 +397,8 @@
 
 	/* Flush gnttab callback work. Must be done with no locks held. */
 	flush_scheduled_work();
+
+	xlvbd_sysfs_delif(info);
 
 	xlvbd_del(info);
 
drivers/xen/blkfront/block.h +15 -0
diff -r 2f1355579c9c drivers/xen/blkfront/block.h
@@ -140,4 +140,19 @@
 void xlvbd_del(struct blkfront_info *info);
 int xlvbd_barrier(struct blkfront_info *info);
 
+#ifdef CONFIG_SYSFS
+int xlvbd_sysfs_addif(struct blkfront_info *info);
+void xlvbd_sysfs_delif(struct blkfront_info *info);
+#else
+static inline int xlvbd_sysfs_addif(struct blkfront_info *info)
+{
+	return 0;
+}
+
+static inline void xlvbd_sysfs_delif(struct blkfront_info *info)
+{
+	;
+}
+#endif
+
 #endif /* __XEN_DRIVERS_BLOCK_H__ */
drivers/xen/blkfront/vbd.c +45 -0

48 lines not on this page · raw message

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel