-
Notifications
You must be signed in to change notification settings - Fork 296
Description
XAPI issue: starting a cloned VM that still has is_a_template=true returns a misleading "multiple VMs" error
Summary
When a VM cloned from a template remains flagged as is_a_template=true, attempts to start it via XenAPI (xe vm-start or any API client such as Ansible's community.general.xenserver_guest) fail with:
VM search: multiple VMs with name '<vm-name>' found! Please use UUID.
In reality there is only one VM with that name; the failure occurs because XAPI refuses to start objects that are still marked as templates. The error message misdirects operators toward name collisions instead of highlighting the real problem (template state), which significantly increases troubleshooting time.
Environment details
- Host:
xcp01(lab/dev server) - Product: XCP-ng (XAPI)
- Workflow: automated provisioning via Ansible
community.general.xenserver_guestwhich calls XenAPI to clone templates and power on the new VM. - Template: Debian 13 base image (
debian-2025-template).
Reproduction steps
- Clone a VM from a template via
xe vm-clone(or XenAPI) in such a way that the resulting VM still hasis_a_template = true. This happens intermittently on our XCP-ng host when the template conversion step fails or is skipped. - Attempt to start the cloned VM via XenAPI (
xe vm-start vm=<name>orcommunity.general.xenserver_guestwithstate=poweredon).
Actual result
XAPI responds with:
VM search: multiple VMs with name '<vm-name>' found! Please use UUID.
- There is only one VM with that
name-label(verified withxe vm-list name-label=<vm>). - The misleading error prevents automation from detecting the real cause and forces manual investigation.
Expected result
XAPI should return an error that explicitly states the VM cannot be started because it is still a template, e.g.:
Cannot start VM '<vm-name>' because it is flagged as a template (is_a_template=true). Convert it to a VM first.
This would immediately direct operators (and tooling) to resolve the template flag rather than searching for nonexistent duplicate names.
Why this matters
- Our provisioning automation relies on XenAPI responses to decide remediation steps.
- The current message causes us to misdiagnose the issue (searching for duplicate names) and delays remediation.
- A clearer error would benefit any tooling built on XenAPI and reduce support load.
Suggested fix / proposal
In the code path that handles VM.start, detect when the target record has is_a_template = true and raise a dedicated error (or include that information in the existing error) before the name lookup path emits the generic "multiple VMs" message.
If you need additional logs or a reproducer script, let us know—we can provide the Ansible playbook and XCP-ng host details used in this scenario.