Skip to content
This repository was archived by the owner on May 4, 2024. It is now read-only.

Commit a9767e8

Browse files
authored
Merge pull request #21 from AkihiroSuda/opt-vde
`change the default prefix from /usr/local to /opt/vde` + `support vde_switch >= 2021-08-31`
2 parents a5fdfe1 + 55799ca commit a9767e8

9 files changed

+65
-33
lines changed

.github/workflows/test.yml

+14-4
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,22 @@ jobs:
2121
uname -a
2222
sw_vers
2323
ifconfig
24-
- name: Install build dependencies
25-
run: brew install vde
24+
- name: Install build dependencies of VDE
25+
run: brew install autoconf automake
26+
- name: Install VDE
27+
run: |
28+
git clone https://github.com/virtualsquare/vde-2.git /tmp/vde-2
29+
cd /tmp/vde-2
30+
# Aug 31, 2021
31+
git checkout 50964c3fb0776e82f8bd1ecdc527683966f3d52c
32+
autoreconf -fis
33+
./configure --prefix=/opt/vde
34+
make
35+
sudo make install
2636
- name: Make
27-
run: make
37+
run: make PREFIX=/opt/vde
2838
- name: Install
29-
run: sudo make install
39+
run: sudo make PREFIX=/opt/vde install
3040
- name: Print launchd status (shared mode)
3141
run: launchctl print system/io.github.lima-vm.vde_vmnet.plist
3242
- name: Install test dependencies

Makefile

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
PREFIX ?= /usr/local
1+
# PREFIX should be only writable by the root to avoid privilege escalation with launchd or sudo
2+
PREFIX ?= /opt/vde
3+
4+
# VDEPREFIX should be only writable by the root to avoid privilege escalation with launchd or sudo
5+
VDEPREFIX ?= $(PREFIX)
26

37
CFLAGS ?= -O3
48

59
VERSION ?= $(shell git describe --match 'v[0-9]*' --dirty='.m' --always --tags)
6-
CFLAGS += -DVERSION=\"$(VERSION)\"
10+
CFLAGS += -I"$(VDEPREFIX)/include" -DVERSION=\"$(VERSION)\"
711

8-
LDFLAGS += -lvdeplug -framework vmnet
12+
LDFLAGS += -L"$(VDEPREFIX)/lib" -lvdeplug -framework vmnet
913

1014
# Interface name for bridged mode. Empty value (default) disables bridged mode.
1115
BRIDGED ?=
@@ -24,11 +28,12 @@ install.bin: vde_vmnet
2428
install vde_vmnet "$(DESTDIR)/$(PREFIX)/bin/vde_vmnet"
2529

