Selaa lähdekoodia

[xen] Skip probing of any unsupported device types

Xen 4.4 includes the device "device/suspend/event-channel" which does
not have a "backend" key.  This currently causes the entire XenBus
device tree probe to fail.

Fix by skipping probe attempts for device types for which there is no
iPXE driver.

Debugged-by: Eytan Heidingsfeld <eytanh@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 6 vuotta sitten
vanhempi
commit
e4461f65d8
1 muutettua tiedostoa jossa 21 lisäystä ja 18 poistoa
  1. 21
    18
      src/interface/xen/xenbus.c

+ 21
- 18
src/interface/xen/xenbus.c Näytä tiedosto

206
  *
206
  *
207
  * @v xen		Xen hypervisor
207
  * @v xen		Xen hypervisor
208
  * @v parent		Parent device
208
  * @v parent		Parent device
209
- * @v type		Device type
210
  * @v instance		Device instance
209
  * @v instance		Device instance
210
+ * @v driver		Device driver
211
  * @ret rc		Return status code
211
  * @ret rc		Return status code
212
  */
212
  */
213
 static int xenbus_probe_device ( struct xen_hypervisor *xen,
213
 static int xenbus_probe_device ( struct xen_hypervisor *xen,
214
-				 struct device *parent, const char *type,
215
-				 const char *instance ) {
214
+				 struct device *parent, const char *instance,
215
+				 struct xen_driver *driver ) {
216
+	const char *type = driver->type;
216
 	struct xen_device *xendev;
217
 	struct xen_device *xendev;
217
 	size_t key_len;
218
 	size_t key_len;
218
 	int rc;
219
 	int rc;
234
 	xendev->xen = xen;
235
 	xendev->xen = xen;
235
 	xendev->key = ( ( void * ) ( xendev + 1 ) );
236
 	xendev->key = ( ( void * ) ( xendev + 1 ) );
236
 	snprintf ( xendev->key, key_len, "device/%s/%s", type, instance );
237
 	snprintf ( xendev->key, key_len, "device/%s/%s", type, instance );
238
+	xendev->driver = driver;
239
+	xendev->dev.driver_name = driver->name;
240
+	DBGC ( xendev, "XENBUS %s has driver \"%s\"\n", xendev->key,
241
+	       xendev->driver->name );
237
 
242
 
238
 	/* Read backend key */
243
 	/* Read backend key */
239
 	if ( ( rc = xenstore_read ( xen, &xendev->backend, xendev->key,
244
 	if ( ( rc = xenstore_read ( xen, &xendev->backend, xendev->key,
253
 	DBGC ( xendev, "XENBUS %s backend=\"%s\" in domain %ld\n",
258
 	DBGC ( xendev, "XENBUS %s backend=\"%s\" in domain %ld\n",
254
 	       xendev->key, xendev->backend, xendev->backend_id );
259
 	       xendev->key, xendev->backend, xendev->backend_id );
255
 
260
 
256
-	/* Look for a driver */
257
-	xendev->driver = xenbus_find_driver ( type );
258
-	if ( ! xendev->driver ) {
259
-		DBGC ( xendev, "XENBUS %s has no driver\n", xendev->key );
260
-		/* Not a fatal error */
261
-		rc = 0;
262
-		goto err_no_driver;
263
-	}
264
-	xendev->dev.driver_name = xendev->driver->name;
265
-	DBGC ( xendev, "XENBUS %s has driver \"%s\"\n", xendev->key,
266
-	       xendev->driver->name );
267
-
268
 	/* Probe driver */
261
 	/* Probe driver */
269
 	if ( ( rc = xendev->driver->probe ( xendev ) ) != 0 ) {
262
 	if ( ( rc = xendev->driver->probe ( xendev ) ) != 0 ) {
270
 		DBGC ( xendev, "XENBUS could not probe %s: %s\n",
263
 		DBGC ( xendev, "XENBUS could not probe %s: %s\n",
276
 
269
 
277
 	xendev->driver->remove ( xendev );
270
 	xendev->driver->remove ( xendev );
278
  err_probe:
271
  err_probe:
279
- err_no_driver:
280
  err_read_backend_id:
272
  err_read_backend_id:
281
 	free ( xendev->backend );
273
 	free ( xendev->backend );
282
  err_read_backend:
274
  err_read_backend:
310
  */
302
  */
311
 static int xenbus_probe_type ( struct xen_hypervisor *xen,
303
 static int xenbus_probe_type ( struct xen_hypervisor *xen,
312
 			       struct device *parent, const char *type ) {
304
 			       struct device *parent, const char *type ) {
305
+	struct xen_driver *driver;
313
 	char *children;
306
 	char *children;
314
 	char *child;
307
 	char *child;
315
 	size_t len;
308
 	size_t len;
316
 	int rc;
309
 	int rc;
317
 
310
 
311
+	/* Look for a driver */
312
+	driver = xenbus_find_driver ( type );
313
+	if ( ! driver ) {
314
+		DBGC ( xen, "XENBUS has no driver for \"%s\" devices\n", type );
315
+		/* Not a fatal error */
316
+		rc = 0;
317
+		goto err_no_driver;
318
+	}
319
+
318
 	/* Get children of this key */
320
 	/* Get children of this key */
319
 	if ( ( rc = xenstore_directory ( xen, &children, &len, "device",
321
 	if ( ( rc = xenstore_directory ( xen, &children, &len, "device",
320
 					 type, NULL ) ) != 0 ) {
322
 					 type, NULL ) ) != 0 ) {
326
 	/* Probe each child */
328
 	/* Probe each child */
327
 	for ( child = children ; child < ( children + len ) ;
329
 	for ( child = children ; child < ( children + len ) ;
328
 	      child += ( strlen ( child ) + 1 /* NUL */ ) ) {
330
 	      child += ( strlen ( child ) + 1 /* NUL */ ) ) {
329
-		if ( ( rc = xenbus_probe_device ( xen, parent, type,
330
-						  child ) ) != 0 )
331
+		if ( ( rc = xenbus_probe_device ( xen, parent, child,
332
+						  driver ) ) != 0 )
331
 			goto err_probe_device;
333
 			goto err_probe_device;
332
 	}
334
 	}
333
 
335
 
337
  err_probe_device:
339
  err_probe_device:
338
 	free ( children );
340
 	free ( children );
339
  err_directory:
341
  err_directory:
342
+ err_no_driver:
340
 	return rc;
343
 	return rc;
341
 }
344
 }
342
 
345
 

Loading…
Peruuta
Tallenna