1This document describes how to test each device, which is required when 2modifying the common I/O infrastructure. 3 4 59P 6-- 7 8 CONFIG_NET_9P_VIRTIO 9 10Without a --disk parameter, kvmtool shares part of the host filesystem 11with the guest using 9p. Otherwise, use the `--9p <directory>,<tag>` 12parameter to share a directory with the guest, and mount it in the guest 13with: 14 15 $ mount -t 9p <tag> <mountpoint> 16 17 18BALLOON 19------- 20 21 CONFIG_VIRTIO_BALLOON 22 23 $ lkvm run ... --balloon 24 25Display memory statistics: 26 27 $ lkvm stat -a -m 28 *** Guest memory statistics *** 29 ... 30 31Remove 20MB of memory from the guest: 32 33 $ lkvm balloon -n guest-$(pidof lkvm) -i 20 34 35 36BLOCK 37----- 38 39 CONFIG_VIRTIO_BLK 40 41 $ lkvm run ... --disk <raw or qcow2 image> 42 43 44CONSOLE 45------- 46 47 $ lkvm run ... --console virtio 48 49See also virtio-console.txt 50 51 52NET 53--- 54 55 CONFIG_VIRTIO_NET (guest) 56 CONFIG_VHOST_NET (host) 57 58By default kvmtool instantiates a user network device. In order to test 59both tap and vhost, setup a tap interface on a local network. 60 61In the host: 62 63 # ip tuntap add tap0 mode tap user $USER 64 # ip link set tap0 up 65 # ip link add br0 type bridge 66 # ip link set tap0 master br0 67 # ip link set br0 up 68 # ip addr add 192.168.3.1/24 dev br0 69 70 $ lkvm run ... -n mode=tap,tapif=tap0,vhost=1 71 72In the guest: 73 74 # ip link set eth0 up 75 # ip addr add 192.168.3.12/24 dev eth0 76 $ ping -c 1 192.168.3.1 77 64 bytes from 192.168.3.1: seq=0 ttl=64 time=0.303 ms 78 79 80RNG 81--- 82 83 CONFIG_HW_RANDOM_VIRTIO 84 85 $ lkvm run ... --rng 86 87In the guest: 88 89 $ cat /sys/devices/virtual/misc/hw_random/rng_available 90 virtio_rng.0 91 92 93SCSI 94---- 95 96 CONFIG_SCSI_VIRTIO (guest) 97 CONFIG_TCM_FILEIO (host) 98 CONFIG_VHOST_SCSI (host) 99 100In the host, create a fileio backstore and a target: 101 102 # targetcli (https://github.com/open-iscsi/targetcli-fb) 103 /> cd backstores/fileio 104 /backstores/fileio> create kvmtool_1 /srv/kvmtool_1 2M 105 Created fileio kvmtool_1 with size 2097152 106 /backstores/fileio> cd /vhost 107 /vhost> create 108 Created target naa.500140571c9308aa. 109 Created TPG 1. 110 /vhost> cd naa.500140571c9308aa/tpg1/luns 111 /vhost/naa.50...8aa/tpg1/luns> create /backstores/fileio/kvmtool_1 112 Created LUN 0. 113 114 $ lkvm run ... --disk scsi:naa.500140571c9308aa 115 [ 0.479644] scsi host0: Virtio SCSI HBA 116 [ 0.483009] scsi 0:0:1:0: Direct-Access LIO-ORG kvmtool_1 4.0 PQ: 0 ANSI: 6 117 118 [ 1.242833] sd 0:0:1:0: [sda] 4096 512-byte logical blocks: (2.10 MB/2.00 MiB) 119 120 121VSOCK 122----- 123 124 CONFIG_VSOCKETS 125 CONFIG_VIRTIO_VSOCKETS (guest) 126 CONFIG_VHOST_VSOCK (host) 127 128In the host, start a vsock server: 129 130 $ socat - VSOCK-LISTEN:1234 131 132We pick 12 as the guest ID. 0 and 1 are reserved, and the host has default 133ID 2. 134 135 $ lkvm run ... --vsock 12 136 137In the guest, send a message to the host: 138 139 $ echo Hello | socat - VSOCK-CONNECT:2:1234 140 141The host server should display "Hello". 142