Commit Graph

673 Commits

Author SHA1 Message Date
Fabiano Fidêncio
4c34cfb0ab Merge pull request #10420 from pmores/add-support-for-virtio-scsi
runtime-rs: support virtio-scsi device in qemu-rs
2024-10-22 11:00:33 +02:00
Pavel Mores
8cdd968092 runtime-rs: support virtio-scsi device in qemu-rs
Semantics are lifted straight out of the go runtime for compatibility.
We introduce DeviceVirtioScsi to represent a virtio-scsi device and
instantiate it if block device driver in the configuration file is set
to virtio-scsi.  We also introduce ObjectIoThread which is instantiated
if the configuration file additionally enables iothreads.

Signed-off-by: Pavel Mores <pmores@redhat.com>
2024-10-22 08:55:54 +02:00
Anastassios Nanos
68d539f5c5 Merge pull request #10435 from nubificus/fix_fc_machineconfig
runtime-rs: Use vCPU and memory values from config
2024-10-18 13:41:20 +01:00
Anastassios Nanos
23f5786cca runtime-rs: Use vCPU and memory values from config
Use values from the config for the setup of the microVM.

Fixes: #10434

Signed-off-by: Anastassios Nanos <ananos@nubificus.co.uk>
2024-10-17 23:17:02 +01:00
Pavel Mores
23927d8a94 runtime-rs: plug in netdev hotplugging functionality and actually call it
add_device() now checks if QEMU is running already by checking if we have
a QMP connection.  If we do a new function hotplug_device() is called
which hotplugs the device if it's a network one.

Signed-off-by: Pavel Mores <pmores@redhat.com>
2024-10-03 11:23:10 +02:00
Pavel Mores
ac393f6316 runtime-rs: implement netdev hotplugging for qemu-rs
With the helpers from previous commit, the actual hotplugging
implementation, though lengthy, is mostly just assembling a QMP command
to hotplug the network device backend and then doing the same for the
corresponding frontend.

Note that hotplug_network_device() takes cmdline_generator types Netdev
and DeviceVirtioNet.  This is intentional and aims to take advantage of
the similarity between parameter sets needed to coldplug and hotplug
devices reuse and simplify our code.  To enable using the types from qmp,
accessors were added as needed.

Signed-off-by: Pavel Mores <pmores@redhat.com>
2024-10-03 11:20:02 +02:00
Pavel Mores
4eb7e2966c runtime-rs: add netdev hotplugging helpers to qemu-rs
Before adding network device hotplugging functionality itself we add
a couple of helpers in a separate commit since their functionality is
non-trivial.

To hotplug a device we need a free PCI slot.  We add find_free_slot()
which can be called to obtain one.  It looks for PCI bridges connected
to the root bridge and looks for an unoccupied slot on each of them.  The
first found is returned to the caller.  The algorithm explicitly doesn't
support any more complex bridge hierarchies since those are never produced
when coldplugging PCI bridges.

Sending netdev queue and vhost file descriptors to QEMU is slightly
involved and implemented in pass_fd().  The actual socket has to be passed
in an SCM_RIGHTS socket control message (also called ancillary data, see
man 3 cmsg) so we have to use the msghdr structure and sendmsg() call
(see man 2 sendmsg) to send the message.  Since qapi-rs doesn't support
sending messages with ancillary data we have to do the sending sort of
"under it", manually, by retrieving qapi-rs's socket and using it directly.

Signed-off-by: Pavel Mores <pmores@redhat.com>
2024-10-03 11:15:31 +02:00
Pavel Mores
3f46dfcf2f runtime-rs: don't treat NetworkConfig::index as unique in qemu-rs
NetworkConfig::index has been used to generate an id for a network device
backend.  However, it turns out that it's not unique (it's always zero
as confirmed by a comment at its definition) so it's not suitable to
generate an id that needs to be unique.

Use the host device name instead.

Signed-off-by: Pavel Mores <pmores@redhat.com>
2024-10-03 11:12:37 +02:00
Pavel Mores
cda04fa539 runtime-rs: factor setup of network device out of QemuCmdLine
Network device hotplugging will use the same infrastructure (Netdev,
DeviceVirtioNet) as coldplugging, i.e. QemuCmdLine.  To make the code
of network device setup visible outside of QemuCmdLine we factor it out
to a non-member function `get_network_device()` and make QemuCmdLine just
delegate to it.

