mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
api: http: handle cpu according to openapi
openapi definition defines an object for cpus not an integer Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
This commit is contained in:
committed by
Samuel Ortiz
parent
205b8c1cd5
commit
78e2f7a99a
@@ -131,25 +131,23 @@ fn parse_iommu(iommu: &str) -> Result<bool> {
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct CpusConfig(pub u8);
|
||||
pub struct CpusConfig {
|
||||
pub cpu_count: u8,
|
||||
}
|
||||
|
||||
impl CpusConfig {
|
||||
pub fn parse(cpus: &str) -> Result<Self> {
|
||||
Ok(CpusConfig(
|
||||
cpus.parse::<u8>().map_err(Error::ParseCpusParams)?,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&CpusConfig> for u8 {
|
||||
fn from(val: &CpusConfig) -> Self {
|
||||
val.0
|
||||
Ok(CpusConfig {
|
||||
cpu_count: cpus.parse().map_err(Error::ParseCpusParams)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for CpusConfig {
|
||||
fn default() -> Self {
|
||||
CpusConfig(DEFAULT_VCPUS)
|
||||
CpusConfig {
|
||||
cpu_count: DEFAULT_VCPUS,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user