Commit Graph

4749 Commits

Author SHA1 Message Date
Leonard Cohnen
9b614a4615 genpolicy: align state path getter and setter
Before this patch there was a mismatch between the JSON path under which
the state of the rule evaluation is set in comparison to under which
it is retrieved.

This resulted in the behavior that each time the policy was evaluated,
it thought it was the _first_ time the policy was evaluated.
This also means that the consistency check for the `sandbox_name`
was ineffective.

Signed-off-by: Leonard Cohnen <lc@edgeless.systems>
2024-12-03 13:25:24 +01:00
Saul Paredes
711d12e5db policy: support optional metadata uid field
This prevents a deserialization error when uid is specified

Signed-off-by: Saul Paredes <saulparedes@microsoft.com>
2024-12-02 11:24:58 -08:00
Dan Mihai
efd492d562 runtime: skip logging some of the dial errors
With full debug logging enabled there might be around 1,500 redials
so log just ~15 of these redials to avoid flooding the log.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2024-12-02 19:11:32 +00:00
Saul Paredes
9105c1fa0c policy: add constants to rules.rego
Reuse constants where applicable

Signed-off-by: Saul Paredes <saulparedes@microsoft.com>
2024-12-02 08:28:58 -08:00
Aurélien Bombo
eac197d3b7
Merge pull request #10564 from microsoft/danmihai1/clh-endpoint-type
runtime: clh: addNet() logging clean-up
2024-11-27 14:44:14 -06:00
Steve Horsman
6bb00d9a1d
Merge pull request #10583 from squarti/agent-startup-cdh-client
agent: fix startup when guest_components_procs is set to none
2024-11-27 11:43:07 +00:00
Silenio Quarti
1230bc77f2 agent: fix startup when guest_components_procs is set to none
This PR ensures that OCICRYPT_CONFIG_PATH file is initialized only
when CDH socket exists. This prevents startup error if attestation
binaries are not installed in PodVM.

Fixes: https://github.com/kata-containers/kata-containers/issues/10568

Signed-off-by: Silenio Quarti <silenio_quarti@ca.ibm.com>
2024-11-26 09:57:04 -05:00
Fupan Li
28166c8a32
Merge pull request #10577 from Apokleos/fix-vfiodev-name
runtime-rs: fix vfio device name combination issue
2024-11-26 09:35:45 +08:00
Dan Mihai
d93900c128
Merge pull request #10543 from microsoft/danmihai1/regorus-warning
genpolicy: avoid regorus warning
2024-11-25 16:47:33 -08:00
Dan Mihai
f340b31c41 genpolicy: avoid regorus warning
Avoid adding to the Guest console warnings about "agent_policy:10:8".

"import input" is unnecessary.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2024-11-25 21:19:01 +00:00
Dan Mihai
78cbf33f1d runtime: clh: addNet() logging clean-up
Avoid logging the same endpoint fields twice from addNet().

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2024-11-25 19:58:54 +00:00
alex.lyn
5dba680afb runtime-rs: fix vfio device name combination issue
Fixes #10576

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2024-11-25 14:01:43 +08:00
Hyounggyu Choi
48e2df53f7 runtime-rs: Add devno to DeviceVirtioScsi
A new attribute named `devno` is added to DeviceVirtioScsi.
It will be used to specify a device number for a CCW bus type.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2024-11-23 13:45:36 +01:00
Hyounggyu Choi
2cc48f7822 runtime-rs: Add devno to DeviceVhostUserFs
A new attribute named `devno` is added to DeviceVhostUserFs.
It will be used to specify a device number for a CCW bus type.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2024-11-23 13:45:36 +01:00
Hyounggyu Choi
920484918c runtime-rs: Add devno to VhostVsock
A new attribute named `devno` is added to VhostVsock.
It will be used to specify a device number for a CCW bus type.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2024-11-23 13:45:36 +01:00
Hyounggyu Choi
9486790089 runtime-rs: Add devno to DeviceVirtioSerial
A new attribute named `devno` is added to DeviceVirtioSerial.
It will be used to specify a device number for a CCW bus type.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2024-11-23 13:45:36 +01:00
Hyounggyu Choi
516daecc50 runtime-rs: Add devno to DeviceVirtioBlk
A new attribute named `devno` is added to DeviceVirtioBlk.
It will be used to specify a device number for a CCW bus type.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2024-11-23 13:45:36 +01:00
Hyounggyu Choi
30a64092a7 runtime-rs: Add CcwSubChannel to provide devno for CCW devices
To explicitly specify a device number on the QEMU command line
for the following devices using the CCW transport on s390x:

