Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

virtcontainers: POC support for coldplugging PCI devices #705

Closed
wants to merge 1 commit into from

Conversation

eguzman3
Copy link
Contributor

@eguzman3 eguzman3 commented Sep 6, 2018

Adds support for coldplugging PCI devices at VM boot rather than hotplugging.
Adds two cli config options
pci_coldplug_groups defines a list of IOMMU groups that should be coldplugged when supplied via --device=/dev/vfio/XX
pci_coldplug_device_opts defines a list of per-device vfio-pci options to be passed on the qemu cli when coldplugging these devices

Fixes: #704

Signed-off-by: Edward Guzman [email protected]

Adds support for coldplugging PCI devices at VM boot rather than hotplugging.

Fixes: kata-containers#704

Signed-off-by: Edward Guzman <[email protected]>
@katacontainersbot
Copy link
Contributor

PSS Measurement:
Qemu: 167170 KB
Proxy: 4033 KB
Shim: 8717 KB

Memory inside container:
Total Memory: 2043460 KB
Free Memory: 2003316 KB

@opendev-zuul
Copy link

opendev-zuul bot commented Sep 6, 2018

Build failed (third-party-check pipeline) integration testing with
OpenStack. For information on how to proceed, see
http://docs.openstack.org/infra/manual/developers.html#automated-testing

@caoruidong
Copy link
Member

Thank you for raising this! But if you want to modify govmm codes, you should also raise a PR in https://github.com/intel/govmm. When that PR gets merged, change this PR to 2 commits. The first one uses dep to import vendor changes, the second one is changes in this repo.

Copy link
Contributor

@jodh-intel jodh-intel left a comment

Choose a reason for hiding this comment

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

Thanks for raising @eguzman3! I appreciate this is a POC but have a few questions.

Ideally, we'd also have some unit tests to supplement the code changes and as noted the vendor changes would need to be made upstream first.

}

// getBDF returns the BDF of pci device
// Expected input strng format is [<domain>]:[<bus>][<slot>].[<func>] eg. 0000:02:10.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't that be (missing colon after [<bus>]?):

// Expected input strng format is [<domain>]:[<bus>]:[<slot>].[<func>] eg. 0000:02:10.0

}

func checkForPCIColdPlug(device spec.LinuxDevice, hConfig *vc.HypervisorConfig) bool {
if !strings.Contains(device.Path, "/dev/vfio/") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be strings.HasPrefix()?

}

pathTokens := strings.Split(device.Path, "/")
if len(pathTokens) != 4 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you add a comment documenting the expected format so this token value is clearer?

# A list of parameters to pass to the vfio-pci driver when coldplugging
# devices. This is a semicolon-separated list of device option lists where
# a device option list is comma-separated list where the first entry is
# the device's BDF. All devices that will be coldplugged should be added
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm finding this a little difficult to read. Could it be changed to something like this without losing the meaning?:

A semi-colon separated list of parameters to pass to the vfio-pci driver when coldplugging
devices. Each list element is itself a comma separated list of options which must start with the BDF of the device to be cold-plugged and optionally followed by one or more device-specific options.


// PCIColdplugDeviceOpts is used to indicate what paramaters
// should be passed to vfio-pci for coldplugged devices
PCIColdplugDeviceOpts []string
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not really clear why PCIColdplugDeviceOpts is separate from PCIColdplugDeviceOpts. How about something like:

type PCIDevice {
    Name      string
    Options []string
}

type HypervisorConfig struct {
        :

    PCIColdplugDevices []PCIDevice
}

Splitting the bdf and its options apart would also solve the issue in checkForPCIColdPlug() I think.

tokens := strings.Split(deviceSysStr, ":")

if len(tokens) != 3 {
return "", fmt.Errorf("Incorrect number of tokens found while parsing bdf for device : %s", deviceSysStr)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd consider making the 3 a const and adding that to the returned error so we log 3 vs. len(tokens).


for _, bdf := range bdfs {
for _, opts := range hConfig.PCIColdplugDeviceOpts {
if strings.Contains(opts, bdf) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What if a devices options contained a reference to another BDF? If that's possible, this won't be reliable.

@WeiZhang555
Copy link
Member

Hi @eguzman3 , thanks for your PR! Can you address comment #704 (comment) ? We need a clear understanding about the scenario.

@raravena80
Copy link
Member

Hi, @eguzman3 any updates on this? thx!

@jodh-intel
Copy link
Contributor

Ping @eguzman3.

@flx42
Copy link
Contributor

flx42 commented Oct 2, 2018

I will try to run some tests on a system we have that has 16 GPUs with a large BAR size:
https://www.nvidia.com/en-us/data-center/dgx-2/
But I'm likely to encounter other issues unrelated to coldplug/hotplug, so if it's not conclusive we will have to table this PR for now.

@caoruidong
Copy link
Member

@flx42 Do you solve other problems?

@raravena80
Copy link
Member

@eguzman3 any updates? (from your weekly kata herder)

@flx42
Copy link
Contributor

flx42 commented Dec 18, 2018

Nope, no progress on this side. Thanks for all the feedback in #704, I think we'll reopen if/when needed.

@ghost
Copy link

ghost commented Dec 18, 2018

/do-not-merge
/close

@jodh-intel
Copy link
Contributor

Ok - closing. Let us know if you want this re-opened...

@jodh-intel jodh-intel closed this Dec 19, 2018
egernst pushed a commit to egernst/runtime that referenced this pull request Feb 9, 2021
New Firecracker v0.20.0 has changed the host-initiated vsock
connection protocol to include a trivial handshake.

The new protocol looks like this:
- [host] CONNECT <port><LF>
- [guest/success] OK <assigned_host_port><LF>

Fixes: kata-containers#705

Signed-off-by: Penny Zheng <[email protected]>
egernst pushed a commit to egernst/runtime that referenced this pull request Feb 9, 2021
This file is mainly used by kata-runtime and missing logging part.
We add one new "agent-client" log field here, and Plz notice that,
you should turn on the `kata-runtime` debug option to see the output.

Fixes: kata-containers#705
Depends-on: github.com/kata-containers#2379

Signed-off-by: Penny Zheng <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants