d316463c15a00b294e832277afefdb28d172b019
[vpp.git] / docs / usecases / vhost / vhost02.rst
1 .. _vhost02:
2
3 Creating the Virtual Machine
4 ----------------------------
5
6 We will now create the virtual machine. We use the "virsh create command". For the complete file we
7 use refer to :ref:`xmlexample`.
8
9 It is important to note that in the XML file we specify the socket path that is used to connect to
10 FD.io VPP.
11
12 This is done with a section that looks like this
13
14 .. code-block:: console
15
16     <interface type='vhostuser'>
17       <mac address='52:54:00:4c:47:f2'/>
18       <source type='unix' path='/tmp//vm00.sock' mode='server'/>
19       <driver rx_queue_size='1024' tx_queue_size='1024'/>
20       <model type='virtio'/>
21       <alias name='net1'/>
22       <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
23     </interface>
24
25 Notice the **interface type** and the **path** to the socket.
26
27 Now we create the VM. The virsh list command shows the VMs that have been created. We start with no VMs.
28
29 .. code-block:: console
30
31     $ virsh list
32     Id    Name                           State
33     ----------------------------------------------------
34
35 Create the VM with the virsh create command specifying our xml file.
36
37 .. code-block:: console
38
39     $ virsh create ./iperf3-vm.xml
40     Domain iperf-server3 created from ./iperf3-vm.xml
41
42     $ virsh list
43     Id    Name                           State
44     ----------------------------------------------------
45     65    iperf-server3                  running
46
47 The VM is now created.
48
49 .. note::
50
51     After a VM is created an xml file can created with "virsh dumpxml".
52
53 .. code-block:: console
54
55     $ virsh dumpxml iperf-server3
56     <domain type='kvm' id='65'>
57       <name>iperf-server3</name>
58       <uuid>e23d37c1-10c3-4a6e-ae99-f315a4165641</uuid>
59       <memory unit='KiB'>262144</memory>
60     .....
61
62 Once the virtual machine is created notice the socket filename shows **Success** and
63 there are **Memory Regions**. At this point the VM and FD.io VPP are connected. Also
64 notice **qsz 1024**. A queue size of 256 will affect vhost throughput. The qsz should
65 be 1024. In QEMU 2.10.0 and libvirt 3.7.0 and later versions this is specified in the
66 xml file with the line **<driver rx_queue_size='1024' tx_queue_size='1024'/>** shown above
67 and in the example.
68
69 .. code-block:: console
70
71     vpp# show vhost
72     Virtio vhost-user interfaces
73     Global:
74       coalesce frames 32 time 1e-3
75       number of rx virtqueues in interrupt mode: 0
76     Interface: VirtualEthernet0/0/0 (ifindex 3)
77     virtio_net_hdr_sz 12
78      features mask (0xffffffffffffffff):
79      features (0x58208000):
80        VIRTIO_NET_F_MRG_RXBUF (15)
81        VIRTIO_NET_F_GUEST_ANNOUNCE (21)
82        VIRTIO_F_ANY_LAYOUT (27)
83        VIRTIO_F_INDIRECT_DESC (28)
84        VHOST_USER_F_PROTOCOL_FEATURES (30)
85       protocol features (0x3)
86        VHOST_USER_PROTOCOL_F_MQ (0)
87        VHOST_USER_PROTOCOL_F_LOG_SHMFD (1)
88     
89      socket filename /tmp/vm00.sock type client errno "Success"
90     
91      rx placement:
92        thread 1 on vring 1, polling
93      tx placement: spin-lock
94        thread 0 on vring 0
95        thread 1 on vring 0
96     
97      Memory regions (total 2)
98      region fd    guest_phys_addr    memory_size        userspace_addr     mmap_offset        mmap_addr
99      ====== ===== ================== ================== ================== ================== ===============    ===
100       0     31    0x0000000000000000 0x00000000000a0000 0x00007f1db9c00000 0x0000000000000000 0x00007f7db0400    000
101       1     32    0x00000000000c0000 0x000000000ff40000 0x00007f1db9cc0000 0x00000000000c0000 0x00007f7d94ec0    000
102     
103      Virtqueue 0 (TX)
104       qsz 1024 last_avail_idx 0 last_used_idx 0
105       avail.flags 0 avail.idx 256 used.flags 1 used.idx 0
106       kickfd 33 callfd 34 errfd -1
107     
108      Virtqueue 1 (RX)
109       qsz 1024 last_avail_idx 8 last_used_idx 8
110       avail.flags 0 avail.idx 8 used.flags 1 used.idx 8
111       kickfd 29 callfd 35 errfd -1