diff options
author | Isaku Yamahata <yamahata@valinux.co.jp> | 2008-06-10 16:00:33 +0900 |
---|---|---|
committer | Isaku Yamahata <yamahata@valinux.co.jp> | 2008-06-10 16:00:33 +0900 |
commit | 006dff9e0417b59020b675f1b0ee49713a9a5739 (patch) | |
tree | ad5cd6ea6736b6f93c0af54412be9581f610a289 /tools/libxc | |
parent | 55c5209d25e3d507d03eee29681de6b4c9bf7e53 (diff) | |
download | xen-006dff9e0417b59020b675f1b0ee49713a9a5739.tar.gz xen-006dff9e0417b59020b675f1b0ee49713a9a5739.tar.bz2 xen-006dff9e0417b59020b675f1b0ee49713a9a5739.zip |
[IA64] ia64 save/restore new formart. save part.
Introduce ia64 save/restore new formart. save part.
The formart twist is necessary for pv_ops linux support saving/restoring
all of the online vcpu context.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Diffstat (limited to 'tools/libxc')
-rw-r--r-- | tools/libxc/ia64/xc_ia64_linux_save.c | 137 | ||||
-rw-r--r-- | tools/libxc/ia64/xc_ia64_save_restore.h | 2 |
2 files changed, 90 insertions, 49 deletions
diff --git a/tools/libxc/ia64/xc_ia64_linux_save.c b/tools/libxc/ia64/xc_ia64_linux_save.c index 2009da781e..ec7b28ef50 100644 --- a/tools/libxc/ia64/xc_ia64_linux_save.c +++ b/tools/libxc/ia64/xc_ia64_linux_save.c @@ -207,33 +207,97 @@ xc_ia64_send_shared_info(int xc_handle, int io_fd, shared_info_t *live_shinfo) } static int -xc_ia64_pv_send_context(int xc_handle, int io_fd, uint32_t dom, - shared_info_t *live_shinfo) +xc_ia64_send_vcpumap(int xc_handle, int io_fd, uint32_t dom, + const xc_dominfo_t *info, uint64_t max_virt_cpus, + uint64_t **vcpumapp) { - /* A copy of the CPU context of the guest. */ - vcpu_guest_context_t ctxt; - char *mem; + int rc = -1; + unsigned int i; + unsigned long vcpumap_size; + uint64_t *vcpumap = NULL; - if (xc_ia64_send_vcpu_context(xc_handle, io_fd, dom, 0, &ctxt)) - return -1; + vcpumap_size = (max_virt_cpus + 1 + sizeof(vcpumap[0]) - 1) / + sizeof(vcpumap[0]); + vcpumap = malloc(vcpumap_size); + if (vcpumap == NULL) { + ERROR("memory alloc for vcpumap"); + goto out; + } + memset(vcpumap, 0, vcpumap_size); - mem = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, - PROT_READ|PROT_WRITE, ctxt.privregs_pfn); - if (mem == NULL) { - ERROR("cannot map privreg page"); - return -1; + for (i = 0; i <= info->max_vcpu_id; i++) { + xc_vcpuinfo_t vinfo; + if ((xc_vcpu_getinfo(xc_handle, dom, i, &vinfo) == 0) && vinfo.online) + __set_bit(i, vcpumap); } - if (write_exact(io_fd, mem, PAGE_SIZE)) { - ERROR("Error when writing privreg to state file (5)"); - munmap(mem, PAGE_SIZE); - return -1; + + if (write_exact(io_fd, &max_virt_cpus, sizeof(max_virt_cpus))) { + ERROR("write max_virt_cpus"); + goto out; } - munmap(mem, PAGE_SIZE); - if (xc_ia64_send_shared_info(xc_handle, io_fd, live_shinfo)) - return -1; + if (write_exact(io_fd, vcpumap, vcpumap_size)) { + ERROR("write vcpumap"); + goto out; + } - return 0; + rc = 0; + + out: + if (rc != 0 && vcpumap != NULL) { + free(vcpumap); + vcpumap = NULL; + } + *vcpumapp = vcpumap; + return rc; +} + + +static int +xc_ia64_pv_send_context(int xc_handle, int io_fd, uint32_t dom, + const xc_dominfo_t *info, shared_info_t *live_shinfo) +{ + int rc = -1; + unsigned int i; + + /* vcpu map */ + uint64_t *vcpumap = NULL; + if (xc_ia64_send_vcpumap(xc_handle, io_fd, dom, info, MAX_VIRT_CPUS, + &vcpumap)) + goto out; + + /* vcpu context */ + for (i = 0; i <= info->max_vcpu_id; i++) { + /* A copy of the CPU context of the guest. */ + vcpu_guest_context_t ctxt; + char *mem; + + if (!__test_bit(i, vcpumap)) + continue; + + if (xc_ia64_send_vcpu_context(xc_handle, io_fd, dom, i, &ctxt)) + goto out; + + mem = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, + PROT_READ|PROT_WRITE, ctxt.privregs_pfn); + if (mem == NULL) { + ERROR("cannot map privreg page"); + goto out; + } + if (write_exact(io_fd, mem, PAGE_SIZE)) { + ERROR("Error when writing privreg to state file (5)"); + munmap(mem, PAGE_SIZE); + goto out; + } + munmap(mem, PAGE_SIZE); + } + + rc = xc_ia64_send_shared_info(xc_handle, io_fd, live_shinfo); + + out: + if (vcpumap != NULL) + free(vcpumap); + return rc; } static int @@ -244,8 +308,6 @@ xc_ia64_hvm_send_context(int xc_handle, int io_fd, uint32_t dom, unsigned int i; /* vcpu map */ - uint64_t max_virt_cpus; - unsigned long vcpumap_size; uint64_t *vcpumap = NULL; /* HVM: magic frames for ioreqs and xenstore comms */ @@ -268,31 +330,9 @@ xc_ia64_hvm_send_context(int xc_handle, int io_fd, uint32_t dom, return -1; /* vcpu map */ - max_virt_cpus = MAX_VIRT_CPUS; - vcpumap_size = (max_virt_cpus + 1 + sizeof(vcpumap[0]) - 1) / - sizeof(vcpumap[0]); - vcpumap = malloc(vcpumap_size); - if (vcpumap == NULL) { - ERROR("memory alloc for vcpumap"); - goto out; - } - memset(vcpumap, 0, vcpumap_size); - - for (i = 0; i <= info->max_vcpu_id; i++) { - xc_vcpuinfo_t vinfo; - if ((xc_vcpu_getinfo(xc_handle, dom, i, &vinfo) == 0) && vinfo.online) - __set_bit(i, vcpumap); - } - - if (write_exact(io_fd, &max_virt_cpus, sizeof(max_virt_cpus))) { - ERROR("write max_virt_cpus"); + if (xc_ia64_send_vcpumap(xc_handle, io_fd, dom, info, MAX_VIRT_CPUS, + &vcpumap)) goto out; - } - - if (write_exact(io_fd, vcpumap, vcpumap_size)) { - ERROR("write vcpumap"); - goto out; - } /* vcpu context */ for (i = 0; i <= info->max_vcpu_id; i++) { @@ -305,7 +345,7 @@ xc_ia64_hvm_send_context(int xc_handle, int io_fd, uint32_t dom, if (xc_ia64_send_vcpu_context(xc_handle, io_fd, dom, i, &ctxt)) goto out; - // system context of vcpu is sent as hvm context. + /* system context of vcpu is sent as hvm context. */ } /* Save magic-page locations. */ @@ -733,7 +773,8 @@ xc_domain_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters, goto out; if (!hvm) - rc = xc_ia64_pv_send_context(xc_handle, io_fd, dom, live_shinfo); + rc = xc_ia64_pv_send_context(xc_handle, io_fd, + dom, &info, live_shinfo); else rc = xc_ia64_hvm_send_context(xc_handle, io_fd, dom, &info, live_shinfo); diff --git a/tools/libxc/ia64/xc_ia64_save_restore.h b/tools/libxc/ia64/xc_ia64_save_restore.h index 98f92888a1..cfca1cdf68 100644 --- a/tools/libxc/ia64/xc_ia64_save_restore.h +++ b/tools/libxc/ia64/xc_ia64_save_restore.h @@ -31,7 +31,7 @@ #define XC_IA64_SR_FORMAT_VER_THREE 3UL #define XC_IA64_SR_FORMAT_VER_MAX 3UL -#define XC_IA64_SR_FORMAT_VER_CURRENT XC_IA64_SR_FORMAT_VER_TWO +#define XC_IA64_SR_FORMAT_VER_CURRENT XC_IA64_SR_FORMAT_VER_THREE /* ** During (live) save/migrate, we maintain a number of bitmaps to track |