Menu

Can't stop VRDE: The machine 'OL7-41' is already locked for a session (or being unlocked)

Help
2019-10-05
2022-07-28
  • Till Wimmer

    Till Wimmer - 2019-10-05

    Hi there

    I'm running VB 6.0.10 on Debian 10 with phpVirtualBox (develop branch).

    I wonder if this issue is related to phpVirtualBox:
    I wrote a backup script which stops all VMs, then copies the whole folder to a NAS, and then starts them again.
    I'm using this command to stop the VM: VBoxManage controlvm "$vm" acpipowerbutton

    On some VMs this command shuts down the OS (Linux and Windows), but the VMs state in the phpVirtualBox GUI is still "running" and trying to get information with VBoxManage showvminfo hangs forever.

    This seems to be a problem related to VRDP and libvncserver : If there is an existing RD session, the VM does not shut down properly (see here).

    Hence my plan to shut off VRDP before sending the acpipowerbutton command. But here comes the next issue:

    VBoxManage modifyvm MYVM_XY --vrde off
    VBoxManage: error: The machine 'MYVM_XY' is already locked for a session (or being unlocked)
    VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MachineWrap, interface IMachine, callee nsISupports

    In the phpVirtualBox GUI I can disable VRDE without any issue. So I wonder if phpVirtualBox is locking the session? But the error still occurs after closing the phpVirtualBox GUI.

    How can I keep phpVirtualBox from locking the session so that I can stop VRDE from the command line?

    Cheers,
    Till

     
  • Till Wimmer

    Till Wimmer - 2019-10-05

    Well... I was on the wrong track, thinking that this has anything to do with the libvncserver issue.

    I'm using RDP, and obviously this makes no use of any VNC library...

    The question remains why I can't fully shut down certain VMs and if this is related to phpVirtualBox.
    The other question is: How does phpVirtualBox manage to disable VRDE at runtime, while on the command line I get a session locking issue?

    Cheers,
    Till

     
    • Eduardo B

      Eduardo B - 2022-07-28

      Hi,
      I am going thru the same problem you posted. I need to activate/deactivate vrde feature on running VMs, but when I run "VBOXManage modifyvm VM --vrde off" I get a session lock error (VBOX_E_INVALID_OBJECT_STATE).
      I also tried to start VM with VBoxHeadless --vrde config changing vrde config with above command, but I got the same result.
      I'm curious how PHPVirtualBox and VirtualBox Host GUI manage to switch vrde feature on/off for running VMs.
      As a desperate trial, I tried to pause VM to disable vrde feature with the same command (VBOXManage modifyvm --vrde off), but didnt also worked, even with administrator privileges.
      It seems to me the problem regards to the command VBoxManage isn't having write privileges to change a session state that is not stopped.

      Any clues are very welcome.

      Host - DEV: Windows 10
      Host - PROD: Ubuntu 20.04
      VirtualBox version: 6.1.34 r150636 (Qt5.6.2)
      Guest VM: Windows 10

      Thanks you
      Eduardo

      Whole error output:

      VBoxManage.exe: error: The machine 'w10' is already locked for a session (or being unlocked)
      VBoxManage.exe: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MachineWrap, interface IMachine, callee IUnknown
      VBoxManage.exe: error: Context: "LockMachine(a->session, LockType_Write)" at line 554 of file VBoxManageModifyVM.cpp
      
       
      • Eduardo B

        Eduardo B - 2022-07-28

        For those who came here looking for a solution to the same problem.
        As per my previous thoughts, the problem was really regarding to modifyvm command. To modify VM config, it has to be stopped.
        However, it is possible to change session config keeping VM config unchanged. The key is to use controlvm like bellow:

        VBoxManage controlvm "w10" vrde off
        Adm privilege isn't necessary.

        The official docs explain everything in details. Big shame on me for not reading it before!
        https://docs.oracle.com/en/virtualization/virtualbox/6.0/user/vboxmanage-controlvm.html

         
  • Smart Guide

    Smart Guide - 2019-10-09
    Post awaiting moderation.

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.