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)

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM