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).
较⼤的值使⽤更多的内存,但可能允许更快的完成(默认值通常是正确的)。
block truncated
--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)
ute(*cmd)

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。