2630
install.launchd.plist: launchd/*.plist
27-
install launchd/io.github.virtualsquare.vde-2.vde_switch.plist "$(DESTDIR)/Library/LaunchDaemons/io.github.virtualsquare.vde-2.vde_switch.plist"
28-
install launchd/io.github.lima-vm.vde_vmnet.plist "$(DESTDIR)/Library/LaunchDaemons/io.github.lima-vm.vde_vmnet.plist"
31+
sed -e "s@/opt/vde@$(PREFIX)@g" launchd/io.github.virtualsquare.vde-2.vde_switch.plist > "$(DESTDIR)/Library/LaunchDaemons/io.github.virtualsquare.vde-2.vde_switch.plist"
32+
sed -e "s@/opt/vde@$(PREFIX)@g" launchd/io.github.lima-vm.vde_vmnet.plist > "$(DESTDIR)/Library/LaunchDaemons/io.github.lima-vm.vde_vmnet.plist"
33+
2934
ifneq ($(BRIDGED),)
30-
sed -e "s/en0/$(BRIDGED)/g" launchd/io.github.virtualsquare.vde-2.vde_switch.bridged.en0.plist > "$(DESTDIR)/Library/LaunchDaemons/io.github.virtualsquare.vde-2.vde_switch.bridged.$(BRIDGED).plist"
31-
sed -e "s/en0/$(BRIDGED)/g" launchd/io.github.lima-vm.vde_vmnet.bridged.en0.plist > "$(DESTDIR)/Library/LaunchDaemons/io.github.lima-vm.vde_vmnet.bridged.$(BRIDGED).plist"
35+
sed -e "s@/opt/vde@$(PREFIX)@g" -e "s/en0/$(BRIDGED)/g" launchd/io.github.virtualsquare.vde-2.vde_switch.bridged.en0.plist > "$(DESTDIR)/Library/LaunchDaemons/io.github.virtualsquare.vde-2.vde_switch.bridged.$(BRIDGED).plist"
36+
sed -e "s@/opt/vde@$(PREFIX)@g" -e "s/en0/$(BRIDGED)/g" launchd/io.github.lima-vm.vde_vmnet.bridged.en0.plist > "$(DESTDIR)/Library/LaunchDaemons/io.github.lima-vm.vde_vmnet.bridged.$(BRIDGED).plist"
3237
endif
3338

3439
install.launchd: install.launchd.plist

README.md

+23-5
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,34 @@
1010

1111
Requires macOS 10.15 or later.
1212

13-
```console
14-
brew install vde
13+
### Step 1: Install vde-2 (`vde_switch`)
1514

16-
make
15+
The version of `vde-2` must be [commit 50964c3f](https://github.com/virtualsquare/vde-2/tree/50964c3f) (2021-08-31) or later.
16+
17+
The `--prefix` dir below does not necessarily need to be `/opt/vde`, however, it is highly recommended
18+
to set the prefix to a directory that can be only written by the root.
19+
20+
Note that `/usr/local` is typically chowned for a non-root user on Homebrew environments, so
21+
`/usr/local` is *not* an appropriate prefix.
1722

23+
```bash
24+
git clone https://github.com/virtualsquare/vde-2.git
25+
cd vde-2
26+
autoreconf -fis
27+
./configure --prefix=/opt/vde
28+
make
1829
sudo make install
1930
```
2031

32+
### Step 2: Install `vde_vmnet`
33+
```bash
34+
git clone https://github.com/lima-vm/vde_vmnet
35+
make PREFIX=/opt/vde
36+
sudo make PREFIX=/opt/vde install
37+
```
38+
2139
The following files will be installed:
22-
- `/usr/local/bin/vde_vmnet`
40+
- `/opt/vde/bin/vde_vmnet`
2341
- `/Library/LaunchDaemons/io.github.virtualsquare.vde-2.vde_switch.plist`
2442
- `/Library/LaunchDaemons/io.github.lima-vm.vde_vmnet.plist`
2543
- Configured to use `192.168.105.0/24`. Modifiy the file if it conflicts with your local network.
@@ -86,7 +104,7 @@ Note: make sure to run `vde_vmnet` with root (`sudo`). See [FAQs](#FAQs) for the
86104
### PTP mode (Switchless mode)
87105

88106
- Pros: doesn't require the `vde_switch` process to be running
89-
- Cons: no support for multi-VM
107+
- Cons: Only single QEMU process can connect to the socket. Multiple `vde_vmnet` processes need to be launched for multiple QEMU processes.
90108

91109
To enable PTP mode, append `[]` to the socket path argument of `vde_vmnet`.
92110

etc_sudoers.d/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@
33
To allow non-root users to run `vde_vmnet`, use [launchd](../launchd) *or*
44
install [the `vde_vmnet` file in this directory](./vde_vmnet) as `/etc/sudoers.d/vde_vmnet`.
55

6-
At least you have to modify the `sha224` digests in [`/etc/sudoers.d/vde_vmnet`](./vde_vmnet).
76
See the comment lines in the file for the further information.

etc_sudoers.d/vde_vmnet

+6-10
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,14 @@
22

33
# To allow non-root users to run `vde_vmnet`, use launchd OR install this file as `/etc/sudoers.d/vde_vmnet`.
44

5-
# Prerequisite: Replace dummy sha224 digest values in this file with the actual sha224 digest values.
6-
# - `openssl dgst -binary -sha224 /usr/local/bin/vde_switch | openssl base64`
7-
# - `openssl dgst -binary -sha224 /usr/local/bin/vde_vmnet | openssl base64`
8-
95
# Usage:
10-
# - sudo -u daemon -g staff /usr/local/bin/vde_switch ...
11-
# - sudo /usr/local/bin/vde_vmnet ...
6+
# - sudo -u daemon -g staff /opt/vde/bin/vde_switch ...
7+
# - sudo /opt/vde/bin/vde_vmnet ...
128

139
# Entries for shared mode (192.168.105.0/24)
14-
%staff ALL=(daemon:staff) NOPASSWD:NOSETENV: sha224:N9Msbbq+1xHLHUYgtkCQ/vDvY6sWpKUdZoJZ5g== /usr/local/bin/vde_switch --sock=/var/run/vde.ctl --pidfile=/var/run/vde.pid --group=staff --dirmode=0770
15-
%staff ALL=(root:root) NOPASSWD:NOSETENV: sha224:XQMHsLqtLONKq3yskqPXLFfKli/60d02UALUXg== /usr/local/bin/vde_vmnet --vmnet-gateway=192.168.105.1 /var/run/vde.ctl
10+
%staff ALL=(daemon:staff) NOPASSWD:NOSETENV: /opt/vde/bin/vde_switch --sock=/var/run/vde.ctl --pidfile=/var/run/vde.pid --group=staff --dirmode=0770 --nostdin
11+
%staff ALL=(root:root) NOPASSWD:NOSETENV: /opt/vde/bin/vde_vmnet --vmnet-gateway=192.168.105.1 /var/run/vde.ctl
1612

1713
# Entries for bridged mode (en0)
18-
%staff ALL=(daemon:staff) NOPASSWD:NOSETENV: sha224:N9Msbbq+1xHLHUYgtkCQ/vDvY6sWpKUdZoJZ5g== /usr/local/bin/vde_switch --sock=/var/run/vde.bridged.en0.ctl --pidfile=/var/run/vde.bridged.en0.pid --group=staff --dirmode=0770
19-
%staff ALL=(root:root) NOPASSWD:NOSETENV: sha224:XQMHsLqtLONKq3yskqPXLFfKli/60d02UALUXg== /usr/local/bin/vde_vmnet --vmnet-mode=bridged --vmnet-interface=en0 /var/run/vde.bridged.en0.ctl
14+
%staff ALL=(daemon:staff) NOPASSWD:NOSETENV: /opt/vde/bin/vde_switch --sock=/var/run/vde.bridged.en0.ctl --pidfile=/var/run/vde.bridged.en0.pid --group=staff --dirmode=0770 --nostdin
15+
%staff ALL=(root:root) NOPASSWD:NOSETENV: /opt/vde/bin/vde_vmnet --vmnet-mode=bridged --vmnet-interface=en0 /var/run/vde.bridged.en0.ctl

launchd/io.github.lima-vm.vde_vmnet.bridged.en0.plist

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
<key>Label</key>
77
<string>io.github.lima-vm.vde_vmnet.bridged.en0.plist</string>
88
<key>Program</key>
9-
<string>/usr/local/bin/vde_vmnet</string>
9+
<string>/opt/vde/bin/vde_vmnet</string>
1010
<key>ProgramArguments</key>
1111
<array>
12-
<string>/usr/local/bin/vde_vmnet</string>
12+
<string>/opt/vde/bin/vde_vmnet</string>
1313
<string>--vmnet-mode=bridged</string>
1414
<string>--vmnet-interface=en0</string>
1515
<string>/var/run/vde.bridged.en0.ctl</string>

launchd/io.github.lima-vm.vde_vmnet.plist

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
<key>Label</key>
77
<string>io.github.lima-vm.vde_vmnet.plist</string>
88
<key>Program</key>
9-
<string>/usr/local/bin/vde_vmnet</string>
9+
<string>/opt/vde/bin/vde_vmnet</string>
1010
<key>ProgramArguments</key>
1111
<array>
12-
<string>/usr/local/bin/vde_vmnet</string>
12+
<string>/opt/vde/bin/vde_vmnet</string>
1313
<string>--vmnet-gateway=192.168.105.1</string>
1414
<string>/var/run/vde.ctl</string>
1515
</array>

launchd/io.github.virtualsquare.vde-2.vde_switch.bridged.en0.plist

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<string>/usr/local/bin/vde_switch</string>
1111
<key>ProgramArguments</key>
1212
<array>
13-
<string>/usr/local/bin/vde_switch</string>
13+
<string>/opt/vde/bin/vde_switch</string>
1414
<string>--sock</string>
1515
<string>/var/run/vde.bridged.en0.ctl</string>
1616
<string>--pidfile</string>
@@ -19,6 +19,8 @@
1919
<string>staff</string>
2020
<string>--dirmode</string>
2121
<string>0770</string>
22+
<!-- Requires vde-2 2021-08-31 or later -->
23+
<string>--nostdin</string>
2224
</array>
2325
<key>StandardErrorPath</key>
2426
<string>/var/run/vde.bridged.en0.stderr</string>

launchd/io.github.virtualsquare.vde-2.vde_switch.plist

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<string>/usr/local/bin/vde_switch</string>
1111
<key>ProgramArguments</key>
1212
<array>
13-
<string>/usr/local/bin/vde_switch</string>
13+
<string>/opt/vde/bin/vde_switch</string>
1414
<string>--sock</string>
1515
<string>/var/run/vde.ctl</string>
1616
<string>--pidfile</string>
@@ -19,6 +19,8 @@
1919
<string>staff</string>
2020
<string>--dirmode</string>
2121
<string>0770</string>
22+
<!-- Requires vde-2 2021-08-31 or later -->
23+
<string>--nostdin</string>
2224
</array>
2325
<key>StandardErrorPath</key>
2426
<string>/var/run/vde.stderr</string>

0 commit comments

Comments
 (0)