If a guest finds any error and aborts the connection of a block device,
it's online state set at device create phase will stop it from being
properly cleaned up.
Follows a fix for it.
--
Glauber de Oliveira Costa
Red Hat Inc.
"Free as in Freedom"
# HG changeset patch
# User gcosta@xxxxxxxxxx
# Date 1165272179 18000
# Node ID 6702c80880a1ed7e7467a59135f3764fb145cd0b
# Parent fd28a1b139dea91b8bfcf06dd233dbdda8f51ff1
[LINUX] Get rid of device if block-attach fails
The current backend code checks to see if a device is online
before unregistering it. However, when block attach fails
due to a guest failure, guest is the one to start closing protocols,
and state is never set to offline again.
Proposal is to check if there are error entries in xenstore,
and unregister if it is the case.
Signed-off-by: Glauber de Oliveira Costa <gcosta@xxxxxxxxxx>
diff -r fd28a1b139de -r 6702c80880a1
linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Mon Dec 04 09:29:26
2006 +0000
+++ b/linux-2.6-xen-sparse/drivers/xen/blkback/xenbus.c Mon Dec 04 17:42:59
2006 -0500
@@ -306,6 +306,32 @@ static void backend_changed(struct xenbu
}
+static int dev_had_error(struct xenbus_device *dev)
+{
+ int err;
+ unsigned int virtual_device, frontend_id;
+ char *path = NULL;
+
+ err = xenbus_scanf(XBT_NIL, dev->otherend,
+ "virtual-device", "%u",
&virtual_device);
+ if (err < 0)
+ return 0;
+
+ err = xenbus_scanf(XBT_NIL, dev->nodename,
+ "frontend-id", "%u", &frontend_id);
+ if (err < 0)
+ return 0;
+
+ path = kasprintf(GFP_KERNEL, "%u/error/device/vbd/%u",
+ frontend_id,virtual_device);
+ if (!path)
+ return 0;
+
+ err = xenbus_exists(XBT_NIL,"/local/domain",path);
+ kfree(path);
+ return err;
+}
+
/**
* Callback received when the frontend's state changes.
*/
@@ -347,7 +373,7 @@ static void frontend_changed(struct xenb
case XenbusStateClosed:
xenbus_switch_state(dev, XenbusStateClosed);
- if (xenbus_dev_is_online(dev))
+ if (xenbus_dev_is_online(dev) && !dev_had_error(dev))
break;
/* fall through if not online */
case XenbusStateUnknown:
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|