Skip to content

[Bug]: VBoxManage import invocations fail when running in parallel #80

@hholzgra

Description

@hholzgra

Version

7.1.10

Host OS Type

Linux

Host Architecture

x86

Guest OS Type

Linux

Guest Architecture

x86

Component

VBoxManage CLI

What happened?

I always had intermittent failures with VirtualBox when trying to bring up multiple new VMs at about the same time, but I now did set up a new box with VirtualBox and vagrant on Debian 13 (was previously using 7.0 on Debian 12).

Now whenever two or more instances of "VBoxManage import ..." run in parallel, executed by "vagrant up", between all-but-one and all fail with:

There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["import", "/home/hartmut/.vagrant.d/boxes/os-xenial/0/virtualbox/box.ovf", "--vsys", "0", "--vmname", "xenial_default_1752334718148_46180_1752688918633_94039", "--vsys", "0", "--unit", "12", "--disk", "/home/hartmut/VirtualBox VMs/xenial_default_1752334718148_46180_1752688918633_94039/box-disk001.vmdk", "--vsys", "0", "--unit", "13", "--disk", "/home/hartmut/VirtualBox VMs/xenial_default_1752334718148_46180_1752688918633_94039/box-disk002.vmdk"]

Stderr: 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Interpreting /home/hartmut/.vagrant.d/boxes/os-xenial/0/virtualbox/box.ovf...
OK.
0%...NS_ERROR_INVALID_ARG
VBoxManage: error: Appliance import failed
VBoxManage: error: Code NS_ERROR_INVALID_ARG (0x80070057) - Invalid argument value (extended info not available)
VBoxManage: error: Context: "RTEXITCODE handleImportAppliance(HandlerArg*)" at line 1447 of file VBoxManageAppliance.cpp

This makes starting multiple setups at the same time pretty impossible. I typically build VM base boxes with one process per CPU core in parallel, but had to switch back to running a single instance only.

I for now solved this by patching the /usr/bin/VBoxManage script like this, serializing import calls using a simple exclusive lock file:

--- VBoxManage.orig	2025-07-16 22:13:45.792141632 +0200
+++ VBoxManage	2025-07-16 20:51:44.963385398 +0200
@@ -142,7 +142,22 @@
         exec "$INSTALL_DIR/VirtualBoxVM" "$@"
         ;;
     VBoxManage|vboxmanage)
-        exec "$INSTALL_DIR/VBoxManage" "$@"
+	if [ "$1" = "import" ]
+	then
+	    LOCKFILE=/tmp/vbox-import.lock
+	    trap '{ rm -f -- "$LOCKFILE"; }' EXIT
+	    while [ -e "$LOCKFILE" ]
+	    do
+		sleep 1
+	    done
+	    touch -- "$LOCKFILE"
+	fi
+        "$INSTALL_DIR/VBoxManage" "$@"
+	if [ "$1" = "import" ]
+	then
+	    rm -f -- "$LOCKFILE"
+	fi
+	exit
         ;;
     VBoxSDL|vboxsdl)
         exec "$INSTALL_DIR/VBoxSDL" "$@"

With that I'm still getting intermittent errors every once in a while, but not a constant flow of them when trying to do things in parallel.

How can we reproduce this?

Try to run multiple VBoxManage import in parallel

Did you upload all of your necessary log files, screenshots, etc.?

  • Yes, I've uploaded all pertinent files to this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions