vmm/api: Add vm.add-fs route

Currently unimplemented. Once implemented, this API will allow for
creating virtio-fs devices in the VM after it has booted.

Signed-off-by: Dean Sheather <dean@coder.com>
This commit is contained in:
Dean Sheather
2020-04-14 18:13:48 +10:00
committed by Sebastien Boeuf
parent d35e775ed9
commit bb2139a408
7 changed files with 74 additions and 9 deletions

View File

@@ -4,8 +4,8 @@
//
use crate::api::http_endpoint::{
VmActionHandler, VmAddDevice, VmAddDisk, VmAddNet, VmAddPmem, VmCreate, VmInfo, VmRemoveDevice,
VmResize, VmRestore, VmSnapshot, VmmPing, VmmShutdown,
VmActionHandler, VmAddDevice, VmAddDisk, VmAddFs, VmAddNet, VmAddPmem, VmCreate, VmInfo,
VmRemoveDevice, VmResize, VmRestore, VmSnapshot, VmmPing, VmmShutdown,
};
use crate::api::{ApiRequest, VmAction};
use crate::seccomp_filters::{get_seccomp_filter, Thread};
@@ -70,6 +70,7 @@ lazy_static! {
r.routes.insert(endpoint!("/vm.add-device"), Box::new(VmAddDevice {}));
r.routes.insert(endpoint!("/vm.remove-device"), Box::new(VmRemoveDevice {}));
r.routes.insert(endpoint!("/vm.add-disk"), Box::new(VmAddDisk {}));
r.routes.insert(endpoint!("/vm.add-fs"), Box::new(VmAddFs {}));
r.routes.insert(endpoint!("/vm.add-pmem"), Box::new(VmAddPmem {}));
r.routes.insert(endpoint!("/vm.add-net"), Box::new(VmAddNet {}));

View File

@@ -487,6 +487,24 @@ impl EndpointHandler for VmAddDisk {
}
}
// /api/v1/vm.add-fs handler
pub struct VmAddFs {}
impl EndpointHandler for VmAddFs {
fn handle_request(
&self,
req: &Request,
_api_notifier: EventFd,
_api_sender: Sender<ApiRequest>,
) -> Response {
match req.method() {
// Not implemented.
Method::Put => Response::new(Version::Http11, StatusCode::NotImplemented),
_ => Response::new(Version::Http11, StatusCode::BadRequest),
}
}
}
// /api/v1/vm.add-pmem handler
pub struct VmAddPmem {}

View File

@@ -187,6 +187,22 @@ paths:
500:
description: The new disk could not be added to the VM instance.
/vm.add-fs:
put:
summary: Add a new virtio-fs device to the VM
requestBody:
description: The details of the new virtio-fs
content:
application/json:
schema:
$ref: '#/components/schemas/FsConfig'
required: true
responses:
204:
description: The new device was successfully added to the VM instance.
500:
description: The new device could not be added to the VM instance.
/vm.add-pmem:
put:
summary: Add a new pmem device to the VM