VMware import (importVm) fails when datacenter/cluster/host name contains a space
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 75/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- java
- Domain
- backend, infrastructure
Research direction
Start in plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConvertInstanceCommandWrapper.java, reading buildVpxUrl, getExportOVAUrlFromRemoteInstance, and encodeUsername. Reproduce the import with a space in a datacenter, cluster, host, path, or VM name and inspect both OVA and VDDK paths. Done means the generated vpx:// and vi:// URIs parse successfully while folder separators remain intact.
Written by the indexing model from the issue text.
Description
Summary
LibvirtConvertInstanceCommandWrapper builds the vpx:///vi:// connection URIs for virt-v2v by concatenating the vCenter datacenter/cluster/host names without percent-encoding them. A datacenter (or cluster/host) name containing a space — valid in vSphere — produces an invalid URI, and VM import from VMware fails.
Environment
- CloudStack main (
659f675b059c1e5008deb3bb28793eadf377d687) - KVM host,
virt-v2v 2.7.1,libvirt 9.0.0 - Import VM from VMware (UI: Import Instance, or the
importVmAPI withimportsource=vmware), reproduced on both the OVA-conversion path and the VDDK path (-it vddk)
Steps to Reproduce
- Rename a vCenter Datacenter to include a space, e.g.
"QA Lab". - Import a VM from it via the CloudStack UI (Import Instance) or the
importVmAPI. - Conversion fails.
Actual Behavior
Using VPX URL: vpx://Administrator%40vsphere.local@203.0.113.10/QA Lab/cluster-a/203.0.113.20?no_verify=1
virt-v2v: error: could not parse '-ic vpx://...QA Lab/cluster-a/203.0.113.20?no_verify=1'. Original error message was: parse_uri: unable to parse URI
Also seen on the VDDK import path (-it vddk), same unencoded QA Lab segment, surfacing as java.io.IOException: Stream closed instead — a downstream symptom of virt-v2v exiting immediately on the same bad URI, not a separate defect.
The username is correctly percent-encoded (Administrator%40vsphere.local); datacenter/cluster/host are not.
Root Cause
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtConvertInstanceCommandWrapper.java
buildVpxUrl(~L463): appendsdatacenter,cluster,hostraw afterurl.append("/").getExportOVAUrlFromRemoteInstance(~L203): same pattern fordatacenter/path/vmin thevi://URL.encodeUsername(~L298) usesURLEncoder.encode, which encodes space as+— wrong for a URI path/authority (libvirt only decodes%20). Not yet visible as a bug since vCenter usernames rarely have spaces, but worth fixing alongside the above with the same helper.
Suggested Fix
Percent-encode datacenter/cluster/host/path/vm per /-delimited sub-segment (not as one string) — datacenter/cluster names can be folder-nested (e.g. MyFolder/MyDC), and that / must stay literal.
versions
ACS 4.22.1
- Dominant language
- Java
- Stars
- 3.1k
- Forks
- 1.4k
- Avg merge
- 6d 20h
- Merged PRs (30d)
- 27
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/cloudstack
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 90/100
apache/cloudstack#14222 ·
-
bug component:kubernetes
Difficulty 1/5 Under an hour Newbie friendliness 88/100
apache/cloudstack#14180 ·
-
bug component:projects component:UI
Difficulty 1/5 Under an hour Newbie friendliness 88/100
apache/cloudstack#14070 · 5 comments ·
-
component:backup
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
apache/cloudstack#14013 ·
-
KVM agent fails to connect to Ceph RBD storage pool after upgrading Ceph client to Tentacle 20.2.4 Openbug component:ceph
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/cloudstack#13989 · 3 comments ·
All issues in apache/cloudstack
Similar issues
-
area/plugin
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
kestra-io/plugin-kestra#190 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
integra-team-red/meet-map#249 ·
-
[Studio][Bug] Cancelled create-user dialog keeps the password and admin switch for the next attempt Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
apache/rocketmq-dashboard#5064 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
wso2/dpdp-accelerator#287 ·