Sebastian Arcus wrote on 03/04/2018 09:57 AM: > > On 03/03/18 01:36, Donald R Laster Jr wrote: >> Sebastian, >> >> Could you be dealing with a locked screen where the first reboot command >> is sending a "ctl-alt-del" that unlocks the screen and the second reboot >> command send a second "ctl-alt-del" that is actually telling Windows-10 to >> reboot? >> >> One way that might be useful to see if that is the case is to connect to >> the Windows 10 console and then send the reboot commands. You could see if >> the reboot command is doing someone on the console screen. > > Thank you Don. I've done more testing and I am slightly more confused, > although I think I am making progress: > > 1. If I am on on the login screen (through vnc or rdp) or already logged in, > both shutdown and reboot commands work > 2. If I have logged in, but then locked the screen, neither shutdown nor > reboot work, no matter how many times I send them. > > It is starting to sound like a Windows specific problem, so I will get back > to researching whatever registry settings might be available. > > Thanks again for the suggestions >
Sebastian, From what you are describing check what the shutdown and reboot command are trying to do. If they are trying to send a "ctl-alt-del" sequence and the screen is locked I would expect Windows to basically ignore them. I would try this: 1) On the VNC screen do a "ctrl-shift-alt-2" and get to the QEMU command screen. 2) Then enter the command "system_powerdown" to see if the system does a shutdown. I am running a older version of qemuu but the command screen should be basically the same. The sequence "ctrl-shift-alt-1" should put you back on the Windows-10 console screen. The attached script rc.vms is something I wrote to start and stop virtual machines on my Slackware Linux system. It uses the qmp port to send commands to qemu. It might help. When I start the VMs on the systems running VMs I have the command argument: -qmp unix:/tmp/.qemu_control_XXXXX,server,nowait added, where XXXXX is a port number. The rc.vms script uses this to talk to the qemu command interface. The file /etc/virtual_machines/qemu_vm.conf contains command to start the VMs. The commands in the file are like this: /vms/Network/DNS_Server_1/VM_Start.sh sleep 60 /opt/laster/sbin/listvms sleep 10 The attached script listvms is used to list the VMs that are running. The scripts VM_Start.sh are used to configure and start the VMs. I also use the QMP command. Don -- ============================================================== Donald R. Laster Jr. 25 Heidl Ave West Long Branch, NJ 07764 Email : las...@dlaster.com donaldrlaste...@gmail.com (Cell) Phone : (732) 263-9235 (Home Evening) (732) 263-9236 (Home Office) (978) 392-8860 x4925 (Corp Apt) (732) 539-5658 (Cell) (732) 263-9280 (Fax) -------------------------------------------------------------- Nearly all men can stand adversity, but if you want to test a man's character, give him power. -- Abraham Lincoln ==============================================================
#!/bin/sh ############################################################################### # # # rc.vms R00-02.00 # # # # =========================================================================== # # # # Purpose: # # # # This script is used to start and stop Virtual Machines. # # # # =========================================================================== # # # # Arguments: # # # # # # =========================================================================== # # # # Programming Notes: # # # # This script expects that the configuration contains at least a -qmp # # option on the command line that started the Virtual Machine session. # # # # =========================================================================== # # # # Revision: # # # # Revision Who When Why # # ========= =========== =========== ====================================== # # R00-00.00 DRLJr/I-AS 09/May/2013 Script created # # R00-01.00 DRLJr/I-AS 10/May/2013 Reworked to use ps and look at the # # command line of the process for a -qmp # # option to do a controlled power based # # shutdown. Added use of start-up # # configuration file to start the VMs # # via /etc/virtual_machines so the # # script does not have to change. # # R00-02.00 DRLJr/I-AS 02/May/2014 Echo command being run, except for the # # sleep commands (sleep, /bin/sleep, # # or /usr/bin/sleep). # # # ############################################################################### #=============================================================================# # # #=============================================================================# get_field() { OFF=$1 if [ ${OFF} -le $# ] ; then shift ${OFF} ANS="$1" else ANS="" fi echo "${ANS}" return 0 } #=============================================================================# # Insure all leading blanks are eliminated # #=============================================================================# strip_blanks() { CMD="$*" echo "${CMD}" return 0 } #=============================================================================# # Extract the Associated QEMU Pipe Name itself # #=============================================================================# vms_extract_field() { echo "$2" return 0 } #=============================================================================# # Extract the Process Ids # #=============================================================================# vms_extract_pids() { WPIDS="" # for pid in $* ; do while ( true ) do if [ "$1" = "" ] ; then break fi WPIDS="${WPIDS} $1" shift 2 done echo "${WPIDS}" return 0 } #=============================================================================# # Read a Configuration File # #=============================================================================# start_vms_config_file() { while ( true ) do read COMMAND EOF=$? if [ ${EOF} -ne 0 ] ; then break fi COMMAND="`strip_blanks ${COMMAND}`" COMMENT="${COMMAND:0:1}" if [ "${COMMENT}" != "#" -a "${COMMENT}" != "" ] ; then # Not a Command echo "Executing Command: ${COMMAND}" ${COMMAND} fi done return 0 } #=============================================================================# # Start a Virtual Machine Session # #=============================================================================# start_vms() { echo "Removing any left-over Virtual Machine access point files." echo " " rm -f /tmp/.qemu_control_* CFG_FILES="`ls ${VM_CDIR}/*.conf`" for file in ${CFG_FILES} ; do echo " " echo "Processing ${file}" echo " " start_vms_config_file < ${file} done return 0 } #=============================================================================# # Extract the Associated QEMU Pipe (-qmp argument) # #=============================================================================# vms_extract_qemu_pipe() { PIPENAME="none" STATUS=1 while ( true ) do if [ "$1" = "" ] ; then break fi if [ "$1" = "-qmp" ] ; then PIPENAME="$2" IFSSV="${IFS}" IFS=":," PIPENAME=`vms_extract_field $2` IFS="${IFSSV}" STATUS=0 break fi shift 1 done echo "${PIPENAME}" return ${STATUS} } #=============================================================================# # $1=PIPE $2=QPID [ $3=QFNAM ] # #=============================================================================# stop_one_qemu_vm() { echo "Shutting down QEMU Virtual Machine $2 (Access Pipe $1)" # echo "QEMU PIPE = $1" # echo "QEMU PID = $2" # echo "QEMU FNAM = $3" if [ "$1" = "none" ] ; then echo " Killing Virtual Machine $2 with PWR (no -qmp control socket)" kill -PWR $2 STATUS=2 else echo "system_powerdown" | /usr/local/sbin/QMP/qmp-shell $1 > /dev/null EOT=$? if [ ${EOT} != 0 ] ; then echo " Unable to communicate with QEMU Virtual Machine $2 to do shutdown." echo " Killing Virtual Machine $2 with PWR (no -qmp control socket)" kill -PWR $2 STATUS=1 fi fi for try in 10 10 20 20 30 30 30 30 30 30 30 30 30 kill ; do RPID=`ps -e -o pid | grep "^ *$2"` RPID="${RPID/ /}" if [ "${RPID}" != "" -a "${try}" != "kill" ] ; then echo " Waiting for ${try} seconds for Virtual Machine $2 shutdown" sleep ${try} else if [ "${try}" = "kill" ] ; then echo " Killing Virtual Machine $2 with PWR" kill -PWR $2 fi echo " Virtual Machine $2 is shutdown " rm -f $1 if [ "$3" != "" ] ; then rm -f $3 else rm -f $1,* fi STATUS=0 break fi done # Remove the acess files regardless rm -f $1 if [ "$3" != "" ] ; then rm -f $3 else rm -f $1,* fi return ${STATUS} } #=============================================================================# # Get the information for the QEMU Virtual Machines # #=============================================================================# stop_qemu_vms() { QEMUS=`ps -e -o pid,comm | grep qemu` QPIDS=`vms_extract_pids ${QEMUS}` for pid in ${QPIDS} ; do QPSINFO=`ps -p ${pid} -o pid,args --no-headers ` # echo " " # echo "QPSINFO=${QPSINFO}" # echo " " PIPE=`vms_extract_qemu_pipe ${QPSINFO}` STATUS=$? # echo "STATUS=${STATUS}, PIPE=${PIPE}" # echo " " stop_one_qemu_vm ${PIPE} ${pid} # echo " " done return 0 } #=============================================================================# # # #=============================================================================# stop_vms() { stop_qemu_vms return 0 } #=============================================================================# # # #=============================================================================# VM_CDIR="/etc/virtual_machines" case "$1" in 'start') start_vms ;; 'stop') stop_vms ;; *) echo "usage $0 start|stop" ;; esac ############################################################################### # # ###############################################################################
#!/bin/sh ############################################################################################## # # # listvms R00-00.01 # # # # ========================================================================================== # # # # Purpose: # # # # This script is used to list the Virtual Machines running on the system. # # # # ========================================================================================== # # # # Arguments: # # # # # # ========================================================================================== # # # # Programming Notes: # # # # # # ========================================================================================== # # # # Revision: # # # # Revision Who When Why # # ========= =========== =========== ===================================================== # # R00-00.00 DRLJr/I-AS 30/Apr/2014 Created # # R00-00.01 DRLJr/I-AS 16/May/2014 Check and insure the qemu entry is the executable. # # # ############################################################################################## #============================================================================================# # # #============================================================================================# get_data() { PSCMD="-e -o pid,args" # /bin/ps ${PSCMD} | /bin/grep qemu | /bin/grep -v grep return 0 } #============================================================================================# # # #============================================================================================# extract_data() { PID="$1" EXE="$2" shift 2 NAME="Not-Set" while ( true ) do if [ "$1" = "-name" ] ; then NAME="$2" shift 1 fi shift 1 if [ "$1" = "" ] ; then break fi done if [ "${NAME}" = "Not-Set" ] ; then echo "${EXE}" | /bin/grep -q qemu 1> /dev/null 2> /dev/null EOT=$? else EOT=0 fi if [ ${EOT} -eq 0 ] ; then PID=" ${PID}" PID="${PID: -6: 6}" echo "${PID} ${NAME}" fi return 0 } #============================================================================================# # # #============================================================================================# process_data() { if [ "${QUIET}" != "Y" ] ; then echo "Pid Name " echo "------ -------------------------------------------------------------------------" fi while ( true ) do read LINE EOF=$? if [ ${EOF} -ne 0 ] ; then break fi # echo " " # echo "Line:${LINE}" # echo " " extract_data ${LINE} done } #============================================================================================# # # #============================================================================================# if [ "$1" = "-h" -o "$1" = "--help" ] ; then echo " " echo " Usage: $0 -h | --help | -q | --quiet " echo " " echo " -h : Show this help screen " echo " --help : Show this help screen " echo " -q : Do not display header " echo " --quiet : Do not display header " echo " " EOT=0 else if [ "$1" = "-q" -o "$1" = "--quiet" ] ; then QUIET="Y" else QUIET="N" fi export QUIET if [ "${QUIET}" != "Y" ] ; then echo " " fi get_data | process_data if [ "${QUIET}" != "Y" ] ; then echo " " fi EOT=0 fi ############################################################################################## # # ##############################################################################################