Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
7c4df85
wip
loktev-d Feb 27, 2026
f5099bd
Merge remote-tracking branch 'origin/main' into feat/vm/hotplug-block…
loktev-d Feb 27, 2026
ddf6e44
wip
loktev-d Feb 27, 2026
ccbe3a4
wip
loktev-d Feb 27, 2026
b46c4ab
wip
loktev-d Mar 2, 2026
a04c63e
wip
loktev-d Mar 2, 2026
331ba6a
wip
loktev-d Mar 2, 2026
eb51b47
wip
loktev-d Mar 2, 2026
6312d9f
fix linter errors
loktev-d Mar 2, 2026
6c6d5e6
Merge branch 'main' into feat/vm/hotplug-block-devices-via-spec
loktev-d Mar 3, 2026
bebae37
move attachment service back
loktev-d Mar 3, 2026
2b40420
wip
loktev-d Mar 3, 2026
1a9ea6f
wip
loktev-d Mar 3, 2026
625783e
Merge branch 'main' into feat/vm/hotplug-block-devices-via-spec
loktev-d Mar 3, 2026
9f0b015
wip
loktev-d Mar 3, 2026
ababbb2
wip
loktev-d Mar 3, 2026
fab1cb0
add e2e
loktev-d Mar 4, 2026
3f9bbe1
add unit tests
loktev-d Mar 4, 2026
9fa1597
add doc
loktev-d Mar 4, 2026
e4d602e
wip
loktev-d Mar 4, 2026
d015889
fix vmbda error
loktev-d Mar 4, 2026
a8fc9cf
add validation for conflicts
loktev-d Mar 5, 2026
1843d0e
docs: review
prismagod Mar 10, 2026
7e25cbc
Merge remote-tracking branch 'origin/main' into feat/vm/hotplug-block…
loktev-d Mar 11, 2026
417b093
fix merge
loktev-d Mar 11, 2026
69e74ad
Merge remote-tracking branch 'origin/main' into feat/vm/hotplug-block…
loktev-d Mar 13, 2026
8e9a8a1
docs: update user guide for block device attachment methods
prismagod Mar 13, 2026
ace7f4c
docs: fix
prismagod Mar 13, 2026
a29e584
docs: add additional info from ADR
prismagod Mar 13, 2026
bfc9a1b
docs: post-review updates
prismagod Mar 13, 2026
de41a9a
fix backward compatility
loktev-d Mar 13, 2026
6ce1e96
fix comments
loktev-d Mar 13, 2026
f9ec5d8
wip
loktev-d Mar 13, 2026
3823407
fix: golangci-lint error
Mar 17, 2026
4861047
docs: update bootOrder description
prismagod Mar 18, 2026
981aa64
fix: vi on pvc is not ephemeral
Mar 19, 2026
d461779
feat: add bootOrder to vm block device refs status
Mar 20, 2026
919e4e7
chore: refactor bootOrder status
Mar 20, 2026
4d87095
chore: refactor bootOrderStatus 2
Mar 20, 2026
494a45f
wip
loktev-d Apr 2, 2026
cf571b3
Merge branch 'main' into feat/vm/hotplug-block-devices-via-spec
loktev-d Apr 2, 2026
31cd2d7
fix logic for disk buses
loktev-d Apr 13, 2026
98362b1
Merge branch 'main' into feat/vm/hotplug-block-devices-via-spec
loktev-d Apr 13, 2026
e7d2151
wip
loktev-d Apr 13, 2026
a10a634
fix linter errors
loktev-d Apr 13, 2026
ee73fce
wip
loktev-d Apr 13, 2026
615087f
Merge branch 'main' into feat/vm/hotplug-block-devices-via-spec
loktev-d Apr 13, 2026
f809e17
wip
loktev-d Apr 13, 2026
0940704
wip
loktev-d Apr 13, 2026
151cea8
wip
loktev-d Apr 13, 2026
3426283
update docs
loktev-d Apr 13, 2026
ae66847
update docs
loktev-d Apr 13, 2026
e0c378d
update docs
loktev-d Apr 13, 2026
e31e2af
docs: update user guide on disk hotplug and paravirtualization
prismagod Apr 15, 2026
ee8e0e3
docs: fix user guide
prismagod Apr 15, 2026
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
8 changes: 8 additions & 0 deletions api/core/v1alpha2/block_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ type BlockDeviceSpecRef struct {
Kind BlockDeviceKind `json:"kind"`
// The name of attached resource.
Name string `json:"name"`
// Boot order of the block device. A smaller value means a higher priority.
// If the parameter is not set for any device, the boot order follows the device position in the list (starting from 1).
// If the parameter is set for at least one device, the boot order is determined by the specified values.
// +optional
// +kubebuilder:validation:Minimum=1
BootOrder *uint `json:"bootOrder,omitempty"`
}

