Skip to content

vmm: move logic for creating vcpus #1004

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

Merged
merged 2 commits into from
Mar 14, 2019
Merged

Conversation

dianpopa
Copy link
Contributor

On aarch64 KVM_CREATE_VCPU needs to be called before setting up the
IRQCHIP, while on x86 it needs to be called after setting up the
IRQCHIP. Consequently the configuration of the vcpus was moved to a
different function.
Also, architecture specific labeling was added.

Signed-off-by: Diana Popa [email protected]

Issue #, if available: #757

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@@ -101,6 +101,8 @@ pub enum StartMicrovmError {
VcpuConfigure(vstate::Error),
/// vCPUs were not configured.
VcpusNotConfigured,
/// vCPUs were not created prior to starting them.
VcpusNotCreated,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to ever get this error? At least in current implementation, it seems start_vcpus is invoked right after create_vcpus, so they're always created before being started.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can get this error if start_vcpus is called before create_vcpus (programming error) but this misuse will also be caught by the assert_eq!(vcpus.len(), vcpu_count as usize, "The number of vCPU fds is corrupted!" );
so I will only leave this assert and remove this error from this enum which indeed should only keep around user triggered errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the error. Take a look.

.map_err(|e| VmmActionError::StartMicrovm(ErrorKind::Internal, e))?;

self.start_vcpus(vcpus)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there anything missing here between calling create_vcpus and start_vcpus? It seems the IRQ chip still gets set up as part of init_microvm for all architectures, and init_microvm gets called before these two functions (line 1275).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Creating the irqchip after calling create_vcpus is mandatory for aarch64 not x86_64 which is the reason behind carving out the create_vcpus logic from start_vcpus. No aarch64 logic was added yet. That will come in following PRs. So, all this PR does is move away create_vcpu logic for aarch64 specific purposes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We agreed to move to a separate function the setup of the interrupt controller for x86_64 to make more obvious the order of operations that need to be respected when initializing the microvm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created setup_interrupt_controller function and did some additional refactoring.

@dianpopa
Copy link
Contributor Author

dianpopa commented Mar 13, 2019

@aghecenco @alexandruag please re-review.

On aarch64 KVM_CREATE_VCPU needs to be called before setting up the
IRQCHIP, while on x86 it needs to be called after setting up the
IRQCHIP. Consequently the configuration of the vcpus was moved to a
different function.
Also, architecture specific labeling was added.

Signed-off-by: Diana Popa <[email protected]>
@dianpopa dianpopa force-pushed the i757e branch 2 times, most recently from e1fedf2 to 34a9bd3 Compare March 13, 2019 17:31
* separate function for seting up the interrupt controller
* init_devices was renamed to attach_virtio_devices
* init_microvm was removed since its functionality was moved to the
  relevant functions
* created new functions for attaching legacy devices
* added unit tests

Signed-off-by: Diana Popa <[email protected]>
@alxiord alxiord merged commit 973596f into firecracker-microvm:master Mar 14, 2019
@dianpopa dianpopa deleted the i757e branch March 14, 2019 14:44
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.

3 participants