|
1 | 1 | # Creating the VM |
| 2 | + |
2 | 3 | + Below are the steps to create a brand new VM using Vagrant: |
3 | 4 | + Install [Vagrant](https://developer.hashicorp.com/vagrant/docs/installation) on your system if it's not already installed. |
4 | | - + Navigate to the directory where you want to create the new VM. |
| 5 | + + In a shell/terminal window, change to this `vm-ubuntu-20.04` |
| 6 | + directory inside the `tutorials` directory. |
5 | 7 | + Run the below command in the terminal. |
6 | 8 |
|
7 | | - ``` |
| 9 | + ```bash |
8 | 10 | vagrant up |
9 | 11 | ``` |
10 | 12 |
|
|
13 | 15 | - You can update these packages using `apt upgrade` within the VM. |
14 | 16 |
|
15 | 17 | + Alternatively, a development VM can be created by running |
16 | | - ``` |
| 18 | + ```bash |
17 | 19 | vagrant up dev |
18 | 20 | ``` |
19 | 21 |
|
20 | | -*Note* : that creating a development VM can take one to several |
21 | | -hours, depending upon the speed of your computer and Internet |
22 | | -connection. |
23 | | -
|
24 | | -Below are steps that were performed _after_ one of the commands above |
25 | | -was run on the host OS, before creating the VM images. Some of these |
26 | | -steps could probably be automated with programs, and changes to the |
27 | | -`vagrant` scripts that can do so are welcome. I performed these steps |
28 | | -manually to create a VM image, simply to avoid the experimentation and |
29 | | -time required to automate them. I typically only create new VM images |
30 | | -once per month. |
31 | | -
|
32 | | -+ Log in as user p4 (password p4) |
33 | | -+ Click "Upgrade" in the pop-up window asking if you want to upgrade |
34 | | - the system, if asked. This will download the latest Linux kernel |
35 | | - version released for Ubuntu 20.04, and other updated packages. |
36 | | -+ Reboot the system. |
37 | | -+ This is optional, but if you want to save a little disk space, use |
38 | | - |
39 | | - ``` |
40 | | - sudo apt purge <list of packages> |
41 | | - ``` |
42 | | - |
43 | | - to remove older version of Linux |
44 | | - kernel, if the upgrade installed a newer one. |
45 | | -+ Clean the local repository of retrieved package files to free up disk space |
46 | | - |
47 | | - ``` |
48 | | - sudo apt clean |
49 | | - ``` |
50 | | - |
51 | | -+ Log in as user p4 (password p4) |
52 | | -+ Start menu -> Preferences -> LXQt settings -> Monitor settings |
53 | | - + Change resolution from initial 800x600 to 1024x768. Apply the changes. |
54 | | - + Close monitor settings window |
55 | | - + *Note*: For some reason I do not know, these settings seem to be |
56 | | - undone, even if I use the "Save" button. They are temporarily in |
57 | | - effect if I shut down the system and log back in, but then in a few |
58 | | - seconds it switches back to 800x600. Strange. |
59 | | -+ Start menu -> Preferences -> LXQt settings -> Desktop |
60 | | - + In "Wallpaper mode" popup menu, choose "Center on the screen". |
61 | | - + Click Apply button |
62 | | - + Close "Desktop preferences" window |
63 | | -+ Several of the icons on the desktop have an exclamation mark on |
64 | | - them. If you try double-clicking those icons, it pops up a window |
65 | | - saying "This file 'Wireshark' seems to be a desktop entry. What do |
66 | | - you want to do with it?" with buttons for "Open", "Execute", and |
67 | | - "Cancel". Clicking "Execute" executes the associated command. |
68 | | - If you do a mouse middle click on one of these desktop icons, a |
69 | | - popup menu appears where the second-to-bottom choice is "Trust this |
70 | | - executable". Selecting that causes the exclamation mark to go away, |
71 | | - and future double-clicks of the icon execute the program without |
72 | | - first popping up a window to choose between Open/Execute/Cancel. I |
73 | | - did that for each of these desktop icons: |
74 | | - + Terminal |
75 | | - + Wireshark |
76 | | -+ Log off |
77 | | -
|
78 | | -+ Log in as user vagrant (password vagrant) |
79 | | -+ Change monitor settings and wallpaper mode as described above for |
80 | | - user p4. |
81 | | -+ Open a terminal. |
82 | | - + Run the command |
83 | | - |
84 | | - ``` |
85 | | - ./clean.sh |
86 | | - ``` |
87 | | - which removes about 6 to 7 GBytes of |
88 | | - files created while building the projects. |
89 | | -+ Log off |
90 | | -
|
91 | | -
|
92 | | -# Notes on test results for the VM |
93 | | -
|
94 | | -I have run the tests below on every VM image I release, before |
95 | | -releasing it. You need not run them again, unless you are curious how |
96 | | -to do so. |
97 | | -
|
98 | | -
|
99 | | -## p4c testing results |
100 | | -
|
101 | | -Steps to run the p4c tests: |
102 | | -
|
103 | | -+ Log in as user vagrant (password vagrant) |
104 | | -+ In a new terminal, execute these commands: |
105 | | -
|
106 | | -If you are testing on a Release VM image, first get a copy of the p4c |
107 | | -source code using the following command. This is unnecessary with a |
108 | | -Development VM image, as there is already a `p4c` directory with the |
109 | | -version of source code used to create that image already included in |
110 | | -the home directory of the `vagrant` user account: |
111 | | -
|
112 | | -```bash |
113 | | -# for Release VM image only |
114 | | -git clone --recursive https://github.com/p4lang/p4c |
115 | | -``` |
116 | | - |
117 | | -The following steps are common for both Release and Development VM |
118 | | -images: |
119 | | - |
120 | | -```bash |
121 | | -# Compile p4c again from source, since the clean.sh step reduced disk |
122 | | -# space by deleting the p4c/build directory. |
123 | | -git clone https://github.com/jafingerhut/p4-guide |
124 | | -cd p4c |
125 | | -~/p4-guide/bin/build-p4c.sh |
126 | | - |
127 | | -# Run the p4c tests |
128 | | -cd build |
129 | | -make -j2 check |& tee make-check-out.txt |
130 | | -``` |
131 | | - |
132 | | -As of 2024-08-01, the p4c compiler passes all of its included tests, |
133 | | -except for some of the p4testgen tests (if those are enabled). |
134 | | - |
135 | | - |
136 | | -## Send ping packets in the solution to `basic` exercise of `p4lang/tutorials` repository |
137 | | - |
138 | | -With the version of the [tutorials](https://github.com/p4lang/tutorials) repository |
139 | | -that comes pre-installed in the `p4` user account of this VM, the |
140 | | -following tests pass. |
141 | | - |
142 | | -First log in as the user `p4` (password `p4`) and open a terminal |
143 | | -window. |
144 | | -```bash |
145 | | -$ cd tutorials/exercises/basic |
146 | | -$ cp solution/basic.p4 basic.p4 |
147 | | -$ make run |
148 | | -``` |
149 | | - |
150 | | -If at the end of many lines of logging output you see a prompt |
151 | | -`mininet>`, you can try entering the command `h1 ping h2` to ping from |
152 | | -virtual host `h1` in the exercise to `h2`, and it should report a |
153 | | -successful ping every second. It will not stop on its own. You can |
154 | | -type Control-C to stop it and return to the `mininet>` prompt, and you |
155 | | -can type Control-D to exit from mininet and get back to the original |
156 | | -shell prompt. To ensure that any processes started by the above steps |
157 | | -are terminated, you can run this command: |
158 | | -```bash |
159 | | -$ make stop |
160 | | -``` |
161 | | - |
162 | | - |
163 | | -# Creating a single file image of the VM |
164 | | - |
165 | | -These notes are primarily here as a reminder for people creating VM |
166 | | -images for distribution. If you downloaded a VM image, these steps |
167 | | -were already performed, and there is no reason you need to perform |
168 | | -them again. |
169 | | - |
170 | | -For the particular case of creating the VM named: |
171 | | - |
172 | | -+ 'P4 Tutorial Development 2024-08-01' |
173 | | -+ created on August 1, 2024 |
174 | | - |
175 | | -here were the host OS details, in case it turns out that matters to |
176 | | -the finished VM image for some reason: |
177 | | - |
178 | | -+ Windows 10 Enterprise |
179 | | -+ VirtualBox 6.1.30 r148432 |
180 | | -+ Vagrant 2.2.18 |
181 | | - |
182 | | -In the VirtualBox GUI interface: |
183 | | - |
184 | | -+ Choose menu item File -> Export Appliance ... |
185 | | -+ Select the VM named 'P4 Tutorial Development 2024-08-01' and click |
186 | | - Continue button |
187 | | - |
188 | | -+ Format |
189 | | - + I used: Open Virtualization Format 1.0 |
190 | | - + Other available options were: |
191 | | - + Open Virtualization Format 0.9 |
192 | | - + Open Virtualization Format 2.0 |
193 | | -+ Target file |
194 | | - + I used: /Users/andy/Documents/P4 Tutorials Development 2024-08-01.ova |
195 | | -+ Mac Address Policy |
196 | | - + I used: Include only NAT network adapter MAC addresses |
197 | | - + Other available options were: |
198 | | - + Include all network adapter MAC addresses |
199 | | - + Strip all network adapter MAC addresses |
200 | | -+ Additionally |
201 | | - + Write Manifest file: checked |
202 | | - + Include ISO image files: unchecked |
203 | | - |
204 | | -Clicked "Continue" button. |
205 | | - |
206 | | -Virtual system settings: |
207 | | - |
208 | | -+ Name: P4 Tutorial 2024-08-01 |
209 | | -+ Product: I left this blank |
210 | | -+ Product-URL: I left this blank |
211 | | -+ Vendor: P4.org - P4 Language Consortium |
212 | | -+ Vendor-URL: https://p4.org |
213 | | -+ Version: 2024-08-01 |
214 | | -+ Description: |
215 | | - |
216 | | -``` |
217 | | -Open source P4 development tools built from latest source code as of 2024-Aug-01 and packaged into an Ubuntu 20.04 Desktop Linux VM for the AMD64 architecture. |
218 | | -``` |
219 | | - |
220 | | -+ License |
221 | | - |
222 | | -``` |
223 | | -Open source code available hosted at https://github.com/p4lang is released under the Apache 2.0 license. Libraries it depends upon, such as Protobuf, Thrift, gRPC, Ubuntu Linux, etc. are released under their own licenses. |
224 | | -``` |
225 | | - |
226 | | -Clicked "Export" button. |
| 22 | +*Note* that creating a development VM can take several hours, |
| 23 | +depending upon the speed of your computer and Internet connection. |
0 commit comments