type BlockDeviceStatusRef struct {
Expand All @@ -37,6 +43,8 @@ type BlockDeviceStatusRef struct {
Hotplugged bool `json:"hotplugged,omitempty"`
// The name of the `VirtualMachineBlockDeviceAttachment` resource that defines hot plug disk connection to the virtual machine.
VirtualMachineBlockDeviceAttachmentName string `json:"virtualMachineBlockDeviceAttachmentName,omitempty"`
// Boot order of the block device. A smaller value means a higher priority.
BootOrder *uint `json:"bootOrder,omitempty"`
}

// The BlockDeviceKind is a type of the block device. Options are:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const (
)

// VirtualMachineBlockDeviceAttachment provides a hot plug for attaching a disk to a virtual machine.
// Disks are always attached using the SCSI bus, regardless of the enableParavirtualization setting.
//
// +kubebuilder:object:root=true
// +kubebuilder:metadata:labels={heritage=deckhouse,module=virtualization}
Expand Down
18 changes: 16 additions & 2 deletions api/core/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crds/doc-ru-virtualmachineblockdeviceattachments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ spec:
schema:
openAPIV3Schema:
description: |
Ресурс обеспечивает возможность «горячего» подключения диска к виртуальной машине (ВМ).
Ресурс обеспечивает возможность «горячего» подключения диска к виртуальной машине (ВМ). Диски всегда подключаются через шину SCSI независимо от значения параметра `enableParavirtualization`.
properties:
spec:
properties:
Expand Down
7 changes: 7 additions & 0 deletions crds/doc-ru-virtualmachines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,11 @@ spec:
name:
description: |
Имя ресурса заданного типа.
bootOrder:
description: |
Порядок загрузки блочного устройства. Меньшее значение означает более высокий приоритет.
Если параметр не задан ни для одного устройства, порядок загрузки определяется позицией устройства в списке (начиная с 1).
Если параметр задан хотя бы для одного устройства, порядок загрузки определяется указанными значениями.
bootloader:
description: |
Загрузчик для ВМ:
Expand Down Expand Up @@ -409,6 +414,8 @@ spec:
Использовать шину `virtio` для подключения виртуальных устройств ВМ. Чтобы отключить `virtio` для ВМ, установите значение `False`.

> **Внимание**: Для использования режима паравиртуализации некоторые ОС требуют установки соответствующих драйверов.

> **Внимание**: При значении `false` горячее подключение блочных устройств через `.spec.blockDeviceRefs` не поддерживается. Изменения блочных устройств требуют перезагрузки ВМ. Горячее подключение через `VirtualMachineBlockDeviceAttachment` по-прежнему поддерживается.
memory:
description: |
Блок настроек оперативной памяти для виртуальной машины.
Expand Down
6 changes: 3 additions & 3 deletions crds/virtualmachineblockdeviceattachments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ spec:
name: v1alpha2
schema:
openAPIV3Schema:
description:
VirtualMachineBlockDeviceAttachment provides a hot plug for attaching
a disk to a virtual machine.
description: |-
VirtualMachineBlockDeviceAttachment provides a hot plug for attaching a disk to a virtual machine.
Disks are always attached using the SCSI bus, regardless of the enableParavirtualization setting.
properties:
apiVersion:
description: |-
Expand Down
13 changes: 13 additions & 0 deletions crds/virtualmachines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,8 @@ spec:

