Updated Branches: refs/heads/master 5410901ae -> a709f34ff
kvm: During migrate change the VNC listen address The migrate method from libvirt supports passing down a different XML for running the instance of the target hypervisor. This enables the VNC to bind to the private IP Address of the hypervisor and during migration this will be changed to the private IP address of the target host. This way VNC doesn't listen world wide and is much safer. Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/a709f34f Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/a709f34f Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/a709f34f Branch: refs/heads/master Commit: a709f34ff93579981afbd4df0f4334b61ada29a8 Parents: 5410901 Author: Wido den Hollander <w...@widodh.nl> Authored: Mon Sep 16 11:36:21 2013 +0200 Committer: Wido den Hollander <w...@widodh.nl> Committed: Mon Sep 16 11:57:16 2013 +0200 ---------------------------------------------------------------------- docs/en-US/hypervisor-host-install-libvirt.xml | 5 ----- .../kvm/resource/LibvirtComputingResource.java | 23 +++++++++++++++++--- pom.xml | 4 ++-- 3 files changed, 22 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a709f34f/docs/en-US/hypervisor-host-install-libvirt.xml ---------------------------------------------------------------------- diff --git a/docs/en-US/hypervisor-host-install-libvirt.xml b/docs/en-US/hypervisor-host-install-libvirt.xml index c4be67e..d3d6b9b 100644 --- a/docs/en-US/hypervisor-host-install-libvirt.xml +++ b/docs/en-US/hypervisor-host-install-libvirt.xml @@ -47,11 +47,6 @@ <programlisting>libvirtd_opts="-d -l"</programlisting> </listitem> <listitem> - <para>In order to have the VNC Console work we have to make sure it will bind on 0.0.0.0. We do this by editing <filename>/etc/libvirt/qemu.conf</filename></para> - <para>Make sure this parameter is set:</para> - <programlisting>vnc_listen = "0.0.0.0"</programlisting> - </listitem> - <listitem> <para>Restart libvirt</para> <para>In RHEL or CentOS:</para> <programlisting><command>$ service libvirtd restart</command></programlisting> http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a709f34f/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java ---------------------------------------------------------------------- diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java index 94ee9ae..203587a 100755 --- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java +++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java @@ -2878,17 +2878,34 @@ ServerResource { Connect dconn = null; Domain destDomain = null; Connect conn = null; + String xmlDesc = null; try { conn = LibvirtConnection.getConnectionByVmName(cmd.getVmName()); ifaces = getInterfaces(conn, vmName); - dm = conn.domainLookupByName(vmName); + dm = conn.domainLookupByUUID(UUID.nameUUIDFromBytes(vmName + .getBytes())); + /* + 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) */ - destDomain = dm.migrate(dconn, (1 << 0) | (1 << 3), vmName, "tcp:" + destDomain = dm.migrate(dconn, (1 << 0) | (1 << 3), xmlDesc, vmName, "tcp:" + cmd.getDestinationIp(), _migrateSpeed); } catch (LibvirtException e) { s_logger.debug("Can't migrate domain: " + e.getMessage()); @@ -3441,7 +3458,7 @@ ServerResource { //add the VNC port passwd here, get the passwd from the vmInstance. String passwd = vmTO.getVncPassword(); - GraphicDef grap = new GraphicDef("vnc", (short) 0, true, null, passwd, + GraphicDef grap = new GraphicDef("vnc", (short) 0, true, vmTO.getVncAddr(), passwd, null); devices.addDevice(grap); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a709f34f/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 4013fa6..6d9a30f 100644 --- a/pom.xml +++ b/pom.xml @@ -81,11 +81,11 @@ <cs.reflections.version>0.9.8</cs.reflections.version> <cs.java-ipv6.version>0.10</cs.java-ipv6.version> <cs.replace.properties>build/replace.properties</cs.replace.properties> - <cs.libvirt-java.version>0.4.9</cs.libvirt-java.version> + <cs.libvirt-java.version>0.5.0</cs.libvirt-java.version> <cs.rados-java.version>0.1.3</cs.rados-java.version> <cs.target.dir>target</cs.target.dir> <cs.daemon.version>1.0.10</cs.daemon.version> - <cs.jna.version>3.0.9</cs.jna.version> + <cs.jna.version>4.0.0</cs.jna.version> </properties> <distributionManagement>