All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pat Campbell <plc@novell.com>
To: xen-devel <xen-devel@lists.xensource.com>
Subject: [PATCH]linux/blkfront: Add "media" file to vbd sysfs directory
Date: Tue, 29 Jul 2008 07:48:18 -0600	[thread overview]
Message-ID: <488F1FA2.5030106@novell.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 809 bytes --]

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

Signed-off-by: Pat Campbell  <plc@novell.com>



[-- Attachment #2: blkfront-sysfs.patch --]
[-- Type: text/x-patch, Size: 2556 bytes --]

diff -r 2f1355579c9c drivers/xen/blkfront/blkfront.c
--- a/drivers/xen/blkfront/blkfront.c	Mon Jul 28 11:43:36 2008 +0100
+++ b/drivers/xen/blkfront/blkfront.c	Tue Jul 29 07:19:57 2008 -0600
@@ -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);
 
diff -r 2f1355579c9c drivers/xen/blkfront/block.h
--- a/drivers/xen/blkfront/block.h	Mon Jul 28 11:43:36 2008 +0100
+++ b/drivers/xen/blkfront/block.h	Tue Jul 29 07:19:57 2008 -0600
@@ -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__ */
diff -r 2f1355579c9c drivers/xen/blkfront/vbd.c
--- a/drivers/xen/blkfront/vbd.c	Mon Jul 28 11:43:36 2008 +0100
+++ b/drivers/xen/blkfront/vbd.c	Tue Jul 29 07:19:57 2008 -0600
@@ -413,3 +413,48 @@
 	return -ENOSYS;
 }
 #endif
+
+#ifdef CONFIG_SYSFS
+static ssize_t show_media(struct device *dev,
+		                  struct device_attribute *attr, char *buf)
+{
+	struct xenbus_device *xendev = to_xenbus_device(dev);
+	struct blkfront_info *info = xendev->dev.driver_data;
+
+	if (info->gd->flags & GENHD_FL_CD)
+		return sprintf(buf, "cdrom\n");
+	return sprintf(buf, "disk\n");
+}
+
+static struct device_attribute xlvbd_attrs[] = {
+	__ATTR(media, S_IRUGO, show_media, NULL),
+};
+
+int xlvbd_sysfs_addif(struct blkfront_info *info)
+{
+	int i;
+	int error = 0;
+
+	for (i = 0; i < ARRAY_SIZE(xlvbd_attrs); i++) {
+		error = device_create_file(info->gd->driverfs_dev,
+				&xlvbd_attrs[i]);
+		if (error)
+			goto fail;
+	}
+	return 0;
+
+fail:
+	while (--i >= 0)
+		device_remove_file(info->gd->driverfs_dev, &xlvbd_attrs[i]);
+	return error;
+}
+
+void xlvbd_sysfs_delif(struct blkfront_info *info)
+{
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(xlvbd_attrs); i++)
+		device_remove_file(info->gd->driverfs_dev, &xlvbd_attrs[i]);
+}
+
+#endif /* CONFIG_SYSFS */

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

                 reply	other threads:[~2008-07-29 13:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=488F1FA2.5030106@novell.com \
    --to=plc@novell.com \
    --cc=xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.