Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to the systemd unit file #207

Merged
merged 5 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ qemu-wrapper:

.PHONY: vm
vm:
GOOS=linux CGO_ENABLED=0 go build $(LDFLAGS) -o bin/vm ./cmd/vm
GOOS=linux CGO_ENABLED=0 go build $(LDFLAGS) -o bin/gvforwarder ./cmd/vm

# win-sshproxy is compiled as a windows GUI to support backgrounding
.PHONY: win-sshproxy
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ With a container:

With the executable:
```
(vm) # ./vm -debug
(vm) # ./gvforwarder -debug
```

## Services
Expand Down
13 changes: 13 additions & 0 deletions contrib/systemd/gv-user-network@.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=gvisor-tap-vsock Network Traffic Forwarder
After=NetworkManager.service
BindsTo=sys-devices-virtual-net-%i.device
After=sys-devices-virtual-net-%i.device

[Service]
Environment=GV_VSOCK_PORT="1024"
EnvironmentFile=-/etc/sysconfig/gv-user-network
ExecStart=/usr/libexec/podman/gvforwarder -preexisting -iface %i -url vsock://2:${GV_VSOCK_PORT}/connect

[Install]
WantedBy=multi-user.target
12 changes: 0 additions & 12 deletions contrib/systemd/user-network.service

This file was deleted.

19 changes: 16 additions & 3 deletions gvisor-tap-vsock.spec.rpkg
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Source: {{{ git_dir_pack }}}
BuildRequires: gcc
BuildRequires: golang >= 1.16.6
BuildRequires: git-core
BuildRequires: systemd-rpm-macros
%if 0%{?fedora} || 0%{?rhel} >= 9
BuildRequires: go-rpm-macros
%endif
Expand Down Expand Up @@ -71,17 +72,29 @@ ln -s vendor src

export GOPATH=$(pwd)/_build:$(pwd)
%gobuild -o bin/gvproxy ./cmd/gvproxy
%gobuild -o bin/vm ./cmd/vm
%gobuild -o bin/gvforwarder ./cmd/vm

%install
install -dp %{buildroot}%{_libexecdir}/podman
install -p -m0755 bin/gvproxy %{buildroot}%{_libexecdir}/podman
install -p -m0755 bin/vm %{buildroot}%{_libexecdir}/podman
install -p -m0755 bin/gvforwarder %{buildroot}%{_libexecdir}/podman
install -dp %{buildroot}%{_unitdir}
install -p -m0644 contrib/systemd/gv-user-network@.service %{buildroot}%{_unitdir}

%post
%systemd_post gv-user-network@.service

%preun
%systemd_preun gv-user-network@.service

%postun
%systemd_postun_with_restart gv-user-network@.service

%files
%dir %{_libexecdir}/podman
%{_libexecdir}/podman/gvproxy
%{_libexecdir}/podman/vm
%{_libexecdir}/podman/gvforwarder
%{_unitdir}/gv-user-network@.service

%changelog
{{{ git_dir_changelog }}}
4 changes: 2 additions & 2 deletions images/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ RUN make
FROM busybox
COPY images/udhcpc.sh /usr/share/udhcpc/default.script
RUN chmod +x /usr/share/udhcpc/default.script
COPY --from=build /opt/app-root/src/bin/vm .
ENTRYPOINT ["/vm"]
COPY --from=build /opt/app-root/src/bin/gvforwarder .
ENTRYPOINT ["/gvforwarder"]
2 changes: 1 addition & 1 deletion test/wsl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -x

./bin/vm \
./bin/gvforwarder \
-url="stdio:$(pwd)/bin/gvproxy-windows.exe?listen-stdio=accept&debug=true" \
-iface="eth1" \
-stop-if-exist="" \
Expand Down