Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion api/core/v1alpha2/vmcondition/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ const (
ReasonDisksNotMigratable MigratableReason = "VirtualMachineDisksNotMigratable"
ReasonDisksShouldBeMigrating MigratableReason = "VirtualMachineDisksShouldBeMigrating"
ReasonHostDevicesNotMigratable MigratableReason = "VirtualMachineHostDevicesNotMigratable"
ReasonUSBShouldBeMigrating MigratableReason = "VirtualMachineUSBShouldBeMigrating"
)

type MigratingReason string
Expand Down
2 changes: 1 addition & 1 deletion build/components/versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ firmware:
libvirt: v10.9.0
edk2: stable202411
core:
3p-kubevirt: v1.6.2-v12n.15
3p-kubevirt: v1.6.2-v12n.16
3p-containerized-data-importer: v1.60.3-v12n.16
distribution: 2.8.3
package:
Expand Down
16 changes: 16 additions & 0 deletions crds/embedded/virtualmachineinstances.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3585,6 +3585,10 @@ spec:
deviceResourceClaimStatus:
description: DRA-related information for the device.
properties:
allowMultipleAllocations:
description: AllowMultipleAllocations is a flag to allow multiple
allocations of the same device
type: boolean
attributes:
description: |-
Properties of the device that could be used by kubevirt and other components to learn more
Expand All @@ -3597,6 +3601,10 @@ spec:
description: PCIe bus address of the allocated device.
type: string
type: object
bindsToNode:
description: BindsToNode is a flag to bind the device to the
node
type: boolean
name:
description: Name of actual device on the host provisioned by the driver as reflected in `resourceclaim.status`.
type: string
Expand Down Expand Up @@ -3633,6 +3641,10 @@ spec:
deviceResourceClaimStatus:
description: DRA-related information for the device.
properties:
allowMultipleAllocations:
description: AllowMultipleAllocations is a flag to allow multiple
allocations of the same device
type: boolean
attributes:
description: |-
Properties of the device that could be used by kubevirt and other components to learn more
Expand Down Expand Up @@ -3661,6 +3673,10 @@ spec:
- deviceNumber
type: object
type: object
bindsToNode:
description: BindsToNode is a flag to bind the device to the
node
type: boolean
name:
description: Name of actual device on the host provisioned by the driver as reflected in `resourceclaim.status`.
type: string
Expand Down
2 changes: 1 addition & 1 deletion images/virtualization-artifact/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,4 @@ replace (
)

