List<InterfaceDef> ifaces = null;
List<DiskDef> disks = null;
Domain dm = null;
Connect dconn = null;
Domain destDomain = null;
Connect conn = null;
String xmlDesc = null;
try {
conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName());
ifaces = getInterfaces(conn, vmName);
disks = getDisks(conn, vmName);
dm = conn.domainLookupByName(vmName);
/*
We replace the private IP address with the address of the destination host.
This is because the VNC listens on the private IP address of the hypervisor,
but that address is ofcourse different on the target host.
MigrateCommand.getDestinationIp() returns the private IP address of the target
hypervisor. So it's safe to use.
The Domain.migrate method from libvirt supports passing a different XML
description for the instance to be used on the target host.
This is supported by libvirt-java from version 0.50.0
*/
xmlDesc = dm.getXMLDesc(0).replace(_privateIp, cmd.getDestinationIp());
dconn = new Connect("qemu+tcp://" + cmd.getDestinationIp()
+ "/system");
/*
* Hard code lm flags: VIR_MIGRATE_LIVE(1<<0) and
* VIR_MIGRATE_PERSIST_DEST(1<<3)
*/