Commit c5f7f56d authored by Kroese's avatar Kroese Committed by GitHub
Browse files

qemu

parent 9ad1676f
Loading
Loading
Loading
Loading
+2 −23
Original line number Diff line number Diff line
@@ -25,29 +25,8 @@ _graceful_shutdown(){
  echo "Received $1 signal, shutting down..."
  echo 0 > "${_QEMU_SHUTDOWN_COUNTER}"

  # Don't send the powerdown signal because vDSM ignores ACPI signals
  # echo 'system_powerdown' | nc -q 1 -w 1 localhost "${QEMU_MONPORT}">/dev/null

  # Send shutdown command to guest agent tools instead via serial port
  RESPONSE=$(curl -s -m 2 -S http://127.0.0.1:2210/write?command=6 2>&1)

  if [[ ! "${RESPONSE}" =~ "\"success\"" ]] ; then

    echo "Could not send shutdown command to guest, error: $RESPONSE"

    FILE="${IMG}/agent.ver"
    [ ! -f "$FILE" ] && echo "1" > "$FILE"
    AGENT_VERSION=$(cat "${FILE}")

    if ((AGENT_VERSION < 2)); then
      echo "Please update the agent to allow gracefull shutdowns..."
      pkill -f qemu-system-x86_64
    else
      # Send a NMI interrupt which will be detected by the kernel
      echo 'nmi' | nc -q 1 -w 1 localhost "${QEMU_MONPORT}">/dev/null
    fi

  fi
  # Send the shutdown (system_powerdown) command to the QMP monitor
  echo 'system_powerdown' | nc -q 1 -w 1 localhost "${QEMU_MONPORT}">/dev/null

  while [ "$(cat ${_QEMU_SHUTDOWN_COUNTER})" -lt "${QEMU_POWERDOWN_TIMEOUT}" ]; do