diff --git a/tools/libxc/xc_sr_common.c b/tools/libxc/xc_sr_common.c
index 48fa676..c1babf6 100644
--- a/tools/libxc/xc_sr_common.c
+++ b/tools/libxc/xc_sr_common.c
@@ -52,8 +52,8 @@ const char *rec_type_to_str(uint32_t type)
     return "Reserved";
 }
 
-int write_split_record(struct xc_sr_context *ctx, struct xc_sr_record *rec,
-                       void *buf, size_t sz)
+int write_split_record(struct xc_sr_context *ctx, int fd,
+                       struct xc_sr_record *rec, void *buf, size_t sz)
 {
     static const char zeroes[(1u << REC_ALIGN_ORDER) - 1] = { 0 };
 
@@ -81,7 +81,7 @@ int write_split_record(struct xc_sr_context *ctx, struct xc_sr_record *rec,
     if ( sz )
         assert(buf);
 
-    if ( writev_exact(ctx->fd, parts, ARRAY_SIZE(parts)) )
+    if ( writev_exact(fd, parts, ARRAY_SIZE(parts)) )
         goto err;
 
     return 0;
diff --git a/tools/libxc/xc_sr_common.h b/tools/libxc/xc_sr_common.h
index a83f22a..2f33ccc 100644
--- a/tools/libxc/xc_sr_common.h
+++ b/tools/libxc/xc_sr_common.h
@@ -361,8 +361,8 @@ struct xc_sr_record
  *
  * Returns 0 on success and non0 on failure.
  */
-int write_split_record(struct xc_sr_context *ctx, struct xc_sr_record *rec,
-                       void *buf, size_t sz);
+int write_split_record(struct xc_sr_context *ctx, int fd,
+                       struct xc_sr_record *rec, void *buf, size_t sz);
 
 /*
  * Writes a record to the stream, applying correct padding where appropriate.
@@ -371,10 +371,10 @@ int write_split_record(struct xc_sr_context *ctx, struct xc_sr_record *rec,
  *
  * Returns 0 on success and non0 on failure.
  */
-static inline int write_record(struct xc_sr_context *ctx,
+static inline int write_record(struct xc_sr_context *ctx, int fd,
                                struct xc_sr_record *rec)
 {
-    return write_split_record(ctx, rec, NULL, 0);
+    return write_split_record(ctx, fd, rec, NULL, 0);
 }
 
 /*
diff --git a/tools/libxc/xc_sr_common_x86.c b/tools/libxc/xc_sr_common_x86.c
index 98f1cef..7b3dd50 100644
--- a/tools/libxc/xc_sr_common_x86.c
+++ b/tools/libxc/xc_sr_common_x86.c
@@ -18,7 +18,7 @@ int write_tsc_info(struct xc_sr_context *ctx)
         return -1;
     }
 
-    return write_record(ctx, &rec);
+    return write_record(ctx, ctx->fd, &rec);
 }
 
 int handle_tsc_info(struct xc_sr_context *ctx, struct xc_sr_record *rec)
diff --git a/tools/libxc/xc_sr_save.c b/tools/libxc/xc_sr_save.c
index fc63a55..61fc4a4 100644
--- a/tools/libxc/xc_sr_save.c
+++ b/tools/libxc/xc_sr_save.c
@@ -53,7 +53,7 @@ static int write_end_record(struct xc_sr_context *ctx)
 {
     struct xc_sr_record end = { REC_TYPE_END, 0, NULL };
 
-    return write_record(ctx, &end);
+    return write_record(ctx, ctx->fd, &end);
 }
 
 /*
@@ -63,7 +63,7 @@ static int write_checkpoint_record(struct xc_sr_context *ctx)
 {
     struct xc_sr_record checkpoint = { REC_TYPE_CHECKPOINT, 0, NULL };
 
-    return write_record(ctx, &checkpoint);
+    return write_record(ctx, ctx->fd, &checkpoint);
 }
 
 /*
@@ -646,7 +646,7 @@ static int verify_frames(struct xc_sr_context *ctx)
 
     DPRINTF("Enabling verify mode");
 
-    rc = write_record(ctx, &rec);
+    rc = write_record(ctx, ctx->fd, &rec);
     if ( rc )
         goto out;
 
diff --git a/tools/libxc/xc_sr_save_x86_hvm.c b/tools/libxc/xc_sr_save_x86_hvm.c
index e485928..ea4b780 100644
--- a/tools/libxc/xc_sr_save_x86_hvm.c
+++ b/tools/libxc/xc_sr_save_x86_hvm.c
@@ -42,7 +42,7 @@ static int write_hvm_context(struct xc_sr_context *ctx)
     }
 
     hvm_rec.length = hvm_buf_size;
-    rc = write_record(ctx, &hvm_rec);
+    rc = write_record(ctx, ctx->fd, &hvm_rec);
     if ( rc < 0 )
     {
         PERROR("error write HVM_CONTEXT record");
@@ -112,7 +112,8 @@ static int write_hvm_params(struct xc_sr_context *ctx)
         }
     }
 
-    rc = write_split_record(ctx, &rec, entries, hdr.count * sizeof(*entries));
+    rc = write_split_record(ctx, ctx->fd, &rec, entries,
+                            hdr.count * sizeof(*entries));
     if ( rc )
         PERROR("Failed to write HVM_PARAMS record");
 
diff --git a/tools/libxc/xc_sr_save_x86_pv.c b/tools/libxc/xc_sr_save_x86_pv.c
index f218d17..2b2c050 100644
--- a/tools/libxc/xc_sr_save_x86_pv.c
+++ b/tools/libxc/xc_sr_save_x86_pv.c
@@ -571,9 +571,9 @@ static int write_one_vcpu_basic(struct xc_sr_context *ctx, uint32_t id)
     }
 
     if ( ctx->x86_pv.width == 8 )
-        rc = write_split_record(ctx, &rec, &vcpu, sizeof(vcpu.x64));
+        rc = write_split_record(ctx, ctx->fd, &rec, &vcpu, sizeof(vcpu.x64));
     else
-        rc = write_split_record(ctx, &rec, &vcpu, sizeof(vcpu.x32));
+        rc = write_split_record(ctx, ctx->fd, &rec, &vcpu, sizeof(vcpu.x32));
 
  err:
     return rc;
@@ -609,7 +609,7 @@ static int write_one_vcpu_extended(struct xc_sr_context *ctx, uint32_t id)
         return -1;
     }
 
-    return write_split_record(ctx, &rec, &domctl.u.ext_vcpucontext,
+    return write_split_record(ctx, ctx->fd, &rec, &domctl.u.ext_vcpucontext,
                               domctl.u.ext_vcpucontext.size);
 }
 
@@ -664,7 +664,8 @@ static int write_one_vcpu_xsave(struct xc_sr_context *ctx, uint32_t id)
         goto err;
     }
 
-    rc = write_split_record(ctx, &rec, buffer, domctl.u.vcpuextstate.size);
+    rc = write_split_record(ctx, ctx->fd, &rec, buffer,
+                            domctl.u.vcpuextstate.size);
     if ( rc )
         goto err;
 
@@ -730,7 +731,7 @@ static int write_one_vcpu_msrs(struct xc_sr_context *ctx, uint32_t id)
         goto err;
     }
 
-    rc = write_split_record(ctx, &rec, buffer,
+    rc = write_split_record(ctx, ctx->fd, &rec, buffer,
                             domctl.u.vcpu_msrs.msr_count *
                             sizeof(xen_domctl_vcpu_msr_t));
     if ( rc )
@@ -805,7 +806,7 @@ static int write_x86_pv_info(struct xc_sr_context *ctx)
             .data = &info
         };
 
-    return write_record(ctx, &rec);
+    return write_record(ctx, ctx->fd, &rec);
 }
 
 /*
@@ -846,7 +847,7 @@ static int write_x86_pv_p2m_frames(struct xc_sr_context *ctx)
     else
         data = (uint64_t *)ctx->x86_pv.p2m_pfns;
 
-    rc = write_split_record(ctx, &rec, data, datasz);
+    rc = write_split_record(ctx, ctx->fd, &rec, data, datasz);
 
     if ( data != (uint64_t *)ctx->x86_pv.p2m_pfns )
         free(data);
@@ -866,7 +867,7 @@ static int write_shared_info(struct xc_sr_context *ctx)
         .data = ctx->x86_pv.shinfo,
     };
 
-    return write_record(ctx, &rec);
+    return write_record(ctx, ctx->fd, &rec);
 }
 
 /*
