mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-03-20 07:58:55 +00:00
vmm: Include device tree in vm.info API
The DeviceNode cannot be fully represented as it embeds a Rust style enum (i.e. with data) which is instead represented by a simple associative array. Fixes: #1167 Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
15f0451c34
commit
280d4fb245
@ -39,6 +39,7 @@ pub mod http_endpoint;
|
||||
use crate::config::{
|
||||
DeviceConfig, DiskConfig, FsConfig, NetConfig, PmemConfig, RestoreConfig, VmConfig, VsockConfig,
|
||||
};
|
||||
use crate::device_tree::DeviceTree;
|
||||
use crate::vm::{Error as VmError, VmState};
|
||||
use micro_http::Body;
|
||||
use std::io;
|
||||
@ -153,6 +154,7 @@ pub struct VmInfo {
|
||||
pub config: Arc<Mutex<VmConfig>>,
|
||||
pub state: VmState,
|
||||
pub memory_actual_size: u64,
|
||||
pub device_tree: Option<Arc<Mutex<DeviceTree>>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
|
@ -363,8 +363,30 @@ components:
|
||||
memory_actual_size:
|
||||
type: integer
|
||||
format: int64
|
||||
device_tree:
|
||||
type: object
|
||||
additionalProperties:
|
||||
$ref: '#/components/schemas/DeviceNode'
|
||||
description: Virtual Machine information
|
||||
|
||||
DeviceNode:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
resources:
|
||||
type: array
|
||||
items:
|
||||
# Rust enum type (with data) which can't be better represented here
|
||||
type: object
|
||||
children:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
pci_bdf:
|
||||
type: integer
|
||||
format: int32
|
||||
|
||||
VmCounters:
|
||||
type: object
|
||||
additionalProperties:
|
||||
|
@ -3134,6 +3134,10 @@ impl DeviceManager {
|
||||
|
||||
0
|
||||
}
|
||||
|
||||
pub fn device_tree(&self) -> Arc<Mutex<DeviceTree>> {
|
||||
self.device_tree.clone()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "acpi")]
|
||||
|
@ -484,10 +484,13 @@ impl Vmm {
|
||||
memory_actual_size -= vm.balloon_size();
|
||||
}
|
||||
|
||||
let device_tree = self.vm.as_ref().map(|vm| vm.device_tree());
|
||||
|
||||
Ok(VmInfo {
|
||||
config,
|
||||
state,
|
||||
memory_actual_size,
|
||||
device_tree,
|
||||
})
|
||||
}
|
||||
None => Err(VmError::VmNotCreated),
|
||||
|
@ -30,6 +30,7 @@ use crate::config::{
|
||||
};
|
||||
use crate::cpu;
|
||||
use crate::device_manager::{self, get_win_size, Console, DeviceManager, DeviceManagerError};
|
||||
use crate::device_tree::DeviceTree;
|
||||
use crate::memory_manager::{Error as MemoryManagerError, MemoryManager};
|
||||
use crate::migration::{get_vm_snapshot, url_to_path, VM_SNAPSHOT_FILE};
|
||||
use crate::seccomp_filters::{get_seccomp_filter, Thread};
|
||||
@ -1717,6 +1718,10 @@ impl Vm {
|
||||
.unwrap()
|
||||
.dirty_memory_range_table()
|
||||
}
|
||||
|
||||
pub fn device_tree(&self) -> Arc<Mutex<DeviceTree>> {
|
||||
self.device_manager.lock().unwrap().device_tree()
|
||||
}
|
||||
}
|
||||
|
||||
impl Pausable for Vm {
|
||||
|
Loading…
x
Reference in New Issue
Block a user