Skip to content

feat(vm): reducing USB device downtime during VM migration#2098

Merged
yaroslavborbat merged 1 commit into
mainfrom
feat/usb-migration
Mar 23, 2026
Merged

feat(vm): reducing USB device downtime during VM migration#2098
yaroslavborbat merged 1 commit into
mainfrom
feat/usb-migration

Conversation

@yaroslavborbat
Copy link
Copy Markdown
Member

@yaroslavborbat yaroslavborbat commented Mar 12, 2026

Description

This PR improves USB device migration for virtual machines by delegating USB migration logic to KubeVirt.

Changes:

  • Removed all USB device detach/attach logic around migration from virtualization-controller
  • Migrated USB migration handling to KubeVirt fork: feat: add usb migration strategy annotation 3p-kubevirt#77
  • Introduced USBMigrationStrategyAnn annotation on KVVMI to control USB device behavior during migration
  • Default strategy is USBMigrationStrategyIgnore: USB device is not detached before migration, instead it is ignored on the target domain and automatically detached/re-attached when the VM switches to the target node

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

Previously, the USB migration logic was implemented in virtualization-controller:

  1. USB device was detached from the VM before migration started
  2. VM migrated to the target node
  3. USB device was attached again after migration completed

This approach caused significant downtime for USB devices during migration — the device was unavailable from the detach operation until the attach operation completed on the target node.

The new approach moves this logic into KubeVirt and uses the USBMigrationStrategyAnn annotation (set to USBMigrationStrategyIgnore) on the KVVMI object:

  • USB device is not detached before migration
  • On the target node, USB device is initially ignored (not attached during migration)
  • When the VM switches to the target node, the USB device is automatically detached from source and re-attached on target
  • This significantly reduces USB device downtime

What is the expected result?

  1. Create a VM with an attached USB device
  2. Initiate live migration of the VM
  3. Verify that USB device downtime is minimal (detach/re-attach happens atomically when VM becomes active on target)
  4. After migration completes, verify that USB device is successfully attached on the target node
  5. VM migration completes successfully

Expected behavior:

  • USB device downtime is reduced from "full migration duration + detach/attach overhead" to near-instant detach/re-attach
  • USB device is automatically re-attached on the target node after migration
  • No USB-related migration logic remains in virtualization-controller
  • USB migration behavior is controlled by the USBMigrationStrategyAnn annotation on KVVMI

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: feature
summary: Reduced USB device downtime during virtual machine migration.

@yaroslavborbat yaroslavborbat added this to the v1.7.0 milestone Mar 12, 2026
@yaroslavborbat yaroslavborbat changed the title improve usb migration feat(vm): reducing USB device downtime during VM migration Mar 16, 2026
@yaroslavborbat yaroslavborbat marked this pull request as ready for review March 16, 2026 08:46
@prismagod
Copy link
Copy Markdown
Member

prismagod commented Mar 16, 2026

Do we need to update this alert in USER_GUIDE.md?

Upd: updated the alert in the 1.7.0 documentation PR.

@yaroslavborbat yaroslavborbat force-pushed the feat/usb-migration branch 3 times, most recently from 8ae8005 to cc6b8ff Compare March 23, 2026 09:00
danilrwx
danilrwx previously approved these changes Mar 23, 2026
Signed-off-by: Yaroslav Borbat <yaroslav.borbat@flant.com>
@yaroslavborbat yaroslavborbat merged commit 656ad43 into main Mar 23, 2026
27 of 28 checks passed
@yaroslavborbat yaroslavborbat deleted the feat/usb-migration branch March 23, 2026 14:34
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.

3 participants