Fix xm scsi-attach/detach/list for inactive managed domains
PATCH 1/1 Fix xm scsi-attach/detach/list for inactive managed domains
Hi,
This patch fixes xm scsi-attach/detach/list command for inactive managed domains.
In inactive managed domains, xm scsi-detach command and xm scsi-list command always fail. Also xm scsi-attach command fail under certain conditions. Results of those commands are as follows.
# xm new vm1 Using config file "/etc/xen/vm1". # xm scsi-attach vm1 0:0:1:0 0:0:1:0 # xm scsi-attach vm1 0:0:2:0 0:0:2:0 Error: (22, 'Invalid argument, while reading None/device-misc/vscsi/nextDeviceID') Usage: xm scsi-attach <Domain> <PhysDevice> <VirtDevice> [BackDomain]
Attach a new SCSI device.
# xm scsi-list vm1 Idx BE state phy-hctl phy vir-hctl devstate 0 -1 -1 Unexpected error: exceptions.KeyError
Please report to [email protected] Traceback (most recent call last):
File "/usr/sbin/xm", line 10, in ?
main.main(sys.argv)
File "//usr/lib/python/xen/xm/main.py", line 2928, in main
_, rc = _run_cmd(cmd, cmd_name, args)
File "//usr/lib/python/xen/xm/main.py", line 2952, in _run_cmd
return True, cmd(args)
File "//usr/lib/python/xen/xm/main.py", line 2281, in xm_scsi_list
print "%(p-dev)-10s %(p-devname)-5s %(v-dev)-10s %(frontstate)-4s" % mi
KeyError: 'p-dev'
# xm scsi-detach vm1 0:0:1:0
Error: (22, 'Invalid argument, while reading None/device-misc/vscsi/nextDeviceID')
Usage: xm scsi-detach <Domain> <VirtDevice>Detach a specified SCSI device.
BTW, this patch separates constants in DevController.py into a new file DevConstants.py because an import error occurs when xm/main.py tries to refer to xenbusState.
Best regards,
Kan
tools/python/xen/util/diagnose.py +2 -2
@@ -23,7 +23,7 @@ from xen.xend.XendClient import server from xen.xend.XendClient import server from xen.xend.XendError import XendError from xen.xend.xenstore.xstransact import xstransact -from xen.xend.server import DevController +from xen.xend.server import DevConstants import xen.xend.XendProtocol
@@ -169,7 +169,7 @@ def diagnose_hotplugging(): def stateString(state): - return state and DevController.xenbusState[int(state)] or '<None>' + return state and DevConstants.xenbusState[int(state)] or '<None>' def main(argv = None):
tools/python/xen/xend/XendConfig.py +9 -8
@@ -1602,21 +1602,21 @@ class XendConfig(dict): # [vscsi, # [dev, # [devid, 0], [p-devname, sdb], [p-dev, 1:0:0:1], - # [v-dev, 0:0:0:0], [state, Initialising] + # [v-dev, 0:0:0:0], [state, 1] # ], # [dev, # [devid, 0], [p-devname, sdc], [p-dev, 1:0:0:2], - # [v-dev, 0:0:0:1], [satet, Initialising] + # [v-dev, 0:0:0:1], [satet, 1] # ] # ], # [vscsi, # [dev, # [devid, 1], [p-devname, sdg], [p-dev, 2:0:0:0], - # [v-dev, 1:0:0:0], [state, Initialising] + # [v-dev, 1:0:0:0], [state, 1] # ], # [dev, # [devid, 1], [p-devname, sdh], [p-dev, 2:0:0:1], - # [v-dev, 1:0:0:1], [satet, Initialising] + # [v-dev, 1:0:0:1], [satet, 1] # ] # ] # ]
@@ -1632,18 +1632,19 @@ class XendConfig(dict): # [vscsi, # [dev, # [devid, 0], [p-devname, sdd], [p-dev, 1:0:0:3], - # [v-dev, 0:0:0:2], [state, Initialising] + # [v-dev, 0:0:0:2], [state, 1] # ] # ] # ] # - # state 'Initialising' indicates that the device is being attached, - # while state 'Closing' indicates that the device is being detached. + # state xenbusState['Initialising'] indicates that the device is + # being attached, while state xenbusState['Closing'] indicates + # that the device is being detached. # # The Dict looks like this: # # { devs: [ {devid: 0, p-devname: sdd, p-dev: 1:0:0:3, - # v-dev: 0:0:0:2, state: Initialising} ] } + # v-dev: 0:0:0:2, state: 1} ] } dev_config = {}
tools/python/xen/xend/XendDomainInfo.py +53 -20
123 lines not on this page · raw message
tools/python/xen/xend/server/DevController.py +1 -28
@@ -23,41 +23,14 @@ from xen.xend.XendError import VmError from xen.xend.XendError import VmError from xen.xend.XendLogging import log import xen.xend.XendConfig +from xen.xend.server.DevConstants import * from xen.xend.xenstore.xstransact import xstransact, complete from xen.xend.xenstore.xswatch import xswatch import os -DEVICE_CREATE_TIMEOUT = 100 -DEVICE_DESTROY_TIMEOUT = 100 -HOTPLUG_STATUS_NODE = "hotplug-status" -HOTPLUG_ERROR_NODE = "hotplug-error" -HOTPLUG_STATUS_ERROR = "error" -HOTPLUG_STATUS_BUSY = "busy" - -Connected = 1 -Error = 2 -Missing = 3 -Timeout = 4 -Busy = 5 -Disconnected = 6 - -xenbusState = { - 'Unknown' : 0, - 'Initialising' : 1, - 'InitWait' : 2, - 'Initialised' : 3, - 'Connected' : 4, - 'Closing' : 5, - 'Closed' : 6, - 'Reconfiguring': 7, - 'Reconfigured' : 8, - } - xoptions = XendOptions.instance() - -xenbusState.update(dict(zip(xenbusState.values(), xenbusState.keys()))) class DevController:
tools/python/xen/xend/server/pciif.py +2 -1
@@ -25,7 +25,8 @@ from xen.xend.XendError import VmError from xen.xend.XendError import VmError from xen.xend.XendLogging import log -from xen.xend.server.DevController import DevController, xenbusState +from xen.xend.server.DevController import DevController +from xen.xend.server.DevConstants import xenbusState import xen.lowlevel.xc
tools/python/xen/xend/server/vscsiif.py +8 -7
@@ -28,7 +28,8 @@ from xen.xend.XendError import VmError from xen.xend.XendError import VmError from xen.xend.XendLogging import log -from xen.xend.server.DevController import DevController, xenbusState +from xen.xend.server.DevController import DevController +from xen.xend.server.DevConstants import xenbusState from xen.xend.xenstore.xstransact import xstransact class VSCSIController(DevController):
@@ -92,8 +93,8 @@ class VSCSIController(DevController): back[devpath + '/p-devname'] = pdevname vdev = vscsi_config.get('v-dev', '') back[devpath + '/v-dev'] = vdev - state = vscsi_config.get('state', '') - back[devpath + '/state'] = str(xenbusState[state]) + state = vscsi_config.get('state', xenbusState['Unknown']) + back[devpath + '/state'] = str(state) devid = vscsi_config.get('devid', '') back[devpath + '/devid'] = str(devid)
@@ -168,17 +169,17 @@ class VSCSIController(DevController): (devid, back, front) = self.getDeviceDetails(config) devid = int(devid) vscsi_config = config['devs'][0] - state = vscsi_config.get('state', '') + state = vscsi_config.get('state', xenbusState['Unknown']) driver_state = self.readBackend(devid, 'state') if str(xenbusState['Connected']) != driver_state: raise VmError("Driver status is not connected") uuid = self.readBackend(devid, 'uuid') - if state == 'Initialising': + if state == xenbusState['Initialising']: back['uuid'] = uuid self.writeBackend(devid, back) - elif state == 'Closing': + elif state == xenbusState['Closing']: found = False devs = self.readBackendList(devid, "vscsi-devs") vscsipath = "vscsi-devs/"
@@ -198,7 +199,7 @@ class VSCSIController(DevController): else: raise XendError("Error configuring device invalid " - "state '%s'" % state) + "state '%s'" % xenbusState[state]) self.writeBackend(devid, 'state', str(xenbusState['Reconfiguring'])) return self.readBackend(devid, 'uuid')
tools/python/xen/xm/create.py +3 -2
@@ -32,6 +32,7 @@ from xen.xend import osdep from xen.xend import osdep import xen.xend.XendClient from xen.xend.XendBootloader import bootloader +from xen.xend.server.DevConstants import xenbusState from xen.util import blkif from xen.util import vscsi_util import xen.util.xsm.xsm as security
@@ -707,7 +708,7 @@ def configure_vscsis(config_devs, vals): vscsi_util.vscsi_get_hctl_and_devname_by(p_dev, scsi_devices) if p_hctl == None: - raise ValueError("Cannot find device \"%s\"" % p_dev) + raise ValueError('Cannot find device "%s"' % p_dev) for config in config_scsi: dev = vscsi_convert_sxp_to_dict(config)
@@ -717,7 +718,7 @@ def configure_vscsis(config_devs, vals): v_hctl = v_dev.split(':') devid = int(v_hctl[0]) config_scsi.append(['dev', \ - ['state', 'Initialising'], \ + ['state', xenbusState['Initialising']], \ ['devid', devid], \ ['p-dev', p_hctl], \ ['p-devname', devname], \
tools/python/xen/xm/main.py +3 -2
@@ -47,6 +47,7 @@ from xen.xend import sxp from xen.xend import sxp from xen.xend import XendClient from xen.xend.XendConstants import * +from xen.xend.server.DevConstants import xenbusState from xen.xm.opts import OptionError, Opts, wrap, set_true from xen.xm import console
@@ -2515,7 +2516,7 @@ def xm_scsi_attach(args): dom = args[0] p_scsi = args[1] v_hctl = args[2] - scsi = parse_scsi_configuration(p_scsi, v_hctl, 'Initialising') + scsi = parse_scsi_configuration(p_scsi, v_hctl, xenbusState['Initialising']) if serverType == SERVER_XEN_API:
@@ -2635,7 +2636,7 @@ def xm_scsi_detach(args): arg_check(args, 'scsi-detach', 2) dom = args[0] v_hctl = args[1] - scsi = parse_scsi_configuration(None, v_hctl, 'Closing') + scsi = parse_scsi_configuration(None, v_hctl, xenbusState['Closing']) if serverType == SERVER_XEN_API:
tools/python/xen/xend/server/DevConstants.py new file +45 -0
45 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel