Blob Blame History Raw
From: K. Y. Srinivasan <ksrinivasan@novell.com>
Subject: In HVM guests do not take over the CDROM device
References: bnc#645893
Patch-mainline: n/a

Signed-off-by: K. Y. Srinivasan <ksrinivasan@novell.com> 

ohering@novell.com: return -ENXIO instead of 0 when ignoring (bnc#672004)

--- head.orig/drivers/xen/blkfront/blkfront.c	2012-06-12 15:39:55.000000000 +0200
+++ head/drivers/xen/blkfront/blkfront.c	2012-06-12 15:39:59.000000000 +0200
@@ -88,6 +88,26 @@ static int blkfront_probe(struct xenbus_
 	int err, vdevice, i;
 	struct blkfront_info *info;
 
+#ifndef CONFIG_XEN /* For HVM guests, do not take over CDROM devices. */
+	char *type;
+
+	type = xenbus_read(XBT_NIL, dev->nodename, "device-type", NULL);
+	if (IS_ERR(type)) {
+		xenbus_dev_fatal(dev, PTR_ERR(type), "reading dev type");
+		return PTR_ERR(type);
+	}
+	if (!strncmp(type, "cdrom", 5)) {
+		/*
+		 * We are handed a cdrom device in a hvm guest; let the
+		 * native cdrom driver handle this device.
+		 */
+		kfree(type);
+		pr_notice("blkfront: ignoring CDROM %s\n", dev->nodename);
+		return -ENXIO;
+	}
+	kfree(type);
+#endif
+
 	/* FIXME: Use dynamic device id if this is not set. */
 	err = xenbus_scanf(XBT_NIL, dev->nodename,
 			   "virtual-device", "%i", &vdevice);
--- head.orig/drivers/xen/blkfront/block.h	2012-06-08 10:40:36.000000000 +0200
+++ head/drivers/xen/blkfront/block.h	2012-06-08 10:40:41.000000000 +0200
@@ -159,7 +159,12 @@ static inline void xlvbd_sysfs_delif(str
 void xlbd_release_major_info(void);
 
 /* Virtual cdrom block-device */
+#ifdef CONFIG_XEN
 extern void register_vcd(struct blkfront_info *info);
 extern void unregister_vcd(struct blkfront_info *info);
+#else
+static inline void register_vcd(struct blkfront_info *info) {}
+static inline void unregister_vcd(struct blkfront_info *info) {}
+#endif
 
 #endif /* __XEN_DRIVERS_BLOCK_H__ */