> **Note**: To use the paravirtualization mode, some operating systems require installing the corresponding drivers.

> **Note**: When set to `false`, hot-plugging block devices via `.spec.blockDeviceRefs` is not supported. Changes to block devices require a VM restart. Hot-plugging via `VirtualMachineBlockDeviceAttachment` is still supported.

osType:
type: string
enum:
Expand Down Expand Up @@ -958,6 +960,13 @@ spec:
type: string
description: |
Name of the attached resource.
bootOrder:
type: integer
minimum: 1
description: |
Boot order of the block device. A smaller value means a higher priority.
If the parameter is not set for any device, the boot order follows the device position in the list (starting from 1).
If the parameter is set for at least one device, the boot order is determined by the specified values.

liveMigrationPolicy:
type: string
Expand Down Expand Up @@ -1111,6 +1120,10 @@ spec:
type: string
description: |
Name of the VirtualMachineBlockDeviceAttachment resource that defines the hot-plug disk connection to the VM.
bootOrder:
type: integer
description: |
Boot order of the block device. A smaller value means a higher priority.
migrationState:
type: object
description: Details on the VM migration.
Expand Down
93 changes: 63 additions & 30 deletions docs/USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1384,10 +1384,10 @@ spec:
For most modern Linux distributions, it is recommended to use `bootloader: EFI`. For Windows, `bootloader: EFI` or `bootloader: EFIWithSecureBoot` is usually required.
{{< /alert >}}

The `enableParavirtualization` parameter controls the use of the `virtio` bus for connecting virtual devices of the VM:
The `enableParavirtualization` parameter controls the use of the `virtio` bus for connecting virtual devices to the VM. Changing the parameter value takes effect only after the VM is restarted.

