obj-y += debug_ch.o
# ecs
-obj-y += ecs.o ecs-json-streamer.o qmp_handler.o
+obj-y += ecs_msg.o ecs.o ecs-json-streamer.o qmp_handler.o
# maru hardware
include $(SRC_PATH)/tizen/src/Makefile.tizen.$(TARGET_BASE_ARCH)
#include "console.h"
#include "migration.h"
-#ifndef _WIN32
-#include <sys/epoll.h>
-#endif
-
#include "qemu-common.h"
#include "qemu_socket.h"
#include "qemu-queue.h"
#include "qemu-char.h"
#include "sdb.h"
#include "qjson.h"
-#include "ecs-json-streamer.h"
+
#include "json-parser.h"
#include "qmp-commands.h"
#include "qint.h"
#include <stdbool.h>
#include <pthread.h>
-#define OUT_BUF_SIZE 4096
-#define READ_BUF_LEN 4096
+
#define DEBUG
QLIST_ENTRY(mon_fd_t) next;
};
-struct Monitor {
- int suspend_cnt;
- uint8_t outbuf[OUT_BUF_SIZE];
- int outbuf_index;
- CPUArchState *mon_cpu;
- void *password_opaque;
- QError *error;
- QLIST_HEAD(,mon_fd_t) fds;
- QLIST_ENTRY(Monitor) entry;
-};
-
-#define MAX_EVENTS 1000
-typedef struct ECS_State {
- int listen_fd;
- int epoll_fd;
- struct epoll_event events[MAX_EVENTS];
- int is_unix;
- int ecs_running;
- QEMUTimer *alive_timer;
- Monitor *mon;
-} ECS_State;
-
-typedef struct ECS_Client {
- int client_fd;
- int client_id;
- int keep_alive;
- const char* type;
- ECS_State *cs;
- JSONMessageParser parser;
- QTAILQ_ENTRY(ECS_Client) next;
-} ECS_Client;
-
typedef struct mon_cmd_t {
const char *name;
const char *args_type;
memset(cmd, 0, 10);
strcpy(cmd, qdict_get_str(header, "cat"));
type_length length = (type_length) qdict_get_int(header, "length");
- type_group action = (type_group) (qdict_get_int(header, "action") & 0xff);
- type_action group = (type_action) (qdict_get_int(header, "group") & 0xff);
+ type_group group = (type_action) (qdict_get_int(header, "group") & 0xff);
+ type_action action = (type_group) (qdict_get_int(header, "action") & 0xff);
+
// get data
const char* data = qdict_get_str(qobject_to_qdict(obj), COMMANDS_DATA);
static bool control_command_proc(ECS_Client *clii, QObject *obj)
{
+ int64_t control_type = qdict_get_int(qobject_to_qdict(obj), "control_type");
+
+ QDict* data = qdict_get_qdict(qobject_to_qdict(obj), "data");
+
+ if (control_type == CONTROL_COMMAND_HOST_KEYBOARD_ONOFF_REQ)
+ {
+ control_host_keyboard_onoff_req(clii, data);
+ }
+ else if (control_type == CONTROL_COMMAND_SCREENSHOT_REQ)
+ {
+
+ }
+ //LOG(">> control : feature = %s, action=%d, data=%s", feature, action, data);
+
return true;
}
type_name = qdict_get_str(qobject_to_qdict(obj), COMMANDS_TYPE);
- if (!strcmp(type_name, TYPE_DATA_SELF)) {
- LOG("set client fd %d keep alive 0", clii->client_fd);
- clii->keep_alive = 0;
- return;
- }
-
+ /*
def_data = check_key(obj, COMMANDS_DATA);
if (0 > def_data) {
LOG("json format error: data.");
LOG("data key is not found.");
return;
}
+ */
-
- if (!strcmp(type_name, COMMAND_TYPE_INJECTOR)) {
+ if (!strcmp(type_name, TYPE_DATA_SELF)) {
+ LOG("set client fd %d keep alive 0", clii->client_fd);
+ clii->keep_alive = 0;
+ return;
+ }
+ else if (!strcmp(type_name, COMMAND_TYPE_INJECTOR)) {
injector_command_proc(clii, obj);
}
else if (!strcmp(type_name, COMMAND_TYPE_CONTROL)) {
else if (!strcmp(type_name, COMMAND_TYPE_MONITOR)) {
handle_qmp_command(clii, type_name, get_data_object(obj));
}
+ else if (!strcmp(type_name, ECS_MSG_STARTINFO_REQ)){
+ ecs_startinfo_req(clii);
+ }
+ else
+ {
+ LOG("handler not found");
+ }
}
static Monitor *monitor_create(void)
#ifndef __ECS_H__
#define __ECS_H__
+#ifndef _WIN32
+#include <sys/epoll.h>
+#endif
+
#include "qemu-common.h"
+#include "ecs-json-streamer.h"
#define ECS_DEBUG 1
#define COMMAND_TYPE_CONTROL "control"
#define COMMAND_TYPE_MONITOR "monitor"
+#define ECS_MSG_STARTINFO_REQ "startinfo_req"
+#define ECS_MSG_STARTINFO_ANS "startinfo_ans"
+
+
#define TIMER_ALIVE_S 60
#define TYPE_DATA_SELF "self"
typedef unsigned char type_group;
typedef unsigned char type_action;
+#define OUT_BUF_SIZE 4096
+#define READ_BUF_LEN 4096
+
+
+struct Monitor {
+ int suspend_cnt;
+ uint8_t outbuf[OUT_BUF_SIZE];
+ int outbuf_index;
+ CPUArchState *mon_cpu;
+ void *password_opaque;
+ QError *error;
+ QLIST_HEAD(,mon_fd_t) fds;
+ QLIST_ENTRY(Monitor) entry;
+};
+
+#define MAX_EVENTS 1000
+typedef struct ECS_State {
+ int listen_fd;
+ int epoll_fd;
+ struct epoll_event events[MAX_EVENTS];
+ int is_unix;
+ int ecs_running;
+ QEMUTimer *alive_timer;
+ Monitor *mon;
+} ECS_State;
+
+typedef struct ECS_Client {
+ int client_fd;
+ int client_id;
+ int keep_alive;
+ const char* type;
+ ECS_State *cs;
+ JSONMessageParser parser;
+ QTAILQ_ENTRY(ECS_Client) next;
+} ECS_Client;
+
int start_ecs(void);
int stop_ecs(void);
void read_val_char(const char* data, unsigned char* ret_val);
void read_val_str(const char* data, char* ret_val, int len);
+
+
+enum{
+ CONTROL_COMMAND_HOST_KEYBOARD_ONOFF_REQ = 1,
+ CONTROL_COMMAND_SCREENSHOT_REQ = 2
+};
+
+// messages
+void ecs_startinfo_req(ECS_Client *clii);
+void control_host_keyboard_onoff_req(ECS_Client *clii, QDict* data);
+
#endif /* __ECS_H__ */
--- /dev/null
+\r
+#include "hw/qdev.h"\r
+#include "net.h"\r
+#include "console.h"\r
+#include "migration.h"\r
+\r
+#ifndef _WIN32\r
+#include <sys/epoll.h>\r
+#endif\r
+\r
+#include "qemu-common.h"\r
+#include "qemu_socket.h"\r
+#include "qemu-queue.h"\r
+#include "qemu-option.h"\r
+#include "main-loop.h"\r
+#include "ui/qemu-spice.h"\r
+#include "qemu-char.h"\r
+#include "sdb.h"\r
+#include "qjson.h"\r
+#include "ecs-json-streamer.h"\r
+#include "json-parser.h"\r
+#include "qmp-commands.h"\r
+#include "qint.h"\r
+#include "qbool.h"\r
+#include "ecs.h"\r
+#include "hw/maru_virtio_evdi.h"\r
+#include "skin/maruskin_operation.h"\r
+#include <stdbool.h>\r
+#include <pthread.h>\r
+\r
+\r
+void ecs_startinfo_req(ECS_Client *clii)\r
+{\r
+ LOG("ecs_startinfo_req");\r
+\r
+ int usbkbd_status = mloop_evcmd_get_hostkbd_status();\r
+\r
+ LOG("usbkbd_status = %d", usbkbd_status);\r
+\r
+\r
+\r
+ QDict* objData = qdict_new();\r
+ qdict_put(objData, "host_keyboard_onoff", qint_from_int((int64_t )usbkbd_status));\r
+\r
+ QDict* objMsg = qdict_new();\r
+ qobject_incref(QOBJECT(objData));\r
+\r
+ qdict_put(objMsg, "type", qstring_from_str(ECS_MSG_STARTINFO_ANS));\r
+ qdict_put(objMsg, "result", qstring_from_str("success"));\r
+ qdict_put(objMsg, "data", objData);\r
+\r
+ QString *json;\r
+ json = qobject_to_json(QOBJECT(objMsg));\r
+\r
+ assert(json != NULL);\r
+\r
+ qstring_append_chr(json, '\n');\r
+ const char* snddata = qstring_get_str(json);\r
+\r
+ LOG("<< startinfo json str = %s", snddata);\r
+\r
+ send_to_client(clii->client_fd, snddata);\r
+\r
+ QDECREF(json);\r
+ QDECREF(objData);\r
+ QDECREF(objMsg);\r
+}\r
+\r
+void control_host_keyboard_onoff_req(ECS_Client *clii, QDict* data)\r
+{\r
+ int64_t is_on = qdict_get_int(data, "is_on");\r
+ onoff_host_kbd(is_on);\r
+}\r
+\r
+void host_keyboard_onoff_ntf(int is_on)\r
+{\r
+ QDict* objMsg = qdict_new();\r
+\r
+ qdict_put(objMsg, "type", qstring_from_str("host_keyboard_onoff_ntf"));\r
+ qdict_put(objMsg, "ison", qbool_from_int((int64_t)is_on));\r
+\r
+ QString *json;\r
+ json = qobject_to_json(QOBJECT(objMsg));\r
+\r
+ assert(json != NULL);\r
+\r
+ qstring_append_chr(json, '\n');\r
+ const char* snddata = qstring_get_str(json);\r
+\r
+ LOG("<< json str = %s", snddata);\r
+\r
+ send_to_all_client(snddata, strlen(snddata));\r
+\r
+ QDECREF(json);\r
+\r
+ QDECREF(objMsg);\r
+}\r
memcpy(elem.in_sg[0].iov_base, &msginfo->info, sizeof(struct msg_info));\r
\r
//INFO(">> send to guest count = %d, use = %d, msg = %s, iov_len = %d \n",\r
- ++g_cnt, msginfo->info.use, msginfo->info.buf, elem.in_sg[0].iov_len);\r
+ // ++g_cnt, msginfo->info.use, msginfo->info.buf, elem.in_sg[0].iov_len);\r
\r
virtqueue_push(vio_evdi->rvq, &elem, sizeof(msg_info));\r
virtio_notify(&vio_evdi->vdev, vio_evdi->rvq);\r