vmm: Add id option to VFIO hotplug

Add a new id option to the VFIO hotplug command so that it matches the
VFIO coldplug semantic.

This is done by refactoring the existing code for VFIO hotplug, where
VmAddDeviceData structure is replaced by DeviceConfig. This structure is
the one used whenever a VFIO device is coldplugged, which is why it
makes sense to reuse it for the hotplug codepath.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2020-03-11 16:17:51 +01:00
parent 18dc916380
commit 34412c9b41
6 changed files with 21 additions and 35 deletions

View File

@@ -7,7 +7,7 @@ use crate::api::http::EndpointHandler;
use crate::api::{
vm_add_device, vm_boot, vm_create, vm_delete, vm_info, vm_pause, vm_reboot, vm_remove_device,
vm_resize, vm_resume, vm_shutdown, vmm_ping, vmm_shutdown, ApiError, ApiRequest, ApiResult,
VmAction, VmAddDeviceData, VmConfig, VmRemoveDeviceData, VmResizeData,
DeviceConfig, VmAction, VmConfig, VmRemoveDeviceData, VmResizeData,
};
use micro_http::{Body, Method, Request, Response, StatusCode, Version};
use serde_json::Error as SerdeError;
@@ -283,8 +283,8 @@ impl EndpointHandler for VmAddDevice {
Method::Put => {
match &req.body {
Some(body) => {
// Deserialize into a VmAddDeviceData
let vm_add_device_data: VmAddDeviceData =
// Deserialize into a DeviceConfig
let vm_add_device_data: DeviceConfig =
match serde_json::from_slice(body.raw())
.map_err(HttpError::SerdeJsonDeserialize)
{