Signed-off-by: Pavel Mores <pmores@redhat.com>
2024-10-03 11:03:32 +02:00
Pavel Mores
efc8e93bfe runtime-rs: factor bus_type() out of QemuCmdLine
The function takes a whole QemuCmdLine but only actually uses
HypervisorConfig.  We increase callability of the function by limiting
its interface to what it needs.  This will come handy shortly.

Signed-off-by: Pavel Mores <pmores@redhat.com>
2024-10-03 11:03:32 +02:00
Pavel Mores
720265c2d8 runtime-rs: support adding PCI bridges to qemu VM
At least one PCI bridge is necessary to hotplug PCI devices.  We only
support PCI (at this point at least) since that's what the go runtime
does (note that looking at the code in virtcontainers it might seem that
other bus types are supported, however when the bridge objects are passed
to govmm, all but PCI bridges are actually ignored).  The entire logic of
bridge setup is lifted from runtime-go for compatibility's sake.

Signed-off-by: Pavel Mores <pmores@redhat.com>
2024-10-03 11:03:32 +02:00
Alex Lyn
dfd0ca9bfe Merge pull request #10312 from sidneychang/configurable-build-dragonball
runtime-rs: Add Configurable Compilation for Dragonball in Runtime-rs
2024-09-29 22:33:54 +08:00
Xuewei Niu
ad0f2b2a55 Merge pull request #10219 from sidneychang/decouple-runtime-rs-from-dragonball
runtime-rs: Port TAP implementation from dragonball
2024-09-27 11:17:55 +08:00
Fupan Li
f7bc627a86 sandbox: refactor the sandbox init process
Inorder to support sandbox api, intorduce the sandbox_config
struct and split the sandbox start stage from init process.

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2024-09-26 23:50:24 +08:00
Sicheng Liu
08eb5fc7ff runtime-rs: Notify containerd when process exits
Docker cannot exit normally after the container process exits when
used with runtime-rs since it doesn't receive the exit event. This
commit enable runtime-rs to send TaskExit to containerd after process
exits.

Also, it moves "system_time_into" and "option_system_time_into" from
crates/runtimes/common/src/types/trans_into_shim.rs to a new utility
mod.

Signed-off-by: Sicheng Liu <lsc2001@outlook.com>
2024-09-26 02:52:50 +00:00
Xuewei Niu
857222af02 Merge pull request #10330 from lifupan/main_sandboxapi
Some prepared work for sandbox api support
2024-09-26 09:47:47 +08:00
Alex Lyn
6b94cc47a8 Merge pull request #10146 from Apokleos/intro-cdi
Introduce cdi in runtime-rs
2024-09-23 21:45:42 +08:00
Alex Lyn
b8ba346e98 runtime-rs: Add test for container devices with CDI.
Fixes #10145

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2024-09-23 17:20:22 +08:00
Fupan Li
52397ca2c1 sandbox: rename the task_service to service
rename the task_service to service, in order to
incopperate with the following added sandbox
services.

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2024-09-22 14:44:19 +08:00
Fupan Li
20b4be0225 runtime-rs: rename the Request/Response to TaskRequest/TaskResponse
In order to make different from sandbox request/response, this commit
changed the task request/response to TaskRequest/TaskResponse.

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2024-09-22 14:44:11 +08:00
Fupan Li
ba94eed891 sandbox: fix the issue of hypervisor's wait_vm
Since the wait_vm would be called before calling stop_vm,
which would take the reader lock, thus blocking the stop_vm
getting the writer lock, which would trigge the dead lock.

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2024-09-22 14:44:03 +08:00
Fupan Li
fb27de3561 runtime-rs: fix the issue of using block_on
Since the block_on would block on the current thread
which would prevent other async tasks to be run on this
worker thread, thus change it to use the async task for
this task.

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2024-09-22 14:40:44 +08:00
sidney chang
456e13db98 runtime-rs: Add Configurable Compilation for Dragonball in Runtime-rs
rename DEFAULT_HYPERVISOR to HYPERVISOR in Makefile
Fixes #10310

Signed-off-by: sidney chang <2190206983@qq.com>
2024-09-20 05:41:34 -07:00
sidneychang
b85a886694 runtime-rs: Add Configurable Compilation for Dragonball in Runtime-rs
This PR introduces support for selectively compiling Dragonball in
runtime-rs. By default, Dragonball will continue to be compiled into
the containerd-shim-kata-v2 executable, but users now have the option
to disable Dragonball compilation.

Fixes #10310

