mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-02 11:35:46 +00:00
tests,vm-virtio,vmm: Use 'socket' for all CLI/API parameters
This patch unifies the inconsistent uses of 'socket' and 'sock' from our CLI/API parameters. Fixes: #1091 Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
parent
90e7accf8b
commit
a8cdf2f070
@ -60,20 +60,20 @@ Assuming you have `clear-kvm.img` and `custom-vmlinux.bin` on your system, here
|
|||||||
--disk path=clear-kvm.img \
|
--disk path=clear-kvm.img \
|
||||||
--kernel custom-vmlinux.bin \
|
--kernel custom-vmlinux.bin \
|
||||||
--cmdline "console=ttyS0 reboot=k panic=1 nomodules root=/dev/vda3" \
|
--cmdline "console=ttyS0 reboot=k panic=1 nomodules root=/dev/vda3" \
|
||||||
--fs tag=myfs,sock=/tmp/virtiofs,num_queues=1,queue_size=512
|
--fs tag=myfs,socket=/tmp/virtiofs,num_queues=1,queue_size=512
|
||||||
```
|
```
|
||||||
|
|
||||||
By default, DAX is enabled with a cache window of 8GiB. You can specify a custom size (let's say 4GiB for this example) for the cache by explicitly setting DAX and the cache size:
|
By default, DAX is enabled with a cache window of 8GiB. You can specify a custom size (let's say 4GiB for this example) for the cache by explicitly setting DAX and the cache size:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
--fs tag=virtiofs,sock=/tmp/virtiofs,num_queues=1,queue_size=512,dax=on,cache_size=4G
|
--fs tag=virtiofs,socket=/tmp/virtiofs,num_queues=1,queue_size=512,dax=on,cache_size=4G
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
In case you don't want to use a shared window of cache to pass the shared files content, this means you will have to explicitly disable DAX with `dax=off`. Note that in this case, the `cache_size` parameter will be ignored.
|
In case you don't want to use a shared window of cache to pass the shared files content, this means you will have to explicitly disable DAX with `dax=off`. Note that in this case, the `cache_size` parameter will be ignored.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
--fs tag=virtiofs,sock=/tmp/virtiofs,num_queues=1,queue_size=512,dax=off
|
--fs tag=virtiofs,socket=/tmp/virtiofs,num_queues=1,queue_size=512,dax=off
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
82
src/main.rs
82
src/main.rs
@ -745,14 +745,14 @@ mod unit_tests {
|
|||||||
"--memory",
|
"--memory",
|
||||||
"shared=true",
|
"shared=true",
|
||||||
"--disk",
|
"--disk",
|
||||||
"vhost_user=true,socket=/tmp/socket1",
|
"vhost_user=true,socket=/tmp/sock1",
|
||||||
"path=/path/to/disk/2",
|
"path=/path/to/disk/2",
|
||||||
],
|
],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"memory" : { "shared": true, "size": 536870912 },
|
"memory" : { "shared": true, "size": 536870912 },
|
||||||
"disks": [
|
"disks": [
|
||||||
{"vhost_user":true, "vhost_socket":"/tmp/socket1"},
|
{"vhost_user":true, "vhost_socket":"/tmp/sock1"},
|
||||||
{"path": "/path/to/disk/2"}
|
{"path": "/path/to/disk/2"}
|
||||||
]
|
]
|
||||||
}"#,
|
}"#,
|
||||||
@ -766,14 +766,14 @@ mod unit_tests {
|
|||||||
"--memory",
|
"--memory",
|
||||||
"shared=true",
|
"shared=true",
|
||||||
"--disk",
|
"--disk",
|
||||||
"vhost_user=true,socket=/tmp/socket1",
|
"vhost_user=true,socket=/tmp/sock1",
|
||||||
"path=/path/to/disk/2",
|
"path=/path/to/disk/2",
|
||||||
],
|
],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"memory" : { "shared": true, "size": 536870912 },
|
"memory" : { "shared": true, "size": 536870912 },
|
||||||
"disks": [
|
"disks": [
|
||||||
{"vhost_user":true, "vhost_socket":"/tmp/socket1"},
|
{"vhost_user":true, "vhost_socket":"/tmp/sock1"},
|
||||||
{"path": "/path/to/disk/2"}
|
{"path": "/path/to/disk/2"}
|
||||||
]
|
]
|
||||||
}"#,
|
}"#,
|
||||||
@ -952,12 +952,12 @@ mod unit_tests {
|
|||||||
true,
|
true,
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
vec!["cloud-hypervisor", "--kernel", "/path/to/kernel", "--memory", "shared=true", "--net", "mac=12:34:56:78:90:ab,host_mac=34:56:78:90:ab:cd,vhost_user=true,socket=/tmp/socket"],
|
vec!["cloud-hypervisor", "--kernel", "/path/to/kernel", "--memory", "shared=true", "--net", "mac=12:34:56:78:90:ab,host_mac=34:56:78:90:ab:cd,vhost_user=true,socket=/tmp/sock"],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"memory" : { "shared": true, "size": 536870912 },
|
"memory" : { "shared": true, "size": 536870912 },
|
||||||
"net": [
|
"net": [
|
||||||
{"mac": "12:34:56:78:90:ab", "host_mac": "34:56:78:90:ab:cd", "vhost_user": true, "vhost_socket": "/tmp/socket"}
|
{"mac": "12:34:56:78:90:ab", "host_mac": "34:56:78:90:ab:cd", "vhost_user": true, "vhost_socket": "/tmp/sock"}
|
||||||
]
|
]
|
||||||
}"#,
|
}"#,
|
||||||
true,
|
true,
|
||||||
@ -999,15 +999,15 @@ mod unit_tests {
|
|||||||
"cloud-hypervisor", "--kernel", "/path/to/kernel",
|
"cloud-hypervisor", "--kernel", "/path/to/kernel",
|
||||||
"--memory", "shared=true",
|
"--memory", "shared=true",
|
||||||
"--fs",
|
"--fs",
|
||||||
"tag=virtiofs1,sock=/path/to/sock1",
|
"tag=virtiofs1,socket=/path/to/sock1",
|
||||||
"tag=virtiofs2,sock=/path/to/sock2",
|
"tag=virtiofs2,socket=/path/to/sock2",
|
||||||
],
|
],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"memory" : { "shared": true, "size": 536870912 },
|
"memory" : { "shared": true, "size": 536870912 },
|
||||||
"fs": [
|
"fs": [
|
||||||
{"tag": "virtiofs1", "sock": "/path/to/sock1"},
|
{"tag": "virtiofs1", "socket": "/path/to/sock1"},
|
||||||
{"tag": "virtiofs2", "sock": "/path/to/sock2"}
|
{"tag": "virtiofs2", "socket": "/path/to/sock2"}
|
||||||
]
|
]
|
||||||
}"#,
|
}"#,
|
||||||
true,
|
true,
|
||||||
@ -1017,14 +1017,14 @@ mod unit_tests {
|
|||||||
"cloud-hypervisor", "--kernel", "/path/to/kernel",
|
"cloud-hypervisor", "--kernel", "/path/to/kernel",
|
||||||
"--memory", "shared=true",
|
"--memory", "shared=true",
|
||||||
"--fs",
|
"--fs",
|
||||||
"tag=virtiofs1,sock=/path/to/sock1",
|
"tag=virtiofs1,socket=/path/to/sock1",
|
||||||
"tag=virtiofs2,sock=/path/to/sock2",
|
"tag=virtiofs2,socket=/path/to/sock2",
|
||||||
],
|
],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"memory" : { "shared": true, "size": 536870912 },
|
"memory" : { "shared": true, "size": 536870912 },
|
||||||
"fs": [
|
"fs": [
|
||||||
{"tag": "virtiofs1", "sock": "/path/to/sock1"}
|
{"tag": "virtiofs1", "socket": "/path/to/sock1"}
|
||||||
]
|
]
|
||||||
}"#,
|
}"#,
|
||||||
false,
|
false,
|
||||||
@ -1034,13 +1034,13 @@ mod unit_tests {
|
|||||||
"cloud-hypervisor", "--kernel", "/path/to/kernel",
|
"cloud-hypervisor", "--kernel", "/path/to/kernel",
|
||||||
"--memory", "shared=true",
|
"--memory", "shared=true",
|
||||||
"--fs",
|
"--fs",
|
||||||
"tag=virtiofs1,sock=/path/to/sock1,num_queues=4",
|
"tag=virtiofs1,socket=/path/to/sock1,num_queues=4",
|
||||||
],
|
],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"memory" : { "shared": true, "size": 536870912 },
|
"memory" : { "shared": true, "size": 536870912 },
|
||||||
"fs": [
|
"fs": [
|
||||||
{"tag": "virtiofs1", "sock": "/path/to/sock1", "num_queues": 4}
|
{"tag": "virtiofs1", "socket": "/path/to/sock1", "num_queues": 4}
|
||||||
]
|
]
|
||||||
}"#,
|
}"#,
|
||||||
true,
|
true,
|
||||||
@ -1050,13 +1050,13 @@ mod unit_tests {
|
|||||||
"cloud-hypervisor", "--kernel", "/path/to/kernel",
|
"cloud-hypervisor", "--kernel", "/path/to/kernel",
|
||||||
"--memory", "shared=true",
|
"--memory", "shared=true",
|
||||||
"--fs",
|
"--fs",
|
||||||
"tag=virtiofs1,sock=/path/to/sock1,num_queues=4,queue_size=128"
|
"tag=virtiofs1,socket=/path/to/sock1,num_queues=4,queue_size=128"
|
||||||
],
|
],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"memory" : { "shared": true, "size": 536870912 },
|
"memory" : { "shared": true, "size": 536870912 },
|
||||||
"fs": [
|
"fs": [
|
||||||
{"tag": "virtiofs1", "sock": "/path/to/sock1", "num_queues": 4, "queue_size": 128}
|
{"tag": "virtiofs1", "socket": "/path/to/sock1", "num_queues": 4, "queue_size": 128}
|
||||||
]
|
]
|
||||||
}"#,
|
}"#,
|
||||||
true,
|
true,
|
||||||
@ -1066,13 +1066,13 @@ mod unit_tests {
|
|||||||
"cloud-hypervisor", "--kernel", "/path/to/kernel",
|
"cloud-hypervisor", "--kernel", "/path/to/kernel",
|
||||||
"--memory", "shared=true",
|
"--memory", "shared=true",
|
||||||
"--fs",
|
"--fs",
|
||||||
"tag=virtiofs1,sock=/path/to/sock1,num_queues=4,queue_size=128,dax=on"
|
"tag=virtiofs1,socket=/path/to/sock1,num_queues=4,queue_size=128,dax=on"
|
||||||
],
|
],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"memory" : { "shared": true, "size": 536870912 },
|
"memory" : { "shared": true, "size": 536870912 },
|
||||||
"fs": [
|
"fs": [
|
||||||
{"tag": "virtiofs1", "sock": "/path/to/sock1", "num_queues": 4, "queue_size": 128}
|
{"tag": "virtiofs1", "socket": "/path/to/sock1", "num_queues": 4, "queue_size": 128}
|
||||||
]
|
]
|
||||||
}"#,
|
}"#,
|
||||||
true,
|
true,
|
||||||
@ -1082,13 +1082,13 @@ mod unit_tests {
|
|||||||
"cloud-hypervisor", "--kernel", "/path/to/kernel",
|
"cloud-hypervisor", "--kernel", "/path/to/kernel",
|
||||||
"--memory", "shared=true",
|
"--memory", "shared=true",
|
||||||
"--fs",
|
"--fs",
|
||||||
"tag=virtiofs1,sock=/path/to/sock1,num_queues=4,queue_size=128,dax=on"
|
"tag=virtiofs1,socket=/path/to/sock1,num_queues=4,queue_size=128,dax=on"
|
||||||
],
|
],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"memory" : { "shared": true, "size": 536870912 },
|
"memory" : { "shared": true, "size": 536870912 },
|
||||||
"fs": [
|
"fs": [
|
||||||
{"tag": "virtiofs1", "sock": "/path/to/sock1", "num_queues": 4, "queue_size": 128, "dax": true}
|
{"tag": "virtiofs1", "socket": "/path/to/sock1", "num_queues": 4, "queue_size": 128, "dax": true}
|
||||||
]
|
]
|
||||||
}"#,
|
}"#,
|
||||||
true,
|
true,
|
||||||
@ -1098,13 +1098,13 @@ mod unit_tests {
|
|||||||
"cloud-hypervisor", "--kernel", "/path/to/kernel",
|
"cloud-hypervisor", "--kernel", "/path/to/kernel",
|
||||||
"--memory", "shared=true",
|
"--memory", "shared=true",
|
||||||
"--fs",
|
"--fs",
|
||||||
"tag=virtiofs1,sock=/path/to/sock1,num_queues=4,queue_size=128"
|
"tag=virtiofs1,socket=/path/to/sock1,num_queues=4,queue_size=128"
|
||||||
],
|
],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"memory" : { "shared": true, "size": 536870912 },
|
"memory" : { "shared": true, "size": 536870912 },
|
||||||
"fs": [
|
"fs": [
|
||||||
{"tag": "virtiofs1", "sock": "/path/to/sock1", "num_queues": 4, "queue_size": 128, "dax": true}
|
{"tag": "virtiofs1", "socket": "/path/to/sock1", "num_queues": 4, "queue_size": 128, "dax": true}
|
||||||
]
|
]
|
||||||
}"#,
|
}"#,
|
||||||
true,
|
true,
|
||||||
@ -1114,13 +1114,13 @@ mod unit_tests {
|
|||||||
"cloud-hypervisor", "--kernel", "/path/to/kernel",
|
"cloud-hypervisor", "--kernel", "/path/to/kernel",
|
||||||
"--memory", "shared=true",
|
"--memory", "shared=true",
|
||||||
"--fs",
|
"--fs",
|
||||||
"tag=virtiofs1,sock=/path/to/sock1,num_queues=4,queue_size=128,cache_size=8589934592"
|
"tag=virtiofs1,socket=/path/to/sock1,num_queues=4,queue_size=128,cache_size=8589934592"
|
||||||
],
|
],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"memory" : { "shared": true, "size": 536870912 },
|
"memory" : { "shared": true, "size": 536870912 },
|
||||||
"fs": [
|
"fs": [
|
||||||
{"tag": "virtiofs1", "sock": "/path/to/sock1", "num_queues": 4, "queue_size": 128}
|
{"tag": "virtiofs1", "socket": "/path/to/sock1", "num_queues": 4, "queue_size": 128}
|
||||||
]
|
]
|
||||||
}"#,
|
}"#,
|
||||||
true,
|
true,
|
||||||
@ -1130,13 +1130,13 @@ mod unit_tests {
|
|||||||
"cloud-hypervisor", "--kernel", "/path/to/kernel",
|
"cloud-hypervisor", "--kernel", "/path/to/kernel",
|
||||||
"--memory", "shared=true",
|
"--memory", "shared=true",
|
||||||
"--fs",
|
"--fs",
|
||||||
"tag=virtiofs1,sock=/path/to/sock1,num_queues=4,queue_size=128"
|
"tag=virtiofs1,socket=/path/to/sock1,num_queues=4,queue_size=128"
|
||||||
],
|
],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"memory" : { "shared": true, "size": 536870912 },
|
"memory" : { "shared": true, "size": 536870912 },
|
||||||
"fs": [
|
"fs": [
|
||||||
{"tag": "virtiofs1", "sock": "/path/to/sock1", "num_queues": 4, "queue_size": 128, "cache_size": 8589934592}
|
{"tag": "virtiofs1", "socket": "/path/to/sock1", "num_queues": 4, "queue_size": 128, "cache_size": 8589934592}
|
||||||
]
|
]
|
||||||
}"#,
|
}"#,
|
||||||
true,
|
true,
|
||||||
@ -1146,13 +1146,13 @@ mod unit_tests {
|
|||||||
"cloud-hypervisor", "--kernel", "/path/to/kernel",
|
"cloud-hypervisor", "--kernel", "/path/to/kernel",
|
||||||
"--memory", "shared=true",
|
"--memory", "shared=true",
|
||||||
"--fs",
|
"--fs",
|
||||||
"tag=virtiofs1,sock=/path/to/sock1,num_queues=4,queue_size=128,cache_size=4294967296"
|
"tag=virtiofs1,socket=/path/to/sock1,num_queues=4,queue_size=128,cache_size=4294967296"
|
||||||
],
|
],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"memory" : { "shared": true, "size": 536870912 },
|
"memory" : { "shared": true, "size": 536870912 },
|
||||||
"fs": [
|
"fs": [
|
||||||
{"tag": "virtiofs1", "sock": "/path/to/sock1", "num_queues": 4, "queue_size": 128, "cache_size": 4294967296}
|
{"tag": "virtiofs1", "socket": "/path/to/sock1", "num_queues": 4, "queue_size": 128, "cache_size": 4294967296}
|
||||||
]
|
]
|
||||||
}"#,
|
}"#,
|
||||||
true,
|
true,
|
||||||
@ -1162,13 +1162,13 @@ mod unit_tests {
|
|||||||
"cloud-hypervisor", "--kernel", "/path/to/kernel",
|
"cloud-hypervisor", "--kernel", "/path/to/kernel",
|
||||||
"--memory", "shared=true",
|
"--memory", "shared=true",
|
||||||
"--fs",
|
"--fs",
|
||||||
"tag=virtiofs1,sock=/path/to/sock1,num_queues=4,queue_size=128,cache_size=4294967296"
|
"tag=virtiofs1,socket=/path/to/sock1,num_queues=4,queue_size=128,cache_size=4294967296"
|
||||||
],
|
],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"memory" : { "shared": true, "size": 536870912 },
|
"memory" : { "shared": true, "size": 536870912 },
|
||||||
"fs": [
|
"fs": [
|
||||||
{"tag": "virtiofs1", "sock": "/path/to/sock1", "num_queues": 4, "queue_size": 128}
|
{"tag": "virtiofs1", "socket": "/path/to/sock1", "num_queues": 4, "queue_size": 128}
|
||||||
]
|
]
|
||||||
}"#,
|
}"#,
|
||||||
false,
|
false,
|
||||||
@ -1427,11 +1427,11 @@ mod unit_tests {
|
|||||||
"--kernel",
|
"--kernel",
|
||||||
"/path/to/kernel",
|
"/path/to/kernel",
|
||||||
"--vsock",
|
"--vsock",
|
||||||
"cid=123,sock=/path/to/sock/1",
|
"cid=123,socket=/path/to/sock/1",
|
||||||
],
|
],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"vsock": {"cid": 123, "sock": "/path/to/sock/1"}
|
"vsock": {"cid": 123, "socket": "/path/to/sock/1"}
|
||||||
}"#,
|
}"#,
|
||||||
true,
|
true,
|
||||||
),
|
),
|
||||||
@ -1441,11 +1441,11 @@ mod unit_tests {
|
|||||||
"--kernel",
|
"--kernel",
|
||||||
"/path/to/kernel",
|
"/path/to/kernel",
|
||||||
"--vsock",
|
"--vsock",
|
||||||
"cid=124,sock=/path/to/sock/1",
|
"cid=124,socket=/path/to/sock/1",
|
||||||
],
|
],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"vsock": {"cid": 123, "sock": "/path/to/sock/1"}
|
"vsock": {"cid": 123, "socket": "/path/to/sock/1"}
|
||||||
}"#,
|
}"#,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
@ -1455,11 +1455,11 @@ mod unit_tests {
|
|||||||
"--kernel",
|
"--kernel",
|
||||||
"/path/to/kernel",
|
"/path/to/kernel",
|
||||||
"--vsock",
|
"--vsock",
|
||||||
"cid=123,sock=/path/to/sock/1,iommu=on",
|
"cid=123,socket=/path/to/sock/1,iommu=on",
|
||||||
],
|
],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"vsock": {"cid": 123, "sock": "/path/to/sock/1", "iommu": true},
|
"vsock": {"cid": 123, "socket": "/path/to/sock/1", "iommu": true},
|
||||||
"iommu": true
|
"iommu": true
|
||||||
}"#,
|
}"#,
|
||||||
true,
|
true,
|
||||||
@ -1470,11 +1470,11 @@ mod unit_tests {
|
|||||||
"--kernel",
|
"--kernel",
|
||||||
"/path/to/kernel",
|
"/path/to/kernel",
|
||||||
"--vsock",
|
"--vsock",
|
||||||
"cid=123,sock=/path/to/sock/1,iommu=on",
|
"cid=123,socket=/path/to/sock/1,iommu=on",
|
||||||
],
|
],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"vsock": {"cid": 123, "sock": "/path/to/sock/1", "iommu": true}
|
"vsock": {"cid": 123, "socket": "/path/to/sock/1", "iommu": true}
|
||||||
}"#,
|
}"#,
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
@ -1484,11 +1484,11 @@ mod unit_tests {
|
|||||||
"--kernel",
|
"--kernel",
|
||||||
"/path/to/kernel",
|
"/path/to/kernel",
|
||||||
"--vsock",
|
"--vsock",
|
||||||
"cid=123,sock=/path/to/sock/1,iommu=off",
|
"cid=123,socket=/path/to/sock/1,iommu=off",
|
||||||
],
|
],
|
||||||
r#"{
|
r#"{
|
||||||
"kernel": {"path": "/path/to/kernel"},
|
"kernel": {"path": "/path/to/kernel"},
|
||||||
"vsock": {"cid": 123, "sock": "/path/to/sock/1", "iommu": false}
|
"vsock": {"cid": 123, "socket": "/path/to/sock/1", "iommu": false}
|
||||||
}"#,
|
}"#,
|
||||||
true,
|
true,
|
||||||
),
|
),
|
||||||
|
@ -370,7 +370,7 @@ mod tests {
|
|||||||
// Start the daemon
|
// Start the daemon
|
||||||
let child = Command::new(clh_command("vhost_user_fs"))
|
let child = Command::new(clh_command("vhost_user_fs"))
|
||||||
.args(&["--shared-dir", shared_dir])
|
.args(&["--shared-dir", shared_dir])
|
||||||
.args(&["--sock", virtiofsd_socket_path.as_str()])
|
.args(&["--socket", virtiofsd_socket_path.as_str()])
|
||||||
.spawn()
|
.spawn()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@ -813,7 +813,7 @@ mod tests {
|
|||||||
Ok(cache == (end_addr - start_addr + 1))
|
Ok(cache == (end_addr - start_addr + 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_vsock(&self, sock: &str) {
|
fn check_vsock(&self, socket: &str) {
|
||||||
// Listen from guest on vsock CID=3 PORT=16
|
// Listen from guest on vsock CID=3 PORT=16
|
||||||
// SOCKET-LISTEN:<domain>:<protocol>:<local-address>
|
// SOCKET-LISTEN:<domain>:<protocol>:<local-address>
|
||||||
let guest_ip = self.network.guest_ip.clone();
|
let guest_ip = self.network.guest_ip.clone();
|
||||||
@ -830,7 +830,7 @@ mod tests {
|
|||||||
.arg(
|
.arg(
|
||||||
format!(
|
format!(
|
||||||
"echo -e \"CONNECT 16\\nHelloWorld!\" | socat - UNIX-CONNECT:{}",
|
"echo -e \"CONNECT 16\\nHelloWorld!\" | socat - UNIX-CONNECT:{}",
|
||||||
sock
|
socket
|
||||||
)
|
)
|
||||||
.as_str(),
|
.as_str(),
|
||||||
)
|
)
|
||||||
@ -1926,7 +1926,7 @@ mod tests {
|
|||||||
.args(&["--api-socket", &api_socket]);
|
.args(&["--api-socket", &api_socket]);
|
||||||
|
|
||||||
let fs_params = format!(
|
let fs_params = format!(
|
||||||
"id=myfs0,tag=myfs,sock={},num_queues=1,queue_size=1024,dax={}{}",
|
"id=myfs0,tag=myfs,socket={},num_queues=1,queue_size=1024,dax={}{}",
|
||||||
virtiofsd_socket_path, dax_vmm_param, cache_size_vmm_param
|
virtiofsd_socket_path, dax_vmm_param, cache_size_vmm_param
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -2048,7 +2048,7 @@ mod tests {
|
|||||||
);
|
);
|
||||||
thread::sleep(std::time::Duration::new(10, 0));
|
thread::sleep(std::time::Duration::new(10, 0));
|
||||||
let fs_params = format!(
|
let fs_params = format!(
|
||||||
"id=myfs0,tag=myfs,sock={},num_queues=1,queue_size=1024,dax={}{}",
|
"id=myfs0,tag=myfs,socket={},num_queues=1,queue_size=1024,dax={}{}",
|
||||||
virtiofsd_socket_path, dax_vmm_param, cache_size_vmm_param
|
virtiofsd_socket_path, dax_vmm_param, cache_size_vmm_param
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -2706,7 +2706,7 @@ mod tests {
|
|||||||
.args(&[
|
.args(&[
|
||||||
"--fs",
|
"--fs",
|
||||||
format!(
|
format!(
|
||||||
"tag=myfs,sock={},num_queues=1,queue_size=1024,dax=on",
|
"tag=myfs,socket={},num_queues=1,queue_size=1024,dax=on",
|
||||||
virtiofsd_socket_path,
|
virtiofsd_socket_path,
|
||||||
)
|
)
|
||||||
.as_str(),
|
.as_str(),
|
||||||
@ -3023,7 +3023,7 @@ mod tests {
|
|||||||
let mut workload_path = dirs::home_dir().unwrap();
|
let mut workload_path = dirs::home_dir().unwrap();
|
||||||
workload_path.push("workloads");
|
workload_path.push("workloads");
|
||||||
|
|
||||||
let sock = temp_vsock_path(&guest.tmp_dir);
|
let socket = temp_vsock_path(&guest.tmp_dir);
|
||||||
let api_socket = temp_api_path(&guest.tmp_dir);
|
let api_socket = temp_api_path(&guest.tmp_dir);
|
||||||
|
|
||||||
let mut cmd = GuestCommand::new(&guest);
|
let mut cmd = GuestCommand::new(&guest);
|
||||||
@ -3035,7 +3035,7 @@ mod tests {
|
|||||||
cmd.default_net();
|
cmd.default_net();
|
||||||
|
|
||||||
if !hotplug {
|
if !hotplug {
|
||||||
cmd.args(&["--vsock", format!("cid=3,sock={}", sock).as_str()]);
|
cmd.args(&["--vsock", format!("cid=3,socket={}", socket).as_str()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut child = cmd.spawn().unwrap();
|
let mut child = cmd.spawn().unwrap();
|
||||||
@ -3048,19 +3048,19 @@ mod tests {
|
|||||||
remote_command(
|
remote_command(
|
||||||
&api_socket,
|
&api_socket,
|
||||||
"add-vsock",
|
"add-vsock",
|
||||||
Some(format!("cid=3,sock={},id=test0", sock).as_str())
|
Some(format!("cid=3,socket={},id=test0", socket).as_str())
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
thread::sleep(std::time::Duration::new(10, 0));
|
thread::sleep(std::time::Duration::new(10, 0));
|
||||||
// Check adding a second one fails
|
// Check adding a second one fails
|
||||||
aver!(
|
aver!(
|
||||||
tb,
|
tb,
|
||||||
!remote_command(&api_socket, "add-vsock", Some("cid=1234,sock=/tmp/fail"))
|
!remote_command(&api_socket, "add-vsock", Some("cid=1234,socket=/tmp/fail"))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate vsock works as expected.
|
// Validate vsock works as expected.
|
||||||
guest.check_vsock(sock.as_str());
|
guest.check_vsock(socket.as_str());
|
||||||
|
|
||||||
let reboot_count = guest
|
let reboot_count = guest
|
||||||
.ssh_command("sudo journalctl | grep -c -- \"-- Reboot --\"")
|
.ssh_command("sudo journalctl | grep -c -- \"-- Reboot --\"")
|
||||||
@ -3082,7 +3082,7 @@ mod tests {
|
|||||||
aver_eq!(tb, reboot_count, 1);
|
aver_eq!(tb, reboot_count, 1);
|
||||||
|
|
||||||
// Validate vsock still works after a reboot.
|
// Validate vsock still works after a reboot.
|
||||||
guest.check_vsock(sock.as_str());
|
guest.check_vsock(socket.as_str());
|
||||||
|
|
||||||
if hotplug {
|
if hotplug {
|
||||||
aver!(
|
aver!(
|
||||||
@ -4304,7 +4304,7 @@ mod tests {
|
|||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
let sock = temp_vsock_path(&guest.tmp_dir);
|
let socket = temp_vsock_path(&guest.tmp_dir);
|
||||||
|
|
||||||
let mut child = GuestCommand::new(&guest)
|
let mut child = GuestCommand::new(&guest)
|
||||||
.args(&["--api-socket", &api_socket])
|
.args(&["--api-socket", &api_socket])
|
||||||
@ -4321,7 +4321,7 @@ mod tests {
|
|||||||
cloudinit_params.as_str(),
|
cloudinit_params.as_str(),
|
||||||
])
|
])
|
||||||
.args(&["--net", net_params.as_str()])
|
.args(&["--net", net_params.as_str()])
|
||||||
.args(&["--vsock", format!("cid=3,sock={}", sock).as_str()])
|
.args(&["--vsock", format!("cid=3,socket={}", socket).as_str()])
|
||||||
.args(&["--cmdline", CLEAR_KERNEL_CMDLINE])
|
.args(&["--cmdline", CLEAR_KERNEL_CMDLINE])
|
||||||
.capture_output()
|
.capture_output()
|
||||||
.spawn()
|
.spawn()
|
||||||
@ -4354,7 +4354,7 @@ mod tests {
|
|||||||
.is_ok()
|
.is_ok()
|
||||||
);
|
);
|
||||||
// Check vsock
|
// Check vsock
|
||||||
guest.check_vsock(sock.as_str());
|
guest.check_vsock(socket.as_str());
|
||||||
// Check if the console is usable
|
// Check if the console is usable
|
||||||
let console_text = String::from("On a branch floating down river a cricket, singing.");
|
let console_text = String::from("On a branch floating down river a cricket, singing.");
|
||||||
let console_cmd = format!("echo {} | sudo tee /dev/hvc0", console_text);
|
let console_cmd = format!("echo {} | sudo tee /dev/hvc0", console_text);
|
||||||
@ -4416,7 +4416,7 @@ mod tests {
|
|||||||
// Remove the vsock socket file.
|
// Remove the vsock socket file.
|
||||||
Command::new("rm")
|
Command::new("rm")
|
||||||
.arg("-f")
|
.arg("-f")
|
||||||
.arg(sock.as_str())
|
.arg(socket.as_str())
|
||||||
.output()
|
.output()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@ -4455,7 +4455,7 @@ mod tests {
|
|||||||
.ssh_command("head -c 1000 /dev/hwrng > /dev/null")
|
.ssh_command("head -c 1000 /dev/hwrng > /dev/null")
|
||||||
.is_ok()
|
.is_ok()
|
||||||
);
|
);
|
||||||
guest.check_vsock(sock.as_str());
|
guest.check_vsock(socket.as_str());
|
||||||
aver!(tb, guest.ssh_command(&console_cmd).is_ok());
|
aver!(tb, guest.ssh_command(&console_cmd).is_ok());
|
||||||
|
|
||||||
// Shutdown the target VM and check console output
|
// Shutdown the target VM and check console output
|
||||||
|
@ -50,7 +50,7 @@ pub struct Blk {
|
|||||||
impl Blk {
|
impl Blk {
|
||||||
/// Create a new vhost-user-blk device
|
/// Create a new vhost-user-blk device
|
||||||
pub fn new(id: String, vu_cfg: VhostUserConfig) -> Result<Blk> {
|
pub fn new(id: String, vu_cfg: VhostUserConfig) -> Result<Blk> {
|
||||||
let mut vhost_user_blk = Master::connect(&vu_cfg.sock, vu_cfg.num_queues as u64)
|
let mut vhost_user_blk = Master::connect(&vu_cfg.socket, vu_cfg.num_queues as u64)
|
||||||
.map_err(Error::VhostUserCreateMaster)?;
|
.map_err(Error::VhostUserCreateMaster)?;
|
||||||
|
|
||||||
// Filling device and vring features VMM supports.
|
// Filling device and vring features VMM supports.
|
||||||
|
@ -56,7 +56,7 @@ impl Net {
|
|||||||
/// Create a new vhost-user-net device
|
/// Create a new vhost-user-net device
|
||||||
/// Create a new vhost-user-net device
|
/// Create a new vhost-user-net device
|
||||||
pub fn new(id: String, mac_addr: MacAddr, vu_cfg: VhostUserConfig) -> Result<Net> {
|
pub fn new(id: String, mac_addr: MacAddr, vu_cfg: VhostUserConfig) -> Result<Net> {
|
||||||
let mut vhost_user_net = Master::connect(&vu_cfg.sock, vu_cfg.num_queues as u64)
|
let mut vhost_user_net = Master::connect(&vu_cfg.socket, vu_cfg.num_queues as u64)
|
||||||
.map_err(Error::VhostUserCreateMaster)?;
|
.map_err(Error::VhostUserCreateMaster)?;
|
||||||
|
|
||||||
// Filling device and vring features VMM supports.
|
// Filling device and vring features VMM supports.
|
||||||
|
@ -18,7 +18,7 @@ use vmm_sys_util::eventfd::EventFd;
|
|||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct VhostUserConfig {
|
pub struct VhostUserConfig {
|
||||||
pub sock: String,
|
pub socket: String,
|
||||||
pub num_queues: usize,
|
pub num_queues: usize,
|
||||||
pub queue_size: u16,
|
pub queue_size: u16,
|
||||||
}
|
}
|
||||||
|
@ -506,12 +506,12 @@ components:
|
|||||||
FsConfig:
|
FsConfig:
|
||||||
required:
|
required:
|
||||||
- tag
|
- tag
|
||||||
- sock
|
- socket
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
tag:
|
tag:
|
||||||
type: string
|
type: string
|
||||||
sock:
|
socket:
|
||||||
type: string
|
type: string
|
||||||
num_queues:
|
num_queues:
|
||||||
type: integer
|
type: integer
|
||||||
@ -581,7 +581,7 @@ components:
|
|||||||
VsockConfig:
|
VsockConfig:
|
||||||
required:
|
required:
|
||||||
- cid
|
- cid
|
||||||
- sock
|
- socket
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
cid:
|
cid:
|
||||||
@ -589,7 +589,7 @@ components:
|
|||||||
format: int64
|
format: int64
|
||||||
minimum: 3
|
minimum: 3
|
||||||
description: Guest Vsock CID
|
description: Guest Vsock CID
|
||||||
sock:
|
socket:
|
||||||
type: string
|
type: string
|
||||||
description: Path to UNIX domain socket, used to proxy vsock connections.
|
description: Path to UNIX domain socket, used to proxy vsock connections.
|
||||||
iommu:
|
iommu:
|
||||||
|
@ -123,7 +123,7 @@ impl fmt::Display for Error {
|
|||||||
ParseDevice(o) => write!(f, "Error parsing --device: {}", o),
|
ParseDevice(o) => write!(f, "Error parsing --device: {}", o),
|
||||||
ParseDevicePathMissing => write!(f, "Error parsing --device: path missing"),
|
ParseDevicePathMissing => write!(f, "Error parsing --device: path missing"),
|
||||||
ParseFileSystem(o) => write!(f, "Error parsing --fs: {}", o),
|
ParseFileSystem(o) => write!(f, "Error parsing --fs: {}", o),
|
||||||
ParseFsSockMissing => write!(f, "Error parsing --fs: sock missing"),
|
ParseFsSockMissing => write!(f, "Error parsing --fs: socket missing"),
|
||||||
ParseFsTagMissing => write!(f, "Error parsing --fs: tag missing"),
|
ParseFsTagMissing => write!(f, "Error parsing --fs: tag missing"),
|
||||||
InvalidCacheSizeWithDaxOff => {
|
InvalidCacheSizeWithDaxOff => {
|
||||||
write!(f, "Error parsing --fs: cache_size used with dax=on")
|
write!(f, "Error parsing --fs: cache_size used with dax=on")
|
||||||
@ -132,7 +132,7 @@ impl fmt::Display for Error {
|
|||||||
ParsePmemFileMissing => write!(f, "Error parsing --pmem: file missing"),
|
ParsePmemFileMissing => write!(f, "Error parsing --pmem: file missing"),
|
||||||
ParseVsock(o) => write!(f, "Error parsing --vsock: {}", o),
|
ParseVsock(o) => write!(f, "Error parsing --vsock: {}", o),
|
||||||
ParseVsockCidMissing => write!(f, "Error parsing --vsock: cid missing"),
|
ParseVsockCidMissing => write!(f, "Error parsing --vsock: cid missing"),
|
||||||
ParseVsockSockMissing => write!(f, "Error parsing --vsock: sock missing"),
|
ParseVsockSockMissing => write!(f, "Error parsing --vsock: socket missing"),
|
||||||
ParseMemory(o) => write!(f, "Error parsing --memory: {}", o),
|
ParseMemory(o) => write!(f, "Error parsing --memory: {}", o),
|
||||||
ParseNetwork(o) => write!(f, "Error parsing --net: {}", o),
|
ParseNetwork(o) => write!(f, "Error parsing --net: {}", o),
|
||||||
ParseDisk(o) => write!(f, "Error parsing --disk: {}", o),
|
ParseDisk(o) => write!(f, "Error parsing --disk: {}", o),
|
||||||
@ -857,7 +857,7 @@ impl Default for RngConfig {
|
|||||||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
||||||
pub struct FsConfig {
|
pub struct FsConfig {
|
||||||
pub tag: String,
|
pub tag: String,
|
||||||
pub sock: PathBuf,
|
pub socket: PathBuf,
|
||||||
#[serde(default = "default_fsconfig_num_queues")]
|
#[serde(default = "default_fsconfig_num_queues")]
|
||||||
pub num_queues: usize,
|
pub num_queues: usize,
|
||||||
#[serde(default = "default_fsconfig_queue_size")]
|
#[serde(default = "default_fsconfig_queue_size")]
|
||||||
@ -890,7 +890,7 @@ impl Default for FsConfig {
|
|||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
tag: "".to_owned(),
|
tag: "".to_owned(),
|
||||||
sock: PathBuf::new(),
|
socket: PathBuf::new(),
|
||||||
num_queues: default_fsconfig_num_queues(),
|
num_queues: default_fsconfig_num_queues(),
|
||||||
queue_size: default_fsconfig_queue_size(),
|
queue_size: default_fsconfig_queue_size(),
|
||||||
dax: default_fsconfig_dax(),
|
dax: default_fsconfig_dax(),
|
||||||
@ -902,7 +902,7 @@ impl Default for FsConfig {
|
|||||||
|
|
||||||
impl FsConfig {
|
impl FsConfig {
|
||||||
pub const SYNTAX: &'static str = "virtio-fs parameters \
|
pub const SYNTAX: &'static str = "virtio-fs parameters \
|
||||||
\"tag=<tag_name>,sock=<socket_path>,num_queues=<number_of_queues>,\
|
\"tag=<tag_name>,socket=<socket_path>,num_queues=<number_of_queues>,\
|
||||||
queue_size=<size_of_each_queue>,dax=on|off,cache_size=<DAX cache size: \
|
queue_size=<size_of_each_queue>,dax=on|off,cache_size=<DAX cache size: \
|
||||||
default 8Gib>,id=<device_id>\"";
|
default 8Gib>,id=<device_id>\"";
|
||||||
|
|
||||||
@ -914,12 +914,12 @@ impl FsConfig {
|
|||||||
.add("cache_size")
|
.add("cache_size")
|
||||||
.add("queue_size")
|
.add("queue_size")
|
||||||
.add("num_queues")
|
.add("num_queues")
|
||||||
.add("sock")
|
.add("socket")
|
||||||
.add("id");
|
.add("id");
|
||||||
parser.parse(fs).map_err(Error::ParseFileSystem)?;
|
parser.parse(fs).map_err(Error::ParseFileSystem)?;
|
||||||
|
|
||||||
let tag = parser.get("tag").ok_or(Error::ParseFsTagMissing)?;
|
let tag = parser.get("tag").ok_or(Error::ParseFsTagMissing)?;
|
||||||
let sock = PathBuf::from(parser.get("sock").ok_or(Error::ParseFsSockMissing)?);
|
let socket = PathBuf::from(parser.get("socket").ok_or(Error::ParseFsSockMissing)?);
|
||||||
|
|
||||||
let queue_size = parser
|
let queue_size = parser
|
||||||
.convert("queue_size")
|
.convert("queue_size")
|
||||||
@ -950,7 +950,7 @@ impl FsConfig {
|
|||||||
|
|
||||||
Ok(FsConfig {
|
Ok(FsConfig {
|
||||||
tag,
|
tag,
|
||||||
sock,
|
socket,
|
||||||
num_queues,
|
num_queues,
|
||||||
queue_size,
|
queue_size,
|
||||||
dax,
|
dax,
|
||||||
@ -1141,7 +1141,7 @@ impl DeviceConfig {
|
|||||||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, Default)]
|
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, Default)]
|
||||||
pub struct VsockConfig {
|
pub struct VsockConfig {
|
||||||
pub cid: u64,
|
pub cid: u64,
|
||||||
pub sock: PathBuf,
|
pub socket: PathBuf,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub iommu: bool,
|
pub iommu: bool,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
@ -1150,14 +1150,14 @@ pub struct VsockConfig {
|
|||||||
|
|
||||||
impl VsockConfig {
|
impl VsockConfig {
|
||||||
pub const SYNTAX: &'static str = "Virtio VSOCK parameters \
|
pub const SYNTAX: &'static str = "Virtio VSOCK parameters \
|
||||||
\"cid=<context_id>,sock=<socket_path>,iommu=on|off,id=<device_id>\"";
|
\"cid=<context_id>,socket=<socket_path>,iommu=on|off,id=<device_id>\"";
|
||||||
pub fn parse(vsock: &str) -> Result<Self> {
|
pub fn parse(vsock: &str) -> Result<Self> {
|
||||||
let mut parser = OptionParser::new();
|
let mut parser = OptionParser::new();
|
||||||
parser.add("sock").add("cid").add("iommu").add("id");
|
parser.add("socket").add("cid").add("iommu").add("id");
|
||||||
parser.parse(vsock).map_err(Error::ParseVsock)?;
|
parser.parse(vsock).map_err(Error::ParseVsock)?;
|
||||||
|
|
||||||
let sock = parser
|
let socket = parser
|
||||||
.get("sock")
|
.get("socket")
|
||||||
.map(PathBuf::from)
|
.map(PathBuf::from)
|
||||||
.ok_or(Error::ParseVsockSockMissing)?;
|
.ok_or(Error::ParseVsockSockMissing)?;
|
||||||
let iommu = parser
|
let iommu = parser
|
||||||
@ -1173,7 +1173,7 @@ impl VsockConfig {
|
|||||||
|
|
||||||
Ok(VsockConfig {
|
Ok(VsockConfig {
|
||||||
cid,
|
cid,
|
||||||
sock,
|
socket,
|
||||||
iommu,
|
iommu,
|
||||||
id,
|
id,
|
||||||
})
|
})
|
||||||
@ -1663,12 +1663,14 @@ mod tests {
|
|||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
NetConfig::parse("mac=de:ad:be:ef:12:34,host_mac=12:34:de:ad:be:ef,vhost_user=true,socket=/tmp/socket")?,
|
NetConfig::parse(
|
||||||
|
"mac=de:ad:be:ef:12:34,host_mac=12:34:de:ad:be:ef,vhost_user=true,socket=/tmp/sock"
|
||||||
|
)?,
|
||||||
NetConfig {
|
NetConfig {
|
||||||
mac: MacAddr::parse_str("de:ad:be:ef:12:34").unwrap(),
|
mac: MacAddr::parse_str("de:ad:be:ef:12:34").unwrap(),
|
||||||
host_mac: MacAddr::parse_str("12:34:de:ad:be:ef").unwrap(),
|
host_mac: MacAddr::parse_str("12:34:de:ad:be:ef").unwrap(),
|
||||||
vhost_user: true,
|
vhost_user: true,
|
||||||
vhost_socket: Some("/tmp/socket".to_owned()),
|
vhost_socket: Some("/tmp/sock".to_owned()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -1720,27 +1722,27 @@ mod tests {
|
|||||||
// "tag" and "socket" must be supplied
|
// "tag" and "socket" must be supplied
|
||||||
assert!(FsConfig::parse("").is_err());
|
assert!(FsConfig::parse("").is_err());
|
||||||
assert!(FsConfig::parse("tag=mytag").is_err());
|
assert!(FsConfig::parse("tag=mytag").is_err());
|
||||||
assert!(FsConfig::parse("sock=/tmp/sock").is_err());
|
assert!(FsConfig::parse("socket=/tmp/sock").is_err());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
FsConfig::parse("tag=mytag,sock=/tmp/sock")?,
|
FsConfig::parse("tag=mytag,socket=/tmp/sock")?,
|
||||||
FsConfig {
|
FsConfig {
|
||||||
sock: PathBuf::from("/tmp/sock"),
|
socket: PathBuf::from("/tmp/sock"),
|
||||||
tag: "mytag".to_owned(),
|
tag: "mytag".to_owned(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
FsConfig::parse("tag=mytag,sock=/tmp/sock")?,
|
FsConfig::parse("tag=mytag,socket=/tmp/sock")?,
|
||||||
FsConfig {
|
FsConfig {
|
||||||
sock: PathBuf::from("/tmp/sock"),
|
socket: PathBuf::from("/tmp/sock"),
|
||||||
tag: "mytag".to_owned(),
|
tag: "mytag".to_owned(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
FsConfig::parse("tag=mytag,sock=/tmp/sock,num_queues=4,queue_size=1024")?,
|
FsConfig::parse("tag=mytag,socket=/tmp/sock,num_queues=4,queue_size=1024")?,
|
||||||
FsConfig {
|
FsConfig {
|
||||||
sock: PathBuf::from("/tmp/sock"),
|
socket: PathBuf::from("/tmp/sock"),
|
||||||
tag: "mytag".to_owned(),
|
tag: "mytag".to_owned(),
|
||||||
num_queues: 4,
|
num_queues: 4,
|
||||||
queue_size: 1024,
|
queue_size: 1024,
|
||||||
@ -1749,9 +1751,9 @@ mod tests {
|
|||||||
);
|
);
|
||||||
// DAX on -> default cache size
|
// DAX on -> default cache size
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
FsConfig::parse("tag=mytag,sock=/tmp/sock,dax=on")?,
|
FsConfig::parse("tag=mytag,socket=/tmp/sock,dax=on")?,
|
||||||
FsConfig {
|
FsConfig {
|
||||||
sock: PathBuf::from("/tmp/sock"),
|
socket: PathBuf::from("/tmp/sock"),
|
||||||
tag: "mytag".to_owned(),
|
tag: "mytag".to_owned(),
|
||||||
dax: true,
|
dax: true,
|
||||||
cache_size: default_fsconfig_cache_size(),
|
cache_size: default_fsconfig_cache_size(),
|
||||||
@ -1759,9 +1761,9 @@ mod tests {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
FsConfig::parse("tag=mytag,sock=/tmp/sock,dax=on,cache_size=4G")?,
|
FsConfig::parse("tag=mytag,socket=/tmp/sock,dax=on,cache_size=4G")?,
|
||||||
FsConfig {
|
FsConfig {
|
||||||
sock: PathBuf::from("/tmp/sock"),
|
socket: PathBuf::from("/tmp/sock"),
|
||||||
tag: "mytag".to_owned(),
|
tag: "mytag".to_owned(),
|
||||||
dax: true,
|
dax: true,
|
||||||
cache_size: 4 << 30,
|
cache_size: 4 << 30,
|
||||||
@ -1769,7 +1771,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
// Cache size without DAX is an error
|
// Cache size without DAX is an error
|
||||||
assert!(FsConfig::parse("tag=mytag,sock=/tmp/sock,dax=off,cache_size=4G").is_err());
|
assert!(FsConfig::parse("tag=mytag,socket=/tmp/sock,dax=off,cache_size=4G").is_err());
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1901,22 +1903,22 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_vsock_parsing() -> Result<()> {
|
fn test_vsock_parsing() -> Result<()> {
|
||||||
// sock and cid is required
|
// socket and cid is required
|
||||||
assert!(VsockConfig::parse("").is_err());
|
assert!(VsockConfig::parse("").is_err());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
VsockConfig::parse("sock=/tmp/sock,cid=1")?,
|
VsockConfig::parse("socket=/tmp/sock,cid=1")?,
|
||||||
VsockConfig {
|
VsockConfig {
|
||||||
cid: 1,
|
cid: 1,
|
||||||
sock: PathBuf::from("/tmp/sock"),
|
socket: PathBuf::from("/tmp/sock"),
|
||||||
iommu: false,
|
iommu: false,
|
||||||
id: None,
|
id: None,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
VsockConfig::parse("sock=/tmp/sock,cid=1,iommu=on")?,
|
VsockConfig::parse("socket=/tmp/sock,cid=1,iommu=on")?,
|
||||||
VsockConfig {
|
VsockConfig {
|
||||||
cid: 1,
|
cid: 1,
|
||||||
sock: PathBuf::from("/tmp/sock"),
|
socket: PathBuf::from("/tmp/sock"),
|
||||||
iommu: true,
|
iommu: true,
|
||||||
id: None,
|
id: None,
|
||||||
}
|
}
|
||||||
@ -1993,7 +1995,7 @@ mod tests {
|
|||||||
|
|
||||||
let mut invalid_config = valid_config.clone();
|
let mut invalid_config = valid_config.clone();
|
||||||
invalid_config.disks = Some(vec![DiskConfig {
|
invalid_config.disks = Some(vec![DiskConfig {
|
||||||
vhost_socket: Some("/path/to/socket".to_owned()),
|
vhost_socket: Some("/path/to/sock".to_owned()),
|
||||||
path: Some(PathBuf::from("/path/to/image")),
|
path: Some(PathBuf::from("/path/to/image")),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}]);
|
}]);
|
||||||
|
@ -135,7 +135,7 @@ pub enum DeviceManagerError {
|
|||||||
/// Cannot create virtio-fs device
|
/// Cannot create virtio-fs device
|
||||||
CreateVirtioFs(vm_virtio::vhost_user::Error),
|
CreateVirtioFs(vm_virtio::vhost_user::Error),
|
||||||
|
|
||||||
/// Virtio-fs device was created without a sock.
|
/// Virtio-fs device was created without a socket.
|
||||||
NoVirtioFsSock,
|
NoVirtioFsSock,
|
||||||
|
|
||||||
/// Cannot create vhost-user-blk device
|
/// Cannot create vhost-user-blk device
|
||||||
@ -1331,7 +1331,7 @@ impl DeviceManager {
|
|||||||
/// Launch block backend
|
/// Launch block backend
|
||||||
fn start_block_backend(&mut self, disk_cfg: &DiskConfig) -> DeviceManagerResult<String> {
|
fn start_block_backend(&mut self, disk_cfg: &DiskConfig) -> DeviceManagerResult<String> {
|
||||||
let _socket_file = NamedTempFile::new().map_err(DeviceManagerError::CreateSocketFile)?;
|
let _socket_file = NamedTempFile::new().map_err(DeviceManagerError::CreateSocketFile)?;
|
||||||
let sock = _socket_file.path().to_str().unwrap().to_owned();
|
let socket = _socket_file.path().to_str().unwrap().to_owned();
|
||||||
|
|
||||||
let child = std::process::Command::new(&self.vmm_path)
|
let child = std::process::Command::new(&self.vmm_path)
|
||||||
.args(&[
|
.args(&[
|
||||||
@ -1344,7 +1344,7 @@ impl DeviceManager {
|
|||||||
.ok_or(DeviceManagerError::NoDiskPath)?
|
.ok_or(DeviceManagerError::NoDiskPath)?
|
||||||
.to_str()
|
.to_str()
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
&sock,
|
&socket,
|
||||||
disk_cfg.num_queues,
|
disk_cfg.num_queues,
|
||||||
disk_cfg.queue_size
|
disk_cfg.queue_size
|
||||||
),
|
),
|
||||||
@ -1358,7 +1358,7 @@ impl DeviceManager {
|
|||||||
_socket_file,
|
_socket_file,
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(sock)
|
Ok(socket)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_virtio_block_device(
|
fn make_virtio_block_device(
|
||||||
@ -1374,13 +1374,13 @@ impl DeviceManager {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if disk_cfg.vhost_user {
|
if disk_cfg.vhost_user {
|
||||||
let sock = if let Some(sock) = disk_cfg.vhost_socket.clone() {
|
let socket = if let Some(socket) = disk_cfg.vhost_socket.clone() {
|
||||||
sock
|
socket
|
||||||
} else {
|
} else {
|
||||||
self.start_block_backend(disk_cfg)?
|
self.start_block_backend(disk_cfg)?
|
||||||
};
|
};
|
||||||
let vu_cfg = VhostUserConfig {
|
let vu_cfg = VhostUserConfig {
|
||||||
sock,
|
socket,
|
||||||
num_queues: disk_cfg.num_queues,
|
num_queues: disk_cfg.num_queues,
|
||||||
queue_size: disk_cfg.queue_size,
|
queue_size: disk_cfg.queue_size,
|
||||||
};
|
};
|
||||||
@ -1506,7 +1506,7 @@ impl DeviceManager {
|
|||||||
/// Launch network backend
|
/// Launch network backend
|
||||||
fn start_net_backend(&mut self, net_cfg: &NetConfig) -> DeviceManagerResult<String> {
|
fn start_net_backend(&mut self, net_cfg: &NetConfig) -> DeviceManagerResult<String> {
|
||||||
let _socket_file = NamedTempFile::new().map_err(DeviceManagerError::CreateSocketFile)?;
|
let _socket_file = NamedTempFile::new().map_err(DeviceManagerError::CreateSocketFile)?;
|
||||||
let sock = _socket_file.path().to_str().unwrap().to_owned();
|
let socket = _socket_file.path().to_str().unwrap().to_owned();
|
||||||
|
|
||||||
let child = std::process::Command::new(&self.vmm_path)
|
let child = std::process::Command::new(&self.vmm_path)
|
||||||
.args(&[
|
.args(&[
|
||||||
@ -1515,7 +1515,7 @@ impl DeviceManager {
|
|||||||
"ip={},mask={},socket={},num_queues={},queue_size={},host_mac={}",
|
"ip={},mask={},socket={},num_queues={},queue_size={},host_mac={}",
|
||||||
net_cfg.ip,
|
net_cfg.ip,
|
||||||
net_cfg.mask,
|
net_cfg.mask,
|
||||||
&sock,
|
&socket,
|
||||||
net_cfg.num_queues,
|
net_cfg.num_queues,
|
||||||
net_cfg.queue_size,
|
net_cfg.queue_size,
|
||||||
net_cfg.host_mac
|
net_cfg.host_mac
|
||||||
@ -1530,7 +1530,7 @@ impl DeviceManager {
|
|||||||
_socket_file,
|
_socket_file,
|
||||||
});
|
});
|
||||||
|
|
||||||
Ok(sock)
|
Ok(socket)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_virtio_net_device(
|
fn make_virtio_net_device(
|
||||||
@ -1546,13 +1546,13 @@ impl DeviceManager {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if net_cfg.vhost_user {
|
if net_cfg.vhost_user {
|
||||||
let sock = if let Some(sock) = net_cfg.vhost_socket.clone() {
|
let socket = if let Some(socket) = net_cfg.vhost_socket.clone() {
|
||||||
sock
|
socket
|
||||||
} else {
|
} else {
|
||||||
self.start_net_backend(net_cfg)?
|
self.start_net_backend(net_cfg)?
|
||||||
};
|
};
|
||||||
let vu_cfg = VhostUserConfig {
|
let vu_cfg = VhostUserConfig {
|
||||||
sock,
|
socket,
|
||||||
num_queues: net_cfg.num_queues,
|
num_queues: net_cfg.num_queues,
|
||||||
queue_size: net_cfg.queue_size,
|
queue_size: net_cfg.queue_size,
|
||||||
};
|
};
|
||||||
@ -1715,7 +1715,7 @@ impl DeviceManager {
|
|||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(fs_sock) = fs_cfg.sock.to_str() {
|
if let Some(fs_socket) = fs_cfg.socket.to_str() {
|
||||||
let cache = if fs_cfg.dax {
|
let cache = if fs_cfg.dax {
|
||||||
let (cache_base, cache_size) = if let Some((base, size)) = cache_range {
|
let (cache_base, cache_size) = if let Some((base, size)) = cache_range {
|
||||||
// The memory needs to be 2MiB aligned in order to support
|
// The memory needs to be 2MiB aligned in order to support
|
||||||
@ -1792,7 +1792,7 @@ impl DeviceManager {
|
|||||||
let virtio_fs_device = Arc::new(Mutex::new(
|
let virtio_fs_device = Arc::new(Mutex::new(
|
||||||
vm_virtio::vhost_user::Fs::new(
|
vm_virtio::vhost_user::Fs::new(
|
||||||
id.clone(),
|
id.clone(),
|
||||||
fs_sock,
|
fs_socket,
|
||||||
&fs_cfg.tag,
|
&fs_cfg.tag,
|
||||||
fs_cfg.num_queues,
|
fs_cfg.num_queues,
|
||||||
fs_cfg.queue_size,
|
fs_cfg.queue_size,
|
||||||
@ -2028,7 +2028,7 @@ impl DeviceManager {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let socket_path = vsock_cfg
|
let socket_path = vsock_cfg
|
||||||
.sock
|
.socket
|
||||||
.to_str()
|
.to_str()
|
||||||
.ok_or(DeviceManagerError::CreateVsockConvertPath)?;
|
.ok_or(DeviceManagerError::CreateVsockConvertPath)?;
|
||||||
let backend =
|
let backend =
|
||||||
@ -2039,7 +2039,7 @@ impl DeviceManager {
|
|||||||
vm_virtio::Vsock::new(
|
vm_virtio::Vsock::new(
|
||||||
id.clone(),
|
id.clone(),
|
||||||
vsock_cfg.cid,
|
vsock_cfg.cid,
|
||||||
vsock_cfg.sock.clone(),
|
vsock_cfg.socket.clone(),
|
||||||
backend,
|
backend,
|
||||||
vsock_cfg.iommu,
|
vsock_cfg.iommu,
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user