From a02a5946b009c67781d2db79197dc208f0d12fc5 Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: <8d140e6fe679a73fd193609be44d508f17f7892b.1350045285.git.minovotn@redhat.com> References: <8d140e6fe679a73fd193609be44d508f17f7892b.1350045285.git.minovotn@redhat.com> From: Luiz Capitulino Date: Thu, 11 Oct 2012 18:24:19 +0200 Subject: [PATCH 07/12] qerror: OpenFileFailed: add __com.redhat_error_message key RH-Author: Luiz Capitulino Message-id: <1349979864-509-2-git-send-email-lcapitulino@redhat.com> Patchwork-id: 42992 O-Subject: [RHEL6.4 qemu-kvm PATCH 1/6] qerror: OpenFileFailed: add __com.redhat_error_message key Bugzilla: 806775 RH-Acked-by: Laszlo Ersek RH-Acked-by: Paolo Bonzini RH-Acked-by: Pavel Hrdina It's a string that will be used by callers to pass the error message returned by strerror(). Right now callers pass "", as qerror doesn't support passing NULL. Next commits will convert them to pass the real error message. Signed-off-by: Luiz Capitulino --- blockdev.c | 10 +++++----- dump.c | 2 +- monitor.c | 4 ++-- qerror.c | 2 +- qerror.h | 2 +- qga/commands-posix.c | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) Signed-off-by: Michal Novotny --- blockdev.c | 10 +++++----- dump.c | 2 +- monitor.c | 4 ++-- qerror.c | 2 +- qerror.h | 2 +- qga/commands-posix.c | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/blockdev.c b/blockdev.c index 2028a74..4b705de 100644 --- a/blockdev.c +++ b/blockdev.c @@ -771,9 +771,9 @@ void qmp___com_redhat_drive_reopen(const char *device, const char *new_image_fil if (ret != 0) { ret = bdrv_open(bs, old_filename, flags, old_drv); if (ret != 0) { - error_set(errp, QERR_OPEN_FILE_FAILED, old_filename); + error_set(errp, QERR_OPEN_FILE_FAILED, old_filename, ""); } else { - error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file); + error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file, ""); } } } @@ -992,7 +992,7 @@ void qmp_transaction(BlockdevActionList *dev_list, Error **errp) } if (ret) { - error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file); + error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file, ""); goto delete_and_fail; } @@ -1022,7 +1022,7 @@ void qmp_transaction(BlockdevActionList *dev_list, Error **errp) } if (ret != 0) { - error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file); + error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file, ""); goto delete_and_fail; } } @@ -1166,7 +1166,7 @@ int do_change_block(Monitor *mon, const char *device, bdrv_flags = bdrv_get_type_hint(bs) == BDRV_TYPE_CDROM ? 0 : BDRV_O_RDWR; bdrv_flags |= bdrv_is_snapshot(bs) ? BDRV_O_SNAPSHOT : 0; if (bdrv_open(bs, filename, bdrv_flags, drv)) { - qerror_report(QERR_OPEN_FILE_FAILED, filename); + qerror_report(QERR_OPEN_FILE_FAILED, filename, ""); return -1; } return monitor_read_bdrv_key_start(mon, bs, NULL, NULL); diff --git a/dump.c b/dump.c index 21c732e..3dc5311 100644 --- a/dump.c +++ b/dump.c @@ -840,7 +840,7 @@ void qmp_dump_guest_memory(bool paging, const char *file, bool has_begin, if (strstart(file, "file:", &p)) { fd = qemu_open(p, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRUSR); if (fd < 0) { - error_set(errp, QERR_OPEN_FILE_FAILED, p); + error_set(errp, QERR_OPEN_FILE_FAILED, p, ""); return; } } diff --git a/monitor.c b/monitor.c index 8b1c337..14a84e9 100644 --- a/monitor.c +++ b/monitor.c @@ -1744,7 +1744,7 @@ static int do_memory_save(Monitor *mon, const QDict *qdict, QObject **ret_data) f = fopen(filename, "wb"); if (!f) { - qerror_report(QERR_OPEN_FILE_FAILED, filename); + qerror_report(QERR_OPEN_FILE_FAILED, filename, ""); return -1; } while (size != 0) { @@ -1780,7 +1780,7 @@ static int do_physical_memory_save(Monitor *mon, const QDict *qdict, f = fopen(filename, "wb"); if (!f) { - qerror_report(QERR_OPEN_FILE_FAILED, filename); + qerror_report(QERR_OPEN_FILE_FAILED, filename, ""); return -1; } while (size != 0) { diff --git a/qerror.c b/qerror.c index 430692c..4d39339 100644 --- a/qerror.c +++ b/qerror.c @@ -191,7 +191,7 @@ static const QErrorStringTable qerror_table[] = { }, { .error_fmt = QERR_OPEN_FILE_FAILED, - .desc = "Could not open '%(filename)'", + .desc = "Could not open '%(filename)': %(__com.redhat_error_message)", }, { .error_fmt = QERR_PROPERTY_NOT_FOUND, diff --git a/qerror.h b/qerror.h index 05a2d0e..e4bf670 100644 --- a/qerror.h +++ b/qerror.h @@ -164,7 +164,7 @@ QError *qobject_to_qerror(const QObject *obj); "{ 'class': 'NotSupported', 'data': {} }" #define QERR_OPEN_FILE_FAILED \ - "{ 'class': 'OpenFileFailed', 'data': { 'filename': %s } }" + "{ 'class': 'OpenFileFailed', 'data': { 'filename': %s, '__com.redhat_error_message': %s } }" #define QERR_PROPERTY_NOT_FOUND \ "{ 'class': 'PropertyNotFound', 'data': { 'device': %s, 'property': %s } }" diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 249e1d4..f04cbd3 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -135,7 +135,7 @@ int64_t qmp_guest_file_open(const char *path, bool has_mode, const char *mode, E slog("guest-file-open called, filepath: %s, mode: %s", path, mode); fh = fopen(path, mode); if (!fh) { - error_set(err, QERR_OPEN_FILE_FAILED, path); + error_set(err, QERR_OPEN_FILE_FAILED, path, ""); return -1; } -- 1.7.11.7