- SerialDevice
- BlockDevice
- VhostUserDevice
- SCSIController
- VSOCKDevice

this commit introduces a new structure CcwSubChannel and implements
the following methods:

- add_device()
- remove_device()
- address_format_ccw()
- set_addr()

You can see the detailed explanation for each method in the comment.

This resolves the 1st part of #10573.

Signed-off-by: Hyounggyu Choi <Hyounggyu.Choi@ibm.com>
2024-11-23 13:45:36 +01:00
Zvonko Kaiser
e9f36f8187 ci: Fixing simple typo
change evn to env

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2024-11-20 18:40:14 +00:00
Zvonko Kaiser
a5733877a4 ci: Fix error on self-hosted machines
We need to clean-up any created files/dirs otherwise
we cause problems on self-hosted runners. Using tempdir which
will be removed automatically.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2024-11-20 18:40:13 +00:00
Saul Paredes
eab48c9884
Merge pull request #10545 from microsoft/cameronbaird/sync-clh-logging
runtime: fix comment to accurately reflect clh behavior
2024-11-18 11:25:58 -08:00
Steve Horsman
0ce3f5fc6f
Merge pull request #10514 from squarti/pause_command
agent: overwrite OCI process spec when overwriting pause image
2024-11-15 18:03:58 +00:00
Cameron Baird
65881ceb8a runtime: fix comment to accurately reflect clh behavior
Fix the CLH log levels description

Signed-off-by: Cameron Baird <cameronbaird@microsoft.com>
2024-11-14 23:16:11 +00:00
Silenio Quarti
42b6203493 agent: overwrite OCI process spec when overwriting pause image
The PR replaces the OCI process spec of the pause container with the spec of
the guest provided pause bundle.

Fixes: https://github.com/kata-containers/kata-containers/issues/10537

Signed-off-by: Silenio Quarti <silenio_quarti@ca.ibm.com>
2024-11-14 13:05:16 -05:00
Hyounggyu Choi
5869046d04
Merge pull request #9195 from UiPath/fix/vcpus-for-static-mgmt
runtime: Set maxvcpus equal to vcpus for the static resources case
2024-11-14 09:38:20 +01:00
Dan Mihai
d9977b3e75
Merge pull request #10431 from microsoft/saulparedes/add-policy-state
genpolicy: add state to policy
2024-11-13 11:48:46 -08:00
Fabiano Fidêncio
02d4c3efbf
Merge pull request #10519 from fidencio/topic/relax-restriction-for-qemu-tdx
Reapply "runtime: confidential: Do not set the max_vcpu to cpu"
2024-11-13 16:09:06 +01:00
Saul Paredes
c207312260 genpolicy: validate container sandbox names
Make sure all container sandbox names match the sandbox name of the first container.

Signed-off-by: Saul Paredes <saulparedes@microsoft.com>
2024-11-12 15:17:01 -08:00
Saul Paredes
52d1aea1f7 genpolicy: Add state
Use regorous engine's add_data method to add state to the policy.
This data can later be accessed inside rego context through the data namespace.

Support state modifications (json-patches) that may be returned as a result from policy evaluation.

Also initialize a policy engine data slice "pstate" dedicated for storing state.

Fixes #10087

Signed-off-by: Saul Paredes <saulparedes@microsoft.com>
2024-11-12 15:16:53 -08:00
Alexandru Matei
e83f8f8a04 runtime: Set maxvcpus equal to vcpus for the static resources case
Fixes: #9194

Signed-off-by: Alexandru Matei <alexandru.matei@uipath.com>
2024-11-12 16:36:42 +02:00
Fabiano Fidêncio
56812c852f
Reapply "runtime: confidential: Do not set the max_vcpu to cpu"
This reverts commit f15e16b692, as we
don't have to do this since we're relying on the
`static_sandbox_resource_mgmt` feature, which gives us the correct
amount of memory and CPUs to be allocated.

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
2024-11-09 23:20:17 +01:00
Aurélien Bombo
19e972151f gha: Hardcode ubuntu-22.04 instead of latest
GHA is migrating ubuntu-latest to Ubuntu 24 so
let's hardcode the current 22.04 LTS.

https://github.blog/changelog/2024-11-05-notice-of-breaking-changes-for-github-actions/

