diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2010-06-10 10:04:43 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2010-06-10 10:04:43 +0100 |
commit | 1823065fc45e9b269ee18416dd1a34e2165e8e4c (patch) | |
tree | c145238b6c6a41d82d22bb2eeb7c8fdb41f0cfea | |
parent | ea382e0272188558166ebdc96fa0142deb6b4e7f (diff) | |
download | xen-1823065fc45e9b269ee18416dd1a34e2165e8e4c.tar.gz xen-1823065fc45e9b269ee18416dd1a34e2165e8e4c.tar.bz2 xen-1823065fc45e9b269ee18416dd1a34e2165e8e4c.zip |
xc_domain_restore: Remove static variable 'completed'
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen-unstable changeset: 21589:b311acfb2742
xen-unstable date: Thu Jun 10 09:43:49 2010 +0100
-rw-r--r-- | tools/libxc/xc_domain_restore.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/tools/libxc/xc_domain_restore.c b/tools/libxc/xc_domain_restore.c index 83a3a00cb5..c0d527b78f 100644 --- a/tools/libxc/xc_domain_restore.c +++ b/tools/libxc/xc_domain_restore.c @@ -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, void* buf, size_t size) 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, void* buf, size_t size) 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, struct tailbuf_hvm *buf) 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 restore_ctx *ctx, struct tailbuf_hvm *buf, int * 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* buf, int fd, int xch, uint32_t dom) } 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* buf, int fd, int xch, uint32_t dom) 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* buf, int fd, int xch, uint32_t dom) 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* buf, int fd, int xch, uint32_t dom) 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* buf, int fd, int xch, uint32_t dom) 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* buf, int fd, int xch, uint32_t dom) 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 io_fd, uint32_t dom, 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 io_fd, uint32_t dom, // 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 io_fd, uint32_t dom, 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 io_fd, uint32_t dom, // 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; } |