All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: Alexey Perevalov <a.perevalov@samsung.com>,
	"Daniel P . Berrange" <berrange@redhat.com>,
	Juan Quintela <quintela@redhat.com>,
	Andrea Arcangeli <aarcange@redhat.com>,
	"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
	peterx@redhat.com
Subject: [Qemu-devel] [PATCH v4 08/32] migration: allow send_rq to fail
Date: Wed,  8 Nov 2017 14:01:06 +0800	[thread overview]
Message-ID: <20171108060130.3772-9-peterx@redhat.com> (raw)
In-Reply-To: <20171108060130.3772-1-peterx@redhat.com>

We will not allow failures to happen when sending data from destination
to source via the return path. However it is possible that there can be
errors along the way.  This patch allows the migrate_send_rp_message()
to return error when it happens, and further extended it to
migrate_send_rp_req_pages().

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
---
 migration/migration.c | 38 ++++++++++++++++++++++++++++++--------
 migration/migration.h |  2 +-
 2 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/migration/migration.c b/migration/migration.c
index 8d93b891e3..db896233f6 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -199,17 +199,35 @@ static void deferred_incoming_migration(Error **errp)
  * Send a message on the return channel back to the source
  * of the migration.
  */
-static void migrate_send_rp_message(MigrationIncomingState *mis,
-                                    enum mig_rp_message_type message_type,
-                                    uint16_t len, void *data)
+static int migrate_send_rp_message(MigrationIncomingState *mis,
+                                   enum mig_rp_message_type message_type,
+                                   uint16_t len, void *data)
 {
+    int ret = 0;
+
     trace_migrate_send_rp_message((int)message_type, len);
     qemu_mutex_lock(&mis->rp_mutex);
+
+    /*
+     * It's possible that the file handle got lost due to network
+     * failures.
+     */
+    if (!mis->to_src_file) {
+        ret = -EIO;
+        goto error;
+    }
+
     qemu_put_be16(mis->to_src_file, (unsigned int)message_type);
     qemu_put_be16(mis->to_src_file, len);
     qemu_put_buffer(mis->to_src_file, data, len);
     qemu_fflush(mis->to_src_file);
+
+    /* It's possible that qemu file got error during sending */
+    ret = qemu_file_get_error(mis->to_src_file);
+
+error:
     qemu_mutex_unlock(&mis->rp_mutex);
+    return ret;
 }
 
 /* Request a range of pages from the source VM at the given
@@ -219,26 +237,30 @@ static void migrate_send_rp_message(MigrationIncomingState *mis,
  *   Start: Address offset within the RB
  *   Len: Length in bytes required - must be a multiple of pagesize
  */
-void migrate_send_rp_req_pages(MigrationIncomingState *mis, const char *rbname,
-                               ram_addr_t start, size_t len)
+int migrate_send_rp_req_pages(MigrationIncomingState *mis, const char *rbname,
+                              ram_addr_t start, size_t len)
 {
     uint8_t bufc[12 + 1 + 255]; /* start (8), len (4), rbname up to 256 */
     size_t msglen = 12; /* start + len */
+    int rbname_len;
+    enum mig_rp_message_type msg_type;
 
     *(uint64_t *)bufc = cpu_to_be64((uint64_t)start);
     *(uint32_t *)(bufc + 8) = cpu_to_be32((uint32_t)len);
 
     if (rbname) {
-        int rbname_len = strlen(rbname);
+        rbname_len = strlen(rbname);
         assert(rbname_len < 256);
 
         bufc[msglen++] = rbname_len;
         memcpy(bufc + msglen, rbname, rbname_len);
         msglen += rbname_len;
-        migrate_send_rp_message(mis, MIG_RP_MSG_REQ_PAGES_ID, msglen, bufc);
+        msg_type = MIG_RP_MSG_REQ_PAGES_ID;
     } else {
-        migrate_send_rp_message(mis, MIG_RP_MSG_REQ_PAGES, msglen, bufc);
+        msg_type = MIG_RP_MSG_REQ_PAGES;
     }
+
+    return migrate_send_rp_message(mis, msg_type, msglen, bufc);
 }
 
 void qemu_start_incoming_migration(const char *uri, Error **errp)
