[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC v5 091/126] colo: introduce ERRP_AUTO_PROPAGATE
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[RFC v5 091/126] colo: introduce ERRP_AUTO_PROPAGATE |
Date: |
Fri, 11 Oct 2019 19:05:17 +0300 |
If we want to add some info to errp (by error_prepend() or
error_append_hint()), we must use the ERRP_AUTO_PROPAGATE macro.
Otherwise, this info will not be added when errp == &fatal_err
(the program will exit prior to the error_append_hint() or
error_prepend() call). Fix such cases.
If we want to check error after errp-function call, we need to
introduce local_err and than propagate it to errp. Instead, use
ERRP_AUTO_PROPAGATE macro, benefits are:
1. No need of explicit error_propagate call
2. No need of explicit local_err variable: use errp directly
3. ERRP_AUTO_PROPAGATE leaves errp as is if it's not NULL or
&error_fatel, this means that we don't break error_abort
(we'll abort on error_set, not on error_propagate)
This commit (together with its neighbors) was generated by
for f in $(git grep -l errp \*.[ch]); do \
spatch --sp-file scripts/coccinelle/auto-propagated-errp.cocci \
--macro-file scripts/cocci-macro-file.h --in-place --no-show-diff $f; \
done;
then fix a bit of compilation problems: coccinelle for some reason
leaves several
f() {
...
goto out;
...
out:
}
patterns, with "out:" at function end.
then
./python/commit-per-subsystem.py MAINTAINERS "$(< auto-msg)"
(auto-msg was a file with this commit message)
Still, for backporting it may be more comfortable to use only the first
command and then do one huge commit.
Reported-by: Kevin Wolf <address@hidden>
Reported-by: Greg Kurz <address@hidden>
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
migration/colo.c | 38 +++++++++++++++++---------------------
1 file changed, 17 insertions(+), 21 deletions(-)
diff --git a/migration/colo.c b/migration/colo.c
index 2c88aa57a2..375aa6d8ce 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -243,19 +243,19 @@ void qmp_xen_set_replication(bool enable, bool primary,
ReplicationStatus *qmp_query_xen_replication_status(Error **errp)
{
- Error *err = NULL;
+ ERRP_AUTO_PROPAGATE();
ReplicationStatus *s = g_new0(ReplicationStatus, 1);
- replication_get_error_all(&err);
- if (err) {
+ replication_get_error_all(errp);
+ if (*errp) {
s->error = true;
s->has_desc = true;
- s->desc = g_strdup(error_get_pretty(err));
+ s->desc = g_strdup(error_get_pretty(*errp));
} else {
s->error = false;
}
- error_free(err);
+ error_free_errp(errp);
return s;
}
@@ -314,12 +314,11 @@ static void colo_send_message(QEMUFile *f, COLOMessage
msg,
static void colo_send_message_value(QEMUFile *f, COLOMessage msg,
uint64_t value, Error **errp)
{
- Error *local_err = NULL;
+ ERRP_AUTO_PROPAGATE();
int ret;
- colo_send_message(f, msg, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ colo_send_message(f, msg, errp);
+ if (*errp) {
return;
}
qemu_put_be64(f, value);
@@ -354,12 +353,11 @@ static COLOMessage colo_receive_message(QEMUFile *f,
Error **errp)
static void colo_receive_check_message(QEMUFile *f, COLOMessage expect_msg,
Error **errp)
{
+ ERRP_AUTO_PROPAGATE();
COLOMessage msg;
- Error *local_err = NULL;
- msg = colo_receive_message(f, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ msg = colo_receive_message(f, errp);
+ if (*errp) {
return;
}
if (msg != expect_msg) {
@@ -371,13 +369,12 @@ static void colo_receive_check_message(QEMUFile *f,
COLOMessage expect_msg,
static uint64_t colo_receive_message_value(QEMUFile *f, uint32_t expect_msg,
Error **errp)
{
- Error *local_err = NULL;
+ ERRP_AUTO_PROPAGATE();
uint64_t value;
int ret;
- colo_receive_check_message(f, expect_msg, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ colo_receive_check_message(f, expect_msg, errp);
+ if (*errp) {
return 0;
}
@@ -667,12 +664,11 @@ void migrate_start_colo_process(MigrationState *s)
static void colo_wait_handle_message(QEMUFile *f, int *checkpoint_request,
Error **errp)
{
+ ERRP_AUTO_PROPAGATE();
COLOMessage msg;
- Error *local_err = NULL;
- msg = colo_receive_message(f, &local_err);
- if (local_err) {
- error_propagate(errp, local_err);
+ msg = colo_receive_message(f, errp);
+ if (*errp) {
return;
}
--
2.21.0
- [RFC v5 068/126] scsi: introduce ERRP_AUTO_PROPAGATE, (continued)
- [RFC v5 068/126] scsi: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 052/126] vhost: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 085/126] Tracing: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 096/126] VHDX: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 097/126] VDI: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 081/126] qga: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 065/126] XIVE: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 095/126] Sheepdog: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 033/126] ARM Machines: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 089/126] I/O Channels: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 091/126] colo: introduce ERRP_AUTO_PROPAGATE,
Vladimir Sementsov-Ogievskiy <=
- [RFC v5 090/126] Sockets: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 088/126] Cryptography: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 094/126] RBD: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 098/126] iSCSI: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 087/126] Migration: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 092/126] Record/replay: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 082/126] QOM: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 093/126] VMDK: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 035/126] PowerPC Machines: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11
- [RFC v5 067/126] block: introduce ERRP_AUTO_PROPAGATE, Vladimir Sementsov-Ogievskiy, 2019/10/11