Signed-off-by: sidney chang <2190206983@qq.com>
2024-09-20 05:38:59 -07:00
Alex Lyn
63b25e8cb0 runtime-rs: Introduce cdi devices in container creation
Fixes #10145

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2024-09-20 09:28:51 +08:00
Alex Lyn
03735d78ec runtime-rs: add cdi devices definition and related methods
Add cdi devices including ContainerDevice definition and
annotation_container_device method to annotate vfio device
in OCI Spec annotations which is inserted into Guest with
its mapping of vendor-class and guest pci path.

Fixes #10145

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2024-09-20 09:28:51 +08:00
Alex Lyn
020e3da9b9 runtime-rs: extend DeviceVendor with device class
We need vfio device's properties device, vendor and
class, but we can only get property device and vendor.
just extend it with class is ok.

Fixes #10145

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2024-09-20 09:28:51 +08:00
Fabiano Fidêncio
fefcf7cfa4 acrn: Drop support
As we don't have any CI, nor maintainer to keep ACRN code around, we
better have it removed than give users the expectation that it should or
would work at some point.

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
2024-09-19 16:05:43 +02:00
Pavel Mores
5e5eb9759f runtime-rs: handle disabled guest selinux in virtiofsd
This is just a port of functionality existing in the golang runtime.

Signed-off-by: Pavel Mores <pmores@redhat.com>
2024-09-19 12:47:10 +02:00
Pavel Mores
8c92f3bfec runtime-rs: enable/disable selinux in guest based on disable_guest_selinux
This change technically affects the path for enabled guest selinux as well,
however since this is not implemented in runtime-rs anyway nothing should
break.  When guest selinux support is added this change will come handy.

Signed-off-by: Pavel Mores <pmores@redhat.com>
2024-09-19 12:47:10 +02:00
Pavel Mores
204ee21bc8 runtime-rs: handle disabled guest selinux in OCI spec
If guest selinux is off the runtime has to ensure that container OCI spec
contains no selinux labels for the container rootfs and process.  Failure
to do so causes kata agent to try and apply the labels which fails since
selinux is not enabled in guest, which in turn causes container launch
to fail.

This is largely inspired by golang runtime(*) with a slight deviation
in ordering of checks.  This change simply checks the disable_guest_selinux
config setting and if it's true it clears both rootfs and process label if
necessary.  Golang runtime, on the other hand, seems to first check if
process label is non-empty and only then it checks the config setting,
meaning that if process label is empty the rootfs label is not reset
even if it's non-empty.  Frankly, this looks like a potential bug though
probably unlikely to manifest since it can be assumed that the labels are
either both empty, or both non-empty.

(*) 4fd4b02f2e/src/runtime/virtcontainers/kata_agent.go (L1005)

Signed-off-by: Pavel Mores <pmores@redhat.com>
2024-09-19 12:47:10 +02:00
sidney chang
5a7d0ed3ad runtime-rs: introduce tap in hypervisor by extrating it from dragonball
It's a prerequisite PR to make built-in vmm dragonball compilation
options configurable.

Extract TAP device-related code from dragonball's dbs_utils into a
separate library within the runtime-rs hypervisor module.
To enhance functionality and reduce dependencies, the extracted code
has been reimplemented using the libc crate and the ifreq structure.

Fixes #10182

Signed-off-by: sidney chang <2190206983@qq.com>
2024-09-13 07:32:14 -07:00
Hui Zhu
dfea12bc53 runtime-rs: configuration-dragonball.toml.in: Remove duplication
Remove duplicated description of enable_balloon_f_reporting from
configuration-dragonball.toml.in.

Signed-off-by: Hui Zhu <teawater@antgroup.com>
2024-09-10 07:34:29 +08:00
Hui Zhu
447a7feccf runtime-rs: configuration-dragonball.toml.in: Add config for balloon
Add enable_balloon_f_reporting config to
configuration-dragonball.toml.in.

Signed-off-by: Hui Zhu <teawater@antgroup.com>
2024-09-04 17:25:38 +08:00
Hui Zhu
ad9968ce2d runtime-rs: Add enable_balloon_f_reporting for dragonball
Under normal circumstances, the virtual machine only requests memory
from the host and does not actively release it back to host when it is
no longer needed, leading to a waste of memory resources.

Free page reporting is a sub-feature of virtio-balloon. When this
feature is enabled, the Linux guest kernel will send information about
released pages to dragonball via virtio-balloon, and dragonball will
then release these pages.

This commit adds an option enable_balloon_f_reporting to runtime-rs.
When this option is enabled, runtime-rs will insert a virtio-balloon
device with the f_reporting option enabled during the Dragonball virtual
machine startup.

