Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[VMware to KVM Migration] Fix unused convert env vars #11947

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
nvazquez wants to merge 2 commits into apache:4.22
base: 4.22
Choose a base branch
Loading
from shapeblue:422-vmware-import-vars-unused

Conversation

@nvazquez
Copy link
Contributor

@nvazquez nvazquez commented Oct 30, 2025

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?

Copy link
Contributor Author

@blueorangutan package

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.

Copy link

codecov bot commented Oct 30, 2025
edited
Loading

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).
⚠️ Report is 60 commits behind head on 4.22.

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.

Copy link

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

Copy link
Contributor Author

@blueorangutan package

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.

Copy link

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

Copy link
Contributor Author

Copy link

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

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
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
edited
Loading

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

@DaanHoogland DaanHoogland Nov 3, 2025

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

Copy link
Contributor

@DaanHoogland DaanHoogland Jan 23, 2026

Choose a reason for hiding this comment

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

I don’t see a null @nvazquez , what do you mean?

Copy link
Contributor

@blueorangutan package

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.

Copy link

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

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
Copy link
Contributor Author

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

Copy link
Contributor Author

@blueorangutan package

Copy link
Contributor Author

@blueorangutan package

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.

Copy link

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

Copy link
Contributor Author

Copy link

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

Copy link

[SF] Trillian Build Failed (tid-15186)

Copy link
Contributor Author

Copy link

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

Copy link

[SF] Trillian Build Failed (tid-15189)

Copy link

@rajujith rajujith left a comment
edited
Loading

Choose a reason for hiding this comment

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

@nvazquez I see the convert.instance.env.tmpdir getting used as a virt-v2v tmp directory but I do not see the other one being used although I set separate directories for both.
cc @NuxRo

Copy link
Contributor

NuxRo commented Jan 23, 2026

@nvazquez @rajujith I do not remember at the moment under which circumstances TMPDIR was needed. I'd argue that it's good to have it in there even if in your test so far you have not seen it applied.

Copy link

@nvazquez, the usage of the configuration seems to be interchanged; otherwise its fine. Just wondering if we need a doc PR for this.

Copy link

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

Copy link
Contributor

@nvazquez can you please address the conflicts and comments from Jithin?

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

Reviewers

@rajujith rajujith rajujith left review comments

Copilot code review Copilot Copilot left review comments

@NuxRo NuxRo Awaiting requested review from NuxRo

@Pearl1594 Pearl1594 Awaiting requested review from Pearl1594

@vladimirpetrov vladimirpetrov Awaiting requested review from vladimirpetrov

@weizhouapache weizhouapache Awaiting requested review from weizhouapache

@shwstppr shwstppr Awaiting requested review from shwstppr

@DaanHoogland DaanHoogland Awaiting requested review from DaanHoogland

Assignees

No one assigned

Projects

Status: In Progress

Milestone

4.22.1

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /