VirtualBox

Opened 15 years ago

Closed 15 years ago

Last modified 15 years ago

#4388 closed defect (fixed)

Error in linux /etc/init.d/vboxdrv stop_vms() function => Fixed in SVN

Reported by: Kevin Rolfes Owned by:
Component: other Version: VirtualBox 3.0.0
Keywords: Cc:
Guest type: Linux Host type: Linux

Description

I found this problem to exist in both VirtualBox 2.2.4 and 3.0.0, although the behavior is different between the two.

Summary: The line

  VMS=`$VBOXMANAGE --nologo list runningvms | sed -e 's/^".*.*"{\(.*\)}/\1/' 2>/dev/null`

in stop_vms() of /etc/init.d/vboxdrv (in version 3.0.0) should be changed to:

  VMS=`$VBOXMANAGE --nologo list runningvms | sed -e 's/^".*".*{\(.*\)}/\1/' 2>/dev/null`
                                                            ^^^

Long explanation:

There is a function "stop_vms()" in /etc/init.d/vboxdrv which can be used to power off or save the state of active VMs belonging to a list of users. To test it, I created a file /etc/default/virtualbox containing the following two lines:

SHUTDOWN_USERS="kevin" SHUTDOWN=savestate

and executed "/etc/init.d/vboxdrv stop_vms" as root.

  1. VirtualBox 2.2.4 r47978 Debian Lenny AMD64 .deb (from download.virtualbox.org), running on

Debian Testing / Squeeze.

In this package, the stop_vms() function in vboxdrv contains this code:

VMS=$VBOXMANAGE --nologo list runningvms | sed -e 's/^".*"//' 2>/dev/null

This creates a list of the UUIDs of the running VMs. For example, on my system:

  $ VBoxManage --nologo list runningvms
  "VBox 1" {26f8caca-ddc5-40c0-94d3-2ee29c9e26bb}
  "VBox 2" {093d1dcb-e581-403d-a00d-234972fb5ca5}
  $ VBoxManage --nologo list runningvms | sed -e 's/^".*"//'
   {26f8caca-ddc5-40c0-94d3-2ee29c9e26bb}
   {093d1dcb-e581-403d-a00d-234972fb5ca5}

I believe this code needs to strip the {} braces from the UUIDs. The output of this, in $VMS, is used as a parameter to "VBoxManage controlvm" and the braces are not permitted. The resulting error looks like this:

  # /etc/init.d/vboxdrv stop_vms
  Saving state of remaining VMs:ERROR: Could not find a registered machine named '{26f8caca-ddc5-40c0-94d3-2ee29c9e26bb}'
  Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBox, interface IVirtualBox, callee nsISupports
  Context: "FindMachine (Bstr(a->argv[0]), machine.asOutParam())" at line 570 of file VBoxManage.cpp
  ERROR: Could not find a registered machine named '{093d1dcb-e581-403d-a00d-234972fb5ca5}'
  Details: code VBOX_E_OBJECT_NOT_FOUND (0x80bb0001), component VirtualBox, interface IVirtualBox, callee nsISupports
  Context: "FindMachine (Bstr(a->argv[0]), machine.asOutParam())" at line 570 of file VBoxManage.cpp
  done..
  1. VirtualBox 3.0.0 r49315 Debian Lenny AMD64 .deb (from download.virtualbox.org), running on

Debian Testing / Squeeze.

The arguments to sed were changed in this version. Here is the line from stop_vms() in vboxdrv:

VMS=$VBOXMANAGE --nologo list runningvms | sed -e 's/^".*.*"{\(.*\)}/\1/' 2>/dev/null

This sed command isn't doing any editing when I try it:

  $ VBoxManage --nologo list runningvms
  "VBox 1" {26f8caca-ddc5-40c0-94d3-2ee29c9e26bb}
  "VBox 2" {093d1dcb-e581-403d-a00d-234972fb5ca5}
  $ VBoxManage --nologo list runningvms | sed -e 's/^".*.*"{\(.*\)}/\1/' 
  "VBox 1" {26f8caca-ddc5-40c0-94d3-2ee29c9e26bb}
  "VBox 2" {093d1dcb-e581-403d-a00d-234972fb5ca5}

As a result, the stop_vms() function gives numerous errors for each VM (can't find "VBox", can't find "1", and can't find "{uuid}").

The correct command, I believe, should be this:

  $ VBoxManage --nologo list runningvms | sed -e 's/^".*".*{\(.*\)}/\1/'
  26f8caca-ddc5-40c0-94d3-2ee29c9e26bb
  093d1dcb-e581-403d-a00d-234972fb5ca5

Change History (2)

comment:1 by Frank Mehnert, 15 years ago

Summary: Error in linux /etc/init.d/vboxdrv stop_vms() functionError in linux /etc/init.d/vboxdrv stop_vms() function => Fixed in SVN

Thanks for the report, fixed that annoying typo in SVN.

comment:2 by Frank Mehnert, 15 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette