01_restore_basic_pos.py

来自「xen 3.2.2 源码」· Python 代码 · 共 83 行

PY
83
字号
#!/usr/bin/python# Copyright (C) International Business Machines Corp., 2005# Author: Dan Smith <danms@us.ibm.com># Save a domain and attempt to restore it## Since we don't want to depend on the fact that save/01_basic_pos.py# ran successfully, we try to save the domain here againimport timefrom XmTestLib import *if ENABLE_HVM_SUPPORT:    SKIP("Restore currently not supported for HVM domains")domain = XmTestDomain()try:    console = domain.start()except DomainError, e:    if verbose:        print "Failed to create test domain because:"        print e.extra    FAIL(str(e))# Make sure the domain isn't DOAtry:    console.runCmd("foo=bar")except ConsoleError, e:    FAIL(str(e))domain.closeConsole()# Save it outtry:    s, o = traceCommand("xm save %s /tmp/test.state" % domain.getName(),                        timeout=30)except TimeoutError, e:    FAIL(str(e))    if s != 0:    FAIL("save command exited %i != 0" % s)# FIXME: Give the system some time to update the internal statetraceCommand("xm list")# Make sure it's goneif isDomainRunning(domain.getName()):    FAIL("Domain still running after save!")# Let things settletime.sleep(2)# Restore it instatus, output = traceCommand("xm restore /tmp/test.state",                              timeout=30)if s != 0:    FAIL("restore command exited %i != 0" % s)# Make sure it's runningif not isDomainRunning(domain.getName()):    FAIL("Restore didn't result in a running %s domain!" % domain.getName())# Make sure it's alivetry:    newConsole = domain.getConsole()    # Enable debug dumping because this generates a Oops on x86_64    newConsole.debugMe = True    newConsole.sendInput("ls")    run = newConsole.runCmd("echo xx$foo")    if not re.search("bar", run["output"]):        FAIL("Restored domain has been reset")except ConsoleError, e:    FAIL("Restored domain is dead (%s)" % str(e))domain.closeConsole()# This only works because the domain# still has the same namedomain.stop()

⌨️ 快捷键说明

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