- `true` (default) — uses the `virtio` bus for disks, network interfaces, and other devices, providing better performance.
- `false` — uses standard device emulation (SATA for disks, e1000e for network interfaces), which may be necessary for compatibility with older operating systems.
- `true` (default): The `virtio` bus is used for disks, network interfaces, and other devices, which provides better performance. You can change `.spec.blockDeviceRefs` on a running VM without rebooting by adding and removing devices if the disk is available on the node where the VM runs.
- `false`: Standard device emulation is used (SATA for disks, e1000e for network interfaces), which may be required for compatibility with older guest OSes without `VirtIO` drivers. Changes to `.spec.blockDeviceRefs` on a running VM (adding or removing disks and images, including ISO images) take effect after rebooting the VM. To attach and detach disks without rebooting, use the [VirtualMachineBlockDeviceAttachment](/modules/virtualization/cr.html#virtualmachineblockdeviceattachment) (`vmbda`) resource without changing the list in the VM specification.

{{< alert level="info" >}}
To use paravirtualization mode (`virtio`), some operating systems require installing the corresponding drivers. If drivers are not installed, the VM may fail to boot or devices may not work correctly.
Expand Down Expand Up @@ -2099,23 +2099,54 @@ d8 k get nodes -o custom-columns=NAME:.metadata.name,ZONE:.metadata.labels.topol

### Attaching block devices (disks and images)

Block devices can be divided into two types based on how they are connected: static and dynamic (hotplug).
You can attach disks and images to a virtual machine. They are described as block devices (BlockDevices).

Block devices and their features are shown in the table below:
Block device types and access modes:

| Block device type | Comment |
| --------------------- | --------------------------------------------------------- |
| `VirtualImage` | connected in read-only mode, or as a cdrom for iso images |
| `ClusterVirtualImage` | connected in read-only mode, or as a cdrom for iso images |
| `VirtualDisk` | connects in read/write mode |
| Block device type | Comment |
|----------------------------------------------------------------------------|-------------------------------------------------------------|
| [VirtualImage](/modules/virtualization/cr.html#virtualimage) | Connected in read-only mode, or as a CD-ROM for ISO images. |
| [ClusterVirtualImage](/modules/virtualization/cr.html#clustervirtualimage) | Connected in read-only mode, or as a CD-ROM for ISO images. |
| [VirtualDisk](/modules/virtualization/cr.html#virtualdisk) | Connected in read/write mode. |

#### Boot Block Devices
Two attachment methods are available:

Boot block devices are defined in the virtual machine specification in the `.spec.blockDeviceRefs` block as a list. The order of the devices in this list determines the sequence in which they are loaded. Thus, if a disk or image is specified first, the loader will first try to boot from it. If it fails, the system will go to the next device in the list and try to boot from it. And so on until the first boot loader is detected.
- Via the VM specification (`.spec.blockDeviceRefs`): Disks are listed in the [VirtualMachine](/modules/virtualization/cr.html#virtualmachine) configuration and boot order is set for them (by position in the list or via the `bootOrder` field). Recommended when configuring the VM manually or via GitOps, or when you need to control boot order (e.g., an ISO for OS installation).
- Via [VirtualMachineBlockDeviceAttachment](/modules/virtualization/cr.html#virtualmachineblockdeviceattachment) (`vmbda`): Disk is attached via a separate resource and does not participate in boot order. Disks are always attached using the `virtio-scsi` bus regardless of `enableParavirtualization`. Recommended for automation and when you do not have permission to edit the VM.

Changing the composition and order of devices in the `.spec.blockDeviceRefs` block is possible only with a reboot of the virtual machine.
With `enableParavirtualization: true`, both methods let you attach and detach disks on a running VM without rebooting, if the disk is available on the node where the VM runs. With `enableParavirtualization: false`, the `.spec.blockDeviceRefs` list on a running VM changes only after a reboot; you can still attach and detach disks without rebooting using [VirtualMachineBlockDeviceAttachment](/modules/virtualization/cr.html#virtualmachineblockdeviceattachment) (`vmbda`).

VirtualMachine configuration fragment with statically connected disk and project image:
{{< alert level="warning" >}}
For VMs with `enableParavirtualization: false`, the following applies:

- devices in `.spec.blockDeviceRefs` use the SATA bus; changes to the list on a running VM (adding or removing a disk, including an ISO image) take effect after rebooting the VM. Account for this when using the web interface and in automation;
- disks attached through [VirtualMachineBlockDeviceAttachment](/modules/virtualization/cr.html#virtualmachineblockdeviceattachment) use the `virtio-scsi` bus and can be attached and detached without rebooting the VM; `VirtIO` drivers for the SCSI controller must be installed in the guest OS, otherwise the disk may not appear in the OS even when the `vmbda` resource is created successfully in the cluster.
{{< /alert >}}

Hot-plugging (hotplug) is only possible if the storage is available on the cluster node where the virtual machine runs. When you create or update a VM, or create a `vmbda`, placement rules (`nodeSelector`, `affinity`, `tolerations`) for the volume, the VM, and the VM class are taken into account: there must be at least one valid combined placement. If the VM is already running on a specific node, a new disk must be available on that node.

#### Attaching via the VM specification

The list of block devices is defined in the `.spec.blockDeviceRefs` field of the [VirtualMachine](/modules/virtualization/cr.html#virtualmachine) resource.

By default, boot order follows the order of devices in the list. You can set it explicitly with the optional `bootOrder` field (smaller value means higher priority). If `bootOrder` is set for at least one device, only devices with `bootOrder` set are included in the boot sequence. Allowed values: integers ≥ 1, unique within the list. When you remove a device from the list, boot order is recalculated for the remaining devices.

Changing the order of devices in the list or their `bootOrder` values takes effect after a VM reboot. For example, you can attach an ISO image for OS installation with the desired boot priority, then remove it from the list after installation. If paravirtualization is disabled (`enableParavirtualization: false`), edits to `.spec.blockDeviceRefs` on a running VM, including for ISO images, apply after rebooting the VM.

Virtual machine configuration fragment with block devices and explicit boot order:

```yaml
spec:
blockDeviceRefs:
- kind: VirtualDisk
name: <virtual-disk-name>
bootOrder: 1
- kind: VirtualImage
name: <virtual-image-name>
bootOrder: 2
```

To attach a disk to a running virtual machine, add it to the `.spec.blockDeviceRefs` list:

```yaml
spec:
Expand All @@ -2124,8 +2155,12 @@ spec:
name: <virtual-disk-name>
- kind: VirtualImage
name: <virtual-image-name>
- kind: VirtualDisk
name: <additional-disk-name>
```

To detach a disk, remove it from the list. When `enableParavirtualization: false`, list changes on a running VM take effect after rebooting the VM.

How to work with bootable block devices in the web interface:

- Go to the "Projects" tab and select the desired project.
Expand All @@ -2139,15 +2174,13 @@ How to work with bootable block devices in the web interface:
- Resize: Change the size of the disk.
- Reorder: Change the boot order of devices.

#### Additional Block Devices
#### Attaching via VirtualMachineBlockDeviceAttachment (vmbda)

Additional block devices can be connected and disconnected from a virtual machine that is in a running state without having to reboot it.
The [VirtualMachineBlockDeviceAttachment](/modules/virtualization/cr.html#virtualmachineblockdeviceattachment) resource attaches and detaches a block device to or from a VM without changing its spec. Suited for automation and scenarios when the user does not have permission to edit the VM.

The `VirtualMachineBlockDeviceAttachment` (`vmbda`) resource is used to connect additional block devices.
Create a resource that attaches the empty disk `blank-disk` to the virtual machine `linux-vm`:

As an example, create the following share that connects an empty blank-disk disk to a linux-vm virtual machine:

```yaml
```shell
d8 k apply -f - <<EOF
apiVersion: virtualization.deckhouse.io/v1alpha2
kind: VirtualMachineBlockDeviceAttachment
Expand All @@ -2161,24 +2194,24 @@ spec:
EOF
```

After creation, `VirtualMachineBlockDeviceAttachment` can be in the following states (phases):
After creation, [VirtualMachineBlockDeviceAttachment](/modules/virtualization/cr.html#virtualmachineblockdeviceattachment) can be in the following states:

- `Pending` - waiting for all dependent resources to be ready.
- `InProgress` - the process of device connection is in progress.
- `Attached` - the device is connected.

Diagnosing problems with a resource is done by analyzing the information in the `.status.conditions` block
Diagnosing problems with the resource is done by analyzing the information in the `.status.conditions` block.

Check the state of your resource::
Check the state of your resource:

```bash
d8 k get vmbda attach-blank-disk
```

Example output:

```txt
NAME PHASE VIRTUAL MACHINE NAME AGE
```console
NAME PHASE VIRTUAL MACHINE NAME AGE
attach-blank-disk Attached linux-vm 3m7s
```

Expand All @@ -2190,14 +2223,14 @@ d8 v ssh cloud@linux-vm --local-ssh --command "lsblk"

Example output:

```txt
```console
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 10G 0 disk <--- statically mounted linux-vm-root disk
sda 8:0 0 10G 0 disk <--- statically attached linux-vm-root disk
|-sda1 8:1 0 9.9G 0 part /
|-sda14 8:14 0 4M 0 part
`-sda15 8:15 0 106M 0 part /boot/efi
sdb 8:16 0 1M 0 disk <--- cloudinit
sdc 8:32 0 95.9M 0 disk <--- dynamically mounted disk blank-disk
sdc 8:32 0 95.9M 0 disk <--- dynamically attached disk blank-disk
```

To detach the disk from the virtual machine, delete the previously created resource:
Expand All @@ -2206,9 +2239,9 @@ To detach the disk from the virtual machine, delete the previously created resou
d8 k delete vmbda attach-blank-disk
```

Attaching images is done by analogy. To do this, specify `VirtualImage` or `ClusterVirtualImage` and the image name as `kind`:
Attaching images is done by analogy: set the `kind` field to VirtualImage or ClusterVirtualImage and the image name.

```yaml
```bash
d8 k apply -f - <<EOF
apiVersion: virtualization.deckhouse.io/v1alpha2
kind: VirtualMachineBlockDeviceAttachment
Expand Down
Loading
Loading