merge with xen-unstable.hg

This commit is contained in:
Alex Williamson committed 2007-07-02 12:19:26 -06:00
commit 19472a02dd
63 files changed
+949 -548

No files matched your search

+9
View File
@@ -27,6 +27,7 @@ LIB_64_ARCHS = [ 'x86_64', 's390x', 'sparc64']
import os
import os.path
import sys
def execute(exe, args = None):
@@ -47,6 +48,14 @@ def path():
def libpath():
machine = os.uname()[4]
if sys.argv[0] != '-c':
prefix = os.path.dirname(os.path.dirname(sys.argv[0]))
path = os.path.join(prefix, os.path.basename(LIB_64))
if machine in LIB_64_ARCHS and os.path.exists(path):
return path
path = os.path.join(prefix, os.path.basename(LIB_32))
if os.path.exists(path):
return path
if machine in LIB_64_ARCHS and os.path.exists(LIB_64):
return LIB_64
else:
+2
View File
@@ -148,6 +148,8 @@ def save(fd, dominfo, network, live, dst, checkpoint=False):
except:
log.exception("Failed to reset the migrating domain's name")
raise exn
def restore(xd, fd, dominfo = None, paused = False):
signature = read_exact(fd, len(SIGNATURE),
+86 -15
View File
@@ -28,6 +28,7 @@ from xen.xend.XendDevices import XendDevices
from xen.xend.PrettyPrint import prettyprintstring
from xen.xend.XendConstants import DOM_STATE_HALTED
from xen.xend.server.netif import randomMAC
from xen.util.blkif import blkdev_name_to_number
log = logging.getLogger("xend.XendConfig")
log.setLevel(logging.WARN)
@@ -934,6 +935,62 @@ class XendConfig(dict):
return sxpr
def _blkdev_name_to_number(self, dev):
if 'ioemu:' in dev:
_, dev = dev.split(':', 1)
try:
dev, _ = dev.split(':', 1)
except ValueError:
pass
try:
devid = int(dev)
except ValueError:
# devid is not a number but a string containing either device
# name (e.g. xvda) or device_type/device_id (e.g. vbd/51728)
dev2 = type(dev) is str and dev.split('/')[-1] or None
if dev2 == None:
log.debug("Could not check the device %s", dev)
return None
try:
devid = int(dev2)
except ValueError:
devid = blkdev_name_to_number(dev2)
if devid == None:
log.debug("The device %s is not device name", dev2)
return None
return devid
def device_duplicate_check(self, dev_type, dev_info, defined_config):
defined_devices_sxpr = self.all_devices_sxpr(target = defined_config)
if dev_type == 'vbd':
dev_uname = dev_info.get('uname')
blkdev_name = dev_info.get('dev')
devid = self._blkdev_name_to_number(blkdev_name)
if devid == None:
return
for o_dev_type, o_dev_info in defined_devices_sxpr:
if dev_type == o_dev_type:
if dev_uname == sxp.child_value(o_dev_info, 'uname'):
raise XendConfigError('The uname "%s" is already defined' %
dev_uname)
o_blkdev_name = sxp.child_value(o_dev_info, 'dev')
o_devid = self._blkdev_name_to_number(o_blkdev_name)
if o_devid != None and devid == o_devid:
raise XendConfigError('The device "%s" is already defined' %
blkdev_name)
elif dev_type == 'vif':
dev_mac = dev_info.get('mac')
for o_dev_type, o_dev_info in defined_devices_sxpr:
if dev_type == o_dev_type:
if dev_mac == sxp.child_value(o_dev_info, 'mac'):
raise XendConfigError('The mac "%s" is already defined' %
dev_mac)
def device_add(self, dev_type, cfg_sxp = None, cfg_xenapi = None,
target = None):
"""Add a device configuration in SXP format or XenAPI struct format.
@@ -998,6 +1055,8 @@ class XendConfig(dict):
if not dev_info.get('mac'):
dev_info['mac'] = randomMAC()
self.device_duplicate_check(dev_type, dev_info, target)
# create uuid if it doesn't exist
dev_uuid = dev_info.get('uuid', None)
if not dev_uuid:
@@ -1275,15 +1334,19 @@ class XendConfig(dict):
return False
def device_sxpr(self, dev_uuid = None, dev_type = None, dev_info = None):
def device_sxpr(self, dev_uuid = None, dev_type = None, dev_info = None, target = None):
"""Get Device SXPR by either giving the device UUID or (type, config).
@rtype: list of lists
@return: device config sxpr
"""
sxpr = []
if dev_uuid != None and dev_uuid in self['devices']:
dev_type, dev_info = self['devices'][dev_uuid]
if target == None:
target = self
if dev_uuid != None and dev_uuid in target['devices']:
dev_type, dev_info = target['devices'][dev_uuid]
if dev_type == None or dev_info == None:
raise XendConfigError("Required either UUID or device type and "
@@ -1300,8 +1363,12 @@ class XendConfig(dict):
return sxpr
def ordered_device_refs(self):
def ordered_device_refs(self, target = None):
result = []
if target == None:
target = self
# vkbd devices *must* be before vfb devices, otherwise
# there is a race condition when setting up devices
# where the daemon spawned for the vfb may write stuff
@@ -1309,27 +1376,30 @@ class XendConfig(dict):
# setup permissions on the vkbd backend path. This race
# results in domain creation failing with 'device already
# connected' messages
result.extend([u for u in self['devices'].keys() if self['devices'][u][0] == 'vkbd'])
result.extend([u for u in target['devices'].keys() if target['devices'][u][0] == 'vkbd'])
result.extend(self['console_refs'] +
self['vbd_refs'] +
self['vif_refs'] +
self['vtpm_refs'])
result.extend(target.get('console_refs', []) +
target.get('vbd_refs', []) +
target.get('vif_refs', []) +
target.get('vtpm_refs', []))
result.extend([u for u in self['devices'].keys() if u not in result])
result.extend([u for u in target['devices'].keys() if u not in result])
return result
def all_devices_sxpr(self):
def all_devices_sxpr(self, target = None):
"""Returns the SXPR for all devices in the current configuration."""
sxprs = []
pci_devs = []
if 'devices' not in self:
if target == None:
target = self
if 'devices' not in target:
return sxprs
ordered_refs = self.ordered_device_refs()
ordered_refs = self.ordered_device_refs(target = target)
for dev_uuid in ordered_refs:
dev_type, dev_info = self['devices'][dev_uuid]
dev_type, dev_info = target['devices'][dev_uuid]
if dev_type == 'pci': # special case for pci devices
sxpr = [['uuid', dev_info['uuid']]]
for pci_dev_info in dev_info['devs']:
@@ -1340,7 +1410,8 @@ class XendConfig(dict):
sxprs.append((dev_type, sxpr))
else:
sxpr = self.device_sxpr(dev_type = dev_type,
dev_info = dev_info)
dev_info = dev_info,
target = target)
sxprs.append((dev_type, sxpr))
return sxprs
+3 -1
View File
@@ -1262,8 +1262,10 @@ class XendDomain:
try:
XendCheckpoint.save(fd, dominfo, False, False, dst,
checkpoint=checkpoint)
finally:
except Exception, e:
os.close(fd)
raise e
os.close(fd)
except OSError, ex:
raise XendError("can't write guest state file %s: %s" %
(dst, ex[1]))
+1 -1
View File
@@ -61,7 +61,7 @@ class IRQController(DevController):
pirq = get_param('irq')
rc = xc.domain_irq_permission(dom = self.getDomid(),
rc = xc.domain_irq_permission(domid = self.getDomid(),
pirq = pirq,
allow_access = True)
+3
View File
@@ -185,3 +185,6 @@ class PciController(DevController):
def waitForBackend(self,devid):
return (0, "ok - no hotplug")
def migrate(self, config, network, dst, step, domName):
raise XendError('Migration not permitted with assigned PCI device.')
+7 -7
View File
@@ -2168,9 +2168,7 @@ def xm_network_attach(args):
server.xend.domain.device_create(dom, vif)
def detach(args, command, deviceClass):
arg_check(args, command, 2, 3)
def detach(args, deviceClass):
dom = args[0]
dev = args[1]
try:
@@ -2204,16 +2202,17 @@ def xm_block_detach(args):
raise OptionError("Cannot find device '%s' in domain '%s'"
% (dev,dom))
else:
arg_check(args, 'block-detach', 2, 3)
try:
detach(args, 'block-detach', 'vbd')
detach(args, 'vbd')
return
except:
pass
detach(args, 'block-detach', 'tap')
detach(args, 'tap')
def xm_network_detach(args):
if serverType == SERVER_XEN_API:
arg_check(args, "xm_block_detach", 2, 3)
arg_check(args, "xm_network_detach", 2, 3)
dom = args[0]
devid = args[1]
vif_refs = server.xenapi.VM.get_VIFs(get_single_vm(dom))
@@ -2227,7 +2226,8 @@ def xm_network_detach(args):
else:
print "Cannot find device '%s' in domain '%s'" % (devid,dom)
else:
detach(args, 'network-detach', 'vif')
arg_check(args, 'network-detach', 2, 3)
detach(args, 'vif')
def xm_vnet_list(args):
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.