Skip to content

Commit 8eb44ef

Browse files
TibixDevLevev
andcommitted
chore: Improve Podman compose preset and minor refactors
Removed the requirement for slirp4netns, priviliged is no longer required for Podman (actually having it breaks networking in some cases). Since we're no longer priviliged in Podman, we add the `:Z` volume label needed by SELinux. Co-authored-by: Levev <[email protected]>
1 parent ca2888c commit 8eb44ef

File tree

6 files changed

+20
-21
lines changed

6 files changed

+20
-21
lines changed

src/renderer/data/docker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const DOCKER_DEFAULT_COMPOSE: ComposeConfig = {
3737
volumes: [
3838
"data:/storage",
3939
"${HOME}:/shared",
40-
"/dev/bus/usb:/dev/bus/usb", // QEMU Synamic USB Passthrough
40+
"/dev/bus/usb:/dev/bus/usb", // QEMU Dynamic USB Passthrough
4141
"./oem:/oem",
4242
],
4343
devices: ["/dev/kvm"],

src/renderer/data/podman.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { ComposeConfig } from "../../types";
22
import { RESTART_ON_FAILURE } from "../lib/constants";
33

4-
// TODO: investigate whether this approach is even necessary.
54
export const PODMAN_DEFAULT_COMPOSE: ComposeConfig = {
65
name: "winboat",
76
volumes: {
@@ -24,9 +23,7 @@ export const PODMAN_DEFAULT_COMPOSE: ComposeConfig = {
2423
HOST_PORTS: "7149",
2524
ARGUMENTS: "-qmp tcp:0.0.0.0:7149,server,wait=off",
2625
},
27-
network_mode: "slirp4netns:port_handler=slirp4netns",
2826
cap_add: ["NET_ADMIN"],
29-
privileged: true,
3027
ports: [
3128
"127.0.0.1::8006", // VNC Web Interface
3229
"127.0.0.1::7148", // Winboat Guest Server API
@@ -37,10 +34,9 @@ export const PODMAN_DEFAULT_COMPOSE: ComposeConfig = {
3734
stop_grace_period: "120s",
3835
restart: RESTART_ON_FAILURE,
3936
volumes: [
40-
"data:/storage",
41-
"${HOME}:/shared",
42-
"/dev/bus/usb:/dev/bus/usb:rslave", // QEMU Synamic USB Passthrough
43-
"./oem:/oem",
37+
"data:/storage:Z",
38+
"${HOME}:/shared:Z",
39+
"./oem:/oem:Z",
4440
],
4541
devices: ["/dev/kvm", "/dev/net/tun", "/dev/bus/usb"],
4642
},

src/renderer/lib/install.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { createNanoEvents, type Emitter } from "nanoevents";
55
import { Winboat } from "./winboat";
66
import { ContainerManager } from "./containers/container";
77
import { WinboatConfig } from "./config";
8-
import { CommonPorts, createContainer, getActiveHostPort } from "./containers/common";
8+
import { CommonPorts, createContainer, getActiveHostPort, ContainerRuntimes } from "./containers/common";
99

1010
const fs: typeof import("fs") = require("fs");
1111
const path: typeof import("path") = require("path");
@@ -46,7 +46,7 @@ export class InstallManager {
4646
this.state = InstallStates.IDLE;
4747
this.preinstallMsg = "";
4848
this.emitter = createNanoEvents<InstallEvents>();
49-
this.container = conf.container;
49+
this.container = createContainer(conf.container);
5050
}
5151

5252
changeState(newState: InstallState) {
@@ -99,11 +99,13 @@ export class InstallManager {
9999

100100
// Storage folder mapping
101101
const storageFolderIdx = composeContent.services.windows.volumes.findIndex(vol => vol.includes("/storage"));
102+
const volumeLabel = this.conf.container === ContainerRuntimes.PODMAN ? ":Z" : "";
103+
102104
if (storageFolderIdx === -1) {
103105
logger.warn("No /storage volume found in compose template, adding one...");
104-
composeContent.services.windows.volumes.push(`${this.conf.installFolder}:/storage`);
106+
composeContent.services.windows.volumes.push(`${this.conf.installFolder}:/storage${volumeLabel}`);
105107
} else {
106-
composeContent.services.windows.volumes[storageFolderIdx] = `${this.conf.installFolder}:/storage`;
108+
composeContent.services.windows.volumes[storageFolderIdx] = `${this.conf.installFolder}:/storage${volumeLabel}`;
107109
}
108110

109111
// Home folder mapping

src/renderer/views/Config.vue

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -667,11 +667,6 @@ const statAsync = promisify(fs.stat);
667667
// Emits
668668
const $emit = defineEmits(["rerender"]);
669669
670-
// Constants
671-
const HOMEFOLDER_SHARE_STR = "${HOME}:/shared";
672-
const USB_BUS_PATH = "/dev/bus/usb:/dev/bus/usb";
673-
const QMP_ARGUMENT = "-qmp tcp:0.0.0.0:7149,server,wait=off"; // 7149 can remain hardcoded as it refers to a guest port
674-
675670
// For Resources
676671
const compose = ref<ComposeConfig | null>(null);
677672
const numCores = ref(0);
@@ -713,6 +708,12 @@ const wbConfig = WinboatConfig.getInstance();
713708
const winboat = Winboat.getInstance();
714709
const usbManager = USBManager.getInstance();
715710
711+
// Constants
712+
const HOMEFOLDER_SHARE_STR = winboat.containerMgr!.defaultCompose.services.windows.volumes.find(v => v.startsWith("${HOME}"))!;
713+
// ^ We have to do this because the Podman and Docker equivalents differ (:Z ending on Podman)
714+
const USB_BUS_PATH = "/dev/bus/usb:/dev/bus/usb";
715+
const QMP_ARGUMENT = "-qmp tcp:0.0.0.0:7149,server,wait=off"; // 7149 can remain hardcoded as it refers to a guest port
716+
716717
onMounted(async () => {
717718
await assignValues();
718719
});

src/renderer/views/SetupUI.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ function install() {
10681068
password: password.value,
10691069
shareHomeFolder: homeFolderSharing.value,
10701070
...(customIsoPath.value ? { customIsoPath: customIsoPath.value } : {}),
1071-
container: createContainer(containerRuntime.value), // Hardcdde for now
1071+
container: containerRuntime.value, // Hardcdde for now
10721072
};
10731073
10741074
const wbConfig = WinboatConfig.getInstance(); // Create winboat config.

src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { type WindowsVersionKey } from "./renderer/lib/constants";
2-
import { ContainerManager } from "./renderer/lib/containers/container";
2+
import { ContainerRuntimes } from "./renderer/lib/containers/common";
33
import { type Winboat } from "./renderer/lib/winboat";
44

55
export type Specs = {
@@ -20,7 +20,7 @@ export type InstallConfiguration = {
2020
password: string;
2121
customIsoPath?: string;
2222
shareHomeFolder: boolean;
23-
container: ContainerManager;
23+
container: ContainerRuntimes;
2424
};
2525

2626
export type WinApp = {
@@ -76,7 +76,7 @@ export type ComposeConfig = {
7676
HOST_PORTS: string;
7777
[key: string]: string; // Allow additional env vars
7878
};
79-
privileged: boolean;
79+
privileged?: boolean;
8080
ports: Array<string | LongPortMapping>;
8181
network_mode?: string;
8282
cap_add: string[];

0 commit comments

Comments
 (0)