Skip to content
Draft
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
8 changes: 8 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Language: Proto
BasedOnStyle: Microsoft
AlignConsecutiveAssignments: Consecutive
BreakBeforeBraces: Attach
IndentWidth: 4
InsertNewlineAtEOF: true
KeepEmptyLines:
AtEndOfFile: true
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6093,6 +6093,7 @@ dependencies = [
"mesh_rpc",
"prost",
"prost-build",
"prost-types",
]

[[package]]
Expand Down
1 change: 1 addition & 0 deletions openvmm/openvmm_ttrpc_vmservice/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ mesh.workspace = true
mesh_rpc.workspace = true

prost.workspace = true
prost-types.workspace = true

[build-dependencies]
mesh_build.workspace = true
Expand Down
11 changes: 10 additions & 1 deletion openvmm/openvmm_ttrpc_vmservice/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,14 @@ fn main() {
.compile_protos(&["src/vmservice.proto"], &["src"])
.unwrap();

println!("cargo:rerun-if-changed=src/vmservice.proto");
// TODO: std::fs::read_dir to (recursively) enumerate all `src/**/*.proto` files
// Tell cargo to recompile if any of these proto files are changed
let _ = [
"src/vmservice.proto",
"src/vmservice.events.proto",
"src/vmservice.resource.proto",
"src/vmservice.scsi.proto",
"src/vmservice.state.proto",
]
.map(|f| println!("cargo:rerun-if-changed={f}"));
}
3 changes: 2 additions & 1 deletion openvmm/openvmm_ttrpc_vmservice/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

//! Rust binadings to the `vmservice.proto` TTRPC API
//! Rust bindings to the `vmservice.proto` TTRPC API

#![expect(missing_docs)]
#![forbid(unsafe_code)]
Expand All @@ -12,5 +12,6 @@
// automated tools do not remove them.
use mesh_rpc as _;
use prost as _;
use prost_types as _;

include!(concat!(env!("OUT_DIR"), "/vmservice.rs"));
97 changes: 97 additions & 0 deletions openvmm/openvmm_ttrpc_vmservice/src/vmservice.events.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

syntax = 'proto3';

package vmservice;
option go_package = "vmservice";

import "google/protobuf/any.proto";
import "google/protobuf/timestamp.proto";

import "vmservice.resource.proto";
import "vmservice.state.proto";

// Subscribe to the events from the specified VM.
message SubscribeVmEventsRequest {
// Event ID to start the stream on.
// Leave empty to subscribe to only the latest events.
optional uint64 event_id = 1;

// Include events for general VM errors.
optional bool include_error_events = 2;
// Include events for VM service operations.
optional bool include_service_events = 3;
// Include events for VM resource operations.
optional bool include_resource_event = 4;
// Include events for VM requests.
optional bool include_request_events = 5;
Comment on lines +27 to +28
}

enum VmEventInitiator {
VM_EVENT_INITIATOR_UNSPECIFIED = 0;
VM_EVENT_INITIATOR_SERVICE = 1;
VM_EVENT_INITIATOR_GUEST = 2;
}

message StackTrace {
google.protobuf.Timestamp timestamp = 1;
string source = 2;
string message = 3;
repeated google.protobuf.Any data = 4;
}

// VmErrorEvent describes an error that occurred in the VM or service.
message VmErrorEvent {
// error code (e.g., an HRESULT or exit status), if applicable
optional uint64 error_code = 1;
// an error string, if applicable
optional string error_message = 2;
repeated StackTrace stack_trace = 3;
}

// VmServiceEvent describes an event associated with the VM service.
message VmServiceEvent {
enum VmServiceEventType {
VM_SERVICE_EVENT_TYPE_UNSPECIFIED = 0;
// Host initiated VM service quit.
VM_SERVICE_EVENT_TYPE_QUIT = 1;
// Unrecoverable error in VM server or worker process.
// Should be preceded by a VmErrorEvent.
VM_SERVICE_EVENT_TYPE_CRASH = 2;
}

VmServiceEventType type = 1;
}

// VmStateEvent describes a VM state change.
message VmStateEvent {
VmState state = 1;
VmEventInitiator initiator = 2;
}

// VmResourceEvent describes an event assoicated with a particular VM resource.
message VmResourceEvent {
VmEventInitiator initiator = 1;
VmResourceOperationType operation = 2;
VmResourceType resource = 3;
google.protobuf.Any settings = 4;
}

message VmEvent {
// ID of the event sent on the stream.
// Stable across VmEvent streams.
uint64 event_id = 1;
google.protobuf.Timestamp timestamp = 2;

string log_id = 3;

// payload contains the event data.
// The payload type may match the EventType field, or could be an Error.
oneof payload {
VmErrorEvent error = 4;
VmServiceEvent service = 5;
VmStateEvent power_state = 6;
VmResourceEvent resource = 7;
}
}
Loading
Loading