mirror of
https://dev.lirent.ru/Vatrog/vm-control-io.git
synced 2026-06-18 03:46:36 +03:00
vmctl: input-control library over QMP and Linux uinput
QMP client and driver, Linux uinput driver, keymap, open/power helpers, public header, and CMake build.
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
/* power.c — QMP power/lifecycle actuation. This plane is orthogonal to the
|
||||
* input driver and always rides the shared QMP channel; every entry returns -1
|
||||
* when there is no connection. */
|
||||
|
||||
#include "driver.h"
|
||||
|
||||
/* QMP responses are small; a stack buffer suffices. */
|
||||
static int qmp_simple(vmctl_t* v, const char* cmd) {
|
||||
if (!v->qmp) return -1;
|
||||
char resp[1024];
|
||||
return qmp_exec(v->qmp, cmd, resp, sizeof resp);
|
||||
}
|
||||
|
||||
int vmctl_powerdown(vmctl_t* v) { return qmp_simple(v, "{\"execute\":\"system_powerdown\"}"); }
|
||||
int vmctl_reset (vmctl_t* v) { return qmp_simple(v, "{\"execute\":\"system_reset\"}"); }
|
||||
int vmctl_wakeup (vmctl_t* v) { return qmp_simple(v, "{\"execute\":\"system_wakeup\"}"); }
|
||||
int vmctl_pause (vmctl_t* v) { return qmp_simple(v, "{\"execute\":\"stop\"}"); }
|
||||
int vmctl_resume (vmctl_t* v) { return qmp_simple(v, "{\"execute\":\"cont\"}"); }
|
||||
Reference in New Issue
Block a user