xen虚拟机配置文件c_统一Xen DomU配置文件

xen虚拟机配置文件c

Previously, we create a configuration file for each DomU virtual machines in our cluster. Most of the content in these configuration files is the same. The differences are only the name, memory size and image file address. There are several disadvantages of this method: We must create and configure a new configuration file when creating a new virtual machines; We must change every configuration files when we want to change the parameters of the virtual machines such as change the raw image file driver from loopback to tap. So we change to using a unified Xen DomU configuration file. We creating DomUs, just use this unified Xen DomU configuration file and add some parameters to it.

以前,我们为集群中的每个DomU虚拟机创建一个配置文件。 这些配置文件中的大多数内容是相同的。 区别只是名称, 内存大小和图像文件地址。 这种方法有几个缺点:创建新的虚拟机时,我们必须创建并配置新的配置文件。 要更改虚拟机的参数(例如,将原始映像文件驱动程序从环回更改为Tap)时,必须更改每个配置文件。 因此,我们更改为使用统一的Xen DomU配置文件。 我们创建DomU,仅使用此统一的Xen DomU配置文件并向其中添加一些参数。

Assumption

假设条件

For VM with id *vmid*: Name is: vm*vmid* Raw image file address is: /lhome/xen/vm*vmid*/vmdisk*vmid* The parameter for *vmid *is *vmid*. The parameter for memory size is *vmmem*. We force the memory size of the virtual machines to be at least 1G. We assume the virtual cpu number is 2 for all virtual machines. If the cpu number should be different from virtual machines, we can also add a parameter for it.

对于ID为* vmid *的VM:名称为:vm * vmid *原始映像文件地址为:/ lhome / xen / vm * vmid * / vmdisk * vmid * * vmid *的参数为* vmid *。 内存大小的参数是* vmmem *。 我们强制虚拟机的内存大小至少为1G。 我们假设所有虚拟机的虚拟cpu数均为2。 如果cpu编号应与虚拟机不同,我们也可以为其添加一个参数。

The configuration file vm.run

配置文件vm.run

This is the unified configuration file /lhome/xen/vm.run:

这是统一的配置文件/lhome/xen/vm.run:

    # Called automatically by 'xm create'.
    # Checks that 'vmid' has been given a valid value.
    def vmid_check(var, val):
        val = int(val)
        if val <= 0:
             raise ValueError
        return val
    
    # Checks that 'vmmem' has been given a valid value
    # Make sure the vmmem is >= 1024
    def vmmem_check(var, val):
        val = int(val)
        if val <= 1024:
            return 1024
        return val
    
    # Define the 'vmid' variable so that 'xm create' knows about it.
    xm_vars.var('vmid',
                use="Virtual machine id. Integer greater than 0.",
                check=vmid_check)
    
    # Define the 'vmmem' variable
    xm_vars.var('vmmem',
                use="Virtual machine memory. Integer greater thatn 1024.",
                check=vmmem_check)
    
    # Check the defined variables have valid values..
    xm_vars.check()
    
    # --------------------------------------------------------------
    name="vm%d" % vmid
    memory="%d" % vmmem
    disk=["tap:aio:/lhome/xen/vm%d/vmdisk%d,xvda,w" % (vmid,vmid) ]
    vif=['bridge=eth0']
    bootloader="/usr/bin/pygrub"
    vcpus=2
    on_reboot='restart'
    on_crash='restart'

The meaning should be easy to understand with these comments.

通过这些注释,其含义应该易于理解。

How to use it

如何使用它

When we want to create vm*vmid* with *vmmem* kb memory, just follow these steps:

当我们要使用* vmmem * kb内存创建vm * vmid *时,只需执行以下步骤:

    # cd /lhome/xen
    # xm create vm.run vmid=<em>vmid</em> vmmem=<em>vmmem</em>

翻译自: https://www.systutorials.com/unified-xen-domu-configuration-file/

xen虚拟机配置文件c

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值