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
|