]> git.proxmox.com Git - mirror_ovs.git/blame - INSTALL.Windows.md
tests: Add mirror-related keywords to all the mirroring tests.
[mirror_ovs.git] / INSTALL.Windows.md
CommitLineData
542cc9bb
TG
1How to Build the Kernel module & userspace daemons for Windows
2==============================================================
c803536e
SS
3
4Autoconf, Automake and Visual C++:
5---------------------------------
6Open vSwitch on Linux uses autoconf and automake for generating Makefiles.
7It will be useful to maintain the same build system while compiling on Windows
8too. One approach is to compile Open vSwitch in a MinGW environment that
9contains autoconf and automake utilities and then use Visual C++ as a compiler
10and linker.
11
12The following explains the steps in some detail.
13
14* Install Mingw on a Windows machine by following the instructions at:
15http://www.mingw.org/wiki/Getting_Started
16
17This should install mingw at C:\Mingw and msys at C:\Mingw\msys.
18Add "C:\MinGW\bin" and "C:\Mingw\msys\1.0\bin" to PATH environment variable
19of Windows.
20
21You can either use the MinGW installer or the command line utility 'mingw-get'
22to install both the base packages and additional packages like automake and
23autoconf(version 2.68).
24
25Also make sure that /mingw mount point exists. If its not, please add/create
26the following entry in /etc/fstab - 'C:/MinGW /mingw'.
27
28* Install the latest Python 2.x from python.org and verify that its path is
29part of Windows' PATH environment variable.
30
ecbc260f
GS
31* You will need at least Visual Studio 2013 (update 4) to compile userspace
32binaries. In addition to that, if you want to compile the kernel module you
33will also need to install Windows Driver Kit (WDK) 8.1 Update.
c803536e
SS
34
35It is important to get the Visual Studio related environment variables and to
1cb3649c
AS
36have the $PATH inside the bash to point to the proper compiler and linker. One
37easy way to achieve this for VS2013 is to get into the "VS2013 x86 Native
38Tools Command Prompt" (in a default installation of Visual Studio 2013 this can
39be found under the following location:
40C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts)
41and through it enter into the bash shell available from msys by typing
38b01df6 42'bash --login'.
c803536e 43
1cb3649c
AS
44There is support for generating 64 bit binaries too. To compile under x64,
45open the "VS2013 x64 Native Tools Command Prompt" (if your current running OS
46is 64 bit) or "VS2013 x64 Cross Tools Command Prompt" (if your current running
47OS is not 64 bit) instead of opening its x86 variant. This will point the
48compiler and the linker to their 64 bit equivalent.
49
c803536e
SS
50If after the above step, a 'which link' inside MSYS's bash says,
51"/bin/link.exe", rename /bin/link.exe to something else so that the
38b01df6
GS
52Visual studio's linker is used. You should also see a 'which sort' report
53"/bin/sort.exe".
c803536e
SS
54
55* For pthread support, install the library, dll and includes of pthreads-win32
56project from
57ftp://sourceware.org/pub/pthreads-win32/prebuilt-dll-2-9-1-release to a
d0d808fd
GS
58directory (e.g.: C:/pthread). You should add the pthread-win32's dll
59path (e.g.: C:\pthread\dll\x86) to the Windows' PATH environment variable.
c803536e
SS
60
61* Get the Open vSwitch sources from either cloning the repo using git
62or from a distribution tar ball.
63
64* If you pulled the sources directly from an Open vSwitch Git tree,
65 run boot.sh in the top source directory:
66
542cc9bb 67 % ./boot.sh
c803536e
SS
68
69* In the top source directory, configure the package by running the
70 configure script. You should provide some configure options to choose
71 the right compiler, linker, libraries, Open vSwitch component installation
72 directories, etc. For example,
73
694ebbc8
AS
74 % ./configure CC=./build-aux/cccl LD="`which link`" \
75 LIBS="-lws2_32 -liphlpapi" --prefix="C:/openvswitch/usr" \
76 --localstatedir="C:/openvswitch/var" --sysconfdir="C:/openvswitch/etc" \
77 --with-pthread="C:/pthread"
c803536e 78
b0e1bce5
GS
79 By default, the above enables compiler optimization for fast code.
80 For default compiler optimization, pass the "--with-debug" configure
81 option.
82
c803536e
SS
83* Run make for the ported executables in the top source directory, e.g.:
84
542cc9bb 85 % make
d9d8dbc8 86
d0d808fd
GS
87 For faster compilation, you can pass the '-j' argument to make. For
88 example, to run 4 jobs simultaneously, run 'make -j4'.
89
90 Note: MSYS 1.0.18 has a bug that causes parallel make to hang. You
91 can overcome this by downgrading to MSYS 1.0.17. A simple way to
92 downgrade is to exit all MinGW sessions and then run the command
93 'mingw-get upgrade msys-core-bin=1.0.17-1' from MSVC developers command
94 prompt.
95
96* To run all the unit tests in Open vSwitch, one at a time:
d9d8dbc8 97
542cc9bb 98 % make check
c803536e 99
d0d808fd
GS
100 To run all the unit tests in Open vSwitch, up to 8 in parallel:
101
102 % make check TESTSUITEFLAGS="-j8"
103
104* To install all the compiled executables on the local machine, run:
105
106 % make install
107
108 The above command will install the Open vSwitch executables in
109 C:/openvswitch. You can add 'C:\openvswitch\usr\bin' and
110 'C:\openvswitch\usr\sbin' to Windows' PATH environment variable
111 for easy access.
112
c803536e
SS
113OpenSSL, Open vSwitch and Visual C++
114------------------------------------
115To get SSL support for Open vSwitch on Windows, do the following:
116
117* Install OpenSSL for Windows as suggested at
118http://www.openssl.org/related/binaries.html.
119The link as of this writing suggests to download it from
bb996e5b 120http://slproweb.com/products/Win32OpenSSL.html
c803536e
SS
121
122Note down the directory where OpenSSL is installed (e.g.: C:/OpenSSL-Win32).
123
124* While configuring the package, specify the OpenSSL directory path.
125For example,
126
694ebbc8
AS
127 % ./configure CC=./build-aux/cccl LD="`which link`" \
128 LIBS="-lws2_32 -liphlpapi" --prefix="C:/openvswitch/usr" \
129 --localstatedir="C:/openvswitch/var" --sysconfdir="C:/openvswitch/etc" \
130 --with-pthread="C:/pthread" --enable-ssl --with-openssl="C:/OpenSSL-Win32"
c803536e
SS
131
132* Run make for the ported executables.
133
978ce0e9
NR
134Building the Kernel datapath module
135-----------------------------------
136* We directly use the Visual Studio 2013 IDE to compile the kernel datapath.
137You can open the extensions.sln file in the IDE and build the solution.
138
139* The kernel datapath can be compiled from command line as well. The top
140level 'make' will invoke building the kernel datapath, if the
d183efc2 141'--with-vstudiotarget' argument is specified while configuring the package.
978ce0e9
NR
142For example,
143
694ebbc8
AS
144 % ./configure CC=./build-aux/cccl LD="`which link`" \
145 LIBS="-lws2_32 -liphlpapi" --prefix="C:/openvswitch/usr" \
146 --localstatedir="C:/openvswitch/var" --sysconfdir="C:/openvswitch/etc" \
147 --with-pthread="C:/pthread" --enable-ssl \
d183efc2 148 --with-openssl="C:/OpenSSL-Win32" --with-vstudiotarget="<target type>"
978ce0e9 149
d183efc2
AS
150 Possible values for "<target type>" are:
151 "Debug" and "Release"
c803536e
SS
152
153Installing the Kernel module
154----------------------------
155Once you have built the solution, you can copy the following files to the
978ce0e9 156target Hyper-V machines.
c803536e
SS
157
158 ./datapath-windows/x64/Win8.1Debug/package/ovsext.inf
159 ./datapath-windows/x64/Win8.1Debug/package/OVSExt.sys
160 ./datapath-windows/x64/Win8.1Debug/package/ovsext.cat
161 ./datapath-windows/misc/install.cmd
162 ./datapath-windows/misc/uninstall.cmd
163
978ce0e9
NR
164The above path assumes that the kernel module has been built using Windows
165DDK 8.1 in Debug mode. Change the path appropriately, if a different WDK
166has been used.
167
c803536e
SS
168Steps to install the module
169---------------------------
170
17101> Run ./uninstall.cmd to remove the old extension.
0a46bca7
NR
172
17302> Run ./install.cmd to insert the new one. For this to work you will have to
c803536e 174turn on TESTSIGNING boot option or 'Disable Driver Signature Enforcement'
64d15689
NR
175during boot. The following commands can be used:
176 % bcdedit /set LOADOPTIONS DISABLE_INTEGRITY_CHECKS
177 % bcdedit /set TESTSIGNING ON
178 % bcdedit /set nointegritychecks ON
179
180Note: you may have to restart the machine for the settings to take effect.
0a46bca7
NR
181
18203> In the Virtual Switch Manager configuration you can enable the Open vSwitch
183Extension on an existing switch or create a new switch. If you are using an
184existing switch, make sure to enable the "Allow Management OS" option for VXLAN
185to work (covered later).
186
187The command to create a new switch named 'OVS-Extended-Switch' using a physical
188NIC named 'Ethernet 1' is:
189 % New-VMSwitch "OVS-Extended-Switch" -AllowManagementOS $true \
190 -NetAdapterName "Ethernet 1"
191
192Note: you can obtain the list of physical NICs on the host using
193'Get-NetAdapter' command.
194
19504> In the properties of any switch, you should should now see "Open
196vSwitch Extension" under 'Extensions'. Click the check box to enable the
197extension. An alternative way to do the same is to run the following command:
198 % Enable-VMSwitchExtension "Open vSwitch Extension" OVS-Extended-Switch
199
200Note: If you enabled the extension using the command line, a delay of a few
201seconds has been observed for the change to be reflected in the UI. This is
202not a bug in Open vSwitch.
203
204Steps to run the user processes & configure ports
205-------------------------------------------------
d0d808fd
GS
206The following steps assume that you have installed the Open vSwitch
207utilities in the local machine via 'make install'.
208
20901> Create the database.
210 % ovsdb-tool create C:\openvswitch\etc\openvswitch\conf.db \
211 C:\openvswitch\usr\share\openvswitch\vswitch.ovsschema
212
21302> Start the ovsdb-server and initialize the database.
214 % ovsdb-server -vfile:info --remote=punix:db.sock --log-file --pidfile \
215 --detach
216 % ovs-vsctl --no-wait init
217
218 If you would like to terminate the started ovsdb-server, run:
219 % ovs-appctl -t ovsdb-server exit
220
221 (Note that the logfile is created at C:/openvswitch/var/log/openvswitch/)
0a46bca7 222
d0d808fd
GS
22303> Start ovs-vswitchd.
224 % ovs-vswitchd -vfile:info --log-file --pidfile --detach
0a46bca7 225
d0d808fd
GS
226 If you would like to terminate the started ovs-vswitchd, run:
227 % ovs-appctl exit
0a46bca7 228
d0d808fd 229 (Note that the logfile is created at C:/openvswitch/var/log/openvswitch/)
0a46bca7
NR
230
23104> Create integration bridge & pif bridge
d0d808fd
GS
232 % ovs-vsctl add-br br-int
233 % ovs-vsctl add-br br-pif
0a46bca7 234
d0d808fd
GS
235NOTE: There's a known bug that running the ovs-vsctl command does not
236terminate. This is generally solved by having ovs-vswitchd running. If
237you face the issue despite that, hit Ctrl-C to terminate ovs-vsctl and
0a46bca7
NR
238check the output to see if your command succeeded.
239
d0d808fd
GS
240NOTE: There's a known bug that the ports added to OVSDB via ovs-vsctl don't
241get to the kernel datapath immediately, ie. they don't show up in the output of
242"ovs-dpctl show" even though they show up in output of "ovs-vsctl show".
243In order to workaround this issue, restart ovs-vswitchd. (You can terminate
244ovs-vswitchd by running 'ovs-appctl exit'.)
0a46bca7
NR
245
24605> Dump the ports in the kernel datapath
d0d808fd 247 % ovs-dpctl show
0a46bca7
NR
248
249* Sample output is as follows:
250
d0d808fd 251 % ovs-dpctl show
0a46bca7
NR
252 system@ovs-system:
253 lookups: hit:0 missed:0 lost:0
254 flows: 0
255 port 2: br-pif (internal) <<< internal port on 'br-pif' bridge
256 port 1: br-int (internal) <<< internal port on 'br-int' bridge
257
25806> Dump the ports in the OVSDB
d0d808fd 259 % ovs-vsctl show
0a46bca7
NR
260
261* Sample output is as follows:
d0d808fd 262 % ovs-vsctl show
0a46bca7
NR
263 a56ec7b5-5b1f-49ec-a795-79f6eb63228b
264 Bridge br-pif
265 Port br-pif
266 Interface br-pif
267 type: internal
268 Bridge br-int
269 Port br-int
270 Interface br-int
271 type: internal
272
27307> Add the physical NIC and the internal port to br-pif.
274
9f760fd8
AS
275In OVS for Hyper-V, we use the name of the adapter on top of which the Hyper-V
276virtual switch was created, as a special name to refer to the physical NICs
277connected to the Hyper-V switch. I.e. let us suppose we created the Hyper-V
278virtual switch on top of the adapter named 'Ethernet0'. In OVS for Hyper-V, we
279use that name('Ethernet0') as a special name to refer to that adapter.
0a46bca7
NR
280
281Note: Currently, we assume that the Hyper-V switch on which OVS extension is
282enabled has a single physical NIC connected to it.
283
9f760fd8 284Internal port is the virtual adapter created on the Hyper-V switch using the
0a46bca7 285'AllowManagementOS' setting. This has already been setup while creating the
9f760fd8
AS
286switch using the instructions above. In OVS for Hyper-V, we use a the name of
287that specific adapter as a special name to refer to that adapter. By default it
288is created under the following rule "vEthernet (<name of the switch>)".
0a46bca7 289
9f760fd8
AS
290As a whole example, if we issue the following in a powershell console:
291PS C:\package\binaries> Get-NetAdapter | select Name,MacAddress,InterfaceDescription
292
293Name MacAddress InterfaceDescription
294---- ---------- --------------------
295Ethernet1 00-0C-29-94-05-65 Intel(R) PRO/1000 MT Network Connection
296vEthernet (external) 00-0C-29-94-05-5B Hyper-V Virtual Ethernet Adapter #2
297Ethernet0 00-0C-29-94-05-5B Intel(R) PRO/1000 MT Network Connection #2
298
299PS C:\package\binaries> Get-VMSwitch
300
301Name SwitchType NetAdapterInterfaceDescription
302---- ---------- ------------------------------
303external External Intel(R) PRO/1000 MT Network Connection #2
304
305
306We can see that we have a switch(external) created upon adapter name 'Ethernet0'
307with an internal port under name 'vEthernet (external)'. Thus resulting into the
308following ovs-vsctl commands
309
310 % ovs-vsctl add-port br-pif Ethernet0
311 % ovs-vsctl add-port br-pif "vEthernet (external)"
0a46bca7
NR
312
313* Dumping the ports should show the additional ports that were just added.
314 Sample output shows up as follows:
315
d0d808fd 316 % ovs-dpctl show
0a46bca7
NR
317 system@ovs-system:
318 lookups: hit:0 missed:0 lost:0
319 flows: 0
9f760fd8
AS
320 port 4: vEthernet (external) (internal) <<< 'AllowManagementOS'
321 adapter on
322 Hyper-V switch
0a46bca7 323 port 2: br-pif (internal)
9f760fd8
AS
324 port 1: br-int (internal)
325 port 3: Ethernet0 <<< Physical NIC
0a46bca7 326
d0d808fd 327 % ovs-vsctl show
0a46bca7
NR
328 a56ec7b5-5b1f-49ec-a795-79f6eb63228b
329 Bridge br-pif
9f760fd8
AS
330 Port "vEthernet (external)"
331 Interface "vEthernet (external)"
0a46bca7
NR
332 Port br-pif
333 Interface br-pif
334 type: internal
9f760fd8
AS
335 Port "Ethernet0"
336 Interface "Ethernet0"
df4d9ec3 337 Bridge br-int
0a46bca7
NR
338 Port br-int
339 Interface br-int
340 type: internal
341
34208> Add the VIFs to br-int
343
344Adding VIFs to openvswitch is a two step procedure. The first step is to
345assign a 'OVS port name' which is a unique name across all VIFs on this
346Hyper-V. The next step is to add the VIF to the ovsdb using its 'OVS port
347name' as key.
348
34908a> Assign a unique 'OVS port name' to the VIF
350
351Note that the VIF needs to have been disconnected from the Hyper-V switch
352before assigning a 'OVS port name' to it. In the example below, we assign a
353'OVS port name' called 'ovs-port-a' to a VIF on a VM by name 'VM1'. By using
354index 0 for '$vnic', the first VIF of the VM is being addressed. After
355assigning the name 'ovs-port-a', the VIF is connected back to the Hyper-V
356switch with name 'OVS-HV-Switch', which is assumed to be the Hyper-V switch
357with OVS extension enabled.
358
359 Eg:
360 % import-module .\datapath-windows\misc\OVS.psm1
361 % $vnic = Get-VMNetworkAdapter <Name of the VM>
362 % Disconnect-VMNetworkAdapter -VMNetworkAdapter $vnic[0]
363 % $vnic[0] | Set-VMNetworkAdapterOVSPort -OVSPortName ovs-port-a
364 % Connect-VMNetworkAdapter -VMNetworkAdapter $vnic[0] \
365 -SwitchName OVS-Extended-Switch
366
36708b> Add the VIFs to br-int in ovsdb
368
369 Eg:
d0d808fd 370 % ovs-vsctl add-port br-int ovs-port-a
0a46bca7
NR
371
37209> Verify the status
d0d808fd 373 % ovs-dpctl show
0a46bca7
NR
374 system@ovs-system:
375 lookups: hit:0 missed:0 lost:0
376 flows: 0
9f760fd8 377 port 4: vEthernet (external) (internal)
0a46bca7
NR
378 port 5: ovs-port-a
379 port 2: br-pif (internal)
380 port 1: br-int (internal
9f760fd8 381 port 3: Ethernet0
0a46bca7 382
d0d808fd 383 % ovs-vsctl show
0a46bca7
NR
384 4cd86499-74df-48bd-a64d-8d115b12a9f2
385 Bridge br-pif
9f760fd8
AS
386 Port "vEthernet (external)"
387 Interface "vEthernet (external)"
388 Port "Ethernet0"
389 Interface "Ethernet0"
0a46bca7
NR
390 Port br-pif
391 Interface br-pif
392 type: internal
393 Bridge br-int
394 Port br-int
395 Interface br-int
396 type: internal
397 Port "ovs-port-a"
398 Interface "ovs-port-a"
399
400Steps to configure patch ports and switch VLAN tagging
401------------------------------------------------------
402The Windows Open vSwitch implementation support VLAN tagging in the switch.
403Switch VLAN tagging along with patch ports between 'br-int' and 'br-pif' is
404used to configure VLAN tagging functionality between two VMs on different
405Hyper-Vs. The following examples demonstrate how it can be done:
406
40701> Add a patch port from br-int to br-pif
d0d808fd
GS
408 % ovs-vsctl add-port br-int patch-to-pif
409 % ovs-vsctl set interface patch-to-pif type=patch \
0a46bca7
NR
410 options:peer=patch-to-int
411
41202> Add a patch port from br-pif to br-int
d0d808fd
GS
413 % ovs-vsctl add-port br-pif patch-to-int
414 % ovs-vsctl set interface patch-to-int type=patch \
0a46bca7
NR
415 options:peer=patch-to-pif
416
41703> Re-Add the VIF ports with the VLAN tag
d0d808fd
GS
418 % ovs-vsctl add-port br-int ovs-port-a tag=900
419 % ovs-vsctl add-port br-int ovs-port-b tag=900
0a46bca7 420
022c2040 421Steps to add tunnels
0a46bca7 422--------------------------
022c2040 423The Windows Open vSwitch implementation support VXLAN and STT tunnels. To add
0a46bca7
NR
424tunnels, the following steps serve as examples.
425
426Note that, any patch ports created between br-int and br-pif MUST be beleted
022c2040
EE
427prior to adding tunnels.
428
42901> Add the tunnel port between 172.168.201.101 <-> 172.168.201.102
430 % ovs-vsctl add-port br-int tun-1
431 % ovs-vsctl set Interface tun-1 type=port-type
432 % ovs-vsctl set Interface tun-1 options:local_ip=172.168.201.101
433 % ovs-vsctl set Interface tun-1 options:remote_ip=172.168.201.102
434 % ovs-vsctl set Interface tun-1 options:in_key=flow
435 % ovs-vsctl set Interface tun-1 options:out_key=flow
436
43702> Add the tunnel port between 172.168.201.101 <-> 172.168.201.105
438 % ovs-vsctl add-port br-int tun-2
439 % ovs-vsctl set Interface tun-2 type=port-type
440 % ovs-vsctl set Interface tun-2 options:local_ip=172.168.201.102
441 % ovs-vsctl set Interface tun-2 options:remote_ip=172.168.201.105
442 % ovs-vsctl set Interface tun-2 options:in_key=flow
443 % ovs-vsctl set Interface tun-2 options:out_key=flow
444
9f760fd8 445 Where port-type is the string stt or vxlan
d9d8dbc8
NR
446
447
c803536e
SS
448Requirements
449------------
c803536e
SS
450* We require that you don't disable the "Allow management operating system to
451share this network adapter" under 'Virtual Switch Properties' > 'Connection
452type: External network', in the HyperV virtual network switch configuration.
453
454* Checksum Offloads
455 While there is some support for checksum/segmentation offloads in software,
456this is still a work in progress. Till the support is complete we recommend
457disabling TX/RX offloads for both the VM's as well as the HyperV.
458
0be55e38
GS
459Windows Services
460----------------
461Open vSwitch daemons come with support to run as a Windows service. The
462instructions here assume that you have installed the Open vSwitch utilities
463and daemons via 'make install'. The commands shown here can be run from
464MSYS bash or Windows command prompt.
465
466* Create the database.
467
468 % ovsdb-tool create C:/openvswitch/etc/openvswitch/conf.db \
469 "C:/openvswitch/usr/share/openvswitch/vswitch.ovsschema"
470
471* Create the ovsdb-server service and start it.
472
aeef025a 473 % sc create ovsdb-server binpath="C:/openvswitch/usr/sbin/ovsdb-server.exe C:/openvswitch/etc/openvswitch/conf.db -vfile:info --log-file --pidfile --remote=punix:db.sock --service --service-monitor"
0be55e38
GS
474
475 One of the common issues with creating a Windows service is with mungled
476 paths. You can make sure that the correct path has been registered with
477 the Windows services manager by running:
478
479 % sc qc ovsdb-server
480
481 Start the service.
482
483 % sc start ovsdb-server
484
485 Check that the service is healthy by running:
486
487 % sc query ovsdb-server
488
489* Initialize the database.
490
491 % ovs-vsctl --no-wait init
492
493* Create the ovs-vswitchd service and start it.
494
aeef025a 495 % sc create ovs-vswitchd binpath="C:/openvswitch/usr/sbin/ovs-vswitchd.exe --pidfile -vfile:info --log-file --service --service-monitor"
0be55e38
GS
496
497 % sc start ovs-vswitchd
498
499 Check that the service is healthy by running:
500
501 % sc query ovs-vswitchd
502
503* To stop and delete the services, run:
504
505 % sc stop ovs-vswitchd
506 % sc stop ovsdb-server
507 % sc delete ovs-vswitchd
508 % sc delete ovsdb-server
509
d8a24927
GS
510Windows autobuild service
511-------------------------
d8a24927
GS
512AppVeyor (appveyor.com) provides a free Windows autobuild service for
513opensource projects. Open vSwitch has integration with AppVeyor for
514continuous build. A developer can build test his changes for Windows by
515logging into appveyor.com using a github account, creating a new project
516by linking it to his development repository in github and triggering
517a new build.
c803536e 518
d9d8dbc8 519TODO
c803536e
SS
520----
521
c803536e
SS
522* Investigate the working of sFlow on Windows and re-enable the unit tests.
523
abe6d620
GS
524* Investigate and add the feature to provide QOS.
525
c803536e
SS
526* Sign the driver & create an MSI for installing the different OpenvSwitch
527components on windows.