From f8903dd0a4a9f273770afec9252f8675e9284df6 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Wed, 21 Apr 2010 09:23:43 -0300 Subject: [PATCH 25/66] error: Rename qemu_error_new() to qerror_report() RH-Author: Markus Armbruster Message-id: Patchwork-id: 8755 O-Subject: [PATCH 25/66 v2] error: Rename qemu_error_new() to qerror_report() Bugzilla: 579470 RH-Acked-by: Luiz Capitulino RH-Acked-by: Kevin Wolf RH-Acked-by: Juan Quintela (cherry picked from commit ab5b027ee645f26320379d1d80cd96fdc944ecb5) Conflicts: monitor.c spice.c manually backported. Signed-off-by: Markus Armbruster --- v2: new spice.c, trivially rediff the rest hw/qdev.c | 2 +- monitor.c | 82 +++++++++++++++++++++++++++++----------------------------- qemu-error.c | 6 ++-- qemu-error.h | 10 +++--- spice.c | 14 +++++----- 5 files changed, 57 insertions(+), 57 deletions(-) Signed-off-by: Eduardo Habkost --- hw/qdev.c | 2 +- monitor.c | 82 +++++++++++++++++++++++++++++----------------------------- qemu-error.c | 6 ++-- qemu-error.h | 10 +++--- spice.c | 14 +++++----- 5 files changed, 57 insertions(+), 57 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 98123e6..8bf86a5 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -191,7 +191,7 @@ DeviceState *qdev_device_add(QemuOpts *opts) /* find driver */ info = qdev_find_info(NULL, driver); if (!info) { - qemu_error_new(QERR_DEVICE_NOT_FOUND, driver); + qerror_report(QERR_DEVICE_NOT_FOUND, driver); return NULL; } if (info->no_user) { diff --git a/monitor.c b/monitor.c index f35b968..048c043 100644 --- a/monitor.c +++ b/monitor.c @@ -215,7 +215,7 @@ static int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func, void *opaque) { if (monitor_ctrl_mode(mon)) { - qemu_error_new(QERR_MISSING_PARAMETER, "password"); + qerror_report(QERR_MISSING_PARAMETER, "password"); return -EINVAL; } else if (mon->rs) { readline_start(mon->rs, "Password: ", 1, readline_func, opaque); @@ -620,7 +620,7 @@ static int do_info(Monitor *mon, const QDict *qdict, QObject **ret_data) if (cmd->name == NULL) { if (monitor_ctrl_mode(mon)) { - qemu_error_new(QERR_COMMAND_NOT_FOUND, item); + qerror_report(QERR_COMMAND_NOT_FOUND, item); return -1; } goto help; @@ -652,7 +652,7 @@ static int do_info(Monitor *mon, const QDict *qdict, QObject **ret_data) } else { if (monitor_ctrl_mode(mon)) { /* handler not converted yet */ - qemu_error_new(QERR_COMMAND_NOT_FOUND, item); + qerror_report(QERR_COMMAND_NOT_FOUND, item); return -1; } else { cmd->mhandler.info(mon); @@ -978,7 +978,7 @@ static int do_cpu_set(Monitor *mon, const QDict *qdict, QObject **ret_data) { int index = qdict_get_int(qdict, "index"); if (mon_set_cpu(index) < 0) { - qemu_error_new(QERR_INVALID_PARAMETER, "index"); + qerror_report(QERR_INVALID_PARAMETER, "index"); return -1; } return 0; @@ -1052,12 +1052,12 @@ static int eject_device(Monitor *mon, BlockDriverState *bs, int force) if (bdrv_is_inserted(bs)) { if (!force) { if (!bdrv_is_removable(bs)) { - qemu_error_new(QERR_DEVICE_NOT_REMOVABLE, + qerror_report(QERR_DEVICE_NOT_REMOVABLE, bdrv_get_device_name(bs)); return -1; } if (bdrv_is_locked(bs)) { - qemu_error_new(QERR_DEVICE_LOCKED, bdrv_get_device_name(bs)); + qerror_report(QERR_DEVICE_LOCKED, bdrv_get_device_name(bs)); return -1; } } @@ -1074,7 +1074,7 @@ static int do_eject(Monitor *mon, const QDict *qdict, QObject **ret_data) bs = bdrv_find(filename); if (!bs) { - qemu_error_new(QERR_DEVICE_NOT_FOUND, filename); + qerror_report(QERR_DEVICE_NOT_FOUND, filename); return -1; } return eject_device(mon, bs, force); @@ -1088,16 +1088,16 @@ static int do_block_set_passwd(Monitor *mon, const QDict *qdict, bs = bdrv_find(qdict_get_str(qdict, "device")); if (!bs) { - qemu_error_new(QERR_DEVICE_NOT_FOUND, qdict_get_str(qdict, "device")); + qerror_report(QERR_DEVICE_NOT_FOUND, qdict_get_str(qdict, "device")); return -1; } err = bdrv_set_key(bs, qdict_get_str(qdict, "password")); if (err == -EINVAL) { - qemu_error_new(QERR_DEVICE_NOT_ENCRYPTED, bdrv_get_device_name(bs)); + qerror_report(QERR_DEVICE_NOT_ENCRYPTED, bdrv_get_device_name(bs)); return -1; } else if (err < 0) { - qemu_error_new(QERR_INVALID_PASSWORD); + qerror_report(QERR_INVALID_PASSWORD); return -1; } @@ -1112,13 +1112,13 @@ static int do_change_block(Monitor *mon, const char *device, bs = bdrv_find(device); if (!bs) { - qemu_error_new(QERR_DEVICE_NOT_FOUND, device); + qerror_report(QERR_DEVICE_NOT_FOUND, device); return -1; } if (fmt) { drv = bdrv_find_whitelisted_format(fmt); if (!drv) { - qemu_error_new(QERR_INVALID_BLOCK_FORMAT, fmt); + qerror_report(QERR_INVALID_BLOCK_FORMAT, fmt); return -1; } } @@ -1134,7 +1134,7 @@ static int do_change_block(Monitor *mon, const char *device, static int change_vnc_password(const char *password) { if (vnc_display_password(NULL, password, 0) < 0) { - qemu_error_new(QERR_SET_PASSWD_FAILED); + qerror_report(QERR_SET_PASSWD_FAILED); return -1; } @@ -1162,7 +1162,7 @@ static int do_change_vnc(Monitor *mon, const char *target, const char *arg) } } else { if (vnc_display_open(NULL, target) < 0) { - qemu_error_new(QERR_VNC_SERVER_FAILED, target); + qerror_report(QERR_VNC_SERVER_FAILED, target); return -1; } } @@ -1535,7 +1535,7 @@ static int do_memory_save(Monitor *mon, const QDict *qdict, QObject **ret_data) f = fopen(filename, "wb"); if (!f) { - qemu_error_new(QERR_OPEN_FILE_FAILED, filename); + qerror_report(QERR_OPEN_FILE_FAILED, filename); return -1; } while (size != 0) { @@ -1571,7 +1571,7 @@ static int do_physical_memory_save(Monitor *mon, const QDict *qdict, f = fopen(filename, "wb"); if (!f) { - qemu_error_new(QERR_OPEN_FILE_FAILED, filename); + qerror_report(QERR_OPEN_FILE_FAILED, filename); return -1; } while (size != 0) { @@ -2348,13 +2348,13 @@ static int do_info_balloon(Monitor *mon, MonitorCompletion cb, void *opaque) int ret; if (kvm_enabled() && !kvm_has_sync_mmu()) { - qemu_error_new(QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon"); + qerror_report(QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon"); return -1; } ret = qemu_balloon_status(cb, opaque); if (!ret) { - qemu_error_new(QERR_DEVICE_NOT_ACTIVE, "balloon"); + qerror_report(QERR_DEVICE_NOT_ACTIVE, "balloon"); return -1; } @@ -2370,13 +2370,13 @@ static int do_balloon(Monitor *mon, const QDict *params, int ret; if (kvm_enabled() && !kvm_has_sync_mmu()) { - qemu_error_new(QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon"); + qerror_report(QERR_KVM_MISSING_CAP, "synchronous MMU", "balloon"); return -1; } ret = qemu_balloon(qdict_get_int(params, "value"), cb, opaque); if (ret == 0) { - qemu_error_new(QERR_DEVICE_NOT_ACTIVE, "balloon"); + qerror_report(QERR_DEVICE_NOT_ACTIVE, "balloon"); return -1; } @@ -2517,21 +2517,21 @@ static int do_getfd(Monitor *mon, const QDict *qdict, QObject **ret_data) fd = qemu_chr_get_msgfd(mon->chr); if (fd == -1) { - qemu_error_new(QERR_FD_NOT_SUPPLIED); + qerror_report(QERR_FD_NOT_SUPPLIED); return -1; } if (qemu_isdigit(fdname[0])) { - qemu_error_new(QERR_INVALID_PARAMETER, "fdname"); + qerror_report(QERR_INVALID_PARAMETER, "fdname"); return -1; } fd = dup(fd); if (fd == -1) { if (errno == EMFILE) - qemu_error_new(QERR_TOO_MANY_FILES); + qerror_report(QERR_TOO_MANY_FILES); else - qemu_error_new(QERR_UNDEFINED_ERROR); + qerror_report(QERR_UNDEFINED_ERROR); return -1; } @@ -2570,7 +2570,7 @@ static int do_closefd(Monitor *mon, const QDict *qdict, QObject **ret_data) return 0; } - qemu_error_new(QERR_FD_NOT_FOUND, fdname); + qerror_report(QERR_FD_NOT_FOUND, fdname); return -1; } @@ -3941,7 +3941,7 @@ static void handler_audit(Monitor *mon, const mon_cmd_t *cmd, int ret) * Action: Report an internal error to the client if in QMP. */ if (monitor_ctrl_mode(mon)) { - qemu_error_new(QERR_UNDEFINED_ERROR); + qerror_report(QERR_UNDEFINED_ERROR); } MON_DEBUG("command '%s' returned failure but did not pass an error\n", cmd->name); @@ -4264,7 +4264,7 @@ typedef struct CmdArgs { static int check_opt(const CmdArgs *cmd_args, const char *name, QDict *args) { if (!cmd_args->optional) { - qemu_error_new(QERR_MISSING_PARAMETER, name); + qerror_report(QERR_MISSING_PARAMETER, name); return -1; } @@ -4297,7 +4297,7 @@ static int check_arg(const CmdArgs *cmd_args, QDict *args) case 'B': case 's': if (qobject_type(value) != QTYPE_QSTRING) { - qemu_error_new(QERR_INVALID_PARAMETER_TYPE, name, "string"); + qerror_report(QERR_INVALID_PARAMETER_TYPE, name, "string"); return -1; } break; @@ -4308,11 +4308,11 @@ static int check_arg(const CmdArgs *cmd_args, QDict *args) for (i = 0; keys[i]; i++) { QObject *obj = qdict_get(args, keys[i]); if (!obj) { - qemu_error_new(QERR_MISSING_PARAMETER, name); + qerror_report(QERR_MISSING_PARAMETER, name); return -1; } if (qobject_type(obj) != QTYPE_QINT) { - qemu_error_new(QERR_INVALID_PARAMETER_TYPE, name, "int"); + qerror_report(QERR_INVALID_PARAMETER_TYPE, name, "int"); return -1; } } @@ -4322,21 +4322,21 @@ static int check_arg(const CmdArgs *cmd_args, QDict *args) case 'l': case 'M': if (qobject_type(value) != QTYPE_QINT) { - qemu_error_new(QERR_INVALID_PARAMETER_TYPE, name, "int"); + qerror_report(QERR_INVALID_PARAMETER_TYPE, name, "int"); return -1; } break; case 'b': case 'T': if (qobject_type(value) != QTYPE_QINT && qobject_type(value) != QTYPE_QFLOAT) { - qemu_error_new(QERR_INVALID_PARAMETER_TYPE, name, "number"); + qerror_report(QERR_INVALID_PARAMETER_TYPE, name, "number"); return -1; } break; case '-': if (qobject_type(value) != QTYPE_QINT && qobject_type(value) != QTYPE_QBOOL) { - qemu_error_new(QERR_INVALID_PARAMETER_TYPE, name, "bool"); + qerror_report(QERR_INVALID_PARAMETER_TYPE, name, "bool"); return -1; } if (qobject_type(value) == QTYPE_QBOOL) { @@ -4433,10 +4433,10 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens) obj = json_parser_parse(tokens, NULL); if (!obj) { // FIXME: should be triggered in json_parser_parse() - qemu_error_new(QERR_JSON_PARSING); + qerror_report(QERR_JSON_PARSING); goto err_out; } else if (qobject_type(obj) != QTYPE_QDICT) { - qemu_error_new(QERR_QMP_BAD_INPUT_OBJECT, "object"); + qerror_report(QERR_QMP_BAD_INPUT_OBJECT, "object"); qobject_decref(obj); goto err_out; } @@ -4448,17 +4448,17 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens) obj = qdict_get(input, "execute"); if (!obj) { - qemu_error_new(QERR_QMP_BAD_INPUT_OBJECT, "execute"); + qerror_report(QERR_QMP_BAD_INPUT_OBJECT, "execute"); goto err_input; } else if (qobject_type(obj) != QTYPE_QSTRING) { - qemu_error_new(QERR_QMP_BAD_INPUT_OBJECT, "string"); + qerror_report(QERR_QMP_BAD_INPUT_OBJECT, "string"); goto err_input; } cmd_name = qstring_get_str(qobject_to_qstring(obj)); if (invalid_qmp_mode(mon, cmd_name)) { - qemu_error_new(QERR_COMMAND_NOT_FOUND, cmd_name); + qerror_report(QERR_COMMAND_NOT_FOUND, cmd_name); goto err_input; } @@ -4467,7 +4467,7 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens) * converted into 'query-' commands */ if (compare_cmd(cmd_name, "info")) { - qemu_error_new(QERR_COMMAND_NOT_FOUND, cmd_name); + qerror_report(QERR_COMMAND_NOT_FOUND, cmd_name); goto err_input; } else if (strstart(cmd_name, "query-", &info_item)) { cmd = monitor_find_command("info"); @@ -4476,7 +4476,7 @@ static void handle_qmp_command(JSONMessageParser *parser, QList *tokens) } else { cmd = monitor_find_command(cmd_name); if (!cmd || !monitor_handler_ported(cmd)) { - qemu_error_new(QERR_COMMAND_NOT_FOUND, cmd_name); + qerror_report(QERR_COMMAND_NOT_FOUND, cmd_name); goto err_input; } } @@ -4709,7 +4709,7 @@ int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs, } if (monitor_ctrl_mode(mon)) { - qemu_error_new(QERR_DEVICE_ENCRYPTED, bdrv_get_device_name(bs)); + qerror_report(QERR_DEVICE_ENCRYPTED, bdrv_get_device_name(bs)); return -1; } diff --git a/qemu-error.c b/qemu-error.c index 51e2abf..0a175d8 100644 --- a/qemu-error.c +++ b/qemu-error.c @@ -44,7 +44,7 @@ void error_printf(const char *fmt, ...) /* * Print an error message to current monitor if we have one, else to stderr. * Appends a newline to the message. - * It's wrong to call this in a QMP monitor. Use qemu_error_new() there. + * It's wrong to call this in a QMP monitor. Use qerror_report() there. */ void error_report(const char *fmt, ...) { @@ -56,8 +56,8 @@ void error_report(const char *fmt, ...) error_printf("\n"); } -void qemu_error_internal(const char *file, int linenr, const char *func, - const char *fmt, ...) +void qerror_report_internal(const char *file, int linenr, const char *func, + const char *fmt, ...) { va_list va; QError *qerror; diff --git a/qemu-error.h b/qemu-error.h index 99dfcce..5b05371 100644 --- a/qemu-error.h +++ b/qemu-error.h @@ -16,11 +16,11 @@ void error_vprintf(const char *fmt, va_list ap); void error_printf(const char *fmt, ...) __attribute__ ((format(printf, 1, 2))); void error_report(const char *fmt, ...) __attribute__ ((format(printf, 1, 2))); -void qemu_error_internal(const char *file, int linenr, const char *func, - const char *fmt, ...) - __attribute__ ((format(printf, 4, 5))); +void qerror_report_internal(const char *file, int linenr, const char *func, + const char *fmt, ...) + __attribute__ ((format(printf, 4, 5))); -#define qemu_error_new(fmt, ...) \ - qemu_error_internal(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__) +#define qerror_report(fmt, ...) \ + qerror_report_internal(__FILE__, __LINE__, __func__, fmt, ## __VA_ARGS__) #endif diff --git a/spice.c b/spice.c index 3a49f5c..c4fcaef 100644 --- a/spice.c +++ b/spice.c @@ -292,7 +292,7 @@ int mon_set_password(Monitor *mon, const QDict *qdict, QObject **ret_data) } else if (strcmp(connected, "keep") == 0) { /* nothing */ } else { - qemu_error_new(QERR_INVALID_PARAMETER, "connected"); + qerror_report(QERR_INVALID_PARAMETER, "connected"); return -1; } } @@ -300,30 +300,30 @@ int mon_set_password(Monitor *mon, const QDict *qdict, QObject **ret_data) if (strcmp(protocol, "spice") == 0) { if (!s) { /* correct one? spice isn't a device ,,, */ - qemu_error_new(QERR_DEVICE_NOT_ACTIVE, "spice"); + qerror_report(QERR_DEVICE_NOT_ACTIVE, "spice"); return -1; } rc = spice_server_set_ticket(s, password, lifetime, fail_if_connected, disconnect_if_connected); if (rc != 0) { - qemu_error_new(QERR_SET_PASSWD_FAILED); + qerror_report(QERR_SET_PASSWD_FAILED); return -1; } } else if (strcmp(protocol, "vnc") == 0) { if (fail_if_connected || disconnect_if_connected) { /* vnc supports "connected=keep" only */ - qemu_error_new(QERR_INVALID_PARAMETER, "connected"); + qerror_report(QERR_INVALID_PARAMETER, "connected"); return -1; } if (vnc_display_password(NULL, password, lifetime) < 0) { - qemu_error_new(QERR_SET_PASSWD_FAILED); + qerror_report(QERR_SET_PASSWD_FAILED); return -1; } } else { - qemu_error_new(QERR_INVALID_PARAMETER, "protocol"); + qerror_report(QERR_INVALID_PARAMETER, "protocol"); return -1; } @@ -338,7 +338,7 @@ int mon_spice_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data) int tls_port = qdict_get_try_int(qdict, "tls-port", -1); if (!s) { - qemu_error_new(QERR_DEVICE_NOT_ACTIVE, "spice"); + qerror_report(QERR_DEVICE_NOT_ACTIVE, "spice"); return -1; } -- 1.7.0.3