// Kubevirt API replaces
replace kubevirt.io/api => github.com/deckhouse/3p-kubevirt/staging/src/kubevirt.io/api v1.6.2-v12n.12
replace kubevirt.io/api => github.com/deckhouse/3p-kubevirt/staging/src/kubevirt.io/api v1.6.2-v12n.16
4 changes: 2 additions & 2 deletions images/virtualization-artifact/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deckhouse/3p-kubevirt/staging/src/kubevirt.io/api v1.6.2-v12n.12 h1:KJoeBr01U8q2NXKvx4iCQwW8K6voiUrI1oOzDuaEvSk=
github.com/deckhouse/3p-kubevirt/staging/src/kubevirt.io/api v1.6.2-v12n.12/go.mod h1:J2HiSOLVhKj2UXoe14V6rpr3ZO/W/QBxcN+QK/S0Xkc=
github.com/deckhouse/3p-kubevirt/staging/src/kubevirt.io/api v1.6.2-v12n.16 h1:HzyValkO6ODGNvGtHhu11R7QkXzNkk4vmPgFouLE3NM=
github.com/deckhouse/3p-kubevirt/staging/src/kubevirt.io/api v1.6.2-v12n.16/go.mod h1:J2HiSOLVhKj2UXoe14V6rpr3ZO/W/QBxcN+QK/S0Xkc=
github.com/deckhouse/deckhouse/pkg/log v0.0.0-20250226105106-176cd3afcdd5 h1:PsN1E0oxC/+4zdA977txrqUCuObFL3HAuu5Xnud8m8c=
github.com/deckhouse/deckhouse/pkg/log v0.0.0-20250226105106-176cd3afcdd5/go.mod h1:Mk5HRzkc5pIcDIZ2JJ6DPuuqnwhXVkb3you8M8Mg+4w=
github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,3 +655,7 @@ func (b *KVVM) SetMetadata(metadata metav1.ObjectMeta) {
func (b *KVVM) SetUpdateVolumesStrategy(strategy *virtv1.UpdateVolumesStrategy) {
b.Resource.Spec.UpdateVolumesStrategy = strategy
}

func (b *KVVM) SetUSBMigrationStrategy() {
b.SetKVVMIAnnotation(virtv1.USBMigrationStrategyAnn, string(virtv1.USBMigrationStrategyIgnore))
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func ApplyVirtualMachineSpec(
return err
}

kvvm.SetUSBMigrationStrategy()
kvvm.SetMetadata(vm.ObjectMeta)
setNetwork(kvvm, networkSpec)
kvvm.SetTablet("default-0")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (h *MigratingHandler) Handle(ctx context.Context, s state.VirtualMachineSta
vm.Status.MigrationState = migrationState
}

err = h.syncMigratable(ctx, s, vm, kvvm, kvvmi)
err = h.syncMigratable(ctx, s, vm, kvvm)
if err != nil {
return reconcile.Result{}, fmt.Errorf("failed to sync migratable condition: %w", err)
}
Expand Down Expand Up @@ -277,7 +277,7 @@ func (h *MigratingHandler) getVMOPCandidate(ctx context.Context, s state.Virtual
return nil, nil
}

func (h *MigratingHandler) syncMigratable(ctx context.Context, s state.VirtualMachineState, vm *v1alpha2.VirtualMachine, kvvm *virtv1.VirtualMachine, kvvmi *virtv1.VirtualMachineInstance) error {
func (h *MigratingHandler) syncMigratable(ctx context.Context, s state.VirtualMachineState, vm *v1alpha2.VirtualMachine, kvvm *virtv1.VirtualMachine) error {
cb := conditions.NewConditionBuilder(vmcondition.TypeMigratable).Generation(vm.GetGeneration())

if kvvm != nil {
Expand All @@ -297,18 +297,9 @@ func (h *MigratingHandler) syncMigratable(ctx context.Context, s state.VirtualMa
conditions.SetCondition(cb, &vm.Status.Conditions)
return nil
case liveMigratable.Reason == virtv1.VirtualMachineInstanceReasonHostDeviceNotMigratable:
hostDeviceNames := getHostDeviceNamesFromKVVMI(kvvmi)
isAllUSB := allHostDevicesAreUSB(hostDeviceNames)

if isAllUSB {
cb.Status(metav1.ConditionTrue).
Reason(vmcondition.ReasonUSBShouldBeMigrating).
Message("")
} else {
cb.Status(metav1.ConditionFalse).
Reason(vmcondition.ReasonHostDevicesNotMigratable).
Message("Live migration requires that all Host Devices must be unplugged")
}
cb.Status(metav1.ConditionFalse).
Reason(vmcondition.ReasonHostDevicesNotMigratable).
Message("Live migration requires that all Host Devices must be unplugged")

conditions.SetCondition(cb, &vm.Status.Conditions)
return nil
Expand Down Expand Up @@ -354,43 +345,3 @@ func (h *MigratingHandler) syncMigratable(ctx context.Context, s state.VirtualMa
func liveMigrationInProgress(migrationState *v1alpha2.VirtualMachineMigrationState) bool {
return migrationState != nil && migrationState.StartTimestamp != nil && migrationState.EndTimestamp == nil
}

// getHostDeviceNamesFromKVVMI returns unique host device names from both Spec and Status.
// Either spec or status (or both) can be nil when the other has devices, e.g. after deleting hp pod.
func getHostDeviceNamesFromKVVMI(kvvmi *virtv1.VirtualMachineInstance) []string {
if kvvmi == nil {
return nil
}
names := make(map[string]struct{})
if kvvmi.Spec.Domain.Devices.HostDevices != nil {
for _, d := range kvvmi.Spec.Domain.Devices.HostDevices {
if d.Name != "" {
names[d.Name] = struct{}{}
}
}
}
if kvvmi.Status.DeviceStatus != nil && kvvmi.Status.DeviceStatus.HostDeviceStatuses != nil {
for _, st := range kvvmi.Status.DeviceStatus.HostDeviceStatuses {
if st.Name != "" {
names[st.Name] = struct{}{}
}
}
}
result := make([]string, 0, len(names))
for n := range names {
result = append(result, n)
}
return result
}

func allHostDevicesAreUSB(deviceNames []string) bool {
if len(deviceNames) == 0 {
return true // no host devices visible — do not block migration (e.g. when spec/status incomplete)
}
for _, name := range deviceNames {
if !strings.HasPrefix(name, "usb-") {
return false
}
}
return true
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ func (h *SyncMetadataHandler) updateKVVMSpecTemplateMetadataAnnotations(currAnno
res[netmanager.AnnoIPAddressCNIRequest] = v
}

if v, ok := currAnno[virtv1.USBMigrationStrategyAnn]; ok {
res[virtv1.USBMigrationStrategyAnn] = v
}

return commonvm.RemoveNonPropagatableAnnotations(res)
}

Expand Down

This file was deleted.

Loading
Loading