Skip to content

Commit

Permalink
add disk parameters serial and wwn (#767)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergelogvinov committed May 24, 2023
1 parent f2ee893 commit 811f017
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/resources/vm_qemu.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ See the [docs about disks](https://pve.proxmox.com/pve-docs/chapter-qm.html#qm_h
| `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` | `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. |
Expand All @@ -232,6 +232,8 @@ See the [docs about disks](https://pve.proxmox.com/pve-docs/chapter-qm.html#qm_h
| `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. |
Expand Down
18 changes: 18 additions & 0 deletions proxmox/resource_vm_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,18 @@ func resourceVmQemu() *schema.Resource {
Optional: true,
Default: 0,
},
"serial": {
Type: schema.TypeString,
Optional: true,
Default: "",
ValidateFunc: validation.StringLenBetween(0, 20),
},
"wwn": {
Type: schema.TypeString,
Optional: true,
Default: "",
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^0x[A-Fa-f0-9]+$`), "The drive’s worldwide name, encoded as 16 bytes hex string, prefixed by 0x."),
},
// Misc
"file": {
Type: schema.TypeString,
Expand Down Expand Up @@ -1448,6 +1460,12 @@ func resourceVmQemuUpdate(ctx context.Context, d *schema.ResourceData, meta inte
if oldValues[i].(map[string]interface{})["size"] != newValues[i].(map[string]interface{})["size"] {
d.Set("reboot_required", true)
}
if oldValues[i].(map[string]interface{})["serial"] != newValues[i].(map[string]interface{})["serial"] {
d.Set("reboot_required", true)
}
if oldValues[i].(map[string]interface{})["wwn"] != newValues[i].(map[string]interface{})["wwn"] {
d.Set("reboot_required", true)
}
// these paramater changes only require reboot if disk hotplug is disabled
if !strings.Contains(d.Get("hotplug").(string), "disk") {
if oldValues[i].(map[string]interface{})["type"] != newValues[i].(map[string]interface{})["type"] {
Expand Down

0 comments on commit 811f017

Please sign in to comment.