Is it possible to start a VM any time another VM is started?
Say one has VMs A, B and C.
I would like to start A if either B or C are started, if A is not yet running.
The catch is that this should work no matter how B or C have been started (API, UI or command line).
I am currently running VirtualBox 7.0.26 on Slackware64 (Linux).
VM start-up dependency
Re: VM start-up dependency
The main way I know how to do this is to use a shell script to periodically poll VirtualBox to see if the VMs are running. You can either use a loop with a sleep command or a cron job to perform the check every so many seconds.
These commands will check the running status of a VM:
The second option has a faster execution time.
Just check if the result is greater than zero (i.e. grep found at least one match) for VMs B or C. If so, use the same method to check if VM A is running already. If not, then start it with:
These commands will check the running status of a VM:
Code: Select all
vboxmanage showvminfo '{UUID} or VM Name' --machinereadable | grep -c -i 'VMState="running"'
vboxmanage list runningvms | grep -c -i '{UUID} or VM Name'Just check if the result is greater than zero (i.e. grep found at least one match) for VMs B or C. If so, use the same method to check if VM A is running already. If not, then start it with:
Code: Select all
vboxmanage startvm '{UUID} or VM Name'