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

Firecracker: virtio mmio support #1045

Merged

Conversation

mcastelino
Copy link
Contributor

Add support for virtio-mmio block devices. Firecracker only support virtio-mmio.

Note: Add a firecracker specific workaround to handle the fact that rootfs of the VM itself is also sent in as block device.

@mcastelino
Copy link
Contributor Author

/cc @egernst @sboeuf

@@ -831,7 +832,10 @@ func (k *kataAgent) appendDevices(deviceList []*grpc.Device, c *Container) []*gr
ContainerPath: dev.ContainerPath,
}

if d.SCSIAddr == "" {
if d.VirtPath != "" {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Open for suggestions here on how to figure out the actual type. Today we have no top level type information.

Copy link

Choose a reason for hiding this comment

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

Well I agree the if/else here looks flaky.
I think one approach would be to add a field Type to the BlockDrive structure. This way, we could factorize both VirtPath, SCSIAddr and PCIAddr into one unique field Dest (or similar) to describe how to identify the device from the guest side. The Type field would be used to know how to actually decipher the Dest field.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has been fixed by deriving the information directly.

@egernst
Copy link
Member

egernst commented Dec 18, 2018

/test

Copy link

@sboeuf sboeuf left a comment

Choose a reason for hiding this comment

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

A few comments but globally LGTM

virtcontainers/device/drivers/block.go Show resolved Hide resolved
virtcontainers/hyperstart_agent.go Outdated Show resolved Hide resolved
@@ -831,7 +832,10 @@ func (k *kataAgent) appendDevices(deviceList []*grpc.Device, c *Container) []*gr
ContainerPath: dev.ContainerPath,
}

if d.SCSIAddr == "" {
if d.VirtPath != "" {
Copy link

Choose a reason for hiding this comment

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

Well I agree the if/else here looks flaky.
I think one approach would be to add a field Type to the BlockDrive structure. This way, we could factorize both VirtPath, SCSIAddr and PCIAddr into one unique field Dest (or similar) to describe how to identify the device from the guest side. The Type field would be used to know how to actually decipher the Dest field.

virtcontainers/device/drivers/block.go Outdated Show resolved Hide resolved
@sboeuf
Copy link

sboeuf commented Dec 18, 2018

/test

@egernst
Copy link
Member

egernst commented Dec 18, 2018

/retest

virtcontainers/device/drivers/block.go Outdated Show resolved Hide resolved
virtcontainers/device/drivers/block.go Outdated Show resolved Hide resolved
pkg/katautils/config.go Outdated Show resolved Hide resolved
virtcontainers/qemu_arch_base.go Outdated Show resolved Hide resolved
@egernst
Copy link
Member

egernst commented Dec 19, 2018

@sboeuf identified issue here. PTAL @mcastelino : mcastelino@30d2279

Copy link
Member

@egernst egernst left a comment

Choose a reason for hiding this comment

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

see above comment, and fix @ mcastelino@30d2279

@mcastelino mcastelino force-pushed the topic/firecracker-virtio-mmio branch 2 times, most recently from a856de3 to e340395 Compare December 19, 2018 22:49
@mcastelino
Copy link
Contributor Author

/test

@mcastelino
Copy link
Contributor Author

@egernst @sboeuf @jodh-intel all the review comments should have been addressed.

Can you you review/merge.

@sboeuf
Copy link

sboeuf commented Dec 19, 2018

@mcastelino looks fine, but you need to fix the CI checks.

@mcastelino
Copy link
Contributor Author

@egernst @ mcastelino/runtime-1@30d2279 is not needed as we can always use virtPath. Now the flow is uniform across volumes and block devices as it should have been.

@mcastelino mcastelino force-pushed the topic/firecracker-virtio-mmio branch from e340395 to 027340f Compare December 19, 2018 23:33
@mcastelino mcastelino dismissed egernst’s stale review December 19, 2018 23:37

This change is no longer needed as we can use virtPath vs mmioaddr

@mcastelino
Copy link
Contributor Author

/test

@sboeuf
Copy link

sboeuf commented Dec 20, 2018

/test

globalIdx = index + 1
}

driveName, err := utils.GetVirtDriveName(globalIdx)
Copy link
Member

Choose a reason for hiding this comment

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

@amshinde I'm wondering if we still rely on GetVirtDriveName for virtio-blk device identification? I thought we now use pci address for them. Then at least GetVirtDriveName is not needed for virtio-blk. We can still keep it for virtio-mmio. In future we might want to replace it with disk UUID though.

Copy link
Member

Choose a reason for hiding this comment

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

Agree with @bergwolf

Overall it LGTM

@jodh-intel
Copy link
Contributor

jodh-intel commented Dec 20, 2018

Thanks @mcastelino !

lgtm

Approved with PullApprove

@jodh-intel
Copy link
Contributor

/retest

@sboeuf
Copy link

sboeuf commented Dec 20, 2018

Just so we don't try to test and retest, here are some consistent failures due to this patch:

Summarizing 3 Failures:

[Fail] run hot plug block devices [It] should be attached 
/tmp/jenkins/workspace/kata-containers-runtime-ubuntu-16-04-PR/go/src/github.com/kata-containers/tests/integration/docker/run_test.go:135

[Fail] docker volume passing a block device [It] should be mounted 
/tmp/jenkins/workspace/kata-containers-runtime-ubuntu-16-04-PR/go/src/github.com/kata-containers/tests/integration/docker/volume_test.go:135

[Fail] docker volume remove bind-mount source before container exits [It] should exit cleanly without leaking process 
/tmp/jenkins/workspace/kata-containers-runtime-ubuntu-16-04-PR/go/src/github.com/kata-containers/tests/integration/docker/volume_test.go:160

Ran 222 of 234 Specs in 1309.588 seconds
FAIL! -- 219 Passed | 3 Failed | 0 Pending | 12 Skipped --- FAIL: TestIntegration (1336.17s)

I'm trying to figure out what's wrong here.

@sboeuf
Copy link

sboeuf commented Dec 20, 2018

@mcastelino after more investigations, I found that the failing tests were related to some of our Docker integration tests testing --device option. And the generated error was the same I was seeing when I could not pass an extra block device into my VM!
So please include into this PR the small fix I have submitted here: mcastelino#5, this should fix those issues.

@mcastelino mcastelino force-pushed the topic/firecracker-virtio-mmio branch from 027340f to 676b820 Compare December 20, 2018 17:13
@mcastelino
Copy link
Contributor Author

@mcastelino after more investigations, I found that the failing tests were related to some of our Docker integration tests testing --device option. And the generated error was the same I was seeing when I could not pass an extra block device into my VM!
So please include into this PR the small fix I have submitted here: mcastelino#5, this should fix those issues.

@sboeuf I have pulled in the commit into this PR

@sboeuf
Copy link

sboeuf commented Dec 20, 2018

/test

@mcastelino mcastelino force-pushed the topic/firecracker-virtio-mmio branch from 410b69c to e889bb7 Compare December 20, 2018 19:47
@sboeuf
Copy link

sboeuf commented Dec 20, 2018

/test

@mcastelino mcastelino force-pushed the topic/firecracker-virtio-mmio branch from e889bb7 to 84a3ee9 Compare December 20, 2018 21:55
@sboeuf
Copy link

sboeuf commented Dec 20, 2018

/test

Start adding support for virtio-mmio devices starting with block.
The devices show within the vm as vda, vdb,... based on order of
insertion and such within the VM resemble virtio-blk devices.

They need to be explicitly differentiated to ensure that the
agent logic within the VM can discover and mount them appropropriately.
The agent uses PCI location to discover them for virtio-blk.
For virtio-mmio we need to use the predicted device name for now.

Note: Kata used a disk for the VM rootfs in the case of Firecracker.
(Instead of initrd or virtual-nvdimm). The Kata code today does not
handle this case properly.

For now as Firecracker is the only Hypervisor in Kata that
uses virtio-mmio directly offset the drive index to comprehend
this.

Longer term we should track if the rootfs is setup as a block
device explicitly.

Fixes: kata-containers#1046

Signed-off-by: Sebastien Boeuf <[email protected]>
Signed-off-by: Manohar Castelino <[email protected]>
@mcastelino mcastelino force-pushed the topic/firecracker-virtio-mmio branch from a7b77a8 to 0d84d79 Compare December 20, 2018 23:10
@sboeuf
Copy link

sboeuf commented Dec 20, 2018

/test

@WeiZhang555
Copy link
Member

WeiZhang555 commented Dec 21, 2018

Except @bergwolf 's comment, other parts
LGTM

Approved with PullApprove

@sboeuf sboeuf merged commit e14071f into kata-containers:master Dec 21, 2018
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