From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Fabiano Rosas" <farosas@suse.de>,
peterx@redhat.com, "Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Juan Quintela" <quintela@redhat.com>
Subject: [PATCH v4 5/5] migration: Change ram_save_queue_pages() retval to bool
Date: Tue, 17 Oct 2023 16:26:33 -0400 [thread overview]
Message-ID: <20231017202633.296756-6-peterx@redhat.com> (raw)
In-Reply-To: <20231017202633.296756-1-peterx@redhat.com>
After we have errp which contains the more detailed error message, make
ram_save_queue_pages() returns bool in its stack.
Signed-off-by: Peter Xu <peterx@redhat.com>
---
migration/ram.h | 4 ++--
migration/migration.c | 16 ++++++++--------
migration/ram.c | 18 +++++++++---------
3 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/migration/ram.h b/migration/ram.h
index af0290f8ab..e22a6b0d1c 100644
--- a/migration/ram.h
+++ b/migration/ram.h
@@ -51,8 +51,8 @@ uint64_t ram_bytes_total(void);
void mig_throttle_counter_reset(void);
uint64_t ram_pagesize_summary(void);
-int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len,
- Error **errp);
+bool ram_save_queue_pages(const char *rbname, ram_addr_t start,
+ ram_addr_t len, Error **errp);
void ram_postcopy_migrated_memory_release(MigrationState *ms);
/* For outgoing discard bitmap */
void ram_postcopy_send_discard_bitmap(MigrationState *ms);
diff --git a/migration/migration.c b/migration/migration.c
index dfb8b48dcb..50bf8422c7 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -1820,8 +1820,10 @@ static struct rp_cmd_args {
* Process a request for pages received on the return path,
* We're allowed to send more than requested (e.g. to round to our page size)
* and we don't need to send pages that have already been sent.
+ *
+ * Returns true if succeed, false otherwise.
*/
-static void
+static bool
migrate_handle_rp_req_pages(MigrationState *ms, const char* rbname,
ram_addr_t start, size_t len, Error **errp)
{
@@ -1837,10 +1839,10 @@ migrate_handle_rp_req_pages(MigrationState *ms, const char* rbname,
!QEMU_IS_ALIGNED(len, our_host_ps)) {
error_setg(errp, "MIG_RP_MSG_REQ_PAGES: Misaligned page request, start:"
RAM_ADDR_FMT " len: %zd", start, len);
- return;
+ return false;
}
- ram_save_queue_pages(rbname, start, len, errp);
+ return ram_save_queue_pages(rbname, start, len, errp);
}
static bool migrate_handle_rp_recv_bitmap(MigrationState *s, char *block_name,
@@ -1990,8 +1992,7 @@ static void *source_return_path_thread(void *opaque)
case MIG_RP_MSG_REQ_PAGES:
start = ldq_be_p(buf);
len = ldl_be_p(buf + 8);
- migrate_handle_rp_req_pages(ms, NULL, start, len, &err);
- if (err) {
+ if (!migrate_handle_rp_req_pages(ms, NULL, start, len, &err)) {
goto out;
}
break;
@@ -2012,9 +2013,8 @@ static void *source_return_path_thread(void *opaque)
header_len, expected_len);
goto out;
}
- migrate_handle_rp_req_pages(ms, (char *)&buf[13], start, len,
- &err);
- if (err) {
+ if (!migrate_handle_rp_req_pages(ms, (char *)&buf[13], start, len,
+ &err)) {
goto out;
}
break;
diff --git a/migration/ram.c b/migration/ram.c
index ca77444e18..aca9ae5846 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1948,15 +1948,15 @@ static void migration_page_queue_free(RAMState *rs)
*
* A request from postcopy destination for example.
*
- * Returns zero on success or negative on error
+ * Returns true on success or false on error (detailed error put in @errp)
*
* @rbname: Name of the RAMBLock of the request. NULL means the
* same that last one.
* @start: starting address from the start of the RAMBlock
* @len: length (in bytes) to send
*/
-int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len,
- Error **errp)
+bool ram_save_queue_pages(const char *rbname, ram_addr_t start,
+ ram_addr_t len, Error **errp)
{
RAMBlock *ramblock;
RAMState *rs = ram_state;
@@ -1974,7 +1974,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len,
* it's the 1st request.
*/
error_setg(errp, "MIG_RP_MSG_REQ_PAGES has no previous block");
- return -1;
+ return false;
}
} else {
ramblock = qemu_ram_block_by_name(rbname);
@@ -1982,7 +1982,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len,
if (!ramblock) {
/* We shouldn't be asked for a non-existent RAMBlock */
error_setg(errp, "MIG_RP_MSG_REQ_PAGES has no block '%s'", rbname);
- return -1;
+ return false;
}
rs->last_req_rb = ramblock;
}
@@ -1992,7 +1992,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len,
"start=" RAM_ADDR_FMT " len="
RAM_ADDR_FMT " blocklen=" RAM_ADDR_FMT,
start, len, ramblock->used_length);
- return -1;
+ return false;
}
/*
@@ -2003,7 +2003,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len,
ram_addr_t page_start = start >> TARGET_PAGE_BITS;
size_t page_size = qemu_ram_pagesize(ramblock);
PageSearchStatus *pss = &ram_state->pss[RAM_CHANNEL_POSTCOPY];
- int ret = 0;
+ bool ret = true;
qemu_mutex_lock(&rs->bitmap_mutex);
@@ -2026,7 +2026,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len,
error_setg(errp, "ram_save_host_page_urgent() failed: "
"ramblock=%s, start_addr=0x"RAM_ADDR_FMT,
ramblock->idstr, start);
- ret = -1;
+ ret = false;
break;
}
/*
@@ -2057,7 +2057,7 @@ int ram_save_queue_pages(const char *rbname, ram_addr_t start, ram_addr_t len,
migration_make_urgent_request();
qemu_mutex_unlock(&rs->src_page_req_mutex);
- return 0;
+ return true;
}
static bool save_page_use_compression(RAMState *rs)
--
2.41.0
next prev parent reply other threads:[~2023-10-17 20:28 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-17 20:26 [PATCH v4 0/5] migration: Better error handling in rp thread, allow failures in recover Peter Xu
2023-10-17 20:26 ` [PATCH v4 1/5] migration: Refactor error handling in source return path Peter Xu
2023-10-19 21:09 ` Fabiano Rosas
2023-10-31 13:47 ` Juan Quintela
2023-10-17 20:26 ` [PATCH v4 2/5] migration: Allow network to fail even during recovery Peter Xu
2023-10-31 14:26 ` Juan Quintela
2023-10-31 15:32 ` Peter Xu
2023-10-17 20:26 ` [PATCH v4 3/5] tests/migration-test: Add a test for postcopy hangs during RECOVER Peter Xu
2023-10-31 22:01 ` Fabiano Rosas
2023-10-31 22:19 ` Peter Xu
2023-10-31 22:34 ` Juan Quintela
2023-10-17 20:26 ` [PATCH v4 4/5] migration: Change ram_dirty_bitmap_reload() retval to bool Peter Xu
2023-10-19 21:12 ` Fabiano Rosas
2023-10-31 14:30 ` Juan Quintela
2023-10-17 20:26 ` Peter Xu [this message]
2023-10-19 21:13 ` [PATCH v4 5/5] migration: Change ram_save_queue_pages() " Fabiano Rosas
2023-10-31 14:34 ` Juan Quintela
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231017202633.296756-6-peterx@redhat.com \
--to=peterx@redhat.com \
--cc=farosas@suse.de \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).