ia64/xen-unstable

view tools/xcutils/xc_restore.c @ 19639:205b1badbcfd

Add support for superpages (hugepages) in PV domain

This patch adds the option "superpages" to the domain configuration
file. If it is set, the domain is populated using 2M pages.

This code does not support fallback to small pages. If the domain can
not be created with 2M pages, the create will fail.

The patch also includes support for saving and restoring domains with
the superpage flag set. However, if a domain has freed small pages
within its physical page array and then extended the array, the
restore will fill in those freed pages. It will then attempt to
allocate more than its memory limit and will fail. This is
significant because apparently Linux does this during boot, thus a
freshly booted Linux image can not be saved and restored successfully.

Signed-off-by: Dave McCracken <dcm@mccr.org>
author Keir Fraser <keir.fraser@citrix.com>
date Tue May 26 09:58:38 2009 +0100 (2009-05-26)
parents 694b7daa353c
children
line source
1 /*
2 * This file is subject to the terms and conditions of the GNU General
3 * Public License. See the file "COPYING" in the main directory of
4 * this archive for more details.
5 *
6 * Copyright (C) 2005 by Christian Limpach
7 *
8 */
10 #include <err.h>
11 #include <stdlib.h>
12 #include <stdint.h>
13 #include <stdio.h>
15 #include <xenctrl.h>
16 #include <xenguest.h>
18 int
19 main(int argc, char **argv)
20 {
21 unsigned int domid, store_evtchn, console_evtchn;
22 unsigned int hvm, pae, apic;
23 int xc_fd, io_fd, ret;
24 int superpages;
25 unsigned long store_mfn, console_mfn;
27 if ( (argc != 8) && (argc != 9) )
28 errx(1, "usage: %s iofd domid store_evtchn "
29 "console_evtchn hvm pae apic [superpages]", argv[0]);
31 xc_fd = xc_interface_open();
32 if ( xc_fd < 0 )
33 errx(1, "failed to open control interface");
35 io_fd = atoi(argv[1]);
36 domid = atoi(argv[2]);
37 store_evtchn = atoi(argv[3]);
38 console_evtchn = atoi(argv[4]);
39 hvm = atoi(argv[5]);
40 pae = atoi(argv[6]);
41 apic = atoi(argv[7]);
42 if ( argc == 9 )
43 superpages = atoi(argv[8]);
44 else
45 superpages = 0;
47 ret = xc_domain_restore(xc_fd, io_fd, domid, store_evtchn, &store_mfn,
48 console_evtchn, &console_mfn, hvm, pae, superpages);
50 if ( ret == 0 )
51 {
52 printf("store-mfn %li\n", store_mfn);
53 if ( !hvm )
54 printf("console-mfn %li\n", console_mfn);
55 fflush(stdout);
56 }
58 xc_interface_close(xc_fd);
60 return ret;
61 }