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

Add support for PCI device pass through #205

Merged
merged 21 commits into from
Jul 18, 2023

Conversation

romantomjak
Copy link
Contributor

This PR introduces the pci_devices block to allow mapping host's PCI devices into the guest VM. This is often used to passthrough a graphics card or a network adapter. Devices that are mapped into a guest VM are no longer available on the host.

@romantomjak romantomjak requested a review from a team as a code owner July 10, 2023 21:16
docs/builders/iso.mdx Outdated Show resolved Hide resolved
Copy link
Contributor

@lbajolet-hashicorp lbajolet-hashicorp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @romantomjak,

Thanks for this PR! I've taken a look at the options you're introducing and responded to your comments. I also added a few comments and suggestions that should be fixed before we can merge, but overall this looks good to me.

I'll let you address those comments, and I'll circle back later.
As always please let me know if you need any kind of help!

builder/proxmox/common/step_start_vm.go Outdated Show resolved Hide resolved
docs/builders/iso.mdx Outdated Show resolved Hide resolved
builder/proxmox/common/config.go Outdated Show resolved Hide resolved
builder/proxmox/common/config_test.go Show resolved Hide resolved
builder/proxmox/common/config.go Outdated Show resolved Hide resolved
docs/builders/clone.mdx Outdated Show resolved Hide resolved
docs/builders/clone.mdx Outdated Show resolved Hide resolved
@romantomjak romantomjak reopened this Jul 15, 2023
@@ -441,3 +442,59 @@ func TestStartVMWithForce(t *testing.T) {
})
}
}

func TestStartVM_AssertInitialQuemuConfig(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this test to make sure the value is actually inverted when the config is assembled

@@ -365,18 +368,30 @@ or responding to pattern `/dev/.+`. Example:

- `machine` - (string) - Set the machine type. Supported values are 'pc' or 'q35'.

#### VirtIO RNG device
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

De-dented header size. The config reference section has h2 headers, so I think this must be h3.

Copy link
Contributor

@lbajolet-hashicorp lbajolet-hashicorp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @romantomjak,

Thanks for the quick reroll, this looks good to me already :)

I left a couple more comments on the reworked PR, but as I said above, this looks really good, so I don't think there's a lot left to change here.

That being said, I'll let you have a look at what I point out/suggest, and let me know which deserve some attention.

I'll circle back later when you've had time to address those.

Thanks again for this PR!

builder/proxmox/common/config.go Outdated Show resolved Hide resolved
docs/builders/iso.mdx Show resolved Hide resolved
builder/proxmox/common/config_test.go Show resolved Hide resolved
Copy link
Contributor

@lbajolet-hashicorp lbajolet-hashicorp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @romantomjak,

Thanks again for the reroll! I left a couple of comments regarding the docs (especially the HCL example), and regarding usage of setDeviceParamIfDefined, especially after the discussion on #207.
I implemented changes locally, but I can't push them on your branch unfortunately because of permission issues. Let me know if you want me to share patches, otherwise please feel free to address those and we can circle back on it later.

In the meantime, I'm pre-approving this PR, we are very close to completion here I think, good job and thanks again for this enhancement!

builder/proxmox/common/config.go Outdated Show resolved Hide resolved
builder/proxmox/common/step_start_vm.go Outdated Show resolved Hide resolved
builder/proxmox/common/config.go Outdated Show resolved Hide resolved
//
// ```hcl
// pci_devices {
// host = "0000:0d:00.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In HCL2 generally, the contents of a block are intented (with 2 spaces) relative to their immediate parent, I suggest we do the same here, is this OK?

Copy link
Contributor Author

@romantomjak romantomjak Jul 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I can't get my editor to do that. If I add two spaces it just reindents everything extremely weirdly like the rng0. I tried changing that via vim, but as soon as I save the file in vscode it just reindents it again 🙈

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's OK! I can do this change in a subsequent PR either way, so I think I'll merge your PR if everything checks out, and fix this later :)

Copy link
Contributor

@lbajolet-hashicorp lbajolet-hashicorp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the last changes, LGTM!

I'll merge this as soon as tests are green. Many thanks once more @romantomjak!

//
// ```hcl
// pci_devices {
// host = "0000:0d:00.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's OK! I can do this change in a subsequent PR either way, so I think I'll merge your PR if everything checks out, and fix this later :)

builder/proxmox/common/step_start_vm.go Outdated Show resolved Hide resolved
@lbajolet-hashicorp lbajolet-hashicorp merged commit 2965501 into hashicorp:main Jul 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants