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