[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] Implement xm block-configure for CD-ROMs.
# HG changeset patch # User emellor@xxxxxxxxxxxxxxxxxxxxxx # Node ID ff124973a28ae61bac91e68e55efa7c52d75802d # Parent 716ef8e8bddcd1b3b677f46d1d7de1d1d89e77db Implement xm block-configure for CD-ROMs. Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx> --- tools/python/xen/xend/XendDomainInfo.py | 5 ++--- tools/python/xen/xend/server/DevController.py | 22 +++++++++++++--------- tools/python/xen/xend/server/XMLRPCServer.py | 4 +++- tools/python/xen/xend/server/blkif.py | 19 ++++++++++++++++++- tools/python/xen/xm/main.py | 23 ++++++++++++++++++++--- 5 files changed, 56 insertions(+), 17 deletions(-) diff -r 716ef8e8bddc -r ff124973a28a tools/python/xen/xend/XendDomainInfo.py --- a/tools/python/xen/xend/XendDomainInfo.py Wed Aug 16 11:58:48 2006 +0100 +++ b/tools/python/xen/xend/XendDomainInfo.py Wed Aug 16 12:59:30 2006 +0100 @@ -1527,13 +1527,12 @@ class XendDomainInfo: return self.getDeviceController(dev_type).sxpr(devid) - def device_configure(self, dev_config, devid): + def device_configure(self, dev_config): """Configure an existing device. @param dev_config: device configuration - @param devid: device id """ deviceClass = sxp.name(dev_config) - self.reconfigureDevice(deviceClass, devid, dev_config) + self.reconfigureDevice(deviceClass, None, dev_config) def pause(self): diff -r 716ef8e8bddc -r ff124973a28a tools/python/xen/xend/server/DevController.py --- a/tools/python/xen/xend/server/DevController.py Wed Aug 16 11:58:48 2006 +0100 +++ b/tools/python/xen/xend/server/DevController.py Wed Aug 16 12:59:30 2006 +0100 @@ -206,15 +206,9 @@ class DevController: """ devid = int(devid) - - frontpath = self.frontendPath(devid) - backpath = xstransact.Read(frontpath, "backend") - - if backpath: - xstransact.Write(backpath, 'state', str(xenbusState['Closing'])) - else: - raise VmError("Device %s not connected" % devid) - + + self.writeBackend(devid, 'state', str(xenbusState['Closing'])) + def configurations(self): return map(self.configuration, self.deviceIDs()) @@ -355,6 +349,16 @@ class DevController: return map(int, xstransact.List(fe)) + def writeBackend(self, devid, *args): + frontpath = self.frontendPath(devid) + backpath = xstransact.Read(frontpath, "backend") + + if backpath: + xstransact.Write(backpath, *args) + else: + raise VmError("Device %s not connected" % devid) + + ## private: def addStoreEntries(self, config, devid, backDetails, frontDetails): diff -r 716ef8e8bddc -r ff124973a28a tools/python/xen/xend/server/XMLRPCServer.py --- a/tools/python/xen/xend/server/XMLRPCServer.py Wed Aug 16 11:58:48 2006 +0100 +++ b/tools/python/xen/xend/server/XMLRPCServer.py Wed Aug 16 12:59:30 2006 +0100 @@ -24,6 +24,7 @@ from xen.util.xmlrpclib2 import UnixXMLR from xen.xend.XendClient import XML_RPC_SOCKET, ERROR_INVALID_DOMAIN from xen.xend.XendError import * +from xen.xend.XendLogging import log from types import ListType def lookup(domid): @@ -74,7 +75,8 @@ def get_log(): finally: f.close() -methods = ['device_create', 'destroyDevice', 'getDeviceSxprs', +methods = ['device_create', 'device_configure', 'destroyDevice', + 'getDeviceSxprs', 'setMemoryTarget', 'setName', 'setVCpuCount', 'shutdown', 'send_sysrq', 'getVCPUInfo', 'waitForDevices'] diff -r 716ef8e8bddc -r ff124973a28a tools/python/xen/xend/server/blkif.py --- a/tools/python/xen/xend/server/blkif.py Wed Aug 16 11:58:48 2006 +0100 +++ b/tools/python/xen/xend/server/blkif.py Wed Aug 16 12:59:30 2006 +0100 @@ -13,7 +13,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #============================================================================ # Copyright (C) 2004, 2005 Mike Wray <mike.wray@xxxxxx> -# Copyright (C) 2005 XenSource Ltd +# Copyright (C) 2005, 2006 XenSource Inc. #============================================================================ @@ -76,6 +76,23 @@ class BlkifController(DevController): return (devid, back, front) + def reconfigureDevice(self, _, config): + """@see DevController.reconfigureDevice""" + (devid, new_back, new_front) = self.getDeviceDetails(config) + + (dev, mode) = self.readBackend(devid, 'dev', 'mode') + dev_type = self.readFrontend(devid, 'device-type') + + if (dev_type == 'cdrom' and new_front['device-type'] == 'cdrom' and + dev == new_back['dev'] and mode == 'r'): + self.writeBackend(devid, + 'type', new_back['type'], + 'params', new_back['params']) + else: + raise VmError('Refusing to reconfigure device %s:%d to %s' % + (self.deviceClass, devid, config)) + + def configuration(self, devid): """@see DevController.configuration""" diff -r 716ef8e8bddc -r ff124973a28a tools/python/xen/xm/main.py --- a/tools/python/xen/xm/main.py Wed Aug 16 11:58:48 2006 +0100 +++ b/tools/python/xen/xm/main.py Wed Aug 16 12:59:30 2006 +0100 @@ -113,6 +113,8 @@ block_detach_help = """block-detach <Do or the device name as mounted in the guest""" block_list_help = "block-list <DomId> [--long] List virtual block devices for a domain" +block_configure_help = """block-configure <DomId> <BackDev> <FrontDev> <Mode> + [BackDomId] Change block device configuration""" network_attach_help = """network-attach <DomID> [script=<script>] [ip=<ip>] [mac=<mac>] [bridge=<bridge>] [backend=<backDomID>] Create a new virtual network device """ @@ -199,6 +201,7 @@ device_commands = [ "block-attach", "block-detach", "block-list", + "block-configure", "network-attach", "network-detach", "network-list", @@ -1055,9 +1058,8 @@ def xm_vtpm_list(args): "%(be-path)-30s " % ni) -def xm_block_attach(args): - arg_check(args, 'block-attach', 4, 5) - + +def parse_block_configuration(args): dom = args[0] if args[1].startswith('tap:'): @@ -1087,7 +1089,21 @@ def xm_block_attach(args): traceback.print_exc(limit=1) sys.exit(1) + return (dom, vbd) + + +def xm_block_attach(args): + arg_check(args, 'block-attach', 4, 5) + + (dom, vbd) = parse_block_configuration(args) server.xend.domain.device_create(dom, vbd) + + +def xm_block_configure(args): + arg_check(args, 'block-configure', 4, 5) + + (dom, vbd) = parse_block_configuration(args) + server.xend.domain.device_configure(dom, vbd) def xm_network_attach(args): @@ -1201,6 +1217,7 @@ commands = { "block-attach": xm_block_attach, "block-detach": xm_block_detach, "block-list": xm_block_list, + "block-configure": xm_block_configure, # network "network-attach": xm_network_attach, "network-detach": xm_network_detach, _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |