本地iso安装如下:
# =====================================================================
# Example HVM guest configuration
# =====================================================================
#
# This is a fairly minimal example of what is required for an
# HVM guest. For a more complete guide see xl.cfg(5)# This configures an HVM rather than PV guest
builder = "hvm"# Guest name
name = "test.hvm"# 128-bit UUID for the domain as a hexadecimal number.
# Use "uuidgen" to generate one if required.
# The default behavior is to generate a new UUID each time the guest is started.
#uuid = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"# Enable Microsoft Hyper-V compatibile paravirtualisation /
# enlightenment interfaces. Turning this on can improve Windows guest
# performance and is therefore recommended
#viridian = 1# Initial memory allocation (MB)
memory = 1024# Maximum memory (MB)
# If this is greater than `memory' then the slack will start ballooned
# (this assumes guest kernel support for ballooning)
#maxmem = 512# Number of VCPUS
vcpus = 2# Network devices
# A list of 'vifspec' entries as described in
# docs/misc/xl-network-configuration.markdown
vif = [ 'mac=00:16:36:48:87:7B,model=rtl8139,bridge=virbr0' ]# Disk Devices
# A list of `diskspec' entries as described in
# docs/misc/xl-disk-configuration.txt
disk = [ '/opt/xen/test.img,raw,xvda,rw','/root/ubuntu.iso,,xvdb,cdrom' ]# Guest VGA console configuration, either SDL or VNC
sdl = 1
boot="c"
#vnc = 1
光驱安装过程如下:
mport os, re
arch = os.uname()[4]
if re.search('64', arch):arch_libdir = 'lib64'
else:arch_libdir = 'lib'kernel = "/usr/lib/xen/boot/hvmloader"
builder = 'hvm'
memory = 2048
name = "Hybrid"
vcpus = 4
vif = [ 'type=vnif, mac=00:16:36:48:87:7B' ]
disk = ['file:/var/lib/xen/images/CentOS_x64.img,xvda,w', 'phy:/dev/cdrom,hdc:cdrom,r']
on_poweroff = 'destroy'
on_reboot   = 'restart'
device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm'
vnc=1
localtime=1
usb=1
boot="dc"安装完成后,1.
  1. disk = [ "file:/home/xen/images/windows2003.disk1.img,hda,w", "file:/home/WindowsServer2003SP2.iso,ioemu:hdc:cdrom,r" ]
重点在第二个参数:把/home/WindowsServer2003SP2.iso通过io虚拟,虚拟成一个cdrom,属性只读

 2."file:/home/WindowsServer2003SP2.iso,ioemu:hdc:cdrom,r"   

