aboutsummaryrefslogtreecommitdiff
path: root/hw/xen_backend.c
diff options
context:
space:
mode:
authorJohn Haxby <john.haxby@oracle.com>2011-06-17 12:15:35 +0000
committerStefano Stabellini <stefano.stabellini@eu.citrix.com>2011-09-09 13:13:16 +0000
commit384087b2fec0da72238e92a0c6124579117e0c4b (patch)
tree8fa78910a65fd5b553bc41c4d65310c536edf494 /hw/xen_backend.c
parent07ff2c4475df77e38a31d50ee7f3932631806c15 (diff)
Introduce a new 'connected' xendev op called when Connected.
Rename the existing xendev 'connect' op to 'initialised' and introduce a new 'connected' op. This new op, if defined, is called when the backend is connected. Note that since there is no state transition this may be called more than once. Signed-off-by: John Haxby <john.haxby@oracle.com> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Diffstat (limited to 'hw/xen_backend.c')
-rw-r--r--hw/xen_backend.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/hw/xen_backend.c b/hw/xen_backend.c
index aa642675f8..d876cabb12 100644
--- a/hw/xen_backend.c
+++ b/hw/xen_backend.c
@@ -421,13 +421,13 @@ static int xen_be_try_init(struct XenDevice *xendev)
}
/*
- * Try to connect xendev. Depends on the frontend being ready
+ * Try to initialise xendev. Depends on the frontend being ready
* for it (shared ring and evtchn info in xenstore, state being
* Initialised or Connected).
*
* Goes to Connected on success.
*/
-static int xen_be_try_connect(struct XenDevice *xendev)
+static int xen_be_try_initialise(struct XenDevice *xendev)
{
int rc = 0;
@@ -441,11 +441,11 @@ static int xen_be_try_connect(struct XenDevice *xendev)
}
}
- if (xendev->ops->connect) {
- rc = xendev->ops->connect(xendev);
+ if (xendev->ops->initialise) {
+ rc = xendev->ops->initialise(xendev);
}
if (rc != 0) {
- xen_be_printf(xendev, 0, "connect() failed\n");
+ xen_be_printf(xendev, 0, "initialise() failed\n");
return rc;
}
@@ -454,6 +454,29 @@ static int xen_be_try_connect(struct XenDevice *xendev)
}
/*
+ * Try to let xendev know that it is connected. Depends on the
+ * frontend being Connected. Note that this may be called more
+ * than once since the backend state is not modified.
+ */
+static void xen_be_try_connected(struct XenDevice *xendev)
+{
+ if (!xendev->ops->connected) {
+ return;
+ }
+
+ if (xendev->fe_state != XenbusStateConnected) {
+ if (xendev->ops->flags & DEVOPS_FLAG_IGNORE_STATE) {
+ xen_be_printf(xendev, 2, "frontend not ready, ignoring\n");
+ } else {
+ xen_be_printf(xendev, 2, "frontend not ready (yet)\n");
+ return;
+ }
+ }
+
+ xendev->ops->connected(xendev);
+}
+
+/*
* Teardown connection.
*
* Goes to Closed when done.
@@ -508,7 +531,12 @@ void xen_be_check_state(struct XenDevice *xendev)
rc = xen_be_try_init(xendev);
break;
case XenbusStateInitWait:
- rc = xen_be_try_connect(xendev);
+ rc = xen_be_try_initialise(xendev);
+ break;
+ case XenbusStateConnected:
+ /* xendev->be_state doesn't change */
+ xen_be_try_connected(xendev);
+ rc = -1;
break;
case XenbusStateClosed:
rc = xen_be_try_reset(xendev);