[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] qemu: react to XenbusStateClosing



Qemu was not reacting when setting xenstore state of a device to
XenbusStateClosing (5). This patch makes qemu react to this state and
close the appropiate device.

Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>
---
 hw/xen_backend.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/hw/xen_backend.c b/hw/xen_backend.c
index 64dc93a..4e4dd77 100644
--- a/hw/xen_backend.c
+++ b/hw/xen_backend.c
@@ -285,11 +285,23 @@ static struct XenDevice *xen_be_del_xendev(int dom, int 
dev)
  */
 static void xen_be_backend_changed(struct XenDevice *xendev, const char *node)
 {
+    int be_state;
+
     if (node == NULL  ||  strcmp(node, "online") == 0) {
        if (xenstore_read_be_int(xendev, "online", &xendev->online) == -1)
            xendev->online = 0;
     }
 
+    if (node != NULL && strcmp(node, "state") == 0) {
+        if (xenstore_read_be_int(xendev, "state", &be_state) == -1) {
+            xendev->be_state = XenbusStateUnknown;
+        } else if (xendev->be_state == be_state) {
+            return;
+        } else {
+            xendev->be_state = be_state;
+        }
+    }
+
     if (node) {
        xen_be_printf(xendev, 2, "backend update: %s\n", node);
        if (xendev->ops->backend_changed)
@@ -461,8 +473,7 @@ static void xen_be_try_connected(struct XenDevice *xendev)
  */
 static void xen_be_disconnect(struct XenDevice *xendev, enum xenbus_state 
state)
 {
-    if (xendev->be_state != XenbusStateClosing &&
-        xendev->be_state != XenbusStateClosed  &&
+    if (xendev->be_state != XenbusStateClosed  &&
         xendev->ops->disconnect)
        xendev->ops->disconnect(xendev);
     if (xendev->be_state != state)
@@ -513,6 +524,9 @@ void xen_be_check_state(struct XenDevice *xendev)
            xen_be_try_connected(xendev);
            rc = -1;
            break;
+    case XenbusStateClosing:
+        xen_be_disconnect(xendev, XenbusStateClosed);
+        break;
         case XenbusStateClosed:
             rc = xen_be_try_reset(xendev);
             break;
-- 
1.7.2.5


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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.