diff --git a/migration/migration.h b/migration/migration.h
index ebb049f692..b63cdfbfdb 100644
--- a/migration/migration.h
+++ b/migration/migration.h
@@ -216,7 +216,7 @@ void migrate_send_rp_shut(MigrationIncomingState *mis,
                           uint32_t value);
 void migrate_send_rp_pong(MigrationIncomingState *mis,
                           uint32_t value);
-void migrate_send_rp_req_pages(MigrationIncomingState *mis, const char* rbname,
+int migrate_send_rp_req_pages(MigrationIncomingState *mis, const char* rbname,
                               ram_addr_t start, size_t len);
 
 #endif
-- 
2.13.6

  parent reply	other threads:[~2017-11-08  6:02 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-08  6:00 [Qemu-devel] [PATCH v4 00/32] Migration: postcopy failure recovery Peter Xu
2017-11-08  6:00 ` [Qemu-devel] [PATCH v4 01/32] migration: better error handling with QEMUFile Peter Xu
2017-11-30 10:24   ` Dr. David Alan Gilbert
2017-12-01  8:39     ` Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 02/32] migration: reuse mis->userfault_quit_fd Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 03/32] migration: provide postcopy_fault_thread_notify() Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 04/32] migration: new postcopy-pause state Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 05/32] migration: implement "postcopy-pause" src logic Peter Xu
2017-11-30 10:49   ` Dr. David Alan Gilbert
2017-12-01  8:56     ` Peter Xu
2017-12-01 10:49       ` Dr. David Alan Gilbert
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 06/32] migration: allow dst vm pause on postcopy Peter Xu
2017-11-30 11:17   ` Dr. David Alan Gilbert
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 07/32] migration: allow src return path to pause Peter Xu
2017-11-08  6:01 ` Peter Xu [this message]
2017-11-30 12:13   ` [Qemu-devel] [PATCH v4 08/32] migration: allow send_rq to fail Dr. David Alan Gilbert
2017-12-01  9:30     ` Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 09/32] migration: allow fault thread to pause Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 10/32] qmp: hmp: add migrate "resume" option Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 11/32] migration: pass MigrationState to migrate_init() Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 12/32] migration: rebuild channel on source Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 13/32] migration: new state "postcopy-recover" Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 14/32] migration: wakeup dst ram-load-thread for recover Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 15/32] migration: new cmd MIG_CMD_RECV_BITMAP Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 16/32] migration: new message MIG_RP_MSG_RECV_BITMAP Peter Xu
2017-11-30 17:21   ` Dr. David Alan Gilbert
2017-12-01  9:37     ` Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 17/32] migration: new cmd MIG_CMD_POSTCOPY_RESUME Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 18/32] migration: new message MIG_RP_MSG_RESUME_ACK Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 19/32] migration: introduce SaveVMHandlers.resume_prepare Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 20/32] migration: synchronize dirty bitmap for resume Peter Xu
2017-11-30 18:40   ` Dr. David Alan Gilbert
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 21/32] migration: setup ramstate " Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 22/32] migration: final handshake for the resume Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 23/32] migration: free SocketAddress where allocated Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 24/32] migration: return incoming task tag for sockets Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 25/32] migration: return incoming task tag for exec Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 26/32] migration: return incoming task tag for fd Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 27/32] migration: store listen task tag Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 28/32] migration: allow migrate_incoming for paused VM Peter Xu
2017-12-01 17:21   ` Dr. David Alan Gilbert
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 29/32] migration: init dst in migration_object_init too Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 30/32] migration: delay the postcopy-active state switch Peter Xu
2017-12-01 12:34   ` Dr. David Alan Gilbert
2017-12-04  4:14     ` Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 31/32] migration, qmp: new command "migrate-pause" Peter Xu
2017-12-01 16:53   ` Dr. David Alan Gilbert
2017-12-04  4:48     ` Peter Xu
2017-12-04 17:10       ` Dr. David Alan Gilbert
2017-12-05  2:52         ` Peter Xu
2017-11-08  6:01 ` [Qemu-devel] [PATCH v4 32/32] migration, hmp: new command "migrate_pause" Peter Xu
2017-11-30 20:00 ` [Qemu-devel] [PATCH v4 00/32] Migration: postcopy failure recovery Dr. David Alan Gilbert
2017-12-01 10:23   ` Peter Xu

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=20171108060130.3772-9-peterx@redhat.com \
    --to=peterx@redhat.com \
    --cc=a.perevalov@samsung.com \
    --cc=aarcange@redhat.com \
    --cc=berrange@redhat.com \
    --cc=dgilbert@redhat.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.