mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-18 11:47:30 +00:00
Misc: lifemngr-daemon-on-UOS for windows
For cross-VM S5 notify via vUART, life_mngr service is running on UOS. It is listening on COM2 to get SOS's commands. The protocol is: SOS send "shutdown", UOS feedback "acked". When SOS triggle shutdown, SOS can 1) check VM's status until UOS stopped, 2) retry shutdown UOS normally with timeout. So, no matter life_mngr server is running, SOS's shutdown procedure will properly finish. Tracked-On: #3564 Signed-off-by: Yuan Liu <yuan1.liu@intel.com>
This commit is contained in:
parent
82a0d39e84
commit
73b8c91e06
@ -4,9 +4,9 @@ RELEASE ?= 0
|
||||
|
||||
.PHONY: all acrn-crashlog acrnlog acrn-manager acrntrace acrnbridge life_mngr
|
||||
ifeq ($(RELEASE),0)
|
||||
all: acrn-crashlog acrnlog acrn-manager acrntrace acrnbridge life_mngr
|
||||
all: acrn-crashlog acrnlog acrn-manager acrntrace acrnbridge
|
||||
else
|
||||
all: acrn-manager acrnbridge life_mngr
|
||||
all: acrn-manager acrnbridge
|
||||
endif
|
||||
|
||||
acrn-crashlog:
|
||||
|
240
misc/life_mngr/COPYING.MinGW-w64-runtime.txt
Normal file
240
misc/life_mngr/COPYING.MinGW-w64-runtime.txt
Normal file
@ -0,0 +1,240 @@
|
||||
MinGW-w64 runtime licensing
|
||||
***************************
|
||||
|
||||
This program or library was built using MinGW-w64 and statically
|
||||
linked against the MinGW-w64 runtime. Some parts of the runtime
|
||||
are under licenses which require that the copyright and license
|
||||
notices are included when distributing the code in binary form.
|
||||
These notices are listed below.
|
||||
|
||||
|
||||
========================
|
||||
Overall copyright notice
|
||||
========================
|
||||
|
||||
Copyright (c) 2009, 2010, 2011, 2012, 2013 by the mingw-w64 project
|
||||
|
||||
This license has been certified as open source. It has also been designated
|
||||
as GPL compatible by the Free Software Foundation (FSF).
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions in source code must retain the accompanying copyright
|
||||
notice, this list of conditions, and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the accompanying
|
||||
copyright notice, this list of conditions, and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. Names of the copyright holders must not be used to endorse or promote
|
||||
products derived from this software without prior written permission
|
||||
from the copyright holders.
|
||||
4. The right to distribute this software or to use it for any purpose does
|
||||
not give you the right to use Servicemarks (sm) or Trademarks (tm) of
|
||||
the copyright holders. Use of them is covered by separate agreement
|
||||
with the copyright holders.
|
||||
5. If any files are modified, you must cause the modified files to carry
|
||||
prominent notices stating that you changed the files and the date of
|
||||
any change.
|
||||
|
||||
Disclaimer
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
========================================
|
||||
getopt, getopt_long, and getop_long_only
|
||||
========================================
|
||||
|
||||
Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
Sponsored in part by the Defense Advanced Research Projects
|
||||
Agency (DARPA) and Air Force Research Laboratory, Air Force
|
||||
Materiel Command, USAF, under agreement number F39502-99-1-0512.
|
||||
|
||||
* * * * * * *
|
||||
|
||||
Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
All rights reserved.
|
||||
|
||||
This code is derived from software contributed to The NetBSD Foundation
|
||||
by Dieter Baron and Thomas Klausner.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
|
||||
===============================================================
|
||||
gdtoa: Converting between IEEE floating point numbers and ASCII
|
||||
===============================================================
|
||||
|
||||
The author of this software is David M. Gay.
|
||||
|
||||
Copyright (C) 1997, 1998, 1999, 2000, 2001 by Lucent Technologies
|
||||
All Rights Reserved
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and
|
||||
its documentation for any purpose and without fee is hereby
|
||||
granted, provided that the above copyright notice appear in all
|
||||
copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of Lucent or any of its entities
|
||||
not be used in advertising or publicity pertaining to
|
||||
distribution of the software without specific, written prior
|
||||
permission.
|
||||
|
||||
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
|
||||
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
||||
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||
THIS SOFTWARE.
|
||||
|
||||
* * * * * * *
|
||||
|
||||
The author of this software is David M. Gay.
|
||||
|
||||
Copyright (C) 2005 by David M. Gay
|
||||
All Rights Reserved
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted,
|
||||
provided that the above copyright notice appear in all copies and that
|
||||
both that the copyright notice and this permission notice and warranty
|
||||
disclaimer appear in supporting documentation, and that the name of
|
||||
the author or any of his current or former employers not be used in
|
||||
advertising or publicity pertaining to distribution of the software
|
||||
without specific, written prior permission.
|
||||
|
||||
THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
|
||||
NO EVENT SHALL THE AUTHOR OR ANY OF HIS CURRENT OR FORMER EMPLOYERS BE
|
||||
LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
|
||||
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
||||
SOFTWARE.
|
||||
|
||||
* * * * * * *
|
||||
|
||||
The author of this software is David M. Gay.
|
||||
|
||||
Copyright (C) 2004 by David M. Gay.
|
||||
All Rights Reserved
|
||||
Based on material in the rest of /netlib/fp/gdota.tar.gz,
|
||||
which is copyright (C) 1998, 2000 by Lucent Technologies.
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and
|
||||
its documentation for any purpose and without fee is hereby
|
||||
granted, provided that the above copyright notice appear in all
|
||||
copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of Lucent or any of its entities
|
||||
not be used in advertising or publicity pertaining to
|
||||
distribution of the software without specific, written prior
|
||||
permission.
|
||||
|
||||
LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
||||
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
||||
IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
|
||||
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
|
||||
IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||
THIS SOFTWARE.
|
||||
|
||||
|
||||
=========================
|
||||
Parts of the math library
|
||||
=========================
|
||||
|
||||
Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
|
||||
Developed at SunSoft, a Sun Microsystems, Inc. business.
|
||||
Permission to use, copy, modify, and distribute this
|
||||
software is freely granted, provided that this notice
|
||||
is preserved.
|
||||
|
||||
* * * * * * *
|
||||
|
||||
Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
|
||||
Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
Permission to use, copy, modify, and distribute this
|
||||
software is freely granted, provided that this notice
|
||||
is preserved.
|
||||
|
||||
* * * * * * *
|
||||
|
||||
FIXME: Cephes math lib
|
||||
Copyright (C) 1984-1998 Stephen L. Moshier
|
||||
|
||||
It sounds vague, but as to be found at
|
||||
<http://lists.debian.org/debian-legal/2004/12/msg00295.html>, it gives an
|
||||
impression that the author could be willing to give an explicit
|
||||
permission to distribute those files e.g. under a BSD style license. So
|
||||
probably there is no problem here, although it could be good to get a
|
||||
permission from the author and then add a license into the Cephes files
|
||||
in MinGW runtime. At least on follow-up it is marked that debian sees the
|
||||
version a-like BSD one. As MinGW.org (where those cephes parts are coming
|
||||
from) distributes them now over 6 years, it should be fine.
|
||||
|
||||
===================================
|
||||
Headers and IDLs imported from Wine
|
||||
===================================
|
||||
|
||||
Some header and IDL files were imported from the Wine project. These files
|
||||
are prominent maked in source. Their copyright belongs to contributors and
|
||||
they are distributed under LGPL license.
|
||||
|
||||
Disclaimer
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
@ -40,6 +40,9 @@ all:
|
||||
$(CC) -g life_mngr.c -o $(OUT_DIR)/life_mngr -lpthread $(LIFEMNGR_CFLAGS) $(LIFEMNGR_LDFLAGS)
|
||||
cp life_mngr.service $(OUT_DIR)/life_mngr.service
|
||||
|
||||
-x86_64-w64-mingw32-gcc -g life_mngr_win.c -o $(OUT_DIR)/life_mngr_win.exe -Wall -O2 $(LDFLAGS)
|
||||
cp COPYING.MinGW-w64-runtime.txt $(OUT_DIR)/COPYING.MinGW-w64-runtime.txt
|
||||
|
||||
clean:
|
||||
rm -f $(OUT_DIR)/life_mngr
|
||||
ifneq ($(OUT_DIR),.)
|
||||
|
82
misc/life_mngr/life_mngr_win.c
Normal file
82
misc/life_mngr/life_mngr_win.c
Normal file
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (C)2019 Intel Corporation
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#define SOS_REQ "shutdown"
|
||||
#define UOS_ACK "acked"
|
||||
#define BUFF_SIZE 16U
|
||||
#define MSG_SIZE 8U
|
||||
|
||||
HANDLE initCom(const char *szStr)
|
||||
{
|
||||
HANDLE hCom = CreateFile(szStr,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
0,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
0,
|
||||
NULL);
|
||||
|
||||
if (hCom == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
printf("open %s failed!\n", szStr);
|
||||
return hCom;
|
||||
}
|
||||
|
||||
printf("open %s successed!\n", szStr);
|
||||
SetupComm(hCom, 1024, 1024);
|
||||
|
||||
COMMTIMEOUTS TimeOuts;
|
||||
TimeOuts.ReadIntervalTimeout = 100; /* Maximum time between read chars. */
|
||||
TimeOuts.ReadTotalTimeoutMultiplier = 5000; /* Multiplier of characters. */
|
||||
TimeOuts.ReadTotalTimeoutConstant = 5000; /* Constant in milliseconds. */
|
||||
TimeOuts.WriteTotalTimeoutMultiplier = 500; /* Multiplier of characters. */
|
||||
TimeOuts.WriteTotalTimeoutConstant = 2000; /* Constant in milliseconds. */
|
||||
SetCommTimeouts(hCom, &TimeOuts);
|
||||
|
||||
DCB dcb;
|
||||
GetCommState(hCom, &dcb);
|
||||
dcb.BaudRate = 115200;
|
||||
dcb.ByteSize = 8;
|
||||
dcb.Parity = NOPARITY;
|
||||
dcb.StopBits = ONESTOPBIT;
|
||||
SetCommState(hCom, &dcb);
|
||||
|
||||
return hCom;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
DWORD recvsize = 0;
|
||||
char recvbuf[BUFF_SIZE];
|
||||
|
||||
HANDLE hCom = initCom("COM2");
|
||||
if (hCom == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
do {
|
||||
memset(recvbuf, 0, sizeof(recvbuf));
|
||||
ReadFile(hCom, recvbuf, sizeof(recvbuf), &recvsize, NULL);
|
||||
if (recvsize < MSG_SIZE)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strncmp(recvbuf, SOS_REQ, MSG_SIZE) == 0)
|
||||
{
|
||||
WriteFile(hCom, UOS_ACK, sizeof(UOS_ACK), NULL, NULL);
|
||||
system("shutdown -s -t 0");
|
||||
break;
|
||||
}
|
||||
} while (1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user