diff options
| author | Peter Maydell | 2019-04-24 12:55:48 +0200 |
|---|---|---|
| committer | Peter Maydell | 2019-04-24 12:55:50 +0200 |
| commit | c4e9f845f6248885ff73a9e1ecb74052a1c3dcd4 (patch) | |
| tree | 279a6b792989bc2bfd9b5e08b5df4cf65e098b74 /block | |
| parent | Open 4.1 development tree (diff) | |
| parent | include: Move fprintf_function to disas/ (diff) | |
| download | qemu-c4e9f845f6248885ff73a9e1ecb74052a1c3dcd4.tar.gz qemu-c4e9f845f6248885ff73a9e1ecb74052a1c3dcd4.tar.xz qemu-c4e9f845f6248885ff73a9e1ecb74052a1c3dcd4.zip | |
Merge remote-tracking branch 'remotes/armbru/tags/pull-error-monitor-2019-04-18' into staging
Error reporting & monitor patches for 2019-04-18
# gpg: Signature made Thu 18 Apr 2019 21:40:41 BST
# gpg: using RSA key 3870B400EB918653
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full]
# gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full]
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653
* remotes/armbru/tags/pull-error-monitor-2019-04-18: (36 commits)
include: Move fprintf_function to disas/
disas: Rename include/disas/bfd.h back to include/disas/dis-asm.h
monitor: Clean up how monitor_disas() funnels output to monitor
qom/cpu: Simplify how CPUClass:cpu_dump_state() prints
qemu-print: New qemu_fprintf(), qemu_vfprintf()
qom/cpu: Simplify how CPUClass::dump_statistics() prints
target/i386: Simplify how x86_cpu_dump_local_apic_state() prints
target: Clean up how the dump_mmu() print
target: Simplify how the TARGET_cpu_list() print
memory: Clean up how mtree_info() prints
block/qapi: Clean up how we print to monitor or stdout
qsp: Simplify how qsp_report() prints
tcg: Simplify how dump_drift_info() prints
tcg: Simplify how dump_exec_info() prints
tcg: Simplify how dump_opcount_info() prints
trace: Simplify how st_print_trace_file_status() prints
include: Include fprintf-fn.h only where needed
monitor: Simplify how -device/device_add print help
char-pty: Print "char device redirected" message to stdout
char: Make -chardev help print to stdout
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'block')
| -rw-r--r-- | block/qapi.c | 120 | ||||
| -rw-r--r-- | block/ssh.c | 38 | ||||
| -rw-r--r-- | block/trace-events | 3 |
3 files changed, 71 insertions, 90 deletions
diff --git a/block/qapi.c b/block/qapi.c index 21edab34fc..e3e74f898f 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -36,6 +36,7 @@ #include "qapi/qmp/qlist.h" #include "qapi/qmp/qnum.h" #include "qapi/qmp/qstring.h" +#include "qemu/qemu-print.h" #include "sysemu/block-backend.h" #include "qemu/cutils.h" @@ -660,8 +661,7 @@ static char *get_human_readable_size(char *buf, int buf_size, int64_t size) return buf; } -void bdrv_snapshot_dump(fprintf_function func_fprintf, void *f, - QEMUSnapshotInfo *sn) +void bdrv_snapshot_dump(QEMUSnapshotInfo *sn) { char buf1[128], date_buf[128], clock_buf[128]; struct tm tm; @@ -669,9 +669,8 @@ void bdrv_snapshot_dump(fprintf_function func_fprintf, void *f, int64_t secs; if (!sn) { - func_fprintf(f, - "%-10s%-20s%7s%20s%15s", - "ID", "TAG", "VM SIZE", "DATE", "VM CLOCK"); + qemu_printf("%-10s%-20s%7s%20s%15s", + "ID", "TAG", "VM SIZE", "DATE", "VM CLOCK"); } else { ti = sn->date_sec; localtime_r(&ti, &tm); @@ -684,50 +683,46 @@ void bdrv_snapshot_dump(fprintf_function func_fprintf, void *f, (int)((secs / 60) % 60), (int)(secs % 60), (int)((sn->vm_clock_nsec / 1000000) % 1000)); - func_fprintf(f, - "%-10s%-20s%7s%20s%15s", - sn->id_str, sn->name, - get_human_readable_size(buf1, sizeof(buf1), - sn->vm_state_size), - date_buf, - clock_buf); + qemu_printf("%-10s%-20s%7s%20s%15s", + sn->id_str, sn->name, + get_human_readable_size(buf1, sizeof(buf1), + sn->vm_state_size), + date_buf, + clock_buf); } } -static void dump_qdict(fprintf_function func_fprintf, void *f, int indentation, - QDict *dict); -static void dump_qlist(fprintf_function func_fprintf, void *f, int indentation, - QList *list); +static void dump_qdict(int indentation, QDict *dict); +static void dump_qlist(int indentation, QList *list); -static void dump_qobject(fprintf_function func_fprintf, void *f, - int comp_indent, QObject *obj) +static void dump_qobject(int comp_indent, QObject *obj) { switch (qobject_type(obj)) { case QTYPE_QNUM: { QNum *value = qobject_to(QNum, obj); char *tmp = qnum_to_string(value); - func_fprintf(f, "%s", tmp); + qemu_printf("%s", tmp); g_free(tmp); break; } case QTYPE_QSTRING: { QString *value = qobject_to(QString, obj); - func_fprintf(f, "%s", qstring_get_str(value)); + qemu_printf("%s", qstring_get_str(value)); break; } case QTYPE_QDICT: { QDict *value = qobject_to(QDict, obj); - dump_qdict(func_fprintf, f, comp_indent, value); + dump_qdict(comp_indent, value); break; } case QTYPE_QLIST: { QList *value = qobject_to(QList, obj); - dump_qlist(func_fprintf, f, comp_indent, value); + dump_qlist(comp_indent, value); break; } case QTYPE_QBOOL: { QBool *value = qobject_to(QBool, obj); - func_fprintf(f, "%s", qbool_get_bool(value) ? "true" : "false"); + qemu_printf("%s", qbool_get_bool(value) ? "true" : "false"); break; } default: @@ -735,8 +730,7 @@ static void dump_qobject(fprintf_function func_fprintf, void *f, } } -static void dump_qlist(fprintf_function func_fprintf, void *f, int indentation, - QList *list) +static void dump_qlist(int indentation, QList *list) { const QListEntry *entry; int i = 0; @@ -744,17 +738,16 @@ static void dump_qlist(fprintf_function func_fprintf, void *f, int indentation, for (entry = qlist_first(list); entry; entry = qlist_next(entry), i++) { QType type = qobject_type(entry->value); bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST); - func_fprintf(f, "%*s[%i]:%c", indentation * 4, "", i, - composite ? '\n' : ' '); - dump_qobject(func_fprintf, f, indentation + 1, entry->value); + qemu_printf("%*s[%i]:%c", indentation * 4, "", i, + composite ? '\n' : ' '); + dump_qobject(indentation + 1, entry->value); if (!composite) { - func_fprintf(f, "\n"); + qemu_printf("\n"); } } } -static void dump_qdict(fprintf_function func_fprintf, void *f, int indentation, - QDict *dict) +static void dump_qdict(int indentation, QDict *dict) { const QDictEntry *entry; @@ -769,18 +762,17 @@ static void dump_qdict(fprintf_function func_fprintf, void *f, int indentation, key[i] = entry->key[i] == '-' ? ' ' : entry->key[i]; } key[i] = 0; - func_fprintf(f, "%*s%s:%c", indentation * 4, "", key, - composite ? '\n' : ' '); - dump_qobject(func_fprintf, f, indentation + 1, entry->value); + qemu_printf("%*s%s:%c", indentation * 4, "", key, + composite ? '\n' : ' '); + dump_qobject(indentation + 1, entry->value); if (!composite) { - func_fprintf(f, "\n"); + qemu_printf("\n"); } g_free(key); } } -void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f, - ImageInfoSpecific *info_spec) +void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec) { QObject *obj, *data; Visitor *v = qobject_output_visitor_new(&obj); @@ -788,13 +780,12 @@ void bdrv_image_info_specific_dump(fprintf_function func_fprintf, void *f, visit_type_ImageInfoSpecific(v, NULL, &info_spec, &error_abort); visit_complete(v, &obj); data = qdict_get(qobject_to(QDict, obj), "data"); - dump_qobject(func_fprintf, f, 1, data); + dump_qobject(1, data); qobject_unref(obj); visit_free(v); } -void bdrv_image_info_dump(fprintf_function func_fprintf, void *f, - ImageInfo *info) +void bdrv_image_info_dump(ImageInfo *info) { char size_buf[128], dsize_buf[128]; if (!info->has_actual_size) { @@ -804,49 +795,48 @@ void bdrv_image_info_dump(fprintf_function func_fprintf, void *f, info->actual_size); } get_human_readable_size(size_buf, sizeof(size_buf), info->virtual_size); - func_fprintf(f, - "image: %s\n" - "file format: %s\n" - "virtual size: %s (%" PRId64 " bytes)\n" - "disk size: %s\n", - info->filename, info->format, size_buf, - info->virtual_size, - dsize_buf); + qemu_printf("image: %s\n" + "file format: %s\n" + "virtual size: %s (%" PRId64 " bytes)\n" + "disk size: %s\n", + info->filename, info->format, size_buf, + info->virtual_size, + dsize_buf); if (info->has_encrypted && info->encrypted) { - func_fprintf(f, "encrypted: yes\n"); + qemu_printf("encrypted: yes\n"); } if (info->has_cluster_size) { - func_fprintf(f, "cluster_size: %" PRId64 "\n", - info->cluster_size); + qemu_printf("cluster_size: %" PRId64 "\n", + info->cluster_size); } if (info->has_dirty_flag && info->dirty_flag) { - func_fprintf(f, "cleanly shut down: no\n"); + qemu_printf("cleanly shut down: no\n"); } if (info->has_backing_filename) { - func_fprintf(f, "backing file: %s", info->backing_filename); + qemu_printf("backing file: %s", info->backing_filename); if (!info->has_full_backing_filename) { - func_fprintf(f, " (cannot determine actual path)"); + qemu_printf(" (cannot determine actual path)"); } else if (strcmp(info->backing_filename, info->full_backing_filename) != 0) { - func_fprintf(f, " (actual path: %s)", info->full_backing_filename); + qemu_printf(" (actual path: %s)", info->full_backing_filename); } - func_fprintf(f, "\n"); + qemu_printf("\n"); if (info->has_backing_filename_format) { - func_fprintf(f, "backing file format: %s\n", - info->backing_filename_format); + qemu_printf("backing file format: %s\n", + info->backing_filename_format); } } if (info->has_snapshots) { SnapshotInfoList *elem; - func_fprintf(f, "Snapshot list:\n"); - bdrv_snapshot_dump(func_fprintf, f, NULL); - func_fprintf(f, "\n"); + qemu_printf("Snapshot list:\n"); + bdrv_snapshot_dump(NULL); + qemu_printf("\n"); /* Ideally bdrv_snapshot_dump() would operate on SnapshotInfoList but * we convert to the block layer's native QEMUSnapshotInfo for now. @@ -862,13 +852,13 @@ void bdrv_image_info_dump(fprintf_function func_fprintf, void *f, pstrcpy(sn.id_str, sizeof(sn.id_str), elem->value->id); pstrcpy(sn.name, sizeof(sn.name), elem->value->name); - bdrv_snapshot_dump(func_fprintf, f, &sn); - func_fprintf(f, "\n"); + bdrv_snapshot_dump(&sn); + qemu_printf("\n"); } } if (info->has_format_specific) { - func_fprintf(f, "Format specific information:\n"); - bdrv_image_info_specific_dump(func_fprintf, f, info->format_specific); + qemu_printf("Format specific information:\n"); + bdrv_image_info_specific_dump(info->format_specific); } } diff --git a/block/ssh.c b/block/ssh.c index 190ef95300..859249113d 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -159,31 +159,19 @@ sftp_error_setg(Error **errp, BDRVSSHState *s, const char *fs, ...) g_free(msg); } -static void GCC_FMT_ATTR(2, 3) -sftp_error_report(BDRVSSHState *s, const char *fs, ...) +static void sftp_error_trace(BDRVSSHState *s, const char *op) { - va_list args; - - va_start(args, fs); - error_vprintf(fs, args); + char *ssh_err; + int ssh_err_code; + unsigned long sftp_err_code; - if ((s)->sftp) { - char *ssh_err; - int ssh_err_code; - unsigned long sftp_err_code; + /* This is not an errno. See <libssh2.h>. */ + ssh_err_code = libssh2_session_last_error(s->session, + &ssh_err, NULL, 0); + /* See <libssh2_sftp.h>. */ + sftp_err_code = libssh2_sftp_last_error((s)->sftp); - /* This is not an errno. See <libssh2.h>. */ - ssh_err_code = libssh2_session_last_error(s->session, - &ssh_err, NULL, 0); - /* See <libssh2_sftp.h>. */ - sftp_err_code = libssh2_sftp_last_error((s)->sftp); - - error_printf(": %s (libssh2 error code: %d, sftp error code: %lu)", - ssh_err, ssh_err_code, sftp_err_code); - } - - va_end(args); - error_printf("\n"); + trace_sftp_error(op, ssh_err, ssh_err_code, sftp_err_code); } static int parse_uri(const char *filename, QDict *options, Error **errp) @@ -1035,7 +1023,7 @@ static coroutine_fn int ssh_read(BDRVSSHState *s, BlockDriverState *bs, goto again; } if (r < 0) { - sftp_error_report(s, "read failed"); + sftp_error_trace(s, "read"); s->offset = -1; return -EIO; } @@ -1105,7 +1093,7 @@ static int ssh_write(BDRVSSHState *s, BlockDriverState *bs, goto again; } if (r < 0) { - sftp_error_report(s, "write failed"); + sftp_error_trace(s, "write"); s->offset = -1; return -EIO; } @@ -1188,7 +1176,7 @@ static coroutine_fn int ssh_flush(BDRVSSHState *s, BlockDriverState *bs) return 0; } if (r < 0) { - sftp_error_report(s, "fsync failed"); + sftp_error_trace(s, "fsync"); return -EIO; } diff --git a/block/trace-events b/block/trace-events index 7335a42540..79ccd8d824 100644 --- a/block/trace-events +++ b/block/trace-events @@ -208,3 +208,6 @@ sheepdog_co_rw_vector_new(uint64_t oid) "new oid 0x%" PRIx64 sheepdog_snapshot_create_info(const char *sn_name, const char *id, const char *name, int64_t size, int is_snapshot) "sn_info: name %s id_str %s s: name %s vm_state_size %" PRId64 " " "is_snapshot %d" sheepdog_snapshot_create(const char *sn_name, const char *id) "%s %s" sheepdog_snapshot_create_inode(const char *name, uint32_t snap, uint32_t vdi) "s->inode: name %s snap_id 0x%" PRIx32 " vdi 0x%" PRIx32 + +# ssh.c +sftp_error(const char *op, const char *ssh_err, int ssh_err_code, unsigned long sftp_err_code) "%s failed: %s (libssh2 error code: %d, sftp error code: %lu)" |
