mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: add HTTP API endpoints for generic vhost-user
This includes OpenAPI schemas. Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
This commit is contained in:
committed by
Rob Bradford
parent
d510f11a50
commit
df86b2864b
@@ -168,6 +168,7 @@ impl RequestHandler for StubApiRequestHandler {
|
|||||||
},
|
},
|
||||||
balloon: None,
|
balloon: None,
|
||||||
fs: None,
|
fs: None,
|
||||||
|
generic_vhost_user: None,
|
||||||
pmem: None,
|
pmem: None,
|
||||||
serial: ConsoleConfig {
|
serial: ConsoleConfig {
|
||||||
file: None,
|
file: None,
|
||||||
@@ -254,6 +255,13 @@ impl RequestHandler for StubApiRequestHandler {
|
|||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn vm_add_generic_vhost_user(
|
||||||
|
&mut self,
|
||||||
|
_: GenericVhostUserConfig,
|
||||||
|
) -> Result<Option<Vec<u8>>, VmError> {
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
|
|
||||||
fn vm_add_pmem(&mut self, _: PmemConfig) -> Result<Option<Vec<u8>>, VmError> {
|
fn vm_add_pmem(&mut self, _: PmemConfig) -> Result<Option<Vec<u8>>, VmError> {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,10 +45,11 @@ use crate::api::VmCoredump;
|
|||||||
use crate::api::http::http_endpoint::fds_helper::{attach_fds_to_cfg, attach_fds_to_cfgs};
|
use crate::api::http::http_endpoint::fds_helper::{attach_fds_to_cfg, attach_fds_to_cfgs};
|
||||||
use crate::api::http::{EndpointHandler, HttpError, error_response};
|
use crate::api::http::{EndpointHandler, HttpError, error_response};
|
||||||
use crate::api::{
|
use crate::api::{
|
||||||
AddDisk, ApiAction, ApiError, ApiRequest, NetConfig, VmAddDevice, VmAddFs, VmAddNet, VmAddPmem,
|
AddDisk, ApiAction, ApiError, ApiRequest, NetConfig, VmAddDevice, VmAddFs,
|
||||||
VmAddUserDevice, VmAddVdpa, VmAddVsock, VmBoot, VmConfig, VmCounters, VmDelete, VmNmi, VmPause,
|
VmAddGenericVhostUser, VmAddNet, VmAddPmem, VmAddUserDevice, VmAddVdpa, VmAddVsock, VmBoot,
|
||||||
VmPowerButton, VmReboot, VmReceiveMigration, VmRemoveDevice, VmResize, VmResizeDisk,
|
VmConfig, VmCounters, VmDelete, VmNmi, VmPause, VmPowerButton, VmReboot, VmReceiveMigration,
|
||||||
VmResizeZone, VmRestore, VmResume, VmSendMigration, VmShutdown, VmSnapshot,
|
VmRemoveDevice, VmResize, VmResizeDisk, VmResizeZone, VmRestore, VmResume, VmSendMigration,
|
||||||
|
VmShutdown, VmSnapshot,
|
||||||
};
|
};
|
||||||
use crate::config::RestoreConfig;
|
use crate::config::RestoreConfig;
|
||||||
use crate::cpu::Error as CpuError;
|
use crate::cpu::Error as CpuError;
|
||||||
@@ -419,6 +420,7 @@ vm_action_put_handler!(VmNmi);
|
|||||||
vm_action_put_handler_body!(VmAddDevice);
|
vm_action_put_handler_body!(VmAddDevice);
|
||||||
vm_action_put_handler_body!(AddDisk);
|
vm_action_put_handler_body!(AddDisk);
|
||||||
vm_action_put_handler_body!(VmAddFs);
|
vm_action_put_handler_body!(VmAddFs);
|
||||||
|
vm_action_put_handler_body!(VmAddGenericVhostUser);
|
||||||
vm_action_put_handler_body!(VmAddPmem);
|
vm_action_put_handler_body!(VmAddPmem);
|
||||||
vm_action_put_handler_body!(VmAddVdpa);
|
vm_action_put_handler_body!(VmAddVdpa);
|
||||||
vm_action_put_handler_body!(VmAddVsock);
|
vm_action_put_handler_body!(VmAddVsock);
|
||||||
|
|||||||
@@ -28,10 +28,10 @@ use self::http_endpoint::{VmActionHandler, VmCreate, VmInfo, VmmPing, VmmShutdow
|
|||||||
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
#[cfg(all(target_arch = "x86_64", feature = "guest_debug"))]
|
||||||
use crate::api::VmCoredump;
|
use crate::api::VmCoredump;
|
||||||
use crate::api::{
|
use crate::api::{
|
||||||
AddDisk, ApiError, ApiRequest, VmAddDevice, VmAddFs, VmAddNet, VmAddPmem, VmAddUserDevice,
|
AddDisk, ApiError, ApiRequest, VmAddDevice, VmAddFs, VmAddGenericVhostUser, VmAddNet,
|
||||||
VmAddVdpa, VmAddVsock, VmBoot, VmCounters, VmDelete, VmNmi, VmPause, VmPowerButton, VmReboot,
|
VmAddPmem, VmAddUserDevice, VmAddVdpa, VmAddVsock, VmBoot, VmCounters, VmDelete, VmNmi,
|
||||||
VmReceiveMigration, VmRemoveDevice, VmResize, VmResizeDisk, VmResizeZone, VmRestore, VmResume,
|
VmPause, VmPowerButton, VmReboot, VmReceiveMigration, VmRemoveDevice, VmResize, VmResizeDisk,
|
||||||
VmSendMigration, VmShutdown, VmSnapshot,
|
VmResizeZone, VmRestore, VmResume, VmSendMigration, VmShutdown, VmSnapshot,
|
||||||
};
|
};
|
||||||
use crate::landlock::Landlock;
|
use crate::landlock::Landlock;
|
||||||
use crate::seccomp_filters::{Thread, get_seccomp_filter};
|
use crate::seccomp_filters::{Thread, get_seccomp_filter};
|
||||||
@@ -196,6 +196,10 @@ pub static HTTP_ROUTES: LazyLock<HttpRoutes> = LazyLock::new(|| {
|
|||||||
endpoint!("/vm.add-fs"),
|
endpoint!("/vm.add-fs"),
|
||||||
Box::new(VmActionHandler::new(&VmAddFs)),
|
Box::new(VmActionHandler::new(&VmAddFs)),
|
||||||
);
|
);
|
||||||
|
r.routes.insert(
|
||||||
|
endpoint!("/vm.add-generic-vhost-user"),
|
||||||
|
Box::new(VmActionHandler::new(&VmAddGenericVhostUser)),
|
||||||
|
);
|
||||||
r.routes.insert(
|
r.routes.insert(
|
||||||
endpoint!("/vm.add-net"),
|
endpoint!("/vm.add-net"),
|
||||||
Box::new(VmActionHandler::new(&VmAddNet)),
|
Box::new(VmActionHandler::new(&VmAddNet)),
|
||||||
|
|||||||
@@ -277,6 +277,28 @@ paths:
|
|||||||
500:
|
500:
|
||||||
description: The new device could not be added to the VM instance.
|
description: The new device could not be added to the VM instance.
|
||||||
|
|
||||||
|
/vm.add-generic-vhost-user:
|
||||||
|
put:
|
||||||
|
summary: Add a new generic vhost-user device to the VM
|
||||||
|
requestBody:
|
||||||
|
description: The details of the new generic vhost-user device
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/GenericVhostUserConfig"
|
||||||
|
required: true
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: The new device was successfully added to the VM instance.
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: "#/components/schemas/PciDeviceInfo"
|
||||||
|
204:
|
||||||
|
description: The new device was successfully (cold) added to the VM instance.
|
||||||
|
500:
|
||||||
|
description: The new device could not be added to the VM instance.
|
||||||
|
|
||||||
/vm.add-pmem:
|
/vm.add-pmem:
|
||||||
put:
|
put:
|
||||||
summary: Add a new pmem device to the VM
|
summary: Add a new pmem device to the VM
|
||||||
@@ -603,6 +625,10 @@ components:
|
|||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: "#/components/schemas/FsConfig"
|
$ref: "#/components/schemas/FsConfig"
|
||||||
|
generic-vhost-user:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: "#/components/schemas/GenericVhostUserConfig"
|
||||||
pmem:
|
pmem:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
@@ -1057,6 +1083,26 @@ components:
|
|||||||
id:
|
id:
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
|
GenericVhostUserConfig:
|
||||||
|
required:
|
||||||
|
- queue_sizes
|
||||||
|
- socket
|
||||||
|
- tag
|
||||||
|
- virtio_id
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
socket:
|
||||||
|
type: string
|
||||||
|
queue_size:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: uint16
|
||||||
|
pci_segment:
|
||||||
|
type: integer
|
||||||
|
format: int16
|
||||||
|
virtio_id:
|
||||||
|
type: uint32
|
||||||
|
|
||||||
PmemConfig:
|
PmemConfig:
|
||||||
required:
|
required:
|
||||||
- file
|
- file
|
||||||
|
|||||||
Reference in New Issue
Block a user