]> xenbits.xensource.com Git - mini-os.git/commitdiff
mini-os: netfront: Handle init failure when no vifs are provided
authorCostin Lupu <costin.lupu@cs.pub.ro>
Tue, 15 Dec 2020 16:50:12 +0000 (16:50 +0000)
committerWei Liu <wl@xen.org>
Tue, 15 Dec 2020 16:52:00 +0000 (16:52 +0000)
These changes deal with the case when no vifs are created. This can happen when
no vif is provided in the config file for mini-os images with netfront support.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Samuel Thibault <samuel.thibault@@ens-lyon.org>
lwip-net.c
netfront.c

index 7e0d8719577e32d76623253da91343071018fc28..16950d322d66521dcc069cde2f33072f24a3e7b4 100644 (file)
@@ -348,6 +348,10 @@ void start_networking(void)
   tprintk("Waiting for network.\n");
 
   dev = init_netfront(NULL, NULL, rawmac, &ip);
+  if (!dev) {
+      tprintk("Error initializing netfront.\n");
+      return;
+  }
   netmask_str = netfront_get_netmask(dev);
   gw_str = netfront_get_gateway(dev);
   
index 20754102566fdbbd92d7e5ce16f9e2e33f448b13..f927e99cd501009ab84d6b08dcd57645f1e48f5f 100644 (file)
@@ -383,6 +383,7 @@ char *netfront_get_gateway(struct netfront_dev *dev)
 
 static struct netfront_dev *_init_netfront(struct netfront_dev *dev)
 {
+    int domid;
     xenbus_transaction_t xbt;
     char* err = NULL;
     char* message=NULL;
@@ -393,6 +394,12 @@ static struct netfront_dev *_init_netfront(struct netfront_dev *dev)
     int i;
     char path[256];
 
+    snprintf(path, sizeof(path), "%s/backend-id", dev->nodename);
+    domid = xenbus_read_integer(path);
+    if (domid < 0)
+        return NULL;
+    dev->dom = domid;
+
     printk("net TX ring size %lu\n", (unsigned long) NET_TX_RING_SIZE);
     printk("net RX ring size %lu\n", (unsigned long) NET_RX_RING_SIZE);
     init_SEMAPHORE(&dev->tx_sem, NET_TX_RING_SIZE);
@@ -407,8 +414,6 @@ static struct netfront_dev *_init_netfront(struct netfront_dev *dev)
         BUG_ON(dev->rx_buffers[i].page == NULL);
     }
 
-    snprintf(path, sizeof(path), "%s/backend-id", dev->nodename);
-    dev->dom = xenbus_read_integer(path);
 #ifdef HAVE_LIBC
     if (dev->netif_rx == NETIF_SELECT_RX)
         evtchn_alloc_unbound(dev->dom, netfront_select_handler, dev, &dev->evtchn);