| 1 |
vscp |
| 2 |
==== |
| 3 |
|
| 4 |
Command `vscp` provides a `scp`-like utility for copying files over VM |
| 5 |
sockets. It is meant to show example usage of package `vsock`, but is |
| 6 |
also useful in scenarios where a virtual machine does not have |
| 7 |
networking configured, but VM sockets are available. |
| 8 |
|
| 9 |
Usage |
| 10 |
----- |
| 11 |
|
| 12 |
`vscp` has two modes of operation: receiving and sending. |
| 13 |
|
| 14 |
``` |
| 15 |
$ vscp -h |
| 16 |
Usage of vscp: |
| 17 |
-c uint |
| 18 |
send only: context ID of the remote VM socket |
| 19 |
-p uint |
| 20 |
- receive: port ID to listen on (random port by default) |
| 21 |
- send: port ID to connect to |
| 22 |
-r receive files from another instance of vscp |
| 23 |
-s send files to another instance of vscp |
| 24 |
-v enable verbose logging to stderr |
| 25 |
``` |
| 26 |
|
| 27 |
For example, let's transfer the contents of `/proc/cpuinfo` from a |
| 28 |
virtual machine to a hypervisor. |
| 29 |
|
| 30 |
First, start a server on the hypervisor. The following command will: |
| 31 |
- enable verbose logging |
| 32 |
- start `vscp` as a server to receive data |
| 33 |
- specify port 1024 as the server's listener port |
| 34 |
- use `cpuinfo.txt` as an output file |
| 35 |
|
| 36 |
``` |
| 37 |
hv $ vscp -v -r -p 1024 cpuinfo.txt |
| 38 |
2017/03/10 10:51:48 receive: creating file "cpuinfo.txt" for output |
| 39 |
2017/03/10 10:51:48 receive: opening listener: 1024 |
| 40 |
2017/03/10 10:51:48 receive: listening: host(2):1024 |
| 41 |
# listening for client connection |
| 42 |
``` |
| 43 |
|
| 44 |
Next, in the virtual machine, start a client to send a file to |
| 45 |
the server on the hypervisor. The following command will: |
| 46 |
- enable verbose logging |
| 47 |
- start `vscp` as a client to send data |
| 48 |
- specify context ID 2 (host process) as the server's context ID |
| 49 |
- specify port 1024 as the server's port |
| 50 |
- use `/proc/cpuinfo` as an input file |
| 51 |
|
| 52 |
``` |
| 53 |
vm $ vscp -v -s -c 2 -p 1024 /proc/cpuinfo |
| 54 |
2017/03/10 10:56:18 send: opening file "/proc/cpuinfo" for input |
| 55 |
2017/03/10 10:56:18 send: dialing: 2.1024 |
| 56 |
2017/03/10 10:56:18 send: client: vm(3):1077 |
| 57 |
2017/03/10 10:56:18 send: server: host(2):1024 |
| 58 |
2017/03/10 10:56:18 send: sending data |
| 59 |
2017/03/10 10:56:18 send: transfer complete |
| 60 |
vm $ |
| 61 |
``` |
| 62 |
|
| 63 |
The transfer is now complete. You should see more output in the |
| 64 |
hypervisor's terminal, and the server process should have exited. |
| 65 |
|
| 66 |
``` |
| 67 |
hv $ vscp -v -r -p 1024 cpuinfo.txt |
| 68 |
2017/03/10 10:51:48 receive: creating file "cpuinfo.txt" for output |
| 69 |
2017/03/10 10:51:48 receive: opening listener: 1024 |
| 70 |
2017/03/10 10:51:48 receive: listening: host(2):1024 |
| 71 |
# listening for client connection |
| 72 |
2017/03/10 10:55:39 receive: server: host(2):1024 |
| 73 |
2017/03/10 10:55:39 receive: client: vm(3):1077 |
| 74 |
2017/03/10 10:55:39 receive: receiving data |
| 75 |
2017/03/10 10:55:39 receive: transfer complete |
| 76 |
hv $ |
| 77 |
``` |
| 78 |
|
| 79 |
To verify the transfer worked as intended, you can check the hash |
| 80 |
of the file on both sides using a tool such as `md5sum`. |
| 81 |
|
| 82 |
``` |
| 83 |
hv $ md5sum cpuinfo.txt |
| 84 |
cda57941b11f0c82da425eec5d837c26 cpuinfo.txt |
| 85 |
``` |
| 86 |
``` |
| 87 |
vm $ md5sum /proc/cpuinfo |
| 88 |
cda57941b11f0c82da425eec5d837c26 /proc/cpuinfo |
| 89 |
``` |