misc: life_mngr: add script to do user VM shutdown
COM2 in user VM is used by acrnctl to do user VM shutdown. In this patch series, COM2 in user VM is used as uart channel device for new lifecycle manager. So acrnctl can't be used to do user VM shutdown. This patch provides a script to user to do guest shutdown in service VM. Lifecycle manager in service VM will send user VM shutdown command to user VM directly. TODO: When user VM shutdown is supported in libvirt, this script will be removed. Tracked-On: #6652 Signed-off-by: Xiangyang Wu <xiangyang.wu@intel.com> Reviewed-by: fei1.li@intel.com
This commit is contained in:
parent
d1cb1aafa0
commit
e7ed68afc8
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (C) 2021 Intel Corporation.
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
import socket
|
||||
import sys
|
||||
|
||||
class SocketClient:
|
||||
def __init__(self):
|
||||
pass
|
||||
def connect_to_server(self):
|
||||
SOKET_ADDR = '/var/lib/life_mngr/monitor.sock'
|
||||
SHUTDOWN_REQ = 'user_vm_shutdown:' + sys.argv[1]
|
||||
BUF_LEN = 1024
|
||||
|
||||
print(SHUTDOWN_REQ)
|
||||
# unix domain sockets
|
||||
server_address = SOKET_ADDR
|
||||
socket_family = socket.AF_UNIX
|
||||
socket_type = socket.SOCK_STREAM
|
||||
|
||||
sock = socket.socket(socket_family, socket_type)
|
||||
sock.connect(server_address)
|
||||
sock.sendall(SHUTDOWN_REQ.encode())
|
||||
data = sock.recv(BUF_LEN)
|
||||
print(f"Waiting for ACK message...: {data.decode()}")
|
||||
sock.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
socket_client_obj = SocketClient()
|
||||
socket_client_obj.connect_to_server()
|
Loading…
Reference in New Issue