示例#1
0
int main(int argc, char **argv)
{
    int r;
    int send_back_fd, recv_fd;

#define NEXTARG (++argv, assert(*argv), *argv)

    const char *mode = *++argv;
    assert(mode);

    if (!strcmp(mode,"--save-domain")) {

        io_fd =                             atoi(NEXTARG);
        recv_fd =                           atoi(NEXTARG);
        uint32_t dom =                      strtoul(NEXTARG,0,10);
        uint32_t max_iters =                strtoul(NEXTARG,0,10);
        uint32_t max_factor =               strtoul(NEXTARG,0,10);
        uint32_t flags =                    strtoul(NEXTARG,0,10);
        int hvm =                           atoi(NEXTARG);
        unsigned cbflags =                  strtoul(NEXTARG,0,10);
        xc_migration_stream_t stream_type = strtoul(NEXTARG,0,10);
        assert(!*++argv);

        helper_setcallbacks_save(&helper_save_callbacks, cbflags);

        startup("save");
        setup_signals(save_signal_handler);

        r = xc_domain_save(xch, io_fd, dom, max_iters, max_factor, flags,
                           &helper_save_callbacks, hvm, stream_type,
                           recv_fd);
        complete(r);

    } else if (!strcmp(mode,"--restore-domain")) {

        io_fd =                             atoi(NEXTARG);
        send_back_fd =                      atoi(NEXTARG);
        uint32_t dom =                      strtoul(NEXTARG,0,10);
        unsigned store_evtchn =             strtoul(NEXTARG,0,10);
        domid_t store_domid =               strtoul(NEXTARG,0,10);
        unsigned console_evtchn =           strtoul(NEXTARG,0,10);
        domid_t console_domid =             strtoul(NEXTARG,0,10);
        unsigned int hvm =                  strtoul(NEXTARG,0,10);
        unsigned int pae =                  strtoul(NEXTARG,0,10);
        int superpages =                    strtoul(NEXTARG,0,10);
        unsigned cbflags =                  strtoul(NEXTARG,0,10);
        xc_migration_stream_t stream_type = strtoul(NEXTARG,0,10);
        assert(!*++argv);

        helper_setcallbacks_restore(&helper_restore_callbacks, cbflags);

        unsigned long store_mfn = 0;
        unsigned long console_mfn = 0;

        startup("restore");
        setup_signals(SIG_DFL);

        r = xc_domain_restore(xch, io_fd, dom, store_evtchn, &store_mfn,
                              store_domid, console_evtchn, &console_mfn,
                              console_domid, hvm, pae, superpages,
                              stream_type,
                              &helper_restore_callbacks, send_back_fd);
        helper_stub_restore_results(store_mfn,console_mfn,0);
        complete(r);

    } else {
        assert(!"unexpected mode argument");
    }
}
示例#2
0
int main(int argc, char **argv)
{
    int r;

#define NEXTARG (++argv, assert(*argv), *argv)

    const char *mode = *++argv;
    assert(mode);

    if (!strcmp(mode,"--save-domain")) {

        int io_fd =                atoi(NEXTARG);
        uint32_t dom =             strtoul(NEXTARG,0,10);
        uint32_t max_iters =       strtoul(NEXTARG,0,10);
        uint32_t max_factor =      strtoul(NEXTARG,0,10);
        uint32_t flags =           strtoul(NEXTARG,0,10);
        int hvm =                  atoi(NEXTARG);
        unsigned long genidad =    strtoul(NEXTARG,0,10);
        toolstack_save_fd  =       atoi(NEXTARG);
        toolstack_save_len =       strtoul(NEXTARG,0,10);
        unsigned cbflags =         strtoul(NEXTARG,0,10);
        assert(!*++argv);

        if (toolstack_save_fd >= 0)
            helper_save_callbacks.toolstack_save = toolstack_save_cb;

        helper_setcallbacks_save(&helper_save_callbacks, cbflags);

        startup("save");
        r = xc_domain_save(xch, io_fd, dom, max_iters, max_factor, flags,
                           &helper_save_callbacks, hvm, genidad);
        complete(r);

    } else if (!strcmp(mode,"--restore-domain")) {

        int io_fd =                atoi(NEXTARG);
        uint32_t dom =             strtoul(NEXTARG,0,10);
        unsigned store_evtchn =    strtoul(NEXTARG,0,10);
        domid_t store_domid =      strtoul(NEXTARG,0,10);
        unsigned console_evtchn =  strtoul(NEXTARG,0,10);
        domid_t console_domid =    strtoul(NEXTARG,0,10);
        unsigned int hvm =         strtoul(NEXTARG,0,10);
        unsigned int pae =         strtoul(NEXTARG,0,10);
        int superpages =           strtoul(NEXTARG,0,10);
        int no_incr_genidad =      strtoul(NEXTARG,0,10);
        unsigned cbflags =         strtoul(NEXTARG,0,10);
        assert(!*++argv);

        helper_setcallbacks_restore(&helper_restore_callbacks, cbflags);

        unsigned long store_mfn = 0;
        unsigned long console_mfn = 0;
        unsigned long genidad = 0;

        startup("restore");
        r = xc_domain_restore(xch, io_fd, dom, store_evtchn, &store_mfn,
                              store_domid, console_evtchn, &console_mfn,
                              console_domid, hvm, pae, superpages,
                              no_incr_genidad, &genidad,
                              &helper_restore_callbacks);
        helper_stub_restore_results(store_mfn,console_mfn,genidad,0);
        complete(r);

    } else {
        assert(!"unexpected mode argument");
    }
}