ia64/xen-unstable

view tools/xcutils/xc_restore.c @ 13896:d39e8c44da34

[HVM] Save/restore: disentangle max_pfn from nr_pages.
These have been used interchangeably, which is OK for PV domains but
not for HVM. This fixes an over-allocation by 256MB when restoring
HVM guests that have more than 4GB of RAM.
Signed-off-by: Tim Deegan <Tim.Deegan@xensource.com>
author Tim Deegan <Tim.Deegan@xensource.com>
date Fri Feb 09 10:48:41 2007 +0000 (2007-02-09)
parents 16ba1d434f89
children 121a97005d11
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 xc_fd, io_fd, domid, max_pfn, store_evtchn, console_evtchn;
22 unsigned int hvm, pae, apic;
23 int ret;
24 unsigned long store_mfn, console_mfn;
26 if (argc != 9)
27 errx(1,
28 "usage: %s iofd domid max_pfn store_evtchn console_evtchn hvm pae apic",
29 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 max_pfn = atoi(argv[3]);
38 store_evtchn = atoi(argv[4]);
39 console_evtchn = atoi(argv[5]);
40 hvm = atoi(argv[6]);
41 pae = atoi(argv[7]);
42 apic = atoi(argv[8]);
44 if (hvm) {
45 /* pass the memsize to xc_hvm_restore to find the store_mfn */
46 store_mfn = hvm;
47 ret = xc_hvm_restore(xc_fd, io_fd, domid, max_pfn, store_evtchn,
48 &store_mfn, pae, apic);
49 } else
50 ret = xc_linux_restore(xc_fd, io_fd, domid, max_pfn, store_evtchn,
51 &store_mfn, console_evtchn, &console_mfn);
53 if (ret == 0) {
54 printf("store-mfn %li\n", store_mfn);
55 if (!hvm)
56 printf("console-mfn %li\n", console_mfn);
57 fflush(stdout);
58 }
60 xc_interface_close(xc_fd);
62 return ret;
63 }