summaryrefslogtreecommitdiffstats
path: root/docs/usecases/vhost/vhost02.rst
blob: 17bbafc854f833b15c7928997cf0e7ca8276bcaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
.. _vhost02:

Creating the Virtual Machine
----------------------------

We will now create the virtual machine. We use the "virsh create command".

It is important to note that in the XML file we specify the socket path that is used to connect to
FD.io VPP.

This is done with a section that looks like this

.. code-block:: console

    <interface type='vhostuser'>
      <mac address='52:54:00:4c:47:f2'/>
      <source type='unix' path='/tmp//vm00.sock' mode='server'/>
      <driver rx_queue_size='1024' tx_queue_size='1024'/>
      <model type='virtio'/>
      <alias name='net1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
    </interface>

Notice the **interface type** and the **path** to the socket.

Now we create the VM. The virsh list command shows the VMs that have been created. We start with no VMs.

.. code-block:: console

    $ virsh list
    Id    Name                           State
    ----------------------------------------------------

Create the VM with the virsh create command specifying our xml file.

.. code-block:: console

    $ virsh create ./iperf3-vm.xml
    Domain iperf-server3 created from ./iperf3-vm.xml

    $ virsh list
    Id    Name                           State
    ----------------------------------------------------
    65    iperf-server3                  running

The VM is now created.

.. note::

    After a VM is created an xml file can created with "virsh dumpxml".

.. code-block:: console

    $ virsh dumpxml iperf-server3
    <domain type='kvm' id='65'>
      <name>iperf-server3</name>
      <uuid>e23d37c1-10c3-4a6e-ae99-f315a4165641</uuid>
      <memory unit='KiB'>262144</memory>
    .....

Once the virtual machine is created notice the socket filename shows **Success** and
there are **Memory Regions**. At this point the VM and FD.io VPP are connected. Also
notice **qsz 1024**. A queue size of 256 will affect vhost throughput. The qsz should
be 1024. In QEMU 2.10.0 and libvirt 3.7.0 and later versions this is specified in the
xml file with the line **<driver rx_queue_size='1024' tx_queue_size='1024'/>** shown above
and in the example.

.. code-block:: console

    vpp# show vhost
    Virtio vhost-user interfaces
    Global:
      coalesce frames 32 time 1e-3
      number of rx virtqueues in interrupt mode: 0
    Interface: VirtualEthernet0/0/0 (ifindex 3)
    virtio_net_hdr_sz 12
     features mask (0xffffffffffffffff):
     features (0x58208000):
       VIRTIO_NET_F_MRG_RXBUF (15)
       VIRTIO_NET_F_GUEST_ANNOUNCE (21)
       VIRTIO_F_ANY_LAYOUT (27)
       VIRTIO_F_INDIRECT_DESC (28)
       VHOST_USER_F_PROTOCOL_FEATURES (30)
      protocol features (0x3)
       VHOST_USER_PROTOCOL_F_MQ (0)
       VHOST_USER_PROTOCOL_F_LOG_SHMFD (1)

     socket filename /tmp/vm00.sock type client errno "Success"

     rx placement:
       thread 1 on vring 1, polling
     tx placement: spin-lock
       thread 0 on vring 0
       thread 1 on vring 0

     Memory regions (total 2)
     region fd    guest_phys_addr    memory_size        userspace_addr     mmap_offset        mmap_addr
     ====== ===== ================== ================== ================== ================== ===============    ===
      0     31    0x0000000000000000 0x00000000000a0000 0x00007f1db9c00000 0x0000000000000000 0x00007f7db0400    000
      1     32    0x00000000000c0000 0x000000000ff40000 0x00007f1db9cc0000 0x00000000000c0000 0x00007f7d94ec0    000

     Virtqueue 0 (TX)
      qsz 1024 last_avail_idx 0 last_used_idx 0
      avail.flags 0 avail.idx 256 used.flags 1 used.idx 0
      kickfd 33 callfd 34 errfd -1

     Virtqueue 1 (RX)
      qsz 1024 last_avail_idx 8 last_used_idx 8
      avail.flags 0 avail.idx 8 used.flags 1 used.idx 8
      kickfd 29 callfd 35 errfd -1