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

📄 create.py

📁 xen虚拟机源代码安装包
💻 PY
📖 第 1 页 / 共 4 页
字号:
#============================================================================# This library is free software; you can redistribute it and/or# modify it under the terms of version 2.1 of the GNU Lesser General Public# License as published by the Free Software Foundation.## This library is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU# Lesser General Public License for more details.## You should have received a copy of the GNU Lesser General Public# License along with this library; if not, write to the Free Software# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA#============================================================================# Copyright (C) 2004, 2005 Mike Wray <mike.wray@hp.com># Copyright (C) 2005 Nguyen Anh Quynh <aquynh@gmail.com># Copyright (C) 2005-2006 XenSource Ltd#============================================================================"""Domain creation."""import osimport os.pathimport sysimport socketimport reimport timeimport xmlrpclibfrom xen.xend import sxpfrom xen.xend import PrettyPrint as SXPPrettyPrintfrom xen.xend import osdepimport xen.xend.XendClientfrom xen.xend.XendBootloader import bootloaderfrom xen.util import blkiffrom xen.util import vscsi_utilimport xen.util.xsm.xsm as securityfrom xen.xm.main import serverType, SERVER_XEN_API, get_single_vmfrom xen.util import utilsfrom xen.xm.opts import *from main import serverfrom main import domain_name_to_domidimport consolegopts = Opts(use="""[options] [vars]Create a domain.Domain creation parameters can be set by command-line switches, froma python configuration script or an SXP config file. See documentationfor --defconfig, --config. Configuration variables can be set usingVAR=VAL on the command line. For example vmid=3 sets vmid to 3.""")gopts.opt('help', short='h',          fn=set_true, default=0,          use="Print this help.")gopts.opt('help_config',          fn=set_true, default=0,          use="Print the available configuration variables (vars) for the "          "configuration script.")gopts.opt('quiet', short='q',          fn=set_true, default=0,          use="Quiet.")gopts.opt('path', val='PATH',          fn=set_value, default='.:/etc/xen',          use="Search path for configuration scripts. "          "The value of PATH is a colon-separated directory list.")gopts.opt('defconfig', short='f', val='FILE',          fn=set_value, default='xmdefconfig',          use="Use the given Python configuration script."          "The configuration script is loaded after arguments have been "          "processed. Each command-line option sets a configuration "          "variable named after its long option name, and these "          "variables are placed in the environment of the script before "          "it is loaded. Variables for options that may be repeated have "          "list values. Other variables can be set using VAR=VAL on the "          "command line. "               "After the script is loaded, option values that were not set "          "on the command line are replaced by the values set in the script.")gopts.default('defconfig')gopts.opt('config', short='F', val='FILE',          fn=set_value, default=None,          use="Domain configuration to use (SXP).\n"          "SXP is the underlying configuration format used by Xen.\n"          "SXP configurations can be hand-written or generated from Python "          "configuration scripts, using the -n (dryrun) option to print "          "the configuration.")gopts.opt('dryrun', short='n',          fn=set_true, default=0,          use="Dry run - prints the resulting configuration in SXP but "          "does not create the domain.")gopts.opt('xmldryrun', short='x',          fn=set_true, default=0,          use="XML dry run - prints the resulting configuration in XML but "          "does not create the domain.")gopts.opt('skipdtd', short='s',          fn=set_true, default=0,          use="Skip DTD checking - skips checks on XML before creating. "          " Experimental.  Can decrease create time." )gopts.opt('paused', short='p',          fn=set_true, default=0,          use='Leave the domain paused after it is created.')gopts.opt('console_autoconnect', short='c',          fn=set_true, default=0,          use="Connect to the console after the domain is created.")gopts.opt('vncviewer',          fn=set_true, default=0,          use="Connect to the VNC display after the domain is created.")gopts.opt('vncviewer-autopass',          fn=set_true, default=0,          use="Pass VNC password to viewer via stdin and -autopass.")gopts.var('vncpasswd', val='NAME',          fn=set_value, default=None,          use="Password for VNC console on HVM domain.")gopts.var('vncviewer', val='no|yes',          fn=set_bool, default=None,           use="Spawn a vncviewer listening for a vnc server in the domain.\n"           "The address of the vncviewer is passed to the domain on the "           "kernel command line using 'VNC_SERVER=<host>:<port>'. The port "           "used by vnc is 5500 + DISPLAY. A display value with a free port "           "is chosen if possible.\nOnly valid when vnc=1.\nDEPRECATED")gopts.var('vncconsole', val='no|yes',          fn=set_bool, default=None,          use="Spawn a vncviewer process for the domain's graphical console.\n"          "Only valid when vnc=1.")gopts.var('name', val='NAME',          fn=set_value, default=None,          use="Domain name. Must be unique.")gopts.var('bootloader', val='FILE',          fn=set_value, default=None,          use="Path to bootloader.")gopts.var('bootargs', val='NAME',          fn=set_value, default=None,          use="Arguments to pass to boot loader")gopts.var('bootentry', val='NAME',          fn=set_value, default=None,          use="DEPRECATED.  Entry to boot via boot loader.  Use bootargs.")gopts.var('kernel', val='FILE',          fn=set_value, default=None,          use="Path to kernel image.")gopts.var('ramdisk', val='FILE',          fn=set_value, default='',          use="Path to ramdisk.")gopts.var('loader', val='FILE',          fn=set_value, default='',          use="Path to HVM firmware.")gopts.var('features', val='FEATURES',          fn=set_value, default='',          use="Features to enable in guest kernel")gopts.var('builder', val='FUNCTION',          fn=set_value, default='linux',          use="Function to use to build the domain.")gopts.var('memory', val='MEMORY',          fn=set_int, default=128,          use="Domain memory in MB.")gopts.var('maxmem', val='MEMORY',          fn=set_int, default=None,          use="Maximum domain memory in MB.")gopts.var('shadow_memory', val='MEMORY',          fn=set_int, default=0,          use="Domain shadow memory in MB.")gopts.var('cpu', val='CPU',          fn=set_int, default=None,          use="CPU to run the VCPU0 on.")gopts.var('cpus', val='CPUS',          fn=set_value, default=None,          use="CPUS to run the domain on.")gopts.var('rtc_timeoffset', val='RTC_TIMEOFFSET',          fn=set_value, default="0",          use="Set RTC offset.")gopts.var('pae', val='PAE',          fn=set_int, default=1,          use="Disable or enable PAE of HVM domain.")gopts.var('hpet', val='HPET',          fn=set_int, default=0,          use="Enable virtual high-precision event timer.")gopts.var('timer_mode', val='TIMER_MODE',          fn=set_int, default=0,          use="""Timer mode (0=delay virtual time when ticks are missed;          1=virtual time is always wallclock time.""")gopts.var('acpi', val='ACPI',          fn=set_int, default=1,          use="Disable or enable ACPI of HVM domain.")gopts.var('apic', val='APIC',          fn=set_int, default=1,          use="Disable or enable APIC mode.")gopts.var('vcpus', val='VCPUS',          fn=set_int, default=1,          use="# of Virtual CPUS in domain.")gopts.var('vcpu_avail', val='VCPUS',          fn=set_long, default=None,          use="Bitmask for virtual CPUs to make available immediately.")gopts.var('vhpt', val='VHPT',          fn=set_int, default=0,          use="Log2 of domain VHPT size for IA64.")gopts.var('cpu_cap', val='CAP',          fn=set_int, default=None,          use="""Set the maximum amount of cpu.          CAP is a percentage that fixes the maximum amount of cpu.""")gopts.var('cpu_weight', val='WEIGHT',          fn=set_int, default=None,          use="""Set the cpu time ratio to be allocated to the domain.""")gopts.var('restart', val='onreboot|always|never',          fn=set_value, default=None,          use="""Deprecated.  Use on_poweroff, on_reboot, and on_crash          instead.          Whether the domain should be restarted on exit.          - onreboot: restart on exit with shutdown code reboot          - always:   always restart on exit, ignore exit code          - never:    never restart on exit, ignore exit code""")gopts.var('on_poweroff', val='destroy|restart|preserve|rename-restart',          fn=set_value, default=None,          use="""Behaviour when a domain exits with reason 'poweroff'.          - destroy:        the domain is cleaned up as normal;          - restart:        a new domain is started in place of the old one;          - preserve:       no clean-up is done until the domain is manually                            destroyed (using xm destroy, for example);          - rename-restart: the old domain is not cleaned up, but is                            renamed and a new domain started in its place.          """)gopts.var('on_reboot', val='destroy|restart|preserve|rename-restart',          fn=set_value, default=None,          use="""Behaviour when a domain exits with reason 'reboot'.          - destroy:        the domain is cleaned up as normal;          - restart:        a new domain is started in place of the old one;          - preserve:       no clean-up is done until the domain is manually                            destroyed (using xm destroy, for example);          - rename-restart: the old domain is not cleaned up, but is                            renamed and a new domain started in its place.          """)gopts.var('on_crash', val='destroy|restart|preserve|rename-restart|coredump-destroy|coredump-restart',          fn=set_value, default=None,          use="""Behaviour when a domain exits with reason 'crash'.          - destroy:          the domain is cleaned up as normal;          - restart:          a new domain is started in place of the old one;          - preserve:         no clean-up is done until the domain is manually                              destroyed (using xm destroy, for example);          - rename-restart:   the old domain is not cleaned up, but is                              renamed and a new domain started in its place.          - coredump-destroy: dump the domain's core, followed by destroy          - coredump-restart: dump the domain's core, followed by restart          """)gopts.var('blkif', val='no|yes',          fn=set_bool, default=0,          use="Make the domain a block device backend.")gopts.var('netif', val='no|yes',          fn=set_bool, default=0,          use="Make the domain a network interface backend.")gopts.var('tpmif', val='no|yes',          fn=append_value, default=0,          use="Make the domain a TPM interface backend.")gopts.var('disk', val='phy:DEV,VDEV,MODE[,DOM]',          fn=append_value, default=[],          use="""Add a disk device to a domain. The physical device is DEV,          which is exported to the domain as VDEV. The disk is read-only if MODE          is 'r', read-write if MODE is 'w'. If DOM is specified it defines the          backend driver domain to use for the disk.          The option may be repeated to add more than one disk.""")gopts.var('pci', val='BUS:DEV.FUNC',          fn=append_value, default=[],          use="""Add a PCI device to a domain, using given params (in hex).         For example 'pci=c0:02.1'.         The option may be repeated to add more than one pci device.""")gopts.var('vscsi', val='PDEV,VDEV[,DOM]',          fn=append_value, default=[],          use="""Add a SCSI device to a domain. The physical device is PDEV,          which is exported to the domain as VDEV(X:X:X:X).""")gopts.var('ioports', val='FROM[-TO]',          fn=append_value, default=[],          use="""Add a legacy I/O range to a domain, using given params (in hex).         For example 'ioports=02f8-02ff'.         The option may be repeated to add more than one i/o range.""")gopts.var('irq', val='IRQ',          fn=append_value, default=[],          use="""Add an IRQ (interrupt line) to a domain.         For example 'irq=7'.         This option may be repeated to add more than one IRQ.""")gopts.var('vfb', val="type={vnc,sdl},vncunused=1,vncdisplay=N,vnclisten=ADDR,display=DISPLAY,xauthority=XAUTHORITY,vncpasswd=PASSWORD,opengl=1,keymap=FILE",          fn=append_value, default=[],          use="""Make the domain a framebuffer backend.          The backend type should be either sdl or vnc.

⌨️ 快捷键说明

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