LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   KDE permit logout with Virtual Machine (https://www.linuxquestions.org/questions/slackware-14/kde-permit-logout-with-virtual-machine-4175623098/)

mfoley 02-04-2018 09:51 PM

KDE permit logout with Virtual Machine
 
When a KDE user goes to logout with a Virtual Machine running (in this case VirtualBox, WIN7 VM), it initially prevents the user from logging out if the VM is running. Normally, this is a great feature as it prevents the user from "pulling" the plug" on the VM. However, I have added a VM shutdown script to System Settings > Startup and Shutdown > Autostart which does shutdown the VM when the user logs out. However, it still aborts the actual logout and the user has to log out again.

Is there a way to turn off this feature?

Aeterna 02-05-2018 07:54 AM

Quote:

Originally Posted by mfoley (Post 5815885)
When a KDE user goes to logout with a Virtual Machine running (in this case VirtualBox, WIN7 VM), it initially prevents the user from logging out if the VM is running. Normally, this is a great feature as it prevents the user from "pulling" the plug" on the VM. However, I have added a VM shutdown script to System Settings > Startup and Shutdown > Autostart which does shutdown the VM when the user logs out. However, it still aborts the actual logout and the user has to log out again.

Is there a way to turn off this feature?

I don't know how to turn it off but it is easy to circumvent:
1) mouse click on host desktop so it becomes active then press ctrl - alt - L for a bit longer (if you do this too short then you get logged out and logged in instantly)
2) if you have virtual desktops, just switch to another desktop and press ctrl - alt - L

both ways work for me

hope this will help

mfoley 02-05-2018 11:42 AM

Thanks, I'll experiment with that, but it's not entirely satisfactory. This workstation is in production in an office and the user is an accountant, not a techy. They can click on things to log out (KDE Launcher > Leave), but would like be more adverse to using a "secrect" key combination than doing the logout twice. Like I said, it's a great feature and one not present in Kubuntu and one reason I chose Slackware/KDE, but if it can't be disabled I'll remove the shutdown script and let the user do it the old way.

mfoley 02-05-2018 05:45 PM

The message I get is, "KDE Workspace / Logout canceled by '/opt/VirtualBox/VirtualBox'

mfoley 02-05-2018 08:34 PM

I've done more searching on this. There are DOZENS of posts on the Internet about this issue -- none of them have resolutions. In addition to VirtualBox, other packages exhibiting this phenomenon that I've come across are ckb, seafile, smplayer, Steam, Viber; with distros: Kubuntu, Archlinux, Manjaro.

So, this appears to be a KDE issue, not necessarily related to VirtualBox or Slackware.

Do any KDE experts know how to turn this off? So far, none of the above listed reports have a solution, so maybe we just have to live with it.

Aeterna 02-06-2018 10:42 AM

Quote:

Originally Posted by mfoley (Post 5816246)
I've done more searching on this. There are DOZENS of posts on the Internet about this issue -- none of them have resolutions. In addition to VirtualBox, other packages exhibiting this phenomenon that I've come across are ckb, seafile, smplayer, Steam, Viber; with distros: Kubuntu, Archlinux, Manjaro.

So, this appears to be a KDE issue, not necessarily related to VirtualBox or Slackware.

Do any KDE experts know how to turn this off? So far, none of the above listed reports have a solution, so maybe we just have to live with it.

I don't think that there is anything wrong with KDE and Virtualbox (I don't know about other software).
If you logout then any user running sessions - including vb - will be shut down. Because vb is running whatever os guest then logging out will in fact kill running os in unclean manner assuming that guest os is running some applications.

While you can lock user (crtl+alt+L) and switch user with running vb, logging out/killing guest os is not the best idea.

I would think that vb is not the best idea for your multiuser setup.

mfoley 02-07-2018 08:42 AM

Aeterna - As mentioned, I do have a KDE shutdown script that works fine to shutdown the VM when a user logs out. What I want is for after that script runs, the logout process to complete and go ahead and log the user out. Instead, the VM is shutdown via the script, but the user gets the message "KDE Workspace / Logout canceled by '/opt/VirtualBox/VirtualBox'" and the user has to Leave/Logout again.

I don't know if this is a KDE thing or a VirtualBox thing. As mentioned in my post #5, lots of other programs exhibit this phenomenon with KDE on platforms other than Slackware. That leads me to believe there is something KDE related. On the other hand the message says, "canceled by ...VirtualBox", and other programs (Thunderbird, LibreOffice, Firefox) don't exhibit this behavior, they just stop; so perhaps it is an issue with VirtualBox. I've submitted a bug report to VirtualBox: https://www.virtualbox.org/ticket/17528 which is actually a re-open request for a bug report on this going back 4 years ago. We'll see if there is any response.

Didier Spaier 02-08-2018 06:51 AM

To make sure that the problem doesn't come from your script please post it and tell us how it runs, in other words what modifications you made so that it runs when the user logs out.

This will also allow us to try to reproduce this behavior, thus confirming the issue.

mfoley 02-08-2018 12:24 PM

in ~/.kde/shutdown/shutdown:
Code:

#!/bin/bash

LOGFILE=$HOME/logfiles
if [ ! -e $LOGFILE ]; then mkdir $LOGFILE; fi
LOGFILE=$LOGFILE/shutdownVM.log

echo Shutting down VMs

if [ "$1" = "shutdown" ]
then
    mode="acpipowerbutton"
    shift
else
    mode="savestate"
fi

if [ $USER != root ]
then
    VM=`/usr/bin/VBoxManage list runningvms`
    VM=`echo $VM | awk '{print $1}' | tr -d "\""`

    if [ -n "$VM" ]
    then
        echo `date "+%Y-%m-%d %H:%M:%S"` Shutting down \($mode\) VirtualMachine $VM for user $USER >> $LOGFILE
        /usr/bin/VBoxManage controlvm $VM $mode
    fi

    exit 0
fi


Didier Spaier 02-08-2018 05:04 PM

I could reproduce this behavior but sorry, no clue.

Incidentally, unless I miss something this script is run by KDE itself without arguments, so $1 being not set mode is always set to powerstate.

mfoley 02-08-2018 09:43 PM

Quote:

Originally Posted by Didier Spaier (Post 5817526)
Incidentally, unless I miss something this script is run by KDE itself without arguments, so $1 being not set mode is always set to powerstate.

That is correct. The default is to save the state of the VM. I also have an Autostart script that starts to VM when the user logs in. This shutdown script can also be run manually from the command line by any user, so there is the option to do a VM shutdown if desired.

What's interesting is that if I shutdown the VM manually from the VM, then logoff there is no such problem, so there must be some communication between VM and KDE to prevent the logout even after a successful ~/.kde/shutdown script. I've tried putting a long sleep in the script after VM shutdown, but that didn't help.

Thanks for your extra effort. So far no responses on the VirtualBox ticket. It's probably not a high priority for them. :(

Ian M 02-09-2018 12:17 PM

I don't know if this will work or if it's a good idea but you can logout of KDE using the command
Code:

kquitapp ksmserver
so you could try adding that to your shutdown script after the VM has been shutdown, maybe that will force a logout. If you google "KDE logout command" there's other ways to do it if that doesn't work.

mfoley 02-09-2018 08:43 PM

Ian M: good idea, but it didn't work. I'll check out your search suggestion.


All times are GMT -5. The time now is 01:07 AM.