关闭主机前执行 savestate (Virtualbox/OpenSUSE)

man*_*k13 2 opensuse virtualbox

我正在开发一个旧版本的 VirtualBox (3.2.6),我可以在其中编辑/etc/sysconfig/vbox,在那里我可以添加尽可能多的 VM 以在主机启动时启动。

现在这个新版本 4.2.6 无法编辑该文件,因为它不再受支持。检查论坛我发现了一些东西,但我不工作。

cat /etc/default/virtualbox
# /etc/default/virtualbox
#
# -------------------------------------------------------------------------------------------------
# In the "SHUTDOWN_USERS" list all users for which a check for runnings VMs should be done during
# shutdown of "vboxdrv" resp. the server:
# SHUTDOWN_USERS="foo bar"
#
# Set "SHUTDOWN" to one of "poweroff", "acpibutton" or "savestate" depending on which of the
# shutdown methods for running VMs are wanted:
# SHUTDOWN="poweroff"
# SHUTDOWN="acpibutton"
# SHUTDOWN="savestate"
# -------------------------------------------------------------------------------------------------
#
#SHUTDOWN_USERS="foo bar"
#SHUTDOWN="savestate"
VBOXAUTOSTART_DB=/etc/vbox
#VBOXAUTOSTART_CONFIG=/etc/vbox/vbox.cfg
VBOXAUTOSTART_CONFIG=/etc/vbox/vboxauto.conf
Run Code Online (Sandbox Code Playgroud)

这是vboxauto.conf

cat /etc/vbox/vboxauto.conf
# Default policy is to deny starting a VM, the other option is "allow".
default_policy = deny

root = {
    allow = true
}
Run Code Online (Sandbox Code Playgroud)

然后我这样做:

VBoxManage setproperty autostartdbpath /etc/vbox
Run Code Online (Sandbox Code Playgroud)

和这个

VBoxManage modifyvm <the_machine> --autostart-enabled on
Run Code Online (Sandbox Code Playgroud)

当我尝试查看状态时

rcvboxes status
Virtualbox machines: no virtual machines running.                                                                                                                       skipped
vboxes.service - LSB: Autostart Virtual Box VMs
          Loaded: loaded (/etc/init.d/vboxes)
          Active: active (exited) since Tue, 2013-02-05 23:34:57 UYST; 32min ago
         Process: 30764 ExecStart=/etc/init.d/vboxes start (code=exited, status=0/SUCCESS)
          CGroup: name=systemd:/system/vboxes.service

Feb 05 23:34:57 my.machine vboxes[30764]: Starting Virtualbox machines: no virtual machines configured..unused
Feb 05 23:34:57 my.machine systemd[1]: Started LSB: Autostart Virtual Box VMs.
Run Code Online (Sandbox Code Playgroud)

为什么 VirtualBox 看不到我的虚拟机而让它们无头? 编辑 30 - 五月

我确实在/etc/sysconfig/vbox 中配置了它,但是当我在 init.d 下运行它时得到这个

/etc/init.d/vboxes status
Virtualbox machines: no virtual machines running.                    skipped
vboxes.service - LSB: Autostart Virtual Box VMs
          Loaded: loaded (/etc/init.d/vboxes)
          Active: inactive (dead) since Sat, 2013-02-02 22:00:49 UYST; 1 day and 21h ago
         Process: 4155 ExecStop=/etc/init.d/vboxes stop (code=exited, status=0/SUCCESS)
         Process: 3955 ExecStart=/etc/init.d/vboxes start (code=exited, status=0/SUCCESS)
          CGroup: name=systemd:/system/vboxes.service
Run Code Online (Sandbox Code Playgroud)

我做了一个小测试并将脚本移动到 /root/bin ,它工作得很好。

./vboxes_test status
 test (user: root):                                       running (since 2013-02-04 21:55:46)                                                        running
 test (user: root):                                       running (since 2013-02-04 21:55:46)
Run Code Online (Sandbox Code Playgroud)

小编辑: 到目前为止,这就是我所谈论的....无论如何都做了旧配置(在 /etc/sysconfig/vbox 中添加虚拟机),然后我重新启动主机,虚拟机也这样做了。问题是我不希望 vms 在我关闭主机电源时重新启动:t*他 vms 必须在主机关闭之前执行 savestate *。

small_comment: 如果我之前做了一个保存状态并重新启动主机.. vms 可以按我的意愿工作......

有什么信息可以使它工作吗?

slm*_*slm 5

我认为你正在寻找的命令是这样的:

VBoxManage modifyvm <Machine Name> --autostop-type savestate
Run Code Online (Sandbox Code Playgroud)

以下是 savestate 的替代方法:[disabled|savestate|poweroff|acpishutdown].

如果这不起作用,我相信您可以使用该acpishutdown选项来配置虚拟机,以便在它收到acpishutdown到 savestate的触发器时。

如果上述方法不起作用,则总是使用以下命令自己手动执行保存状态:

VBoxManage controlvm <vm> savestate
Run Code Online (Sandbox Code Playgroud)

然后重新启动主机系统。

参考