[libvirt] [PATCH] migration: Add more specific error code/message on migration abort

A generic error code was returned, if the user aborted a migration job. This made it hard to distinguish between a user requested abort and an error that might have occured. This patch introduces a new error code, which is returned if a migration API call fails. This makes it easier to distinguish between failure while mirgrating and an user requested abort. * include/libvirt/virterror.h: - add new error code * src/util/virterror.c: - add message for the new error code * src/qemu/qemu_migration.h: - Emit operation aborted error instead of operation failed, on migration abort --- include/libvirt/virterror.h | 2 ++ src/qemu/qemu_migration.c | 2 +- src/util/virterror.c | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletions(-) diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h index 7063ef6..e896d67 100644 --- a/include/libvirt/virterror.h +++ b/include/libvirt/virterror.h @@ -241,6 +241,8 @@ typedef enum { VIR_ERR_STORAGE_POOL_BUILT = 76, /* storage pool already built */ VIR_ERR_SNAPSHOT_REVERT_RISKY = 77, /* force was not requested for a risky domain snapshot revert */ + VIR_ERR_OPERATION_ABORTED = 78, /* operation on a domain was + canceled/aborted by user */ } virErrorNumber; /** diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 8c4ecc8..7e4135b 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -905,7 +905,7 @@ qemuMigrationUpdateJobStatus(struct qemud_driver *driver, case QEMU_MONITOR_MIGRATION_STATUS_CANCELLED: priv->job.info.type = VIR_DOMAIN_JOB_CANCELLED; - qemuReportError(VIR_ERR_OPERATION_FAILED, + qemuReportError(VIR_ERR_OPERATION_ABORTED, _("%s: %s"), job, _("canceled by client")); break; } diff --git a/src/util/virterror.c b/src/util/virterror.c index 44a276a..380dc56 100644 --- a/src/util/virterror.c +++ b/src/util/virterror.c @@ -1213,6 +1213,12 @@ virErrorMsg(virErrorNumber error, const char *info) else errmsg = _("revert requires force: %s"); break; + case VIR_ERR_OPERATION_ABORTED: + if (info == NULL) + errmsg = _("operation aborted"); + else + errmsg = _("operation aborted: %s"); + break; } return (errmsg); } -- 1.7.3.4

On 12/16/2011 07:14 AM, Peter Krempa wrote:
A generic error code was returned, if the user aborted a migration job. This made it hard to distinguish between a user requested abort and an error that might have occured. This patch introduces a new error code,
s/occured/occurred/
which is returned if a migration API call fails. This makes it easier to
That wording didn't quite make sense to me - you made it sound like arbitrary failure gets the new error value. Maybe a better wording would be: This patch introduces a new error code, which is returned in the specific case of a user abort, while leaving all other failures with their existing code.
distinguish between failure while mirgrating and an user requested abort.
* include/libvirt/virterror.h: - add new error code * src/util/virterror.c: - add message for the new error code * src/qemu/qemu_migration.h: - Emit operation aborted error instead of operation failed, on migration abort --- include/libvirt/virterror.h | 2 ++ src/qemu/qemu_migration.c | 2 +- src/util/virterror.c | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletions(-)
ACK. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 12/16/2011 04:19 PM, Eric Blake wrote:
On 12/16/2011 07:14 AM, Peter Krempa wrote:
A generic error code was returned, if the user aborted a migration job. This made it hard to distinguish between a user requested abort and an error that might have occured. This patch introduces a new error code,
s/occured/occurred/
which is returned if a migration API call fails. This makes it easier to
That wording didn't quite make sense to me - you made it sound like arbitrary failure gets the new error value. Maybe a better wording would be:
This patch introduces a new error code, which is returned in the specific case of a user abort, while leaving all other failures with their existing code.
distinguish between failure while mirgrating and an user requested abort.
* include/libvirt/virterror.h: - add new error code * src/util/virterror.c: - add message for the new error code * src/qemu/qemu_migration.h: - Emit operation aborted error instead of operation failed, on migration abort --- include/libvirt/virterror.h | 2 ++ src/qemu/qemu_migration.c | 2 +- src/util/virterror.c | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletions(-)
ACK.
Thanks. I fixed the typo and wording of the sentence (It really didn't make much sense :( ) and pushed. Peter
participants (2)
-
Eric Blake
-
Peter Krempa