Crates.io | dbs-upcall |
lib.rs | dbs-upcall |
version | 0.3.0 |
source | src |
created_at | 2022-11-08 11:47:26.132434 |
updated_at | 2023-03-01 03:48:40.311651 |
description | dbs-upcall is a direct communication tool between VMM and guest |
homepage | https://github.com/openanolis/dragonball-sandbox |
repository | https://github.com/openanolis/dragonball-sandbox/tree/main/crates/dbs-virtio-devices |
max_upload_size | |
id | 707981 |
size | 124,384 |
dbs-upcall
is a direct communication tool between VMM and guest developed upon vsock. The server side of the upcall is a driver in guest kernel (kernel patches are needed for this feature) and it'll start to serve the requests after the kernel starts. And the client side is in VMM , it'll be a thread that communicates with vsock through uds.
We have accomplished device hotplug / hot-unplug directly through upcall in order to avoid virtualization of ACPI to minimize virtual machines' overhead. And there could be many other usage through this direct communication channel.
The server side of upcall is a driver in guest kernel and the vsock port is 0xDB. After the vsock is connected, upcall related service will be registered and a kthread providing corresponding service will be created. The upcall service thread will first send a message with message type Connect to try to connect with the client side (VMM). After service successfully connects, the service thread will get into a loop for continuously receiving requests from the client side and processing the requests until the service stops.
The service we currently support:
The client side is in VMM and we abstract related logic into this crate dbs-upcall
.
The upcall state machine for the client side:
The client side's workflow:
If step 1 and 2 failed, upcall will try to reconnect. If request is sent in step 3, upcall state will change to ServiceBusy and upcall will not process other requests in this state.
There are two parts for the upcall request message : message header and message load. And there are three parts for the upcall reply messgae: message header, result and message load.
Message Header contains following information and it remains the same for the request and the reply :
For the upcall request message, message load currently contains two kinds of msg_load. msg_load type 1: add_mmio_dev - for virtio-mmio hotplug / hot-unplug request:
msg_load type 2: cpu_dev_info - for cpu hotplug / hot-unplug request:
For the upcall reply message, reply contains result and two kinds of msg_load. If result is 0, the operation is successful. If result is not 0, result refers to the error code.
msg_load type 1: add_mmio_dev - for virtio-mmio reply: currently empty
msg_load type 2: cpu_dev_reply_info - for cpu hotplug / hot-unplug reply:
Kernel patches are needed for dbs-upcall. You could go to kernel patches to get the patches.
0001-dragonball-introduce-dragonball-driver.patch
in /kernel
is needed as a prerequisite to enable upcall.
0001-upcall-add-vsock-server-and-upcall-support.patch
in /kernel/upcall
is the patch for enabling upcall.
The patches have been tested on linux kernel 4.19 (stable).
This project is licensed under Apache License, Version 2.0.