Skip to content

Commit 7dc5d50

Browse files
Added vddk support in vmware to kvm migrations
1 parent 4708121 commit 7dc5d50

File tree

12 files changed

+687
-69
lines changed

12 files changed

+687
-69
lines changed

agent/conf/agent.properties

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,3 +457,19 @@ iscsi.session.cleanup.enabled=false
457457

458458
# Instance conversion VIRT_V2V_TMPDIR env var
459459
#convert.instance.env.virtv2v.tmpdir=
460+
461+
# LIBGUESTFS backend to use for VMware to KVM conversion via VDDK (default: direct)
462+
#libguestfs.backend=direct
463+
464+
# Path to the VDDK library directory for VMware to KVM conversion via VDDK,
465+
# passed to virt-v2v as -io vddk-libdir=<path>
466+
#vddk.lib.dir=
467+
468+
# Ordered VDDK transport preference for VMware to KVM conversion via VDDK, passed as
469+
# -io vddk-transports=<value> to virt-v2v. Example: nbd:nbdssl
470+
#vddk.transports=
471+
472+
# Optional vCenter SHA1 thumbprint for VMware to KVM conversion via VDDK, passed as
473+
# -io vddk-thumbprint=<value>. If unset, CloudStack computes it on the KVM host via openssl.
474+
#vddk.thumbprint=
475+