Signed-off-by: Hui Zhu <teawater@antgroup.com>
2024-09-04 16:38:13 +08:00
Hyounggyu Choi
7d0aba1a24 runtime: Enable to get cdh_api_timeout from configuration file
This commit allows `cdh_api_timeout` to be configured from the configuration file.
The configuration is commented out with specifying a default value (50s) because
the default value is configured in the agent.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2024-08-22 14:47:37 +02:00
Fupan Li
cadcf5f92d runtime-rs: Add the wait_vm support for hypervisors
Add the wait_vm method for hypervisors. This is a
prerequisite for sandbox api support.

Fixes: #7043

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2024-08-14 12:01:34 +08:00
Tom Dohrmann
b7999ac765 runtime-rs: don't emit scsi parameter for block devices
This parameter has been deprecated for a long time and QEMU 9.1.0 finally removes it.

Signed-off-by: Tom Dohrmann <erbse.13@gmx.de>
2024-08-02 07:30:23 +02:00
Wainer Moschetta
528745fc88 Merge pull request #10052 from nubificus/feat_fix_qemu_after_8070
runtime-rs: Fix QEMU backend for runtime-rs
2024-07-30 11:00:14 -03:00
Fupan Li
e3f0d2a751 runtime-rs: enable dragonball hypervisor support initrd
enable the dragonball support initrd.

Fixes: #10023

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2024-07-30 14:50:24 +08:00
Anastassios Nanos
d11657a581 runtime-rs: Remove unused env vars from build
Since we can't find a homogeneous value for the resource/cgroup
management of multiple hypervisors, and we have decoupled the
env vars in the Makefile, we don't need the generic ones.

Signed-off-by: Anastassios Nanos <ananos@nubificus.co.uk>
2024-07-26 14:03:50 +00:00
Anastassios Nanos
3f58ea9258 runtime-rs: Decouple Makefile env VARS
To avoid overriding env vars when multiple hypervisors are
available, we add per-hypervisor vars for static resource
management and cgroups handling. We reflect that in the
relevant config files as well.

Signed-off-by: Anastassios Nanos <ananos@nubificus.co.uk>
2024-07-26 14:02:35 +00:00
Fupan Li
c51ba73199 container: fix the issue of send signal to process
It's better to check the container's status before
try to send signal to it. Since there's no need
to send signal to it when the container's stopped.

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2024-07-26 19:23:43 +08:00
Fupan Li
e156516bde sandbox: fix the issue of stop sandbox
Since stop sandbox would be called in multi path,
thus it's better to set and check the sandbox's state.

Fixes: #10042

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2024-07-26 19:23:34 +08:00
Alex Lyn
abb0a2659a Merge pull request #9944 from Apokleos/align-ocispec-rs
Align kata oci spec with oci-spec-rs
2024-07-25 19:36:52 +08:00
Alex Lyn
882385858d runtime-rs: Align oci spec in runtime-rs with oci-spec-rs
This commit aligns the OCI Spec implementation in runtime-rs
with the OCI Spec definitions and related operations provided
by oci-spec-rs. Key changes as below:
(1) Leveraged oci-spec-rs to align Kata Runtime OCI Spec with
the official OCI Spec.
(2) Introduced runtime-spec to separate OCI Spec definitions
from Kata-specific State data structures.
(3) Preserved the original code logic and implementation as
much as possible.
(4) Made minor code adjustments to adhere to Rust programming
conventions;

Fixes #9766

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2024-07-25 17:47:01 +08:00
Anastassios Nanos
cda00ed176 runtime-rs: Add FC specific KERNELPARAMS
To avoid overriding KERNELPARAMS for other hypervisors, add
FC-specific KERNELPARAMS.

Signed-off-by: Anastassios Nanos <ananos@nubificus.co.uk>
2024-07-25 08:53:57 +00:00
Alex Lyn
4e003a2125 Merge pull request #10058 from Apokleos/enhance-vsock-connect
runtime-rs: enhance debug info for agent connect.
2024-07-25 11:29:04 +08:00
Alex Lyn
36385a114d runtime-rs: enhance debug info for agent connect.
we need more friendly logs for debugging agent conntion
cases when kata pods fail.

Fixes #10057

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2024-07-25 08:51:57 +08:00
Pavel Mores
dd1e09bd9d runtime-rs: add experimental support for memory hotunplugging to qemu-rs
Hotunplugging memory is not guaranteed or even likely to work.
Nevertheless I'd really like to have this code in for tests and
observation.  It shouldn't hurt, from experience so far.

Signed-off-by: Pavel Mores <pmores@redhat.com>
2024-07-24 13:22:41 +02:00