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

Overhaul of the crate to fit our use case #1

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

lucido-simon
Copy link

Hi !

This PR is aimed at providing a more specific use case of the rust-vmm/vm-device crate. Since we are exclusively using it for virtio-mmio device, I've deleted all the code related to PIO devices, to make the code more readable.

I've also taken the liberty of specializing this crate to virtio 1.2 mmio devices, and not for all kind of mmio-mapped devices. This is also our only use case, and allows for some virtio abstractions higher up in the layers when managing virtio devices.

Most of the PR is deletions and renaming.

@@ -1,5 +1,5 @@
// Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
// SPDX-License-Identifier: GuestAddresspache-2.0 OR BSD-3-Clause
Copy link

Choose a reason for hiding this comment

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

:-)

}
pub trait VirtioMmioDevice {
fn virtio_mmio_read(&self, base: GuestAddress, offset: VirtioMmioOffset, data: &mut [u8]);
fn virtio_mmio_write(&self, base: GuestAddress, offset: VirtioMmioOffset, data: &[u8]);
Copy link

Choose a reason for hiding this comment

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

This commit is huge and highly intrusive. Since it seems to be turning the vm_device crate into a virtio specific one, I have a couple of fundamental questions:

  • How is a virtio MMIO device different than a DeviceMmio one?
  • You're renaming a bunch of structures, deleting a bunch of modules, to essentially accommodate for virtio MMIO. But is there something missing from the vm_device crate that would prevent you to use it as is?

Copy link
Author

Choose a reason for hiding this comment

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

  • A virtio MMIO device is basically a DeviceMmio, with some slightly tweaked QoL (such as having the offset as an Enum corresponding to the virtio layout, or using GuestAddress , the same as in lumper). They are essentially the same.
  • Nothing is missing from vm_device. However, this fork is easier to work with, since it corresponds to our use case.

I will try giving another shot at using the upstream crate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants