Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul qemu disks #794

Closed
258 changes: 209 additions & 49 deletions docs/resources/vm_qemu.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,81 +164,240 @@ details.
| `queues` | `int` | `1` | Number of packet queues to be used on the device. Requires `virtio` model to have an effect. |
| `link_down` | `bool` | `false` | Whether this interface should be disconnected (like pulling the plug). |

### Disk Block
### Disks Block

The `disk` block is used to configure the disk devices. It may be specified multiple times. The order in which the
blocks are specified and the disk device type determines the ID for each disk device. Take the following for example:
The `disks` block is used to configure the disk devices. It may be specified once. There are four types of disk `ide`,`sata`,`scsi` and `virtio`. Configuration for these sub types can be found in their respective chapters:

* `cdrom`: [Disks.x.Cdrom Block](#disksxcdrom-block).
* `disk`: [Disks.x.Disk Block](#disksxdisk-block).
* `passthrough`: [Disks.x.Passthrough Block](#disksxpassthrough-block).

```hcl
resource "proxmox_vm_qemu" "resource-name" {
//<arguments omitted for brevity...>

disk {
// This disk will become scsi0
type = "scsi"
disks {
ide {
//<arguments omitted for brevity...>
}
sata {
//<arguments omitted for brevity...>
}
scsi {
//<arguments omitted for brevity...>
}
virtio {
//<arguments omitted for brevity...>
}
}
}
```

### Disks.Ide Block

The `disks.ide` block is used to configure disks of type ide. It may only be specified once. It has the options `ide0` through `ide1`. Each disk can have only one of the following mutually exclusive sub types `cdrom`, `disk`, `passthrough`. Configuration for these sub types can be found in their respective chapters:

* `cdrom`: [Disks.x.Cdrom Block](#disksxcdrom-block).
* `disk`: [Disks.x.Disk Block](#disksxdisk-block).
* `passthrough`: [Disks.x.Passthrough Block](#disksxpassthrough-block).

```hcl
resource "proxmox_vm_qemu" "resource-name" {
//<arguments omitted for brevity...>

disks {
ide {
ide0 {
disk {
//<arguments omitted for brevity...>
}
}
ide1 {
passthrough {
//<arguments omitted for brevity...>
}
}
}
//<arguments omitted for brevity...>
}
}
```

### Disks.Sata Block

disk {
// This disk will become ide0
type = "ide"
The `disks.sata` block is used to configure disks of type sata. It may only be specified once. It has the options `sata0` through `sata5`. Each disk can have only one of the following mutually exclusive sub types `cdrom`, `disk`, `passthrough`. Configuration for these sub types can be found in their respective chapters:

* `cdrom`: [Disks.x.Cdrom Block](#disksxcdrom-block).
* `disk`: [Disks.x.Disk Block](#disksxdisk-block).
* `passthrough`: [Disks.x.Passthrough Block](#disksxpassthrough-block).

```hcl
resource "proxmox_vm_qemu" "resource-name" {
//<arguments omitted for brevity...>

disks {
sata {
sata0 {
cdrom {
//<arguments omitted for brevity...>
}
}
sata1 {
disk {
//<arguments omitted for brevity...>
}
}
sata2 {
passthrough {
//<arguments omitted for brevity...>
}
}
//<arguments omitted for brevity...>
}
//<arguments omitted for brevity...>
}
}
```

### Disks.Scsi Block

The `disks.scsi` block is used to configure disks of type scsi. It may only be specified once. It has the options `scsi0` through `scsi30`. Each disk can have only one of the following mutually exclusive sub types `cdrom`, `disk`, `passthrough`. Configuration for these sub types can be found in their respective chapters:

disk {
// This disk will become scsi1
type = "scsi"
* `cdrom`: [Disks.x.Cdrom Block](#disksxcdrom-block).
* `disk`: [Disks.x.Disk Block](#disksxdisk-block).
* `passthrough`: [Disks.x.Passthrough Block](#disksxpassthrough-block).

```hcl
resource "proxmox_vm_qemu" "resource-name" {
//<arguments omitted for brevity...>

disks {
scsi {
scsi0 {
cdrom {
//<arguments omitted for brevity...>
}
}
scsi1 {
disk {
//<arguments omitted for brevity...>
}
}
scsi2 {
passthrough {
//<arguments omitted for brevity...>
}
}
//<arguments omitted for brevity...>
}
//<arguments omitted for brevity...>
}
}
```

### Disks.Virtio Block

The `disks.scsi` block is used to configure disks of type scsi. It may only be specified once. It has the options `virtio0` through `virtio15`. Each disk can have only one of the following mutually exclusive sub types `cdrom`, `disk`, `passthrough`. Configuration for these sub types can be found in their respective chapters:

disk {
// This disk will become sata0
type = "sata"
* `cdrom`: [Disks.x.Cdrom Block](#disksxcdrom-block).
* `disk`: [Disks.x.Disk Block](#disksxdisk-block).
* `passthrough`: [Disks.x.Passthrough Block](#disksxpassthrough-block).

```hcl
resource "proxmox_vm_qemu" "resource-name" {
//<arguments omitted for brevity...>

disks {
virtio {
virtio0 {
cdrom {
//<arguments omitted for brevity...>
}
}
virtio1 {
disk {
//<arguments omitted for brevity...>
}
}
virtio2 {
passthrough {
//<arguments omitted for brevity...>
}
}
//<arguments omitted for brevity...>
}
//<arguments omitted for brevity...>
}
}
```

### Disks.x.Cdrom Block

| Argument | Type | Default Value | Description |
|:------------|:-----|:-------------:|:------------|
|`iso` |`str` | |The name of the ISO image to mount to the VM in the format: [storage pool]:iso/[name of iso file]. Note that `iso` is mutually exclusive with `passthrough`.|
|`passthrough`|`bool`|`false` |Wether the physical cdrom drive should be passed through.|

When `iso` and `passthrough` are omitted an empty cdrom drive will be created.

### Disks.x.Disk Block

See the [docs about disks](https://pve.proxmox.com/pve-docs/chapter-qm.html#qm_hard_disk) for more details.

| Argument | Type | Default Value | Disk Types | Description |
|:---------------------|:-----:|:-------------:|:-------------------:|:------------|
|`asyncio` |`str` | |`all` |The drive's asyncio setting. Options: `io_uring`, `native`, `threads`|
|`backup` |`bool` |`true` |`all` |Whether the drive should be included when making backups.|
|`cache` |`str` | |`all` |The drive’s cache mode. Options: `directsync`, `none`, `unsafe`, `writeback`, `writethrough`.|
|`discard` |`bool` |`false` |`all` |Controls whether to pass discard/trim requests to the underlying storage. Only effective when the underlying storage supports thin provisioning. There are other caveats too, see the [docs about disks](https://pve.proxmox.com/pve-docs/chapter-qm.html#qm_hard_disk) for more info.|
|`emulatessd` |`bool` |`false` |`ide`, `sata`, `scsi`|Whether to expose this drive as an SSD, rather than a rotational hard disk.|
|`format` |`str` |`raw` |`all` |The drive’s backing file’s data format.|
|`id` |`int` | |`all` |**Computed** Unique id of the disk.|
|`iops_r_burst` |`int` |`0` |`all` |Maximum number of iops while reading in short bursts. `0` means unlimited.|
|`iops_r_burst_length` |`int` |`0` |`all` |Length of the read burst duration in seconds. `0` means the default duration dictated by proxmox.|
|`iops_r_concurrent` |`int` |`0` |`all` |Maximum number of iops while reading concurrently. `0` means unlimited.|
|`iops_wr_burst` |`int` |`0` |`all` |Maximum number of iops while writing in short bursts. `0` means unlimited.|
|`iops_wr_burst_length`|`int` |`0` |`all` |Length of the write burst duration in seconds. `0` means the default duration dictated by proxmox.|
|`iops_wr_concurrent` |`int` |`0` |`all` |Maximum number of iops while writing concurrently. `0` means unlimited.|
|`iothread` |`bool` |`false` |`scsi`, `virtio` |Whether to use iothreads for this drive. Only effective when the the emulated controller type (`scsihw` top level block argument) is `virtio-scsi-single`.|
|`linked_disk_id` |`int` | |`all` |**Computed** The `vmid` of the linked vm this disk was cloned from.|
|`mbps_r_burst` |`float`|`0.0` |`all` |Maximum read speed in megabytes per second. `0` means unlimited.|
|`mbps_r_concurrent` |`float`|`0.0` |`all` |Maximum read speed in megabytes per second. `0` means unlimited.|
|`mbps_wr_burst` |`float`|`0.0` |`all` |Maximum write speed in megabytes per second. `0` means unlimited.|
|`mbps_wr_concurrent` |`float`|`0.0` |`all` |Maximum throttled write pool in megabytes per second. `0` means unlimited.|
|`readonly` |`bool` |`false` |`scsi`, `virtio` |Whether the drive should be readonly.|
|`replicate` |`bool` |`false` |`all` |Whether the drive should considered for replication jobs.|
|`serial` |`str` | |`all` |The serial number of the disk.|
|`size` |`int` | |`all` |**Required** The size of the created disk in Gigabytes.|
|`storage` |`str` | |`all` |**Required** The name of the storage pool on which to store the disk.|

### Disks.x.Passthrough Block

See the [docs about disks](https://pve.proxmox.com/pve-docs/chapter-qm.html#qm_hard_disk) for more details.

| Argument | Type | Default Value | Description |
|----------------|-------|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `type` | `str` | | **Required** The type of disk device to add. Options: `ide`, `sata`, `scsi`, `virtio`. |
| `storage` | `str` | | **Required** The name of the storage pool on which to store the disk. |
| `size` | `str` | | **Required** The size of the created disk, format must match the regex `\d+[GMK]`, where G, M, and K represent Gigabytes, Megabytes, and Kilobytes respectively. |
| `format` | `str` | `"raw"` | The drive’s backing file’s data format. |
| `cache` | `str` | `"none"` | The drive’s cache mode. Options: `directsync`, `none`, `unsafe`, `writeback`, `writethrough` |
| `backup` | `bool` | `true` | Whether the drive should be included when making backups. |
| `iothread` | `int` | `0` | Whether to use iothreads for this drive. Only effective with a disk of type `virtio`, or `scsi` when the the emulated controller type (`scsihw` top level block argument) is `virtio-scsi-single`. |
| `replicate` | `int` | `0` | Whether the drive should considered for replication jobs. |
| `ssd` | `int` | `0` | Whether to expose this drive as an SSD, rather than a rotational hard disk. |
| `discard` | `str` | | Controls whether to pass discard/trim requests to the underlying storage. Only effective when the underlying storage supports thin provisioning. There are other caveats too, see the [docs about disks](https://pve.proxmox.com/pve-docs/chapter-qm.html#qm_hard_disk) for more info. |
| `aio` | `str` | | AIO type to use. Options: `io_uring`, `native`, `threads`. |
| `mbps` | `int` | `0` | Maximum r/w speed in megabytes per second. `0` means unlimited.
| `mbps_rd` | `int` | `0` | Maximum read speed in megabytes per second. `0` means unlimited. |
| `mbps_rd_max` | `int` | `0` | Maximum read speed in megabytes per second. `0` means unlimited. |
| `mbps_wr` | `int` | `0` | Maximum write speed in megabytes per second. `0` means unlimited. |
| `mbps_wr_max` | `int` | `0` | Maximum throttled write pool in megabytes per second. `0` means unlimited. |
| `iops` | `int` | `0` | Maximum r/w I/O in operations per second. `0` means unlimited. |
| `iops_max` | `int` | `0` | Maximum unthrottled r/w I/O pool in operations per second. `0` means unlimited. |
| `iops_max_length` | `int` | `0` | Maximum length of I/O bursts in seconds. `0` means unlimited. |
| `iops_rd` | `int` | `0` | Maximum read I/O in operations per second. `0` means unlimited. |
| `iops_rd_max` | `int` | `0` | Maximum unthrottled read I/O pool in operations per second. `0` means unlimited. |
| `iops_rd_max_length` | `int` | `0` | Maximum length of read I/O bursts in seconds. `0` means unlimited. |
| `iops_wr` | `int` | `0` | Maximum write I/O in operations per second. `0` means unlimited. |
| `iops_wr_max` | `int` | `0` | Maximum unthrottled write I/O pool in operations per second. `0` means unlimited. |
| `iops_wr_max_length` | `int` | `0` | Maximum length of write I/O bursts in seconds. `0` means unlimited. |
| `serial` | `str` | | The drive’s reported serial number, url-encoded, up to 20 bytes long. |
| `wwn` | `str` | | The drive’s worldwide name, encoded as 16 bytes hex string, prefixed by 0x. |
| `file` | `str` | | The filename portion of the path to the drive’s backing volume. You shouldn't need to specify this, use the `storage` parameter instead. |
| `media` | `str` | `"disk"` | The drive’s media type. Options: `cdrom`, `disk`. |
| `volume` | `str` | | The full path to the drive’s backing volume including the storage pool name. You shouldn't need to specify this, use the `storage` parameter instead. |
| `slot` | `int` | | _(not sure what this is for, seems to be deprecated, do not use)_. |
| `storage_type` | `str` | | The type of pool that `storage` is backed by. You shouldn't need to specify this, use the `storage` parameter instead. |
| Argument | Type | Default Value | Disk Types | Description |
|:---------------------|:-----:|:-------------:|:-------------------:|:------------|
|`asyncio` |`str` | |`all` |The drive's asyncio setting. Options: `io_uring`, `native`, `threads`|
|`backup` |`bool` |`true` |`all` |Whether the drive should be included when making backups.|
|`cache` |`str` | |`all` |The drive’s cache mode. Options: `directsync`, `none`, `unsafe`, `writeback`, `writethrough`.|
|`discard` |`bool` |`false` |`all` |Controls whether to pass discard/trim requests to the underlying storage. Only effective when the underlying storage supports thin provisioning. There are other caveats too, see the [docs about disks](https://pve.proxmox.com/pve-docs/chapter-qm.html#qm_hard_disk) for more info.|
|`emulatessd` |`bool` |`false` |`ide`, `sata`, `scsi`|Whether to expose this drive as an SSD, rather than a rotational hard disk.|
|`file` |`str` | |`all` |**Required** The full unix file path to the disk.|
|`iops_r_burst` |`int` |`0` |`all` |Maximum number of iops while reading in short bursts. `0` means unlimited.|
|`iops_r_burst_length` |`int` |`0` |`all` |Length of the read burst duration in seconds. `0` means the default duration dictated by proxmox.|
|`iops_r_concurrent` |`int` |`0` |`all` |Maximum number of iops while reading concurrently. `0` means unlimited.|
|`iops_wr_burst` |`int` |`0` |`all` |Maximum number of iops while writing in short bursts. `0` means unlimited.|
|`iops_wr_burst_length`|`int` |`0` |`all` |Length of the write burst duration in seconds. `0` means the default duration dictated by proxmox.|
|`iops_wr_concurrent` |`int` |`0` |`all` |Maximum number of iops while writing concurrently. `0` means unlimited.|
|`iothread` |`bool` |`false` |`scsi`, `virtio` |Whether to use iothreads for this drive. Only effective when the the emulated controller type (`scsihw` top level block argument) is `virtio-scsi-single`.|
|`mbps_r_burst` |`float`|`0.0` |`all` |Maximum read speed in megabytes per second. `0` means unlimited.|
|`mbps_r_concurrent` |`float`|`0.0` |`all` |Maximum read speed in megabytes per second. `0` means unlimited.|
|`mbps_wr_burst` |`float`|`0.0` |`all` |Maximum write speed in megabytes per second. `0` means unlimited.|
|`mbps_wr_concurrent` |`float`|`0.0` |`all` |Maximum throttled write pool in megabytes per second. `0` means unlimited.|
|`readonly` |`bool` |`false` |`scsi`, `virtio` |Whether the drive should be readonly.|
|`replicate` |`bool` |`false` |`all` |Whether the drive should considered for replication jobs.|
|`serial` |`str` | |`all` |The serial number of the disk.|
|`size` |`int` | |`all` |**Computed** Size of the disk.|

### Serial Block

Expand Down Expand Up @@ -298,6 +457,7 @@ In addition to the arguments above, the following attributes can be referenced f

The following arguments are deprecated, and should no longer be used.

- `disk` - (Optional; use disks instead)
- `disk_gb` - (Optional; use disk.size instead)
- `storage` - (Optional; use disk.storage instead)
- `storage_type` - (Optional; use disk.type instead)
Expand Down
Loading