WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] mini-os: Fix xenbus initialisation

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] mini-os: Fix xenbus initialisation
From: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>
Date: Tue, 6 Apr 2010 01:27:48 +0200
Delivery-date: Mon, 05 Apr 2010 16:28:08 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Mail-followup-to: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.12-2006-07-14
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>

diff -r ebd84be3420a extras/mini-os/blkfront.c
--- a/extras/mini-os/blkfront.c Tue Mar 30 18:31:39 2010 +0100
+++ b/extras/mini-os/blkfront.c Tue Apr 06 01:24:28 2010 +0200
@@ -152,13 +152,12 @@
     }
 
     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);
     if (retry) {
@@ -189,6 +188,7 @@
     {
         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 @@
         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 ebd84be3420a extras/mini-os/fbfront.c
--- a/extras/mini-os/fbfront.c  Tue Mar 30 18:31:39 2010 +0100
+++ b/extras/mini-os/fbfront.c  Tue Apr 06 01:24:28 2010 +0200
@@ -126,8 +126,8 @@
     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 @@
     printk("************************** KBDFRONT\n");
 
     return dev;
+
 error:
     free(msg);
     free(err);
diff -r ebd84be3420a extras/mini-os/netfront.c
--- a/extras/mini-os/netfront.c Tue Mar 30 18:31:39 2010 +0100
+++ b/extras/mini-os/netfront.c Tue Apr 06 01:24:28 2010 +0200
@@ -407,9 +407,9 @@
     }
 
     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 @@
     {
         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);
@@ -463,6 +464,16 @@
             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;
+        }
     }
 
     printk("**************************\n");
@@ -481,6 +492,7 @@
             &rawmac[5]);
 
     return dev;
+
 error:
     free(msg);
     free(err);
diff -r ebd84be3420a extras/mini-os/pcifront.c
--- a/extras/mini-os/pcifront.c Tue Mar 30 18:31:39 2010 +0100
+++ b/extras/mini-os/pcifront.c Tue Apr 06 01:24:28 2010 +0200
@@ -143,7 +143,7 @@
     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 @@
     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 @@
 
     {
         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 @@
         }
 
         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 @@
     return dev;
 
 error:
+    free(msg);
     free(err);
     free_pcifront(dev);
     return NULL;

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

<Prev in Thread] Current Thread [Next in Thread>