Skip to content

Conversation

@nvazquez
Copy link
Contributor

Description

This PR fixes unused convert env variables from PR #11594 on the KVM agents, when agent.properties set:

# Instance conversion TMPDIR env var
#convert.instance.env.tmpdir=

# Instance conversion VIRT_V2V_TMPDIR env var
#convert.instance.env.virtv2v.tmpdir=

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

@nvazquez
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@codecov
Copy link

codecov bot commented Oct 30, 2025

Codecov Report

❌ Patch coverage is 42.85714% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.59%. Comparing base (b8ed34e) to head (1a64f64).

Files with missing lines Patch % Lines
...ervisor/kvm/resource/LibvirtComputingResource.java 14.28% 6 Missing ⚠️
...s/src/main/java/com/cloud/utils/script/Script.java 60.00% 2 Missing and 2 partials ⚠️
.../wrapper/LibvirtConvertInstanceCommandWrapper.java 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.22   #11947   +/-   ##
=========================================
  Coverage     17.59%   17.59%           
- Complexity    15600    15602    +2     
=========================================
  Files          5910     5910           
  Lines        529755   529767   +12     
  Branches      64724    64726    +2     
=========================================
+ Hits          93228    93235    +7     
- Misses       426035   426038    +3     
- Partials      10492    10494    +2     
Flag Coverage Δ
uitests 3.60% <ø> (ø)
unittests 18.66% <42.85%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@blueorangutan
Copy link

Packaging result [SF]: ✖️ el8 ✖️ el9 ✔️ debian ✖️ suse15. SL-JID 15595

@nvazquez
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 15598

@nvazquez
Copy link
Contributor Author

@blueorangutan test

@blueorangutan
Copy link

@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian test result (tid-14752)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 61259 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr11947-t14752-kvm-ol8.zip
Smoke tests completed. 148 look OK, 0 have errors, 1 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
all_test_human_readable_logs Skipped --- test_human_readable_logs.py

@DaanHoogland DaanHoogland added this to the 4.22.1 milestone Oct 31, 2025
@shwstppr shwstppr requested a review from Copilot November 3, 2025 10:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for passing custom environment variables when executing scripts via the Script class, specifically to support virt-v2v instance conversions. The changes enable passing environment variables like TMPDIR and VIRT_V2V_TMPDIR to the virt-v2v command, which is necessary for indirect tool invocations (e.g., virt-v2v calling qemu-img).

Key changes:

  • Extended the Script.execute() method to accept an optional environment variables array
  • Modified the script execution logic to use Runtime.exec() with environment variables when provided, falling back to ProcessBuilder when no environment is specified
  • Updated LibvirtConvertInstanceCommandWrapper to pass environment variables retrieved from the resource configuration

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
utils/src/main/java/com/cloud/utils/script/Script.java Added new overloaded execute() methods to accept environment variables and modified execution logic to handle both ProcessBuilder and Runtime.exec() approaches
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConvertInstanceCommandWrapper.java Updated to retrieve and conditionally pass environment variables to the script execution

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 249 to 253
if (ArrayUtils.isEmpty(convertInstanceEnv)) {
script.execute(outputLogger);
} else {
script.execute(outputLogger, convertInstanceEnv);
}
Copy link

Copilot AI Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditional check and branching can be simplified. The execute(outputLogger) method already calls execute(outputLogger, null), and the implementation handles null/empty arrays. You can directly call script.execute(outputLogger, convertInstanceEnv) without the conditional check, simplifying the code.

Suggested change
if (ArrayUtils.isEmpty(convertInstanceEnv)) {
script.execute(outputLogger);
} else {
script.execute(outputLogger, convertInstanceEnv);
}
script.execute(outputLogger, convertInstanceEnv);

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

@nvazquez nvazquez Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shwstppr @DaanHoogland I would prefer keeping it like this as script.execute(outputLogger); has 73 usages which we'll need passing null as the second parameter. I think keeping it like this it cleaner

Comment on lines 243 to 247
public String execute(OutputInterpreter interpreter, String[] environment) {
return executeInternal(interpreter, environment);
}

public String executeInternal(OutputInterpreter interpreter, String[] environment) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public String execute(OutputInterpreter interpreter, String[] environment) {
return executeInternal(interpreter, environment);
}
public String executeInternal(OutputInterpreter interpreter, String[] environment) {
public String execute(OutputInterpreter interpreter, String[] environment) {

no need for the extra call on the stack, that I can see

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shwstppr @DaanHoogland I would prefer keeping it like this as script.execute(outputLogger); has 73 usages which we'll need passing null as the second parameter. I think keeping it like this it cleaner

@Damans227
Copy link
Contributor

@blueorangutan package

@blueorangutan
Copy link

@Damans227 a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✖️ debian ✔️ suse15. SL-JID 15891

@rajujith
Copy link

@nvazquez Since this is for the 4.22.1 release, could you retarget the PR to the 4.22 branch?

@nvazquez nvazquez force-pushed the 422-vmware-import-vars-unused branch from f2b6474 to f893d3d Compare January 14, 2026 16:53
@nvazquez nvazquez changed the base branch from main to 4.22 January 14, 2026 16:53
@nvazquez
Copy link
Contributor Author

Thanks @rajujith retargeted to branch 4.22. @shwstppr @DaanHoogland I'll address your comments, thanks

@nvazquez
Copy link
Contributor Author

@blueorangutan package

@nvazquez
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@nvazquez a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 16366

@nvazquez
Copy link
Contributor Author

@blueorangutan test

@blueorangutan
Copy link

@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian Build Failed (tid-15186)

@nvazquez nvazquez requested a review from rajujith January 15, 2026 10:40
@nvazquez
Copy link
Contributor Author

@blueorangutan test

@blueorangutan
Copy link

@nvazquez a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian Build Failed (tid-15189)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

6 participants