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

Resolve #78, EmulatedDevice::services should access the VM config #113

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

AntoineRR
Copy link
Contributor

Resolve issue #78

  • Changes EmulatedDevice::services method to access the virtual machine config
  • Adds a new struct called DeviceMapBuilder to be able to manipulate DeviceMap through VirtualMachineConfig

Copy link
Collaborator

@ALSchwalm ALSchwalm 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 working on this! I've not reviewed it yet, but I was hoping @dlrobertson could chime in with his reasoning around this issue. I understand that some devices may need to have additional information to know what guest portio addresses/memory regions they are responsible fore, but I'm not exactly sure why that would be determined by passing the VirtualMachineConfig to the services call. Wouldn't it make sense to pass the required information to the device during its construction, so it can determine whatever it needs to inside services? But I could definitely be missing something.

@@ -79,45 +79,46 @@ fn build_vm(

acpi.add_sdt(madt).unwrap();

let device_map = config.virtual_devices_mut();
// let device_map = config.virtual_devices_mut();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove this comment.

@@ -497,8 +516,22 @@ mod test {
}
}

impl VirtualMachineConfig {
// Default config used for testing
pub fn default() -> VirtualMachineConfig {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It doesn't look like this is used outside of this module, so rather than defining this default, I'd rather have a method in the mod test below that just returns just a VirtualMachineConfig and use that in the tests.

@ALSchwalm
Copy link
Collaborator

@dlrobertson do you have any comment on this? I'm not sure what your thinking was here

@dlrobertson
Copy link
Contributor

Wouldn't it make sense to pass the required information to the device during its construction, so it can determine whatever it needs to inside services?

Yeah, I think at this point something along these lines would be a better approach.

@dlrobertson
Copy link
Contributor

I think #78 and this PR should now be changed to instead reduce the use of magic numbers like src/kmain.rs:79 and src/virtdev/ioapic.rs:21. Instead we should probably use a constant defined in the virtdev implementation when we construct the MADT.

@paulcacheux
Copy link
Contributor

Thanks to you both for taking a look at our PR. We are not sure to understand what would be the best way moving forward, do you just want to remove magic numbers in the implementation or do you still want a way for devices to access the virtual machine configuration ? In what structure would you like to define the magic numbers used by the MADT ?

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.

5 participants