Skip to content

fix(vmrestore): drop usb devices in best effort clone#2076

Merged
danilrwx merged 2 commits intomainfrom
fix/usb/clone-besteffort
Mar 10, 2026
Merged

fix(vmrestore): drop usb devices in best effort clone#2076
danilrwx merged 2 commits intomainfrom
fix/usb/clone-besteffort

Conversation

@danilrwx
Copy link
Contributor

@danilrwx danilrwx commented Mar 6, 2026

Description

Fix VM clone behavior in BestEffort mode when source VM has attached USB devices.

The restore handler now filters out spec.usbDevices during clone validation for SnapshotOperationModeBestEffort, so clone creation is not blocked by USB dependencies.

Also extended unit tests in vm_restorer_test.go to verify:

  • USB devices are removed in BestEffort mode
  • USB devices are preserved in Strict mode

Why do we need it, and what problem does it solve?

In BestEffort clone mode, we should tolerate dependencies that cannot be reproduced in the clone target.

USB devices may be busy or attached to another VM, and carrying them over to a cloned VM can cause clone failures or invalid restore behavior. This change makes BestEffort clone semantics consistent by dropping USB attachments from the cloned VM spec.

What is the expected result?

  1. Create a VM with spec.usbDevices.
  2. Run clone/restore in BestEffort mode.
  3. Verify the cloned VM is created successfully and has no spec.usbDevices.
  4. Run clone/restore in Strict mode.
  5. Verify spec.usbDevices are kept in the cloned VM.

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

Changelog entries

section: vm
type: fix
summary: Fixed cloning of a virtual machine with connected USB devices when using `VirtualMachineOperation` with the `Clone` type in `BestEffort` mode.

@danilrwx danilrwx added this to the v1.7.0 milestone Mar 6, 2026
@danilrwx danilrwx marked this pull request as ready for review March 6, 2026 09:12
@danilrwx danilrwx force-pushed the fix/usb/clone-besteffort branch 2 times, most recently from 8ba7803 to 0d1ce92 Compare March 10, 2026 09:50
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
@danilrwx danilrwx force-pushed the fix/usb/clone-besteffort branch from 0d1ce92 to 7e7bb96 Compare March 10, 2026 09:53
@danilrwx danilrwx merged commit 8931e9c into main Mar 10, 2026
27 of 28 checks passed
@danilrwx danilrwx deleted the fix/usb/clone-besteffort branch March 10, 2026 11:24
Isteb4k pushed a commit that referenced this pull request Mar 10, 2026
Description
Fix VM clone behavior in BestEffort mode when source VM has attached USB devices.

The restore handler now filters out spec.usbDevices during clone validation for SnapshotOperationModeBestEffort, so clone creation is not blocked by USB dependencies.

Also extended unit tests in vm_restorer_test.go to verify:

USB devices are removed in BestEffort mode
USB devices are preserved in Strict mode

---------

Signed-off-by: Daniil Antoshin <daniil.antoshin@flant.com>
(cherry picked from commit 8931e9c)
@Isteb4k Isteb4k modified the milestones: v1.7.0, v1.6.1 Mar 10, 2026
This was referenced Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants