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