⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 01_memset_basic_pos.py

📁 xen虚拟机源代码安装包
💻 PY
字号:
#!/usr/bin/python# Copyright (C) International Business Machines Corp., 2005# Author: Woody Marvel <marvel@us.ibm.com>#### Description:## Tests that verify mem-set output and return code## 1) Test for xm mem-set##	create domain,##	verify domain and ls output,##	mem-set in dom0,##	verify with xm list memory change external,##	verify with xm list memory change internal,#### Author: Woody Marvel		marvel@us.ibm.com##import sys import re import time from XmTestLib import * if ENABLE_HVM_SUPPORT:    SKIP("Mem-set not supported for HVM domains")# Create a domain (default XmTestDomain, with our ramdisk)domain = XmTestDomain() # Start ittry:    console = domain.start() except DomainError, e:    if verbose:        print "Failed to create test domain because:"        print e.extra    FAIL(str(e))try:    # Make sure it's up an running before we continue    console.runCmd("ls")except ConsoleError, e:    FAIL(str(e))    try:    run = console.runCmd("cat /proc/xen/balloon | grep Current");except ConsoleError, e:    FAIL(str(e))match = re.match("[^0-9]+([0-9]+)", run["output"])if not match:    FAIL("Invalid domU meminfo line")        origmem = int(match.group(1)) / 1024newmem = origmem - 1# set mem-set for less than defaultcmd = "xm mem-set %s %i" % (domain.getName(), newmem)status, output = traceCommand(cmd)if status != 0:    if verbose:        print "mem-set failed:"        print output    FAIL("cmd %s returned invalid %i != 0" % (cmd, status))for i in [1,2,3,4,5,6,7,8,9,10]:    mem = getDomMem(domain.getName())    if mem == newmem:        break    time.sleep(1)# verify memory set externallymem = getDomMem(domain.getName())if not mem:    FAIL("Failed to get memory amount for domain %s" % domain.getName())elif mem != newmem:    FAIL("Dom0 failed to verify %i MB; got %i MB" % newmem,mem)# verify memory set internallytry:    run = console.runCmd("cat /proc/xen/balloon | grep Current")except ConsoleError, e:    FAIL(str(e))# Check the output of 'cat /proc/xen/balloon'm = re.match("^Current allocation:\s+(\d+)\skB", run["output"])if not m:     FAIL("The DomU command 'cat /proc/xen/balloon' failed.")domUmem = int(m.group(1)) / 1024if domUmem != newmem:    FAIL("DomU reported incorrect memory amount: %i MB" % (domUmem))# quiesce everything# Close the consoledomain.closeConsole() # Stop the domain (nice shutdown)domain.stop()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -