svn commit: r250917 - head/sys/xen/xenbus

Justin T. Gibbs gibbs at FreeBSD.org
Wed May 22 19:22:45 UTC 2013


Author: gibbs
Date: Wed May 22 19:22:44 2013
New Revision: 250917
URL: http://svnweb.freebsd.org/changeset/base/250917

Log:
  Fix loss of the emulated keyboard on Xen PV HVM domains.
  
  xen/xenbus/xenbusb.c:
      In xenbusb_probe_children(), do not modify the XenBus state of
      devices for which we have no PV driver support. An emulated device
      we do support may share this backend.  Hide the node from XenBus
      instead.
  
      This prevents closing the vkbd device, which Qemu's emulated keyboard
      device is using as the source for keyboard events.
  
      Tested with qemu-xen-traditional, qemu-xen and qemu stubdomains, all
      working as expected.
  
  Submitted by:	Roger Pau Monne <roger.pau at citrix.com>
  Reviewed by:	gibbs
  MFC after:	1 week

Modified:
  head/sys/xen/xenbus/xenbusb.c

Modified: head/sys/xen/xenbus/xenbusb.c
==============================================================================
--- head/sys/xen/xenbus/xenbusb.c	Wed May 22 19:00:05 2013	(r250916)
+++ head/sys/xen/xenbus/xenbusb.c	Wed May 22 19:22:44 2013	(r250917)
@@ -404,6 +404,31 @@ xenbusb_device_sysctl_init(device_t dev)
 }
 
 /**
+ * \brief Decrement the number of XenBus child devices in the
+ *        connecting state by one and release the xbs_attch_ch
+ *        interrupt configuration hook if the connecting count
+ *        drops to zero.
+ *
+ * \param xbs  XenBus Bus device softc of the owner of the bus to enumerate.
+ */
+static void
+xenbusb_release_confighook(struct xenbusb_softc *xbs)
+{
+	mtx_lock(&xbs->xbs_lock);
+	KASSERT(xbs->xbs_connecting_children > 0,
+		("Connecting device count error\n"));
+	xbs->xbs_connecting_children--;
+	if (xbs->xbs_connecting_children == 0
+	 && (xbs->xbs_flags & XBS_ATTACH_CH_ACTIVE) != 0) {
+		xbs->xbs_flags &= ~XBS_ATTACH_CH_ACTIVE;
+		mtx_unlock(&xbs->xbs_lock);
+		config_intrhook_disestablish(&xbs->xbs_attach_ch);
+	} else {
+		mtx_unlock(&xbs->xbs_lock);
+	}
+}
+
+/**
  * \brief Verify the existance of attached device instances and perform
  *        probe/attach processing for newly arrived devices.
  *
@@ -417,7 +442,7 @@ xenbusb_probe_children(device_t dev)
 {
 	device_t *kids;
 	struct xenbus_device_ivars *ivars;
-	int i, count;
+	int i, count, error;
 
 	if (device_get_children(dev, &kids, &count) == 0) {
 		for (i = 0; i < count; i++) {
@@ -430,7 +455,30 @@ xenbusb_probe_children(device_t dev)
 				continue;
 			}
 
-			if (device_probe_and_attach(kids[i])) {
+			error = device_probe_and_attach(kids[i]);
+			if (error == ENXIO) {
+				struct xenbusb_softc *xbs;
+
+				/*
+				 * We don't have a PV driver for this device.
+				 * However, an emulated device we do support
+				 * may share this backend.  Hide the node from
+				 * XenBus until the next rescan, but leave it's
+				 * state unchanged so we don't inadvertently
+				 * prevent attachment of any emulated device.
+				 */
+				xenbusb_delete_child(dev, kids[i]);
+
+				/*
+				 * Since the XenStore state of this device
+				 * still indicates a pending attach, manually
+				 * release it's hold on the boot process.
+				 */
+				xbs = device_get_softc(dev);
+				xenbusb_release_confighook(xbs);
+
+				continue;
+			} else if (error) {
 				/*
 				 * Transition device to the closed state
 				 * so the world knows that attachment will
@@ -579,31 +627,6 @@ xenbusb_nop_confighook_cb(void *arg __un
 {
 }
 
-/**
- * \brief Decrement the number of XenBus child devices in the
- *        connecting state by one and release the xbs_attch_ch
- *        interrupt configuration hook if the connecting count
- *        drops to zero.
- *
- * \param xbs  XenBus Bus device softc of the owner of the bus to enumerate.
- */
-static void
-xenbusb_release_confighook(struct xenbusb_softc *xbs)
-{
-	mtx_lock(&xbs->xbs_lock);
-	KASSERT(xbs->xbs_connecting_children > 0,
-		("Connecting device count error\n"));
-	xbs->xbs_connecting_children--;
-	if (xbs->xbs_connecting_children == 0
-	 && (xbs->xbs_flags & XBS_ATTACH_CH_ACTIVE) != 0) {
-		xbs->xbs_flags &= ~XBS_ATTACH_CH_ACTIVE;
-		mtx_unlock(&xbs->xbs_lock);
-		config_intrhook_disestablish(&xbs->xbs_attach_ch);
-	} else {
-		mtx_unlock(&xbs->xbs_lock);
-	}
-}
-
 /*--------------------------- Public Functions -------------------------------*/
 /*--------- API comments for these methods can be found in xenbusb.h ---------*/
 void


More information about the svn-src-all mailing list