mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-18 07:18:27 +00:00
Merge pull request #4166 from jodh-intel/agent-ctl-fix-abstract
agent-ctl: Fix abstract socket connections
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
The Kata Containers agent control tool (`kata-agent-ctl`) is a low-level test
|
||||
tool. It allows basic interaction with the Kata Containers agent,
|
||||
`kata-agent`, that runs inside the virtual machine.
|
||||
`kata-agent`, that runs inside the virtual machine (VM).
|
||||
|
||||
Unlike the Kata Runtime, which only ever makes sequences of correctly ordered
|
||||
and valid agent API calls, this tool allows users to make arbitrary agent API
|
||||
@@ -117,7 +117,7 @@ establish the VSOCK guest CID value to connect to the agent.
|
||||
|
||||
1. Start a Kata Container
|
||||
|
||||
1. Establish the VSOCK guest CID number for the virtual machine:
|
||||
1. Establish the VSOCK guest CID number for the VM:
|
||||
|
||||
```sh
|
||||
$ guest_cid=$(sudo ss -H --vsock | awk '{print $6}' | cut -d: -f1)
|
||||
@@ -211,10 +211,12 @@ $ sudo install -o root -g root -m 0755 ~/.cargo/bin/kata-agent-ctl /usr/local/bi
|
||||
|
||||
> **Warnings:**
|
||||
>
|
||||
> - This method is **only** for testing and development!
|
||||
> - These methods are **only** for testing and development!
|
||||
> - Only continue if you are using a non-critical system
|
||||
> (such as a freshly installed VM environment).
|
||||
|
||||
#### Use a Unix abstract domain socket
|
||||
|
||||
1. Start the agent, specifying a local socket for it to communicate on:
|
||||
|
||||
```sh
|
||||
@@ -233,3 +235,31 @@ $ sudo install -o root -g root -m 0755 ~/.cargo/bin/kata-agent-ctl /usr/local/bi
|
||||
>
|
||||
> The `@` in the server address is required - it denotes an abstract
|
||||
> socket which the agent requires (see `unix(7)`).
|
||||
|
||||
#### Use a VSOCK loopback socket
|
||||
|
||||
VSOCK supports a special CID value of `1` (known symbolically as
|
||||
`VMADDR_CID_LOCAL`) which assumes that the VM is actually
|
||||
the local environment. This is effectively a `localhost` or loopback
|
||||
interface which does not require an actual VM to be
|
||||
running.
|
||||
|
||||
1. Start the agent, specifying the local VSOCK socket for it to communicate on:
|
||||
|
||||
```sh
|
||||
$ vsock_loopback_cid=1
|
||||
$ agent_vsock_port=1024
|
||||
|
||||
$ sudo KATA_AGENT_SERVER_ADDR="vsock://${vsock_loopback_cid}:${agent_vsock_port}" target/x86_64-unknown-linux-musl/release/kata-agent
|
||||
```
|
||||
|
||||
> **Note:** This example assumes an Intel x86-64 system.
|
||||
|
||||
1. Run the tool in the same environment:
|
||||
|
||||
```sh
|
||||
$ vsock_loopback_cid=1
|
||||
$ agent_vsock_port=1024
|
||||
|
||||
$ cargo run -- -l debug connect --server-address "vsock://${vsock_loopback_cid}:${agent_vsock_port}" --bundle-dir "$bundle_dir" -c Check -c GetGuestDetails
|
||||
```
|
||||
|
@@ -473,10 +473,8 @@ fn create_ttrpc_client(
|
||||
if path.starts_with('@') {
|
||||
abstract_socket = true;
|
||||
|
||||
// Remove the magic abstract-socket request character ('@')
|
||||
// and crucially add a trailing nul terminator (required to
|
||||
// interoperate with the ttrpc crate).
|
||||
path = path[1..].to_string() + &"\x00".to_string();
|
||||
// Remove the magic abstract-socket request character ('@').
|
||||
path = path[1..].to_string();
|
||||
}
|
||||
|
||||
if abstract_socket {
|
||||
|
Reference in New Issue
Block a user