Skip to content

Commit 8664a96

Browse files
authored
Merge pull request #72 from nirs/readme
Improve README.md
2 parents 87ad870 + 4cacacf commit 8664a96

File tree

1 file changed

+56
-34
lines changed

1 file changed

+56
-34
lines changed

README.md

Lines changed: 56 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ Unlike `vde_vmnet`, `socket_vmnet` does not depend on VDE.
1212
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
1313
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
1414

15-
1615
- [Install](#install)
1716
- [From Homebrew](#from-homebrew)
1817
- [From MacPorts](#from-macports)
@@ -47,6 +46,7 @@ brew install socket_vmnet
4746
```
4847

4948
The binaries will be installed onto the following paths:
49+
5050
- `${HOMEBREW_PREFIX}/opt/socket_vmnet/bin/socket_vmnet`
5151
- `${HOMEBREW_PREFIX}/opt/socket_vmnet/bin/socket_vmnet_client`
5252

@@ -55,13 +55,13 @@ The `${HOMEBREW_PREFIX}` path defaults to `/opt/homebrew` on ARM, `/usr/local` o
5555
The `${HOMEBREW_PREFIX}/opt/socket_vmnet` directory is usually symlinked to `../Cellar/socket_vmnet/${VERSION}`.
5656

5757
Run the following command to start the daemon:
58+
5859
```bash
5960
mkdir -p ${HOMEBREW_PREFIX}/var/run
6061
sudo ${HOMEBREW_PREFIX}/opt/socket_vmnet/bin/socket_vmnet --vmnet-gateway=192.168.105.1 ${HOMEBREW_PREFIX}/var/run/socket_vmnet
6162
```
6263

63-
> **Warning**
64-
>
64+
> [!WARNING]
6565
> Typically, the `socket_vmnet` binary in the `${HOMEBREW_PREFIX}` can be replaced by any user in the `admin` group.
6666
6767
<details>
@@ -70,8 +70,8 @@ sudo ${HOMEBREW_PREFIX}/opt/socket_vmnet/bin/socket_vmnet --vmnet-gateway=192.16
7070

7171
<p>
7272

73-
7473
To install the launchd service:
74+
7575
```bash
7676
brew tap homebrew/services
7777
# sudo is necessary for the next line
@@ -82,14 +82,15 @@ The launchd unit file will be installed as `/Library/LaunchDaemons/homebrew.mxcl
8282

8383
Default configuration:
8484

85-
Config | Value
86-
--------|--------------------------------------------------
87-
Socket | `${HOMEBREW_PREFIX}/var/run/socket_vmnet`
88-
Stdout | `${HOMEBREW_PREFIX}/var/log/socket_vmnet/stdout`
89-
Stderr | `${HOMEBREW_PREFIX}/var/log/socket_vmnet/stderr`
90-
Gateway | 192.168.105.1
85+
| Config | Value |
86+
| ------- | ------------------------------------------------ |
87+
| Socket | `${HOMEBREW_PREFIX}/var/run/socket_vmnet` |
88+
| Stdout | `${HOMEBREW_PREFIX}/var/log/socket_vmnet/stdout` |
89+
| Stderr | `${HOMEBREW_PREFIX}/var/log/socket_vmnet/stderr` |
90+
| Gateway | 192.168.105.1 |
9191

9292
To uninstall the launchd service:
93+
9394
```bash
9495
sudo ${HOMEBREW_PREFIX}/bin/brew services stop socket_vmnet
9596
```
@@ -105,10 +106,12 @@ sudo port install socket_vmnet
105106
```
106107

107108
The binaries will be installed onto the following paths:
109+
108110
- `/opt/local/bin/socket_vmnet`
109111
- `/opt/local/bin/socket_vmnet_client`
110112

111113
Run the following command to start the daemon manually:
114+
112115
```bash
113116
sudo /opt/local/bin/socket_vmnet --vmnet-gateway=192.168.105.1 /var/run/socket_vmnet
114117
```
@@ -120,6 +123,7 @@ sudo /opt/local/bin/socket_vmnet --vmnet-gateway=192.168.105.1 /var/run/socket_
120123
<p>
121124

122125
To install the launchd service:
126+
123127
```bash
124128
sudo port load socket_vmnet
125129
```
@@ -129,13 +133,14 @@ The launchd unit file will be installed as
129133

130134
Default configuration:
131135

132-
Config | Value
133-
--------|------------------------------------------------
134-
Socket | `/var/run/socket_vmnet`
135-
Stdout | `/var/log/socket_vmnet.log`
136-
Gateway | 192.168.105.1
136+
| Config | Value |
137+
| ------- | --------------------------- |
138+
| Socket | `/var/run/socket_vmnet` |
139+
| Stdout | `/var/log/socket_vmnet.log` |
140+
| Gateway | 192.168.105.1 |
137141

138142
To uninstall the launchd service:
143+
139144
```bash
140145
sudo port unload socket_vmnet
141146
```
@@ -151,19 +156,21 @@ sudo port unload socket_vmnet
151156
<p>
152157

153158
```bash
154-
sudo make PREFIX=/opt/socket_vmnet install.bin
159+
sudo make install.bin
155160
```
156161

157-
The `PREFIX` dir below does not necessarily need to be `/opt/socket_vmnet`, however, it is highly recommended
158-
to set the prefix to a directory that can be only written by the root.
162+
This installs binaries using `PREFIX=/opt/socket_vmnet`:
159163

160-
Note that `/usr/local/bin` is sometimes chowned for a non-admin user, so `/usr/local` is *not* an appropriate prefix.
161-
162-
The binaries will be installed onto the following paths:
163164
- `/opt/socket_vmnet/bin/socket_vmnet`
164165
- `/opt/socket_vmnet/bin/socket_vmnet_client`
165166

167+
You can customize the install location using the `PREFIX` environment variable,
168+
however, it is highly recommended to set the prefix to a directory that can be
169+
only written by the root. Note that `/usr/local/bin` is sometimes chowned for a
170+
non-admin user, so `/usr/local` is _not_ an appropriate prefix.
171+
166172
Run the following command to start the daemon:
173+
167174
```bash
168175
sudo /opt/socket_vmnet/bin/socket_vmnet --vmnet-gateway=192.168.105.1 /var/run/socket_vmnet
169176
```
@@ -174,27 +181,27 @@ sudo /opt/socket_vmnet/bin/socket_vmnet --vmnet-gateway=192.168.105.1 /var/run/s
174181

175182
<p>
176183

177-
178184
To install the launchd service:
185+
179186
```bash
180-
sudo make PREFIX=/opt/socket_vmnet install.launchd
187+
sudo make install.launchd
181188
```
182189

183190
The launchd unit file will be installed as `/Library/LaunchDaemons/io.github.lima-vm.socket_vmnet.plist`.
184191

185192
Default configuration:
186193

187-
Config | Value
188-
--------|--------------------------------------------------
189-
Socket | `/var/run/socket_vmnet`
190-
Stdout | `/var/log/socket_vmnet/stdout`
191-
Stderr | `/var/log/socket_vmnet/stderr`
192-
Gateway | 192.168.105.1
193-
194+
| Config | Value |
195+
| ------- | ------------------------------ |
196+
| Socket | `/var/run/socket_vmnet` |
197+
| Stdout | `/var/log/socket_vmnet/stdout` |
198+
| Stderr | `/var/log/socket_vmnet/stderr` |
199+
| Gateway | 192.168.105.1 |
194200

195201
To uninstall the launchd service:
202+
196203
```bash
197-
sudo make PREFIX=/opt/socket_vmnet uninstall.launchd
204+
sudo make uninstall.launchd
198205
```
199206

200207
</p>
@@ -208,6 +215,7 @@ sudo make PREFIX=/opt/socket_vmnet uninstall.launchd
208215
## Usage
209216

210217
### QEMU
218+
211219
Make sure that the `socket_vmnet` daemon is running, and execute QEMU via `socket_vmnet_client` as follows:
212220

213221
```console
@@ -236,7 +244,9 @@ $ limactl start --name=default template://vmnet
236244
See also https://github.com/lima-vm/lima/blob/master/docs/network.md
237245

238246
## Advanced usage
247+
239248
### Multi VM
249+
240250
Multiple VMs can be connected to a single `socket_vmnet` instance.
241251

242252
Make sure to specify unique MAC addresses to VMs: `-device virtio-net-pci,netdev=net0,mac=de:ad:be:ef:00:01` .
@@ -249,6 +259,7 @@ You do not need to configure (and you can't, currently) the MAC address of `sock
249259
See [`./launchd/io.github.lima-vm.socket_vmnet.bridged.en0.plist`](./launchd/io.github.lima-vm.socket_vmnet.bridged.en0.plist).
250260

251261
Install:
262+
252263
```bash
253264
BRIDGED=en0
254265
sed -e "s@/opt@${HOMEBREW_PREFIX}/opt@g; s@/var@${HOMEBREW_PREFIX}/var@g; s@en0@${BRIDGED}@g" ./launchd/io.github.lima-vm.socket_vmnet.bridged.en0.plist \
@@ -261,6 +272,7 @@ sudo launchctl kickstart -kp system/io.github.lima-vm.socket_vmnet.bridged.${BRI
261272
Use `${HOMEBREW_PREFIX}/var/run/socket_vmnet.bridged.en0` as the socket.
262273

263274
Uninstall:
275+
264276
```bash
265277
BRIDGED=en0
266278
sudo launchctl bootout system /Library/LaunchDaemons/io.github.lima-vm.socket_vmnet.bridged.${BRIDGED}.plist
@@ -294,13 +306,15 @@ See [`./etc_sudoers.d/socket_vmnet`](./etc_sudoers.d/socket_vmnet) to allow runn
294306
Unlike `vde_vmnet`, `socket_vmnet` does not depend on VDE.
295307

296308
### How is socket_vmnet related to QEMU-builtin vmnet support?
309+
297310
QEMU 7.1 added [the built-in support for vmnet](https://github.com/qemu/qemu/blob/v7.1.0/qapi/net.json#L626-L631).
298311

299312
However, QEMU-builtin vmnet requires running the entire QEMU process as root.
300313

301314
On the other hand, `socket_vmnet` does not require the entire QEMU process to run as root, though `socket_vmnet` has to run as root.
302315

303316
### How to use static IP addresses?
317+
304318
When `--vmnet-gateway=IP` is set to "192.168.105.1", the whole subnet (192.168.105.2-192.168.105.254) is used as the DHCP range.
305319

306320
To use static IP addresses, limit the DHCP range with `--vmnet-dhcp-end=IP`.
@@ -309,11 +323,13 @@ For example, `--vmnet-gateway=192.168.105.1 --vmnet-dhcp-end=192.168.105.100` al
309323
as non-DHCP static addresses.
310324

311325
### How to reserve DHCP addresses?
326+
312327
- Decide a unique MAC address for the VM, e.g. `de:ad:be:ef:00:01`.
313328

314329
- Decide a reserved IP address, e.g., "192.168.105.100"
315330

316331
- Create `/etc/bootptab` like this. Make sure not to drop the "%%" header.
332+
317333
```
318334
# bootptab
319335
%%
@@ -322,6 +338,7 @@ tmp-vm01 1 de:ad:be:ef:00:01 192.168.105.100
322338
```
323339

324340
- Reload the DHCP daemon.
341+
325342
```
326343
sudo /bin/launchctl kickstart -kp system/com.apple.bootpd
327344
```
@@ -332,18 +349,23 @@ NOTE: don't confuse MAC addresses of VMs with the MAC address of `socket_vmnet`
332349
You do not need to configure (and you can't, currently) the MAC address of `socket_vmnet` itself.
333350

334351
### IP address is not assigned
352+
335353
Try the following commands:
354+
336355
```console
356+
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --remove /usr/libexec/bootpd
337357
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --add /usr/libexec/bootpd
338358
/usr/libexec/ApplicationFirewall/socketfilterfw --unblock /usr/libexec/bootpd
339359
```
340360

341361
## Links
362+
342363
- https://developer.apple.com/documentation/vmnet
343364
- https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_vm_networking
344365
- [`file:///Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/vmnet.framework/Versions/Current/Headers/vmnet.h`](file:///Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/vmnet.framework/Versions/Current/Headers/vmnet.h)
345366

346367
## Troubleshooting
347-
- Set environment variable `DEBUG=1`
348-
- See `${HOMEBREW_PREFIX}/var/log/socket_vmnet/{stdout,stderr}` (when using launchd).
349-
The path was previously `${HOMEBREW_PREFIX}/var/run/socket_vmnet.{stdout,stderr}` until March 2023.
368+
369+
- To enable verbose debug logs, set the environment variable `DEBUG=1`.
370+
- When using launchd, logs are written to `/var/log/socket_vmnet/stderr`.
371+
`/var/log/socket_vmnet/stdout` is not used and expected to be empty.

0 commit comments

Comments
 (0)