瀏覽代碼

[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 7 年之前
父節點
當前提交
e4461f65d8
共有 1 個檔案被更改,包括 21 行新增18 行删除
  1. 21
    18
      src/interface/xen/xenbus.c

+ 21
- 18
src/interface/xen/xenbus.c 查看文件

@@ -206,13 +206,14 @@ static struct xen_driver * xenbus_find_driver ( const char *type ) {
206 206
  *
207 207
  * @v xen		Xen hypervisor
208 208
  * @v parent		Parent device
209
- * @v type		Device type
210 209
  * @v instance		Device instance
210
+ * @v driver		Device driver
211 211
  * @ret rc		Return status code
212 212
  */
213 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 217
 	struct xen_device *xendev;
217 218
 	size_t key_len;
218 219
 	int rc;
@@ -234,6 +235,10 @@ static int xenbus_probe_device ( struct xen_hypervisor *xen,
234 235
 	xendev->xen = xen;
235 236
 	xendev->key = ( ( void * ) ( xendev + 1 ) );
236 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 243
 	/* Read backend key */
239 244
 	if ( ( rc = xenstore_read ( xen, &xendev->backend, xendev->key,
@@ -253,18 +258,6 @@ static int xenbus_probe_device ( struct xen_hypervisor *xen,
253 258
 	DBGC ( xendev, "XENBUS %s backend=\"%s\" in domain %ld\n",
254 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 261
 	/* Probe driver */
269 262
 	if ( ( rc = xendev->driver->probe ( xendev ) ) != 0 ) {
270 263
 		DBGC ( xendev, "XENBUS could not probe %s: %s\n",
@@ -276,7 +269,6 @@ static int xenbus_probe_device ( struct xen_hypervisor *xen,
276 269
 
277 270
 	xendev->driver->remove ( xendev );
278 271
  err_probe:
279
- err_no_driver:
280 272
  err_read_backend_id:
281 273
 	free ( xendev->backend );
282 274
  err_read_backend:
@@ -310,11 +302,21 @@ static void xenbus_remove_device ( struct xen_device *xendev ) {
310 302
  */
311 303
 static int xenbus_probe_type ( struct xen_hypervisor *xen,
312 304
 			       struct device *parent, const char *type ) {
305
+	struct xen_driver *driver;
313 306
 	char *children;
314 307
 	char *child;
315 308
 	size_t len;
316 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 320
 	/* Get children of this key */
319 321
 	if ( ( rc = xenstore_directory ( xen, &children, &len, "device",
320 322
 					 type, NULL ) ) != 0 ) {
@@ -326,8 +328,8 @@ static int xenbus_probe_type ( struct xen_hypervisor *xen,
326 328
 	/* Probe each child */
327 329
 	for ( child = children ; child < ( children + len ) ;
328 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 333
 			goto err_probe_device;
332 334
 	}
333 335
 
@@ -337,6 +339,7 @@ static int xenbus_probe_type ( struct xen_hypervisor *xen,
337 339
  err_probe_device:
338 340
 	free ( children );
339 341
  err_directory:
342
+ err_no_driver:
340 343
 	return rc;
341 344
 }
342 345
 

Loading…
取消
儲存