From 453c7b64421b0520de33fdc130863f60a0f1bf9c Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Tue, 6 Apr 2010 07:13:19 +0100 Subject: 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 --- extras/mini-os/blkfront.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'extras/mini-os/blkfront.c') diff --git a/extras/mini-os/blkfront.c b/extras/mini-os/blkfront.c index e06cf9f94a..9862fb9acb 100644 --- a/extras/mini-os/blkfront.c +++ b/extras/mini-os/blkfront.c @@ -152,13 +152,12 @@ 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); if (retry) { @@ -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); -- cgit v1.2.3