aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xcutils/xc_restore.c
blob: 35d725c6cbe5690890b62803e0103a1c8b9faf9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* 
 * This file is subject to the terms and conditions of the GNU General
 * Public License.  See the file "COPYING" in the main directory of
 * this archive for more details.
 *
 * Copyright (C) 2005 by Christian Limpach
 *
 */

#include <err.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>

#include <xenctrl.h>
#include <xenguest.h>

int
main(int argc, char **argv)
{
    unsigned int domid, store_evtchn, console_evtchn;
    unsigned int hvm, pae, apic, lflags;
    xc_interface *xch;
    int io_fd, ret;
    int superpages;
    unsigned long store_mfn, console_mfn;
    xentoollog_level lvl;
    xentoollog_logger *l;

    if ( (argc != 8) && (argc != 9) )
        errx(1, "usage: %s iofd domid store_evtchn "
             "console_evtchn hvm pae apic [superpages]", argv[0]);

    lvl = XTL_DETAIL;
    lflags = XTL_STDIOSTREAM_SHOW_PID | XTL_STDIOSTREAM_HIDE_PROGRESS;
    l = (xentoollog_logger *)xtl_createlogger_stdiostream(stderr, lvl, lflags);
    xch = xc_interface_open(l, 0, 0);
    if ( !xch )
        errx(1, "failed to open control interface");

    io_fd = atoi(argv[1]);
    domid = atoi(argv[2]);
    store_evtchn = atoi(argv[3]);
    console_evtchn = atoi(argv[4]);
    hvm  = atoi(argv[5]);
    pae  = atoi(argv[6]);
    apic = atoi(argv[7]);
    if ( argc == 9 )
	    superpages = atoi(argv[8]);
    else
	    superpages = !!hvm;

    ret = xc_domain_restore(xch, io_fd, domid, store_evtchn, &store_mfn, 0,
                            console_evtchn, &console_mfn, 0, hvm, pae, superpages,
                            0, NULL, NULL);

    if ( ret == 0 )
    {
	printf("store-mfn %li\n", store_mfn);
        if ( !hvm )
            printf("console-mfn %li\n", console_mfn);
	fflush(stdout);
    }

    xc_interface_close(xch);

    return ret;
}