From: SeokYeon Hwang Date: Sat, 1 Aug 2015 12:13:43 +0000 (+0900) Subject: emulator: introduced new error report architecture X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.2~40^2~234 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8e547ca36a210df0f8c6224e97333751b1526fa7;p=sdk%2Femulator%2Fqemu.git emulator: introduced new error report architecture User can see all errors reported by error_report(). Removed most emulator specified codes. Renamed some source files. Removed redudant header includes. Change-Id: I61f92f4e32763eaa1e3ed20c77259dd8b034d497 Signed-off-by: SeokYeon Hwang --- diff --git a/accel.c b/accel.c index 63e15f8e01..f384c697a8 100644 --- a/accel.c +++ b/accel.c @@ -34,10 +34,7 @@ #include "qom/object.h" #include "hw/boards.h" #include "sysemu/hax.h" - -#ifdef CONFIG_MARU -#include "tizen/src/util/maru_err_table.h" -#endif +#include "qemu/error-report.h" int tcg_tb_size; static bool tcg_allowed = true; @@ -124,11 +121,10 @@ int configure_accelerator(MachineState *ms) if (!accel_initialised) { if (!init_failed) { - fprintf(stderr, "No accelerator found!\n"); +// CONFIG_MARU MODIFICATION +// fprintf(stderr, "No accelerator found!\n"); + error_report("No accelerator found!\n"); } -#ifdef CONFIG_MARU - maru_register_exit_msg(MARU_EXIT_UNKNOWN, NO_ACCELERATOR_FOUND); -#endif exit(1); } diff --git a/blockdev.c b/blockdev.c index db8c7acd65..f4b83015fc 100644 --- a/blockdev.c +++ b/blockdev.c @@ -48,7 +48,7 @@ #include "sysemu/arch_init.h" #ifdef CONFIG_MARU -#include "tizen/src/util/maru_err_table.h" +#include "tizen/src/util/exported_strings.h" #endif static const char *const if_name[IF_COUNT] = { @@ -556,16 +556,6 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, assert(bs == blk_bs(blk)); if (ret < 0) { -#ifdef CONFIG_MARU - char *path = get_canonical_path(file); - char *msg = g_strdup_printf("%s%s%s", FAILED_TO_LOAD_DISK, CHECK_FILE_VALID, path); - - start_simple_client(msg); - - g_free(path); - g_free(msg); -#endif - error_setg(errp, "could not open disk image %s: %s", file ?: blk_name(blk), error_get_pretty(error)); error_free(error); diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c index 99cddf1e5f..abb190b209 100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@ -21,10 +21,6 @@ #include "virtio-9p-coth.h" #include "hw/virtio/virtio-access.h" -#ifdef CONFIG_MARU -#include "tizen/src/util/maru_err_table.h" -#endif - static uint32_t virtio_9p_get_features(VirtIODevice *vdev, uint32_t features) { features |= 1 << VIRTIO_9P_MOUNT_TAG; @@ -107,13 +103,6 @@ static void virtio_9p_device_realize(DeviceState *dev, Error **errp) if (s->ops->init(&s->ctx) < 0) { error_setg(errp, "Virtio-9p Failed to initialize fs-driver with id:%s" " and export path:%s", s->fsconf.fsdev_id, s->ctx.fs_root); -#ifdef CONFIG_MARU - gchar *canonical_path = get_canonical_path(s->ctx.fs_root); - maru_register_exit_msg(MARU_EXIT_UNKNOWN, - "Virtio-9p Failed to initialize fs-driver with id: %s" - " and export path: %s", s->fsconf.fsdev_id, canonical_path); - g_free(canonical_path); -#endif goto out; } if (v9fs_init_worker_threads() < 0) { @@ -141,21 +130,9 @@ static void virtio_9p_device_realize(DeviceState *dev, Error **errp) } if (s->ops->lstat(&s->ctx, &path, &stat)) { error_setg(errp, "share path %s does not exist", fse->path); -#ifdef CONFIG_MARU - gchar *canonical_path = get_canonical_path(fse->path); - maru_register_exit_msg(MARU_EXIT_UNKNOWN, - "share path %s does not exist", canonical_path); - g_free(canonical_path); -#endif goto out; } else if (!S_ISDIR(stat.st_mode)) { error_setg(errp, "share path %s is not a directory", fse->path); -#ifdef CONFIG_MARU - gchar *canonical_path = get_canonical_path(fse->path); - maru_register_exit_msg(MARU_EXIT_UNKNOWN, - "share path %s is not a directory", canonical_path); - g_free(canonical_path); -#endif goto out; } diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 6e83a17d30..eb57d6f055 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -63,9 +63,6 @@ #include "qapi/visitor.h" #include "qapi-visit.h" -#ifdef CONFIG_MARU -#include "tizen/src/util/maru_err_table.h" -#endif /* debug PC/ISA interrupts */ //#define DEBUG_IRQ @@ -756,15 +753,13 @@ static void load_linux(FWCfgState *fw_cfg, if (!f || !(kernel_size = get_file_size(f)) || fread(header, 1, MIN(ARRAY_SIZE(header), kernel_size), f) != MIN(ARRAY_SIZE(header), kernel_size)) { - fprintf(stderr, "qemu: could not load kernel '%s': %s\n", +// CONFIG_MARU MODIFICATION +// fprintf(stderr, "qemu: could not load kernel '%s': %s\n", +// kernel_filename, strerror(errno)); + error_report("qemu: could not load kernel '%s': %s\n", kernel_filename, strerror(errno)); -#ifdef CONFIG_MARU - char *path = get_canonical_path(kernel_filename); - maru_register_exit_msg(MARU_EXIT_KERNEL_FILE_EXCEPTION, path); - g_free(path); -#endif exit(1); } diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c index 8cc2e7a0ea..5d282831cb 100644 --- a/hw/i386/pc_sysfw.c +++ b/hw/i386/pc_sysfw.c @@ -34,10 +34,6 @@ #include "hw/block/flash.h" #include "sysemu/kvm.h" -#ifdef CONFIG_MARU -#include "tizen/src/util/maru_err_table.h" -#endif - #define BIOS_FILENAME "bios.bin" typedef struct PcSysFwDevice { @@ -205,10 +201,9 @@ static void old_pc_system_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw) ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1); if (ret != 0) { bios_error: - fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name); -#ifdef CONFIG_MARU - maru_register_exit_msg(MARU_EXIT_BIOS_FILE_EXCEPTION, bios_name); -#endif +// CONFIG_MARU MODIFICATION +// fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name); + error_report("qemu: could not load PC BIOS '%s'\n", bios_name); exit(1); } if (filename) { diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h index 7ab235590e..6c3a2df512 100644 --- a/include/qemu/error-report.h +++ b/include/qemu/error-report.h @@ -43,4 +43,18 @@ void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2); const char *error_get_progname(void); extern bool enable_timestamp_msg; +#ifdef CONFIG_MARU +#include "qemu/queue.h" + +typedef struct ErrorReporter ErrorReporter; + +struct ErrorReporter +{ + void (*report)(const char *fmt, va_list ap); + QLIST_ENTRY(ErrorReporter) node; +}; + +void add_error_reporter(ErrorReporter *new_reporter); +#endif + #endif diff --git a/tizen/src/display/maru_shm.c b/tizen/src/display/maru_shm.c index ef7fc6dbb9..ea076509b7 100644 --- a/tizen/src/display/maru_shm.c +++ b/tizen/src/display/maru_shm.c @@ -34,12 +34,13 @@ #include #include "qemu/main-loop.h" +#include "qemu/error-report.h" + #include "maru_display.h" #include "emul_state.h" #include "maru_display_processing.h" #include "hw/pci/maru_brightness.h" #include "skin/maruskin_server.h" -#include "util/maru_err_table.h" #include "debug_ch.h" #include "eventcast/encode_fb.h" @@ -267,8 +268,7 @@ static void maru_shm_init(uint64 swt_handle, ERR("shmget failed\n"); perror("maru_vga: "); - maru_register_exit_msg(MARU_EXIT_UNKNOWN, - (char*) "Cannot launch this VM.\n" + error_report("Cannot launch this VM." "Failed to get identifier of the shared memory segment."); exit(1); } @@ -278,8 +278,7 @@ static void maru_shm_init(uint64 swt_handle, ERR("shmat failed\n"); perror("maru_vga: "); - maru_register_exit_msg(MARU_EXIT_UNKNOWN, - (char*) "Cannot launch this VM.\n" + error_report("Cannot launch this VM. " "Failed to attach the shared memory segment."); exit(1); } diff --git a/tizen/src/ecs/ecs_msg_device.c b/tizen/src/ecs/ecs_msg_device.c index d2d67772d6..57b921bd10 100644 --- a/tizen/src/ecs/ecs_msg_device.c +++ b/tizen/src/ecs/ecs_msg_device.c @@ -40,7 +40,7 @@ #include "skin/maruskin_operation.h" #include "skin/maruskin_server.h" -#include "util/maru_device_hotplug.h" +#include "util/device_hotplug.h" #include "util/hds.h" #include "emul_state.h" #include "ecs.h" diff --git a/tizen/src/ecs/ecs_msg_injector.c b/tizen/src/ecs/ecs_msg_injector.c index bb6c48f2a9..dca573046b 100644 --- a/tizen/src/ecs/ecs_msg_injector.c +++ b/tizen/src/ecs/ecs_msg_injector.c @@ -38,7 +38,7 @@ #include "hw/virtio/maru_virtio_jack.h" #include "hw/virtio/maru_virtio_power.h" -#include "util/maru_device_hotplug.h" +#include "util/device_hotplug.h" #include "util/hds.h" #include "emul_state.h" #include "ecs.h" diff --git a/tizen/src/ecs/ecs_sdcard.c b/tizen/src/ecs/ecs_sdcard.c index 25487d36c8..00a814021b 100644 --- a/tizen/src/ecs/ecs_sdcard.c +++ b/tizen/src/ecs/ecs_sdcard.c @@ -30,7 +30,7 @@ #include "ecs_sdcard.h" #include "ecs.h" #include "util/osutil.h" -#include "util/maru_device_hotplug.h" +#include "util/device_hotplug.h" #include "debug_ch.h" #include "emul_state.h" diff --git a/tizen/src/emulator.c b/tizen/src/emulator.c index 67d4ae7478..c4d6e9b429 100644 --- a/tizen/src/emulator.c +++ b/tizen/src/emulator.c @@ -40,13 +40,14 @@ #include "emul_state.h" #include "emulator_options.h" #include "util/check_gl.h" -#include "util/maru_err_table.h" +#include "util/error_handler.h" #include "util/osutil.h" #include "util/sdb.h" #include "skin/maruskin_server.h" #include "util/new_debug_ch.h" #include "ecs/ecs.h" -#include "util/maru_device_hotplug.h" +#include "util/device_hotplug.h" +#include "util/exported_strings.h" #ifdef CONFIG_SDL #include @@ -97,8 +98,8 @@ static void construct_main_window(int skin_argc, char *skin_argv[], /* the next line checks for debugging and etc.. */ if (get_emul_skin_enable()) { if (0 > start_skin_client(skin_argc, skin_argv)) { - maru_register_exit_msg(MARU_EXIT_SKIN_SERVER_FAILED, NULL); - exit(-1); + error_report(FAILED_TO_INITIALIZE_SKIN); + exit(1); } } } @@ -120,8 +121,6 @@ static void emulator_notify_exit(Notifier *notifier, void *data) reset_variables(); LOG_INFO("Exit emulator...\n"); - - handle_error_at_exit(); } static Notifier emulator_exit = { .notify = emulator_notify_exit }; @@ -381,13 +380,13 @@ static int emulator_main(int argc, char *argv[], char **envp) #if defined (CONFIG_LINUX) int main(int argc, char *argv[], char **envp) { - register_exception_handler(); + init_error_handler(); return emulator_main(argc, argv, envp); } #else int main(int argc, char *argv[]) { - register_exception_handler(); + init_error_handler(); return emulator_main(argc, argv, NULL); } #endif diff --git a/tizen/src/emulator_legacy.c b/tizen/src/emulator_legacy.c index 619b24f0ea..6092e61dc4 100644 --- a/tizen/src/emulator_legacy.c +++ b/tizen/src/emulator_legacy.c @@ -41,7 +41,7 @@ #include "emul_state.h" #include "hw/virtio/maru_virtio_touchscreen.h" #include "util/check_gl.h" -#include "util/maru_err_table.h" +#include "util/error_handler.h" #include "display/maru_display.h" #include "util/osutil.h" #include "util/sdb.h" @@ -294,7 +294,6 @@ int legacy_emulator_main(int argc, char * argv[], char **envp) extract_qemu_info(_qemu_argc, _qemu_argv); INFO("Emulator start !!!\n"); - atexit(handle_error_at_exit); emulator_add_exit_notifier(&emulator_exit); extract_skin_info(_skin_argc, _skin_argv); diff --git a/tizen/src/skin/maruskin_client.c b/tizen/src/skin/maruskin_client.c index bdbdc2d0cf..ebdf0d894f 100644 --- a/tizen/src/skin/maruskin_client.c +++ b/tizen/src/skin/maruskin_client.c @@ -45,7 +45,7 @@ #ifdef CONFIG_WIN32 #include -#include "util/maru_err_table.h" +#include "qemu/error-report.h" #endif MULTI_DEBUG_CHANNEL(qemu, skinclient); @@ -279,8 +279,8 @@ static void *run_skin_client(void *arg) &pi)) { ERR("Unable to generate process! error %u\n", GetLastError()); - maru_register_exit_msg(MARU_EXIT_UNKNOWN, - "CreateProcess function failed. Unable to generate process."); + error_report("CreateProcess function failed. " + "Unable to generate process."); exit(1); } diff --git a/tizen/src/skin/maruskin_client.h b/tizen/src/skin/maruskin_client.h index 496956c9bf..5e6cd3d256 100644 --- a/tizen/src/skin/maruskin_client.h +++ b/tizen/src/skin/maruskin_client.h @@ -31,7 +31,7 @@ #ifndef MARUSKIN_CLIENT_H_ #define MARUSKIN_CLIENT_H_ -#include "tizen/src/util/maru_util_strings.h" +#include "tizen/src/util/exported_strings.h" int start_skin_client(int argc, char* argv[]); int start_simple_client(char* msg); diff --git a/tizen/src/skin/maruskin_operation.c b/tizen/src/skin/maruskin_operation.c index f89edeab0e..c53b86da41 100644 --- a/tizen/src/skin/maruskin_operation.c +++ b/tizen/src/skin/maruskin_operation.c @@ -49,7 +49,7 @@ #include "maruskin_server.h" #include "display/maru_display.h" #include "hw/maru_pm.h" -#include "util/maru_device_hotplug.h" +#include "util/device_hotplug.h" #include "ecs/ecs.h" #include "hw/virtio/maru_virtio_evdi.h" #include "hw/virtio/maru_virtio_rotary.h" diff --git a/tizen/src/skin/maruskin_server.c b/tizen/src/skin/maruskin_server.c index 29f6af297b..f0c334e505 100644 --- a/tizen/src/skin/maruskin_server.c +++ b/tizen/src/skin/maruskin_server.c @@ -33,9 +33,9 @@ #include "maruskin_server.h" #include "maruskin_operation.h" #include "display/maru_display.h" -#include "util/maru_err_table.h" #include "ecs/ecs.h" #include "emul_state.h" +#include "util/exported_strings.h" #ifdef CONFIG_WIN32 #include @@ -1457,7 +1457,7 @@ static void* do_heart_beat(void* args) ERR("!!! Fail to operate with heartbeat from skin client. Shutdown QEMU !!!\n"); ERR("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"); - maru_register_exit_msg(MARU_EXIT_HB_TIME_EXPIRED, NULL); + error_report(EMULATOR_HAS_STOPPED "\n"); shutdown_qemu_gracefully(TIMEOUT_FOR_SHUTDOWN); } diff --git a/tizen/src/util/Makefile.objs b/tizen/src/util/Makefile.objs index 708b313d5c..43009e8e65 100644 --- a/tizen/src/util/Makefile.objs +++ b/tizen/src/util/Makefile.objs @@ -23,10 +23,10 @@ obj-$(CONFIG_WIN32) += check_gl_wgl.o obj-$(CONFIG_DARWIN) += check_gl_cgl.o # hotplug -obj-y += maru_device_hotplug.o +obj-y += device_hotplug.o -# error table -obj-y += maru_err_table.o +# error handler +obj-y += error_handler.o # debug channel obj-y += new_debug_ch.o diff --git a/tizen/src/util/device_hotplug.c b/tizen/src/util/device_hotplug.c new file mode 100644 index 0000000000..f6d8994d6c --- /dev/null +++ b/tizen/src/util/device_hotplug.c @@ -0,0 +1,316 @@ +/* + * Maru device hotplug + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * SeokYeon Hwang + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "qemu/main-loop.h" +#include "qemu/config-file.h" +#include "hw/qdev.h" +#include "qemu/event_notifier.h" + +#include "emulator.h" +#include "emul_state.h" +#include "device_hotplug.h" +#include "ecs/ecs.h" +#include "hds.h" +#include "ecs/ecs_sdcard.h" + +#define HOST_KEYBOARD_DRIVER "virtio-keyboard-pci" +#define HOST_KEYBOARD_DEFAULT_ID "HOSTKBD0" + +#define FS_MOUNT_TAG "fileshare" + +#include "debug_ch.h" + +MULTI_DEBUG_CHANNEL(qemu, hotplug); + +struct maru_device_hotplug { + EventNotifier notifier; + + char *opaque; + int command; + + // FIXME: Should we query device every time ?? + bool host_keyboard_attached; + bool sdcard_attached; +}; + +static struct maru_device_hotplug *state; + +static bool do_host_keyboard_attach(void) +{ + QDict *qdict = qdict_new(); + qdict_put(qdict, "driver", qstring_from_str(HOST_KEYBOARD_DRIVER)); + qdict_put(qdict, "id", qstring_from_str(HOST_KEYBOARD_DEFAULT_ID)); + + if (do_device_add(default_mon, qdict, NULL)) { + QDECREF(qdict); + // TODO error reporting + return false; + } + + QDECREF(qdict); + + state->host_keyboard_attached = true; + + return true; +} + +static bool do_host_keyboard_detach(void) +{ + QDict *qdict = qdict_new(); + qdict_put(qdict, "id", qstring_from_str(HOST_KEYBOARD_DEFAULT_ID)); + + if (qmp_marshal_input_device_del(default_mon, qdict, NULL)) { + QDECREF(qdict); + // TODO error reporting + return false; + } + + QDECREF(qdict); + + state->host_keyboard_attached = false; + + return true; +} + +static bool do_sdcard_attach(const char * const file) +{ + QDict *qdict = qdict_new(); + QDict *qdict_file = qdict_new(); + QDict *qdict_options = qdict_new(); + gchar *sdcard_img = g_path_get_basename(file); + gchar *sdcard_device_id = g_strdup_printf("device_id_%s", sdcard_img); + gchar *sdcard_drive_id = g_strdup_printf("drive_id_%s", sdcard_img); + + g_free(sdcard_img); + + qdict_put(qdict_file, "driver", qstring_from_str("file")); + qdict_put(qdict_file, "filename", qstring_from_str(file)); + qdict_put(qdict_options, "file", qdict_file); + qdict_put(qdict_options, "driver", qstring_from_str("qcow2")); + qdict_put(qdict_options, "id", qstring_from_str(sdcard_device_id)); + qdict_put(qdict, "options", qdict_options); + + qmp_marshal_input_blockdev_add(default_mon, qdict, NULL); + + QDECREF(qdict); + + qdict = qdict_new(); + qdict_put(qdict, "driver", qstring_from_str(SDCARD_DRIVER)); + qdict_put(qdict, "drive", qstring_from_str(sdcard_device_id)); + /* set sdcard id as sdcard image file name */ + qdict_put(qdict, "id", qstring_from_str(sdcard_drive_id)); + + if (do_device_add(default_mon, qdict, NULL)) { + QDECREF(qdict); + LOG_WARNING("failed to attach sdcard: %s", file); + g_free(sdcard_device_id); + g_free(sdcard_drive_id); + return false; + } + + QDECREF(qdict); + g_free(sdcard_device_id); + g_free(sdcard_drive_id); + state->sdcard_attached = true; + return true; +} + +static bool do_sdcard_detach(const char * const file) +{ + QDict *qdict = qdict_new(); + gchar *sdcard_drive_id = g_strdup_printf("drive_id_%s", g_path_get_basename(file)); + qdict_put(qdict, "id", qstring_from_str(sdcard_drive_id)); + + if (qmp_marshal_input_device_del(cur_mon, qdict, NULL)) { + QDECREF(qdict); + g_free(sdcard_drive_id); + LOG_WARNING("failed to detach sdcard: %s", file); + return false; + } + + QDECREF(qdict); + state->sdcard_attached = false; + g_free(sdcard_drive_id); + return true; +} + +static bool do_hds_attach(const char * const id) +{ + QemuOpts *fsdev; + int ret; + QDict *qdict; + char* host; + int len = 0; + char* guest = NULL; + char emuld_data [OUT_BUF_SIZE]; + + fsdev = qemu_opts_create(qemu_find_opts("fsdev"), + id, 0, NULL); + if (!fsdev) { + return false; + } + + LOG_INFO("do_hds_attach - id: %s\n", id); + + host = get_host_path_by_id((char*)id); + if (host == NULL) { + LOG_SEVERE("host path is null\n"); + return false; + } + + qemu_opt_set(fsdev, "fsdriver", "local"); + qemu_opt_set(fsdev, "path", host); + qemu_opt_set(fsdev, "security_model", "none"); + + ret = qemu_fsdev_add(fsdev); + if (ret != 0) { + return false; + } + + qdict = qdict_new(); + qdict_put(qdict, "driver", qstring_from_str("virtio-9p-pci")); + qdict_put(qdict, "fsdev", qstring_from_str(id)); + qdict_put(qdict, "mount_tag", qstring_from_str(id)); + qdict_put(qdict, "id", qstring_from_str(id)); + + if (do_device_add(default_mon, qdict, NULL)) { + QDECREF(qdict); + return false; + } + + set_hds_attached(id, true); + + QDECREF(qdict); + + // send mount message to emuld + + guest = get_guest_path_by_id((char*)id); + if (guest == NULL) { + LOG_SEVERE("guest path is null\n"); + return false; + } + + len = snprintf(emuld_data, sizeof(emuld_data), "%s\n%s\n", id, guest); + LOG_INFO("send emuld to mount: %s", emuld_data); + send_msg_to_guest(MSG_TYPE_HDS, MSG_GROUP_HDS, HDS_ACTION_MOUNT, emuld_data, len + 1); + + return true; +} + +static bool do_hds_detach(const char * const id) +{ + QDict *qdict = qdict_new(); + qemu_fsdev_remove(id); + + qdict_put(qdict, "id", qstring_from_str(id)); + + if (qmp_marshal_input_device_del(cur_mon, qdict, NULL)) { + QDECREF(qdict); + return false; + } + + QDECREF(qdict); + + remove_hds_list(id); + + return true; +} + +void do_hotplug(int command, void *opaque, size_t size) +{ + if (opaque != NULL && size > 0) { + state->opaque = g_malloc(size); + memcpy(state->opaque, opaque, size); + } + state->command = command; + + event_notifier_set(&state->notifier); +} + +static void device_hotplug_handler(EventNotifier *e) +{ + event_notifier_test_and_clear(e); + + switch(state->command) { + case ATTACH_HOST_KEYBOARD: + do_host_keyboard_attach(); + break; + case DETACH_HOST_KEYBOARD: + do_host_keyboard_detach(); + break; + case ATTACH_SDCARD: + do_sdcard_attach(state->opaque); + break; + case DETACH_SDCARD: + do_sdcard_detach(state->opaque); + break; + case ATTACH_HDS: + do_hds_attach(state->opaque); + break; + case DETACH_HDS: + do_hds_detach(state->opaque); + break; + default: + break; + } + + if (state->opaque != NULL) { + g_free(state->opaque); + state->opaque = NULL; + } +} + +static void deinit_maru_device_hotplug(Notifier *notifier, void *data) +{ + event_notifier_cleanup(&state->notifier); + + g_free(state); +} + +static Notifier maru_device_hotplug_exit = { .notify = deinit_maru_device_hotplug }; + +void init_device_hotplug(void) +{ + state = g_malloc0(sizeof(struct maru_device_hotplug)); + + event_notifier_init(&state->notifier, 0); + event_notifier_set_handler(&state->notifier, device_hotplug_handler); + + emulator_add_exit_notifier(&maru_device_hotplug_exit); +} + +bool is_host_keyboard_attached(void) +{ + return state->host_keyboard_attached; +} + +bool is_sdcard_attached(void) +{ + //TODO: support checking multi sdcard attached + return state->sdcard_attached; +} diff --git a/tizen/src/util/device_hotplug.h b/tizen/src/util/device_hotplug.h new file mode 100644 index 0000000000..6001ee3b81 --- /dev/null +++ b/tizen/src/util/device_hotplug.h @@ -0,0 +1,48 @@ +/* + * Maru device hotplug + * + * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * SeokYeon Hwang + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#ifndef _MARU_DEVICE_HOTPLUG_H_ +#define _MARU_DEVICE_HOTPLUG_H_ + +enum command { + ATTACH_HOST_KEYBOARD, + DETACH_HOST_KEYBOARD, + ATTACH_SDCARD, + DETACH_SDCARD, + ATTACH_HDS, + DETACH_HDS, +}; + +void init_device_hotplug(void); + +void do_hotplug(int command, void *opaque, size_t size); + +bool is_host_keyboard_attached(void); +bool is_sdcard_attached(void); + +#endif // _MARU_DEVICE_HOTPLUG_H_ diff --git a/tizen/src/util/error_handler.c b/tizen/src/util/error_handler.c new file mode 100644 index 0000000000..87f36f7c2b --- /dev/null +++ b/tizen/src/util/error_handler.c @@ -0,0 +1,382 @@ +/* + * Error handler + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * SeokYeon Hwang + * GiWoong Kim + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include +#include +#include +#include + +#include "qemu-common.h" + +#ifdef CONFIG_WIN32 +#include +#else +#include +#endif + +#include "qemu/error-report.h" + +#include "error_handler.h" +#include "emulator_common.h" +#include "emulator.h" + +#include "debug_ch.h" + +MULTI_DEBUG_CHANNEL(qemu, backtrace); + +// deprecated +/* This table must match the enum definition */ +static char _maru_string_table[][JAVA_MAX_COMMAND_LENGTH] = { + /* 0 */ "", + /* 1 */ FAILED_TO_ALLOCATE_MEMORY, + /* 2 */ FAILED_TO_LOAD_KERNEL CHECK_FILE_VALID, + /* 3 */ FAILED_TO_LOAD_BIOS CHECK_FILE_VALID, + /* 4 */ FAILED_TO_INITIALIZE_SKIN, + /* 5 */ EMULATOR_HAS_STOPPED, + /* add here.. */ + "" +}; + +static int maru_exit_status = MARU_EXIT_NORMAL; +static char *maru_exit_msg; + +#ifdef CONFIG_WIN32 +static LPTOP_LEVEL_EXCEPTION_FILTER prevExceptionFilter; +#endif + +#ifdef CONFIG_LINUX +static pthread_spinlock_t siglock; +void maru_sighandler(int sig); +#endif + +// deprecated +char *get_canonical_path(char const *const path) +{ + if ((int)g_path_is_absolute(path)) { + return (char *)g_strdup(path); + } + + char *canonical_path; + +#ifndef _WIN32 + char *current_dir = g_get_current_dir(); + canonical_path = g_strdup_printf("%s/%s", current_dir, path); + g_free(current_dir); +#else + canonical_path = g_malloc(MAX_PATH); + GetFullPathName(path, MAX_PATH, canonical_path, NULL); +#endif + + return canonical_path; +} + +// deprecated +// Use error_report() instead +void register_exit_message(int status, char const *format, ...) +{ + va_list args; + + if (status >= MARU_EXIT_NORMAL) { + fprintf(stderr, "Invalid error message index = %d\n", + status); + return; + } + if (maru_exit_status != MARU_EXIT_NORMAL) { + fprintf(stderr, "The error message is already registered = %d\n", + maru_exit_status); + return; + } + + maru_exit_status = status; + + if (maru_exit_status == MARU_EXIT_HB_TIME_EXPIRED) { + fprintf(stderr, "Skin client could not connect to Skin server." + " The time of internal heartbeat has expired.\n"); + } + + if (!format) { + format = ""; + } + + va_start(args, format); + char *additional = g_strdup_vprintf(format, args); + va_end(args); + maru_exit_msg = g_strdup_printf("%s%s", _maru_string_table[maru_exit_status], + additional); + g_free(additional); + + if (strlen(maru_exit_msg) >= JAVA_MAX_COMMAND_LENGTH) { + maru_exit_msg[JAVA_MAX_COMMAND_LENGTH - 1] = '\0'; + } + + fprintf(stdout, "The error message is registered = %d : %s\n", + maru_exit_status, maru_exit_msg); +} + +/* Print 'backtrace' */ +#ifdef _WIN32 +struct frame_layout { + void *pNext; + void *pReturnAddr; +}; + +static char *get_filename_from_path(char *path_buf) +{ + char *ret_slash; + char *ret_rslash; + + ret_slash = strrchr(path_buf, '/'); + ret_rslash = strrchr(path_buf, '\\'); + + if (ret_slash || ret_rslash) { + if (ret_slash > ret_rslash) { + return ret_slash + 1; + } else{ + return ret_rslash + 1; + } + } + + return path_buf; +} + + +static HMODULE get_module_handle(DWORD dwAddress) +{ + MEMORY_BASIC_INFORMATION Buffer; + return VirtualQuery((LPCVOID) dwAddress, &Buffer, sizeof(Buffer)) + ? (HMODULE) Buffer.AllocationBase : (HMODULE) 0; +} +#endif + +static void dump_backtrace(void *ptr, int depth) +{ +#ifdef _WIN32 + int nCount; + void *pTopFrame; + struct frame_layout currentFrame; + struct frame_layout *pCurrentFrame; + + char module_buf[1024]; + HMODULE hModule; + + PCONTEXT pContext = ptr; + if (!pContext) { + __asm__ __volatile__ ("movl %%ebp, %0" : "=m" (pTopFrame)); + } else { + pTopFrame = (void *)((PCONTEXT)pContext)->Ebp; + } + + if (pTopFrame == NULL) { + INFO("ebp is null, skip this for now\n"); + return ; + } + + nCount = 0; + currentFrame.pNext = ((struct frame_layout *)pTopFrame)->pNext; + currentFrame.pReturnAddr = ((struct frame_layout *)pTopFrame)->pReturnAddr; + pCurrentFrame = (struct frame_layout *)pTopFrame; + + ERR("\nBacktrace Dump Start :\n"); + if (pContext) { + memset(module_buf, 0, sizeof(module_buf)); + hModule = get_module_handle((DWORD)((PCONTEXT)pContext)->Eip); + if (hModule) { + if (!GetModuleFileNameA(hModule, module_buf, sizeof(module_buf))) { + memset(module_buf, 0, sizeof(module_buf)); + } + } + ERR("[%02d]Addr = 0x%p : %s\n", nCount, ((PCONTEXT)pContext)->Eip, get_filename_from_path(module_buf)); + nCount++; + } + + while (1) { + if (((void *)pCurrentFrame < pTopFrame) + || ((void *)pCurrentFrame >= (void *)0xC0000000)) { + break; + } + + memset(module_buf, 0, sizeof(module_buf)); + hModule = get_module_handle((DWORD)currentFrame.pReturnAddr); + if (hModule) { + if (!GetModuleFileNameA(hModule, module_buf, sizeof(module_buf))) { + memset(module_buf, 0, sizeof(module_buf)); + } + } + ERR("[%02d]Addr = 0x%p : %s\n", nCount, currentFrame.pReturnAddr, get_filename_from_path(module_buf)); + + if (!ReadProcessMemory(GetCurrentProcess(), currentFrame.pNext, + (void *)¤tFrame, sizeof(struct frame_layout), NULL)) { + break; + } + pCurrentFrame = (struct frame_layout *)pCurrentFrame->pNext; + + if (depth) { + if (!--depth) { + break; + } + } + nCount++; + } +#else + void *trace[1024]; + int ndepth = backtrace(trace, 1024); + ERR("Backtrace depth is %d.\n", ndepth); + + backtrace_symbols_fd(trace, ndepth, fileno(stderr)); +#endif +} + +static void handle_error_at_exit(void) +{ + + // deprecated + if (maru_exit_status != MARU_EXIT_NORMAL || maru_exit_msg) { + start_simple_client(maru_exit_msg); + } + g_free(maru_exit_msg); + + // dump backtrace log no matter what + INFO("Stack backtrace for tracing...\n"); + INFO("This is not an error.\n"); + dump_backtrace(NULL, 0); +} + +#ifdef CONFIG_WIN32 +static WINAPI LONG maru_unhandled_exception_filter(LPEXCEPTION_POINTERS pExceptionInfo){ + char module_buf[1024]; + + // print system information again + print_system_info(); + + DWORD dwException = pExceptionInfo->ExceptionRecord->ExceptionCode; + ERR("%d\n ", (int)dwException); + + PEXCEPTION_RECORD pExceptionRecord; + HMODULE hModule; + PCONTEXT pContext; + + pExceptionRecord = pExceptionInfo->ExceptionRecord; + + memset(module_buf, 0, sizeof(module_buf)); + hModule = get_module_handle((DWORD)pExceptionRecord->ExceptionAddress); + if(hModule){ + if(!GetModuleFileNameA(hModule, module_buf, sizeof(module_buf))){ + memset(module_buf, 0, sizeof(module_buf)); + } + } + + ERR("Exception [%X] occured at %s:0x%08x\n", + pExceptionRecord->ExceptionCode, + get_filename_from_path(module_buf), + pExceptionRecord->ExceptionAddress + ); + + pContext = pExceptionInfo->ContextRecord; + dump_backtrace(pContext, 0); + _exit(0); + //return EXCEPTION_CONTINUE_SEARCH; +} +#endif + +#ifdef CONFIG_LINUX +void maru_sighandler(int sig) +{ + ERR("Got signal %d\n", sig); + // print system information again + print_system_info(); + + pthread_spin_lock(&siglock); + dump_backtrace(NULL, 0); + pthread_spin_unlock(&siglock); + _exit(0); +} +#endif + + +#ifndef CONFIG_DARWIN +static void register_exception_handler(void) +{ + #ifdef CONFIG_WIN32 + prevExceptionFilter = SetUnhandledExceptionFilter(maru_unhandled_exception_filter); + #else // LINUX + void *trace[1]; + struct sigaction sa; + + // make dummy call to explicitly load glibc library + backtrace(trace, 1); + + pthread_spin_init(&siglock,0); + sa.sa_handler = (void*) maru_sighandler; + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_RESTART; + sigaction(SIGSEGV, &sa, NULL); + sigaction(SIGBUS, &sa, NULL); + sigaction(SIGILL, &sa, NULL); + sigaction(SIGFPE, &sa, NULL); + sigaction(SIGABRT, &sa, NULL); + // main thread only + sigaction(SIGTERM, &sa, NULL); + sigaction(SIGINT, &sa, NULL); + #endif +} +#else // CONFIG_DARWIN +static void register_exception_handler(void) +{ + // TODO: Exception handling on darwin +} +#endif + +#define MAX_MESSAGE_LEN 2048 +static size_t message_len; +static char message[MAX_MESSAGE_LEN]; + +static void report(const char *fmt, va_list ap) +{ + char *new_message = g_strdup_vprintf(fmt, ap); + message_len = g_strlcat(message, new_message, MAX_MESSAGE_LEN); + g_free(new_message); + + // We are wating for '\n' + if (message[message_len - 1] == '\n') { + fprintf(stderr, "%s", message); + start_simple_client(message); + message[0] = '\0'; + message_len = 0; + } +} + +static ErrorReporter error_reporter = + { .report = report }; + +void init_error_handler(void) { + register_exception_handler(); + add_error_reporter(&error_reporter); + + atexit(handle_error_at_exit); +} diff --git a/tizen/src/util/error_handler.h b/tizen/src/util/error_handler.h new file mode 100644 index 0000000000..7081672d1a --- /dev/null +++ b/tizen/src/util/error_handler.h @@ -0,0 +1,56 @@ +/* + * Error handler + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * SeokYeon Hwang + * GiWoong Kim + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + + +#ifndef __ERROR_HANDLER_H__ +#define __ERROR_HANDLER_H__ + +#include "tizen/src/skin/maruskin_client.h" + +// deprecated +/* TODO: define macro for fair of definition */ +/* This enum must match the table definition */ +enum { + /* 0 */ MARU_EXIT_UNKNOWN = 0, + /* 1 */ MARU_EXIT_MEMORY_EXCEPTION, + /* 2 */ MARU_EXIT_KERNEL_FILE_EXCEPTION, + /* 3 */ MARU_EXIT_BIOS_FILE_EXCEPTION, + /* 4 */ MARU_EXIT_SKIN_SERVER_FAILED, + /* 5 */ MARU_EXIT_HB_TIME_EXPIRED, + /* add here.. */ + MARU_EXIT_NORMAL +}; + +void init_error_handler(void); +// deprecated +void register_exit_message(int status, char const *format, ...); +// deprecated +char *get_canonical_path(char const *const path); + +#endif /* __ERROR_HANDLER_H__ */ diff --git a/tizen/src/util/exported_strings.h b/tizen/src/util/exported_strings.h new file mode 100644 index 0000000000..e29c77f067 --- /dev/null +++ b/tizen/src/util/exported_strings.h @@ -0,0 +1,47 @@ +/* + * The strings for the emulator messages + * + * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Sooyoung Ha + * GiWoong Kim + * SeokYeon Hwang + * Sangho Park + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + + +#ifndef __MARU_UTIL_STRINGS_H__ +#define __MARU_UTIL_STRINGS_H__ + +#define FAILED_TO_ALLOCATE_MEMORY "Failed to allocate memory in qemu." +#define FAILED_TO_LOAD_KERNEL "Failed to load a kernel file the following path." +#define FAILED_TO_LOAD_BIOS "Failed to load a bios file in bios path that mentioned on document." +#define FAILED_TO_LOAD_DISK "Failed to load disk file from the following path." +#define CHECK_FILE_VALID " Check if the file is corrupted or missing.\n\n" +#define FAILED_TO_INITIALIZE_SKIN "Skin process cannot be initialized. Skin server is not ready." +#define FAILED_TO_INSTALL_EXTRAPACKAGE_1 "Extra package installation is failed.\n" +#define FAILED_TO_INSTALL_EXTRAPACKAGE_2 " must be installed MANUALLY!" +#define EMULATOR_HAS_STOPPED "Emulator has stopped working.\nA problem caused the program to stop working correctly." +#define NO_ACCELERATOR_FOUND "No accelerator found." + +#endif /* __MARU_UTIL_STRINGS_H__ */ diff --git a/tizen/src/util/maru_device_hotplug.c b/tizen/src/util/maru_device_hotplug.c deleted file mode 100644 index e22605e4a5..0000000000 --- a/tizen/src/util/maru_device_hotplug.c +++ /dev/null @@ -1,316 +0,0 @@ -/* - * Maru device hotplug - * - * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * SeokYeon Hwang - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -#include "qemu/main-loop.h" -#include "qemu/config-file.h" -#include "hw/qdev.h" -#include "qemu/event_notifier.h" - -#include "emulator.h" -#include "emul_state.h" -#include "maru_device_hotplug.h" -#include "ecs/ecs.h" -#include "hds.h" -#include "ecs/ecs_sdcard.h" - -#define HOST_KEYBOARD_DRIVER "virtio-keyboard-pci" -#define HOST_KEYBOARD_DEFAULT_ID "HOSTKBD0" - -#define FS_MOUNT_TAG "fileshare" - -#include "debug_ch.h" - -MULTI_DEBUG_CHANNEL(qemu, hotplug); - -struct maru_device_hotplug { - EventNotifier notifier; - - char *opaque; - int command; - - // FIXME: Should we query device every time ?? - bool host_keyboard_attached; - bool sdcard_attached; -}; - -static struct maru_device_hotplug *state; - -static bool do_host_keyboard_attach(void) -{ - QDict *qdict = qdict_new(); - qdict_put(qdict, "driver", qstring_from_str(HOST_KEYBOARD_DRIVER)); - qdict_put(qdict, "id", qstring_from_str(HOST_KEYBOARD_DEFAULT_ID)); - - if (do_device_add(default_mon, qdict, NULL)) { - QDECREF(qdict); - // TODO error reporting - return false; - } - - QDECREF(qdict); - - state->host_keyboard_attached = true; - - return true; -} - -static bool do_host_keyboard_detach(void) -{ - QDict *qdict = qdict_new(); - qdict_put(qdict, "id", qstring_from_str(HOST_KEYBOARD_DEFAULT_ID)); - - if (qmp_marshal_input_device_del(default_mon, qdict, NULL)) { - QDECREF(qdict); - // TODO error reporting - return false; - } - - QDECREF(qdict); - - state->host_keyboard_attached = false; - - return true; -} - -static bool do_sdcard_attach(const char * const file) -{ - QDict *qdict = qdict_new(); - QDict *qdict_file = qdict_new(); - QDict *qdict_options = qdict_new(); - gchar *sdcard_img = g_path_get_basename(file); - gchar *sdcard_device_id = g_strdup_printf("device_id_%s", sdcard_img); - gchar *sdcard_drive_id = g_strdup_printf("drive_id_%s", sdcard_img); - - g_free(sdcard_img); - - qdict_put(qdict_file, "driver", qstring_from_str("file")); - qdict_put(qdict_file, "filename", qstring_from_str(file)); - qdict_put(qdict_options, "file", qdict_file); - qdict_put(qdict_options, "driver", qstring_from_str("qcow2")); - qdict_put(qdict_options, "id", qstring_from_str(sdcard_device_id)); - qdict_put(qdict, "options", qdict_options); - - qmp_marshal_input_blockdev_add(default_mon, qdict, NULL); - - QDECREF(qdict); - - qdict = qdict_new(); - qdict_put(qdict, "driver", qstring_from_str(SDCARD_DRIVER)); - qdict_put(qdict, "drive", qstring_from_str(sdcard_device_id)); - /* set sdcard id as sdcard image file name */ - qdict_put(qdict, "id", qstring_from_str(sdcard_drive_id)); - - if (do_device_add(default_mon, qdict, NULL)) { - QDECREF(qdict); - LOG_WARNING("failed to attach sdcard: %s", file); - g_free(sdcard_device_id); - g_free(sdcard_drive_id); - return false; - } - - QDECREF(qdict); - g_free(sdcard_device_id); - g_free(sdcard_drive_id); - state->sdcard_attached = true; - return true; -} - -static bool do_sdcard_detach(const char * const file) -{ - QDict *qdict = qdict_new(); - gchar *sdcard_drive_id = g_strdup_printf("drive_id_%s", g_path_get_basename(file)); - qdict_put(qdict, "id", qstring_from_str(sdcard_drive_id)); - - if (qmp_marshal_input_device_del(cur_mon, qdict, NULL)) { - QDECREF(qdict); - g_free(sdcard_drive_id); - LOG_WARNING("failed to detach sdcard: %s", file); - return false; - } - - QDECREF(qdict); - state->sdcard_attached = false; - g_free(sdcard_drive_id); - return true; -} - -static bool do_hds_attach(const char * const id) -{ - QemuOpts *fsdev; - int ret; - QDict *qdict; - char* host; - int len = 0; - char* guest = NULL; - char emuld_data [OUT_BUF_SIZE]; - - fsdev = qemu_opts_create(qemu_find_opts("fsdev"), - id, 0, NULL); - if (!fsdev) { - return false; - } - - LOG_INFO("do_hds_attach - id: %s\n", id); - - host = get_host_path_by_id((char*)id); - if (host == NULL) { - LOG_SEVERE("host path is null\n"); - return false; - } - - qemu_opt_set(fsdev, "fsdriver", "local"); - qemu_opt_set(fsdev, "path", host); - qemu_opt_set(fsdev, "security_model", "none"); - - ret = qemu_fsdev_add(fsdev); - if (ret != 0) { - return false; - } - - qdict = qdict_new(); - qdict_put(qdict, "driver", qstring_from_str("virtio-9p-pci")); - qdict_put(qdict, "fsdev", qstring_from_str(id)); - qdict_put(qdict, "mount_tag", qstring_from_str(id)); - qdict_put(qdict, "id", qstring_from_str(id)); - - if (do_device_add(default_mon, qdict, NULL)) { - QDECREF(qdict); - return false; - } - - set_hds_attached(id, true); - - QDECREF(qdict); - - // send mount message to emuld - - guest = get_guest_path_by_id((char*)id); - if (guest == NULL) { - LOG_SEVERE("guest path is null\n"); - return false; - } - - len = snprintf(emuld_data, sizeof(emuld_data), "%s\n%s\n", id, guest); - LOG_INFO("send emuld to mount: %s", emuld_data); - send_msg_to_guest(MSG_TYPE_HDS, MSG_GROUP_HDS, HDS_ACTION_MOUNT, emuld_data, len + 1); - - return true; -} - -static bool do_hds_detach(const char * const id) -{ - QDict *qdict = qdict_new(); - qemu_fsdev_remove(id); - - qdict_put(qdict, "id", qstring_from_str(id)); - - if (qmp_marshal_input_device_del(cur_mon, qdict, NULL)) { - QDECREF(qdict); - return false; - } - - QDECREF(qdict); - - remove_hds_list(id); - - return true; -} - -void do_hotplug(int command, void *opaque, size_t size) -{ - if (opaque != NULL && size > 0) { - state->opaque = g_malloc(size); - memcpy(state->opaque, opaque, size); - } - state->command = command; - - event_notifier_set(&state->notifier); -} - -static void device_hotplug_handler(EventNotifier *e) -{ - event_notifier_test_and_clear(e); - - switch(state->command) { - case ATTACH_HOST_KEYBOARD: - do_host_keyboard_attach(); - break; - case DETACH_HOST_KEYBOARD: - do_host_keyboard_detach(); - break; - case ATTACH_SDCARD: - do_sdcard_attach(state->opaque); - break; - case DETACH_SDCARD: - do_sdcard_detach(state->opaque); - break; - case ATTACH_HDS: - do_hds_attach(state->opaque); - break; - case DETACH_HDS: - do_hds_detach(state->opaque); - break; - default: - break; - } - - if (state->opaque != NULL) { - g_free(state->opaque); - state->opaque = NULL; - } -} - -static void deinit_maru_device_hotplug(Notifier *notifier, void *data) -{ - event_notifier_cleanup(&state->notifier); - - g_free(state); -} - -static Notifier maru_device_hotplug_exit = { .notify = deinit_maru_device_hotplug }; - -void init_device_hotplug(void) -{ - state = g_malloc0(sizeof(struct maru_device_hotplug)); - - event_notifier_init(&state->notifier, 0); - event_notifier_set_handler(&state->notifier, device_hotplug_handler); - - emulator_add_exit_notifier(&maru_device_hotplug_exit); -} - -bool is_host_keyboard_attached(void) -{ - return state->host_keyboard_attached; -} - -bool is_sdcard_attached(void) -{ - //TODO: support checking multi sdcard attached - return state->sdcard_attached; -} diff --git a/tizen/src/util/maru_device_hotplug.h b/tizen/src/util/maru_device_hotplug.h deleted file mode 100644 index 6001ee3b81..0000000000 --- a/tizen/src/util/maru_device_hotplug.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Maru device hotplug - * - * Copyright (C) 2014 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * SeokYeon Hwang - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -#ifndef _MARU_DEVICE_HOTPLUG_H_ -#define _MARU_DEVICE_HOTPLUG_H_ - -enum command { - ATTACH_HOST_KEYBOARD, - DETACH_HOST_KEYBOARD, - ATTACH_SDCARD, - DETACH_SDCARD, - ATTACH_HDS, - DETACH_HDS, -}; - -void init_device_hotplug(void); - -void do_hotplug(int command, void *opaque, size_t size); - -bool is_host_keyboard_attached(void); -bool is_sdcard_attached(void); - -#endif // _MARU_DEVICE_HOTPLUG_H_ diff --git a/tizen/src/util/maru_err_table.c b/tizen/src/util/maru_err_table.c deleted file mode 100644 index fc5edc5f1f..0000000000 --- a/tizen/src/util/maru_err_table.c +++ /dev/null @@ -1,347 +0,0 @@ -/* - * Error message - * - * Copyright (C) 2011, 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * SeokYeon Hwang - * GiWoong Kim - * YeongKyoon Lee - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -#include -#include -#include -#include -#ifdef CONFIG_WIN32 -#include -#else -#include -#endif - -#include "qemu-common.h" - -#include "emulator_common.h" -#include "emulator.h" -#include "maru_err_table.h" - -#include "debug_ch.h" - -MULTI_DEBUG_CHANNEL(qemu, backtrace); - -/* This table must match the enum definition */ -static char _maru_string_table[][JAVA_MAX_COMMAND_LENGTH] = { - /* 0 */ "", - /* 1 */ FAILED_TO_ALLOCATE_MEMORY, - /* 2 */ FAILED_TO_LOAD_KERNEL CHECK_FILE_VALID, - /* 3 */ FAILED_TO_LOAD_BIOS CHECK_FILE_VALID, - /* 4 */ FAILED_TO_INITIAL_SKIN, - /* 5 */ EMULATOR_HAS_STOPPED, - /* add here.. */ - "" -}; - - -static int maru_exit_status = MARU_EXIT_NORMAL; -static char *maru_exit_msg; - -#ifdef CONFIG_WIN32 -static LPTOP_LEVEL_EXCEPTION_FILTER prevExceptionFilter; -#endif - -#ifdef CONFIG_LINUX -static pthread_spinlock_t siglock; -void maru_sighandler(int sig); -#endif - -char *get_canonical_path(char const *const path) -{ - if ((int)g_path_is_absolute(path)) { - return (char *)g_strdup(path); - } - - char *canonical_path; - -#ifndef _WIN32 - char *current_dir = g_get_current_dir(); - canonical_path = g_strdup_printf("%s/%s", current_dir, path); - g_free(current_dir); -#else - canonical_path = g_malloc(MAX_PATH); - GetFullPathName(path, MAX_PATH, canonical_path, NULL); -#endif - - return canonical_path; -} - -void maru_register_exit_msg(int maru_exit_index, char const *format, ...) -{ - va_list args; - - if (maru_exit_index >= MARU_EXIT_NORMAL) { - fprintf(stderr, "Invalid error message index = %d\n", - maru_exit_index); - return; - } - if (maru_exit_status != MARU_EXIT_NORMAL) { - fprintf(stderr, "The error message is already registered = %d\n", - maru_exit_status); - return; - } - - maru_exit_status = maru_exit_index; - - if (maru_exit_status == MARU_EXIT_HB_TIME_EXPIRED) { - fprintf(stderr, "Skin client could not connect to Skin server." - " The time of internal heartbeat has expired.\n"); - } - - if (!format) { - format = ""; - } - - va_start(args, format); - char *additional = g_strdup_vprintf(format, args); - va_end(args); - maru_exit_msg = g_strdup_printf("%s%s", _maru_string_table[maru_exit_status], - additional); - g_free(additional); - - if (strlen(maru_exit_msg) >= JAVA_MAX_COMMAND_LENGTH) { - maru_exit_msg[JAVA_MAX_COMMAND_LENGTH - 1] = '\0'; - } - - fprintf(stdout, "The error message is registered = %d : %s\n", - maru_exit_status, maru_exit_msg); -} - -/* Print 'backtrace' */ -#ifdef _WIN32 -struct frame_layout { - void *pNext; - void *pReturnAddr; -}; - -static char *aqua_get_filename_from_path(char *path_buf) -{ - char *ret_slash; - char *ret_rslash; - - ret_slash = strrchr(path_buf, '/'); - ret_rslash = strrchr(path_buf, '\\'); - - if (ret_slash || ret_rslash) { - if (ret_slash > ret_rslash) { - return ret_slash + 1; - } else{ - return ret_rslash + 1; - } - } - - return path_buf; -} - - -static HMODULE aqua_get_module_handle(DWORD dwAddress) -{ - MEMORY_BASIC_INFORMATION Buffer; - return VirtualQuery((LPCVOID) dwAddress, &Buffer, sizeof(Buffer)) - ? (HMODULE) Buffer.AllocationBase : (HMODULE) 0; -} -#endif - -static void dump_backtrace(void *ptr, int depth) -{ -#ifdef _WIN32 - int nCount; - void *pTopFrame; - struct frame_layout currentFrame; - struct frame_layout *pCurrentFrame; - - char module_buf[1024]; - HMODULE hModule; - - PCONTEXT pContext = ptr; - if (!pContext) { - __asm__ __volatile__ ("movl %%ebp, %0" : "=m" (pTopFrame)); - } else { - pTopFrame = (void *)((PCONTEXT)pContext)->Ebp; - } - - if (pTopFrame == NULL) { - INFO("ebp is null, skip this for now\n"); - return ; - } - - nCount = 0; - currentFrame.pNext = ((struct frame_layout *)pTopFrame)->pNext; - currentFrame.pReturnAddr = ((struct frame_layout *)pTopFrame)->pReturnAddr; - pCurrentFrame = (struct frame_layout *)pTopFrame; - - ERR("\nBacktrace Dump Start :\n"); - if (pContext) { - memset(module_buf, 0, sizeof(module_buf)); - hModule = aqua_get_module_handle((DWORD)((PCONTEXT)pContext)->Eip); - if (hModule) { - if (!GetModuleFileNameA(hModule, module_buf, sizeof(module_buf))) { - memset(module_buf, 0, sizeof(module_buf)); - } - } - ERR("[%02d]Addr = 0x%p : %s\n", nCount, ((PCONTEXT)pContext)->Eip, aqua_get_filename_from_path(module_buf)); - nCount++; - } - - while (1) { - if (((void *)pCurrentFrame < pTopFrame) - || ((void *)pCurrentFrame >= (void *)0xC0000000)) { - break; - } - - memset(module_buf, 0, sizeof(module_buf)); - hModule = aqua_get_module_handle((DWORD)currentFrame.pReturnAddr); - if (hModule) { - if (!GetModuleFileNameA(hModule, module_buf, sizeof(module_buf))) { - memset(module_buf, 0, sizeof(module_buf)); - } - } - ERR("[%02d]Addr = 0x%p : %s\n", nCount, currentFrame.pReturnAddr, aqua_get_filename_from_path(module_buf)); - - if (!ReadProcessMemory(GetCurrentProcess(), currentFrame.pNext, - (void *)¤tFrame, sizeof(struct frame_layout), NULL)) { - break; - } - pCurrentFrame = (struct frame_layout *)pCurrentFrame->pNext; - - if (depth) { - if (!--depth) { - break; - } - } - nCount++; - } -#else - void *trace[1024]; - int ndepth = backtrace(trace, 1024); - ERR("Backtrace depth is %d.\n", ndepth); - - backtrace_symbols_fd(trace, ndepth, fileno(stderr)); -#endif -} - -void handle_error_at_exit(void) -{ - - if (maru_exit_status != MARU_EXIT_NORMAL || maru_exit_msg) { - start_simple_client(maru_exit_msg); - } - g_free(maru_exit_msg); - - // dump backtrace log no matter what - INFO("This is not a error.\n"); - INFO("Stack backtrace for tracing...\n"); - dump_backtrace(NULL, 0); -} - -#ifdef CONFIG_WIN32 -static WINAPI LONG maru_unhandled_exception_filter(LPEXCEPTION_POINTERS pExceptionInfo){ - char module_buf[1024]; - - // print system information again - print_system_info(); - - DWORD dwException = pExceptionInfo->ExceptionRecord->ExceptionCode; - ERR("%d\n ", (int)dwException); - - PEXCEPTION_RECORD pExceptionRecord; - HMODULE hModule; - PCONTEXT pContext; - - pExceptionRecord = pExceptionInfo->ExceptionRecord; - - memset(module_buf, 0, sizeof(module_buf)); - hModule = aqua_get_module_handle((DWORD)pExceptionRecord->ExceptionAddress); - if(hModule){ - if(!GetModuleFileNameA(hModule, module_buf, sizeof(module_buf))){ - memset(module_buf, 0, sizeof(module_buf)); - } - } - - ERR("Exception [%X] occured at %s:0x%08x\n", - pExceptionRecord->ExceptionCode, - aqua_get_filename_from_path(module_buf), - pExceptionRecord->ExceptionAddress - ); - - pContext = pExceptionInfo->ContextRecord; - dump_backtrace(pContext, 0); - _exit(0); - //return EXCEPTION_CONTINUE_SEARCH; -} -#endif - -#ifdef CONFIG_LINUX -void maru_sighandler(int sig) -{ - // print system information again - print_system_info(); - - pthread_spin_lock(&siglock); - ERR("Got signal %d\n", sig); - dump_backtrace(NULL, 0); - pthread_spin_unlock(&siglock); - _exit(0); -} -#endif - - -#ifndef CONFIG_DARWIN -void register_exception_handler(void) -{ - #ifdef CONFIG_WIN32 - prevExceptionFilter = SetUnhandledExceptionFilter(maru_unhandled_exception_filter); - #else // LINUX - void *trace[1]; - struct sigaction sa; - - // make dummy call to explicitly load glibc library - backtrace(trace, 1); - - pthread_spin_init(&siglock,0); - sa.sa_handler = (void*) maru_sighandler; - sigemptyset(&sa.sa_mask); - sa.sa_flags = SA_RESTART; - sigaction(SIGSEGV, &sa, NULL); - sigaction(SIGBUS, &sa, NULL); - sigaction(SIGILL, &sa, NULL); - sigaction(SIGFPE, &sa, NULL); - sigaction(SIGABRT, &sa, NULL); - // main thread only - sigaction(SIGTERM, &sa, NULL); - sigaction(SIGINT, &sa, NULL); - #endif -} -#else // CONFIG_DARWIN -void register_exception_handler(void) -{ - // TODO: Exception handling on darwin -} -#endif diff --git a/tizen/src/util/maru_err_table.h b/tizen/src/util/maru_err_table.h deleted file mode 100644 index f7f8b81072..0000000000 --- a/tizen/src/util/maru_err_table.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Error message - * - * Copyright (C) 2011, 2012 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * SeokYeon Hwang - * GiWoong Kim - * YeongKyoon Lee - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - - -#ifndef __EMUL_ERR_TABLE_H__ -#define __EMUL_ERR_TABLE_H__ - -#include "tizen/src/skin/maruskin_client.h" - -/* TODO: define macro for fair of definition */ -/* This enum must match the table definition */ -enum { - /* 0 */ MARU_EXIT_UNKNOWN = 0, - /* 1 */ MARU_EXIT_MEMORY_EXCEPTION, - /* 2 */ MARU_EXIT_KERNEL_FILE_EXCEPTION, - /* 3 */ MARU_EXIT_BIOS_FILE_EXCEPTION, - /* 4 */ MARU_EXIT_SKIN_SERVER_FAILED, - /* 5 */ MARU_EXIT_HB_TIME_EXPIRED, - /* add here.. */ - MARU_EXIT_NORMAL -}; - - -char *get_canonical_path(char const *const path); -void maru_register_exit_msg(int maru_exit_status, char const *format, ...); -void register_exception_handler(void); -void handle_error_at_exit(void); - -#endif /* __EMUL_ERR_TABLE_H__ */ diff --git a/tizen/src/util/maru_util_strings.h b/tizen/src/util/maru_util_strings.h deleted file mode 100644 index 4bae1c221e..0000000000 --- a/tizen/src/util/maru_util_strings.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * The strings for the emulator messages - * - * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * Sooyoung Ha - * GiWoong Kim - * SeokYeon Hwang - * Sangho Park - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - - -#ifndef __MARU_UTIL_STRINGS_H__ -#define __MARU_UTIL_STRINGS_H__ - -#define FAILED_TO_ALLOCATE_MEMORY "Failed to allocate memory in qemu." -#define FAILED_TO_LOAD_KERNEL "Failed to load a kernel file the following path." -#define FAILED_TO_LOAD_BIOS "Failed to load a bios file in bios path that mentioned on document." -#define FAILED_TO_LOAD_DISK "Failed to load disk file from the following path." -#define CHECK_FILE_VALID " Check if the file is corrupted or missing.\n\n" -#define FAILED_TO_INITIAL_SKIN "Skin process cannot be initialized. Skin server is not ready." -#define FAILED_TO_INSTALL_EXTRAPACKAGE_1 "Extra package installation is failed.\n" -#define FAILED_TO_INSTALL_EXTRAPACKAGE_2 " must be installed MANUALLY!" -#define EMULATOR_HAS_STOPPED "Emulator has stopped working.\nA problem caused the program to stop working correctly." -#define NO_ACCELERATOR_FOUND "No accelerator found." - -#endif /* __MARU_UTIL_STRINGS_H__ */ diff --git a/tizen/src/util/osutil-darwin.c b/tizen/src/util/osutil-darwin.c index ee7e1943a3..4fc31e28e0 100644 --- a/tizen/src/util/osutil-darwin.c +++ b/tizen/src/util/osutil-darwin.c @@ -39,7 +39,6 @@ #include "emulator.h" #include "emul_state.h" #include "debug_ch.h" -#include "maru_err_table.h" #include "sdb.h" #include "emulator_options.h" diff --git a/tizen/src/util/osutil-linux.c b/tizen/src/util/osutil-linux.c index b940fd11a5..9f0ac30787 100644 --- a/tizen/src/util/osutil-linux.c +++ b/tizen/src/util/osutil-linux.c @@ -35,11 +35,19 @@ */ #include +#include +#include +#include +#include +#include +#include +#include + +#include "qemu/error-report.h" + #include "osutil.h" #include "emulator.h" #include "emul_state.h" -#include "debug_ch.h" -#include "maru_err_table.h" #include "sdb.h" #include "emulator_options.h" @@ -47,14 +55,7 @@ #error #endif -#include -#include -#include -#include -#include -#include -#include - +#include "debug_ch.h" MULTI_DEBUG_CHANNEL(emulator, osutil); static int g_shmid; @@ -79,7 +80,7 @@ void check_vm_lock_os(void) val = shmctl(shm_id, IPC_STAT, &shm_info); if (val != -1) { - INFO("count of process that use shared memory : %d\n", + INFO("count of process that use shared memory: %d\n", shm_info.shm_nattch); if ((shm_info.shm_nattch > 0) && g_strcmp0(get_drive_image_file(), (char *)shm_addr) == 0) { @@ -88,10 +89,9 @@ void check_vm_lock_os(void) continue; } shmdt(shm_addr); - maru_register_exit_msg(MARU_EXIT_UNKNOWN, - "Can not execute this VM.\n" - "The same name is running now."); - exit(0); + error_report("Can not execute this VM. " + "The same name is running now."); + exit(1); } else { shmdt(shm_addr); } diff --git a/tizen/src/util/osutil-win32.c b/tizen/src/util/osutil-win32.c index cc7f3276c3..d01e658e86 100644 --- a/tizen/src/util/osutil-win32.c +++ b/tizen/src/util/osutil-win32.c @@ -39,7 +39,6 @@ #include "osutil.h" #include "emulator.h" #include "emul_state.h" -#include "maru_err_table.h" #include "sdb.h" #include "emulator_options.h" @@ -48,6 +47,7 @@ #endif #include +#include "qemu/error-report.h" #include "debug_ch.h" MULTI_DEBUG_CHANNEL (emulator, osutil); @@ -79,8 +79,7 @@ void check_vm_lock_os(void) } if (strcmp(pBuf, get_drive_image_file()) == 0) { - maru_register_exit_msg(MARU_EXIT_UNKNOWN, - "Can not execute this VM.\n" + error_report("Can not execute this VM. " "The same name is running now."); UnmapViewOfFile(pBuf); CloseHandle(hMapFile); diff --git a/util/qemu-error.c b/util/qemu-error.c index 9bba5f53d8..abab065500 100644 --- a/util/qemu-error.c +++ b/util/qemu-error.c @@ -13,6 +13,26 @@ #include #include "monitor/monitor.h" +#ifdef CONFIG_MARU +static QLIST_HEAD(, ErrorReporter) error_reporters = + QLIST_HEAD_INITIALIZER(error_reporters); + +void add_error_reporter(ErrorReporter *new_reporter) +{ + QLIST_INSERT_HEAD(&error_reporters, new_reporter, node); +} + +static void report_to_clients(const char *fmt, va_list ap) +{ + ErrorReporter *reporter; + QLIST_FOREACH(reporter, &error_reporters, node) { + if (reporter->report) { + (*(reporter->report))(fmt, ap); + } + } +} +#endif + /* * Print to current monitor if we have one, else to stderr. * TODO should return int, so callers can calculate width, but that @@ -24,6 +44,9 @@ void error_vprintf(const char *fmt, va_list ap) monitor_vprintf(cur_mon, fmt, ap); } else { vfprintf(stderr, fmt, ap); +#ifdef CONFIG_MARU + report_to_clients(fmt, ap); +#endif } } diff --git a/vl.c b/vl.c index e8891c920e..bbbe0f69e6 100644 --- a/vl.c +++ b/vl.c @@ -132,7 +132,6 @@ int qemu_main(int argc, char **argv, char **envp); #ifdef CONFIG_MARU #include "tizen/src/emulator.h" -#include "tizen/src/util/maru_err_table.h" #include "tizen/src/emul_state.h" #include "tizen/src/display/maru_display.h" #include "tizen/src/skin/maruskin_operation.h" @@ -2223,9 +2222,8 @@ static DisplayType select_display(const char *p) display = DT_MARU_QT_ONSCREEN; } # else - fprintf(stderr, "maru_qt is disabled\n"); + error_report("maru_qt is disabled.\n"); - maru_register_exit_msg(MARU_EXIT_UNKNOWN, "maru_qt is disabled"); exit(1); # endif #endif /* CONFIG_MARU */ @@ -2697,9 +2695,6 @@ static const QEMUOption *lookup_opt(int argc, char **argv, for(;;) { if (!popt->name) { error_report("invalid option"); -#ifdef CONFIG_MARU - maru_register_exit_msg(MARU_EXIT_UNKNOWN, "invalid option."); -#endif exit(1); } if (!strcmp(popt->name, r + 1)) @@ -2709,9 +2704,6 @@ static const QEMUOption *lookup_opt(int argc, char **argv, if (popt->flags & HAS_ARG) { if (optind >= argc) { error_report("requires an argument"); -#ifdef CONFIG_MARU - maru_register_exit_msg(MARU_EXIT_UNKNOWN, "requires an argument."); -#endif exit(1); } optarg = argv[optind++];