# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1276160683 -3600
# Node ID 2da26c78dbb5211518993b2e2717312be81a5ac9
# Parent a684fbef232d306b8d13ed54be891935d8cb1045
xc_domain_restore: Remove static variable 'completed'
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
xen-unstable changeset: 21589:b311acfb2742
xen-unstable date: Thu Jun 10 09:43:49 2010 +0100
---
tools/libxc/xc_domain_restore.c | 58 ++++++++++++++++++++--------------------
1 files changed, 29 insertions(+), 29 deletions(-)
diff -r a684fbef232d -r 2da26c78dbb5 tools/libxc/xc_domain_restore.c
--- a/tools/libxc/xc_domain_restore.c Thu Jun 10 09:59:56 2010 +0100
+++ b/tools/libxc/xc_domain_restore.c Thu Jun 10 10:04:43 2010 +0100
@@ -40,16 +40,15 @@ struct restore_ctx {
xen_pfn_t *live_p2m; /* Live mapping of the table mapping each PFN to its
current MFN. */
xen_pfn_t *p2m; /* A table mapping each PFN to its new MFN. */
xen_pfn_t *p2m_batch; /* A table of P2M mappings in the current region. */
+ int completed; /* Set when a consistent image is available */
struct domain_info_context dinfo;
};
-/* set when a consistent image is available */
-static int completed = 0;
-
#define HEARTBEAT_MS 1000
#ifndef __MINIOS__
-static ssize_t read_exact_timed(int fd, void* buf, size_t size)
+static ssize_t read_exact_timed(struct restore_ctx *ctx,
+ int fd, void* buf, size_t size)
{
size_t offset = 0;
ssize_t len;
@@ -58,7 +57,7 @@ static ssize_t read_exact_timed(int fd,
while ( offset < size )
{
- if ( completed ) {
+ if ( ctx->completed ) {
/* expect a heartbeat every HEARBEAT_MS ms maximum */
tv.tv_sec = HEARTBEAT_MS / 1000;
tv.tv_usec = (HEARTBEAT_MS % 1000) * 1000;
@@ -82,12 +81,9 @@ static ssize_t read_exact_timed(int fd,
return 0;
}
-
-#define read_exact read_exact_timed
-
-#else
-#define read_exact_timed read_exact
+#define read_exact(fd,buf,size) read_exact_timed(ctx,fd,buf,size)
#endif
+
/*
** In the state file (or during transfer), all page-table pages are
** converted into a 'canonical' form where references to actual mfns
@@ -325,7 +321,8 @@ typedef struct {
} tailbuf_t;
/* read stream until EOF, growing buffer as necssary */
-static int compat_buffer_qemu(int fd, struct tailbuf_hvm *buf)
+static int compat_buffer_qemu(struct restore_ctx *ctx,
+ int fd, struct tailbuf_hvm *buf)
{
uint8_t *qbuf, *tmp;
int blen = 0, dlen = 0;
@@ -373,7 +370,8 @@ static int compat_buffer_qemu(int fd, st
return 0;
}
-static int buffer_qemu(int fd, struct tailbuf_hvm *buf)
+static int buffer_qemu(struct restore_ctx *ctx,
+ int fd, struct tailbuf_hvm *buf)
{
uint32_t qlen;
uint8_t *tmp;
@@ -486,9 +484,9 @@ static int buffer_tail_hvm(struct restor
* until EOF. Remus gets around this by sending a different signature
* which includes a length prefix */
if ( !memcmp(qemusig, "QemuDeviceModelRecord", sizeof(qemusig)) )
- return compat_buffer_qemu(fd, buf);
+ return compat_buffer_qemu(ctx, fd, buf);
else if ( !memcmp(qemusig, "RemusDeviceModelState", sizeof(qemusig)) )
- return buffer_qemu(fd, buf);
+ return buffer_qemu(ctx, fd, buf);
qemusig[20] = '\0';
ERROR("Invalid QEMU signature: %s", qemusig);
@@ -651,7 +649,8 @@ static void pagebuf_free(pagebuf_t* buf)
}
}
-static int pagebuf_get_one(pagebuf_t* buf, int fd, int xch, uint32_t dom)
+static int pagebuf_get_one(struct restore_ctx *ctx,
+ pagebuf_t* buf, int fd, int xch, uint32_t dom)
{
int count, countpages, oldcount, i;
void* ptmp;
@@ -670,7 +669,7 @@ static int pagebuf_get_one(pagebuf_t* bu
} else if (count == -1) {
DPRINTF("Entering page verify mode\n");
buf->verify = 1;
- return pagebuf_get_one(buf, fd, xch, dom);
+ return pagebuf_get_one(ctx, buf, fd, xch, dom);
} else if (count == -2) {
buf->new_ctxt_format = 1;
if ( read_exact(fd, &buf->max_vcpu_id, sizeof(buf->max_vcpu_id)) ||
@@ -680,7 +679,7 @@ static int pagebuf_get_one(pagebuf_t* bu
return -1;
}
// DPRINTF("Max VCPU ID: %d, vcpumap: %llx\n", buf->max_vcpu_id,
buf->vcpumap);
- return pagebuf_get_one(buf, fd, xch, dom);
+ return pagebuf_get_one(ctx, buf, fd, xch, dom);
} else if (count == -3) {
/* Skip padding 4 bytes then read the EPT identity PT location. */
if ( read_exact(fd, &buf->identpt, sizeof(uint32_t)) ||
@@ -690,7 +689,7 @@ static int pagebuf_get_one(pagebuf_t* bu
return -1;
}
// DPRINTF("EPT identity map address: %llx\n", buf->identpt);
- return pagebuf_get_one(buf, fd, xch, dom);
+ return pagebuf_get_one(ctx, buf, fd, xch, dom);
} else if ( count == -4 ) {
/* Skip padding 4 bytes then read the vm86 TSS location. */
if ( read_exact(fd, &buf->vm86_tss, sizeof(uint32_t)) ||
@@ -700,21 +699,21 @@ static int pagebuf_get_one(pagebuf_t* bu
return -1;
}
// DPRINTF("VM86 TSS location: %llx\n", buf->vm86_tss);
- return pagebuf_get_one(buf, fd, xch, dom);
+ return pagebuf_get_one(ctx, buf, fd, xch, dom);
} else if ( count == -5 ) {
DPRINTF("xc_domain_restore start tmem\n");
if ( xc_tmem_restore(xch, dom, fd) ) {
ERROR("error reading/restoring tmem");
return -1;
}
- return pagebuf_get_one(buf, fd, xch, dom);
+ return pagebuf_get_one(ctx, buf, fd, xch, dom);
}
else if ( count == -6 ) {
if ( xc_tmem_restore_extra(xch, dom, fd) ) {
ERROR("error reading/restoring tmem extra");
return -1;
}
- return pagebuf_get_one(buf, fd, xch, dom);
+ return pagebuf_get_one(ctx, buf, fd, xch, dom);
} else if ( count == -7 ) {
uint32_t tsc_mode, khz, incarn;
uint64_t nsec;
@@ -726,7 +725,7 @@ static int pagebuf_get_one(pagebuf_t* bu
ERROR("error reading/restoring tsc info");
return -1;
}
- return pagebuf_get_one(buf, fd, xch, dom);
+ return pagebuf_get_one(ctx, buf, fd, xch, dom);
} else if ( (count > MAX_BATCH_SIZE) || (count < 0) ) {
ERROR("Max batch size exceeded (%d). Giving up.", count);
return -1;
@@ -781,14 +780,15 @@ static int pagebuf_get_one(pagebuf_t* bu
return count;
}
-static int pagebuf_get(pagebuf_t* buf, int fd, int xch, uint32_t dom)
+static int pagebuf_get(struct restore_ctx *ctx,
+ pagebuf_t* buf, int fd, int xch, uint32_t dom)
{
int rc;
buf->nr_physpages = buf->nr_pages = 0;
do {
- rc = pagebuf_get_one(buf, fd, xch, dom);
+ rc = pagebuf_get_one(ctx, buf, fd, xch, dom);
} while (rc > 0);
if (rc < 0)
@@ -1178,9 +1178,9 @@ int xc_domain_restore(int xc_handle, int
prev_pc = this_pc;
}
- if ( !completed ) {
+ if ( !ctx->completed ) {
pagebuf.nr_physpages = pagebuf.nr_pages = 0;
- if ( pagebuf_get_one(&pagebuf, io_fd, xc_handle, dom) < 0 ) {
+ if ( pagebuf_get_one(ctx, &pagebuf, io_fd, xc_handle, dom) < 0 ) {
ERROR("Error when reading batch\n");
goto out;
}
@@ -1246,7 +1246,7 @@ int xc_domain_restore(int xc_handle, int
// DPRINTF("Received all pages (%d races)\n", nraces);
- if ( !completed ) {
+ if ( !ctx->completed ) {
int flags = 0;
if ( buffer_tail(ctx, &tailbuf, io_fd, max_vcpu_id, vcpumap,
@@ -1254,7 +1254,7 @@ int xc_domain_restore(int xc_handle, int
ERROR ("error buffering image tail");
goto out;
}
- completed = 1;
+ ctx->completed = 1;
/* shift into nonblocking mode for the remainder */
if ( (flags = fcntl(io_fd, F_GETFL,0)) < 0 )
flags = 0;
@@ -1263,7 +1263,7 @@ int xc_domain_restore(int xc_handle, int
// DPRINTF("Buffered checkpoint\n");
- if ( pagebuf_get(&pagebuf, io_fd, xc_handle, dom) ) {
+ if ( pagebuf_get(ctx, &pagebuf, io_fd, xc_handle, dom) ) {
ERROR("error when buffering batch, finishing\n");
goto finish;
}
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|