mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
Implement xm block-configure for CD-ROMs.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
This commit is contained in:
1 parent
9c4e5c70be
commit
99c694310f
5 files changed
+54
-15
No files matched your search
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -24,6 +24,7 @@ from xen.util.xmlrpclib2 import UnixXMLRPCServer, TCPXMLRPCServer
|
||||
|
||||
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']
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#============================================================================
|
||||
# Copyright (C) 2004, 2005 Mike Wray <mike.wray@hp.com>
|
||||
# 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"""
|
||||
|
||||
|
||||
@@ -113,6 +113,8 @@ block_detach_help = """block-detach <DomId> <DevId> Destroy a domain's virtu
|
||||
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,9 +1089,23 @@ 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):
|
||||
arg_check(args, 'network-attach', 1, 10000)
|
||||
|
||||
@@ -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,
|
||||
|
||||