diff mbox

[RFC,03/20] libxc/xc_sr_restore.c: use write_record() in send_checkpoint_dirty_pfn_list()

Message ID 1490605592-12189-4-git-send-email-jtotto@uwaterloo.ca (mailing list archive)
State New, archived
Headers show

Commit Message

Joshua Otto March 27, 2017, 9:06 a.m. UTC
Teach send_checkpoint_dirty_pfn_list() to use write_record()'s new fd
parameter, avoiding the need for a manual writev().

No functional change.

Signed-off-by: Joshua Otto <jtotto@uwaterloo.ca>
---
 tools/libxc/xc_sr_restore.c | 27 ++++-----------------------
 1 file changed, 4 insertions(+), 23 deletions(-)

Comments

Andrew Cooper March 28, 2017, 6:56 p.m. UTC | #1
On 27/03/17 10:06, Joshua Otto wrote:
> Teach send_checkpoint_dirty_pfn_list() to use write_record()'s new fd
> parameter, avoiding the need for a manual writev().
>
> No functional change.
>
> Signed-off-by: Joshua Otto <jtotto@uwaterloo.ca>

Hmm - I could have sworn I objected to the patch which added this code
in the first place, for its opencoded use of writev().

Oh well, thanks for fixing it.

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Wei Liu March 31, 2017, 2:19 p.m. UTC | #2
On Mon, Mar 27, 2017 at 05:06:15AM -0400, Joshua Otto wrote:
> Teach send_checkpoint_dirty_pfn_list() to use write_record()'s new fd
> parameter, avoiding the need for a manual writev().
> 
> No functional change.
> 
> Signed-off-by: Joshua Otto <jtotto@uwaterloo.ca>

Acked-by: Wei Liu <wei.liu2@citrix.com>
diff mbox

Patch

diff --git a/tools/libxc/xc_sr_restore.c b/tools/libxc/xc_sr_restore.c
index ee06b3d..481a904 100644
--- a/tools/libxc/xc_sr_restore.c
+++ b/tools/libxc/xc_sr_restore.c
@@ -420,7 +420,6 @@  static int send_checkpoint_dirty_pfn_list(struct xc_sr_context *ctx)
     int rc = -1;
     unsigned count, written;
     uint64_t i, *pfns = NULL;
-    struct iovec *iov = NULL;
     xc_shadow_op_stats_t stats = { 0, ctx->restore.p2m_size };
     struct xc_sr_record rec =
     {
@@ -467,35 +466,17 @@  static int send_checkpoint_dirty_pfn_list(struct xc_sr_context *ctx)
         pfns[written++] = i;
     }
 
-    /* iovec[] for writev(). */
-    iov = malloc(3 * sizeof(*iov));
-    if ( !iov )
-    {
-        ERROR("Unable to allocate memory for sending dirty bitmap");
-        goto err;
-    }
-
+    rec.data = pfns;
     rec.length = count * sizeof(*pfns);
 
-    iov[0].iov_base = &rec.type;
-    iov[0].iov_len = sizeof(rec.type);
-
-    iov[1].iov_base = &rec.length;
-    iov[1].iov_len = sizeof(rec.length);
-
-    iov[2].iov_base = pfns;
-    iov[2].iov_len = count * sizeof(*pfns);
-
-    if ( writev_exact(ctx->restore.send_back_fd, iov, 3) )
-    {
-        PERROR("Failed to write dirty bitmap to stream");
+    rc = write_record(ctx, ctx->restore.send_back_fd, &rec);
+    if ( rc )
         goto err;
-    }
 
     rc = 0;
+
  err:
     free(pfns);
-    free(iov);
     return rc;
 }