Copilot commented on code in PR #11594:
URL: https://github.com/apache/cloudstack/pull/11594#discussion_r2367486766
##########
engine/schema/src/main/resources/META-INF/db/schema-42100to42200.sql:
##########
@@ -21,3 +21,33 @@
-- Increase length of scripts_version column to 128 due to md5sum to sha512sum
change
CALL `cloud`.`IDEMPOTENT_CHANGE_COLUMN`('cloud.domain_router',
'scripts_version', 'scripts_version', 'VARCHAR(128)');
+
+-- VMware to KVM migration improvements
+CREATE TABLE IF NOT EXISTS `cloud`.`import_vm_task`(
+ `id` bigint unsigned NOT NULL auto_increment COMMENT 'id',
+ `uuid` varchar(40),
+ `zone_id` bigint unsigned NOT NULL COMMENT 'Zone ID',
+ `account_id` bigint unsigned NOT NULL COMMENT 'Account ID',
+ `user_id` bigint unsigned NOT NULL COMMENT 'User ID',
+ `vm_id` bigint unsigned COMMENT 'VM ID',
+ `display_name` varchar(255) COMMENT 'Display VM Name',
+ `vcenter` varchar(255) COMMENT 'VCenter',
+ `datacenter` varchar(255) COMMENT 'VCenter Datacenter name',
+ `source_vm_name` varchar(255) COMMENT 'Source VM name on vCenter',
+ `convert_host_id` bigint unsigned COMMENT 'Convert Host ID',
+ `import_host_id` bigint unsigned COMMENT 'Import Host ID',
+ `step` varchar(20) NOT NULL COMMENT 'Importing VM Task Step',
+ `description` varchar(255) COMMENT 'Importing VM Task Description',
+ `duration` bigint unsigned COMMENT 'Duration in milliseconds for the
completed tasks',
+ `created` datetime NOT NULL COMMENT 'date created',
+ `updated` datetime COMMENT 'date updated if not null',
+ `removed` datetime COMMENT 'date removed if not null',
+ PRIMARY KEY (`id`),
+ CONSTRAINT `fk_import_vm_task__zone_id` FOREIGN KEY
`fk_import_vm_task__zone_id` (`zone_id`) REFERENCES `data_center`(`id`) ON
DELETE CASCADE,
+ CONSTRAINT `fk_import_vm_task__account_id` FOREIGN KEY
`fk_import_vm_task__account_id` (`account_id`) REFERENCES `account`(`id`) ON
DELETE CASCADE,
+ CONSTRAINT `fk_import_vm_task__user_id` FOREIGN KEY
`fk_import_vm_task__user_id` (`user_id`) REFERENCES `user`(`id`) ON DELETE
CASCADE,
+ CONSTRAINT `fk_import_vm_task__vm_id` FOREIGN KEY
`fk_import_vm_task__vm_id` (`user_id`) REFERENCES `vm_instance`(`id`) ON DELETE
CASCADE,
Review Comment:
The foreign key constraint is incorrectly referencing `user_id` column
instead of `vm_id` column. It should be `(`vm_id`)` to properly reference the
vm_instance table.
```suggestion
CONSTRAINT `fk_import_vm_task__vm_id` FOREIGN KEY
`fk_import_vm_task__vm_id` (`vm_id`) REFERENCES `vm_instance`(`id`) ON DELETE
CASCADE,
```
##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java:
##########
@@ -1422,6 +1432,22 @@ public boolean configure(final String name, final
Map<String, Object> params) th
return true;
}
+ private void setConvertInstanceEnv(String convertEnvTmpDir, String
convertEnvVirtv2vTmpDir) {
+ if (StringUtils.isAllBlank(convertEnvTmpDir, convertEnvVirtv2vTmpDir))
{
+ return;
+ }
+ if (StringUtils.isNotBlank(convertEnvTmpDir) &&
StringUtils.isNotBlank(convertEnvVirtv2vTmpDir)) {
+ convertInstanceEnv = new String[2];
+ convertInstanceEnv[0] = String.format("%s=%s", "TMPDIR",
convertEnvTmpDir);
+ convertInstanceEnv[1] = String.format("%s=%s", "VIRT_V2V_TMPDIR",
convertEnvTmpDir);
Review Comment:
The environment variable assignment is incorrect. When both tmpdir variables
are provided, the second assignment should use `convertEnvVirtv2vTmpDir`
instead of `convertEnvTmpDir`.
```suggestion
convertInstanceEnv[1] = String.format("%s=%s",
"VIRT_V2V_TMPDIR", convertEnvVirtv2vTmpDir);
```
##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConvertInstanceCommandWrapper.java:
##########
@@ -232,10 +234,13 @@ protected boolean performInstanceConversion(String
sourceOVFDirPath,
if (verboseModeEnabled) {
script.add("-v");
}
+ if (StringUtils.isNotBlank(extraParams)) {
+ script.add(extraParams);
Review Comment:
Adding extraParams directly to the script without validation could allow
command injection. The extraParams should be properly sanitized or parsed to
ensure they contain only valid virt-v2v parameters.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]