Signed-off-by: Aurélien Bombo <abombo@microsoft.com>
2024-11-08 11:00:15 -06:00
Zvonko Kaiser
183bd2aeed
Merge pull request #9584 from zvonkok/kata-agent-cdi
kata-agent: Add CDI support
2024-11-07 14:18:32 -05:00
Zvonko Kaiser
aa2e1a57bd agent: Added test-case for handle_cdi_devices
We are generating a simple CDI spec with device and
global containerEdits to test the CDI crate.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2024-11-07 17:03:18 +00:00
Fabiano Fidêncio
c332e953f9
Merge pull request #10500 from squarti/fix-10499
runtime: Files are not synced between host and guest VMs
2024-11-07 08:28:53 +01:00
Silenio Quarti
be3ea2675c runtime: Files are not synced between host and guest VMs
This PR makes the root dir absolute after resolving the
default root dir symlink. 

Fixes: https://github.com/kata-containers/kata-containers/issues/10499

Signed-off-by: Silenio Quarti <silenio_quarti@ca.ibm.com>
2024-11-06 17:31:12 -05:00
Zvonko Kaiser
3995fe71f9 kata-agent: Add CDI support
For proper device handling add CDI support

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
2024-11-06 17:50:20 +00:00
Fabiano Fidêncio
7d3f2f7200 runtime: Match TEEs for the static_sandbox_resource_mgmt option
The qemu-coco-dev runtime class should be as close as possible to what
the TEEs runtime classes are doing, and this was one of the options that
ended up overlooked till now.

Shout out to Dan Mihai for noticing that!

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
2024-11-06 10:47:08 +01:00
Fabiano Fidêncio
ea8114833c
Merge pull request #10491 from fidencio/topic/fix-typo-in-the-ephemeral-handler
agent: fix typo on getting EphemeralHandler size option
2024-11-06 10:31:48 +01:00
Fabiano Fidêncio
77c87a0990 agent: fix typo on getting EphemeralHandler size option
Most likely this was overlooked during the development / review, but
we're actually interested on the size rather than on the pagesize of the
hugepages.

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
2024-11-05 15:15:17 +01:00
Aurélien Bombo
f639d3e87c
Merge pull request #10395 from Sumynwa/sumsharma/create_container
agent-ctl: Add support to test kata-agent's container creation APIs.
2024-11-04 14:09:12 -06:00
Steve Horsman
a2b9527be3
Merge pull request #10481 from mkulke/mkulke/init-cdh-client-on-gcprocs-none
agent: perform attestation init w/o process launch
2024-11-04 17:27:45 +00:00
Magnus Kulke
bf769851f8 agent: perform attestation init w/o process launch
This change is motivated by a problem in peerpod's podvms. In this setup
the lifecycle of guest components is managed by systemd. The current code
skips over init steps like setting the ocicrypt-rs env and initialization
of a CDH client in this case.

To address this the launch of the processes has been isolated into its
own fn.

Signed-off-by: Magnus Kulke <magnuskulke@microsoft.com>
2024-11-04 13:31:07 +01:00
Steve Horsman
06d2cc7239
Merge pull request #10453 from bpradipt/remote-annotation
runtime: Add GPU annotations for remote hypervisor
2024-11-04 09:10:06 +00:00
Sumedh Alok Sharma
4b7aba5c57 agent-ctl: Add support to test kata-agent's container creation APIs.
This commit introduces changes to enable testing kata-agent's container
APIs of CreateContainer/StartContainer/RemoveContainer. The changeset
include:
- using confidential-containers image-rs crate to pull/unpack/mount a
container image. Currently supports only un-authenicated registry pull
- re-factor api handlers to reduce cmdline complexity and handle
request generation logic in tool
- introduce an OCI config template for container creation
- add test case

Fixes #9707

Signed-off-by: Sumedh Alok Sharma <sumsharma@microsoft.com>
2024-11-01 22:18:54 +05:30
Markus Rudy
df5e6e65b5 protocols: only build RLimit impls on Linux
The current version of the oci-spec crate compiles RLimit structs only
for Linux and Solaris. Until this is fixed upstream, add compilation
conditions to the type converters for the affected structs.

Fixes: #10071

Signed-off-by: Markus Rudy <mr@edgeless.systems>
2024-10-31 09:50:36 +01:00
Markus Rudy
091a410b96 kata-sys-util: move json parsing to protocols crate
The parse_json_string function is specific to parsing capability strings
out of ttRPC proto definitions and does not benefit from being available
to other crates. Moving it into the protocols crate allows removing
kata-sys-util as a dependency, which in turn enables compiling the
library on darwin.

Fixes: #10071

Signed-off-by: Markus Rudy <mr@edgeless.systems>
2024-10-31 09:41:07 +01:00
Markus Rudy
8ab4bd2bfc kata-sys-util: remove obsolete cgroups dependency
The cgroups.rs source file was removed in
234d7bca04. With cgroups support handled
in runtime-rs, the cgroups dependency on kata-sys-util can be removed.

