From: K. Y. Srinivasan <ksrinivasan@novell.com>
Subject: In HVM guests do not take over the CDROM device
References: bnc#645893, bnc#688483
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)

--- sle11sp4.orig/drivers/xen/blkfront/blkfront.c	2014-01-29 13:17:51.000000000 +0100
+++ sle11sp4/drivers/xen/blkfront/blkfront.c	2012-10-24 11:26:26.000000000 +0200
@@ -104,6 +104,26 @@ static int blkfront_probe(struct xenbus_
 	struct blkfront_info *info;
 	enum xenbus_state backend_state;
 
+#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);
--- sle11sp4.orig/drivers/xen/blkfront/block.h	2012-10-24 11:26:10.000000000 +0200
+++ sle11sp4/drivers/xen/blkfront/block.h	2012-10-24 11:26:28.000000000 +0200
@@ -171,7 +171,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__ */
