zoukankan      html  css  js  c++  java
  • virsh命令行blockcopy命令详解

    blockcopy
    Syntax:
    blockcopy domain path { dest [format] [--blockdev] | --xml file }
    [--shallow] [--reuse-external] [bandwidth]
    [--wait [--async] [--verbose]] [{--pivot | --finish}]
    [--timeout seconds] [granularity] [buf-size] [--bytes]
    [--transient-job]

    Copy a disk backing image chain to a destination. Either dest as the destination file name,
    or --xml with the name of an XML file containing a top-level <disk> element describing the destination, must be present(存在的).
    Additionally(另外), if dest is given, format should be specified to declare the format of the destination
    (if format is omitted(遗漏的、忽略的), then libvirt will reuse(重复使用) the format of the source, or with --reuse-external will be forced to probe the destination format, which could be a potential security hole 那可能是一个潜在的安全漏洞).
    The command supports --raw as a boolean flag synonym(同义词) for --format=raw.
    When using dest, the destination is treated as a regular file unless --blockdev is used to signal(表示) that it is a block device.
    当使用dest时,目标文件被视为常规文件,除非--blockdev被用来指示它是一个块设备
    By default, this command flattens the entire(完整的) chain; but if --shallow is specified, the copy shares the backing chain.
    默认情况下,这个命令使整个链变平;但是如果指定了--shallow,则副本共享后台链。
    If --reuse-external is specified, then the destination must exist and have sufficient space to hold the copy.
    If --shallow is used in conjunction with --reuse-external then the pre-created image must have guest visible contents identical to guest visible contents of the backing file of the original image.
    This may be used to modify the backing file names on the destination.
    By default, the copy job runs in the background, and consists of two phases.
    默认情况下,拷贝作业在后台运行,包括两个阶段
    Initially, the job must copy all data from the source, and during this phase, the job can only be canceled to revert back to the source disk, with no guarantees(保证) about the destination.
    最初,作业必须从源复制所有数据,在此阶段,只能取消作业以恢复到源磁盘,而不能保证目标磁盘
    After this phase(阶段) completes, both the source and the destination remain mirrored until a call to blockjob with the --abort and --pivot flags pivots over to the copy, or a call without --pivot leaves the destination as a faithful(忠实的) copy of that point in time.
    在此阶段完成后,源和目标都保持镜像状态,直到带有——abort和——pivot标志的blockjob调用转到副本,或者不带——pivot标志的调用离开目的地作为该时间点的忠实副本
    However, if --wait is specified, then this command will block until the mirroring phase begins, or cancel the operation if the optional timeout in seconds elapses or SIGINT is sent (usually with Ctrl-C).
    但是,如果指定了--wait,则此命令将阻塞直到镜像阶段开始,或者在可选的超时时间(以秒为单位)或发送SIGINT(通常使用Ctrl-C)时取消操作
    Using --verbose along with --wait will produce periodic status updates. Using --pivot (similar to blockjob --pivot) or --finish (similar to blockjob --abort) implies --wait,
    and will additionally end the job cleanly rather than leaving things in the mirroring phase.
    使用--verbose和--wait将产生定期的状态更新。使用--pivot(类似于blockjob --pivot)或--finish(类似于blockjob --abort)意味着--wait,并将额外地干净地结束作业,而不是将事情留在镜像阶段
    If job cancellation is triggered by timeout or by --finish, --async will return control to the user as fast as possible,
    otherwise the command may continue to block a little while longer until the job has actually cancelled.
    path specifies fully-qualified path of the disk. bandwidth specifies copying bandwidth limit in MiB/s.
    Specifying a negative(负的) value is interpreted as an unsigned long long value that might be essentially unlimited, but more likely would overflow;
    指定一个负(负的)值被解释为一个无符号长长值可能本质上是无限的,但更有可能会溢出;
    it is safer to use 0 for that purpose. For further information on the bandwidth argument see the corresponding section for the blockjob command.
    Specifying granularity(粒度) allows fine-tuning(微调) of the granularity that will be copied when a dirty(脏的) region is detected(缺陷的);
    larger values trigger less I/O overhead but may end up(结束,) copying more data overall(总体上) (the default value is usually correct);
    较大的值会触发较少的I/O开销,但最终可能会复制更多的数据(默认值通常是正确的);
    hypervisors may restrict this to be a power of two or fall within a certain range. 虚拟机监控程序可能会将其限制为2的幂或在某个范围内
    Specifying buf-size will control how much data can be simultaneously in-flight during the copy;
    指定buf-size将控制在复制期间可以同时运行的数据量;
    larger values use more memory but may allow faster completion (the default value is usually correct).
    较大的值使用更多的内存,但可能允许更快的完成(默认值通常是正确的)。
    --transient-job allows specifying that the user does not require the job to be recovered(恢复) if the VM crashes or is turned off before the job completes.
    --transient-job允许指定如果虚拟机崩溃或在任务完成前关闭,用户不需要恢复任务。
    This flag removes the restriction of copy jobs to transient domains if that restriction is applied by the hypervisor.

    样例:openstack在热迁移的时候,调用的热迁移的命令行参数

    cmd = ['/usr/bin/virsh', 'blockcopy', self._guest.name, self._disk, '--dest', unicode(base).encode("utf-8")]
    cmd.append('--shallow')
    cmd.append('--reuse-external')
    cmd.append('--blockdev')
    if bandwidth != None:
    	cmd.append('--bandwidth')
    	cmd.append(bandwidth)
    	cmd.append('--granularity')
    	cmd.append(512)
    else:
    	cmd.append('--bandwidth')
    	cmd.append(CONF.libvirt.block_migration_bandwidth)
    	cmd.append('--granularity')
    	cmd.append(512)
    return utils.execute(*cmd)
    

      

  • 相关阅读:
    Android 系统开发做什么?
    MySQL索引-B+树
    转:redis雪崩、穿透、击穿
    转:django3上线部署踩得坑
    nginx、uwsgi部署django中session丢失得问题
    类型转换(数字转字符串等)
    JS基础篇1:数据类型(8种)
    css3动画与js动画的区别
    drag拖拽事件
    三栏布局,中间自适应
  • 原文地址:https://www.cnblogs.com/potato-chip/p/14202855.html
Copyright © 2011-2022 走看看