Signed-off-by: Markus Rudy <mr@edgeless.systems>
2024-10-31 09:41:07 +01:00
Chasing1020
425f6ad4e6 runtime-rs: add oci spec for prepare_vm method
The cloud-api-adaptor needs to support different types of pod VM
instance.
We needs to pass some annotations like machine_type, default_vcpus and
default_memory to prepare the VMs.

Signed-off-by: Chasing1020 <643601464@qq.com>
2024-10-30 01:01:28 +08:00
Chasing1020
f1167645f3 runtime-rs: support for remote hypervisors type
This patch adds the support of the remote hypervisor type for runtime-rs.
The cloud-api-adaptor needs the annotations and network namespace path
to create the VMs.
The remote hypervisor opens a UNIX domain socket specified in the config
file, and sends ttrpc requests to a external process to control sandbox
VMs.

Fixes: #10350

Signed-off-by: Chasing1020 <643601464@qq.com>
2024-10-30 00:54:17 +08:00
Pradipta Banerjee
6f1ba007ed runtime: Add GPU annotations for remote hypervisor
Add GPU annotations for remote hypervisor to help
with the right instance selection based on number of GPUs
and model

Signed-off-by: Pradipta Banerjee <pradipta.banerjee@gmail.com>
2024-10-29 10:28:21 -04:00
Aurélien Bombo
eb04caaf8f
Merge pull request #10074 from koct9i/log-vm-start-error
runtime: log vm start error before cleanup
2024-10-28 14:39:00 -05:00
Fabiano Fidêncio
d23d057ac7
runtime: Enable measured rootfs for qemu-coco-dev
Let's make sure we are prepared to test this with non-TEE environments
as well.

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
2024-10-28 12:43:53 +01:00
Fabiano Fidêncio
ef29824db9
runtime: Don't do measured rootfs for "vanilla" kernel
We may decide to add this later on, but for now this is only targetting
TEEs and the confidential image / initrd.

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
2024-10-28 12:43:53 +01:00
Konstantin Khlebnikov
ee50582848 runtime: log vm start error before cleanup
Return of proper error to the initiator is not guaranteed.
Method StopVM could kill shim process together with VM pieces.

Signed-off-by: Konstantin Khlebnikov <koct9i@gmail.com>
2024-10-28 11:21:21 +01:00
Simon Kaegi
322846b36f agent: Correct rustjail device filemode permission typo
Corrects device filemode permissions typo/regression in rustjail to `666` instead of `066`.
`666` is the standard and expected value for these devices in containers.

Fixes: #10454

Signed-off-by: Simon Kaegi <simon.kaegi@gmail.com>
2024-10-24 16:46:40 -04:00
Greg Kurz
378f454fb9
Merge pull request #10208 from wtootw/main
runtime: Failed to clean up resources when QEMU is terminated
2024-10-23 12:11:57 +02:00
wangyaqi54
cf4b81344d runtime: Failed to clean up resources when QEMU is terminated by signal 15
When QEMU is terminated by signal 15, it deletes the PidFile.
Upon detecting that QEMU has exited, the shim executes the stopVM function.
If the PidFile is not found, the PID is set to 0.
Subsequently, the shim executes `kill -9 0`, which terminates the current process group.
This prevents any further logic from being executed, resulting in resources not being cleaned up.

Signed-off-by: wangyaqi54 <wangyaqi54@jd.com>
2024-10-22 17:04:46 +08:00
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
alex.lyn
3dabe0f5f0 kata-agent: fixing bug of unable setting hostname correctly.
When do update_container_namespaces updating namespaces, setting
all UTS(and IPC) namespace paths to None resulted in hostnames
set prior to the update becoming ineffective. This was primarily
due to an error made while aligning with the oci spec: in an attempt
to match empty strings with None values in oci-spec-rs, all paths
were incorrectly set to None.

Fixes #10325

Signed-off-by: alex.lyn <alex.lyn@antgroup.com>
2024-10-21 16:32:56 +01: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
stevenhorsman
4adb454ed0 agent: config: Use rstest for unit tests
Use rstest for unit test rather than TestData arrays where
possible to make the code more compact, easier to read
and open the possibility to enhance test cases with a
description more easily.

Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2024-10-16 16:55:44 +01:00
Leonard Cohnen
c06bf2e3bb genpolicy: read binaryData value as String
While Kubernetes defines `binaryData` as `[]byte`,
when defined in a YAML file the raw bytes are
base64 encoded. Therefore, we need to read the YAML
value as `String` and not as `Vec<u8>`.

