From 99db3849bf1211b173355639ee18f6adc5b49008 Mon Sep 17 00:00:00 2001 From: Ganga Ram Date: Wed, 2 Oct 2024 10:34:48 +0400 Subject: [PATCH] Shared memory refactoring. Audio on memsocket Signed-off-by: Jaroslaw Kurowski --- modules/common/services/audio.nix | 18 +- modules/disko/disko-ab-partitions.nix | 2 +- modules/hardware/common/shared-mem.nix | 295 +++++++++++++----- .../microvm/virtualization/microvm/appvm.nix | 4 +- .../microvm/common/ghaf-audio.nix | 9 +- .../virtualization/microvm/common/waypipe.nix | 32 +- .../0001-ivshmem-flat-memory-support.patch | 90 ++---- packages/memsocket/default.nix | 8 +- packages/memsocket/module.nix | 10 +- packages/mitmweb-ui/default.nix | 7 +- 10 files changed, 299 insertions(+), 176 deletions(-) diff --git a/modules/common/services/audio.nix b/modules/common/services/audio.nix index ff4cd36c7..35f430581 100644 --- a/modules/common/services/audio.nix +++ b/modules/common/services/audio.nix @@ -29,6 +29,16 @@ in default = 4714; description = "TCP port used by Pipewire-pulseaudio control"; }; + pulseaudioUnixSocketPath = mkOption { + type = types.path; + default = "/run/pipewire/pulseaudio-0"; + description = "Path to Unix socket used by Pipewire-pulseaudio service"; + }; + pulseaudioUseShmem = mkOption { + type = types.bool; + default = true; + description = "Use shared memory for audio service"; + }; }; config = mkIf cfg.enable { @@ -46,10 +56,14 @@ in { name = "libpipewire-module-protocol-pulse"; args = { - # Enable TCP socket for VMs pulseaudio clients + # Enable Unix or TCP socket for VMs pulseaudio clients "server.address" = [ { - address = "tcp:0.0.0.0:${toString cfg.pulseaudioTcpPort}"; + address = + if cfg.pulseaudioUseShmem then + "unix:${cfg.pulseaudioUnixSocketPath}" + else + "tcp:0.0.0.0:${toString cfg.pulseaudioTcpPort}"; "client.access" = "restricted"; } ]; diff --git a/modules/disko/disko-ab-partitions.nix b/modules/disko/disko-ab-partitions.nix index 8dc2801fa..00b8999e0 100644 --- a/modules/disko/disko-ab-partitions.nix +++ b/modules/disko/disko-ab-partitions.nix @@ -47,7 +47,7 @@ }; disko = { # 8GB is the recommeneded minimum for ZFS, so we are using this for VMs to avoid `cp` oom errors. - memSize = 18432; + memSize = 25432; imageBuilder = { extraPostVM = lib.mkIf (config.ghaf.imageBuilder.compression == "zstd") '' ${pkgs.zstd}/bin/zstd --compress $out/*raw diff --git a/modules/hardware/common/shared-mem.nix b/modules/hardware/common/shared-mem.nix index c8c7520dd..9adeedb45 100644 --- a/modules/hardware/common/shared-mem.nix +++ b/modules/hardware/common/shared-mem.nix @@ -13,21 +13,66 @@ let cfg = config.ghaf.shm; inherit (lib) foldl' - lists mkMerge mkIf mkOption mdDoc types ; + enabledServices = lib.filterAttrs (_name: serverAttrs: serverAttrs.enabled) cfg.service; + clientsPerService = + service: + lib.flatten ( + lib.mapAttrsToList ( + name: value: if (name == service || service == "all") then value.clients else [ ] + ) enabledServices + ); + allVMs = lib.unique ( + lib.flatten ( + lib.mapAttrsToList ( + _serviceName: serviceAttrs: serviceAttrs.clients ++ [ serviceAttrs.server ] + ) enabledServices + ) + ); + clientServicePairs = lib.flatten ( + lib.mapAttrsToList ( + serverName: serverAttrs: + lib.map (client: { + service = serverName; + inherit client; + }) serverAttrs.clients + ) enabledServices + ); + clientServiceWithID = lib.foldl' ( + acc: pair: acc ++ [ (pair // { id = builtins.length acc; }) ] + ) [ ] clientServicePairs; + clientID = + client: service: + let + filtered = builtins.filter (x: x.client == client && x.service == service) clientServiceWithID; + in + if filtered != [ ] then (builtins.toString (builtins.head filtered).id) else null; + clientsArg = lib.foldl' ( + acc: pair: + ( + acc + // { + "${pair.service}" = + if (builtins.hasAttr "${pair.service}" acc) then + acc.${pair.service} + "," + (builtins.toString pair.id) + else + (builtins.toString pair.id); + } + ) + ) { } clientServiceWithID; in { options.ghaf.shm = { enable = mkOption { type = types.bool; - default = false; + default = true; description = mdDoc '' - Enables shared memory communication between virtual machines (VMs) + Enables shared memory communication between virtual machines (VMs) and the host ''; }; memSize = mkOption { @@ -52,6 +97,83 @@ in else value; }; + + service = mkOption { + type = types.attrsOf types.anything; + default = + let + stdConfig = service: { + server = "${service}-vm"; + clientSocketPath = "/run/memsocket/${service}-client.sock"; + serverSocketPath = service: suffix: "/run/memsocket/${service}${suffix}.sock"; + userService = false; + }; + in + { + gui = stdConfig "gui" // { + serverSocketPath = service: suffix: "/tmp/${service}${suffix}.sock"; + userService = true; + serverConfig = { + systemdParams = { + wantedBy = [ "ghaf-session.target" ]; + }; + multiProcess = true; + }; + clients = [ + "chrome-vm" + "business-vm" + "comms-vm" + "gala-vm" + "zathura-vm" + ]; + clientConfig = { + systemdParams = { + wantedBy = [ "default.target" ]; + serviceConfig = { + User = "appuser"; + Group = "users"; + }; + }; + }; + enabled = true; + }; + audio = stdConfig "audio" // { + serverSocketPath = _service: _suffix: config.ghaf.services.audio.pulseaudioUnixSocketPath; + serverConfig = { + systemdParams = { + wantedBy = [ "default.target" ]; + after = [ "pipewire.service" ]; + serviceConfig = { + User = "pipewire"; + Group = "pipewire"; + }; + }; + }; + clients = [ + "chrome-vm" + "business-vm" + "comms-vm" + "gala-vm" + ]; + clientConfig = { + systemdParams = { + wantedBy = [ "default.target" ]; + serviceConfig = { + User = "appuser"; + Group = "users"; + }; + }; + }; + enabled = config.ghaf.services.audio.pulseaudioUseShmem; + }; + }; + description = mdDoc '' + Specifies the configuration of shared memory services: + server and client VMs. The server VMs are named after the + service name. + ''; + }; + hostSocketPath = mkOption { type = types.path; default = "/tmp/ivshmem_socket"; # The value is hardcoded in the application @@ -69,55 +191,24 @@ in conflicts with other memory areas, such as PCI regions. ''; }; - vms_enabled = mkOption { - type = types.listOf types.str; - default = [ ]; - description = mdDoc '' - List of vms having access to shared memory - ''; - }; enable_host = mkOption { type = types.bool; - default = false; + default = true; description = mdDoc '' Enables the memsocket functionality on the host system ''; }; - instancesCount = mkOption { + shmSlots = mkOption { type = types.int; default = - if cfg.enable_host then (builtins.length cfg.vms_enabled) + 1 else builtins.length cfg.vms_enabled; + if cfg.enable_host then + (builtins.length clientServiceWithID) + 1 + else + builtins.length clientServiceWithID; description = mdDoc '' Number of memory slots allocated in the shared memory region ''; }; - serverSocketPath = mkOption { - type = types.path; - default = "/run/user/${builtins.toString config.ghaf.users.loginUser.uid}/memsocket-server.sock"; - description = mdDoc '' - Specifies the path of the listening socket, which is used by Waypipe - or other server applications as the output socket in server mode for - data transmission - ''; - }; - clientSocketPath = mkOption { - type = types.path; - default = "/run/user/${builtins.toString config.ghaf.users.loginUser.uid}/memsocket-client.sock"; - description = mdDoc '' - Specifies the location of the output socket, which will connected to - in order to receive data from AppVMs. This socket must be created by - another application, such as Waypipe, when operating in client mode - ''; - }; - display = mkOption { - type = types.bool; - default = false; - description = mdDoc '' - Enables the use of shared memory with Waypipe for Wayland-enabled - applications running on virtual machines (VMs), facilitating - efficient inter-VM communication - ''; - }; }; config = let @@ -142,7 +233,7 @@ in } (mkIf cfg.enable_host { environment.systemPackages = [ - (pkgs.callPackage ../../../packages/memsocket { vms = cfg.instancesCount; }) + (pkgs.callPackage ../../../packages/memsocket { inherit (cfg) shmSlots; }) ]; }) { @@ -151,7 +242,7 @@ in pidFilePath = "/tmp/ivshmem-server.pid"; ivShMemSrv = let - vectors = toString (2 * cfg.instancesCount); + vectors = toString (2 * cfg.shmSlots); in pkgs.writeShellScriptBin "ivshmemsrv" '' if [ -S ${cfg.hostSocketPath} ]; then @@ -180,9 +271,9 @@ in { microvm.vms = let - memsocket = pkgs.callPackage ../../../packages/memsocket { vms = cfg.instancesCount; }; - vectors = toString (2 * cfg.instancesCount); - makeAssignment = vmName: { + memsocket = pkgs.callPackage ../../../packages/memsocket { inherit (cfg) shmSlots; }; + vectors = toString (2 * cfg.shmSlots); + configCommon = vmName: { ${vmName} = { config = { config = { @@ -200,7 +291,7 @@ in boot.extraModulePackages = [ (pkgs.linuxPackages.callPackage ../../../packages/memsocket/module.nix { inherit (config.microvm.vms.${vmName}.config.config.boot.kernelPackages) kernel; - vmCount = cfg.instancesCount; + inherit (cfg) shmSlots; }) ]; services = { @@ -213,47 +304,95 @@ in environment.systemPackages = [ memsocket ]; - systemd.user.services.memsocket = - if vmName == "gui-vm" then + }; + }; + }; + }; + configClient = data: { + ${data.client} = { + config = { + config = { + systemd.services."memsocket-${data.service}" = lib.attrsets.recursiveUpdate { + enable = true; + description = "memsocket"; + serviceConfig = { + Type = "simple"; + ExecStart = "${memsocket}/bin/memsocket -c ${ + cfg.service.${data.service}.clientSocketPath + } ${builtins.toString (clientID data.client data.service)}"; + Restart = "always"; + RestartSec = "1"; + RuntimeDirectory = "memsocket"; + RuntimeDirectoryMode = "0750"; + User = "ghaf"; + Group = "ghaf"; + }; + } cfg.service.${data.service}.clientConfig.systemdParams; + }; + }; + }; + }; + configServer = clientSuffix: clientId: service: { + "${cfg.service.${service}.server}" = + let + baseConfig = lib.attrsets.recursiveUpdate { + enable = true; + description = "memsocket"; + serviceConfig = { + Type = "simple"; + ExecStart = "${memsocket}/bin/memsocket -s ${ + cfg.service.${service}.serverSocketPath service clientSuffix + } -l ${clientId}"; + Restart = "always"; + RestartSec = "1"; + RuntimeDirectory = "memsocket"; + RuntimeDirectoryMode = "0750"; + }; + } cfg.service.${service}.serverConfig.systemdParams; + in + { + config = { + config = + if cfg.service.${service}.userService then { - enable = true; - description = "memsocket"; - after = [ "labwc.service" ]; - serviceConfig = { - Type = "simple"; - ExecStart = "${memsocket}/bin/memsocket -c ${cfg.clientSocketPath}"; - Restart = "always"; - RestartSec = "1"; - }; - wantedBy = [ "ghaf-session.target" ]; + systemd.user.services."memsocket-${service}${clientSuffix}" = baseConfig; } else - # machines connecting to gui-vm - let - vmIndex = lists.findFirstIndex (vm: vm == vmName) null cfg.vms_enabled; - in { - enable = true; - description = "memsocket"; - serviceConfig = { - Type = "simple"; - ExecStart = "${memsocket}/bin/memsocket -s ${cfg.serverSocketPath} ${builtins.toString vmIndex}"; - Restart = "always"; - RestartSec = "1"; - }; - wantedBy = [ "default.target" ]; + systemd.services."memsocket-${service}${clientSuffix}" = baseConfig; }; }; }; - }; }; + clientsConfig = foldl' lib.attrsets.recursiveUpdate { } (map configClient clientServicePairs); + clientsAndServers = lib.foldl' lib.attrsets.recursiveUpdate clientsConfig ( + map ( + service: + let + multiProcess = + if lib.attrsets.hasAttr "multiProcess" cfg.service.${service}.serverConfig then + cfg.service.${service}.serverConfig.multiProcess + else + false; + result = + if multiProcess then + (lib.foldl' lib.attrsets.recursiveUpdate { } ( + map (client: configServer "-${client}" (clientID client service) service) ( + clientsPerService service + ) + )) + else + (configServer "" # clientSuffix + clientsArg.${service} + service + ); + in + result + ) (builtins.attrNames enabledServices) + ); + finalConfig = foldl' lib.attrsets.recursiveUpdate clientsAndServers (map configCommon allVMs); in - foldl' lib.attrsets.recursiveUpdate { } (map makeAssignment cfg.vms_enabled); - } - { - microvm.vms.gui-vm.config.config.boot.kernelParams = [ - "kvm_ivshmem.flataddr=${cfg.flataddr}" - ]; + finalConfig; } ]); } diff --git a/modules/microvm/virtualization/microvm/appvm.nix b/modules/microvm/virtualization/microvm/appvm.nix index 02872ce59..836004a49 100644 --- a/modules/microvm/virtualization/microvm/appvm.nix +++ b/modules/microvm/virtualization/microvm/appvm.nix @@ -48,7 +48,9 @@ let internalIP = vmIndex + 100; }) - ./common/ghaf-audio.nix + (import (./common/ghaf-audio.nix) { + inherit configHost; + }) ./common/storagevm.nix ( with configHost.ghaf.virtualization.microvm-host; diff --git a/modules/microvm/virtualization/microvm/common/ghaf-audio.nix b/modules/microvm/virtualization/microvm/common/ghaf-audio.nix index 648f6f2ac..3feb98678 100644 --- a/modules/microvm/virtualization/microvm/common/ghaf-audio.nix +++ b/modules/microvm/virtualization/microvm/common/ghaf-audio.nix @@ -1,5 +1,8 @@ # Copyright 2022-2024 TII (SSRC) and the Ghaf contributors # SPDX-License-Identifier: Apache-2.0 +{ + configHost, +}: { config, lib, @@ -10,7 +13,11 @@ let cfg = config.ghaf.ghaf-audio; audiovmHost = "audio-vm"; audiovmPort = config.ghaf.services.audio.pulseaudioTcpPort; - address = "tcp:${audiovmHost}:${toString audiovmPort}"; + address = + if configHost.ghaf.shm.service.audio.enabled then + "unix:${configHost.ghaf.shm.service.audio.clientSocketPath}" + else + "tcp:${audiovmHost}:${toString audiovmPort}"; reconnectMs = 1000; in { diff --git a/modules/microvm/virtualization/microvm/common/waypipe.nix b/modules/microvm/virtualization/microvm/common/waypipe.nix index 3d5e1bafb..89c34320c 100644 --- a/modules/microvm/virtualization/microvm/common/waypipe.nix +++ b/modules/microvm/virtualization/microvm/common/waypipe.nix @@ -15,23 +15,27 @@ }: let cfg = config.ghaf.waypipe; + cfgShm = configHost.ghaf.shm.service; waypipePort = configHost.ghaf.virtualization.microvm.appvm.waypipeBasePort + vmIndex; waypipeBorder = lib.optionalString ( cfg.waypipeBorder && vm.borderColor != null ) "--border \"${vm.borderColor}\""; + displayOptServer = + if cfgShm.gui.enabled then + "-s " + cfgShm.gui.serverSocketPath "gui" "-${vm.name}-vm" + else + "--vsock -s ${toString waypipePort}"; + displayOptClient = + if cfgShm.gui.enabled && (lib.lists.elem "${vm.name}-vm" cfgShm.gui.clients) then + "-s " + cfgShm.gui.clientSocketPath + else + "--vsock -s ${toString waypipePort}"; runWaypipe = let - script = - if configHost.ghaf.shm.display then - '' - #!${pkgs.runtimeShell} -e - ${pkgs.waypipe}/bin/waypipe -s ${configHost.ghaf.shm.serverSocketPath} server "$@" - '' - else - '' - #!${pkgs.runtimeShell} -e - ${pkgs.waypipe}/bin/waypipe --vsock -s ${toString waypipePort} server "$@" - ''; + script = '' + #!${pkgs.runtimeShell} -e + ${pkgs.waypipe}/bin/waypipe ${displayOptClient} server "$@" + ''; in pkgs.writeScriptBin "run-waypipe" script; vsockproxy = pkgs.callPackage ../../../../../packages/vsockproxy { }; @@ -74,11 +78,7 @@ in Type = "simple"; Restart = "always"; RestartSec = "1"; - ExecStart = - if configHost.ghaf.shm.display then - "${pkgs.waypipe}/bin/waypipe --secctx \"${vm.name}\" ${waypipeBorder} -s ${configHost.ghaf.shm.clientSocketPath} client" - else - "${pkgs.waypipe}/bin/waypipe --vsock --secctx \"${vm.name}\" ${waypipeBorder} -s ${toString waypipePort} client"; + ExecStart = "${pkgs.waypipe}/bin/waypipe --secctx \"${vm.name}\" ${waypipeBorder} ${displayOptServer} client"; }; startLimitIntervalSec = 0; partOf = [ "ghaf-session.target" ]; diff --git a/overlays/custom-packages/qemu/0001-ivshmem-flat-memory-support.patch b/overlays/custom-packages/qemu/0001-ivshmem-flat-memory-support.patch index 690f15352..100cf9156 100644 --- a/overlays/custom-packages/qemu/0001-ivshmem-flat-memory-support.patch +++ b/overlays/custom-packages/qemu/0001-ivshmem-flat-memory-support.patch @@ -1,17 +1,17 @@ -From 13229d9e11eaf15eb6679be036364b9d0256f1c1 Mon Sep 17 00:00:00 2001 +From 51f29d8e1946bd5008f5e5f640ed93df58a2f4d9 Mon Sep 17 00:00:00 2001 From: Jaroslaw Kurowski -Date: Wed, 10 Jul 2024 15:21:07 +0400 +Date: Tue, 31 Dec 2024 13:53:19 +0400 Subject: ivshmem flat memory support --- - contrib/ivshmem-server/ivshmem-server.c | 6 +- + contrib/ivshmem-server/ivshmem-server.c | 7 ++-- hw/i386/pc_q35.c | 2 + - hw/misc/ivshmem.c | 74 ++++++++++++++++++++++--- + hw/misc/ivshmem.c | 54 ++++++++++++++++++++++++- include/hw/misc/ivshmem.h | 1 + - 4 files changed, 71 insertions(+), 12 deletions(-) + 4 files changed, 60 insertions(+), 4 deletions(-) diff --git a/contrib/ivshmem-server/ivshmem-server.c b/contrib/ivshmem-server/ivshmem-server.c -index 2f3c732..906c5d0 100644 +index 2f3c732..e7c7774 100644 --- a/contrib/ivshmem-server/ivshmem-server.c +++ b/contrib/ivshmem-server/ivshmem-server.c @@ -11,6 +11,7 @@ @@ -36,6 +36,14 @@ index 2f3c732..906c5d0 100644 g_free(filename); } +@@ -347,6 +347,7 @@ ivshmem_server_start(IvshmemServer *server) + + server->sock_fd = sock_fd; + server->shm_fd = shm_fd; ++ server->cur_id = 1; + + return 0; + diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index c7bc8a2..d76939e 100644 --- a/hw/i386/pc_q35.c @@ -57,7 +65,7 @@ index c7bc8a2..d76939e 100644 pc_q35_compat_defaults, pc_q35_compat_defaults_len); } diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c -index de49d1b..b1761b3 100644 +index de49d1b..1a65fb8 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -36,6 +36,7 @@ @@ -114,7 +122,7 @@ index de49d1b..b1761b3 100644 if (s->ivshmem_bar2) { error_setg(errp, "server sent unexpected shared memory message"); -@@ -494,13 +511,26 @@ static void process_msg_shmem(IVShmemState *s, int fd, Error **errp) +@@ -494,13 +511,25 @@ static void process_msg_shmem(IVShmemState *s, int fd, Error **errp) size = buf.st_size; @@ -132,68 +140,16 @@ index de49d1b..b1761b3 100644 + } + /* mmap the region and map into the BAR2 */ -- if (!memory_region_init_ram_from_fd(&s->server_bar2, OBJECT(s), -- "ivshmem.bar2", size, RAM_SHARED, -- fd, 0, errp)) { -+ memory_region_init_ram_from_fd(&s->server_bar2, OBJECT(s), "ivshmem.bar2", -+ size, RAM_SHARED, fd, 0, &local_err); -+ if (local_err) { -+ error_propagate(errp, local_err); + if (!memory_region_init_ram_from_fd(&s->server_bar2, OBJECT(s), + "ivshmem.bar2", size, RAM_SHARED, + fd, 0, errp)) { return; } - s->ivshmem_bar2 = &s->server_bar2; } -@@ -832,7 +862,6 @@ static void ivshmem_write_config(PCIDevice *pdev, uint32_t address, - - static void ivshmem_common_realize(PCIDevice *dev, Error **errp) - { -- ERRP_GUARD(); - IVShmemState *s = IVSHMEM_COMMON(dev); - Error *err = NULL; - uint8_t *pci_conf; -@@ -902,7 +931,8 @@ static void ivshmem_common_realize(PCIDevice *dev, Error **errp) - if (!ivshmem_is_master(s)) { - error_setg(&s->migration_blocker, - "Migration is disabled when using feature 'peer mode' in device 'ivshmem'"); -- if (migrate_add_blocker(&s->migration_blocker, errp) < 0) { -+ if (migrate_add_blocker(s->migration_blocker, errp) < 0) { -+ error_free(s->migration_blocker); - return; - } - } -@@ -920,7 +950,10 @@ static void ivshmem_exit(PCIDevice *dev) - IVShmemState *s = IVSHMEM_COMMON(dev); - int i; - -- migrate_del_blocker(&s->migration_blocker); -+ if (s->migration_blocker) { -+ migrate_del_blocker(s->migration_blocker); -+ error_free(s->migration_blocker); -+ } - - if (memory_region_is_mapped(s->ivshmem_bar2)) { - if (!s->hostmem) { -@@ -1014,7 +1047,7 @@ static const VMStateDescription ivshmem_plain_vmsd = { - .minimum_version_id = 0, - .pre_load = ivshmem_pre_load, - .post_load = ivshmem_post_load, -- .fields = (const VMStateField[]) { -+ .fields = (VMStateField[]) { - VMSTATE_PCI_DEVICE(parent_obj, IVShmemState), - VMSTATE_UINT32(intrstatus, IVShmemState), - VMSTATE_UINT32(intrmask, IVShmemState), -@@ -1068,7 +1101,7 @@ static const VMStateDescription ivshmem_doorbell_vmsd = { - .minimum_version_id = 0, - .pre_load = ivshmem_pre_load, - .post_load = ivshmem_post_load, -- .fields = (const VMStateField[]) { -+ .fields = (VMStateField[]) { - VMSTATE_PCI_DEVICE(parent_obj, IVShmemState), - VMSTATE_MSIX(parent_obj, IVShmemState), - VMSTATE_UINT32(intrstatus, IVShmemState), -@@ -1083,6 +1116,7 @@ static Property ivshmem_doorbell_properties[] = { +@@ -1083,6 +1112,7 @@ static Property ivshmem_doorbell_properties[] = { DEFINE_PROP_BIT("ioeventfd", IVShmemState, features, IVSHMEM_IOEVENTFD, true), DEFINE_PROP_ON_OFF_AUTO("master", IVShmemState, master, ON_OFF_AUTO_OFF), @@ -201,7 +157,7 @@ index de49d1b..b1761b3 100644 DEFINE_PROP_END_OF_LIST(), }; -@@ -1115,6 +1149,20 @@ static void ivshmem_doorbell_class_init(ObjectClass *klass, void *data) +@@ -1115,6 +1145,20 @@ static void ivshmem_doorbell_class_init(ObjectClass *klass, void *data) dc->vmsd = &ivshmem_doorbell_vmsd; } @@ -222,7 +178,7 @@ index de49d1b..b1761b3 100644 static const TypeInfo ivshmem_doorbell_info = { .name = TYPE_IVSHMEM_DOORBELL, .parent = TYPE_IVSHMEM_COMMON, -@@ -1123,11 +1171,19 @@ static const TypeInfo ivshmem_doorbell_info = { +@@ -1123,11 +1167,19 @@ static const TypeInfo ivshmem_doorbell_info = { .class_init = ivshmem_doorbell_class_init, }; @@ -254,5 +210,5 @@ index 433ef53..43aeab7 100644 #endif /* IVSHMEM_H */ -- -2.45.2 +2.47.1 diff --git a/packages/memsocket/default.nix b/packages/memsocket/default.nix index 968fbd6a3..0c0a6dd53 100644 --- a/packages/memsocket/default.nix +++ b/packages/memsocket/default.nix @@ -4,7 +4,7 @@ stdenv, lib, debug ? false, - vms, + shmSlots, fetchFromGitHub, ... }: @@ -14,11 +14,11 @@ stdenv.mkDerivation { src = fetchFromGitHub { owner = "tiiuae"; repo = "shmsockproxy"; - rev = "2357926b94ed12c050fdbfbfc0f248393a4c9ea1"; - sha256 = "sha256-9KlHuVbe5qvjRUXj7oyJ1X7CLvqj7/OoVGDWRqpIY2s="; + rev = "bd8376ac5bc7296c36d5df57a07684ba99a1b0fb"; + sha256 = "sha256-GkT3yolYrIf3oZosVgTShasG+98CkVoV/QJ/7bvQ+t0="; }; - CFLAGS = "-O2 -DVM_COUNT=" + (toString vms) + (if debug then " -DDEBUG_ON" else ""); + CFLAGS = "-O2 -DSHM_SLOTS=" + (toString shmSlots) + (if debug then " -DDEBUG_ON" else ""); sourceRoot = "source/app"; installPhase = '' diff --git a/packages/memsocket/module.nix b/packages/memsocket/module.nix index e4ee0c06a..50c8537cc 100644 --- a/packages/memsocket/module.nix +++ b/packages/memsocket/module.nix @@ -5,18 +5,18 @@ lib, kernel, fetchFromGitHub, - vmCount, + shmSlots, ... }: stdenv.mkDerivation { - inherit vmCount; + inherit shmSlots; name = "ivshmem-driver-${kernel.version}"; src = fetchFromGitHub { owner = "tiiuae"; repo = "shmsockproxy"; - rev = "2357926b94ed12c050fdbfbfc0f248393a4c9ea1"; - sha256 = "sha256-9KlHuVbe5qvjRUXj7oyJ1X7CLvqj7/OoVGDWRqpIY2s="; + rev = "bd8376ac5bc7296c36d5df57a07684ba99a1b0fb"; + sha256 = "sha256-GkT3yolYrIf3oZosVgTShasG+98CkVoV/QJ/7bvQ+t0="; }; sourceRoot = "source/module"; @@ -29,7 +29,7 @@ stdenv.mkDerivation { makeFlags = [ "KDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" "MODULEDIR=$(out)/lib/modules/${kernel.modDirVersion}/kernel/drivers/char" - "CFLAGS_kvm_ivshmem.o=\"-DCONFIG_KVM_IVSHMEM_VM_COUNT=${builtins.toString vmCount}\"" + "CFLAGS_kvm_ivshmem.o=\"-DCONFIG_KVM_IVSHMEM_SHM_SLOTS=${builtins.toString shmSlots}\"" ]; meta = with lib; { diff --git a/packages/mitmweb-ui/default.nix b/packages/mitmweb-ui/default.nix index 1c07945b9..1af4696f3 100644 --- a/packages/mitmweb-ui/default.nix +++ b/packages/mitmweb-ui/default.nix @@ -9,6 +9,11 @@ let waypipePort = 1100; # TODO: remove hardcoded port number idsvmIP = "ids-vm"; + displayOpt = + if configHost.ghaf.shm.service.gui.enabled then + "-s ${configHost.ghaf.shm.service.gui.clientSocketPath}" + else + "--vsock -s ${toString waypipePort}"; mitmwebUI = pkgs.writeShellScript "mitmweb-ui" '' # Create ssh-tunnel between chrome-vm and ids-vm ${pkgs.openssh}/bin/ssh -i /run/waypipe-ssh/id_ed25519 \ @@ -20,7 +25,7 @@ let # Launch google-chrome application and open mitmweb page ${pkgs.openssh}/bin/ssh -i /run/waypipe-ssh/id_ed25519 -o StrictHostKeyChecking=no chrome-vm \ - ${pkgs.waypipe}/bin/waypipe --border=#ff5733,5 --vsock -s ${toString waypipePort} server \ + ${pkgs.waypipe}/bin/waypipe --border=#ff5733,5 ${displayOpt}} server \ google-chrome-stable --enable-features=UseOzonePlatform --ozone-platform=wayland \ http://localhost:8081