libvirt 迁移kvm虚拟机 migrate api

使用libvirt控制KVM虚拟机进行热迁移,这里记录一下migrate方法的使用 

import libvirt 
import pprint
conn_004 = libvirt.open(‘qemu+tcp://username@server004/system’) 
conn_005 = libvirt.open(‘qemu+tcp://username@server005/system’) 
vm_domain = conn_004.lookupByName(‘instance_name’) 
vm_domain.migrate(conn_005,True,’instance_name’,None,0)
pprint.pprint(help(vm_domain.migrate))
下面是程序的输出,也就是migrate接口的说明:

migrate(self, dconn, flags, dname, uri, bandwidth) method of libvirt.virDomain instance Migrate the domain object from its current host to the destination host given by dconn (a connection to the destination host).

Flags may be one of more of the following: 
VIR_MIGRATE_LIVE : Do not pause the VM during migration 
VIR_MIGRATE_PEER2PEER: Direct connection between source & destination hosts 
VIR_MIGRATE_TUNNELLED :Tunnel migration data over the libvirt RPC channel 
VIR_MIGRATE_PERSIST_DEST :If the migration is successful, persist the domain on the destination host. 
VIR_MIGRATE_UNDEFINE_SOURCE :If the migration is successful, undefine the domain on the source host. 
VIR_MIGRATE_PAUSED :Leave the domain suspended on the remote side. 
VIR_MIGRATE_CHANGE_PROTECTION :Protect against domain configuration changes during the migration process (set automatically when supported). 
VIR_MIGRATE_UNSAFE :Force migration even if it is considered unsafe.

VIR_MIGRATE_TUNNELLED requires that VIR_MIGRATE_PEER2PEER be set.
Applications using the VIR_MIGRATE_PEER2PEER flag will probably
prefer to invoke virDomainMigrateToURI, avoiding the need to
open connection to the destination host themselves.

If a hypervisor supports renaming domains during migration,
then you may set the dname parameter to the new name (otherwise
it keeps the same name).  If this is not supported by the
hypervisor, dname must be None or else you will get an error.

If the VIR_MIGRATE_PEER2PEER flag is set, the uri parameter
must be a valid libvirt connection URI, by which the source
libvirt driver can connect to the destination libvirt. If
omitted, the dconn connection object will be queried for its
current URI.

If the VIR_MIGRATE_PEER2PEER flag is NOT set, the URI parameter
takes a hypervisor specific format. The hypervisor capabilities
XML includes details of the support URI schemes. If omitted
the dconn will be asked for a default URI.

In either case it is typically only necessary to specify a
URI if the destination host has multiple interfaces and a
specific interface is required to transmit migration data.

The maximum bandwidth (in MiB/s) that will be used to do migration
can be specified with the bandwidth parameter.  If set to 0,
libvirt will choose a suitable default.  Some hypervisors do
not support this feature and will return an error if bandwidth
is not 0.

To see which features are supported by the current hypervisor,
see virConnectGetCapabilities, /capabilities/host/migration_features.

There are many limitations on migration imposed by the underlying
technology - for example it may not be possible to migrate between
different processors even with the same architecture, or between
different types of hypervisor.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值