Fixes: #10410

Signed-off-by: Leonard Cohnen <lc@edgeless.systems>
2024-10-14 20:03:11 +02:00
ChengyuZhu6
65ecac5777 agent:cdh: fix unit tests about sealed secret
The root cause is that the CDH client is a global variable, and unit tests `test_unseal_env` and `test_unseal_file`
share this lock-free global variable, leading to resource contention and destruction.
Merging the two unit tests into one test_sealed_secret will resolve this issue.

Fixes: #10403

Signed-off-by: ChengyuZhu6 <zhucy0405@gmail.com>
2024-10-10 08:38:06 +08:00
ChengyuZhu6
a992feb7f3 Revert "Revert "agent:cdh: unittest for sealed secret as file""
This reverts commit b5142c94b9.

Signed-off-by: ChengyuZhu6 <zhucy0405@gmail.com>
2024-10-10 08:37:06 +08:00
Fabiano Fidêncio
b5142c94b9
Revert "agent:cdh: unittest for sealed secret as file"
This reverts commit 31e09058af, as it's
breaking the agent unit tests CI.

This is a stop gap till Chengyu Zhu finds the time to properly address
the issue, avoiding the CI to be blocked for now.

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
2024-10-09 16:06:09 +02:00
ChengyuZhu6
fe307303c8 agent:rpc: Refactor CDH-related operations
Refactor CDH-related operations into the cdh_handler function to make the `create_container` code clearer.

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
2024-10-08 16:01:48 +08:00
ChengyuZhu6
31e09058af agent:cdh: unittest for sealed secret as file
add unittest for sealed secret as file.

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
Signed-off-by: Linda Yu <linda.yu@intel.com>
2024-10-08 16:01:48 +08:00
ChengyuZhu6
974d6b0736 agent:cdh: initialize cdhclient with the input cdh socket uri
Refactor cdh code to initialize cdhclient with the input cdh socket uri.

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
2024-10-08 14:58:07 +08:00
ChengyuZhu6
1f33fd4cd4 agent:rpc: handle the sealed secret in createcontainer
Users must set the mount path to `/sealed/<path>` for kata agent to detect the sealed secret mount
and handle it in createcontainer stage.

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
Signed-off-by: Linda Yu <linda.yu@intel.com>
2024-10-08 14:58:07 +08:00
ChengyuZhu6
da281b4444 agent:cdh: support to unseal secret as file
Introduced `unseal_file` function to unseal secret as files:
- Implemented logic to handle symlinks and regular files within the sealed secret directory.
- For each entry, call CDH to unseal secrets and the unsealed contents are written to a new file, and a symlink is created to replace the sealed symlink.

Fixes: #8123

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
Signed-off-by: Linda Yu <linda.yu@intel.com>
2024-10-08 14:58:07 +08: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
Dan Mihai
7fe44d3a3d genpolicy: validate create sandbox storages
Reject any unexpected values from the CreateSandboxRequest storages
field.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2024-09-30 11:31:12 -07: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
Xuewei Niu
11b1a72442
Merge pull request #10349 from lifupan/main_nsandboxapi
sandbox: refactor the sandbox init process
2024-09-27 11:10:45 +08:00
Xuewei Niu
3911bd3108
Merge pull request #10351 from lifupan/main_agent
agent: fix the issue of setup sandbox pidns
2024-09-27 10:49:47 +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
Fupan Li
71afeccdf1 agent: fix the issue of setup sandbox pidns
When the sandbox api was enabled, the pasue container
wouldn't be created, thus the shared sandbox pidns
should be fallbacked to the first container's init process,
instead of return any error here.

Signed-off-by: Fupan Li <fupan.lfp@antgroup.com>
2024-09-26 10:21:25 +08: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
Xuewei Niu
e1825c2ef3
Merge pull request #9977 from l8huang/dan-2-vfio
runtime: add DAN support for VFIO network device in Go kata-runtime
2024-09-25 10:11:38 +08:00
Lei Huang
39b0e9aa8f runtime: add DAN support for VFIO network device in Go kata-runtime
When using network adapters that support SR-IOV, a VFIO device can be
plugged into a guest VM and claimed as a network interface. This can
significantly enhance network performance.

Fixes: #9758

