From: Jean Guyader Date: Wed, 4 Nov 2009 05:25:56 +0000 (+0000) Subject: Add an argument to v2v_accept, to have a non blocking version. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=61b8306b232aede7a3d71f22b9033b4ddb126b5c;p=xenclient%2Flinux-2.6.27-pq.git Add an argument to v2v_accept, to have a non blocking version. --- diff --git a/master/series b/master/series index 9d164dd..33a4d80 100644 --- a/master/series +++ b/master/series @@ -355,3 +355,4 @@ bsg-add-global-sgio-mutex.patch itpm v2v-core v2v-async +v2v-accept-nonblock diff --git a/master/v2v-accept-nonblock b/master/v2v-accept-nonblock new file mode 100644 index 0000000..6de0e49 --- /dev/null +++ b/master/v2v-accept-nonblock @@ -0,0 +1,65 @@ +diff --git a/drivers/xen/v2v/v2v.c b/drivers/xen/v2v/v2v.c +index 57d51be..304f421 100644 +--- a/drivers/xen/v2v/v2v.c ++++ b/drivers/xen/v2v/v2v.c +@@ -792,7 +792,7 @@ v2v_get_remote_state(struct v2v_channel *channel, enum v2v_endpoint_state *state + EXPORT_SYMBOL_GPL(v2v_get_remote_state); + + int +-v2v_accept(struct v2v_channel *channel) ++v2v_accept(struct v2v_channel *channel, int nonblock) + { + int err = 0; + struct xenbus_transaction xbt = {0}; +@@ -807,8 +807,9 @@ v2v_accept(struct v2v_channel *channel) + case v2v_state_disconnected: + case v2v_state_crashed: + xenbus_transaction_end(xbt, 1); +- wait_event(channel->wait_state.wait_event, +- atomic_xchg(&channel->wait_state.wait_condition, 0) == 1); ++ if (!noblock) ++ wait_event(channel->wait_state.wait_event, ++ atomic_xchg(&channel->wait_state.wait_condition, 0) == 1); + /* ### get the event reason, should be only the control event right now */ + reason = v2v_wrq_dequeue(channel, V2V_WAKE_REASON_ANY); + if (reason != V2V_WAKE_REASON_CONTROL) { +@@ -842,6 +843,8 @@ v2v_accept(struct v2v_channel *channel) + EPRINTK("v2v_accept - error commiting xs transaction - err: %d\n", err); + return err; + } ++ if (noblock) ++ return -EAGAIN; + break; /* try again */ + } + } +diff --git a/drivers/xen/v2v/v2vops.c b/drivers/xen/v2v/v2vops.c +index 83854a2..66bfe93 100644 +--- a/drivers/xen/v2v/v2vops.c ++++ b/drivers/xen/v2v/v2vops.c +@@ -752,7 +752,7 @@ v2vdrv_listen_accept(struct v2vdrv_context *ctx) + printk("%s listener(%p) listener started, wait to accept...\n", V2VDRV_LOGTAG, ctx); + + /* Wait to accept the connection from the connector end */ +- err = v2v_accept(ctx->channel); ++ err = v2v_accept(ctx->channel, 0); + if (err) { + if (err != -ENOLINK) + printk("%s listener(%p) failure in v2v_accept() - error: %d\n", V2VDRV_LOGTAG, ctx, err); +diff --git a/include/xen/v2v.h b/include/xen/v2v.h +index 5233f80..8542037 100644 +--- a/include/xen/v2v.h ++++ b/include/xen/v2v.h +@@ -118,10 +118,12 @@ int v2v_listen(const char *xenbus_prefix, + + /* Wait for a remote domain to connect to the channel @channel, which + * should have been allocated with v2v_listen(). ++ * @nonblock, doesn't wait if set, return EAGAIN if the connector is ++ * not ready. + * + * Returns 0 on success and an appropriate errno code on failure. + */ +-int v2v_accept(struct v2v_channel *channel); ++int v2v_accept(struct v2v_channel *channel, int nonblock); + + /* Connect to a VM-to-VM channel specified by @xenbus_prefix, which + * should previously have been initialised by the tools, and place the