Skip to content

Commit

Permalink
Implement VM Service with Cloud Hypervisor (#506)
Browse files Browse the repository at this point in the history
* feat(vm): add initial implementation for managing cloudhypervisor vms

* feat: implement virtual machines with cloud-hypervisor vmm

* feat: successfully mount vm filesystem from initramfs

* feat: implement VM grpc API

* feat: return scope_id in response to build client

* feat: add nested auraed address if exists in vm

* chore: change package visibility

* chore: remove libvirt vm env for auraed

* feat: allocate a fixed set of IPs for VMs

* chore(client): rename vm service in aurae client

* feat: add vms to auraescript

* chore(auraed): remove orphaned changes to pid1 runtime

* chore(auraed): swap println for proper tracing when blocking signals

* chore: update license headers

* chore(auraed): ignore tests that require kvm, and kernel/disk images
  • Loading branch information
mccormickt authored Aug 9, 2024
1 parent dca6fa0 commit 9cffe36
Show file tree
Hide file tree
Showing 31 changed files with 1,752 additions and 4,606 deletions.
831 changes: 726 additions & 105 deletions Cargo.lock

Large diffs are not rendered by default.

78 changes: 50 additions & 28 deletions api/v0/vms/vms.proto
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,58 @@ service VmService {

// Stop one or more VMs.
rpc Stop(VmServiceStopRequest) returns (VmServiceStopResponse) {}

// List all VMs
rpc List(VmServiceListRequest) returns (VmServiceListResponse) {}
}

message VmServiceListRequest{}
message VmServiceListResponse{
repeated VirtualMachineSummary machines = 1;
}

message VirtualMachineSummary {
// The identifier of the VM
string id = 1;

// Status of the VM
string status = 2;

// The memory size of VM
uint32 mem_size_mb = 3;

// The number of vCPUs for the VM
uint32 vcpu_count = 4;

// The path to the VM kernel image
string kernel_img_path = 5;

// Path to the image mounted as the root directory of the VM
string root_dir_path = 6;

// Auraed server address of the VM
string auraed_address = 7;
}

message VmServiceCreateRequest{
VirtualMachine machine = 1;
}

message VmServiceCreateResponse{
string vm_id = 1;
}

message VmServiceFreeRequest{}
message VmServiceFreeResponse{
message VmServiceFreeRequest{
string vm_id = 1;
}
message VmServiceFreeResponse{}

message VmServiceStartRequest{
string vm_id = 1;
}
message VmServiceStartResponse{}
message VmServiceStartResponse{
// Auraed server address of the VM
string auraed_address = 1;
}

message VmServiceStopRequest{
string vm_id = 1;
Expand Down Expand Up @@ -94,46 +127,35 @@ message VirtualMachine {

// Additional drive mount configs
repeated DriveMount drive_mounts = 7;
}

// Static IP configuration for a VM network interface
message IPConfiguration {
// PrimaryAddr specifies, in CIDR notation, the primary address
// and subnet that a network interface will be assigned inside
// the VM.
string primary_addr = 1;

// GatewayAddr specifies the default gateway that a network interface
// should use inside the VM.
string gateway_addr = 2;

// Nameservers is a list of nameservers that the VM will be configured to use internally
repeated string nameservers = 3;
// Auraed server address of the VM
string auraed_address = 8;
}

// Message to specify the block device config for a VM
// Message to specify the root filesystem config for a VM
message RootDrive {
// The path on the host to the filesystem image or device
// The path on the host to the filesystem image
// that will supply the rootfs of the VM.
string host_path = 1;
string image_path = 1;

// Mount the root filesystem as read-write. (Default: false)
bool is_writeable = 2;
// Mount the root filesystem as read-only. (Default: false)
bool read_only = 2;
}

// Message to specify a block device config for a VM
message DriveMount {
// The path on the host to the filesystem image or device
// The path on the host to the filesystem image
// that will be mounted inside the VM.
string host_path = 1;
string image_path = 1;

// The path inside the VM guest at which the filesystem image or device will be mounted.
// The path inside the VM guest at which the filesystem image will be mounted.
string vm_path = 2;

// The filesystem type (i.e. ext4, xfs, etc.), as
// used when mounting the filesystem image inside the VM. The VM guest kernel
// is expected to have support for this filesystem.
string fs_type = 3;

// Mount the root filesystem as read-write. (Default: false)
bool is_writeable = 4;
// Mount the root filesystem as read-only. (Default: false)
bool read_only = 4;
}
14 changes: 12 additions & 2 deletions auraed/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ libcgroups = { git = "https://github.com/containers/youki", rev = "5b62356e377de
libcontainer = { git = "https://github.com/containers/youki", rev = "5b62356e377def45c36c29183c586c4302685cf8", default-features = false, features = [
"v2",
] }
log = "0.4.17"
log = "0.4.21"
netlink-packet-route = "0.13.0" # Used for netlink_packet_route::rtnl::address::nlas definition
nix = { workspace = true, features = ["sched", "mount", "signal"] }
nix = { workspace = true, features = ["sched", "mount", "signal", "net"] }
oci-spec = "0.6.4"
once_cell = "1"
procfs = "0.16.0"
Expand Down Expand Up @@ -77,6 +77,16 @@ uuid = { workspace = true }
validation = { workspace = true, features = ["regex", "tonic"] }
validation_macros = { path = "../crates/validation/macros" }
walkdir = "2"
vmm = { git = "https://github.com/cloud-hypervisor/cloud-hypervisor", tag = "v39.0", default-features = false, features = [
"kvm",
] }
hypervisor = { git = "https://github.com/cloud-hypervisor/cloud-hypervisor", tag = "v39.0", features = [
"kvm",
] }
net_util = { git = "https://github.com/cloud-hypervisor/cloud-hypervisor", tag = "v39.0" }
vmm-sys-util = "0.12.1"
vm-memory = "0.14.1"
seccompiler = "0.4.0"

[dev-dependencies]
futures-util = { workspace = true }
Expand Down
25 changes: 0 additions & 25 deletions auraed/hack/README.md

This file was deleted.

45 changes: 0 additions & 45 deletions auraed/hack/build-container/Dockerfile

This file was deleted.

11 changes: 0 additions & 11 deletions auraed/hack/build-container/README.md

This file was deleted.

36 changes: 0 additions & 36 deletions auraed/hack/build-container/mk-build-container

This file was deleted.

77 changes: 0 additions & 77 deletions auraed/hack/hack.mk

This file was deleted.

Loading

0 comments on commit 9cffe36

Please sign in to comment.