agent/src/main/java/com/cloud/agent/properties/AgentProperties.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,37 @@ public Property<Integer> getWorkers() {
808808
*/
809809
public static final Property<String> CONVERT_ENV_VIRTV2V_TMPDIR = new Property<>("convert.instance.env.virtv2v.tmpdir", null, String.class);
810810

811+
/**
812+
* Path to the VDDK library directory on the KVM conversion host, used when converting VMs from VMware to KVM via VDDK.
813+
* This directory is passed to virt-v2v as <code>-io vddk-libdir=&lt;path&gt;</code>.
814+
* Data type: String.<br>
815+
* Default value: <code>null</code>
816+
*/
817+
public static final Property<String> VDDK_LIB_DIR = new Property<>("vddk.lib.dir", null, String.class);
818+
819+
/**
820+
* Value for the LIBGUESTFS_BACKEND env var used during VMware to KVM conversion via VDDK.
821+
* Data type: String.<br>
822+
* Default value: <code>direct</code>
823+
*/
824+
public static final Property<String> LIBGUESTFS_BACKEND = new Property<>("libguestfs.backend", "direct", String.class);
825+
826+
/**
827+
* Ordered list of VDDK transports for virt-v2v, passed as <code>-io vddk-transports=&lt;value&gt;</code>.
828+
* Example: <code>nbd:nbdssl</code>.
829+
* Data type: String.<br>
830+
* Default value: <code>null</code>
831+
*/
832+
public static final Property<String> VDDK_TRANSPORTS = new Property<>("vddk.transports", null, String.class);
833+
834+
/**
835+
* vCenter TLS certificate thumbprint used by virt-v2v VDDK mode, passed as <code>-io vddk-thumbprint=&lt;value&gt;</code>.
836+
* If unset, the KVM host computes it at runtime from the vCenter endpoint.
837+
* Data type: String.<br>
838+
* Default value: <code>null</code>
839+
*/
840+
public static final Property<String> VDDK_THUMBPRINT = new Property<>("vddk.thumbprint", null, String.class);
841+
811842
/**
812843
* BGP controll CIDR
813844
* Data type: String.<br>

api/src/main/java/com/cloud/agent/api/to/RemoteInstanceTO.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,17 @@ public class RemoteInstanceTO implements Serializable {
3636
private String vcenterPassword;
3737
private String vcenterHost;
3838
private String datacenterName;
39+
private String clusterName;
40+
private String hostName;
3941

4042
public RemoteInstanceTO() {
4143
}
4244

43-
public RemoteInstanceTO(String instanceName) {
45+
public RemoteInstanceTO(String instanceName, String clusterName, String hostName) {
4446
this.hypervisorType = Hypervisor.HypervisorType.VMware;
4547
this.instanceName = instanceName;
48+
this.clusterName = clusterName;
49+
this.hostName = hostName;
4650
}
4751

4852
public RemoteInstanceTO(String instanceName, String instancePath, String vcenterHost, String vcenterUsername, String vcenterPassword, String datacenterName) {
@@ -55,6 +59,12 @@ public RemoteInstanceTO(String instanceName, String instancePath, String vcenter
5559
this.datacenterName = datacenterName;
5660
}
5761

62+
public RemoteInstanceTO(String instanceName, String instancePath, String vcenterHost, String vcenterUsername, String vcenterPassword, String datacenterName, String clusterName, String hostName) {
63+
this(instanceName, instancePath, vcenterHost, vcenterUsername, vcenterPassword, datacenterName);
64+
this.clusterName = clusterName;
65+
this.hostName = hostName;
66+
}
67+
5868
public Hypervisor.HypervisorType getHypervisorType() {
5969
return this.hypervisorType;
6070
}
@@ -82,4 +92,12 @@ public String getVcenterHost() {
8292
public String getDatacenterName() {
8393
return datacenterName;
8494
}
95+
96+
public String getClusterName() {
97+
return clusterName;
98+
}
99+
100+
public String getHostName() {
101+
return hostName;
102+
}
85103
}

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ public class ApiConstants {
621621
public static final String USER_CONFIGURABLE = "userconfigurable";
622622
public static final String USER_SECURITY_GROUP_LIST = "usersecuritygrouplist";
623623
public static final String USER_SECRET_KEY = "usersecretkey";
624+
public static final String USE_VDDK = "usevddk";
624625
public static final String USE_VIRTUAL_NETWORK = "usevirtualnetwork";
625626
public static final String USE_VIRTUAL_ROUTER_IP_RESOLVER = "userouteripresolver";
626627
public static final String UPDATE_IN_SEQUENCE = "updateinsequence";

api/src/main/java/org/apache/cloudstack/api/command/admin/vm/ImportVmCmd.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,14 @@ public class ImportVmCmd extends ImportUnmanagedInstanceCmd {
179179
description = "(only for importing VMs from VMware to KVM) optional - the ID of the guest OS for the imported VM.")
180180
private Long guestOsId;
181181

182+
@Parameter(name = ApiConstants.USE_VDDK,
183+
type = CommandType.BOOLEAN,
184+
since = "4.22.1",
185+
description = "(only for importing VMs from VMware to KVM) optional - if true, uses VDDK on the KVM conversion host for converting the VM. " +
186+
"This parameter is mutually exclusive with " + ApiConstants.FORCE_MS_TO_IMPORT_VM_FILES + ".")
187+
private Boolean useVddk;
188+
189+
182190
/////////////////////////////////////////////////////
183191
/////////////////// Accessors ///////////////////////
184192
/////////////////////////////////////////////////////
@@ -255,6 +263,10 @@ public Long getStoragePoolId() {
255263
return storagePoolId;
256264
}
257265

266+
public boolean getUseVddk() {
267+
return BooleanUtils.toBooleanDefaultIfNull(useVddk, false);
268+
}
269+
258270
public String getTmpPath() {
259271
return tmpPath;
260272
}

core/src/main/java/com/cloud/agent/api/ConvertInstanceCommand.java

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ public class ConvertInstanceCommand extends Command {
3131
private boolean exportOvfToConversionLocation;
3232
private int threadsCountToExportOvf = 0;
3333
private String extraParams;
34+
private boolean useVddk;
35+
private String libguestfsBackend;
36+
private String vddkLibDir;
37+
private String vddkTransports;
38+
private String vddkThumbprint;
3439

3540
public ConvertInstanceCommand() {
3641
}
@@ -90,6 +95,46 @@ public void setExtraParams(String extraParams) {
9095
this.extraParams = extraParams;
9196
}
9297

98+
public boolean isUseVddk() {
99+
return useVddk;
100+
}
101+
102+
public void setUseVddk(boolean useVddk) {
103+
this.useVddk = useVddk;
104+
}
105+
106+
public String getLibguestfsBackend() {
107+
return libguestfsBackend;
108+
}
109+
110+
public void setLibguestfsBackend(String libguestfsBackend) {
111+
this.libguestfsBackend = libguestfsBackend;
112+
}
113+
114+
public String getVddkLibDir() {
115+
return vddkLibDir;
116+
}
117+
118+
public void setVddkLibDir(String vddkLibDir) {
119+
this.vddkLibDir = vddkLibDir;
120+
}
121+
122+
public String getVddkTransports() {
123+
return vddkTransports;
124+
}
125+
126+
public void setVddkTransports(String vddkTransports) {
127+
this.vddkTransports = vddkTransports;
128+
}
129+
130+
public String getVddkThumbprint() {
131+
return vddkThumbprint;
132+
}
133+
134+
public void setVddkThumbprint(String vddkThumbprint) {
135+
this.vddkThumbprint = vddkThumbprint;
136+
}
137+
93138
@Override
94139
public boolean executeInSequence() {
95140
return false;

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,10 +883,14 @@ protected enum HealthCheckResult {
883883

884884
private boolean convertInstanceVerboseMode = false;
885885
private Map<String, String> convertInstanceEnv = null;
886+
private String vddkLibDir = null;
887+
private String libguestfsBackend = "direct";
886888
protected boolean dpdkSupport = false;
887889
protected String dpdkOvsPath;
888890
protected String directDownloadTemporaryDownloadPath;
889891
protected String cachePath;
892+
private String vddkTransports = null;
893+
private String vddkThumbprint = null;
890894
protected String javaTempDir = System.getProperty("java.io.tmpdir");
891895

892896
private String getEndIpFromStartIp(final String startIp, final int numIps) {
@@ -951,6 +955,22 @@ public Map<String, String> getConvertInstanceEnv() {
951955
return convertInstanceEnv;
952956
}
953957

958+
public String getVddkLibDir() {
959+
return vddkLibDir;
960+
}
961+
962+
public String getLibguestfsBackend() {
963+
return libguestfsBackend;
964+
}
965+
966+
public String getVddkTransports() {
967+
return vddkTransports;
968+
}
969+
970+
public String getVddkThumbprint() {
971+
return vddkThumbprint;
972+
}
973+
954974
/**
955975
* Defines resource's public and private network interface according to what is configured in agent.properties.
956976
*/
@@ -1156,6 +1176,14 @@ public boolean configure(final String name, final Map<String, Object> params) th
11561176

11571177
setConvertInstanceEnv(convertEnvTmpDir, convertEnvVirtv2vTmpDir);
11581178

1179+
vddkLibDir = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.VDDK_LIB_DIR);
1180+
libguestfsBackend = StringUtils.defaultIfBlank(
1181+
AgentPropertiesFileHandler.getPropertyValue(AgentProperties.LIBGUESTFS_BACKEND), "direct");
1182+
vddkTransports = StringUtils.trimToNull(
1183+
AgentPropertiesFileHandler.getPropertyValue(AgentProperties.VDDK_TRANSPORTS));
1184+
vddkThumbprint = StringUtils.trimToNull(
1185+
AgentPropertiesFileHandler.getPropertyValue(AgentProperties.VDDK_THUMBPRINT));
1186+
11591187
pool = (String)params.get("pool");
11601188
if (pool == null) {
11611189
pool = "/root";

0 commit comments

Comments
 (0)