Revision 16ca6243 lib/hypervisor/hv_xen.py
b/lib/hypervisor/hv_xen.py | ||
---|---|---|
315 | 315 |
- hv_version: the hypervisor version in the form (major, minor) |
316 | 316 |
|
317 | 317 |
""" |
318 |
# note: in xen 3, memory has changed to total_memory |
|
319 | 318 |
result = utils.RunCmd([constants.XEN_CMD, "info"]) |
320 | 319 |
if result.failed: |
321 | 320 |
logging.error("Can't run 'xm info' (%s): %s", result.fail_reason, |
... | ... | |
326 | 325 |
result = {} |
327 | 326 |
cores_per_socket = threads_per_core = nr_cpus = None |
328 | 327 |
xen_major, xen_minor = None, None |
328 |
memory_total = None |
|
329 |
memory_free = None |
|
330 |
|
|
329 | 331 |
for line in xmoutput: |
330 | 332 |
splitfields = line.split(":", 1) |
331 | 333 |
|
332 | 334 |
if len(splitfields) > 1: |
333 | 335 |
key = splitfields[0].strip() |
334 | 336 |
val = splitfields[1].strip() |
337 |
|
|
338 |
# note: in xen 3, memory has changed to total_memory |
|
335 | 339 |
if key == "memory" or key == "total_memory": |
336 |
result["memory_total"] = int(val)
|
|
340 |
memory_total = int(val)
|
|
337 | 341 |
elif key == "free_memory": |
338 |
result["memory_free"] = int(val)
|
|
342 |
memory_free = int(val)
|
|
339 | 343 |
elif key == "nr_cpus": |
340 | 344 |
nr_cpus = result["cpu_total"] = int(val) |
341 | 345 |
elif key == "nr_nodes": |
... | ... | |
349 | 353 |
elif key == "xen_minor": |
350 | 354 |
xen_minor = int(val) |
351 | 355 |
|
352 |
if (cores_per_socket is not None and |
|
353 |
threads_per_core is not None and nr_cpus is not None): |
|
356 |
if None not in [cores_per_socket, threads_per_core, nr_cpus]: |
|
354 | 357 |
result["cpu_sockets"] = nr_cpus / (cores_per_socket * threads_per_core) |
355 | 358 |
|
356 |
dom0_info = self.GetInstanceInfo(_DOM0_NAME) |
|
357 |
if dom0_info is not None: |
|
358 |
result["memory_dom0"] = dom0_info[2] |
|
359 |
result["dom0_cpus"] = dom0_info[3] |
|
359 |
total_instmem = 0 |
|
360 |
for (name, _, mem, vcpus, _, _) in self._GetXMList(True): |
|
361 |
if name == _DOM0_NAME: |
|
362 |
result["memory_dom0"] = mem |
|
363 |
result["dom0_cpus"] = vcpus |
|
364 |
|
|
365 |
# Include Dom0 in total memory usage |
|
366 |
total_instmem += mem |
|
367 |
|
|
368 |
if memory_free is not None: |
|
369 |
result["memory_free"] = memory_free |
|
370 |
|
|
371 |
if memory_total is not None: |
|
372 |
result["memory_total"] = memory_total |
|
373 |
|
|
374 |
# Calculate memory used by hypervisor |
|
375 |
if None not in [memory_total, memory_free, total_instmem]: |
|
376 |
result["memory_hv"] = memory_total - memory_free - total_instmem |
|
360 | 377 |
|
361 | 378 |
if not (xen_major is None or xen_minor is None): |
362 | 379 |
result[constants.HV_NODEINFO_KEY_VERSION] = (xen_major, xen_minor) |
Also available in: Unified diff