ia64/xen-unstable

changeset 12218:e6fdb32b786c

[TOOLS] Paravirt guests have their memory allocated in the
libxenguest builder function.

Again, PPC and IA64 will need to do some fixing up.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Thu Nov 02 11:11:28 2006 +0000 (2006-11-02)
parents 70687bcb82dd
children af1403dd13af
files tools/libxc/xc_linux_build.c tools/libxc/xenguest.h tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/image.py
line diff
     1.1 --- a/tools/libxc/xc_linux_build.c	Thu Nov 02 07:46:06 2006 +0000
     1.2 +++ b/tools/libxc/xc_linux_build.c	Thu Nov 02 11:11:28 2006 +0000
     1.3 @@ -25,12 +25,6 @@
     1.4  #define L4_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER)
     1.5  #endif
     1.6  
     1.7 -#ifdef __ia64__
     1.8 -#define get_tot_pages xc_get_max_pages
     1.9 -#else
    1.10 -#define get_tot_pages xc_get_tot_pages
    1.11 -#endif
    1.12 -
    1.13  #define round_pgup(_p)    (((_p)+(PAGE_SIZE-1))&PAGE_MASK)
    1.14  #define round_pgdown(_p)  ((_p)&PAGE_MASK)
    1.15  
    1.16 @@ -674,7 +668,6 @@ static int setup_guest(int xc_handle,
    1.17      int hypercall_page_defined;
    1.18      start_info_t *start_info;
    1.19      shared_info_t *shared_info;
    1.20 -    xc_mmu_t *mmu = NULL;
    1.21      const char *p;
    1.22      DECLARE_DOMCTL;
    1.23      int rc;
    1.24 @@ -716,7 +709,7 @@ static int setup_guest(int xc_handle,
    1.25          goto error_out;
    1.26      }
    1.27  
    1.28 -    if (!compat_check(xc_handle, &dsi))
    1.29 +    if ( !compat_check(xc_handle, &dsi) )
    1.30          goto error_out;
    1.31  
    1.32      /* Parse and validate kernel features. */
    1.33 @@ -751,9 +744,13 @@ static int setup_guest(int xc_handle,
    1.34          goto error_out;
    1.35      }
    1.36  
    1.37 -    if ( xc_get_pfn_list(xc_handle, dom, page_array, nr_pages) != nr_pages )
    1.38 +    for ( i = 0; i < nr_pages; i++ )
    1.39 +        page_array[i] = i;
    1.40 +
    1.41 +    if ( xc_domain_memory_populate_physmap(xc_handle, dom, nr_pages,
    1.42 +                                           0, 0, page_array) )
    1.43      {
    1.44 -        PERROR("Could not get the page frame list");
    1.45 +        PERROR("Could not allocate memory for PV guest.\n");
    1.46          goto error_out;
    1.47      }
    1.48  
    1.49 @@ -885,9 +882,8 @@ static int setup_guest(int xc_handle,
    1.50          goto error_out;
    1.51      }
    1.52  
    1.53 -    /* setup page tables */
    1.54  #if defined(__i386__)
    1.55 -    if (dsi.pae_kernel != PAEKERN_no)
    1.56 +    if ( dsi.pae_kernel != PAEKERN_no )
    1.57          rc = setup_pg_tables_pae(xc_handle, dom, ctxt,
    1.58                                   dsi.v_start, v_end,
    1.59                                   page_array, vpt_start, vpt_end,
    1.60 @@ -904,16 +900,16 @@ static int setup_guest(int xc_handle,
    1.61                              page_array, vpt_start, vpt_end,
    1.62                              shadow_mode_enabled);
    1.63  #endif
    1.64 -    if (0 != rc)
    1.65 +    if ( rc != 0 )
    1.66          goto error_out;
    1.67  
    1.68 -#if defined(__i386__)
    1.69      /*
    1.70       * Pin down l2tab addr as page dir page - causes hypervisor to provide
    1.71       * correct protection for the page
    1.72       */
    1.73      if ( !shadow_mode_enabled )
    1.74      {
    1.75 +#if defined(__i386__)
    1.76          if ( dsi.pae_kernel != PAEKERN_no )
    1.77          {
    1.78              if ( pin_table(xc_handle, MMUEXT_PIN_L3_TABLE,
    1.79 @@ -926,40 +922,24 @@ static int setup_guest(int xc_handle,
    1.80                             xen_cr3_to_pfn(ctxt->ctrlreg[3]), dom) )
    1.81                  goto error_out;
    1.82          }
    1.83 +#elif defined(__x86_64__)
    1.84 +        /*
    1.85 +         * Pin down l4tab addr as page dir page - causes hypervisor to  provide
    1.86 +         * correct protection for the page
    1.87 +         */
    1.88 +        if ( pin_table(xc_handle, MMUEXT_PIN_L4_TABLE,
    1.89 +                       xen_cr3_to_pfn(ctxt->ctrlreg[3]), dom) )
    1.90 +            goto error_out;
    1.91 +#endif
    1.92      }
    1.93 -#endif
    1.94  
    1.95 -#if defined(__x86_64__)
    1.96 -    /*
    1.97 -     * Pin down l4tab addr as page dir page - causes hypervisor to  provide
    1.98 -     * correct protection for the page
    1.99 -     */
   1.100 -    if ( pin_table(xc_handle, MMUEXT_PIN_L4_TABLE,
   1.101 -                   xen_cr3_to_pfn(ctxt->ctrlreg[3]), dom) )
   1.102 -        goto error_out;
   1.103 -#endif
   1.104 -
   1.105 -    if ( (mmu = xc_init_mmu_updates(xc_handle, dom)) == NULL )
   1.106 -        goto error_out;
   1.107 -
   1.108 -    /* Write the phys->machine and machine->phys table entries. */
   1.109 +    /* Write the phys->machine table entries (machine->phys already done). */
   1.110      physmap_pfn = (vphysmap_start - dsi.v_start) >> PAGE_SHIFT;
   1.111      physmap = physmap_e = xc_map_foreign_range(
   1.112          xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE,
   1.113          page_array[physmap_pfn++]);
   1.114 -
   1.115      for ( count = 0; count < nr_pages; count++ )
   1.116      {
   1.117 -        if ( xc_add_mmu_update(
   1.118 -            xc_handle, mmu,
   1.119 -            ((uint64_t)page_array[count] << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE,
   1.120 -            count) )
   1.121 -        {
   1.122 -            DPRINTF("m2p update failure p=%lx m=%"PRIx64"\n",
   1.123 -                    count, (uint64_t)page_array[count]);
   1.124 -            munmap(physmap, PAGE_SIZE);
   1.125 -            goto error_out;
   1.126 -        }
   1.127          *physmap_e++ = page_array[count];
   1.128          if ( ((unsigned long)physmap_e & (PAGE_SIZE-1)) == 0 )
   1.129          {
   1.130 @@ -971,10 +951,6 @@ static int setup_guest(int xc_handle,
   1.131      }
   1.132      munmap(physmap, PAGE_SIZE);
   1.133  
   1.134 -    /* Send the page update requests down to the hypervisor. */
   1.135 -    if ( xc_finish_mmu_updates(xc_handle, mmu) )
   1.136 -        goto error_out;
   1.137 -
   1.138      if ( shadow_mode_enabled )
   1.139      {
   1.140          struct xen_add_to_physmap xatp;
   1.141 @@ -1081,10 +1057,6 @@ static int setup_guest(int xc_handle,
   1.142  
   1.143      munmap(shared_info, PAGE_SIZE);
   1.144  
   1.145 -    /* Send the page update requests down to the hypervisor. */
   1.146 -    if ( xc_finish_mmu_updates(xc_handle, mmu) )
   1.147 -        goto error_out;
   1.148 -
   1.149      hypercall_page = xen_elfnote_numeric(&dsi, XEN_ELFNOTE_HYPERCALL_PAGE,
   1.150                                           &hypercall_page_defined);
   1.151      if ( hypercall_page_defined )
   1.152 @@ -1100,7 +1072,6 @@ static int setup_guest(int xc_handle,
   1.153              goto error_out;
   1.154      }
   1.155  
   1.156 -    free(mmu);
   1.157      free(page_array);
   1.158  
   1.159      *pvsi = vstartinfo_start;
   1.160 @@ -1110,7 +1081,6 @@ static int setup_guest(int xc_handle,
   1.161      return 0;
   1.162  
   1.163   error_out:
   1.164 -    free(mmu);
   1.165      free(page_array);
   1.166      return -1;
   1.167  }
   1.168 @@ -1118,6 +1088,7 @@ static int setup_guest(int xc_handle,
   1.169  
   1.170  static int xc_linux_build_internal(int xc_handle,
   1.171                                     uint32_t domid,
   1.172 +                                   unsigned int mem_mb,
   1.173                                     char *image,
   1.174                                     unsigned long image_size,
   1.175                                     struct initrd_info *initrd,
   1.176 @@ -1132,8 +1103,7 @@ static int xc_linux_build_internal(int x
   1.177      struct xen_domctl launch_domctl;
   1.178      DECLARE_DOMCTL;
   1.179      int rc, i;
   1.180 -    vcpu_guest_context_t st_ctxt, *ctxt = &st_ctxt;
   1.181 -    unsigned long nr_pages;
   1.182 +    struct vcpu_guest_context st_ctxt, *ctxt = &st_ctxt;
   1.183      unsigned long vstartinfo_start, vkern_entry, vstack_start;
   1.184      uint32_t      features_bitmap[XENFEAT_NR_SUBMAPS] = { 0, };
   1.185  
   1.186 @@ -1146,12 +1116,6 @@ static int xc_linux_build_internal(int x
   1.187          }
   1.188      }
   1.189  
   1.190 -    if ( (nr_pages = get_tot_pages(xc_handle, domid)) < 0 )
   1.191 -    {
   1.192 -        PERROR("Could not find total pages for domain");
   1.193 -        goto error_out;
   1.194 -    }
   1.195 -
   1.196  #ifdef VALGRIND
   1.197      memset(&st_ctxt, 0, sizeof(st_ctxt));
   1.198  #endif
   1.199 @@ -1175,7 +1139,7 @@ static int xc_linux_build_internal(int x
   1.200  
   1.201      if ( setup_guest(xc_handle, domid, image, image_size,
   1.202                       initrd,
   1.203 -                     nr_pages,
   1.204 +                     mem_mb << (20 - PAGE_SHIFT),
   1.205                       &vstartinfo_start, &vkern_entry,
   1.206                       &vstack_start, ctxt, cmdline,
   1.207                       domctl.u.getdomaininfo.shared_info_frame,
   1.208 @@ -1271,6 +1235,7 @@ static int xc_linux_build_internal(int x
   1.209  
   1.210  int xc_linux_build_mem(int xc_handle,
   1.211                         uint32_t domid,
   1.212 +                       unsigned int mem_mb,
   1.213                         const char *image_buffer,
   1.214                         unsigned long image_size,
   1.215                         const char *initrd,
   1.216 @@ -1319,7 +1284,7 @@ int xc_linux_build_mem(int xc_handle,
   1.217          }
   1.218      }
   1.219  
   1.220 -    sts = xc_linux_build_internal(xc_handle, domid, img_buf, img_len,
   1.221 +    sts = xc_linux_build_internal(xc_handle, domid, mem_mb, img_buf, img_len,
   1.222                                    &initrd_info, cmdline, features, flags,
   1.223                                    store_evtchn, store_mfn,
   1.224                                    console_evtchn, console_mfn);
   1.225 @@ -1339,6 +1304,7 @@ int xc_linux_build_mem(int xc_handle,
   1.226  
   1.227  int xc_linux_build(int xc_handle,
   1.228                     uint32_t domid,
   1.229 +                   unsigned int mem_mb,
   1.230                     const char *image_name,
   1.231                     const char *initrd_name,
   1.232                     const char *cmdline,
   1.233 @@ -1375,7 +1341,7 @@ int xc_linux_build(int xc_handle,
   1.234          }
   1.235      }
   1.236  
   1.237 -    sts = xc_linux_build_internal(xc_handle, domid, image, image_size,
   1.238 +    sts = xc_linux_build_internal(xc_handle, domid, mem_mb, image, image_size,
   1.239                                    &initrd_info, cmdline, features, flags,
   1.240                                    store_evtchn, store_mfn,
   1.241                                    console_evtchn, console_mfn);
     2.1 --- a/tools/libxc/xenguest.h	Thu Nov 02 07:46:06 2006 +0000
     2.2 +++ b/tools/libxc/xenguest.h	Thu Nov 02 11:11:28 2006 +0000
     2.3 @@ -48,8 +48,9 @@ int xc_linux_restore(int xc_handle, int 
     2.4   *
     2.5   * @parm xc_handle a handle to an open hypervisor interface
     2.6   * @parm domid the id of the domain
     2.7 - * @param image_name name of the kernel image file
     2.8 - * @param ramdisk_name name of the ramdisk image file
     2.9 + * @parm mem_mb memory size in megabytes
    2.10 + * @parm image_name name of the kernel image file
    2.11 + * @parm ramdisk_name name of the ramdisk image file
    2.12   * @parm cmdline command line string
    2.13   * @parm flags domain creation flags
    2.14   * @parm store_evtchn the store event channel for this domain to use
    2.15 @@ -60,6 +61,7 @@ int xc_linux_restore(int xc_handle, int 
    2.16   */
    2.17  int xc_linux_build(int xc_handle,
    2.18                     uint32_t domid,
    2.19 +                   unsigned int mem_mb,
    2.20                     const char *image_name,
    2.21                     const char *ramdisk_name,
    2.22                     const char *cmdline,
    2.23 @@ -74,22 +76,24 @@ int xc_linux_build(int xc_handle,
    2.24   * This function will create a domain for a paravirtualized Linux
    2.25   * using buffers for kernel and initrd
    2.26   *
    2.27 - * @param xc_handle a handle to an open hypervisor interface
    2.28 - * @param domid the id of the domain
    2.29 - * @param image_buffer buffer containing kernel image
    2.30 - * @param image_size size of the kernel image buffer
    2.31 - * @param initrd_buffer name of the ramdisk image file
    2.32 - * @param initrd_size size of the ramdisk buffer
    2.33 - * @param cmdline command line string
    2.34 - * @param flags domain creation flags
    2.35 - * @param store_evtchn the store event channel for this domain to use
    2.36 - * @param store_mfn returned with the mfn of the store page
    2.37 - * @param console_evtchn the console event channel for this domain to use
    2.38 - * @param conole_mfn returned with the mfn of the console page
    2.39 + * @parm xc_handle a handle to an open hypervisor interface
    2.40 + * @parm domid the id of the domain
    2.41 + * @parm mem_mb memory size in megabytes
    2.42 + * @parm image_buffer buffer containing kernel image
    2.43 + * @parm image_size size of the kernel image buffer
    2.44 + * @parm initrd_buffer name of the ramdisk image file
    2.45 + * @parm initrd_size size of the ramdisk buffer
    2.46 + * @parm cmdline command line string
    2.47 + * @parm flags domain creation flags
    2.48 + * @parm store_evtchn the store event channel for this domain to use
    2.49 + * @parm store_mfn returned with the mfn of the store page
    2.50 + * @parm console_evtchn the console event channel for this domain to use
    2.51 + * @parm conole_mfn returned with the mfn of the console page
    2.52   * @return 0 on success, -1 on failure
    2.53   */
    2.54  int xc_linux_build_mem(int xc_handle,
    2.55                         uint32_t domid,
    2.56 +                       unsigned int mem_mb,
    2.57                         const char *image_buffer,
    2.58                         unsigned long image_size,
    2.59                         const char *initrd_buffer,
     3.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Thu Nov 02 07:46:06 2006 +0000
     3.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Thu Nov 02 11:11:28 2006 +0000
     3.3 @@ -334,24 +334,25 @@ static PyObject *pyxc_linux_build(XcObje
     3.4      char *image, *ramdisk = NULL, *cmdline = "", *features = NULL;
     3.5      int flags = 0;
     3.6      int store_evtchn, console_evtchn;
     3.7 +    unsigned int mem_mb;
     3.8      unsigned long store_mfn = 0;
     3.9      unsigned long console_mfn = 0;
    3.10  
    3.11 -    static char *kwd_list[] = { "domid", "store_evtchn",
    3.12 +    static char *kwd_list[] = { "domid", "store_evtchn", "memsize",
    3.13                                  "console_evtchn", "image",
    3.14                                  /* optional */
    3.15                                  "ramdisk", "cmdline", "flags",
    3.16                                  "features", NULL };
    3.17  
    3.18 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiis|ssis", kwd_list,
    3.19 -                                      &dom, &store_evtchn,
    3.20 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiis|ssis", kwd_list,
    3.21 +                                      &dom, &store_evtchn, &mem_mb,
    3.22                                        &console_evtchn, &image,
    3.23                                        /* optional */
    3.24                                        &ramdisk, &cmdline, &flags,
    3.25                                        &features) )
    3.26          return NULL;
    3.27  
    3.28 -    if ( xc_linux_build(self->xc_handle, dom, image,
    3.29 +    if ( xc_linux_build(self->xc_handle, dom, mem_mb, image,
    3.30                          ramdisk, cmdline, features, flags,
    3.31                          store_evtchn, &store_mfn,
    3.32                          console_evtchn, &console_mfn) != 0 ) {
     4.1 --- a/tools/python/xen/xend/XendDomainInfo.py	Thu Nov 02 07:46:06 2006 +0000
     4.2 +++ b/tools/python/xen/xend/XendDomainInfo.py	Thu Nov 02 11:11:28 2006 +0000
     4.3 @@ -1270,10 +1270,7 @@ class XendDomainInfo:
     4.4  
     4.5              # Use architecture- and image-specific calculations to determine
     4.6              # the various headrooms necessary, given the raw configured
     4.7 -            # values.
     4.8 -            # reservation, maxmem, memory, and shadow are all in KiB.
     4.9 -            reservation = self.image.getRequiredInitialReservation(
    4.10 -                self.info['memory'] * 1024)
    4.11 +            # values. maxmem, memory, and shadow are all in KiB.
    4.12              maxmem = self.image.getRequiredAvailableMemory(
    4.13                  self.info['maxmem'] * 1024)
    4.14              memory = self.image.getRequiredAvailableMemory(
    4.15 @@ -1296,12 +1293,6 @@ class XendDomainInfo:
    4.16              shadow_cur = xc.shadow_mem_control(self.domid, shadow / 1024)
    4.17              self.info['shadow_memory'] = shadow_cur
    4.18  
    4.19 -            # Initial memory reservation
    4.20 -            if not (self._infoIsSet('image') and
    4.21 -                    sxp.name(self.info['image']) == "hvm"):
    4.22 -                xc.domain_memory_increase_reservation(
    4.23 -                    self.domid, reservation, 0, 0)
    4.24 -
    4.25              self._createChannels()
    4.26  
    4.27              channel_details = self.image.createImage()
     5.1 --- a/tools/python/xen/xend/image.py	Thu Nov 02 07:46:06 2006 +0000
     5.2 +++ b/tools/python/xen/xend/image.py	Thu Nov 02 11:11:28 2006 +0000
     5.3 @@ -152,13 +152,13 @@ class ImageHandler:
     5.4          necessary."""
     5.5          return mem_kb
     5.6  
     5.7 -    def getRequiredInitialReservation(self, mem_kb):
     5.8 +    def getRequiredInitialReservation(self):
     5.9          """@param mem_kb The configured memory, in KiB.
    5.10          @return The corresponding required amount of memory to be free, also
    5.11          in KiB. This is normally the same as getRequiredAvailableMemory, but
    5.12          architecture- or image-specific code may override this to
    5.13          add headroom where necessary."""
    5.14 -        return self.getRequiredAvailableMemory(mem_kb)
    5.15 +        return self.getRequiredAvailableMemory(self.vm.getMemoryTarget())
    5.16  
    5.17      def getRequiredShadowMemory(self, shadow_mem_kb, maxmem_kb):
    5.18          """@param shadow_mem_kb The configured shadow memory, in KiB.
    5.19 @@ -189,7 +189,10 @@ class LinuxImageHandler(ImageHandler):
    5.20          store_evtchn = self.vm.getStorePort()
    5.21          console_evtchn = self.vm.getConsolePort()
    5.22  
    5.23 +        mem_mb = self.getRequiredInitialReservation() / 1024
    5.24 +
    5.25          log.debug("domid          = %d", self.vm.getDomid())
    5.26 +        log.debug("memsize        = %d", mem_mb)
    5.27          log.debug("image          = %s", self.kernel)
    5.28          log.debug("store_evtchn   = %d", store_evtchn)
    5.29          log.debug("console_evtchn = %d", console_evtchn)
    5.30 @@ -199,6 +202,7 @@ class LinuxImageHandler(ImageHandler):
    5.31          log.debug("features       = %s", self.vm.getFeatures())
    5.32  
    5.33          return xc.linux_build(domid          = self.vm.getDomid(),
    5.34 +                              memsize        = mem_mb,
    5.35                                image          = self.kernel,
    5.36                                store_evtchn   = store_evtchn,
    5.37                                console_evtchn = console_evtchn,
    5.38 @@ -218,7 +222,10 @@ class PPC_LinuxImageHandler(LinuxImageHa
    5.39          store_evtchn = self.vm.getStorePort()
    5.40          console_evtchn = self.vm.getConsolePort()
    5.41  
    5.42 +        mem_mb = self.getRequiredInitialReservation() / 1024
    5.43 +
    5.44          log.debug("domid          = %d", self.vm.getDomid())
    5.45 +        log.debug("memsize        = %d", mem_mb)
    5.46          log.debug("image          = %s", self.kernel)
    5.47          log.debug("store_evtchn   = %d", store_evtchn)
    5.48          log.debug("console_evtchn = %d", console_evtchn)
    5.49 @@ -230,6 +237,7 @@ class PPC_LinuxImageHandler(LinuxImageHa
    5.50          devtree = FlatDeviceTree.build(self)
    5.51  
    5.52          return xc.linux_build(domid          = self.vm.getDomid(),
    5.53 +                              memsize        = mem_mb,
    5.54                                image          = self.kernel,
    5.55                                store_evtchn   = store_evtchn,
    5.56                                console_evtchn = console_evtchn,
    5.57 @@ -272,10 +280,12 @@ class HVMImageHandler(ImageHandler):
    5.58      def buildDomain(self):
    5.59          store_evtchn = self.vm.getStorePort()
    5.60  
    5.61 +        mem_mb = self.getRequiredInitialReservation() / 1024
    5.62 +
    5.63          log.debug("domid          = %d", self.vm.getDomid())
    5.64          log.debug("image          = %s", self.kernel)
    5.65          log.debug("store_evtchn   = %d", store_evtchn)
    5.66 -        log.debug("memsize        = %d", self.vm.getMemoryTarget() / 1024)
    5.67 +        log.debug("memsize        = %d", mem_mb)
    5.68          log.debug("vcpus          = %d", self.vm.getVCpuCount())
    5.69          log.debug("pae            = %d", self.pae)
    5.70          log.debug("acpi           = %d", self.acpi)
    5.71 @@ -286,7 +296,7 @@ class HVMImageHandler(ImageHandler):
    5.72          return xc.hvm_build(domid          = self.vm.getDomid(),
    5.73                              image          = self.kernel,
    5.74                              store_evtchn   = store_evtchn,
    5.75 -                            memsize        = self.vm.getMemoryTarget() / 1024,
    5.76 +                            memsize        = mem_mb,
    5.77                              vcpus          = self.vm.getVCpuCount(),
    5.78                              pae            = self.pae,
    5.79                              acpi           = self.acpi,
    5.80 @@ -401,7 +411,7 @@ class HVMImageHandler(ImageHandler):
    5.81          #todo: Error handling
    5.82          args = [self.device_model]
    5.83          args = args + ([ "-d",  "%d" % self.vm.getDomid(),
    5.84 -                  "-m", "%s" % (self.vm.getMemoryTarget() / 1024)])
    5.85 +                  "-m", "%s" % (self.getRequiredInitialReservation() / 1024)])
    5.86          args = args + self.dmargs
    5.87          env = dict(os.environ)
    5.88          if self.display:
    5.89 @@ -480,8 +490,8 @@ class X86_HVM_ImageHandler(HVMImageHandl
    5.90          # Add 8 MiB overhead for QEMU's video RAM.
    5.91          return mem_kb + 8192
    5.92  
    5.93 -    def getRequiredInitialReservation(self, mem_kb):
    5.94 -        return mem_kb
    5.95 +    def getRequiredInitialReservation(self):
    5.96 +        return self.vm.getMemoryTarget()
    5.97  
    5.98      def getRequiredShadowMemory(self, shadow_mem_kb, maxmem_kb):
    5.99          # 256 pages (1MB) per vcpu,