Convert do_migrate() to QError
cover Convert do_migrate() to QError
Markus Armbruster (3):
QError: New QERR_MIGRATION_IN_PROGRESS
QError: New QERR_MIGRATION_FAILED
monitor: Convert do_migrate() to QError
migration.c | 9 +++++---- qerror.c | 8 ++++++++ qerror.h | 6 ++++++ 3 files changed, 19 insertions(+), 4 deletions(-)
PATCH 1/3 QError: New QERR_MIGRATION_IN_PROGRESS
--- qerror.c | 4 ++++ qerror.h | 3 +++ 2 files changed, 7 insertions(+), 0 deletions(-)
qerror.c +4 -0
@@ -141,6 +141,10 @@ static const QErrorStringTable qerror_table[] = { .desc = "Using KVM without %(capability), %(feature) unavailable", }, { + .error_fmt = QERR_MIGRATION_IN_PROGRESS, + .desc ="Migration already in progress" + }, + { .error_fmt = QERR_MISSING_PARAMETER, .desc = "Parameter '%(name)' is missing", },
qerror.h +3 -0
@@ -121,6 +121,9 @@ QError *qobject_to_qerror(const QObject *obj);#define QERR_KVM_MISSING_CAP \ "{ 'class': 'KVMMissingCap', 'data': { 'capability': %s, 'feature': %s } }" +#define QERR_MIGRATION_IN_PROGRESS \ + "{ 'class': 'MigrationInProgress', 'data': {} }" +#define QERR_MISSING_PARAMETER \ "{ 'class': 'MissingParameter', 'data': { 'name': %s } }"
Signature · 1 line
1.6.6.1
PATCH 2/3 QError: New QERR_MIGRATION_FAILED
In reply to Markus Armbruster--- qerror.c | 4 ++++ qerror.h | 3 +++ 2 files changed, 7 insertions(+), 0 deletions(-)
qerror.c +4 -0
@@ -141,6 +141,10 @@ static const QErrorStringTable qerror_table[] = { .desc = "Using KVM without %(capability), %(feature) unavailable", }, { + .error_fmt = QERR_MIGRATION_FAILED, + .desc ="Migration failed" + }, + { .error_fmt = QERR_MIGRATION_IN_PROGRESS, .desc ="Migration already in progress" },
qerror.h +3 -0
@@ -121,6 +121,9 @@ QError *qobject_to_qerror(const QObject *obj);#define QERR_KVM_MISSING_CAP \ "{ 'class': 'KVMMissingCap', 'data': { 'capability': %s, 'feature': %s } }" +#define QERR_MIGRATION_FAILED \ + "{ 'class': 'MigrationFailed', 'data': {} }" +#define QERR_MIGRATION_IN_PROGRESS \ "{ 'class': 'MigrationInProgress', 'data': {} }"
Signature · 1 line
1.6.6.1
PATCH 3/3 monitor: Convert do_migrate() to QError
In reply to Markus ArmbrusterHuman monitor error message changes from "unknown migration protocol:
FOO" to "Invalid parameter uri".
The conversion is shallow: the FOO_start_outgoing_migration() aren't converted. Converting them is a big job for relatively little practical benefit, so leave it for later.
--- migration.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
migration.c +5 -4
@@ -56,14 +56,14 @@ void qemu_start_incoming_migration(const char *uri)int do_migrate (Monitor *mon,const QDict *qdict,QObject **ret_data) { -MigrationState *s =NULL ; +MigrationState *s;const char *p;int detach =qdict_get_int (qdict,"detach" );const char *uri =qdict_get_str (qdict,"uri" );if (current_migration && current_migration->get_status (current_migration) ==MIG_STATE_ACTIVE ) { -monitor_printf (mon,"migration already in progress\n" ); +qerror_report (QERR_MIGRATION_IN_PROGRESS );return -1 ; }
@@ -86,12 +86,13 @@ int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data) (int)qdict_get_int(qdict, "inc"));#endif }else { -monitor_printf (mon,"unknown migration protocol: %s\n" , uri); +qerror_report (QERR_INVALID_PARAMETER ,"uri" );return -1 ; }if (s ==NULL ) { -monitor_printf (mon,"migration failed\n" ); +/* TODO push error reporting into the FOO_start_outgoing_migration() */ +qerror_report (QERR_MIGRATION_FAILED );return -1 ; }
Signature · 1 line
1.6.6.1
[Qemu-devel] Re: [PATCH 3/3] monitor: Convert do_migrate() to QError
Quoted 22 lines · On Tue, 23 Mar 2010 19:07:21 +0100 Markus Armbruster <[email protected]> wrote:
Human monitor error message changes from "unknown migration protocol:
FOO" to "Invalid parameter uri".The conversion is shallow: the
FOO_start_outgoing_migration()aren't converted. Converting them is a big job for relatively little practical benefit, so leave it for later.Signed-off-by Markus Armbruster <[email protected]>--- migration.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)migration.c +1
-1@@ -56,14 +56,14 @@ void qemu_start_incoming_migration(const char *uri)int do_migrate (Monitor *mon,const QDict *qdict,QObject **ret_data) { -MigrationState *s =NULL ; +MigrationState *s;
migration.c void qemu_start_incoming_migration(const char *uri) · line 68
Quoted 10 lines
migration.c +1
-1const char *p;int detach =qdict_get_int (qdict,"detach" );const char *uri =qdict_get_str (qdict,"uri" );if (current_migration && current_migration->get_status (current_migration) ==MIG_STATE_ACTIVE ) { -monitor_printf (mon,"migration already in progress\n" ); +qerror_report (QERR_MIGRATION_IN_PROGRESS );return -1 ; }
What about QERR_OPERATION_IN_PROGRESS? So that we have:
"Operation already in progress: migration".
Quoted 6 lines
migration.c +0
-1@@ -86,12 +86,13 @@ int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data) (int)qdict_get_int(qdict, "inc"));#endif }else { -monitor_printf (mon,"unknown migration protocol: %s\n" , uri);
migration.c int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data) · line 97
Quoted 10 lines
migration.c +3
-1+qerror_report (QERR_INVALID_PARAMETER ,"uri" );return -1 ; }if (s ==NULL ) { -monitor_printf (mon,"migration failed\n" ); +/* TODO push error reporting into the FOO_start_outgoing_migration() */ +qerror_report (QERR_MIGRATION_FAILED );return -1 ; }
I think this one is no better than the automatic UndefinedError
which is going to be triggered. I would only touch this when/if we get the migration functions converted.
[Qemu-devel] Re: [PATCH 3/3] monitor: Convert do_migrate() to QError
Quoted 38 lines · Luiz Capitulino
Quoted 22 lines · On Tue, 23 Mar 2010 19:07:21 +0100 Markus Armbruster <[email protected]> wrote:
Human monitor error message changes from "unknown migration protocol:
FOO" to "Invalid parameter uri".The conversion is shallow: the
FOO_start_outgoing_migration()aren't converted. Converting them is a big job for relatively little practical benefit, so leave it for later.Signed-off-by Markus Armbruster <[email protected]>--- migration.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)migration.c +1
-1@@ -56,14 +56,14 @@ void qemu_start_incoming_migration(const char *uri)int do_migrate (Monitor *mon,const QDict *qdict,QObject **ret_data) { -MigrationState *s =NULL ; +MigrationState *s;migration.c void qemu_start_incoming_migration(const char *uri) · line 68
Quoted 10 lines
migration.c +1
-1const char *p;int detach =qdict_get_int (qdict,"detach" );const char *uri =qdict_get_str (qdict,"uri" );if (current_migration && current_migration->get_status (current_migration) ==MIG_STATE_ACTIVE ) { -monitor_printf (mon,"migration already in progress\n" ); +qerror_report (QERR_MIGRATION_IN_PROGRESS );return -1 ; }What about
QERR_OPERATION_IN_PROGRESS? So that we have:
Quoted 1 line
"Operation already in progress: migration".
We'd get an error argument "activity": "migration". Fine with me.
Quoted 9 lines
Quoted 9 lines
migration.c +1
-1@@ -86,12 +86,13 @@ int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data) (int)qdict_get_int(qdict, "inc"));#endif }else { -monitor_printf (mon,"unknown migration protocol: %s\n" , uri); +qerror_report (QERR_INVALID_PARAMETER ,"uri" );return -1 ; }
Quoted 10 lines
migration.c int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data) · line 97
Quoted 6 lines
migration.c +2
-1if (s ==NULL ) { -monitor_printf (mon,"migration failed\n" ); +/* TODO push error reporting into the FOO_start_outgoing_migration() */ +qerror_report (QERR_MIGRATION_FAILED );return -1 ; }I think this one is no better than the automatic UndefinedError
which is going to be triggered. I would only touch this when/if we get the migration functions converted.
I feel it is a bit better, because:
* It doesn't dilute the nice "this is a bug, and I should report it" property of UndefinedError.
* It avoids the "returned failure but did not pass an error" message. Minor, because it's under CONFIG_DEBUG_MONITOR.
But I'm not particular about it.
[Qemu-devel] Re: [PATCH 3/3] monitor: Convert do_migrate() to QError
On Thu, 25 Mar 2010 18:37:25 +0100
Markus Armbruster <[email protected]> wrote:
[...]
Quoted 20 lines
Quoted 9 lines
Quoted 9 lines
migration.c +1
-1@@ -86,12 +86,13 @@ int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data) (int)qdict_get_int(qdict, "inc"));#endif }else { -monitor_printf (mon,"unknown migration protocol: %s\n" , uri); +qerror_report (QERR_INVALID_PARAMETER ,"uri" );return -1 ; }Quoted 10 lines
migration.c int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data) · line 97
Quoted 6 lines
migration.c +2
-1if (s ==NULL ) { -monitor_printf (mon,"migration failed\n" ); +/* TODO push error reporting into the FOO_start_outgoing_migration() */ +qerror_report (QERR_MIGRATION_FAILED );return -1 ; }I think this one is no better than the automatic UndefinedError
which is going to be triggered. I would only touch this when/if we get the migration functions converted.
Quoted 7 lines
I feel it is a bit better, because:
* It doesn't dilute the nice "this is a bug, and I should report it" property of UndefinedError.
* It avoids the "returned failure but did not pass an error" message. Minor, because it's under
CONFIG_DEBUG_MONITOR.
But this is exactly what we want because having QERR_MIGRATION_FAILED
there doesn't fix the problems those warnings are making us aware of.
[Qemu-devel] Re: [PATCH 3/3] monitor: Convert do_migrate() to QError
Quoted 27 lines · Luiz Capitulino
On Thu, 25 Mar 2010 18:37:25 +0100
Markus Armbruster <[email protected]> wrote:[...]
Quoted 22 lines
Quoted 9 lines
Quoted 9 lines
migration.c +1
-1@@ -86,12 +86,13 @@ int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data) (int)qdict_get_int(qdict, "inc"));#endif }else { -monitor_printf (mon,"unknown migration protocol: %s\n" , uri); +qerror_report (QERR_INVALID_PARAMETER ,"uri" );return -1 ; }Quoted 10 lines
migration.c int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data) · line 97
Quoted 6 lines
migration.c +2
-1if (s ==NULL ) { -monitor_printf (mon,"migration failed\n" ); +/* TODO push error reporting into the FOO_start_outgoing_migration() */ +qerror_report (QERR_MIGRATION_FAILED );return -1 ; }I think this one is no better than the automatic UndefinedError
which is going to be triggered. I would only touch this when/if we get the migration functions converted.I feel it is a bit better, because:
Quoted 8 lines
Quoted 5 lines
* It doesn't dilute the nice "this is a bug, and I should report it" property of UndefinedError.
* It avoids the "returned failure but did not pass an error" message. Minor, because it's under
CONFIG_DEBUG_MONITOR.But this is exactly what we want because having
QERR_MIGRATION_FAILED
there doesn't fix the problems those warnings are making us aware of.
Except we are already aware of the problem, and additional warnings are just noise.
[Qemu-devel] Re: [PATCH 3/3] monitor: Convert do_migrate() to QError
Quoted 32 lines · On Thu, 25 Mar 2010 20:30:33 +0100 Markus Armbruster <[email protected]> wrote:
Quoted 30 lines · Luiz Capitulino
On Thu, 25 Mar 2010 18:37:25 +0100
Markus Armbruster <[email protected]> wrote:[...]
Quoted 25 lines
Quoted 9 lines
Quoted 9 lines
migration.c +1
-1@@ -86,12 +86,13 @@ int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data) (int)qdict_get_int(qdict, "inc"));#endif }else { -monitor_printf (mon,"unknown migration protocol: %s\n" , uri); +qerror_report (QERR_INVALID_PARAMETER ,"uri" );return -1 ; }Quoted 10 lines
migration.c int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data) · line 97
Quoted 6 lines
migration.c +2
-1if (s ==NULL ) { -monitor_printf (mon,"migration failed\n" ); +/* TODO push error reporting into the FOO_start_outgoing_migration() */ +qerror_report (QERR_MIGRATION_FAILED );return -1 ; }I think this one is no better than the automatic UndefinedError
which is going to be triggered. I would only touch this when/if we get the migration functions converted.I feel it is a bit better, because:
* It doesn't dilute the nice "this is a bug, and I should report it" property of UndefinedError.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
* It avoids the "returned failure but did not pass an error" message. Minor, because it's under
CONFIG_DEBUG_MONITOR.But this is exactly what we want because having
QERR_MIGRATION_FAILED
there doesn't fix the problems those warnings are making us aware of.Except we are already aware of the problem, and additional warnings are just noise.
Our memory is not the best place for it, not only because we can forget,
but also because it's limited on you and me.
Anyone who enables QMP's debugging support should be able to know what's
there to be done.
[Qemu-devel] Re: [PATCH 3/3] monitor: Convert do_migrate() to QError
Quoted 41 lines · Luiz Capitulino
Quoted 38 lines · On Thu, 25 Mar 2010 20:30:33 +0100 Markus Armbruster <[email protected]> wrote:
Quoted 35 lines · Luiz Capitulino
On Thu, 25 Mar 2010 18:37:25 +0100
Markus Armbruster <[email protected]> wrote:[...]
Quoted 20 lines
Quoted 9 lines
Quoted 9 lines
migration.c +1
-1@@ -86,12 +86,13 @@ int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data) (int)qdict_get_int(qdict, "inc"));#endif }else { -monitor_printf (mon,"unknown migration protocol: %s\n" , uri); +qerror_report (QERR_INVALID_PARAMETER ,"uri" );return -1 ; }Quoted 10 lines
migration.c int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data) · line 97
Quoted 6 lines
migration.c +2
-1if (s ==NULL ) { -monitor_printf (mon,"migration failed\n" ); +/* TODO push error reporting into the FOO_start_outgoing_migration() */ +qerror_report (QERR_MIGRATION_FAILED );return -1 ; }I think this one is no better than the automatic UndefinedError
which is going to be triggered. I would only touch this when/if we get the migration functions converted.Quoted 7 lines
I feel it is a bit better, because:
* It doesn't dilute the nice "this is a bug, and I should report it" property of UndefinedError.
* It avoids the "returned failure but did not pass an error" message. Minor, because it's under
CONFIG_DEBUG_MONITOR.But this is exactly what we want because having
QERR_MIGRATION_FAILED
there doesn't fix the problems those warnings are making us aware of.
Quoted 8 lines
Quoted 2 lines
Except we are already aware of the problem, and additional warnings are just noise.
Our memory is not the best place for it, not only because we can forget,
but also because it's limited on you and me.Anyone who enables QMP's debugging support should be able to know what's
there to be done.
That's what TODO comments are for.
[Qemu-devel] Re: [PATCH 3/3] monitor: Convert do_migrate() to QError
Quoted 46 lines · On Mon, 29 Mar 2010 14:38:35 +0200 Markus Armbruster <[email protected]> wrote:
Quoted 44 lines · Luiz Capitulino
Quoted 40 lines · On Thu, 25 Mar 2010 20:30:33 +0100 Markus Armbruster <[email protected]> wrote:
Quoted 27 lines · Luiz Capitulino
On Thu, 25 Mar 2010 18:37:25 +0100
Markus Armbruster <[email protected]> wrote:[...]
Quoted 22 lines
Quoted 9 lines
Quoted 9 lines
(quoted diff) +1
-1@@ -86,12 +86,13 @@ int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data) (int)qdict_get_int(qdict, "inc")); #endif } else { - monitor_printf(mon, "unknown migration protocol: %s\n", uri); + qerror_report(QERR_INVALID_PARAMETER, "uri"); return -1; }Quoted 10 lines
Review int do_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data) · line 97
Quoted 6 lines
(quoted diff) +2
-1if (s == NULL) { - monitor_printf(mon, "migration failed\n"); + /* TODO push error reporting into the FOO_start_outgoing_migration() */ + qerror_report(QERR_MIGRATION_FAILED); return -1; }I think this one is no better than the automatic UndefinedError
which is going to be triggered. I would only touch this when/if we get the migration functions converted.I feel it is a bit better, because:
Quoted 8 lines
Quoted 5 lines
* It doesn't dilute the nice "this is a bug, and I should report it" property of UndefinedError.
* It avoids the "returned failure but did not pass an error" message. Minor, because it's under
CONFIG_DEBUG_MONITOR.But this is exactly what we want because having
QERR_MIGRATION_FAILED
there doesn't fix the problems those warnings are making us aware of.Except we are already aware of the problem, and additional warnings are just noise.
Quoted 7 lines
Quoted 5 lines
Our memory is not the best place for it, not only because we can forget,
but also because it's limited on you and me.Anyone who enables QMP's debugging support should be able to know what's
there to be done.That's what TODO comments are for.
It's case by case and in this very case I'd only add QERR_MIGRATION_FAILED
if it makes difference for clients, because besides silencing the warning w/o the proper fix, this error is probably going to be dropped when the *_outgoing_migration() functions are converted.