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@xensource.com>
This commit is contained in:
emellor@ewan committed 2005-10-06 19:41:29 +01:00
1 parent 0c6f366280
commit fa670bf40e
7 files changed
+51 -51

No files matched your search

+6 -6
View File
@@ -306,22 +306,22 @@ class Xend:
{'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 })
'dev' : dev })
def xend_domain_device_destroy(self, id, type, idx):
def xend_domain_device_destroy(self, id, type, dev):
return self.xendPost(self.domainurl(id),
{'op' : 'device_destroy',
'type' : type,
'idx' : idx })
'dev' : dev })
def xend_domain_device_configure(self, id, config, idx):
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):
-7
View File
@@ -492,13 +492,6 @@ class XendDomain:
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,
+9 -5
View File
@@ -876,25 +876,29 @@ class XendDomainInfo:
__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 @@ class XendDomainInfo:
@param devid: device id
"""
deviceClass = sxp.name(dev_config)
self.configureDevice(deviceClass, devid, dev_config)
self.reconfigureDevice(deviceClass, devid, dev_config)
## private:
@@ -86,8 +86,7 @@ class DevController:
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 @@ class DevController:
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.
+2 -10
View File
@@ -156,19 +156,11 @@ class SrvDomain(SrvDir):
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 @@ class SrvDomain(SrvDir):
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
+21 -1
View File
@@ -23,7 +23,7 @@ import string
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 @@ class BlkifController(DevController):
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))
+4 -19
View File
@@ -106,9 +106,10 @@ xm full list of subcommands:
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 @@ def xm_block_attach(args):
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 @@ commands = {
"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 @@ aliases = {
"vbd-create": "block-create",
"vbd-destroy": "block-destroy",
"vbd-list": "block-list",
"vbd-refresh": "block-refresh",
}
help = {
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.