Skip to content

Commit

Permalink
Improve whitespace around sections
Browse files Browse the repository at this point in the history
It is easier to read the source when sections are separated by blank
lines.

(Automatically formatted by Zed markdown extension).

Signed-off-by: Nir Soffer <nsoffer@redhat.com>
  • Loading branch information
nirs committed Nov 10, 2024
1 parent 3a420bc commit 5494727
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Unlike `vde_vmnet`, `socket_vmnet` does not depend on VDE.
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [Install](#install)
- [From Homebrew](#from-homebrew)
- [From MacPorts](#from-macports)
Expand Down Expand Up @@ -47,6 +46,7 @@ brew install socket_vmnet
```

The binaries will be installed onto the following paths:

- `${HOMEBREW_PREFIX}/opt/socket_vmnet/bin/socket_vmnet`
- `${HOMEBREW_PREFIX}/opt/socket_vmnet/bin/socket_vmnet_client`

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

Run the following command to start the daemon:

```bash
mkdir -p ${HOMEBREW_PREFIX}/var/run
sudo ${HOMEBREW_PREFIX}/opt/socket_vmnet/bin/socket_vmnet --vmnet-gateway=192.168.105.1 ${HOMEBREW_PREFIX}/var/run/socket_vmnet
Expand All @@ -70,8 +71,8 @@ sudo ${HOMEBREW_PREFIX}/opt/socket_vmnet/bin/socket_vmnet --vmnet-gateway=192.16

<p>


To install the launchd service:

```bash
brew tap homebrew/services
# sudo is necessary for the next line
Expand All @@ -90,6 +91,7 @@ Default configuration:
| Gateway | 192.168.105.1 |

To uninstall the launchd service:

```bash
sudo ${HOMEBREW_PREFIX}/bin/brew services stop socket_vmnet
```
Expand All @@ -105,10 +107,12 @@ sudo port install socket_vmnet
```

The binaries will be installed onto the following paths:

- `/opt/local/bin/socket_vmnet`
- `/opt/local/bin/socket_vmnet_client`

Run the following command to start the daemon manually:

```bash
sudo /opt/local/bin/socket_vmnet --vmnet-gateway=192.168.105.1 /var/run/socket_vmnet
```
Expand All @@ -120,6 +124,7 @@ sudo /opt/local/bin/socket_vmnet --vmnet-gateway=192.168.105.1 /var/run/socket_
<p>

To install the launchd service:

```bash
sudo port load socket_vmnet
```
Expand All @@ -136,6 +141,7 @@ Default configuration:
| Gateway | 192.168.105.1 |

To uninstall the launchd service:

```bash
sudo port unload socket_vmnet
```
Expand All @@ -155,6 +161,7 @@ sudo make install.bin
```

This installs binaries onto the following paths:

- `/opt/socket_vmnet/bin/socket_vmnet`
- `/opt/socket_vmnet/bin/socket_vmnet_client`

Expand All @@ -175,8 +182,8 @@ sudo /opt/socket_vmnet/bin/socket_vmnet --vmnet-gateway=192.168.105.1 /var/run/s

<p>


To install the launchd service:

```bash
sudo make install.launchd
```
Expand All @@ -193,6 +200,7 @@ Default configuration:
| Gateway | 192.168.105.1 |

To uninstall the launchd service:

```bash
sudo make uninstall.launchd
```
Expand All @@ -208,6 +216,7 @@ sudo make uninstall.launchd
## Usage

### QEMU

Make sure that the `socket_vmnet` daemon is running, and execute QEMU via `socket_vmnet_client` as follows:

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

## Advanced usage

### Multi VM

Multiple VMs can be connected to a single `socket_vmnet` instance.

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

Install:

```bash
BRIDGED=en0
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 \
Expand All @@ -261,6 +273,7 @@ sudo launchctl kickstart -kp system/io.github.lima-vm.socket_vmnet.bridged.${BRI
Use `${HOMEBREW_PREFIX}/var/run/socket_vmnet.bridged.en0` as the socket.

Uninstall:

```bash
BRIDGED=en0
sudo launchctl bootout system /Library/LaunchDaemons/io.github.lima-vm.socket_vmnet.bridged.${BRIDGED}.plist
Expand Down Expand Up @@ -294,13 +307,15 @@ See [`./etc_sudoers.d/socket_vmnet`](./etc_sudoers.d/socket_vmnet) to allow runn
Unlike `vde_vmnet`, `socket_vmnet` does not depend on VDE.

### How is socket_vmnet related to QEMU-builtin vmnet support?

QEMU 7.1 added [the built-in support for vmnet](https://github.com/qemu/qemu/blob/v7.1.0/qapi/net.json#L626-L631).

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

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.

### How to use static IP addresses?

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.

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

### How to reserve DHCP addresses?

- Decide a unique MAC address for the VM, e.g. `de:ad:be:ef:00:01`.

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

- Create `/etc/bootptab` like this. Make sure not to drop the "%%" header.

```
# bootptab
%%
Expand All @@ -322,6 +339,7 @@ tmp-vm01 1 de:ad:be:ef:00:01 192.168.105.100
```

- Reload the DHCP daemon.

```
sudo /bin/launchctl kickstart -kp system/com.apple.bootpd
```
Expand All @@ -332,14 +350,17 @@ NOTE: don't confuse MAC addresses of VMs with the MAC address of `socket_vmnet`
You do not need to configure (and you can't, currently) the MAC address of `socket_vmnet` itself.

### IP address is not assigned

Try the following commands:

```console
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --remove /usr/libexec/bootpd
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --add /usr/libexec/bootpd
/usr/libexec/ApplicationFirewall/socketfilterfw --unblock /usr/libexec/bootpd
```

## Links

- https://developer.apple.com/documentation/vmnet
- https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_vm_networking
- [`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)
Expand Down

0 comments on commit 5494727

Please sign in to comment.