Skip to main content
EARLY ACCESS

This feature is available as Early Access (EA) and should not be used in production.

Hot Plug Disks for a KubeVirt VM

Hot plug lets you attach or detach disks from a running KubeVirt virtual machine (VM) without restarting the VM. With Portworx Fusion Controller, you can hot attach and hot detach Fusion-backed disks while the VM continues to run.

When you hot attach a disk, the Portworx Fusion Controller detects the newly attached volume, updates the corresponding FusionWorkload custom resource (CR), and provisions the volume on the appropriate FlashArray. When you hot detach a disk, the controller updates the FusionWorkload CR to reflect the change.

Prerequisites​

Before attaching or detaching a disk, ensure that the following requirements are met:

  • Portworx Fusion Controller is enabled. For more information, see Enable Portworx Fusion Controller.
  • A Fusion preset is available. For more information, see Create a Fusion Preset.
  • The VM is running.
  • The disk uses the same Fusion-backed StorageClass as the VM's existing disks and is provided through either a DataVolume or a precreated PVC. For more information, see Create a KubeVirt VM using a Fusion Preset or Create a KubeVirt VM using a precreated PVC.
  • All disks attached to the VM, including hot-plugged disks, use the same ReadWriteMany (RWX) volume type. Do not attach a disk that uses a different RWX volume type from the VM's existing disks. Mixing volume types can cause node drains to stall during OpenShift Container Platform or Portworx upgrades.

Hot attach a disk​

You can attach a disk to a running VM by using the virtctl CLI or the OpenShift web console.

A hot-plugged disk can be non-persistent or persistent. A non-persistent disk is detached when the VM restarts. A persistent disk is added to the VM specification and remains attached across restarts.

Use the virtctl CLI​

  1. Attach the disk by using one of the following commands:

    • To attach the disk to the current VM instance only, run:

      virtctl addvolume <vm-name> --volume-name=<pvc-name>

      The disk is detached when the VM restarts.

    • To attach the disk and retain it across VM restarts, run:

      virtctl addvolume <vm-name> --volume-name=<pvc-name> --persist

    Replace <vm-name> with the name of the running VM and <pvc-name> with the name of the PVC or DataVolume to attach.

    note

    To run virtctl addvolume, your account must have permission to update VirtualMachine and VirtualMachineInstance resources in the namespace. If you also create the PVC used as the disk source, your account requires permission to create PVCs.

  2. Verify that the disk is attached:

    virtctl fslist <vm-name>

    You can also verify the disk from within the guest operating system.

Use the OpenShift web console​

  1. In the OpenShift web console, go to Virtualization > VirtualMachines.
  2. Select the running VM.
  3. On the Configuration tab, select Storage.
  4. Select Add disk.
  5. Specify the disk details, and select the PVC that uses a Fusion-backed StorageClass.
  6. Select Save.

The disk is attached to the running VM.

Hot detach a disk​

You can detach a disk from a running VM by using the virtctl CLI or the OpenShift web console.

note

Detaching a disk removes it from the VM but does not delete the underlying PVC or its associated FlashArray volume. The PVC has an independent lifecycle from the VM and is not deleted when you delete the VM. Delete the PVC separately when you no longer need the storage.

Use the virtctl CLI​

To detach a disk, run:

virtctl removevolume <vm-name> --volume-name=<pvc-name>

Replace <vm-name> with the name of the running VM and <pvc-name> with the name of the volume to detach.

note

To run virtctl removevolume, your account must have permission to update VirtualMachine and VirtualMachineInstance resources in the namespace.

Use the OpenShift web console​

  1. In the OpenShift web console, go to Virtualization > VirtualMachines.
  2. Select the running VM.
  3. On the Configuration tab, select Storage.
  4. Select the disk to detach, and then select Detach.

View disk operation events​

The Fusion Controller records disk lifecycle events on the FusionWorkload CR associated with the VM.

To view these events, run:

kubectl describe fusionworkload <workload-name> -n <namespace>

Replace <workload-name> with the name of the FusionWorkload CR associated with the VM and <namespace> with the namespace where the VM runs.

The Events section shows disk attachment, detachment, and provisioning activity. If an operation fails, the event message describes the reason.

To view the disks currently attached to the VM, run:

kubectl describe vm <vm-name> -n <namespace>

Replace <vm-name> with the name of the VM and <namespace> with the namespace where the VM runs.

In this topic: