Skip to content

Commit

Permalink
feat: Add 'import-from' parameter to qemu (Telmate#606)
Browse files Browse the repository at this point in the history
* fix(build): Detect KERNEL on MacOS

* feat: Add 'import_disk' parameter to qemu

---------

Co-authored-by: mleone87 <[email protected]>
  • Loading branch information
2 people authored and spettinichi committed Jan 26, 2024
1 parent f446837 commit 4581e6c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 36 deletions.
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,18 @@ CURRENT_TAG_MICRO := "v$(CURRENT_VERSION_MICRO)"
CURRENT_TAG_MINOR := "v$(CURRENT_VERSION_MINOR)"
CURRENT_TAG_MAJOR := "v$(CURRENT_VERSION_MAJOR)"

uname_s := $(shell uname -s)
uname_m := $(shell uname -m)
l_uname_s = $(shell echo $(uname_s) | tr A-Z a-z)
l_uname_m = $(shell echo $(uname_m) | tr A-Z a-z)
# Determine KERNEL and ARCH
UNAME_S=$(shell uname -s)
UNAME_M=$(shell uname -m)
ifeq ($(UNAME_S),Linux)
KERNEL=linux
else ifeq ($(UNAME_S),Darwin)
KERNEL=darwin
endif

ifeq ($(UNAME_M),x86_64)
ARCH=amd64
endif

KERNEL=$(l_uname_s)
ARCH=$(l_uname_m)
Expand Down
53 changes: 21 additions & 32 deletions docs/resources/vm_qemu.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,38 +213,27 @@ See the [docs about disks](https://pve.proxmox.com/pve-docs/chapter-qm.html#qm_h

| 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. |
| `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` | `int` | `0` | 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. |
| `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. |
| `import_from` | `str` | | Import disk image. Value is a path local to the node, for example `/disk/image.img`. |
| `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. |

### Serial Block

Expand Down
5 changes: 5 additions & 0 deletions proxmox/resource_vm_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,11 @@ func resourceVmQemu() *schema.Resource {
Optional: true,
Default: 0,
},
// Import disk
"import_from": {
Type: schema.TypeString,
Optional: true,
},
"serial": {
Type: schema.TypeString,
Optional: true,
Expand Down

0 comments on commit 4581e6c

Please sign in to comment.