ia64/xen-unstable

changeset 17772:1201c7657832

[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>
author Isaku Yamahata <yamahata@valinux.co.jp>
date Tue Jun 10 16:00:33 2008 +0900 (2008-06-10)
parents fc89fb719214
children 0034766b45c2
files tools/libxc/ia64/xc_ia64_linux_save.c tools/libxc/ia64/xc_ia64_save_restore.h
line diff
     1.1 --- a/tools/libxc/ia64/xc_ia64_linux_save.c	Tue Jun 10 15:58:09 2008 +0900
     1.2 +++ b/tools/libxc/ia64/xc_ia64_linux_save.c	Tue Jun 10 16:00:33 2008 +0900
     1.3 @@ -207,68 +207,15 @@ xc_ia64_send_shared_info(int xc_handle, 
     1.4  }
     1.5  
     1.6  static int
     1.7 -xc_ia64_pv_send_context(int xc_handle, int io_fd, uint32_t dom,
     1.8 -                        shared_info_t *live_shinfo)
     1.9 -{
    1.10 -    /* A copy of the CPU context of the guest. */
    1.11 -    vcpu_guest_context_t ctxt;
    1.12 -    char *mem;
    1.13 -
    1.14 -    if (xc_ia64_send_vcpu_context(xc_handle, io_fd, dom, 0, &ctxt))
    1.15 -        return -1;
    1.16 -
    1.17 -    mem = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
    1.18 -                               PROT_READ|PROT_WRITE, ctxt.privregs_pfn);
    1.19 -    if (mem == NULL) {
    1.20 -        ERROR("cannot map privreg page");
    1.21 -        return -1;
    1.22 -    }
    1.23 -    if (write_exact(io_fd, mem, PAGE_SIZE)) {
    1.24 -        ERROR("Error when writing privreg to state file (5)");
    1.25 -        munmap(mem, PAGE_SIZE);
    1.26 -        return -1;
    1.27 -    }
    1.28 -    munmap(mem, PAGE_SIZE);
    1.29 -
    1.30 -    if (xc_ia64_send_shared_info(xc_handle, io_fd, live_shinfo))
    1.31 -        return -1;
    1.32 -
    1.33 -    return 0;
    1.34 -}
    1.35 -
    1.36 -static int
    1.37 -xc_ia64_hvm_send_context(int xc_handle, int io_fd, uint32_t dom,
    1.38 -                         const xc_dominfo_t *info, shared_info_t *live_shinfo)
    1.39 +xc_ia64_send_vcpumap(int xc_handle, int io_fd, uint32_t dom,
    1.40 +                     const xc_dominfo_t *info, uint64_t max_virt_cpus,
    1.41 +                     uint64_t **vcpumapp)
    1.42  {
    1.43      int rc = -1;
    1.44      unsigned int i;
    1.45 -
    1.46 -    /* vcpu map */
    1.47 -    uint64_t max_virt_cpus;
    1.48      unsigned long vcpumap_size;
    1.49      uint64_t *vcpumap = NULL;
    1.50  
    1.51 -    /* HVM: magic frames for ioreqs and xenstore comms */
    1.52 -    const int hvm_params[] = {
    1.53 -        HVM_PARAM_STORE_PFN,
    1.54 -        HVM_PARAM_IOREQ_PFN,
    1.55 -        HVM_PARAM_BUFIOREQ_PFN,
    1.56 -        HVM_PARAM_BUFPIOREQ_PFN,
    1.57 -    };
    1.58 -    const int NR_PARAMS = sizeof(hvm_params) / sizeof(hvm_params[0]);
    1.59 -    /* ioreq_pfn, bufioreq_pfn, store_pfn */
    1.60 -    uint64_t magic_pfns[NR_PARAMS];
    1.61 -
    1.62 -    /* HVM: a buffer for holding HVM contxt */
    1.63 -    uint64_t rec_size;
    1.64 -    uint64_t hvm_buf_size = 0;
    1.65 -    uint8_t *hvm_buf = NULL;
    1.66 -
    1.67 -    if (xc_ia64_send_shared_info(xc_handle, io_fd, live_shinfo))
    1.68 -        return -1;
    1.69 -
    1.70 -    /* vcpu map */
    1.71 -    max_virt_cpus = MAX_VIRT_CPUS;
    1.72      vcpumap_size = (max_virt_cpus + 1 + sizeof(vcpumap[0]) - 1) /
    1.73          sizeof(vcpumap[0]);
    1.74      vcpumap = malloc(vcpumap_size);
    1.75 @@ -294,6 +241,99 @@ xc_ia64_hvm_send_context(int xc_handle, 
    1.76          goto out;
    1.77      }
    1.78  
    1.79 +    rc = 0;
    1.80 +
    1.81 + out:
    1.82 +    if (rc != 0 && vcpumap != NULL) {
    1.83 +        free(vcpumap);
    1.84 +        vcpumap = NULL;
    1.85 +    }
    1.86 +    *vcpumapp = vcpumap;
    1.87 +    return rc;
    1.88 +}
    1.89 +
    1.90 +
    1.91 +static int
    1.92 +xc_ia64_pv_send_context(int xc_handle, int io_fd, uint32_t dom,
    1.93 +                        const xc_dominfo_t *info, shared_info_t *live_shinfo)
    1.94 +{
    1.95 +    int rc = -1;
    1.96 +    unsigned int i;
    1.97 +
    1.98 +    /* vcpu map */
    1.99 +    uint64_t *vcpumap = NULL;
   1.100 +    if (xc_ia64_send_vcpumap(xc_handle, io_fd, dom, info, MAX_VIRT_CPUS,
   1.101 +                             &vcpumap))
   1.102 +        goto out;
   1.103 +
   1.104 +    /* vcpu context */
   1.105 +    for (i = 0; i <= info->max_vcpu_id; i++) {
   1.106 +        /* A copy of the CPU context of the guest. */
   1.107 +        vcpu_guest_context_t ctxt;
   1.108 +        char *mem;
   1.109 +
   1.110 +        if (!__test_bit(i, vcpumap))
   1.111 +            continue;
   1.112 +
   1.113 +        if (xc_ia64_send_vcpu_context(xc_handle, io_fd, dom, i, &ctxt))
   1.114 +            goto out;
   1.115 +
   1.116 +        mem = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE,
   1.117 +                                   PROT_READ|PROT_WRITE, ctxt.privregs_pfn);
   1.118 +        if (mem == NULL) {
   1.119 +            ERROR("cannot map privreg page");
   1.120 +            goto out;
   1.121 +        }
   1.122 +        if (write_exact(io_fd, mem, PAGE_SIZE)) {
   1.123 +            ERROR("Error when writing privreg to state file (5)");
   1.124 +            munmap(mem, PAGE_SIZE);
   1.125 +            goto out;
   1.126 +        }
   1.127 +        munmap(mem, PAGE_SIZE);
   1.128 +    }    
   1.129 +
   1.130 +    rc = xc_ia64_send_shared_info(xc_handle, io_fd, live_shinfo);
   1.131 +
   1.132 + out:
   1.133 +    if (vcpumap != NULL)
   1.134 +        free(vcpumap);
   1.135 +    return rc;
   1.136 +}
   1.137 +
   1.138 +static int
   1.139 +xc_ia64_hvm_send_context(int xc_handle, int io_fd, uint32_t dom,
   1.140 +                         const xc_dominfo_t *info, shared_info_t *live_shinfo)
   1.141 +{
   1.142 +    int rc = -1;
   1.143 +    unsigned int i;
   1.144 +
   1.145 +    /* vcpu map */
   1.146 +    uint64_t *vcpumap = NULL;
   1.147 +
   1.148 +    /* HVM: magic frames for ioreqs and xenstore comms */
   1.149 +    const int hvm_params[] = {
   1.150 +        HVM_PARAM_STORE_PFN,
   1.151 +        HVM_PARAM_IOREQ_PFN,
   1.152 +        HVM_PARAM_BUFIOREQ_PFN,
   1.153 +        HVM_PARAM_BUFPIOREQ_PFN,
   1.154 +    };
   1.155 +    const int NR_PARAMS = sizeof(hvm_params) / sizeof(hvm_params[0]);
   1.156 +    /* ioreq_pfn, bufioreq_pfn, store_pfn */
   1.157 +    uint64_t magic_pfns[NR_PARAMS];
   1.158 +
   1.159 +    /* HVM: a buffer for holding HVM contxt */
   1.160 +    uint64_t rec_size;
   1.161 +    uint64_t hvm_buf_size = 0;
   1.162 +    uint8_t *hvm_buf = NULL;
   1.163 +
   1.164 +    if (xc_ia64_send_shared_info(xc_handle, io_fd, live_shinfo))
   1.165 +        return -1;
   1.166 +
   1.167 +    /* vcpu map */
   1.168 +    if (xc_ia64_send_vcpumap(xc_handle, io_fd, dom, info, MAX_VIRT_CPUS,
   1.169 +                             &vcpumap))
   1.170 +        goto out;
   1.171 +
   1.172      /* vcpu context */
   1.173      for (i = 0; i <= info->max_vcpu_id; i++) {
   1.174          /* A copy of the CPU context of the guest. */
   1.175 @@ -305,7 +345,7 @@ xc_ia64_hvm_send_context(int xc_handle, 
   1.176          if (xc_ia64_send_vcpu_context(xc_handle, io_fd, dom, i, &ctxt))
   1.177              goto out;
   1.178  
   1.179 -        // system context of vcpu is sent as hvm context.
   1.180 +        /* system context of vcpu is sent as hvm context. */
   1.181      }    
   1.182  
   1.183      /* Save magic-page locations. */
   1.184 @@ -733,7 +773,8 @@ xc_domain_save(int xc_handle, int io_fd,
   1.185          goto out;
   1.186  
   1.187      if (!hvm)
   1.188 -        rc = xc_ia64_pv_send_context(xc_handle, io_fd, dom, live_shinfo);
   1.189 +        rc = xc_ia64_pv_send_context(xc_handle, io_fd,
   1.190 +                                     dom, &info, live_shinfo);
   1.191      else
   1.192          rc = xc_ia64_hvm_send_context(xc_handle, io_fd,
   1.193                                        dom, &info, live_shinfo);
     2.1 --- a/tools/libxc/ia64/xc_ia64_save_restore.h	Tue Jun 10 15:58:09 2008 +0900
     2.2 +++ b/tools/libxc/ia64/xc_ia64_save_restore.h	Tue Jun 10 16:00:33 2008 +0900
     2.3 @@ -31,7 +31,7 @@
     2.4  #define XC_IA64_SR_FORMAT_VER_THREE     3UL
     2.5  #define XC_IA64_SR_FORMAT_VER_MAX       3UL
     2.6  
     2.7 -#define XC_IA64_SR_FORMAT_VER_CURRENT   XC_IA64_SR_FORMAT_VER_TWO
     2.8 +#define XC_IA64_SR_FORMAT_VER_CURRENT   XC_IA64_SR_FORMAT_VER_THREE
     2.9  
    2.10  /*
    2.11  ** During (live) save/migrate, we maintain a number of bitmaps to track