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

runtime-rs: ch: Implement minimal implementation for missing thread/pid APIs #8710

Merged
merged 1 commit into from Jan 17, 2024

Conversation

jodh-intel
Copy link
Contributor

Add implementations for the following Hypervisor trait methods which simply return the same details as the get_vmm_master_tid() method:

  • get_thread_ids()
  • get_pids()

Fixes: #6438.

Add implementations for the following `Hypervisor` trait methods which
simply return the same details as the `get_vmm_master_tid()` method:

- `get_thread_ids()`
- `get_pids()`

Fixes: kata-containers#6438.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
@katacontainersbot katacontainersbot added the size/small Small and simple task label Dec 20, 2023
Ok(VcpuThreadIds::default())
let mut vcpus = HashMap::new();

let vcpu = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

@jodh-intel is this always 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cmaf - well, I'm not sure what else we could do here. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

@jodh-intel This api is meant to return all the tids corresponding to all the vcpus that the VM uses.

qemu has an qmp api query-cpus-fast that returns the details about the vcpus: https://www.qemu.org/docs/master/system/cpu-hotplug.html

I am not sure if such an api exists or has been added to clh since the go implementation.
cc @likebreath Can you let us know about this?

Else we may have to follow the same method that we used for the go-implementation i.e walk through the /proc/pid tree:
https://github.com/kata-containers/kata-containers/blob/main/src/runtime/virtcontainers/clh.go#L760

Copy link
Contributor

Choose a reason for hiding this comment

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

qemu has an qmp api query-cpus-fast that returns the details about the vcpus: https://www.qemu.org/docs/master/system/cpu-hotplug.html

I am not sure if such an api exists or has been added to clh since the go implementation. cc @likebreath Can you let us know about this?

@amshinde is right. Cloud Hypervisor does not provide such pid information at this time. Of course, please feel free to send feature requests to the CLH community.

One clarification questions: what kind of PID information does kata want from VMM?

@@ -688,7 +698,9 @@ impl CloudHypervisorInner {
}

pub(crate) async fn get_pids(&self) -> Result<Vec<u32>> {
Ok(Vec::<u32>::new())
let pid = self.get_vmm_master_tid().await?;
Copy link
Member

Choose a reason for hiding this comment

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

@jodh-intel We should probably return the virtio-fs deamon pid here as well.

Copy link
Member

Choose a reason for hiding this comment

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

I just checked the golang implementation for the GetPids API.
Its interesting that the qemu implementation returns both hypervisor+virtiofs pids, whereas clh just returns the hypervisor pid.
Point to note is that golang has a separate API for the virtiofs deamon:
https://github.com/kata-containers/kata-containers/blob/main/src/runtime/virtcontainers/hypervisor.go#L1108

This is missing from current rust hypervisor plugin API. It would not apply to dragonball anyway as it does not run a separate virtio-fs deamon.

Also, dragonball returns all the child pids in its implementation:
https://github.com/kata-containers/kata-containers/blob/main/src/runtime-rs/crates/hypervisor/src/dragonball/inner_hypervisor.rs#L110

This should also include virtio-fs thread id.

So in conclusion, I feel that with runtime-rs+clh, we should return hypervisor_pid + virtiofs_pid as well.

FYI, the only place I see the golang GetPids api being called is for metrics:
https://github.com/kata-containers/kata-containers/blob/main/src/runtime/virtcontainers/sandbox_metrics.go#L135

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @amshinde - I'm not sure that's needed since with the golang runtime, the CH driver spawns the virtiofsd but with runtime-rs, the runtime itself does that, not the CH driver.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, it makes sense to not include virtio-fs then

@jodh-intel jodh-intel changed the title runtime-rs: ch: Implement missing thread/pid APIs runtime-rs: ch: Implement minimal implementation for missing thread/pid APIs Jan 11, 2024
@jodh-intel
Copy link
Contributor Author

This PR is a minimal implementation. We can't return the full details since CH doesn't provide that information currently. I've raised cloud-hypervisor/cloud-hypervisor#6103 and #8799 for the "phase 2" implementation 😄

/cc @amshinde, @cmaf

Copy link
Member

@amshinde amshinde left a comment

Choose a reason for hiding this comment

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

@jodh-intel I am approving this, lets open a separate PR to handle multiple VCPUs in a separate PR similar to the golang implementation.

Copy link
Contributor

@cmaf cmaf left a comment

Choose a reason for hiding this comment

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

thanks @jodh-intel

@jodh-intel jodh-intel added safe-to-test Add to PR after manually reviewing to allow certain extra checks to run ok-to-test labels Jan 16, 2024
@jodh-intel
Copy link
Contributor Author

/test

@cmaf cmaf merged commit 32ad465 into kata-containers:main Jan 17, 2024
212 of 231 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test safe-to-test Add to PR after manually reviewing to allow certain extra checks to run size/small Small and simple task
Projects
None yet
Development

Successfully merging this pull request may close these issues.

runtime-rs: ch: Implement minimal thread/tid/pid handling
5 participants