[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] mini-os: Fix xenbus initialisation



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1270534399 -3600
# Node ID b20f897d6010457ec507138d450a332eba5147ea
# Parent  a3f7352d83eb6332aa89874ca58863807e8efacd
mini-os: Fix xenbus initialisation

This fixes xenbus initialization of blkfront, netfront and pcifront
by uniformizing with fbfront: after writing parameters, set state to
initialised, then wait for backend to switch to connect state, and
then only read its parameter and switch to the connect state.

Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>
---
 extras/mini-os/blkfront.c |   19 +++++++++++++++----
 extras/mini-os/fbfront.c  |    5 +++--
 extras/mini-os/netfront.c |   16 ++++++++++++++--
 extras/mini-os/pcifront.c |   11 ++++++-----
 4 files changed, 38 insertions(+), 13 deletions(-)

diff -r a3f7352d83eb -r b20f897d6010 extras/mini-os/blkfront.c
--- a/extras/mini-os/blkfront.c Tue Apr 06 07:13:01 2010 +0100
+++ b/extras/mini-os/blkfront.c Tue Apr 06 07:13:19 2010 +0100
@@ -152,12 +152,11 @@ again:
     }
 
     snprintf(path, sizeof(path), "%s/state", nodename);
-    err = xenbus_switch_state(xbt, path, XenbusStateConnected);
+    err = xenbus_switch_state(xbt, path, XenbusStateInitialised);
     if (err) {
-        message = "switching state";
+        printk("error writing blk initialized on %s: %s\n", path, err);
         goto abort_transaction;
     }
-
 
     err = xenbus_transaction_end(xbt, 0, &retry);
     if (err) free(err);
@@ -189,6 +188,7 @@ done:
     {
         XenbusState state;
         char path[strlen(dev->backend) + 1 + 19 + 1];
+        char frontpath[strlen(nodename) + 1 + 6 + 1];
         snprintf(path, sizeof(path), "%s/mode", dev->backend);
         msg = xenbus_read(XBT_NIL, path, &c);
         if (msg) {
@@ -232,7 +232,18 @@ done:
         dev->info.flush = xenbus_read_integer(path);
 
         *info = dev->info;
-    }
+
+        printk("%s connected\n", dev->backend);
+
+        snprintf(frontpath, sizeof(frontpath), "%s/state", nodename);
+        if((err = xenbus_switch_state(XBT_NIL, frontpath, 
XenbusStateConnected))
+            != NULL) {
+            printk("error switching state: %s\n", err);
+            xenbus_unwatch_path_token(XBT_NIL, path, path);
+            goto error;
+        }
+    }
+
     unmask_evtchn(dev->evtchn);
 
     printk("%u sectors of %u bytes\n", dev->info.sectors, 
dev->info.sector_size);
diff -r a3f7352d83eb -r b20f897d6010 extras/mini-os/fbfront.c
--- a/extras/mini-os/fbfront.c  Tue Apr 06 07:13:01 2010 +0100
+++ b/extras/mini-os/fbfront.c  Tue Apr 06 07:13:19 2010 +0100
@@ -126,8 +126,8 @@ again:
     snprintf(path, sizeof(path), "%s/state", nodename);
     err = xenbus_switch_state(xbt, path, XenbusStateInitialised);
     if (err) {
-        printk("error writing initialized: %s\n", err);
-        free(err);
+        printk("error writing fb initialized: %s\n", err);
+        goto abort_transaction;
     }
 
     err = xenbus_transaction_end(xbt, 0, &retry);
@@ -189,6 +189,7 @@ done:
     printk("************************** KBDFRONT\n");
 
     return dev;
+
 error:
     free(msg);
     free(err);
diff -r a3f7352d83eb -r b20f897d6010 extras/mini-os/netfront.c
--- a/extras/mini-os/netfront.c Tue Apr 06 07:13:01 2010 +0100
+++ b/extras/mini-os/netfront.c Tue Apr 06 07:13:19 2010 +0100
@@ -407,9 +407,9 @@ again:
     }
 
     snprintf(path, sizeof(path), "%s/state", nodename);
-    err = xenbus_switch_state(xbt, path, XenbusStateConnected);
+    err = xenbus_switch_state(xbt, path, XenbusStateInitialised);
     if (err) {
-        message = "switching state";
+        printk("error writing net initialized: %s\n", err);
         goto abort_transaction;
     }
 
@@ -445,6 +445,7 @@ done:
     {
         XenbusState state;
         char path[strlen(dev->backend) + 1 + 5 + 1];
+        char frontpath[strlen(nodename) + 1 + 6 + 1];
         snprintf(path, sizeof(path), "%s/state", dev->backend);
 
         xenbus_watch_path_token(XBT_NIL, path, path, &dev->events);
@@ -462,6 +463,16 @@ done:
         if (ip) {
             snprintf(path, sizeof(path), "%s/ip", dev->backend);
             xenbus_read(XBT_NIL, path, ip);
+        }
+
+        printk("%s connected\n", dev->backend);
+
+        snprintf(frontpath, sizeof(frontpath), "%s/state", nodename);
+        if((err = xenbus_switch_state(XBT_NIL, frontpath, 
XenbusStateConnected))
+            != NULL) {
+            printk("error switching state: %s\n", err);
+            xenbus_unwatch_path_token(XBT_NIL, path, path);
+            goto error;
         }
     }
 
@@ -481,6 +492,7 @@ done:
             &rawmac[5]);
 
     return dev;
+
 error:
     free(msg);
     free(err);
diff -r a3f7352d83eb -r b20f897d6010 extras/mini-os/pcifront.c
--- a/extras/mini-os/pcifront.c Tue Apr 06 07:13:01 2010 +0100
+++ b/extras/mini-os/pcifront.c Tue Apr 06 07:13:19 2010 +0100
@@ -143,7 +143,7 @@ struct pcifront_dev *init_pcifront(char 
     char* err;
     char* message=NULL;
     int retry=0;
-    char* msg;
+    char* msg = NULL;
     char* nodename = _nodename ? _nodename : "device/pci/0";
     int dom;
 
@@ -206,7 +206,7 @@ again:
     snprintf(path, sizeof(path), "%s/state", nodename);
     err = xenbus_switch_state(xbt, path, XenbusStateInitialised);
     if (err) {
-        message = "switching state";
+        printk("error writing pci initialized: %s\n", err);
         goto abort_transaction;
     }
 
@@ -237,7 +237,7 @@ done:
 
     {
         char path[strlen(dev->backend) + 1 + 5 + 1];
-        char frontpath[strlen(nodename) + 1 + 5 + 1];
+        char frontpath[strlen(nodename) + 1 + 6 + 1];
         XenbusState state;
         snprintf(path, sizeof(path), "%s/state", dev->backend);
 
@@ -254,9 +254,9 @@ done:
         }
 
         snprintf(frontpath, sizeof(frontpath), "%s/state", nodename);
-        if ((err = xenbus_switch_state(XBT_NIL, frontpath, 
XenbusStateConnected))
+        if((err = xenbus_switch_state(XBT_NIL, frontpath, 
XenbusStateConnected))
             != NULL) {
-            printk("error switching state %s\n", err);
+            printk("error switching state: %s\n", err);
             xenbus_unwatch_path_token(XBT_NIL, path, path);
             goto error;
         }
@@ -271,6 +271,7 @@ done:
     return dev;
 
 error:
+    free(msg);
     free(err);
     free_pcifront(dev);
     return NULL;

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.