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

Determine and pass PCI addresses for block devices #267

Merged
merged 5 commits into from
May 3, 2018

Conversation

amshinde
Copy link
Member

This PR introduces using PCI addresses of virtio-blk devices to determine the device node names within the guest.
A follow up PR will use the same to pass the PCI addresses for VFIO devices as well.
The agent will use this information to identify devices within the guest.

@codecov
Copy link

codecov bot commented Apr 26, 2018

Codecov Report

Merging #267 into master will decrease coverage by 0.03%.
The diff coverage is 27.58%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #267      +/-   ##
==========================================
- Coverage   65.64%   65.61%   -0.04%     
==========================================
  Files          75       75              
  Lines        8008     8014       +6     
==========================================
+ Hits         5257     5258       +1     
- Misses       2181     2185       +4     
- Partials      570      571       +1
Impacted Files Coverage Δ
virtcontainers/sandbox.go 67.72% <ø> (ø) ⬆️
virtcontainers/qemu.go 12.19% <0%> (-0.03%) ⬇️
virtcontainers/container.go 46.11% <10%> (-0.98%) ⬇️
virtcontainers/qemu_arch_base.go 76.99% <100%> (ø) ⬆️
virtcontainers/qemu_amd64.go 93.54% <100%> (ø) ⬆️
virtcontainers/kata_agent.go 33.13% <50%> (+0.25%) ⬆️
virtcontainers/device.go 53.16% <66.66%> (+0.19%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d1b4a1...717bc4c. Read the comment docs.

@@ -565,19 +565,19 @@ func (q *qemu) qmpSetup() (*govmmQemu.QMP, error) {
return qmp, nil
}

func (q *qemu) addDeviceToBridge(ID string) (string, string, error) {
func (q *qemu) addDeviceToBridge(ID string) (string, *Bridge, error) {
Copy link

Choose a reason for hiding this comment

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

you don't need to return a reference to the bridge, a copy should be enough

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, copy should be enough, I tend to pass addresses to avoid extra copies. I believe any incorrect changes should be caught by our unit tests/CI.
I can change this though, would like more input on this.

Copy link

Choose a reason for hiding this comment

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

so.. , a copy should be enough? or no?

Copy link
Member Author

Choose a reason for hiding this comment

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

Like I mentioned copy should be enough. I tend to use addresses to avoid copies and create empty objects in case of error. I'll change this if this is a blocker.

Copy link
Member Author

Choose a reason for hiding this comment

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

@devimc Fixed this.

@egernst
Copy link
Member

egernst commented May 1, 2018

@WeiZhang555 @bergwolf PTAL?

@amshinde
Copy link
Member Author

amshinde commented May 1, 2018

@sboeuf Can you take a look at this as well?

@sboeuf
Copy link

sboeuf commented May 1, 2018

As we discussed offline, I think this change is fine in theory, but I realized that the CI is completely useless here. We don't have any Jenkins job actually testing virtio-blk.
So here is the summary about this:

  • Either we care about virtio-blk support, and this change matters, and we have to test it. This means we need a new Jenkins job dedicated to virtio-blk, testing with Qemu 2.7.
  • Or we don't care about virtio-blk support, and we can simply remove it from the codebase.

I'd prefer option 1 here, but the bottom line is that I would prefer that we take only changes that our CI is actually testing.

Copy link
Member

@bergwolf bergwolf left a comment

Choose a reason for hiding this comment

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

Nice patch! And I agree we should add virtio-blk to the CI test suite.

@amshinde
Copy link
Member Author

amshinde commented May 3, 2018

@sboeuf Talked to @chavafg about running tests for this on an azure instance to see if all tests pass with this PR until we add CI instance for virtio-blk.

@chavafg
Copy link
Contributor

chavafg commented May 3, 2018

@amshinde I have run the whole testswith kata-containers/agent#227 and qemu-lite 2.7. No regressions were found.

@sboeuf
Copy link

sboeuf commented May 3, 2018

@chavafg good news. Are you currently adding a new job for those tests ? I think you are, right ?

@chavafg
Copy link
Contributor

chavafg commented May 3, 2018

@sboeuf Yes, I have opened kata-containers/tests#271 to address this.

@sboeuf
Copy link

sboeuf commented May 3, 2018

Great thank you @chavafg

@amshinde
Copy link
Member Author

amshinde commented May 3, 2018

@sboeuf Can we merge this, now that we know that CI passes?

@sboeuf
Copy link

sboeuf commented May 3, 2018

@amshinde yeah sure, @devimc could you approve and merge ?

Change the function to return the bridge itself that the
device is attached to. This will allow bridge address to be used
for determining the PCI slot of the device within the guest.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
Introduce a new field in Drive to store the PCI address if the drive is
attached using virtio-blk.
Assign PCI address in the format bridge-addr/device-addr.
Since we need to assign the address while hotplugging, pass Drive
by address.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
We need to store the bridge address to state to use it
for assigning addresses to devices attached to teh bridge.
So we need to make sure that the bridge pointer is assigned
the address.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
Store PCI address for a block device on hotplugging it via
virtio-blk. This address will be passed by kata agent in the
device "Id" field. The agent within the guest can then use this
to identify the PCI slot in the guest and create the device node
based on it.

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
Store the PCI address of rootfs in case the rootfs is block
based and passed using virtio-block.
This helps up get rid of prdicting the device name inside the
container for the block device. The agent will determine the device
node name using the PCI address.

Fixes kata-containers#266

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
Copy link

@devimc devimc left a comment

Choose a reason for hiding this comment

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

lgtm

@egernst egernst merged commit 992c895 into kata-containers:master May 3, 2018
zklei pushed a commit to zklei/runtime that referenced this pull request Jun 13, 2019
Don't create the mount destination in `generalMount()` as that is
handled by `mountToRootfs()`.

Fixes kata-containers#267.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
@amshinde amshinde deleted the pass-pci-addr branch July 11, 2019 22:26
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.

6 participants