2.修改hybrid.hvm中的“boot="c"”,即直接从硬盘启动。
安装完成后,系统可能没有默认的网络配置eth0。此时需要手动添加,包括网卡硬件和配置。
创建虚机xm create命令的选项

  1. --config (-F) 配置文件的路径
  2. -n (--dryrun) config_file 显示python配置文件对应的SXP格式(该文件还会在/var/lib/xend/domains/UUID/config.sxp保存一份,而且/var/lib/xend/domains/UUID/config.sxp保存的配置更为全面。
  3. -s (--skipdtd) 忽略XML DTD检测,启动后可减少虚机的创建时间
  4. -p (--paused) 创建后不自动启动
  5. --vncviewer 自动连接vnc display
  6. -c (--console_autoconnect)自动连接控制台
  7. --vncviewer-autopass 通过stdin传入VNC的密码
配置文件的选项列表

'vncpasswd'='NAME', # 传入HVM虚机的VNC密码 one, 说明:"Password for VNC console on HVM domain."'vncviewer'='no|yes', #是否启动vnc one, 说明:"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"'vncconsole'='no|yes', one, 说明:"Spawn a vncviewer process for the domain's graphical console.\n" "Only valid when vnc=1."'name'='NAME',   #  设置虚机名字 one, 说明:"Domain name. Must be unique."'bootloader'='FILE', # 设置bootloader文件 one, 说明:"Path to bootloader."'bootargs'='NAME',   # boot loader参数 one, 说明:"Arguments to pass to boot loader"'bootentry'='NAME', one, 说明:"DEPRECATED.  Entry to boot via boot loader.  Use bootargs."'kernel'='FILE',     # 设置kernel路径 one, 说明:"Path to kernel image." HVM虚机使用kernel = "/usr/lib/xen/boot/hvmloader"'ramdisk'='FILE',    # 设置ramdisk路径 default='', 说明:"Path to ramdisk."'loader'='FILE',     #  HVM firmware路径 default='', 说明:"Path to HVM firmware."'features'='FEATURES',   # Features to enable in guest kernel default='', 说明:"Features to enable in guest kernel"'builder'='FUNCTION',    # 默认linux,HVM虚机为hvm default='linux', 说明:"Function to use to build the domain."'memory'='MEMORY',       #  内存 单位MB default=128, 说明:"Domain memory in MB."'maxmem'='MEMORY',       #  最大内存 单位MB one, 说明:"Maximum domain memory in MB."'shadow_memory'='MEMORY',    # shadow_ default=0, 说明:"Domain shadow memory in MB."'cpu'='CPU',             #  物理CPU one, 说明:"CPU to run the VCPU0 on."'cpus'='CPUS',           #  物理CPU one, 说明:"CPUS to run the domain on." cpus = ""          不指定,让XEN自己去选择。 cpus = "0"         指定让虚拟机的VCPU运行在宿主机的CPU0(第一个CPU,0号)。 cpus = "0-3"       指定让虚拟机的VCPU运行在宿主机的0号、1号、2号、3号CPU。 cpus = "5"         指定让虚拟机的VCPU运行在宿主机的5号CPU上(第六个CPU)。 cpus = "^1"        指定让虚拟机的VCPU不运行在宿主机除1号CPU上(^表示“非”的意思,但没有说是“除这个之外其他全部”的意思,而仅仅是“非”的意思)。 cpus = "0-3,5,^1" 指定让虚拟机的VCPU运行在宿主机的0、1、2、3、5号CPU上,但是由于最后跟着一个^1,所以要把1号CPU去掉。实际指定的是0、2、3、5这四个CPU。'rtc_timeoffset'='RTC_TIMEOFFSET', # rtc_ Set RTC offset default=0, 说明:"Set RTC offset."'pae'='PAE',     # pae=1 使能HVM虚机PAE default=1, 说明:"Disable or enable PAE of HVM domain."'hpet'='HPET',   # hpet=0 Enable virtual high-precision event timer default=0, 说明:"Enable virtual high-precision event timer."'timer_mode'='TIMER_MODE', # timer_ default=1, 说明:Timer mode (0=delay virtual time when ticks are missed; 1=virtual time is always wallclock time.'vpt_align'='VPT_ALIGN',     # vpt_ default=1, 说明:"Enable aligning all periodic vpt to reduce timer interrupts."'viridian'='VIRIDIAN',       # viridian=0 default=0, 说明:Expose Viridian interface to x86 HVM guest? (Default is 0).'acpi'='ACPI',               # acpi=1 enbale HVM ACPI default=1, 说明:"Disable or enable ACPI of HVM domain."'apic'='APIC',               # apic=1 enable APIC mode default=1, 说明:"Disable or enable APIC mode."'vcpus'='VCPUS',             #  虚机CPU的个数上限 default=1, 说明:"# of Virtual CPUS in domain."'vcpu_avail'='VCPUS',        # vcpu_ 可用vcpu one, 说明:"Bitmask for virtual CPUs to make available immediately."'vhpt'='VHPT',               #  for IA64 default=0, 说明:"Log2 of domain VHPT size for IA64."'cpu_cap'='CAP',             # cpu_ 可用物理CPU的最大百分比 one, 说明:Set the maximum amount of cpu. CAP is a percentage that fixes the maximum amount of cpu.'cpu_weight'='WEIGHT',       # cpu_ 物理CPU分配的权值 one, 说明:Set the cpu time ratio to be allocated to the domain.'restart'='onreboot|always|never', one, 说明: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'on_poweroff'='destroy|restart|preserve|rename-restart', # on_|restart|preserve|rename-restart 虚机关机时的动作 one, 说明: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.'on_reboot'='destroy|restart|preserve|rename-restart', # 虚机重启的动作 one, 说明: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.'on_crash'='destroy|restart|preserve|rename-restart|coredump-destroy|coredump-restart', one,   #虚机崩溃时的动作 说明: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'blkif'='no|yes',    # Make the domain a block device backend default=0, 说明:"Make the domain a block device backend."'netif'='no|yes', default=0,   # ake the domain a network interface backend 说明:"Make the domain a network interface backend."'tpmif'='no|yes',    # Make the domain a TPM interface backend default=0, 说明:"Make the domain a TPM interface backend."'disk'='phy:DEV,VDEV,MODE[,DOM]', # 块设备 default=[], 说明: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. 示例: disk = [ 'phy:hda1,hda1,r' ] disk = [ 'file:/var/images/min-el3-i386.img,hda,w', ',hdc:cdrom,r' ]'pci'='BUS:DEV.FUNC[@VSLOT][,msitranslate=0|1][,power_mgmt=0|1]', default=[],  # pci设备 说明:Add a PCI device to a domain, using given params (in hex). For example '0:02.1'. If VSLOT is supplied the device will be inserted into that virtual slot in the guest, else a free slot is selected. If msitranslate is set, MSI-INTx translation is enabled if possible. Guest that doesn't support MSI will get IO-APIC type IRQs translated from physical MSI, HVM only. Default is 1. The option may be repeated to add more than one pci device. If power_mgmt is set, the guest OS will be able to program the power states D0-D3hot of the device, HVM only. Default=0.'vscsi'='PDEV,VDEV[,DOM]',   # SCSI设备 default=[], 说明:Add a SCSI device to a domain. The physical device is PDEV, which is exported to the domain as VDEV(X:X:X:X).'ioports'='FROM[-TO]',       # default=[], 说明: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.'irq'='IRQ', default=[], 说明:Add an IRQ (interrupt line) to a domain. For example 'irq=7'. This option may be repeated to add more than one IRQ.'vfb'="vnc=1,sdl=1,vncunused=1,vncdisplay=N,vnclisten=ADDR,display=DISPLAY,xauthority=XAUTHORITY,vncpasswd=PASSWORD,opengl=1,keymap=FILE" default=[], 说明:Make the domain a framebuffer backend. Both sdl=1 and vnc=1 can be enabled at the same time. For vnc=1, connect an external vncviewer.  The server will listen on ADDR (default 127.0.0.1) on port N+5900.  N defaults to the domain id.  If vncunused=1, the server will try to find an arbitrary unused port above 5900.  vncpasswd overrides the XenD configured default password. For sdl=1, a viewer will be started automatically using the given DISPLAY and XAUTHORITY, which default to the current user's ones.  OpenGL will be used by default unless opengl is set to 0. keymap overrides the XendD configured default layout file.'vif'="type=TYPE,mac=MAC,bridge=BRIDGE,ip=IPADDR,script=SCRIPT, "backend=DOM,vifname=NAME,rate=RATE,model=MODEL,accel=ACCEL" default=[], 说明:Add a network interface with the given MAC address and bridge. The vif is configured by calling the given configuration script. If type is not specified, default is netfront. If mac is not specified a random MAC address is used. If not specified then the network backend chooses it's own MAC address. If bridge is not specified the first bridge found is used. If script is not specified the default script is used. If backend is not specified the default backend driver domain is used. If vifname is not specified the backend virtual interface will have name vifD.N where D is the domain id and N is the interface id. If rate is not specified the default rate is used. If model is not specified the default model is used. If accel is not specified an accelerator plugin module is not used. This option may be repeated to add more than one vif. Specifying vifs will increase the number of interfaces as needed.'vtpm'="instance=INSTANCE,backend=DOM,type=TYPE" default=[], 说明:Add a TPM interface. On the backend side use the given instance as virtual TPM instance. The given number is merely the preferred instance number. The hotplug script will determine which instance number will actually be assigned to the domain. The associtation between virtual machine and the TPM instance number can be found in /etc/xen/vtpm.db. Use the backend in the given domain. The type parameter can be used to select a specific driver type that the VM can use. To prevent a fully virtualized domain (HVM) from being able to access an emulated device model, you may specify 'paravirtualized' here.'access_control'=",", default=[], 说明:Add a security label and the security policy reference that defines it. The local ssid reference is calculated when starting/resuming the domain. At this time, the policy is checked against the active policy as well. This way, migrating through save/restore is covered and local labels are automatically created correctly on the system where a domain is started / resumed.'nics'="NUM", default=-1, 说明:DEPRECATED.  Use empty vif entries instead.Set the number of network interfaces. Use the vif option to define interface parameters, otherwise defaults are used. Specifying vifs will increase the number of interfaces as needed.'root'='DEVICE', default='', 说明:Set the root= parameter on the kernel command line. Use a device, e.g. /dev/sda1, or /dev/nfs for NFS root.'extra'="ARGS", default='', 说明:"Set extra arguments to append to the kernel command line."'ip'='IPADDR', default='', 说明:"Set the kernel IP interface address."'gateway'="IPADDR", default='', 说明:"Set the kernel IP gateway."'netmask'="MASK", default = '', 说明:"Set the kernel IP netmask."'hostname'="NAME", default='', 说明:"Set the kernel IP hostname."'interface'="INTF", default="eth0", 说明:"Set the kernel IP interface name."'dhcp'="off|dhcp", default='off', 说明:"Set the kernel dhcp option."'nfs_server'="IPADDR", one, 说明:"Set the address of the NFS server for NFS root."'nfs_root'="PATH", one, 说明:"Set the path of the root NFS directory."'device_model'='FILE', one, 说明:"Path to device model program." HVM虚机可以设置为device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm''fda'='FILE', default='', 说明:"Path to fda"'fdb'='FILE', default='', 说明:"Path to fdb"'serial'='FILE', default='', 说明:"Path to serial or pty or vc"'monitor'='no|yes', default=0, 说明:Should the device model use monitor?'localtime'='no|yes', default=0, 说明:"Is RTC set to localtime?"'keymap'='FILE', default='', 说明:"Set keyboard layout used"'usb'='no|yes', default=0, 说明:"Emulate USB devices?"'usbdevice'='NAME', default='', 说明:"Name of USB device to add?"'guest_os_type'='NAME', default='default', 说明:"Guest OS type running in HVM"'stdvga'='no|yes', default=0, 说明:"Use std vga or cirrhus logic graphics"'isa'='no|yes', default=0, 说明:"Simulate an ISA only system?"'boot'="a|b|c|d", default='c', 说明:"Default boot device"'nographic'='no|yes', default=0, 说明:"Should device models use graphics?"'soundhw'='audiodev', default='', 说明:"Should device models enable audio device?"'vnc'='', 说明:Should the device model use VNC?'vncdisplay'='', 说明:VNC display to use'vnclisten'='', 说明:Address for VNC server to listen on.'vncunused'='', default=1, 说明:Try to find an unused port for the VNC server. Only valid when vnc=1.'videoram'='MEMORY', default=4, 说明:Maximum amount of videoram a guest can allocate for frame buffer.'sdl'='', 说明:Should the device model use SDL?'opengl'='', 说明:Enable\Disable OpenGL'display'='DISPLAY', 说明:"X11 display to use"'xauthority'='XAUTHORITY', 说明:"X11 Authority to use"'uuid'='', 说明:xenstore UUID (universally unique identifier) to use.  One will be randomly generated if this option is not set, just like MAC addresses for virtual network interfaces.  This must be a unique value across the entire cluster.'on_xend_start'='ignore|start', default='ignore', 说明:'Action to perform when xend starts')'on_xend_stop'='ignore|shutdown|suspend', default="ignore", 说明:Behaviour when Xend stops: - ignore:         Domain continues to run; - shutdown:       Domain is shutdown; - suspend:        Domain is suspended;'target'='TARGET', default=0, 说明:"Set domain target."'hap'='HAP', default=1, 说明:Hap status (0=hap is disabled; 1=hap is enabled.'s3_integrity'='TBOOT_MEMORY_PROTECT', default=1, 说明:Should domain memory integrity be verified during S3? (0=protection is disabled; 1=protection is enabled.'cpuid'="IN[,SIN]", default=[], 说明:Cpuid description.'cpuid_check'="IN[,SIN]", default=[], 说明:Cpuid check description.'machine_address_size'='BITS', one, 说明:Maximum machine address size'suppress_spurious_page_faults'='yes|no', one, 说明:Do not inject spurious page faults into this guest'pci_msitranslate'='TRANSLATE', default=1, 说明:Global PCI MSI-INTx translation flag (0=disable; 1=enable.'pci_power_mgmt'='POWERMGMT', default=0, 说明:Global PCI Power Management flag (0=disable;1=enable).'xen_platform_pci'='0|1', default=1, 说明:"Is xen_platform_pci used?"
关于viridian interface

At the moment we provide MSR access to APIC registers, and the hypercall
to yield the CPU when waiting for a spinlock.  We looked at a few others
(e.g. address-space-change hypercall) but found the benefits, if any,
were negligible.
The most important part of the interface is that we can use it to tell
Windows not to expect timer interrupt delivery to be as even across all
CPUs as it would be on bare metal.  This gets rid of annoying STOP 0x101
bluescreens in multi-vcpu Windows from Vista on.
PAE

PAE,物理地址扩展,是基于x86 的服务器的一种功能,它使运行 Windows Server 2003, Enterprise Edition 和 Windows Server 2003,Datacenter Edition 的计算机可以支持4GB 以上物理内存。物理地址扩展 (PAE) 允许将最多64GB 的物理内存用作常规的4 KB 页面,并扩展内核能使用的位数以将物理内存地址从32扩展到36。ACPI

ACPI就是Advanced Configuration and Power Interface的缩写,意思是“高级配置与电源接口”。这是英特尔、微软和东芝共同开发的一种电源管理标准。ACPI可实现以下功能:  1、用户可以使外设在指定时间开关;  2、使用笔记本电脑的用户可以指定计算机在低电压的情况下进入低功耗状态,以保证重要的应用程序运行;  3、操作系统可以在应用程序对时间要求不高的情况下降低时钟频率;4、操作系统可以根据外设和主板的具体需求为它分配能源;5、在无人使用计算机时可以使计算机进入休眠状态,但保证一些通信设备打开;6、即插即用设备在插入时能够由ACPI来控制。不过,ACPI和其他的电源管理方式一样,要想享受到上面这些功能,必须要有软件和硬件的支持。在软件方面,Windows 98及其后续产品和Windows 2000都对ACPI给予了全面的支持;硬件方面比较麻烦,除了要求主板、显卡和网卡等外设要支持ACPI外,还需要机箱电源的配合。电源在提供5伏电压给主板的同时,还必须使电流稳定在720毫安以上才可以,这样它才能够实现电脑的“睡眠”和“唤醒”。ACPI共有六种状态,分别是S0到S5,它们代表的含义分别是:S0--实际上这就是我们平常的工作状态,所有设备全开,功耗一般会超过80W;S1--也称为POS(Power on Suspend),这时除了通过CPU时钟控制器将CPU关闭之外,其他的部件仍然正常工作,这时的功耗一般在30W以下;(其实有些CPU降温软件就是利用这种工作原理)S2--这时CPU处于停止运作状态,总线时钟也被关闭,但其余的设备仍然运转;S3--这就是我们熟悉的STR(Suspend to RAM),这时的功耗不超过10W;S4--也称为STD(Suspend to Disk),这时系统主电源关闭,但是硬盘仍然带电并可以被唤醒;S5--这种状态是最干脆的,就是连电源在内的所有设备全部关闭,功耗为0。我们最常用到的是S3状态,即Suspend to RAM(挂起到内存)状态,简称STR。顾名思义,STR就是把系统进入STR前的工作状态数据都存放到内存中去。在STR状态下,电源仍然继续为内存等最必要的设备供电,以确保数据不丢失,而其他设备均处于关闭状态,系统的耗电量极低。一旦我们按下Power按钮(主机电源开关),系统就被唤醒,马上从内存中读取数据并恢复到STR之前的工作状态。内存的读写速度极快,因此我们感到进入和离开STR状态所花费的时间不过是几秒钟而已;而S4状态,即STD(挂起到硬盘)与STR的原理是完全一样的,只不过数据是保存在硬盘中。由于硬盘的读写速度比内存要慢得多,因此用起来也就没有STR那么快了。STD的优点是只通过软件就能实现,比如Windows 2000就能在不支持STR的硬件上实现STD。APIC

apic: Advanced Programmable Interrupt Controller高级可编程中断控制器.    APIC 是装置的扩充组合用来驱动 Interrupt 控制器。在目前的建置中,系统的每一个部份都是经由 APIC Bus 连接的。"本机 APIC" 为系统的一部份,负责传递 Interrupt 至指定的处理器;举例来说,当一台机器上有三个处理器则它必须相对的要有三个本机 APIC。自 1994 年的 Pentium P54c 开始Intel 已经将本机 APIC 建置在它们的处理器中。实际建置了 Intel 处理器的电脑就已经包含了 APIC 系统的部份。   系统中另一个重要的部份为 I/O APIC。系统中最多可拥有 8 个 I/O APIC。它们会收集来自 I/O 装置的 Interrupt 讯号且在当那些装置需要 interrupt 时传送讯息至本机 APIC。每个 I/O APIC 有一个专有的 interrupt 输入 (或 IRQ) 号码。Intel 过去与目前的 I/O APIC 通常有 24 个输入 -- 其它的可能有多逹 64 个。而且有些机器拥有数个 I/O APIC,每一个分别有自己的输入号码,加起来一台机器上会有上百个 IRQ 可供装置 Interrupt 使用。   然而,系统中若没有 I/O APIC,那本机 APIC 就没有用处。像这样的状况下,Windows 2000 会还原使用 8259 PIC 。VGA

VGA(Video Graphics Array)是IBM在1987年随PS/2机一起推出的一种视频传输标准,具有分辨率高、显示速率快、颜色丰富等优点,在彩色显示器领域得到了广泛的应用。  
注意:MAC要与guest配置文件中的vif参数相匹配。
在安装Xen虚拟机时,需要决定选用何种块设备(block devices)。你有三种可能的选择:直接在专用分区中安装;使用磁盘镜像文件;使用dd创建磁盘镜像文件。在本文中,TechTarget中国的特约虚拟化专家Sander van Vugt将概括地介绍最重要的几种选择。  使用物理磁盘  如果要获得最好的性能,物理磁盘设备是最好的选择。使用物理磁盘设备安装时,你可以安装到一个分区中或逻辑卷中(如果使用了逻辑卷),既可以使用EVMS也可以使用LVM。使用逻辑卷有这样几个好处:  逻辑卷可以改变大小  可以使用快照进行备份  使用物理磁盘设备的最大好处是它提供的性能可能是最好的。然而,物理存储设备不便于移动。要拷贝磁盘镜像文件很容易,但要拷贝逻辑卷或物理分区就会困难得多。不过,困难得多并不表示不可能。例如,如果要将整个逻辑卷/dev/xen/vm1拷贝到一个预建的逻辑卷/dev/xen/vm1-backup中,只需使用dd if=/dev/xen/vm1 of=/dev/xen/vm1-backup即可。  要通过虚拟机配置文件处理物理磁盘设备,需要使用如下语句:  phy:,,[r|w]  例如:disk=[ ’phy:/dev/system/mainserver,xvda,w’, ’phy:/dev/cdrom,xvdb,r’, ]  使用Xen磁盘镜像文件  在SUSE或Red Hat上安装虚拟机时,默认使用的是Xen磁盘镜像文件。该镜像文件是通过dd工具(dd utility)创建的,所以基本没有任何特殊之处。dd磁盘镜像文件与虚拟硬盘(VHD)格式的文件不一样。dd磁盘镜像文件没有相关的元数据(metadata),只有0和1。  要创建磁盘镜像文件,你需要通过dd工具把/dev/zero设备中的0复制到你的磁盘镜像文件中。例如,如果要创建一个4GB的文件(文件名为/var/lib/xen/images/disk1),可以使用如下命令:  dd if=/dev/zero of=/var/lib/xen/images/disk1 bs=1M count=4096  除了使用dd工具创建空镜像文件以外,你还可以使用ISO文件替代物理光驱创建,用法和用dd一样。如果你甚至没有ISO文件,不要紧,ISO文件很好创建。如果你要创建ISO文件的cd-rom在光驱中,使用如下命令将其复制到cdrom.iso文件:  dd if=/dev/cdrom of=/isos/cdrom.iso  创建好一个磁盘镜像文件或ISO文件后,你需要在虚拟机配置文件中包含该磁盘镜像文件,使用文件选项:  disk=[ ’file:/var/lib/xen/images/disk1,hda,w’, ’file:/isos/cdrom.iso,hdc,r’, ]  其它环境的镜像文件的使用  有时,你想从创建镜像文件开始创建一个新的虚拟机。而有些情况下,你要使用的磁盘镜像文件是来自另一种虚拟化环境,可能是VMware环境下的一个vmdk-file,也可能是Qemu环境下的一个qcow文件或者其它文件。要使用这些文件,你必须 “tap” 磁盘镜像。如下命令行是使用VMware环境下的vmdk-file的语句:  disk=[ ’tap:vmdk:/var/lib/xen/server1.vmdk,hda,w’, ]  Xen磁盘镜像文件是一种特殊的tap设备,它使用的是xen blktap内核模块。这个模块允许在完全虚拟化环境下作为准虚拟设备处理磁盘镜像文件。要使用这个模块,你需要有aio类型的设备。磁盘镜像文件本身可能是一个由dd命令创建的普通磁盘镜像文件。要在配置文件中使用那种设备类型,可以使用如下语句:  disk=[ ’tap:aio:/var/lib/xen/server2.img,xvda,w’, ]  使用tap磁盘镜像有个好处,就是可以使用任何类型的磁盘镜像。然而,它有个缺点:目前的管理工具并不支持tap设备,如virtual manager。这就意味着你不得不利用这个设备手动配置虚拟机。  网络块设备  最后,还有一种在虚拟机中可以使用的磁盘类型是网络磁盘类型。它既可以是一个网络块设备(network block devices),如DRBD设备,也可以是iSCSI设备。这使得在iSCSI SAN中直接处理LUN成为可能,不过要记得先在domain0中启动iSCSI启动程序。  这个磁盘镜像类型是不可移动的,这就意味着你必须在SAN中做一些预防措施,以保护该类型的磁盘镜像文件。例如,在SAN级进行快照备份以保护这些文件。要连接一个iSCSI LUN,你需要在Xen虚拟机的配置文件中包含完整的iSCSI Qualifying Name(iqn)。例如,如果你要使用的iqn为iqn.2007-08.nl.example:xendata,则需要用如下配置行:  disk=[ ’iscsi:2007-08.nl.example:xendata,xvda,w’, ]  在本文中,我们了解到了处理虚拟机磁盘设备的各种不同方法。在多数情况下,即使使用了文件设备和物理设备,其它设备类型也是很有用的。尤其是tap设备类型,它能允许你处理任何类型的磁盘镜像文件。 

HVM guest配置文件相关推荐

  1. Xen HVM DomU配置文件

    An example of Xen HVM DomU configuration file. Xen HVM DomU配置文件的示例. An example for install the OS fr ...

  2. 对XEN中HVM虚拟机的一些理解

    最近又把一些精力花在了XEN上面了,这和我另外在处理的一个邮件系统有一个间接的关系,在那里我遇到了一个间接涉及到XEN的问题.由于邮件系统我还尚 未达到符合要求,待我整理完稍后刊出.以下是我对HVM功 ...

  3. Xen与KVM虚拟化技术调研报告

    1.概述 随着计算机硬件的制作工艺提高,如CPU单位面积可容纳的器件多了好几倍,其他硬件的也快速发展,促使单机性能远远超出满足一个应用的需求.同时,目前传统服务器的利用率大约为20%-30%,通过虚拟 ...

  4. pxelinux_IT怪胎:如何使用PXElinux v5和Wimboot网络引导(PXE)WinPE恢复磁盘

    pxelinux Have you ever wished you could get the "Windows Recovery Console" running for tha ...

  5. Xen虚拟化基本原理详解

    标签: 虚拟化 xen 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任. http://wangzan18.blog.51cto.com/802 ...

  6. Xen DomU 配置与使用

    Xen DomU 配置与使用 在 Xen 安装与配置 完成了 Xen 虚拟机的安装,以及 Dom0 的配置.接下来我们对 DomU 进行配置.Xen DomU 可工作在 PV(paravirtuali ...

  7. 【Xen】什么是 Xen Hypervisor

    What is Xen Hypervisor? 什么是Xen Hypervisor? The Xen hypervisor is a layer of software running directl ...

  8. Linux源码研究-用户管理员手册-内核命令行参数

    下面的列表是__setup(), core_param()和module_param()宏实现的内核参数,内核从命令-开始解析参数,如果参数不被识别,也不包含".",参数会被用来启 ...

  9. 《网络安全工程师笔记》 第五章:用户与组管理

    注:本笔记来自温晓飞老师的网络安全课程 第五章:用户与组管理 第一章:虚拟化架构与系统部署 第二章:IP地址详解 第三章:进制转换 第四章:DOS基本命令与批处理 第五章:用户与组管理 第六章:服务器 ...

最新文章

  1. java入门(1) 程序运行机制及运行过程
  2. vue 传递多行数据_vue 数据传递的方法
  3. 2017年第八届蓝桥杯省赛试题(JavaA组)
  4. Linux 网络编程八(epoll应用--大并发处理)
  5. Hadoop3 Hive Spark完整安装与实践
  6. 网站域名解析端口_环境测试必备,无需注册域名,免费动态IP解析一键解析本地网站...
  7. 用C++11的std::async代替线程的创建
  8. Transposed Convolution 反卷积
  9. SpringBoot写后端接口,看这一篇就够了!
  10. CentOS修改时区
  11. PyTorch-GPU版本、Tensorflow-GPU版本配置
  12. python 客户端_Python客户端
  13. 神马js都是浮云-----限时秒杀
  14. ubuntu18安装wine QQ——2021.11.9
  15. 如何彻底卸载3dmax2020_3dsmax2020卸载/安装失败/如何彻底卸载清除干净3dsmax2020注册表和文件的方法...
  16. python井字棋_python之井字棋游戏
  17. [转]尺度不变特征变换(SIFT算法)Matlab程序代码测试例子的说明(Lowe的代码)
  18. 工具说明书 - FTDI芯片的USB转UART串口线
  19. win7安不了python_win7下安装python失败问题
  20. 「学IT一定要看」一些学习的建议

热门文章

  1. python知识合集
  2. 李洪强iOS开发之RunLoop的原理和核心机制
  3. 无法解决 equal to 操作中 Chinese_PRC_CI_AS_WS 和 Chinese_PRC_CI_AS 之间的排序规则冲突...
  4. 实现无线AP无缝漫游
  5. apache mail发送邮件附件中文乱码
  6. 一文读懂Https的安全性原理、数字证书、单项认证、双项认证等
  7. SpringBoot 的其他使用 及 maven打包
  8. bat 快速切换路径
  9. sphinx配置文件继承
  10. linux c 实现 http get post 请求