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

vmm: support new sandbox controller api and streaming io #155

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions vmm/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
panic = 'abort'

[dependencies]
containerd-sandbox = {git="https://github.com/kuasar-io/rust-extensions.git"}
containerd-sandbox = { git = "https://github.com/kuasar-io/rust-extensions.git" }
serde = "1.0.139"
lazy_static = "1.4.0"
nix = "0.24.1"
Expand All @@ -20,4 +20,4 @@ async-trait = "0.1"
regex = "1.5.6"

[build-dependencies]
ttrpc-codegen = "0.4"
ttrpc-codegen = { git = "https://github.com/kuasar-io/ttrpc-rust.git", branch = "v0.7.1-kuasar" }
2 changes: 2 additions & 0 deletions vmm/common/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ fn main() {
"src/protos/google/protobuf/descriptor.proto",
"src/protos/google/protobuf/empty.proto",
"src/protos/google/protobuf/timestamp.proto",
"src/protos/streaming.proto",
"src/protos/containerd/types/transfer/data.proto",
];

Codegen::new()
Expand Down
3 changes: 3 additions & 0 deletions vmm/common/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ limitations under the License.
*/

pub mod any;
pub mod data;
pub mod descriptor;
pub mod empty;
pub mod events;
pub mod fieldpath;
pub mod sandbox;
pub mod sandbox_ttrpc;
pub mod streaming;
pub mod streaming_ttrpc;
pub mod timestamp;
29 changes: 29 additions & 0 deletions vmm/common/src/protos/containerd/types/transfer/data.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Copyright The containerd Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

syntax = "proto3";

package containerd.types.transfer;

option go_package = "github.com/containerd/containerd/v2/api/types/transfer";

message Data {
bytes data = 1;
}

message WindowUpdate {
int32 update = 1;
}
9 changes: 3 additions & 6 deletions vmm/common/src/protos/google/protobuf/any.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ syntax = "proto3";
package google.protobuf;

option csharp_namespace = "Google.Protobuf.WellKnownTypes";
option go_package = "google.golang.org/protobuf/types/known/anypb";
option go_package = "github.com/golang/protobuf/ptypes/any";
option java_package = "com.google.protobuf";
option java_outer_classname = "AnyProto";
option java_multiple_files = true;
Expand Down Expand Up @@ -77,13 +77,10 @@ option objc_class_prefix = "GPB";
// Example 4: Pack and unpack a message in Go
//
// foo := &pb.Foo{...}
// any, err := anypb.New(foo)
// if err != nil {
// ...
// }
// any, err := ptypes.MarshalAny(foo)
// ...
// foo := &pb.Foo{}
// if err := any.UnmarshalTo(foo); err != nil {
// if err := ptypes.UnmarshalAny(any, foo); err != nil {
// ...
// }
//
Expand Down
31 changes: 31 additions & 0 deletions vmm/common/src/protos/streaming.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Copyright The containerd Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

syntax = "proto3";

package containerd.services.streaming.v1;

import "google/protobuf/any.proto";

option go_package = "github.com/containerd/containerd/v2/api/services/streaming/v1;streaming";

service Streaming {
rpc Stream(stream google.protobuf.Any) returns (stream google.protobuf.Any);
}

message StreamInit {
string id = 1;
}
80 changes: 70 additions & 10 deletions vmm/sandbox/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 9 additions & 10 deletions vmm/sandbox/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ edition = "2021"
panic = 'abort'

[build-dependencies]
built = { version = "0.7.0", features=["cargo-lock", "dependency-tree", "git2", "chrono", "semver"] }
built = { version = "0.7.0", features = ["cargo-lock", "dependency-tree", "git2", "chrono", "semver"] }

[dependencies]
built = { version = "0.7.0", features=["cargo-lock", "dependency-tree", "git2", "chrono", "semver"] }
clap = { version="4.4.2", features=["derive"] }
built = { version = "0.7.0", features = ["cargo-lock", "dependency-tree", "git2", "chrono", "semver"] }
clap = { version = "4.4.2", features = ["derive"] }
tokio = { version = "1.19.2", features = ["full"] }
containerd-sandbox = {git="https://github.com/kuasar-io/rust-extensions.git"}
containerd-shim = { git="https://github.com/kuasar-io/rust-extensions.git", features=["async"] }
containerd-sandbox = { git = "https://github.com/kuasar-io/rust-extensions.git" }
containerd-shim = { git = "https://github.com/kuasar-io/rust-extensions.git", features = ["async"] }
vmm-common = { path = "../common" }
bytefmt = "0.1.7"
async-trait = "0.1.56"
Expand All @@ -38,7 +38,7 @@ uuid = { version = "1.1.2", features = ["v4"] }
unshare = { version = "0.7.0" }
os_pipe = { version = "0.9.2" }
qapi = { version = "0.8.0", features = ["qmp", "async-tokio-all"] }
qapi-spec = {version = "0.3.1"}
qapi-spec = { version = "0.3.1" }
sandbox-derive = { path = "derive" }
api_client = { git = "https://github.com/cloud-hypervisor/cloud-hypervisor.git" }
rtnetlink = "0.13.1"
Expand All @@ -52,17 +52,16 @@ hostname = "0.3"
path-clean = "1.0.1"

[[bin]]
name = "qemu"
name = "qemu"
path = "src/bin/qemu/main.rs"

[[bin]]
name = "cloud_hypervisor"
name = "cloud_hypervisor"
path = "src/bin/cloud_hypervisor/main.rs"

[[bin]]
name = "stratovirt"
name = "stratovirt"
path = "src/bin/stratovirt/main.rs"

[dev-dependencies]
temp-dir = "0.1.11"

2 changes: 1 addition & 1 deletion vmm/sandbox/src/cloud_hypervisor/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl Hooks<CloudHypervisorVM> for CloudHypervisorHooks {
}

async fn post_start(&self, sandbox: &mut KuasarSandbox<CloudHypervisorVM>) -> Result<()> {
sandbox.data.task_address = sandbox.vm.agent_socket.to_string();
sandbox.data.task_address = format!("ttrpc+{}", sandbox.vm.agent_socket);
// sync clock
sandbox.sync_clock().await;
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion vmm/sandbox/src/container/handler/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub async fn attach_pipe<T: VM + Sync + Send>(
sandbox: &mut KuasarSandbox<T>,
io_devices: &mut Vec<String>,
) -> Result<String> {
let name = if !path.is_empty() && !path.contains("vsock") {
let name = if !path.is_empty() && !path.contains("://") {
let (id, chardev_id) = sandbox.hot_attach_pipe(path).await?;
io_devices.push(id);
chardev_id
Expand Down
2 changes: 1 addition & 1 deletion vmm/sandbox/src/qemu/hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl Hooks<QemuVM> for QemuHooks {
}

async fn post_start(&self, sandbox: &mut KuasarSandbox<QemuVM>) -> Result<()> {
sandbox.data.task_address = sandbox.vm.agent_socket.to_string();
sandbox.data.task_address = format!("ttrpc+{}", sandbox.vm.agent_socket);
// sync clock
sandbox.sync_clock().await;
Ok(())
Expand Down
Loading
Loading