WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [Xend] Add a --force option to detach ope

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [Xend] Add a --force option to detach operations.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 14 Dec 2006 12:50:13 +0000
Delivery-date: Thu, 14 Dec 2006 04:49:32 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Node ID ef5e6df3ba9e74419c882c0cdacac9fc7ba1c178
# Parent  997f2bbb5cbc9d9b3518fef9459d0b07f18de0ff
[Xend] Add a --force option to detach operations.

In some situations triggered by errors found on guest side,
the device will be held forever, due to the online flag being still
on. Detach operations mostly fails from this point on, as the backend
will not see frontend's state change anymore.

Signed-off-by: Glauber de Oliveira Costa <gcosta@xxxxxxxxxx>
---
 tools/python/xen/xend/XendDomainInfo.py       |    4 ++--
 tools/python/xen/xend/server/DevController.py |    9 ++++++++-
 tools/python/xen/xend/server/blkif.py         |    6 +++---
 tools/python/xen/xm/main.py                   |   17 ++++++++++++-----
 4 files changed, 25 insertions(+), 11 deletions(-)

diff -r 997f2bbb5cbc -r ef5e6df3ba9e tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Thu Dec 14 10:01:17 2006 +0000
+++ b/tools/python/xen/xend/XendDomainInfo.py   Thu Dec 14 10:17:37 2006 +0000
@@ -563,7 +563,7 @@ class XendDomainInfo:
         for devclass in XendDevices.valid_devices():
             self.getDeviceController(devclass).waitForDevices()
 
-    def destroyDevice(self, deviceClass, devid):
+    def destroyDevice(self, deviceClass, devid, force=None):
         try:
             devid = int(devid)
         except ValueError:
@@ -578,7 +578,7 @@ class XendDomainInfo:
                     devid = entry
                     break
                 
-        return self.getDeviceController(deviceClass).destroyDevice(devid)
+        return self.getDeviceController(deviceClass).destroyDevice(devid, 
force)
 
 
 
diff -r 997f2bbb5cbc -r ef5e6df3ba9e 
tools/python/xen/xend/server/DevController.py
--- a/tools/python/xen/xend/server/DevController.py     Thu Dec 14 10:01:17 
2006 +0000
+++ b/tools/python/xen/xend/server/DevController.py     Thu Dec 14 10:17:37 
2006 +0000
@@ -195,7 +195,7 @@ class DevController:
         raise VmError('%s devices may not be reconfigured' % self.deviceClass)
 
 
-    def destroyDevice(self, devid):
+    def destroyDevice(self, devid, force):
         """Destroy the specified device.
 
         @param devid The device ID, or something device-specific from which
@@ -215,6 +215,13 @@ class DevController:
         # drivers, so this ordering avoids a race).
         self.writeBackend(devid, 'online', "0")
         self.writeBackend(devid, 'state', str(xenbusState['Closing']))
+
+        if force:
+            frontpath = self.frontendPath(devid)
+            backpath = xstransact.Read(frontpath, "backend")
+            if backpath:
+                xstransact.Remove(backpath)
+            xstransact.Remove(frontpath)
 
 
     def configurations(self):
diff -r 997f2bbb5cbc -r ef5e6df3ba9e tools/python/xen/xend/server/blkif.py
--- a/tools/python/xen/xend/server/blkif.py     Thu Dec 14 10:01:17 2006 +0000
+++ b/tools/python/xen/xend/server/blkif.py     Thu Dec 14 10:17:37 2006 +0000
@@ -133,7 +133,7 @@ class BlkifController(DevController):
 
         return config
 
-    def destroyDevice(self, devid):
+    def destroyDevice(self, devid, force):
         """@see DevController.destroyDevice"""
 
         # If we are given a device name, then look up the device ID from it,
@@ -142,13 +142,13 @@ class BlkifController(DevController):
         # superclass's method.
 
         try:
-            DevController.destroyDevice(self, int(devid))
+            DevController.destroyDevice(self, int(devid), force)
         except ValueError:
             devid_end = type(devid) is str and devid.split('/')[-1] or None
 
             for i in self.deviceIDs():
                 d = self.readBackend(i, 'dev')
                 if d == devid or (devid_end and d == devid_end):
-                    DevController.destroyDevice(self, i)
+                    DevController.destroyDevice(self, i, force)
                     return
             raise VmError("Device %s not connected" % devid)
diff -r 997f2bbb5cbc -r ef5e6df3ba9e tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py       Thu Dec 14 10:01:17 2006 +0000
+++ b/tools/python/xen/xm/main.py       Thu Dec 14 10:17:37 2006 +0000
@@ -142,14 +142,14 @@ SUBCOMMAND_HELP = {
                         'Create a new virtual block device.'),
     'block-configure': ('<Domain> <BackDev> <FrontDev> <Mode> [BackDomain]',
                         'Change block device configuration'),
-    'block-detach'  :  ('<Domain> <DevId>',
+    'block-detach'  :  ('<Domain> <DevId> [-f|--force]',
                         'Destroy a domain\'s virtual block device.'),
     'block-list'    :  ('<Domain> [--long]',
                         'List virtual block devices for a domain.'),
     'network-attach':  ('<Domain> [--script=<script>] [--ip=<ip>] '
                         '[--mac=<mac>]',
                         'Create a new virtual network device.'),
-    'network-detach':  ('<Domain> <DevId>',
+    'network-detach':  ('<Domain> <DevId> [-f|--force]',
                         'Destroy a domain\'s virtual network device.'),
     'network-list'  :  ('<Domain> [--long]',
                         'List virtual network interfaces for a domain.'),
@@ -1493,12 +1493,19 @@ def xm_network_attach(args):
 
 
 def detach(args, command, deviceClass):
-    arg_check(args, command, 2)
+    arg_check(args, command, 2, 3)
 
     dom = args[0]
     dev = args[1]
-
-    server.xend.domain.destroyDevice(dom, deviceClass, dev)
+    try:
+        force = args[2]
+        if (force != "--force") and (force != "-f"):
+            print "Ignoring option %s"%(force)
+            force = None
+    except IndexError:
+        force = None
+
+    server.xend.domain.destroyDevice(dom, deviceClass, dev, force)
 
 
 def xm_block_detach(args):

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [Xend] Add a --force option to detach operations., Xen patchbot-unstable <=