Skip to content

Commit

Permalink
Merge pull request Telmate#1162 from Tinyblargon/Telmate#1029
Browse files Browse the repository at this point in the history
Feat: Full Qemu PCI support
  • Loading branch information
Tinyblargon authored Nov 21, 2024
2 parents 5d693ff + db70dd9 commit e2ed468
Show file tree
Hide file tree
Showing 7 changed files with 809 additions and 93 deletions.
75 changes: 75 additions & 0 deletions docs/resources/vm_qemu.md
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,81 @@ See the [docs about EFI disks](https://pve.proxmox.com/pve-docs/chapter-qm.html#
| `efitype` | `str` | `"4m"` | The type of efi disk device to add. Options: `2m`, `4m` |
| `storage` | `str` | | **Required** The name of the storage pool on which to store the disk. |

### PCI Block

The `pci` block is used to configure PCI devices. It may be specified multiple times.
Don't need it in a module? Use the [PCIs Block](#pcis-block) instead.

| Argument | Type | Default Value | Description |
| :-------------- | :----: | :-----------: | :---------- |
| `id` | `str` | | **Required** The id of the PCI device. Range `0` - `15`. |
| `mapping_id` | `str` | | **Required\*** The id of the mapping. Conflicts with `raw_id`.|
| `raw_id` | `str` | | **Required\*** The id of the raw device. Conflicts with `mapping_id`.|
| `pcie` | `bool` | `false` | Whether this device is a `PCIe` device. |
| `primary_gpu` | `bool` | `false` | Whether this PCI device is the primary GPU. |
| `rombar` | `bool` | `true` | Whether to enable the ROM-BAR. |
| `device_id` | `str` | | The device id of the PCI device. |
| `vendor_id` | `str` | | The vendor id of the PCI device. |
| `sub_device_id` | `str` | | The sub device id of the PCI device. |
| `sub_vendor_id` | `str` | | The sub vendor id of the PCI device. |

\* Either `mapping_id` or `raw_id` is required.

### PCIs Block

The `pcis` block is used to configure PCI devices.
There are two types of PCI devices `mapping`, and `raw`. Each of these types has their own block with their own arguments.

These types share the following arguments, with minor differences:

| Argument | Type | Default Value | PCI types |Description |
| :-------------- | :----: | :-----------: | :--------------: | :--------- |
| `mapping_id` | `str` | | `mapping` | **Required** The id of the mapping. |
| `raw_id` | `str` | | `raw` | **Required** The id of the raw device. |
| `pcie` | `bool` | `false` | `mapping`, `raw` | Whether this device is a `PCIe` device. |
| `primary_gpu` | `bool` | `false` | `mapping`, `raw` | Whether this PCI device is the primary GPU. |
| `rombar` | `bool` | `true` | `mapping`, `raw` | Whether to enable the ROM-BAR. |
| `device_id` | `str` | | `mapping`, `raw` | The device id of the PCI device. |
| `vendor_id` | `str` | | `mapping`, `raw` | The vendor id of the PCI device. |
| `sub_device_id` | `str` | | `mapping`, `raw` | The sub device id of the PCI device. |
| `sub_vendor_id` | `str` | | `mapping`, `raw` | The sub vendor id of the PCI device. |

The range of pci devices is from `pci0` to `pci15`.

Example:

```hcl
resource "proxmox_vm_qemu" "resource-name" {
// ...
pcis {
pci0 {
mapping {
mapping_id = "mapping-id"
pcie = true
primary_gpu = true
rombar = true
device_id = "device-id"
vendor_id = "vendor-id"
sub_device_id = "sub-device-id"
sub_vendor_id = "sub-vendor-id"
}
}
pci15 {
raw {
raw_id = "raw-id"
pcie = true
primary_gpu = true
rombar = true
device_id = "device-id"
vendor_id = "vendor-id"
sub_device_id = "sub-device-id"
sub_vendor_id = "sub-vendor-id"
}
}
}
}
```

### Serial Block

Create a serial device inside the VM (up to a maximum of 4 can be specified), and either pass through a host serial device (i.e. /dev/ttyS0), or create a unix socket on the host side. The order in which `serial` blocks are declared does not matter.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.21
toolchain go1.21.0

require (
github.com/Telmate/proxmox-api-go v0.0.0-20241109120634-0146e30e530a
github.com/Telmate/proxmox-api-go v0.0.0-20241121215203-222002bcb5bc
github.com/google/uuid v1.6.0
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
github.com/ProtonMail/go-crypto v1.1.0-alpha.2-proton h1:HKz85FwoXx86kVtTvFke7rgHvq/HoloSUvW5semjFWs=
github.com/ProtonMail/go-crypto v1.1.0-alpha.2-proton/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
github.com/Telmate/proxmox-api-go v0.0.0-20241109120634-0146e30e530a h1:HLnjs22IoYtL3QBkOXiABuQhfg6WDJGbENV6+lzPgtQ=
github.com/Telmate/proxmox-api-go v0.0.0-20241109120634-0146e30e530a/go.mod h1:Gu6n6vEn1hlyFUkjrvU+X1fdgaSXLoM9HKYYJqy1fsY=
github.com/Telmate/proxmox-api-go v0.0.0-20241121215203-222002bcb5bc h1:gKm4H2rehb9iTWh4OW/Yt/SNJwoTLHTam+Trjkz2HHY=
github.com/Telmate/proxmox-api-go v0.0.0-20241121215203-222002bcb5bc/go.mod h1:Gu6n6vEn1hlyFUkjrvU+X1fdgaSXLoM9HKYYJqy1fsY=
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
Expand Down
Loading

0 comments on commit e2ed468

Please sign in to comment.