# HG changeset patch
# User emellor@ewan
# Node ID f5320ac7ed317ab4dfe3b3b44d1ac21c79324d37
# Parent cd228621e1fd4bc0f404b80e6c618ae02d0c1173
Remove xm commands block-refresh and vbd-refresh, as these are unsupported.
Allow xm block-detach to take a device name as well as a device ID. This
closes bug #285 and fixes xm-test's 01_block-destroy_btblock_pos.py and
02_block-destroy_rtblock_pos.py.
Rename and reconnect XendDomainInfo.configureDevice to reconfigureDevice.
There is nothing using this at the moment, mind you.
Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>
diff -r cd228621e1fd -r f5320ac7ed31 tools/python/xen/xend/XendClient.py
--- a/tools/python/xen/xend/XendClient.py Thu Oct 6 14:12:31 2005
+++ b/tools/python/xen/xend/XendClient.py Thu Oct 6 18:41:29 2005
@@ -306,22 +306,22 @@
{'op' : 'device_create',
'config' : fileof(config) })
- def xend_domain_device_refresh(self, id, type, idx):
+ def xend_domain_device_refresh(self, id, type, dev):
return self.xendPost(self.domainurl(id),
{'op' : 'device_refresh',
'type' : type,
- 'idx' : idx })
-
- def xend_domain_device_destroy(self, id, type, idx):
+ 'dev' : dev })
+
+ def xend_domain_device_destroy(self, id, type, dev):
return self.xendPost(self.domainurl(id),
{'op' : 'device_destroy',
'type' : type,
- 'idx' : idx })
-
- def xend_domain_device_configure(self, id, config, idx):
+ 'dev' : dev })
+
+ def xend_domain_device_configure(self, id, config, dev):
return self.xendPost(self.domainurl(id),
{'op' : 'device_configure',
- 'idx' : idx,
+ 'dev' : dev,
'config' : fileof(config) })
def xend_vnets(self):
diff -r cd228621e1fd -r f5320ac7ed31 tools/python/xen/xend/XendDomain.py
--- a/tools/python/xen/xend/XendDomain.py Thu Oct 6 14:12:31 2005
+++ b/tools/python/xen/xend/XendDomain.py Thu Oct 6 18:41:29 2005
@@ -492,13 +492,6 @@
devconfig, devid)
- def domain_device_refresh(self, domid, devtype, devid):
- """Refresh a device."""
- return self.callInfo(domid,
- XendDomainInfo.XendDomainInfo.device_refresh,
- devtype, devid)
-
-
def domain_device_destroy(self, domid, devtype, devid):
"""Destroy a device."""
return self.callInfo(domid,
diff -r cd228621e1fd -r f5320ac7ed31 tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py Thu Oct 6 14:12:31 2005
+++ b/tools/python/xen/xend/XendDomainInfo.py Thu Oct 6 18:41:29 2005
@@ -876,24 +876,28 @@
__repr__ = __str__
+ ## private:
+
def createDevice(self, deviceClass, devconfig):
return self.getDeviceController(deviceClass).createDevice(devconfig)
- def configureDevice(self, deviceClass, devid, devconfig):
- return self.getDeviceController(deviceClass).configureDevice(
+ def reconfigureDevice(self, deviceClass, devid, devconfig):
+ return self.getDeviceController(deviceClass).reconfigureDevice(
devid, devconfig)
+
+ ## public:
def destroyDevice(self, deviceClass, devid):
return self.getDeviceController(deviceClass).destroyDevice(devid)
+ ## private:
+
def getDeviceSxprs(self, deviceClass):
return self.getDeviceController(deviceClass).sxprs()
-
- ## private:
def getDeviceConfigurations(self, deviceClass):
return self.getDeviceController(deviceClass).configurations()
@@ -1234,7 +1238,7 @@
@param devid: device id
"""
deviceClass = sxp.name(dev_config)
- self.configureDevice(deviceClass, devid, dev_config)
+ self.reconfigureDevice(deviceClass, devid, dev_config)
## private:
diff -r cd228621e1fd -r f5320ac7ed31
tools/python/xen/xend/server/DevController.py
--- a/tools/python/xen/xend/server/DevController.py Thu Oct 6 14:12:31 2005
+++ b/tools/python/xen/xend/server/DevController.py Thu Oct 6 18:41:29 2005
@@ -86,8 +86,7 @@
def configurations(self):
- return map(lambda x: self.configuration(int(x)),
- xstransact.List(self.frontendRoot()))
+ return map(self.configuration, self.deviceIDs())
def configuration(self, devid):
@@ -176,7 +175,14 @@
return xstransact.Read(backpath, *args)
- ## private:
+ def deviceIDs(self):
+ """@return The IDs of each of the devices currently configured for
+ this instance's deviceClass.
+ """
+ return map(int, xstransact.List(self.frontendRoot()))
+
+
+## private:
def writeDetails(self, config, devid, backDetails, frontDetails):
"""Write the details in the store to trigger creation of a device.
diff -r cd228621e1fd -r f5320ac7ed31 tools/python/xen/xend/server/SrvDomain.py
--- a/tools/python/xen/xend/server/SrvDomain.py Thu Oct 6 14:12:31 2005
+++ b/tools/python/xen/xend/server/SrvDomain.py Thu Oct 6 18:41:29 2005
@@ -156,19 +156,11 @@
val = fn(req.args, {'dom': self.dom.domid})
return val
- def op_device_refresh(self, op, req):
- fn = FormFn(self.xd.domain_device_refresh,
- [['dom', 'int'],
- ['type', 'str'],
- ['idx', 'int']])
- val = fn(req.args, {'dom': self.dom.domid})
- return val
-
def op_device_destroy(self, op, req):
fn = FormFn(self.xd.domain_device_destroy,
[['dom', 'int'],
['type', 'str'],
- ['idx', 'int']])
+ ['dev', 'str']])
val = fn(req.args, {'dom': self.dom.domid})
return val
@@ -176,7 +168,7 @@
fn = FormFn(self.xd.domain_device_configure,
[['dom', 'int'],
['config', 'sxpr'],
- ['idx', 'int']])
+ ['dev', 'str']])
val = fn(req.args, {'dom': self.dom.domid})
return val
diff -r cd228621e1fd -r f5320ac7ed31 tools/python/xen/xend/server/blkif.py
--- a/tools/python/xen/xend/server/blkif.py Thu Oct 6 14:12:31 2005
+++ b/tools/python/xen/xend/server/blkif.py Thu Oct 6 18:41:29 2005
@@ -23,7 +23,7 @@
from xen.util import blkif
from xen.xend import sxp
-from xen.xend.server.DevController import DevController
+from DevController import DevController
class BlkifController(DevController):
@@ -79,3 +79,23 @@
result.append(['mode', 'w'])
return result
+
+
+ def destroyDevice(self, devid):
+ """@see DevController.destroyDevice"""
+
+ # If we are given a device name, then look up the device ID from it,
+ # and destroy that ID instead. If what we are given is an integer,
+ # then assume it's a device ID and pass it straight through to our
+ # superclass's method.
+
+ try:
+ DevController.destroyDevice(self, int(devid))
+ except ValueError:
+ for i in self.deviceIDs():
+ if self.readBackend(i, 'dev') == devid:
+ DevController.destroyDevice(self, i)
+ return
+ # Try this, but it's almost certainly going to throw VmError,
+ # since we can't find the device.
+ DevController.destroyDevice(self, int(devid))
diff -r cd228621e1fd -r f5320ac7ed31 tools/python/xen/xm/main.py
--- a/tools/python/xen/xm/main.py Thu Oct 6 14:12:31 2005
+++ b/tools/python/xen/xm/main.py Thu Oct 6 18:41:29 2005
@@ -106,9 +106,10 @@
Virtual Device Commands:
block-attach <DomId> <BackDev> <FrontDev> <Mode> [BackDomId]
Create a new virtual block device
- block-detach <DomId> <DevId> Destroy a domain's virtual block device
+ block-detach <DomId> <DevId> Destroy a domain's virtual block device,
+ where <DevId> may either be the device ID
+ or the device name as mounted in the guest.
block-list <DomId> List virtual block devices for a domain
- block-refresh <DomId> <DevId> Refresh a virtual block device for a domain
network-limit <DomId> <Vif> <Credit> <Period>
Limit the transmission rate of a virtual network interface
network-list <DomId> List virtual network interfaces for a domain
@@ -522,25 +523,11 @@
from xen.xend.XendClient import server
server.xend_domain_device_create(dom, vbd)
-def xm_block_refresh(args):
- arg_check(args,2,"block-refresh")
-
- dom = args[0]
- dev = args[1]
-
- from xen.xend.XendClient import server
- server.xend_domain_device_refresh(dom, 'vbd', dev)
-
def xm_block_detach(args):
arg_check(args,2,"block-detach")
dom = args[0]
-
- try:
- dev = int(args[1])
- except ValueError, e:
- err("Invalid device id: %s" % args[1])
- sys.exit(1)
+ dev = args[1]
from xen.xend.XendClient import server
server.xend_domain_device_destroy(dom, 'vbd', dev)
@@ -622,7 +609,6 @@
"block-attach": xm_block_attach,
"block-detach": xm_block_detach,
"block-list": xm_block_list,
- "block-refresh": xm_block_refresh,
# network
"network-limit": xm_network_limit,
"network-list": xm_network_list,
@@ -651,7 +637,6 @@
"vbd-create": "block-create",
"vbd-destroy": "block-destroy",
"vbd-list": "block-list",
- "vbd-refresh": "block-refresh",
}
help = {
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|