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

config: Add Hardware description object to the VM configuration #1209

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

oleksiimoisieiev
Copy link

This adds section to describe HW that should be passed through to the VM. This enables Hardware-level isolation provided by XEN for e.g. functional safety use cases.

Adds hwConfig object to the VM section which is apt to describe the initial configuration for the VM, sush as number of vcpus and memory, provided to the VM.
Hardware description includes path to the device-tree, that should be passed to the VM and the hardware configuration parameters which provides all needed data for VM to use the devices, such as:

  • dtdevs: host device tree nodes to passthrough to the VM;
  • iomems: allow auto-translated domains to access specific hardware I/O memory pages;
  • irqs: allows VM to access specific physical IRQs.

@giuseppe
Copy link
Member

giuseppe commented Jun 5, 2023

@slp could this be useful for krun?

@AkihiroSuda AkihiroSuda added this to the v1.2.0 milestone Jun 5, 2023
@slp
Copy link

slp commented Jun 5, 2023

@giuseppe I don't see an immediate use for it, but it's good to know it's there.

config-vm.md Outdated
* **`memKB`** (int OPTIONAL) Maximum memory in KB allocated to the VM.
* **`dtdevs`** (array OPTIONAL) Host device tree nodes to passthrough to the VM, see [Xen Config][xl-config-format] for the details.
* **`iomems`** (array OPTIONAL) Allow auto-translated domains to access specific hardware I/O memory pages, see [Xen Config][xl-config-format].
* **`firstGFN`** (number OPTIONAL) Guest Frame Number to map the iomem range.
Copy link
Member

Choose a reason for hiding this comment

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

Is “number” different from “int”?

Copy link
Author

Choose a reason for hiding this comment

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

Thank you. Changed to int.

config-vm.md Outdated
],
"iomems": [
{
"firstMFN": 0x3000,
Copy link
Member

Choose a reason for hiding this comment

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

JSON does not allow hex

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the tip. Changed it to the number sequence, supported by JSON format.

// IOMems containes information about iomem addresses that should be passed to the VM.
type IOMems struct {
// Guest Frame Number to map the iomem range. If GFN is not specified, the mapping will be done to the same Frame Number as was provided in FirstMFN.
FirstGFN uint64 `json:"firstGFN"`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
FirstGFN uint64 `json:"firstGFN"`
FirstGFN *uint64 `json:"firstGFN,omitempty"`

to distinguish nil (unset) from zero.

Same for other properties too.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed. Thanks.

@@ -657,6 +683,8 @@ type VM struct {
Kernel VMKernel `json:"kernel"`
// Image specifies guest image related configuration for virtual-machine-based containers.
Image VMImage `json:"image,omitempty"`
// Hardware configuration that should be passed to the VM.
HwConfig HWConfig `json:"hwconfig"`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
HwConfig HWConfig `json:"hwconfig"`
HwConfig *HWConfig `json:"hwconfig,omitempty"`

Copy link
Author

Choose a reason for hiding this comment

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

Fixed. Thanks.

config-vm.md Outdated Show resolved Hide resolved
@AkihiroSuda
Copy link
Member

Looks good, but we are freezing the main branch until releasing v1.1.0.

Hope we can release v1.1.0 and merge post-v1.1 PRs in the next couple of weeks.

This adds section to describe HW that should be passed through to the
VM. This enables Hardware-level isolation provided by XEN for
e.g. functional safety use cases.

Adds hwConfig object to the VM section which is apt to describe the
initial configuration for the VM, sush as number of vcpus and memory,
provided to the VM.
Hardware description includes path to the device-tree, that should be
passed to the VM and the hardware configuration parameters which
provides all needed data for VM to use the devices, such as:
  - dtdevs: host device tree nodes to passthrough to the VM;
  - iomems: allow auto-translated domains to access specific hardware
  I/O memory pages;
  - irqs: allows VM to access specific physical IRQs.

Signed-off-by: Oleksii Moisieiev <oleksii_moisieiev@epam.com>
@klogg
Copy link

klogg commented Jun 6, 2023

@giuseppe I don't see an immediate use for it, but it's good to know it's there.

We plan to extend with RT scheduling / mem bw control for domains, do you have some interest or ideas in that?

@oleksiimoisieiev
Copy link
Author

Hi @AkihiroSuda. Do you have any plans merging this changes?

@AkihiroSuda
Copy link
Member

Yes, but after releasing this:

We also want to see a POC of this PR to confirm implementability.

@oleksiimoisieiev
Copy link
Author

Yes, but after releasing this:

* [Release v1.1.1 #1242](https://github.com/opencontainers/runtime-spec/pull/1242)

We also want to see a POC of this PR to confirm implementability.

Thank you for the quick response. What do you expect as POC? Some real yamls based on this bindings?

@AkihiroSuda
Copy link
Member

A POC of an actual runtime implementation would be more preferable

@AkihiroSuda
Copy link
Member

ping @opencontainers/runtime-spec-maintainers

@oleksiimoisieiev
Copy link
Author

oleksiimoisieiev commented Mar 1, 2024

A POC of an actual runtime implementation would be more preferable

Hi @AkihiroSuda,
Attaching sample JSON spec (see attached domain.json) and Xen config (see attached domain.txt) that can be generated from the provided spec.
Using this config Xen domain can be started.

domain.json
domain.txt

@AkihiroSuda AkihiroSuda requested a review from a team May 17, 2024 17:44
* **`deviceTree`** (string OPTIONAL) Path to the container device-tree file that should be passed to the VM.
* **`vcpus`** (int OPTIONAL) Number of virtual cpus for the VM.
* **`memory`** (int OPTIONAL) Maximum memory in bytes allocated to the VM.
* **`dtdevs`** (array OPTIONAL) Host device tree nodes to passthrough to the VM, see [Xen Config][xl-config-format] for the details.
Copy link
Member

Choose a reason for hiding this comment

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

There's several references here to Xen specifically -- are these all applicable to other implementations too, or are these mostly Xen-specific fields?

I'm trying to understand how this helps improve interoperability between runtimes, so another way to put this question is whether you envision more than one runtime will implement support for this?

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.

None yet

7 participants