Signed-off-by: Lei Huang <leih@nvidia.com>
2024-09-24 09:53:28 -07: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
Fabiano Fidêncio
e9593b53a4
Merge pull request #10234 from pmores/add-support-for-disabled-guest-selinux
runtime-rs: add support for disabled guest selinux
2024-09-19 15:03:24 +02:00
Fabiano Fidêncio
4d11fecc2d
Merge pull request #10274 from ajaypvictor/remote_image-os_types
runtime: Enable Image annotation for remote hypervisor
2024-09-19 13:39:20 +02:00
Fabiano Fidêncio
3d5f48e02e
Merge pull request #10283 from alexman-stripe/alexman-stripe/fix-kata-shim-not-reporting-inactive-file-cgroup-v2
shim: Fix memory usage reporting for cgroup v2
2024-09-19 12:50:36 +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
Pavel Mores
eb1227f47d runtime-rs: parse the disable_guest_selinux config key
In order to handle the setting we have to first parse it and make its
value available to the rest of the program.

The yes() function is added to comply with serde which seems to insist
on default values being returned from functions.  Long term, this is
surely not the best place for this function to live, however given that
this is currently the first and only place where it's used it seems
appropriate to put it near its use.  If it ends up being reused elsewhere
a better place will surely emerge.

Signed-off-by: Pavel Mores <pmores@redhat.com>
2024-09-19 12:47:10 +02:00
Fabiano Fidêncio
eccdffebf7
Merge pull request #10243 from katexochen/nydus-overlayfs-path
virtcontainers: allow specifying nydus-overlayfs binary by path
2024-09-19 11:35:45 +02:00
Ajay Victor
a19f2eacec runtime: Enable ImageName annotation for remote hypervisor
Enables ImageName to support multiple VM images in remote hypervisor scenario

Fixes https://github.com/kata-containers/kata-containers/issues/10240

Signed-off-by: Ajay Victor <ajvictor@in.ibm.com>
2024-09-19 14:48:46 +05:30
Alex Man
27f8f69195 shim: Fix memory usage reporting for cgroup v2
kata-shim was not reporting `inactive_file` in memory stat.

