mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-02 11:35:46 +00:00
vmm, main: Support only zero or one vsock devices
The Linux kernel does not support multiple virtio-vsock devices. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
9d1f95a3cc
commit
10348f73e4
41
src/main.rs
41
src/main.rs
@ -199,7 +199,7 @@ fn create_app<'a, 'b>(
|
|||||||
"Virtio VSOCK parameters \"cid=<context_id>,sock=<socket_path>,iommu=on|off\"",
|
"Virtio VSOCK parameters \"cid=<context_id>,sock=<socket_path>,iommu=on|off\"",
|
||||||
)
|
)
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.min_values(1)
|
.number_of_values(1)
|
||||||
.group("vm-config"),
|
.group("vm-config"),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
@ -1435,34 +1435,13 @@ mod unit_tests {
|
|||||||
"/path/to/kernel",
|
"/path/to/kernel",
|
||||||
"--vsock",
|
"--vsock",
|
||||||
"cid=123,sock=/path/to/sock/1",
|
"cid=123,sock=/path/to/sock/1",
|
||||||
"cid=456,sock=/path/to/sock/2",
|
|
||||||
],
|
],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"vsock": [
|
"vsock": {"cid": 123, "sock": "/path/to/sock/1"}
|
||||||
{"cid": 123, "sock": "/path/to/sock/1"},
|
|
||||||
{"cid": 456, "sock": "/path/to/sock/2"}
|
|
||||||
]
|
|
||||||
}"#,
|
}"#,
|
||||||
true,
|
true,
|
||||||
),
|
),
|
||||||
(
|
|
||||||
vec![
|
|
||||||
"cloud-hypervisor",
|
|
||||||
"--kernel",
|
|
||||||
"/path/to/kernel",
|
|
||||||
"--vsock",
|
|
||||||
"cid=123,sock=/path/to/sock/1",
|
|
||||||
"cid=456,sock=/path/to/sock/2",
|
|
||||||
],
|
|
||||||
r#"{
|
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
|
||||||
"vsock": [
|
|
||||||
{"cid": 123, "sock": "/path/to/sock/1"}
|
|
||||||
]
|
|
||||||
}"#,
|
|
||||||
false,
|
|
||||||
),
|
|
||||||
(
|
(
|
||||||
vec![
|
vec![
|
||||||
"cloud-hypervisor",
|
"cloud-hypervisor",
|
||||||
@ -1473,9 +1452,7 @@ mod unit_tests {
|
|||||||
],
|
],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"vsock": [
|
"vsock": {"cid": 123, "sock": "/path/to/sock/1"}
|
||||||
{"cid": 123, "sock": "/path/to/sock/1"}
|
|
||||||
]
|
|
||||||
}"#,
|
}"#,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
@ -1489,9 +1466,7 @@ mod unit_tests {
|
|||||||
],
|
],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"vsock": [
|
"vsock": {"cid": 123, "sock": "/path/to/sock/1", "iommu": true},
|
||||||
{"cid": 123, "sock": "/path/to/sock/1", "iommu": true}
|
|
||||||
],
|
|
||||||
"iommu": true
|
"iommu": true
|
||||||
}"#,
|
}"#,
|
||||||
true,
|
true,
|
||||||
@ -1506,9 +1481,7 @@ mod unit_tests {
|
|||||||
],
|
],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"vsock": [
|
"vsock": {"cid": 123, "sock": "/path/to/sock/1", "iommu": true}
|
||||||
{"cid": 123, "sock": "/path/to/sock/1", "iommu": true}
|
|
||||||
]
|
|
||||||
}"#,
|
}"#,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
@ -1522,9 +1495,7 @@ mod unit_tests {
|
|||||||
],
|
],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"vsock": [
|
"vsock": {"cid": 123, "sock": "/path/to/sock/1", "iommu": false}
|
||||||
{"cid": 123, "sock": "/path/to/sock/1", "iommu": false}
|
|
||||||
]
|
|
||||||
}"#,
|
}"#,
|
||||||
true,
|
true,
|
||||||
),
|
),
|
||||||
|
@ -337,8 +337,6 @@ components:
|
|||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/DeviceConfig'
|
$ref: '#/components/schemas/DeviceConfig'
|
||||||
vsock:
|
vsock:
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/VsockConfig'
|
$ref: '#/components/schemas/VsockConfig'
|
||||||
iommu:
|
iommu:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
@ -269,7 +269,7 @@ pub struct VmParams<'a> {
|
|||||||
pub serial: &'a str,
|
pub serial: &'a str,
|
||||||
pub console: &'a str,
|
pub console: &'a str,
|
||||||
pub devices: Option<Vec<&'a str>>,
|
pub devices: Option<Vec<&'a str>>,
|
||||||
pub vsock: Option<Vec<&'a str>>,
|
pub vsock: Option<&'a str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> VmParams<'a> {
|
impl<'a> VmParams<'a> {
|
||||||
@ -290,7 +290,7 @@ impl<'a> VmParams<'a> {
|
|||||||
let fs: Option<Vec<&str>> = args.values_of("fs").map(|x| x.collect());
|
let fs: Option<Vec<&str>> = args.values_of("fs").map(|x| x.collect());
|
||||||
let pmem: Option<Vec<&str>> = args.values_of("pmem").map(|x| x.collect());
|
let pmem: Option<Vec<&str>> = args.values_of("pmem").map(|x| x.collect());
|
||||||
let devices: Option<Vec<&str>> = args.values_of("device").map(|x| x.collect());
|
let devices: Option<Vec<&str>> = args.values_of("device").map(|x| x.collect());
|
||||||
let vsock: Option<Vec<&str>> = args.values_of("vsock").map(|x| x.collect());
|
let vsock: Option<&str> = args.value_of("vsock");
|
||||||
|
|
||||||
VmParams {
|
VmParams {
|
||||||
cpus,
|
cpus,
|
||||||
@ -1218,7 +1218,7 @@ pub struct VmConfig {
|
|||||||
#[serde(default = "ConsoleConfig::default_console")]
|
#[serde(default = "ConsoleConfig::default_console")]
|
||||||
pub console: ConsoleConfig,
|
pub console: ConsoleConfig,
|
||||||
pub devices: Option<Vec<DeviceConfig>>,
|
pub devices: Option<Vec<DeviceConfig>>,
|
||||||
pub vsock: Option<Vec<VsockConfig>>,
|
pub vsock: Option<VsockConfig>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub iommu: bool,
|
pub iommu: bool,
|
||||||
}
|
}
|
||||||
@ -1351,19 +1351,14 @@ impl VmConfig {
|
|||||||
devices = Some(device_config_list);
|
devices = Some(device_config_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut vsock: Option<Vec<VsockConfig>> = None;
|
let mut vsock: Option<VsockConfig> = None;
|
||||||
if let Some(vsock_list) = &vm_params.vsock {
|
if let Some(vs) = &vm_params.vsock {
|
||||||
let mut vsock_config_list = Vec::new();
|
let vsock_config = VsockConfig::parse(vs)?;
|
||||||
for item in vsock_list.iter() {
|
|
||||||
let vsock_config = VsockConfig::parse(item)?;
|
|
||||||
if vsock_config.iommu {
|
if vsock_config.iommu {
|
||||||
iommu = true;
|
iommu = true;
|
||||||
}
|
}
|
||||||
vsock_config_list.push(vsock_config);
|
vsock = Some(vsock_config);
|
||||||
}
|
}
|
||||||
vsock = Some(vsock_config_list);
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut kernel: Option<KernelConfig> = None;
|
let mut kernel: Option<KernelConfig> = None;
|
||||||
if let Some(k) = vm_params.kernel {
|
if let Some(k) = vm_params.kernel {
|
||||||
kernel = Some(KernelConfig {
|
kernel = Some(KernelConfig {
|
||||||
|
@ -1120,7 +1120,7 @@ impl DeviceManager {
|
|||||||
devices.append(&mut self.make_virtio_pmem_devices()?);
|
devices.append(&mut self.make_virtio_pmem_devices()?);
|
||||||
|
|
||||||
// Add virtio-vsock if required
|
// Add virtio-vsock if required
|
||||||
devices.append(&mut self.make_virtio_vsock_devices()?);
|
devices.append(&mut self.make_virtio_vsock_device()?);
|
||||||
|
|
||||||
devices.append(&mut self.make_virtio_mem_devices()?);
|
devices.append(&mut self.make_virtio_mem_devices()?);
|
||||||
|
|
||||||
@ -1640,13 +1640,12 @@ impl DeviceManager {
|
|||||||
Ok(devices)
|
Ok(devices)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_virtio_vsock_devices(
|
fn make_virtio_vsock_device(
|
||||||
&mut self,
|
&mut self,
|
||||||
) -> DeviceManagerResult<Vec<(VirtioDeviceArc, bool, Option<String>)>> {
|
) -> DeviceManagerResult<Vec<(VirtioDeviceArc, bool, Option<String>)>> {
|
||||||
let mut devices = Vec::new();
|
let mut devices = Vec::new();
|
||||||
// Add vsock if required
|
// Add vsock if required
|
||||||
if let Some(vsock_list_cfg) = &self.config.lock().unwrap().vsock {
|
if let Some(vsock_cfg) = &self.config.lock().unwrap().vsock {
|
||||||
for vsock_cfg in vsock_list_cfg.iter() {
|
|
||||||
let socket_path = vsock_cfg
|
let socket_path = vsock_cfg
|
||||||
.sock
|
.sock
|
||||||
.to_str()
|
.to_str()
|
||||||
@ -1666,7 +1665,6 @@ impl DeviceManager {
|
|||||||
let id = migratable.lock().unwrap().id();
|
let id = migratable.lock().unwrap().id();
|
||||||
self.migratable_devices.push((id, migratable));
|
self.migratable_devices.push((id, migratable));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Ok(devices)
|
Ok(devices)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user