From 8979652094403d6e1c0efd232414c15e3316c014 Mon Sep 17 00:00:00 2001 From: Roel de Jong <12800443+twiggler@users.noreply.github.com> Date: Wed, 8 Oct 2025 14:32:47 +0200 Subject: [PATCH] fix: raise memory on esxi before loading target --- acquire/acquire.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/acquire/acquire.py b/acquire/acquire.py index 9c196e46..a1df1e57 100644 --- a/acquire/acquire.py +++ b/acquire/acquire.py @@ -1,6 +1,7 @@ from __future__ import annotations import argparse +import contextlib import enum import functools import io @@ -2416,19 +2417,20 @@ def main() -> None: target_path = f"{target_path}?{target_query}" target_paths.append(target_path) + # Use esxi_memory_context_manager only if running on ESXi host + if platform.system().lower() == "vmkernel": + context_mgr = esxi_memory_context_manager() + else: + context_mgr = contextlib.nullcontext() + try: target_name = "Unknown" # just in case open_all already fails - for target in Target.open_all(target_paths): - target_name = "Unknown" # overwrite previous target name - target_name = target.name - log.info("Loading target %s", target_name) - log.info(target) - if target.os == "esxi" and target.name == "local": - # Loader found that we are running on an esxi host - # Perform operations to "enhance" memory - with esxi_memory_context_manager(): - files_to_upload = acquire_children_and_targets(target, args) - else: + with context_mgr: + for target in Target.open_all(target_paths): + target_name = "Unknown" # overwrite previous target name + target_name = target.name + log.info("Loading target %s", target_name) + log.info(target) files_to_upload = acquire_children_and_targets(target, args) except Exception: log.error("Failed to acquire target: %s", target_name) # noqa: TRY400