This memory is deducted by containerd when calculating the size of container working set, as it can be paged out by the operating
system under memory pressure. Without reporting `inactive_file`, containerd will over report container memory usage.
[Here](https://github.com/containerd/containerd/blob/v1.7.22/pkg/cri/server/container_stats_list_linux.go#L117) is where containerd
deducts `inactive_file` from memory usage.

Note that kata-shim correctly reports `total_inactive_file` for cgroup v1, but this was not implemented for cgroup v2.

This commit:
- Adds code in kata-shim to report "inactive_file" memory for cgroup v2
- Implements reporting of all available cgroup v2 memory stats to containerd
- Uses defensive coding to avoid assuming existence of any memory.stat fields

The list of available cgroup v2 memory stats defined by containerd can be found
[here](https://pkg.go.dev/github.com/containerd/cgroups/v2/stats#MemoryStat).

Fixes #10280

Signed-off-by: Alex Man <alexman@stripe.com>
2024-09-18 14:04:24 -07:00
Fabiano Fidêncio
1597f8ba00
Merge pull request #10279 from alexman-stripe/alexman-stripe/fix-cgroup-v2-wrong-cpu-usage-unit
agent: Fix CPU usage reporting for cgroup v2 in kata-agent
2024-09-18 21:36:52 +02:00
Fabiano Fidêncio
593cbb8710
Merge pull request #10306 from microsoft/danmihai1/more-security-contexts
genpolicy: get UID from PodSecurityContext
2024-09-18 21:33:39 +02:00
Sumedh Alok Sharma
18c887f055 agent-ctl: Add SetPolicy support
This patch adds support to call kata agents SetPolicy
API. Also adds tests for SetPolicy API using agent-ctl.

Fixes #9711

Signed-off-by: Sumedh Alok Sharma <sumsharma@microsoft.com>
2024-09-18 10:53:49 +05:30
Sumedh Alok Sharma
cefba08903 agent: add support to provide default agent policy via env
agent built with policy feature initializes the policy engine using a
policy document from a default path, which is installed & linked during
UVM rootfs build. This commit adds support to provide a default agent
policy as environment variable.

This targets development/testing scenarios where kata-agent
is wanted to be started as a local process.

Fixes #10301

Signed-off-by: Sumedh Alok Sharma <sumsharma@microsoft.com>
2024-09-16 18:05:21 +05:30
Xynnn007
9606e7ac8b agent: Set image-rs image security policy
Add two parameters for enabling cosign signature image verification.
- `enable_signature_verification`: to activate signature verification
- `image_policy`: URI of the image policy
config

Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
2024-09-16 09:20:57 +01:00
Xynnn007
653bc3973f agent: fix make test for kata-agent of dependency anyhow
new version of the anyhow crate has changed the backtrace capture thus
unit tests of kata-agent that compares a raised error with an expected
one would fail. To fix this, we need only panics to have backtraces,
thus set `RUST_BACKTRACE=1` and `RUST_LIB_BACKTRACE=0` for tests due to
document

https://docs.rs/anyhow/latest/anyhow/

Signed-off-by: Xynnn007 <xynnn@linux.alibaba.com>
2024-09-16 09:20:57 +01:00
Dan Mihai
16f5ebf5f9 genpolicy: get UID from PodSecurityContext
Get UID from PodSecurityContext for other k8s resource types too,
not just for Pods.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2024-09-13 22:05:31 +00: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
stevenhorsman
00e657cdb7 agent: image-rs: Update to v0.10.0 release
Update image-rs to use the latest release of guest-components

Signed-off-by: stevenhorsman <steven@uk.ibm.com>
2024-09-13 13:29:54 +01:00
Dan Mihai
d2d8d2e519 genpolicy: remove default UID/GID values
Remove the recently added default UID/GID values, because the genpolicy
design is to initialize those fields before this new code path gets
executed.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2024-09-11 22:38:20 +00:00
Hernan Gatta
871476c3cb genpolicy: pull UID:GID values from /etc/passwd
Some container images are configured such that the user (and group)
under which their entrypoint should run is not a number (or pair of
numbers), but a user name.

For example, in a Dockerfile, one might write:

> USER 185

indicating that the entrypoint should run under UID=185.

Some images, however, might have:

> RUN groupadd --system --gid=185 spark
> RUN useradd --system --uid=185 --gid=spark spark
> ...
> USER spark

indicating that the UID:GID pair should be resolved at runtime via
/etc/passwd.

To handle such images correctly, read through all /etc/passwd files in
all layers, find the latest version of it (i.e., the top-most layer with
such a file), and, in so doing, ensure that whiteouts of this file are
respected (i.e., if one layer adds the file and some subsequent layer
removes it, don't use it).

Signed-off-by: Hernan Gatta <hernan.gatta@opaque.co>
2024-09-11 22:38:20 +00:00
Hernan Gatta
f9249b4476 genpolicy: add tar dependency
Used to read /etc/passwd from tar files.

Signed-off-by: Hernan Gatta <hernan.gatta@opaque.co>
2024-09-11 22:38:20 +00:00
Dan Mihai
eb7f747df1 genpolicy: enable create container UID verification
Disabling the UID Policy rule was a workaround for #9928. Re-enable
that rule here and add a new test/CI temporary workaround for this
issue. This new test workaround will be removed after fixing #9928.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
2024-09-11 22:38:20 +00:00
Fabiano Fidêncio
97ecdabde9
Merge pull request #10294 from fidencio/topic/bring-ita-support
Bump guest-components / trustee to a version that supports ITA
2024-09-11 19:45:48 +02:00
Alex Man
7e400f7bb2 agent: Fix CPU usage reporting for cgroup v2 in kata-agent
kata-agent incorrectly reports CPU time for cgroup v2, causing 1000x underreporting.

For cgroup v2, kata-agent reads the cpu.stat file, which reports the time consumed by the processes in the cgroup in µs.
However, there was a bug in kata-agent where it returned this value in µs without converting it to ns.

This commit adds the necessary µs to ns conversion for cgroup v2, aligning it with v1 behavior and kata-shim's expectations.

This fixes #10278

Signed-off-by: Alex Man <alexman@stripe.com>
2024-09-11 10:29:03 -07:00
Fabiano Fidêncio
f94d80783d
agent: image-rs: Update to a version that supports ITA
ITA stands for Intel Trust Authority, which is in the process to being
renamed to ITTS (Intel Tiber Trust Services).

As we've bumped guest-components on trustee, let's make sure we also
bump image-rs to the commit that brings ITA support in:
* 1db6c3a876

The reason we need to bump the dependency here is to avoid kbs_protocol
mismatch between the version used by the agent and the trustee one.

Signed-off-by: Fabiano Fidêncio <fabiano@fidencio.org>
2024-09-11 13:36:46 +02:00
Sumedh Alok Sharma
2af1113426 agent-ctl: Refactor CopyFile handler
In the existing implementation for the CopyFile subcommand,
- cmd line argument list is too long, including various metadata information.
- in case of a regular file, passing the actual data as bytes stream adds to the size and complexity of the input.
- the copy request will fail when the file size exceeds that of the allowed ttrpc max data length limit of 4Mb.

This change refactors the CopyFile handler and modifies the input to a known 'source' 'destination' syntax.

Fixes #9708

Signed-off-by: Sumedh Alok Sharma <sumsharma@microsoft.com>
2024-09-11 10:54:01 +05:30
Alex Lyn
d0968032f7
Merge pull request #10276 from Apokleos/fix-runtime-cdi
runtime: Fix runtime/cdi panic with assignment to entry in nil map
2024-09-11 09:00:11 +08: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
Alex Lyn
1684c1962c runtime: Fix runtime/cdi panic with assignment to entry in nil map
It will panic when users do GPU vfio passthrough with cdi in runtime.
The root cause is that CustomSpec.Annotations is nil when new element
added.
To address this issue, initialization is introduced when it's nil.

Fixes #10266

Signed-off-by: Alex Lyn <alex.lyn@antgroup.com>
2024-09-09 20:15:10 +08:00
Alex Lyn
f31839af63
Merge pull request #10253 from teawater/enable_balloon_f_reporting
Add support of dragonball virtio-balloon free page reporting
2024-09-09 17:37:52 +08:00
Fabiano Fidêncio
026a4d92a9
Merge pull request #10272 from fidencio/topic/add-tdx-mrconfigid-mrowner-mrownerconfig-support
runtime: qemu: tdx: Add support for setting mrconfigid / mrowner / mrownerconfig
2024-09-08 14:11:30 +02:00
ChengyuZhu6
75816d17f1 agent: switch to new device subsystem
Switch to new device subsystem to handle various devices in kata-agent.

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
2024-09-07 09:45:43 +08:00
ChengyuZhu6
df55f37dfe agent: Move unit tests about vfio device to vfio_device_handler
Move unit tests about vfio device to vfio_device_handler.

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
2024-09-07 09:45:43 +08:00
ChengyuZhu6
41c2d81fd3 agent: Move unit tests about scsi device to scsi_device_handler
Move unit tests about scsi device to scsi_device_handler.

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
2024-09-07 09:45:43 +08:00
ChengyuZhu6
f45129cb44 agent: Move unit tests about network device to network_device_handler
Move unit tests about network device to network_device_handler.

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
2024-09-07 09:45:43 +08:00
ChengyuZhu6
52203db760 agent: Move unit tests about block device to block_device_handler
Move unit tests about block device to block_device_handler.

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
2024-09-07 09:45:43 +08:00
ChengyuZhu6
e1afb92a28 agent: Move common unit tests about device
Move common unit tests about device to mod.rs

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
2024-09-07 09:45:43 +08:00
ChengyuZhu6
25bd04c02a agent: Use DeviceHandlerManager to handle various devices
Use DeviceHandlerManager to handle various devices.

Fixes: #10218

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
2024-09-07 09:45:42 +08:00
ChengyuZhu6
5fc645c869 agent: Move network device code to network_device_handler
Move network device code to network_device_handler to simplify the code.

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
2024-09-07 09:40:30 +08:00
ChengyuZhu6
07f104085a agent: Move vfio device code to vfio_device_handler
Move vfio device code to vfio_device_handler to simplify the code.

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
2024-09-07 09:40:30 +08:00
ChengyuZhu6
0cb87767ae agent: Move device code with virtio scsi driver to scsi_device_handler
Move scsi device code to scsi_device_handler to simplify the code.

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
2024-09-07 09:40:30 +08:00
ChengyuZhu6
0738d75a92 agent: Move device code with nvdimm driver to nvdimm_device_handler
Move device code with nvdimm driver to nvdimm_device_handler, including
nvdimm device and pmem device.

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
2024-09-07 09:40:30 +08:00
ChengyuZhu6
bbf934161b agent: Move virtio-block device handlers to block_device_handler
Move virtio-block device handlers to block_device_handler to simplify
the code.

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
2024-09-07 09:40:30 +08:00
ChengyuZhu6
4e33665be8 kata-types: Move device driver constants to kata-types
Move device driver constants and add DeviceHandlerManager type alias.

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
2024-09-07 09:40:30 +08:00
ChengyuZhu6
0b3ad2f830 kata-types: Replace StorageHandlerManager with type alias
Removed the `StorageHandlerManager` struct and its associated implementations and
introduced a type alias `StorageHandlerManager` for `HandlerManager` to simplify the code.
The new type alias maintains the same functionality while reducing redundancy.

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
2024-09-07 07:53:31 +08:00
ChengyuZhu6
281f0d7f29 kata-types: Add HandlerManager to manage registered handlers
Introduced `HandlerManager` struct to manage registered handlers, which will be used to storage and device management for kata-agent.

Signed-off-by: ChengyuZhu6 <chengyu.zhu@intel.com>
2024-09-07 07:51:48 +08:00