ia64/xen-unstable
changeset 14526:2cecfa20ffa9
Merge with xen-ia64-unstable.hg
author | kfraser@localhost.localdomain |
---|---|
date | Fri Mar 23 10:11:58 2007 +0000 (2007-03-23) |
parents | be1017157768 a234dcbd8357 |
children | fd0b109501af |
files |
line diff
1.1 --- a/tools/libxen/test/test_bindings.c Thu Mar 22 09:30:54 2007 -0600 1.2 +++ b/tools/libxen/test/test_bindings.c Fri Mar 23 10:11:58 2007 +0000 1.3 @@ -403,7 +403,7 @@ static xen_vm create_new_vm(xen_session 1.4 * Create a new disk for the new VM. 1.5 */ 1.6 xen_sr_set *srs; 1.7 - if (!xen_sr_get_by_name_label(session, &srs, "Local") || 1.8 + if (!xen_sr_get_by_name_label(session, &srs, "QCoW") || 1.9 srs->size < 1) 1.10 { 1.11 fprintf(stderr, "SR lookup failed.\n");
2.1 --- a/tools/python/xen/util/xmlrpclib2.py Thu Mar 22 09:30:54 2007 -0600 2.2 +++ b/tools/python/xen/util/xmlrpclib2.py Fri Mar 23 10:11:58 2007 +0000 2.3 @@ -54,9 +54,10 @@ def stringify(value): 2.4 (isinstance(value, int) and not isinstance(value, bool)): 2.5 return str(value) 2.6 elif isinstance(value, dict): 2.7 + new_value = {} 2.8 for k, v in value.items(): 2.9 - value[k] = stringify(v) 2.10 - return value 2.11 + new_value[stringify(k)] = stringify(v) 2.12 + return new_value 2.13 elif isinstance(value, (tuple, list)): 2.14 return [stringify(v) for v in value] 2.15 else:
3.1 --- a/tools/python/xen/xend/XendAPI.py Thu Mar 22 09:30:54 2007 -0600 3.2 +++ b/tools/python/xen/xend/XendAPI.py Fri Mar 23 10:11:58 2007 +0000 3.3 @@ -643,6 +643,7 @@ class XendAPI(object): 3.4 3.5 host_attr_ro = ['software_version', 3.6 'resident_VMs', 3.7 + 'PIFs', 3.8 'host_CPUs', 3.9 'cpu_configuration', 3.10 'metrics', 3.11 @@ -712,6 +713,8 @@ class XendAPI(object): 3.12 return xen_api_success(XendNode.instance().xen_version()) 3.13 def host_get_resident_VMs(self, session, host_ref): 3.14 return xen_api_success(XendDomain.instance().get_domain_refs()) 3.15 + def host_get_PIFs(self, session, ref): 3.16 + return xen_api_success(XendNode.instance().get_PIF_refs()) 3.17 def host_get_host_CPUs(self, session, host_ref): 3.18 return xen_api_success(XendNode.instance().get_host_cpu_refs()) 3.19 def host_get_metrics(self, _, ref): 3.20 @@ -1034,9 +1037,8 @@ class XendAPI(object): 3.21 3.22 VM_attr_ro = ['power_state', 3.23 'resident_on', 3.24 - 'memory_static_max', 3.25 + 'memory_static_max', 3.26 'memory_static_min', 3.27 - 'VCPUs_number', 3.28 'consoles', 3.29 'VIFs', 3.30 'VBDs', 3.31 @@ -1054,6 +1056,8 @@ class XendAPI(object): 3.32 'auto_power_on', 3.33 'memory_dynamic_max', 3.34 'memory_dynamic_min', 3.35 + 'VCPUs_max', 3.36 + 'VCPUs_at_startup', 3.37 'VCPUs_params', 3.38 'actions_after_shutdown', 3.39 'actions_after_reboot', 3.40 @@ -1081,9 +1085,11 @@ class XendAPI(object): 3.41 ('suspend', None), 3.42 ('resume', None), 3.43 ('send_sysrq', None), 3.44 + ('set_VCPUs_number_live', None), 3.45 ('add_to_HVM_boot_params', None), 3.46 ('remove_from_HVM_boot_params', None), 3.47 ('add_to_VCPUs_params', None), 3.48 + ('add_to_VCPUs_params_live', None), 3.49 ('remove_from_VCPUs_params', None), 3.50 ('add_to_platform', None), 3.51 ('remove_from_platform', None), 3.52 @@ -1104,6 +1110,8 @@ class XendAPI(object): 3.53 'memory_dynamic_max', 3.54 'memory_dynamic_min', 3.55 'memory_static_min', 3.56 + 'VCPUs_max', 3.57 + 'VCPUs_at_startup', 3.58 'VCPUs_params', 3.59 'actions_after_shutdown', 3.60 'actions_after_reboot', 3.61 @@ -1150,10 +1158,6 @@ class XendAPI(object): 3.62 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 3.63 return xen_api_success(dom.get_memory_static_min()) 3.64 3.65 - def VM_get_VCPUs_number(self, session, vm_ref): 3.66 - dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 3.67 - return xen_api_success(dom.getVCpuCount()) 3.68 - 3.69 def VM_get_VIFs(self, session, vm_ref): 3.70 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 3.71 return xen_api_success(dom.get_vifs()) 3.72 @@ -1178,6 +1182,14 @@ class XendAPI(object): 3.73 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 3.74 return xen_api_success(dom.get_metrics()) 3.75 3.76 + def VM_get_VCPUs_max(self, _, vm_ref): 3.77 + dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 3.78 + return xen_api_todo() 3.79 + 3.80 + def VM_get_VCPUs_at_startup(self, _, vm_ref): 3.81 + dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 3.82 + return xen_api_todo() 3.83 + 3.84 # attributes (rw) 3.85 def VM_get_name_label(self, session, vm_ref): 3.86 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 3.87 @@ -1191,9 +1203,8 @@ class XendAPI(object): 3.88 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 3.89 return xen_api_todo() 3.90 3.91 - def VM_get_is_a_template(self, session, vm_ref): 3.92 - dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 3.93 - return xen_api_todo() 3.94 + def VM_get_is_a_template(self, session, ref): 3.95 + return self.VM_get('is_a_template', session, ref) 3.96 3.97 def VM_get_memory_dynamic_max(self, session, vm_ref): 3.98 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 3.99 @@ -1302,6 +1313,36 @@ class XendAPI(object): 3.100 dom.info['vcpus_params'][key] = value 3.101 return self._VM_save(dom) 3.102 3.103 + def VM_add_to_VCPUs_params_live(self, session, vm_ref, key, value): 3.104 + self.VM_add_to_VCPUs_params(session, vm_ref, key, value) 3.105 + self._VM_VCPUs_params_refresh(vm_ref) 3.106 + return xen_api_success_void() 3.107 + 3.108 + def _VM_VCPUs_params_refresh(self, vm_ref): 3.109 + xendom = XendDomain.instance() 3.110 + xeninfo = xendom.get_vm_by_uuid(vm_ref) 3.111 + 3.112 + #update the cpumaps 3.113 + for key, value in xeninfo.info['vcpus_params'].items(): 3.114 + if key.startswith("cpumap"): 3.115 + vcpu = int(key[6:]) 3.116 + try: 3.117 + xendom.domain_pincpu(xeninfo.getDomid(), vcpu, value) 3.118 + except Exception, ex: 3.119 + log.exception(ex) 3.120 + 3.121 + #need to update sched params aswell 3.122 + if 'weight' in xeninfo.info['vcpus_params'] \ 3.123 + and 'cap' in xeninfo.info['vcpus_params']: 3.124 + weight = xeninfo.info['vcpus_params']['weight'] 3.125 + cap = xeninfo.info['vcpus_params']['cap'] 3.126 + xendom.domain_sched_credit_set(xeninfo.getDomid(), weight, cap) 3.127 + 3.128 + def VM_set_VCPUs_number_live(self, _, vm_ref, num): 3.129 + dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 3.130 + dom.setVCpuCount(int(num)) 3.131 + return xen_api_success_void() 3.132 + 3.133 def VM_remove_from_VCPUs_params(self, session, vm_ref, key): 3.134 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 3.135 if 'vcpus_params' in dom.info \ 3.136 @@ -1442,7 +1483,7 @@ class XendAPI(object): 3.137 'name_label': xeninfo.getName(), 3.138 'name_description': xeninfo.getName(), 3.139 'user_version': 1, 3.140 - 'is_a_template': False, 3.141 + 'is_a_template': xeninfo.info.get('is_a_template'), 3.142 'auto_power_on': False, 3.143 'resident_on': XendNode.instance().uuid, 3.144 'memory_static_min': xeninfo.get_memory_static_min(), 3.145 @@ -1450,7 +1491,8 @@ class XendAPI(object): 3.146 'memory_dynamic_min': xeninfo.get_memory_dynamic_min(), 3.147 'memory_dynamic_max': xeninfo.get_memory_dynamic_max(), 3.148 'VCPUs_params': xeninfo.get_vcpus_params(), 3.149 - 'VCPUs_number': xeninfo.getVCpuCount(), 3.150 + 'VCPUs_at_startup': xeninfo.getVCpuCount(), 3.151 + 'VCPUs_max': xeninfo.getVCpuCount(), 3.152 'actions_after_shutdown': xeninfo.get_on_shutdown(), 3.153 'actions_after_reboot': xeninfo.get_on_reboot(), 3.154 'actions_after_suspend': xeninfo.get_on_suspend(), 3.155 @@ -1472,6 +1514,7 @@ class XendAPI(object): 3.156 'other_config': xeninfo.info.get('other_config', {}), 3.157 'domid': domid is None and -1 or domid, 3.158 'is_control_domain': xeninfo == xendom.privilegedDomain(), 3.159 + 'metrics': xeninfo.get_metrics() 3.160 } 3.161 return xen_api_success(record) 3.162 3.163 @@ -1547,8 +1590,12 @@ class XendAPI(object): 3.164 # ---------------------------------------------------------------- 3.165 3.166 VM_metrics_attr_ro = ['memory_actual', 3.167 - 'vcpus_number', 3.168 - 'vcpus_utilisation'] 3.169 + 'VCPUs_number', 3.170 + 'VCPUs_utilisation', 3.171 + 'VCPUs_CPU', 3.172 + 'VCPUs_flags', 3.173 + 'VCPUs_params', 3.174 + 'start_time'] 3.175 VM_metrics_attr_rw = [] 3.176 VM_metrics_methods = [] 3.177 3.178 @@ -1564,11 +1611,24 @@ class XendAPI(object): 3.179 def VM_metrics_get_memory_actual(self, _, ref): 3.180 return xen_api_success(self._VM_metrics_get(ref).get_memory_actual()) 3.181 3.182 - def VM_metrics_get_vcpus_number(self, _, ref): 3.183 - return xen_api_success(self._VM_metrics_get(ref).get_vcpus_number()) 3.184 + def VM_metrics_get_VCPUs_number(self, _, ref): 3.185 + return xen_api_success(self._VM_metrics_get(ref).get_VCPUs_number()) 3.186 + 3.187 + def VM_metrics_get_VCPUs_utilisation(self, _, ref): 3.188 + return xen_api_success(self._VM_metrics_get(ref).get_VCPUs_utilisation()) 3.189 3.190 - def VM_metrics_get_vcpus_utilisation(self, _, ref): 3.191 - return xen_api_success(self._VM_metrics_get(ref).get_vcpus_utilisation()) 3.192 + def VM_metrics_get_VCPUs_CPU(self, _, ref): 3.193 + return xen_api_success(self._VM_metrics_get(ref).get_VCPUs_CPU()) 3.194 + 3.195 + def VM_metrics_get_VCPUs_flags(self, _, ref): 3.196 + return xen_api_success(self._VM_metrics_get(ref).get_VCPUs_flags()) 3.197 + 3.198 + def VM_metrics_get_VCPUs_params(self, _, ref): 3.199 + return xen_api_success(self._VM_metrics_get(ref).get_VCPUs_params()) 3.200 + 3.201 + def VM_metrics_get_start_time(self, _, ref): 3.202 + return xen_api_success(self._VM_metrics_get(ref).get_start_time()) 3.203 + 3.204 3.205 # Xen API: Class VBD 3.206 # ----------------------------------------------------------------
4.1 --- a/tools/python/xen/xend/XendConfig.py Thu Mar 22 09:30:54 2007 -0600 4.2 +++ b/tools/python/xen/xend/XendConfig.py Fri Mar 23 10:11:58 2007 +0000 4.3 @@ -44,7 +44,7 @@ def reverse_dict(adict): 4.4 return dict([(v, k) for k, v in adict.items()]) 4.5 4.6 def bool0(v): 4.7 - return v != '0' and bool(v) 4.8 + return v != '0' and v != 'False' and bool(v) 4.9 4.10 # Recursively copy a data struct, scrubbing out VNC passwords. 4.11 # Will scrub any dict entry with a key of 'vncpasswd' or any 4.12 @@ -81,18 +81,18 @@ def scrub_password(data): 4.13 # 4.14 # CPU fields: 4.15 # 4.16 -# vcpus_number -- the maximum number of vcpus that this domain may ever have. 4.17 +# VCPUs_max -- the maximum number of vcpus that this domain may ever have. 4.18 # aka XendDomainInfo.getVCpuCount(). 4.19 # vcpus -- the legacy configuration name for above. 4.20 # max_vcpu_id -- vcpus_number - 1. This is given to us by Xen. 4.21 # 4.22 # cpus -- the list of pCPUs available to each vCPU. 4.23 # 4.24 -# vcpu_avail: a bitmap telling the guest domain whether it may use each of 4.25 -# its VCPUs. This is translated to 4.26 -# <dompath>/cpu/<id>/availability = {online,offline} for use 4.27 -# by the guest domain. 4.28 -# online_vpcus -- the number of VCPUs currently up, as reported by Xen. This 4.29 +# vcpu_avail -- a bitmap telling the guest domain whether it may use each of 4.30 +# its VCPUs. This is translated to 4.31 +# <dompath>/cpu/<id>/availability = {online,offline} for use 4.32 +# by the guest domain. 4.33 +# VCPUs_live -- the number of VCPUs currently up, as reported by Xen. This 4.34 # is changed by changing vcpu_avail, and waiting for the 4.35 # domain to respond. 4.36 # 4.37 @@ -103,7 +103,7 @@ def scrub_password(data): 4.38 4.39 XENAPI_CFG_TO_LEGACY_CFG = { 4.40 'uuid': 'uuid', 4.41 - 'vcpus_number': 'vcpus', 4.42 + 'VCPUs_max': 'vcpus', 4.43 'cpus': 'cpus', 4.44 'name_label': 'name', 4.45 'actions_after_shutdown': 'on_poweroff', 4.46 @@ -128,7 +128,6 @@ XENAPI_PLATFORM_CFG = [ 'acpi', 'apic', 4.47 4.48 XENAPI_CFG_TYPES = { 4.49 'uuid': str, 4.50 - 'power_state': str, 4.51 'name_label': str, 4.52 'name_description': str, 4.53 'user_version': str, 4.54 @@ -139,9 +138,10 @@ XENAPI_CFG_TYPES = { 4.55 'memory_dynamic_min': int, 4.56 'memory_dynamic_max': int, 4.57 'cpus': list, 4.58 - 'vcpus_policy': str, 4.59 'vcpus_params': dict, 4.60 - 'vcpus_number': int, 4.61 + 'VCPUs_max': int, 4.62 + 'VCPUs_at_startup': int, 4.63 + 'VCPUs_live': int, 4.64 'actions_after_shutdown': str, 4.65 'actions_after_reboot': str, 4.66 'actions_after_crash': str, 4.67 @@ -318,7 +318,9 @@ class XendConfig(dict): 4.68 'cpus': [], 4.69 'cpu_weight': 256, 4.70 'cpu_cap': 0, 4.71 - 'vcpus_number': 1, 4.72 + 'VCPUs_max': 1, 4.73 + 'VCPUs_live': 1, 4.74 + 'VCPUs_at_startup': 1, 4.75 'vcpus_params': {}, 4.76 'console_refs': [], 4.77 'vif_refs': [], 4.78 @@ -371,8 +373,8 @@ class XendConfig(dict): 4.79 event) 4.80 4.81 def _vcpus_sanity_check(self): 4.82 - if 'vcpus_number' in self and 'vcpu_avail' not in self: 4.83 - self['vcpu_avail'] = (1 << self['vcpus_number']) - 1 4.84 + if 'VCPUs_max' in self and 'vcpu_avail' not in self: 4.85 + self['vcpu_avail'] = (1 << self['VCPUs_max']) - 1 4.86 4.87 def _uuid_sanity_check(self): 4.88 """Make sure UUID is in proper string format with hyphens.""" 4.89 @@ -406,7 +408,7 @@ class XendConfig(dict): 4.90 def _dominfo_to_xapi(self, dominfo): 4.91 self['domid'] = dominfo['domid'] 4.92 self['online_vcpus'] = dominfo['online_vcpus'] 4.93 - self['vcpus_number'] = dominfo['max_vcpu_id'] + 1 4.94 + self['VCPUs_max'] = dominfo['max_vcpu_id'] + 1 4.95 4.96 self['memory_dynamic_min'] = dominfo['mem_kb'] * 1024 4.97 self['memory_dynamic_max'] = dominfo['mem_kb'] * 1024 4.98 @@ -562,12 +564,12 @@ class XendConfig(dict): 4.99 image_vcpus = sxp.child_value(image_sxp, 'vcpus') 4.100 if image_vcpus != None: 4.101 try: 4.102 - if 'vcpus_number' not in cfg: 4.103 - cfg['vcpus_number'] = int(image_vcpus) 4.104 - elif cfg['vcpus_number'] != int(image_vcpus): 4.105 - cfg['vcpus_number'] = int(image_vcpus) 4.106 + if 'VCPUs_max' not in cfg: 4.107 + cfg['VCPUs_max'] = int(image_vcpus) 4.108 + elif cfg['VCPUs_max'] != int(image_vcpus): 4.109 + cfg['VCPUs_max'] = int(image_vcpus) 4.110 log.warn('Overriding vcpus from %d to %d using image' 4.111 - 'vcpus value.', cfg['vcpus_number']) 4.112 + 'vcpus value.', cfg['VCPUs_max']) 4.113 except ValueError, e: 4.114 raise XendConfigError('integer expeceted: %s: %s' % 4.115 image_sxp, e) 4.116 @@ -851,16 +853,6 @@ class XendConfig(dict): 4.117 sxpr.append(["maxmem", int(self["memory_static_max"])/MiB]) 4.118 sxpr.append(["memory", int(self["memory_dynamic_max"])/MiB]) 4.119 4.120 - if not legacy_only: 4.121 - sxpr.append(['memory_dynamic_min', 4.122 - int(self.get('memory_dynamic_min'))]) 4.123 - sxpr.append(['memory_dynamic_max', 4.124 - int(self.get('memory_dynamic_max'))]) 4.125 - sxpr.append(['memory_static_max', 4.126 - int(self.get('memory_static_max'))]) 4.127 - sxpr.append(['memory_static_min', 4.128 - int(self.get('memory_static_min'))]) 4.129 - 4.130 for legacy in LEGACY_UNSUPPORTED_BY_XENAPI_CFG: 4.131 if legacy in ('domid', 'uuid'): # skip these 4.132 continue
5.1 --- a/tools/python/xen/xend/XendDomain.py Thu Mar 22 09:30:54 2007 -0600 5.2 +++ b/tools/python/xen/xend/XendDomain.py Fri Mar 23 10:11:58 2007 +0000 5.3 @@ -34,7 +34,7 @@ import xen.lowlevel.xc 5.4 5.5 from xen.xend import XendOptions, XendCheckpoint, XendDomainInfo 5.6 from xen.xend.PrettyPrint import prettyprint 5.7 -from xen.xend.XendConfig import XendConfig 5.8 +from xen.xend import XendConfig 5.9 from xen.xend.XendError import XendError, XendInvalidDomain, VmError 5.10 from xen.xend.XendError import VMBadState 5.11 from xen.xend.XendLogging import log 5.12 @@ -191,6 +191,10 @@ class XendDomain: 5.13 self._managed_domain_register(new_dom) 5.14 else: 5.15 self._managed_domain_register(running_dom) 5.16 + for key in XendConfig.XENAPI_CFG_TYPES.keys(): 5.17 + if key not in XendConfig.LEGACY_XENSTORE_VM_PARAMS and \ 5.18 + key in dom: 5.19 + running_dom.info[key] = dom[key] 5.20 except Exception: 5.21 log.exception("Failed to create reference to managed " 5.22 "domain: %s" % dom_name) 5.23 @@ -316,7 +320,7 @@ class XendDomain: 5.24 for dom_uuid in dom_uuids: 5.25 try: 5.26 cfg_file = self._managed_config_path(dom_uuid) 5.27 - cfg = XendConfig(filename = cfg_file) 5.28 + cfg = XendConfig.XendConfig(filename = cfg_file) 5.29 if cfg.get('uuid') != dom_uuid: 5.30 # something is wrong with the SXP 5.31 log.error("UUID mismatch in stored configuration: %s" % 5.32 @@ -414,7 +418,7 @@ class XendDomain: 5.33 running_domids = [d['domid'] for d in running if d['dying'] != 1] 5.34 for domid, dom in self.domains.items(): 5.35 if domid not in running_domids and domid != DOM0_ID: 5.36 - self.remove_domain(dom, domid) 5.37 + self._remove_domain(dom, domid) 5.38 5.39 5.40 def add_domain(self, info): 5.41 @@ -433,6 +437,16 @@ class XendDomain: 5.42 self._managed_domain_register(info) 5.43 5.44 def remove_domain(self, info, domid = None): 5.45 + """Remove the domain from the list of running domains, taking the 5.46 + domains_lock first. 5.47 + """ 5.48 + self.domains_lock.acquire() 5.49 + try: 5.50 + self._remove_domain(info, domid) 5.51 + finally: 5.52 + self.domains_lock.release() 5.53 + 5.54 + def _remove_domain(self, info, domid = None): 5.55 """Remove the domain from the list of running domains 5.56 5.57 @requires: Expects to be protected by the domains_lock. 5.58 @@ -683,7 +697,7 @@ class XendDomain: 5.59 self.domains_lock.acquire() 5.60 try: 5.61 try: 5.62 - xeninfo = XendConfig(xapi = xenapi_vm) 5.63 + xeninfo = XendConfig.XendConfig(xapi = xenapi_vm) 5.64 dominfo = XendDomainInfo.createDormant(xeninfo) 5.65 log.debug("Creating new managed domain: %s: %s" % 5.66 (dominfo.getName(), dominfo.get_uuid())) 5.67 @@ -906,7 +920,7 @@ class XendDomain: 5.68 self.domains_lock.acquire() 5.69 try: 5.70 try: 5.71 - domconfig = XendConfig(sxp_obj = config) 5.72 + domconfig = XendConfig.XendConfig(sxp_obj = config) 5.73 dominfo = XendDomainInfo.createDormant(domconfig) 5.74 log.debug("Creating new managed domain: %s" % 5.75 dominfo.getName()) 5.76 @@ -971,18 +985,34 @@ class XendDomain: 5.77 raise VMBadState("Domain is still running", 5.78 POWER_STATE_NAMES[DOM_STATE_HALTED], 5.79 POWER_STATE_NAMES[dominfo.state]) 5.80 - 5.81 - log.info("Domain %s (%s) deleted." % 5.82 - (dominfo.getName(), dominfo.info.get('uuid'))) 5.83 - 5.84 - self._managed_domain_unregister(dominfo) 5.85 - self.remove_domain(dominfo) 5.86 - XendDevices.destroy_device_state(dominfo) 5.87 + 5.88 + self._domain_delete_by_info(dominfo) 5.89 except Exception, ex: 5.90 raise XendError(str(ex)) 5.91 finally: 5.92 self.domains_lock.release() 5.93 - 5.94 + 5.95 + 5.96 + def domain_delete_by_dominfo(self, dominfo): 5.97 + """Only for use by XendDomainInfo. 5.98 + """ 5.99 + self.domains_lock.acquire() 5.100 + try: 5.101 + self._domain_delete_by_info(dominfo) 5.102 + finally: 5.103 + self.domains_lock.release() 5.104 + 5.105 + 5.106 + def _domain_delete_by_info(self, dominfo): 5.107 + """Expects to be protected by domains_lock. 5.108 + """ 5.109 + log.info("Domain %s (%s) deleted." % 5.110 + (dominfo.getName(), dominfo.info.get('uuid'))) 5.111 + 5.112 + self._managed_domain_unregister(dominfo) 5.113 + self._remove_domain(dominfo) 5.114 + XendDevices.destroy_device_state(dominfo) 5.115 + 5.116 5.117 def domain_configure(self, config): 5.118 """Configure an existing domain. 5.119 @@ -1230,7 +1260,9 @@ class XendDomain: 5.120 try: 5.121 rc = xc.vcpu_setaffinity(dominfo.getDomid(), int(v), cpumap) 5.122 except Exception, ex: 5.123 - raise XendError(str(ex)) 5.124 + log.exception(ex) 5.125 + raise XendError("Cannot pin vcpu: %s to cpu: %s - %s" % \ 5.126 + (v, cpumap, str(ex))) 5.127 return rc 5.128 5.129 def domain_cpu_sedf_set(self, domid, period, slice_, latency, extratime,
6.1 --- a/tools/python/xen/xend/XendDomainInfo.py Thu Mar 22 09:30:54 2007 -0600 6.2 +++ b/tools/python/xen/xend/XendDomainInfo.py Fri Mar 23 10:11:58 2007 +0000 6.3 @@ -614,9 +614,9 @@ class XendDomainInfo: 6.4 sxpr = ['domain', 6.5 ['domid', self.domid], 6.6 ['name', self.info['name_label']], 6.7 - ['vcpu_count', self.info['vcpus_number']]] 6.8 - 6.9 - for i in range(0, self.info['vcpus_number']): 6.10 + ['vcpu_count', self.info['VCPUs_max']]] 6.11 + 6.12 + for i in range(0, self.info['VCPUs_max']): 6.13 info = xc.vcpu_getinfo(self.domid, i) 6.14 6.15 sxpr.append(['vcpu', 6.16 @@ -660,7 +660,6 @@ class XendDomainInfo: 6.17 vm_config = dict(zip(augment_entries, vm_config)) 6.18 6.19 for arg in augment_entries: 6.20 - xapicfg = arg 6.21 val = vm_config[arg] 6.22 if val != None: 6.23 if arg in XendConfig.LEGACY_CFG_TO_XENAPI_CFG: 6.24 @@ -678,7 +677,7 @@ class XendDomainInfo: 6.25 # settings to take precedence over any entries in the store. 6.26 if priv: 6.27 xeninfo = dom_get(self.domid) 6.28 - self.info['vcpus_number'] = xeninfo['online_vcpus'] 6.29 + self.info['VCPUs_max'] = xeninfo['online_vcpus'] 6.30 self.info['vcpu_avail'] = (1 << xeninfo['online_vcpus']) - 1 6.31 6.32 # read image value 6.33 @@ -831,7 +830,7 @@ class XendDomainInfo: 6.34 return 'offline' 6.35 6.36 result = {} 6.37 - for v in range(0, self.info['vcpus_number']): 6.38 + for v in range(0, self.info['VCPUs_max']): 6.39 result["cpu/%d/availability" % v] = availability(v) 6.40 return result 6.41 6.42 @@ -952,7 +951,7 @@ class XendDomainInfo: 6.43 return self.info['features'] 6.44 6.45 def getVCpuCount(self): 6.46 - return self.info['vcpus_number'] 6.47 + return self.info['VCPUs_max'] 6.48 6.49 def setVCpuCount(self, vcpus): 6.50 if vcpus <= 0: 6.51 @@ -964,16 +963,16 @@ class XendDomainInfo: 6.52 # update dom differently depending on whether we are adjusting 6.53 # vcpu number up or down, otherwise _vcpuDomDetails does not 6.54 # disable the vcpus 6.55 - if self.info['vcpus_number'] > vcpus: 6.56 + if self.info['VCPUs_max'] > vcpus: 6.57 # decreasing 6.58 self._writeDom(self._vcpuDomDetails()) 6.59 - self.info['vcpus_number'] = vcpus 6.60 + self.info['VCPUs_live'] = vcpus 6.61 else: 6.62 # same or increasing 6.63 - self.info['vcpus_number'] = vcpus 6.64 + self.info['VCPUs_live'] = vcpus 6.65 self._writeDom(self._vcpuDomDetails()) 6.66 else: 6.67 - self.info['vcpus_number'] = vcpus 6.68 + self.info['VCPUs_live'] = vcpus 6.69 xen.xend.XendDomain.instance().managed_config_save(self) 6.70 log.info("Set VCPU count on domain %s to %d", self.info['name_label'], 6.71 vcpus) 6.72 @@ -1427,7 +1426,7 @@ class XendDomainInfo: 6.73 self._recreateDom() 6.74 6.75 # Set maximum number of vcpus in domain 6.76 - xc.domain_max_vcpus(self.domid, int(self.info['vcpus_number'])) 6.77 + xc.domain_max_vcpus(self.domid, int(self.info['VCPUs_max'])) 6.78 6.79 # register the domain in the list 6.80 from xen.xend import XendDomain 6.81 @@ -1464,7 +1463,7 @@ class XendDomainInfo: 6.82 # this is done prior to memory allocation to aide in memory 6.83 # distribution for NUMA systems. 6.84 if self.info['cpus'] is not None and len(self.info['cpus']) > 0: 6.85 - for v in range(0, self.info['vcpus_number']): 6.86 + for v in range(0, self.info['VCPUs_max']): 6.87 xc.vcpu_setaffinity(self.domid, v, self.info['cpus']) 6.88 6.89 # Use architecture- and image-specific calculations to determine 6.90 @@ -1651,6 +1650,12 @@ class XendDomainInfo: 6.91 6.92 self._cleanup_phantom_devs(paths) 6.93 6.94 + if "transient" in self.info["other_config"] \ 6.95 + and bool(self.info["other_config"]["transient"]): 6.96 + from xen.xend import XendDomain 6.97 + XendDomain.instance().domain_delete_by_dominfo(self) 6.98 + 6.99 + 6.100 def destroyDomain(self): 6.101 log.debug("XendDomainInfo.destroyDomain(%s)", str(self.domid)) 6.102 6.103 @@ -1662,26 +1667,17 @@ class XendDomainInfo: 6.104 self.domid = None 6.105 for state in DOM_STATES_OLD: 6.106 self.info[state] = 0 6.107 + self._stateSet(DOM_STATE_HALTED) 6.108 except: 6.109 log.exception("XendDomainInfo.destroy: xc.domain_destroy failed.") 6.110 6.111 from xen.xend import XendDomain 6.112 - 6.113 - if "transient" in self.info["other_config"]\ 6.114 - and bool(self.info["other_config"]["transient"]): 6.115 - xendDomainInstance = XendDomain.instance() 6.116 - 6.117 - xendDomainInstance.domains_lock.acquire() 6.118 - xendDomainInstance._refresh(refresh_shutdown = False) 6.119 - xendDomainInstance.domains_lock.release() 6.120 - 6.121 - xendDomainInstance.domain_delete(self.info["name_label"]) 6.122 - else: 6.123 - XendDomain.instance().remove_domain(self) 6.124 + XendDomain.instance().remove_domain(self) 6.125 6.126 self.cleanupDomain() 6.127 self._cleanup_phantom_devs(paths) 6.128 6.129 + 6.130 def resumeDomain(self): 6.131 log.debug("XendDomainInfo.resumeDomain(%s)", str(self.domid)) 6.132 6.133 @@ -1860,7 +1856,7 @@ class XendDomainInfo: 6.134 if arch.type == "x86": 6.135 # 1MB per vcpu plus 4Kib/Mib of RAM. This is higher than 6.136 # the minimum that Xen would allocate if no value were given. 6.137 - overhead_kb = self.info['vcpus_number'] * 1024 + \ 6.138 + overhead_kb = self.info['VCPUs_max'] * 1024 + \ 6.139 (self.info['memory_static_max'] / 1024 / 1024) * 4 6.140 overhead_kb = ((overhead_kb + 1023) / 1024) * 1024 6.141 # The domain might already have some shadow memory 6.142 @@ -2258,8 +2254,8 @@ class XendDomainInfo: 6.143 def get_vcpus_util(self): 6.144 vcpu_util = {} 6.145 xennode = XendNode.instance() 6.146 - if 'vcpus_number' in self.info and self.domid != None: 6.147 - for i in range(0, self.info['vcpus_number']): 6.148 + if 'VCPUs_max' in self.info and self.domid != None: 6.149 + for i in range(0, self.info['VCPUs_max']): 6.150 util = xennode.get_vcpu_util(self.domid, i) 6.151 vcpu_util[str(i)] = util 6.152
7.1 --- a/tools/python/xen/xend/XendNode.py Thu Mar 22 09:30:54 2007 -0600 7.2 +++ b/tools/python/xen/xend/XendNode.py Fri Mar 23 10:11:58 2007 +0000 7.3 @@ -215,6 +215,10 @@ class XendNode: 7.4 self.save_networks() 7.5 7.6 7.7 + def get_PIF_refs(self): 7.8 + return self.pifs.keys() 7.9 + 7.10 + 7.11 def _PIF_create(self, name, mtu, vlan, mac, network, persist = True, 7.12 pif_uuid = None, metrics_uuid = None): 7.13 for pif in self.pifs.values():
8.1 --- a/tools/python/xen/xend/XendQCoWStorageRepo.py Thu Mar 22 09:30:54 2007 -0600 8.2 +++ b/tools/python/xen/xend/XendQCoWStorageRepo.py Fri Mar 23 10:11:58 2007 +0000 8.3 @@ -208,7 +208,8 @@ class XendQCoWStorageRepo(XendStorageRep 8.4 self.lock.acquire() 8.5 try: 8.6 if not self._has_space_available_for(desired_size_bytes): 8.7 - raise XendError("Not enough space") 8.8 + raise XendError("Not enough space (need %d)" % 8.9 + desired_size_bytes) 8.10 8.11 image_uuid = uuid.createString() 8.12 qcow_path = os.path.join(self.location, 8.13 @@ -251,6 +252,7 @@ class XendQCoWStorageRepo(XendStorageRep 8.14 except OSError: 8.15 log.exception("Failed to destroy image") 8.16 del self.images[image_uuid] 8.17 + self._refresh() 8.18 return True 8.19 finally: 8.20 self.lock.release() 8.21 @@ -317,15 +319,12 @@ class XendQCoWStorageRepo(XendStorageRep 8.22 def create_vdi(self, vdi_struct): 8.23 image_uuid = None 8.24 try: 8.25 - sector_count = int(vdi_struct.get('virtual_size', 0)) 8.26 - sector_size = int(vdi_struct.get('sector_size', 1024)) 8.27 - size_bytes = (sector_count * sector_size) 8.28 + size_bytes = int(vdi_struct.get('virtual_size', 0)) 8.29 8.30 image_uuid = self._create_image_files(size_bytes) 8.31 8.32 image = self.images[image_uuid] 8.33 image_cfg = { 8.34 - 'sector_size': sector_size, 8.35 'virtual_size': size_bytes, 8.36 'type': vdi_struct.get('type', 'system'), 8.37 'name_label': vdi_struct.get('name_label', ''), 8.38 @@ -350,17 +349,3 @@ class XendQCoWStorageRepo(XendStorageRep 8.39 raise 8.40 8.41 return image_uuid 8.42 - 8.43 - 8.44 -# remove everything below this line!! for testing only 8.45 -if __name__ == "__main__": 8.46 - xsr = XendStorageRepository() 8.47 - print 'Free Space: %d MB' % (xsr.free_space_bytes()/MB) 8.48 - print "Create Image:", 8.49 - print xsr._create_image_files(10 * MB) 8.50 - print 'Delete all images:' 8.51 - for image_uuid in xsr.list_images(): 8.52 - print image_uuid, 8.53 - xsr._destroy_image_files(image_uuid) 8.54 - 8.55 - print
9.1 --- a/tools/python/xen/xend/XendVMMetrics.py Thu Mar 22 09:30:54 2007 -0600 9.2 +++ b/tools/python/xen/xend/XendVMMetrics.py Fri Mar 23 10:11:58 2007 +0000 9.3 @@ -13,9 +13,13 @@ 9.4 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 9.5 #============================================================================ 9.6 # Copyright (c) 2006-2007 Xensource Inc. 9.7 +# Copyright (c) 2007 Tom Wilkie 9.8 #============================================================================ 9.9 9.10 from xen.xend.XendLogging import log 9.11 +import xen.lowlevel.xc 9.12 + 9.13 +xc = xen.lowlevel.xc.xc() 9.14 9.15 instances = {} 9.16 9.17 @@ -46,25 +50,79 @@ class XendVMMetrics: 9.18 return self.uuid 9.19 9.20 def get_memory_actual(self): 9.21 - return self.get_record()["memory_actual"] 9.22 + domInfo = self.xend_domain_instance.getDomInfo() 9.23 + if domInfo: 9.24 + return domInfo["mem_kb"] * 1024 9.25 + else: 9.26 + return 0 9.27 9.28 - def get_vcpus_number(self): 9.29 - return self.get_record()["vcpus_number"] 9.30 - 9.31 - def get_vcpus_utilisation(self): 9.32 - return self.xend_domain_instance.get_vcpus_util() 9.33 - 9.34 - def get_record(self): 9.35 + def get_VCPUs_number(self): 9.36 domInfo = self.xend_domain_instance.getDomInfo() 9.37 if domInfo: 9.38 - return { 'uuid' : self.uuid, 9.39 - 'memory_actual' : domInfo["mem_kb"] * 1024, 9.40 - 'vcpus_number' : domInfo["online_vcpus"], 9.41 - 'vcpus_utilisation' : self.get_vcpus_utilisation() 9.42 - } 9.43 + return domInfo["online_vcpus"] 9.44 + else: 9.45 + return 0 9.46 + 9.47 + def get_VCPUs_utilisation(self): 9.48 + return self.xend_domain_instance.get_vcpus_util() 9.49 + 9.50 + def get_VCPUs_CPU(self): 9.51 + domid = self.xend_domain_instance.getDomid() 9.52 + if domid is not None: 9.53 + vcpus_cpu = {} 9.54 + vcpus_max = self.xend_domain_instance.info['VCPUs_max'] 9.55 + for i in range(0, vcpus_max): 9.56 + info = xc.vcpu_getinfo(domid, i) 9.57 + vcpus_cpu[i] = info['cpu'] 9.58 + return vcpus_cpu 9.59 else: 9.60 - return { 'uuid' : self.uuid, 9.61 - 'memory_actual' : 0, 9.62 - 'vcpus_number' : 0, 9.63 - 'vcpus_utilisation' : {} 9.64 - } 9.65 + return {} 9.66 + 9.67 + def get_VCPUs_flags(self): 9.68 + domid = self.xend_domain_instance.getDomid() 9.69 + if domid is not None: 9.70 + vcpus_flags = {} 9.71 + vcpus_max = self.xend_domain_instance.info['VCPUs_max'] 9.72 + for i in range(0, vcpus_max): 9.73 + info = xc.vcpu_getinfo(domid, i) 9.74 + flags = [] 9.75 + def set_flag(flag): 9.76 + if info[flag] == 1: 9.77 + flags.append(flag) 9.78 + set_flag('blocked') 9.79 + set_flag('online') 9.80 + set_flag('running') 9.81 + vcpus_flags[i] = ",".join(flags) 9.82 + return vcpus_flags 9.83 + else: 9.84 + return {} 9.85 + 9.86 + def get_VCPUs_params(self): 9.87 + domid = self.xend_domain_instance.getDomid() 9.88 + if domid is not None: 9.89 + params_live = {} 9.90 + vcpus_max = self.xend_domain_instance.info['VCPUs_max'] 9.91 + for i in range(0, vcpus_max): 9.92 + info = xc.vcpu_getinfo(domid, i) 9.93 + params_live['cpumap%i' % i] = \ 9.94 + ",".join(map(str, info['cpumap'])) 9.95 + 9.96 + params_live.update(xc.sched_credit_domain_get(domid)) 9.97 + 9.98 + return params_live 9.99 + else: 9.100 + return {} 9.101 + 9.102 + def get_start_time(self): 9.103 + return self.xend_domain_instance.info.get("start_time", -1) 9.104 + 9.105 + def get_record(self): 9.106 + return { 'uuid' : self.uuid, 9.107 + 'memory_actual' : self.get_memory_actual(), 9.108 + 'VCPUs_number' : self.get_VCPUs_number(), 9.109 + 'VCPUs_utilisation' : self.get_VCPUs_utilisation(), 9.110 + 'VCPUs_CPU' : self.get_VCPUs_CPU(), 9.111 + 'VCPUs_flags' : self.get_VCPUs_flags(), 9.112 + 'VCPUs_params' : self.get_VCPUs_params(), 9.113 + 'start_time' : self.get_start_time(), 9.114 + }
10.1 --- a/tools/python/xen/xm/main.py Thu Mar 22 09:30:54 2007 -0600 10.2 +++ b/tools/python/xen/xm/main.py Fri Mar 23 10:11:58 2007 +0000 10.3 @@ -502,6 +502,13 @@ def get_default_Network(): 10.4 return [network_ref 10.5 for network_ref in server.xenapi.network.get_all()][0] 10.6 10.7 +class XenAPIUnsupportedException(Exception): 10.8 + pass 10.9 + 10.10 +def xenapi_unsupported(): 10.11 + if serverType == SERVER_XEN_API: 10.12 + raise XenAPIUnsupportedException, "This function is not supported by Xen-API" 10.13 + 10.14 def map2sxp(m): 10.15 return [[k, m[k]] for k in m.keys()] 10.16 10.17 @@ -550,10 +557,13 @@ def err(msg): 10.18 10.19 10.20 def get_single_vm(dom): 10.21 - uuids = server.xenapi.VM.get_by_name_label(dom) 10.22 - n = len(uuids) 10.23 - if n == 1: 10.24 - return uuids[0] 10.25 + if serverType == SERVER_XEN_API: 10.26 + uuids = server.xenapi.VM.get_by_name_label(dom) 10.27 + n = len(uuids) 10.28 + if n > 0: 10.29 + return uuids[0] 10.30 + else: 10.31 + raise OptionError("Domain '%s' not found." % dom) 10.32 else: 10.33 dominfo = server.xend.domain(dom, False) 10.34 return dominfo['uuid'] 10.35 @@ -697,9 +707,10 @@ def getDomains(domain_names, state, full 10.36 dom_metrics = server.xenapi.VM_metrics.get_record(dom_metrics_ref) 10.37 dom_rec.update({'name': dom_rec['name_label'], 10.38 'memory_actual': int(dom_metrics['memory_actual'])/1024, 10.39 - 'vcpus': dom_metrics['vcpus_number'], 10.40 + 'vcpus': dom_metrics['VCPUs_number'], 10.41 'state': '-----', 10.42 - 'cpu_time': dom_metrics['vcpus_utilisation']}) 10.43 + 'cpu_time': dom_metrics['VCPUs_utilisation'], 10.44 + 'start_time': dom_metrics['start_time']}) 10.45 10.46 doms_sxp.append(['domain'] + map2sxp(dom_rec)) 10.47 doms_dict.append(dom_rec) 10.48 @@ -885,11 +896,71 @@ def xm_label_list(doms): 10.49 10.50 10.51 def xm_vcpu_list(args): 10.52 - if args: 10.53 - dominfo = map(server.xend.domain.getVCPUInfo, args) 10.54 - else: 10.55 - doms = server.xend.domains(False) 10.56 - dominfo = map(server.xend.domain.getVCPUInfo, doms) 10.57 + if serverType == SERVER_XEN_API: 10.58 + if args: 10.59 + vm_refs = map(get_single_vm, args) 10.60 + else: 10.61 + vm_refs = server.xenapi.VM.get_all() 10.62 + 10.63 + vm_records = dict(map(lambda vm_ref: 10.64 + (vm_ref, server.xenapi.VM.get_record( 10.65 + vm_ref)), 10.66 + vm_refs)) 10.67 + 10.68 + vm_metrics = dict(map(lambda (ref, record): 10.69 + (ref, 10.70 + server.xenapi.VM_metrics.get_record( 10.71 + record['metrics'])), 10.72 + vm_records.items())) 10.73 + 10.74 + dominfo = [] 10.75 + 10.76 + # vcpu_list doesn't list 'managed' domains 10.77 + # when they are not running, so filter them out 10.78 + 10.79 + vm_refs = [vm_ref 10.80 + for vm_ref in vm_refs 10.81 + if vm_records[vm_ref]["power_state"] != "Halted"] 10.82 + 10.83 + for vm_ref in vm_refs: 10.84 + info = ['domain', 10.85 + ['domid', vm_records[vm_ref]['domid']], 10.86 + ['name', vm_records[vm_ref]['name_label']], 10.87 + ['vcpu_count', vm_records[vm_ref]['VCPUs_max']]] 10.88 + 10.89 + 10.90 + 10.91 + for i in range(int(vm_records[vm_ref]['VCPUs_max'])): 10.92 + def chk_flag(flag): 10.93 + return vm_metrics[vm_ref]['VCPUs_flags'][str(i)] \ 10.94 + .find(flag) > -1 and 1 or 0 10.95 + 10.96 + vcpu_info = ['vcpu', 10.97 + ['number', 10.98 + i], 10.99 + ['online', 10.100 + chk_flag("online")], 10.101 + ['blocked', 10.102 + chk_flag("blocked")], 10.103 + ['running', 10.104 + chk_flag("running")], 10.105 + ['cpu_time', 10.106 + vm_metrics[vm_ref]['VCPUs_utilisation'][str(i)]], 10.107 + ['cpu', 10.108 + vm_metrics[vm_ref]['VCPUs_CPU'][str(i)]], 10.109 + ['cpumap', 10.110 + vm_metrics[vm_ref]['VCPUs_params']\ 10.111 + ['cpumap%i' % i].split(",")]] 10.112 + 10.113 + info.append(vcpu_info) 10.114 + 10.115 + dominfo.append(info) 10.116 + else: 10.117 + if args: 10.118 + dominfo = map(server.xend.domain.getVCPUInfo, args) 10.119 + else: 10.120 + doms = server.xend.domains(False) 10.121 + dominfo = map(server.xend.domain.getVCPUInfo, doms) 10.122 10.123 print '%-32s %3s %5s %5s %5s %9s %s' % \ 10.124 ('Name', 'ID', 'VCPU', 'CPU', 'State', 'Time(s)', 'CPU Affinity') 10.125 @@ -947,16 +1018,20 @@ def xm_vcpu_list(args): 10.126 cpumap = map(lambda x: int(x), cpumap) 10.127 cpumap.sort() 10.128 10.129 - for x in server.xend.node.info()[1:]: 10.130 - if len(x) > 1 and x[0] == 'nr_cpus': 10.131 - nr_cpus = int(x[1]) 10.132 - # normalize cpumap by modulus nr_cpus, and drop duplicates 10.133 - cpumap = dict.fromkeys( 10.134 - map(lambda x: x % nr_cpus, cpumap)).keys() 10.135 - if len(cpumap) == nr_cpus: 10.136 - return "any cpu" 10.137 - break 10.138 - 10.139 + if serverType == SERVER_XEN_API: 10.140 + nr_cpus = len(server.xenapi.host.get_host_CPUs( 10.141 + server.xenapi.session.get_this_host())) 10.142 + else: 10.143 + for x in server.xend.node.info()[1:]: 10.144 + if len(x) > 1 and x[0] == 'nr_cpus': 10.145 + nr_cpus = int(x[1]) 10.146 + 10.147 + # normalize cpumap by modulus nr_cpus, and drop duplicates 10.148 + cpumap = dict.fromkeys( 10.149 + map(lambda x: x % nr_cpus, cpumap)).keys() 10.150 + if len(cpumap) == nr_cpus: 10.151 + return "any cpu" 10.152 + 10.153 return format_pairs(list_to_rangepairs(cpumap)) 10.154 10.155 name = get_info('name') 10.156 @@ -1154,13 +1229,17 @@ def xm_vcpu_pin(args): 10.157 return cpus 10.158 10.159 dom = args[0] 10.160 - vcpu = args[1] 10.161 + vcpu = int(args[1]) 10.162 if args[2] == 'all': 10.163 cpumap = cpu_make_map('0-63') 10.164 else: 10.165 cpumap = cpu_make_map(args[2]) 10.166 - 10.167 - server.xend.domain.pincpu(dom, vcpu, cpumap) 10.168 + 10.169 + if serverType == SERVER_XEN_API: 10.170 + server.xenapi.VM.add_to_VCPUs_params_live( 10.171 + get_single_vm(dom), "cpumap%i" % vcpu, ",".join(cpumap)) 10.172 + else: 10.173 + server.xend.domain.pincpu(dom, vcpu, cpumap) 10.174 10.175 def xm_mem_max(args): 10.176 arg_check(args, "mem-max", 2) 10.177 @@ -1194,7 +1273,7 @@ def xm_vcpu_set(args): 10.178 vcpus = int(args[1]) 10.179 10.180 if serverType == SERVER_XEN_API: 10.181 - server.xenapi.VM.set_vcpus_live(get_single_vm(dom), vcpus) 10.182 + server.xenapi.VM.set_VCPUs_number_live(get_single_vm(dom), vcpus) 10.183 else: 10.184 server.xend.domain.setVCpuCount(dom, vcpus) 10.185 10.186 @@ -1231,6 +1310,8 @@ def xm_domname(args): 10.187 print sxp.child_value(dom, 'name') 10.188 10.189 def xm_sched_sedf(args): 10.190 + xenapi_unsupported() 10.191 + 10.192 def ns_to_ms(val): 10.193 return float(val) * 0.000001 10.194 10.195 @@ -1355,10 +1436,21 @@ def xm_sched_credit(args): 10.196 10.197 for d in doms: 10.198 try: 10.199 - info = server.xend.domain.sched_credit_get(d['domid']) 10.200 + if serverType == SERVER_XEN_API: 10.201 + info = server.xenapi.VM_metrics.get_VCPUs_params( 10.202 + server.xenapi.VM.get_metrics( 10.203 + get_single_vm(d['name']))) 10.204 + else: 10.205 + info = server.xend.domain.sched_credit_get(d['domid']) 10.206 except xmlrpclib.Fault: 10.207 + pass 10.208 + 10.209 + if 'weight' not in info or 'cap' not in info: 10.210 # domain does not support sched-credit? 10.211 info = {'weight': -1, 'cap': -1} 10.212 + 10.213 + info['weight'] = int(info['weight']) 10.214 + info['cap'] = int(info['cap']) 10.215 10.216 info['name'] = d['name'] 10.217 info['domid'] = int(d['domid']) 10.218 @@ -1368,10 +1460,20 @@ def xm_sched_credit(args): 10.219 # place holder for system-wide scheduler parameters 10.220 err("No domain given.") 10.221 usage('sched-credit') 10.222 - 10.223 - result = server.xend.domain.sched_credit_set(domid, weight, cap) 10.224 - if result != 0: 10.225 - err(str(result)) 10.226 + 10.227 + if serverType == SERVER_XEN_API: 10.228 + server.xenapi.VM.add_to_VCPUs_params_live( 10.229 + get_single_vm(domid), 10.230 + "weight", 10.231 + weight) 10.232 + server.xenapi.VM.add_to_VCPUs_params_live( 10.233 + get_single_vm(domid), 10.234 + "cap", 10.235 + cap) 10.236 + else: 10.237 + result = server.xend.domain.sched_credit_set(domid, weight, cap) 10.238 + if result != 0: 10.239 + err(str(result)) 10.240 10.241 def xm_info(args): 10.242 arg_check(args, "info", 0) 10.243 @@ -1754,6 +1856,7 @@ def xm_block_list(args): 10.244 % ni) 10.245 10.246 def xm_vtpm_list(args): 10.247 + xenapi_unsupported() 10.248 (use_long, params) = arg_check_for_resource_list(args, "vtpm-list") 10.249 10.250 dom = params[0] 10.251 @@ -1883,7 +1986,10 @@ def xm_network_attach(args): 10.252 record = vif_record 10.253 for key in keys[:-1]: 10.254 record = record[key] 10.255 - record[keys[-1]] = val 10.256 + record[keys[-1]] = val 10.257 + 10.258 + def get_net_from_bridge(bridge): 10.259 + raise "Not supported just yet" 10.260 10.261 vif_conv = { 10.262 'type': 10.263 @@ -1991,6 +2097,7 @@ def xm_network_detach(args): 10.264 10.265 10.266 def xm_vnet_list(args): 10.267 + xenapi_unsupported() 10.268 try: 10.269 (options, params) = getopt.gnu_getopt(args, 'l', ['long']) 10.270 except getopt.GetoptError, opterr: 10.271 @@ -2019,6 +2126,7 @@ def xm_vnet_list(args): 10.272 print vnet, ex 10.273 10.274 def xm_vnet_create(args): 10.275 + xenapi_unsupported() 10.276 arg_check(args, "vnet-create", 1) 10.277 conf = args[0] 10.278 if not os.access(conf, os.R_OK): 10.279 @@ -2028,6 +2136,7 @@ def xm_vnet_create(args): 10.280 server.xend_vnet_create(conf) 10.281 10.282 def xm_vnet_delete(args): 10.283 + xenapi_unsupported() 10.284 arg_check(args, "vnet-delete", 1) 10.285 vnet = args[0] 10.286 server.xend_vnet_delete(vnet) 10.287 @@ -2044,7 +2153,7 @@ commands = { 10.288 "domid": xm_domid, 10.289 "domname": xm_domname, 10.290 "dump-core": xm_dump_core, 10.291 - "reboot": xm_reboot, 10.292 + "reboot": xm_reboot, 10.293 "rename": xm_rename, 10.294 "restore": xm_restore, 10.295 "resume": xm_resume, 10.296 @@ -2228,6 +2337,8 @@ def _run_cmd(cmd, cmd_name, args): 10.297 err(str(e)) 10.298 _usage(cmd_name) 10.299 print e.usage 10.300 + except XenAPIUnsupportedException, e: 10.301 + err(str(e)) 10.302 except Exception, e: 10.303 if serverType != SERVER_XEN_API: 10.304 from xen.util import security
11.1 --- a/tools/python/xen/xm/xenapi_create.py Thu Mar 22 09:30:54 2007 -0600 11.2 +++ b/tools/python/xen/xm/xenapi_create.py Fri Mar 23 10:11:58 2007 +0000 11.3 @@ -242,9 +242,9 @@ class xenapi_create: 11.4 "user_version": 11.5 get_text_in_child_node(vm, "version"), 11.6 "is_a_template": 11.7 - vm.attributes["is_a_template"].value, 11.8 + vm.attributes["is_a_template"].value == 'true', 11.9 "auto_power_on": 11.10 - vm.attributes["auto_power_on"].value, 11.11 + vm.attributes["auto_power_on"].value == 'true', 11.12 "memory_static_max": 11.13 get_child_node_attribute(vm, "memory", "static_max"), 11.14 "memory_static_min": 11.15 @@ -253,11 +253,11 @@ class xenapi_create: 11.16 get_child_node_attribute(vm, "memory", "dynamic_max"), 11.17 "memory_dynamic_min": 11.18 get_child_node_attribute(vm, "memory", "dynamic_min"), 11.19 - "vcpus_params": 11.20 + "VCPUs_params": 11.21 get_child_nodes_as_dict(vm, "vcpu_param", "key", "value"), 11.22 - "vcpus_max": 11.23 + "VCPUs_max": 11.24 vm.attributes["vcpus_max"].value, 11.25 - "vcpus_at_startup": 11.26 + "VCPUs_at_startup": 11.27 vm.attributes["vcpus_at_startup"].value, 11.28 "actions_after_shutdown": 11.29 vm.attributes["actions_after_shutdown"].value, 11.30 @@ -591,7 +591,6 @@ class sxp2xml: 11.31 def extract_vdi(self, vbd_sxp, document): 11.32 src = get_child_by_name(vbd_sxp, "uname") 11.33 name = "vdi" + str(src.__hash__()) 11.34 - path = src[src.find(":")+1:] 11.35 11.36 vdi = document.createElement("vdi") 11.37 11.38 @@ -599,8 +598,7 @@ class sxp2xml: 11.39 vdi.attributes["read_only"] \ 11.40 = (get_child_by_name(vbd_sxp, "mode") != "w") \ 11.41 and "true" or "false" 11.42 - vdi.attributes["size"] \ 11.43 - = str(os.path.getsize(path)) 11.44 + vdi.attributes["size"] = '-1' 11.45 vdi.attributes["type"] = "system" 11.46 vdi.attributes["shareable"] = "false" 11.47 vdi.attributes["name"] = name