Skip to content

Commit

Permalink
rust-vsock-payload: update doc
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaoyu Lu <xiaoyux.lu@intel.com>
  • Loading branch information
Xiaoyu Lu committed Sep 6, 2021
1 parent 6fd98fc commit ba170f3
Show file tree
Hide file tree
Showing 2 changed files with 142 additions and 1 deletion.
136 changes: 136 additions & 0 deletions rust-vsock-payload/about_vsock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@


## VirtIO VSock

### Enable Vsock module

```insmod vhost_vsock```
```insmod vsock```

```
# set vsock permission
sudo setfacl -m u:${USER}:rw /dev/vhost-vsock
```

result:
```
luxy@luxy-clr-linux ~/run/vsock $ ls -l /dev/vhost-vsock
crw-rw----+ 1 root root 10, 241 Jul 30 15:33 /dev/vhost-vsock
luxy@luxy-clr-linux ~/run/vsock $ lsmod | grep vsock
vsockmon 16384 1
vhost_vsock 24576 0
vmw_vsock_virtio_transport_common 36864 1 vhost_vsock
vsock 45056 3 vmw_vsock_virtio_transport_common,vhost_vsock,vsockmon
luxy@luxy-clr-linux ~/run/vsock $
```


### Test with Nmap (test vsock)

**Version** Use 7.91

NMap
https://nmap.org/download.html

NMap source
https://nmap.org/dist/

Install
https://nmap.org/book/inst-source.html

```
tar xf nmap-7.91.tar.bz2
pushd nmap-7.91/
./configure --prefix /home/luxy/local
make install
popd
export PATH=/home/luxy/local/bin:$PATH
libtool --finish /home/luxy/local/lib
```


```
# listening in host and guest connecting, in this case, they can communicate each other.
# listening in guest and host connecting, in this case, they communicate failed.
# assume guest CID is 33
nc -v --vsock -l 1234
nc -v --vsock 33 1234
```

### Test with Socat

SOCAT
http://www.dest-unreach.org/socat/
**version** 1.7.4.1 on Jul 6 2021 07:45:25
Download: http://www.dest-unreach.org/socat/download/socat-1.7.4.1.tar.gz

```
wget http://www.dest-unreach.org/socat/download/socat-1.7.4.1.tar.gz
e
tar xf socat-1.7.4.1.tar.gz
cd socat-1.7.4.1
./configure
make
make install
```

Socat Example
http://www.dest-unreach.org/socat/doc/socat.html#EXAMPLES

Vsock Test
```
socat - VSOCK-LISTEN:1234
socat - VSOCK-CONNECT:33:1234
```


### Qemu param

CLEARLINUX ref: https://docs.01.org/clearlinux/latest/

```
qemu-system-x86_64 \
-enable-kvm \
-bios $OVMF_FD \
-smp sockets=1,cpus=1,cores=1 -cpu host \
-m 1024 \
-vga none -nographic \
-drive file="$CLEAR_LINUX",if=virtio,aio=threads,format=raw \
-device vhost-vsock-pci,id=vhost-vsock-pci1,guest-cid=${VMN} \
-debugcon file:debug.log -global isa-debugcon.iobase=0x402
```


### Vsock spec

https://github.com/stefanha/virtio

vsock qemu driver
https://github.com/stefanha/qemu/tree/vsock

vsock linux driver
https://github.com/stefanha/linux/tree/vsock


### Appendix A: Reference
kvm conference
https://www.youtube.com/watch?v=_bYSQ68JPwE

use qemu with vsock
https://gist.github.com/mcastelino/9a57d00ccf245b98de2129f0efe39857

VSOCK: VM ↔host socket with minimal configuration - DevConfCZ 2020
https://www.youtube.com/watch?v=R5DQWdPUQSY
https://static.sched.com/hosted_files/devconfcz2020a/b1/DevConf.CZ_2020_vsock_v1.1.pdf

Clear Linux
https://docs.01.org/clearlinux/latest/get-started/virtual-machine-install/kvm.html
https://cdn.download.clearlinux.org/image/

VirtioVsock:
https://static.sched.com/hosted_files/kvmforum2019/50/KVMForum_2019_virtio_vsock_Andra_Paraschiv_Stefano_Garzarella_v1.3.pdf

VSOCK linux upstream
https://lwn.net/Articles/520000/
7 changes: 6 additions & 1 deletion rust-vsock-payload/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ Qemu version is *QEMU emulator version 5.2.0*
Linux kernel version is *5.12.16*

```
## enable vsock-vhost module
sudo insmod vhost-vsock
# set vhost-vsock permission
sudo setfacl -m u:${USER}:rw /dev/vhost-vsock
## RUST_FIRMWARE_BIN is final_vsock.bin
## VMN is GUEST_CID
export VMN=33
/home/luxy/local/bin/qemu-system-x86_64 \
-m 4G -machine q35 \
-m 2G -machine q35 \
-drive if=pflash,format=raw,unit=0,file=$RUST_FIRMWARE_BIN \
-device vhost-vsock-pci,id=vhost-vsock-pci1,guest-cid=${VMN} \
-nic none -vnc 0.0.0.0:1 -serial mon:stdio \
Expand Down

0 comments on commit ba170f3

Please sign in to comment.