int xen_domain_build_pv(const char *kernel, const char *ramdisk,

                        const char *cmdline)

{

    uint32_t ssidref = 0;

    uint32_t flags = 0;

    xen_domain_handle_t uuid;

    unsigned int xenstore_port = 0, console_port = 0;

    unsigned long xenstore_mfn = 0, console_mfn = 0;

    int rc;



    memcpy(uuid, qemu_uuid, sizeof(uuid));

    rc = xc_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid);

    if (rc < 0) {

        fprintf(stderr, "xen: xc_domain_create() failed\n");

        goto err;

    }

    qemu_log("xen: created domain %d\n", xen_domid);

    atexit(xen_domain_cleanup);

    xen_domain_watcher();



    xenstore_domain_init1(kernel, ramdisk, cmdline);



    rc = xc_domain_max_vcpus(xen_xc, xen_domid, smp_cpus);

    if (rc < 0) {

        fprintf(stderr, "xen: xc_domain_max_vcpus() failed\n");

        goto err;

    }



#if 0

    rc = xc_domain_setcpuweight(xen_xc, xen_domid, 256);

    if (rc < 0) {

        fprintf(stderr, "xen: xc_domain_setcpuweight() failed\n");

        goto err;

    }

#endif



    rc = xc_domain_setmaxmem(xen_xc, xen_domid, ram_size >> 10);

    if (rc < 0) {

        fprintf(stderr, "xen: xc_domain_setmaxmem() failed\n");

        goto err;

    }



    xenstore_port = xc_evtchn_alloc_unbound(xen_xc, xen_domid, 0);

    console_port = xc_evtchn_alloc_unbound(xen_xc, xen_domid, 0);



    rc = xc_linux_build(xen_xc, xen_domid, ram_size >> 20,

                        kernel, ramdisk, cmdline,

                        0, flags,

                        xenstore_port, &xenstore_mfn,

                        console_port, &console_mfn);

    if (rc < 0) {

        fprintf(stderr, "xen: xc_linux_build() failed\n");

        goto err;

    }



    xenstore_domain_init2(xenstore_port, xenstore_mfn,

                          console_port, console_mfn);



    qemu_log("xen: unpausing domain %d\n", xen_domid);

    rc = xc_domain_unpause(xen_xc, xen_domid);

    if (rc < 0) {

        fprintf(stderr, "xen: xc_domain_unpause() failed\n");

        goto err;

    }



    xen_poll = qemu_new_timer(rt_clock, xen_domain_poll, NULL);

    qemu_mod_timer(xen_poll, qemu_get_clock(rt_clock) + 1000);

    return 0;



err:

    return -1;

}

int xen_domain_build_pv(const char *kernel, const char *ramdisk,

                        const char *cmdline)

{

    uint32_t ssidref = 0;

    uint32_t flags = 0;

    xen_domain_handle_t uuid;

    unsigned int xenstore_port = 0, console_port = 0;

    unsigned long xenstore_mfn = 0, console_mfn = 0;

    int rc;



    memcpy(uuid, qemu_uuid, sizeof(uuid));

    rc = xc_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid);

    if (rc < 0) {

        fprintf(stderr, "xen: xc_domain_create() failed\n");

        goto err;

    }

    qemu_log("xen: created domain %d\n", xen_domid);

    atexit(xen_domain_cleanup);

    xen_domain_watcher();



    xenstore_domain_init1(kernel, ramdisk, cmdline);



    rc = xc_domain_max_vcpus(xen_xc, xen_domid, smp_cpus);

    if (rc < 0) {

        fprintf(stderr, "xen: xc_domain_max_vcpus() failed\n");

        goto err;

    }



#if 0

    rc = xc_domain_setcpuweight(xen_xc, xen_domid, 256);

    if (rc < 0) {

        fprintf(stderr, "xen: xc_domain_setcpuweight() failed\n");

        goto err;

    }

#endif



    rc = xc_domain_setmaxmem(xen_xc, xen_domid, ram_size >> 10);

    if (rc < 0) {

        fprintf(stderr, "xen: xc_domain_setmaxmem() failed\n");

        goto err;

    }



    xenstore_port = xc_evtchn_alloc_unbound(xen_xc, xen_domid, 0);

    console_port = xc_evtchn_alloc_unbound(xen_xc, xen_domid, 0);



    rc = xc_linux_build(xen_xc, xen_domid, ram_size >> 20,

                        kernel, ramdisk, cmdline,

                        0, flags,

                        xenstore_port, &xenstore_mfn,

                        console_port, &console_mfn);

    if (rc < 0) {

        fprintf(stderr, "xen: xc_linux_build() failed\n");

        goto err;

    }



    xenstore_domain_init2(xenstore_port, xenstore_mfn,

                          console_port, console_mfn);



    qemu_log("xen: unpausing domain %d\n", xen_domid);

    rc = xc_domain_unpause(xen_xc, xen_domid);

    if (rc < 0) {

        fprintf(stderr, "xen: xc_domain_unpause() failed\n");

        goto err;

    }



    xen_poll = qemu_new_timer(rt_clock, xen_domain_poll, NULL);

    qemu_mod_timer(xen_poll, qemu_get_clock(rt_clock) + 1000);

    return 0;



err:

    return -1;

}

int FUNC_0(const char *VAR_0, const char *VAR_1,

                        const char *VAR_2)

{

    uint32_t ssidref = 0;

    uint32_t flags = 0;

    xen_domain_handle_t uuid;

    unsigned int VAR_3 = 0, VAR_4 = 0;

    unsigned long VAR_5 = 0, VAR_6 = 0;

    int VAR_7;



    memcpy(uuid, qemu_uuid, sizeof(uuid));

    VAR_7 = xc_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid);

    if (VAR_7 < 0) {

        fprintf(stderr, "xen: xc_domain_create() failed\n");

        goto err;

    }

    qemu_log("xen: created domain %d\n", xen_domid);

    atexit(xen_domain_cleanup);

    xen_domain_watcher();



    xenstore_domain_init1(VAR_0, VAR_1, VAR_2);



    VAR_7 = xc_domain_max_vcpus(xen_xc, xen_domid, smp_cpus);

    if (VAR_7 < 0) {

        fprintf(stderr, "xen: xc_domain_max_vcpus() failed\n");

        goto err;

    }



#if 0

    VAR_7 = xc_domain_setcpuweight(xen_xc, xen_domid, 256);

    if (VAR_7 < 0) {

        fprintf(stderr, "xen: xc_domain_setcpuweight() failed\n");

        goto err;

    }

#endif



    VAR_7 = xc_domain_setmaxmem(xen_xc, xen_domid, ram_size >> 10);

    if (VAR_7 < 0) {

        fprintf(stderr, "xen: xc_domain_setmaxmem() failed\n");

        goto err;

    }



    VAR_3 = xc_evtchn_alloc_unbound(xen_xc, xen_domid, 0);

    VAR_4 = xc_evtchn_alloc_unbound(xen_xc, xen_domid, 0);



    VAR_7 = xc_linux_build(xen_xc, xen_domid, ram_size >> 20,

                        VAR_0, VAR_1, VAR_2,

                        0, flags,

                        VAR_3, &VAR_5,

                        VAR_4, &VAR_6);

    if (VAR_7 < 0) {

        fprintf(stderr, "xen: xc_linux_build() failed\n");

        goto err;

    }



    xenstore_domain_init2(VAR_3, VAR_5,

                          VAR_4, VAR_6);



    qemu_log("xen: unpausing domain %d\n", xen_domid);

    VAR_7 = xc_domain_unpause(xen_xc, xen_domid);

    if (VAR_7 < 0) {

        fprintf(stderr, "xen: xc_domain_unpause() failed\n");

        goto err;

    }



    xen_poll = qemu_new_timer(rt_clock, xen_domain_poll, NULL);

    qemu_mod_timer(xen_poll, qemu_get_clock(rt_clock) + 1000);

    return 0;



err:

    return -1;

}

int FUNC_0(const char *VAR_0, const char *VAR_1,
const char *VAR_2)
{ uint32_t ssidref = 0; uint32_t flags = 0; xen_domain_handle_t uuid; unsigned int VAR_3 = 0, VAR_4 = 0; unsigned long VAR_5 = 0, VAR_6 = 0; int VAR_7; memcpy(uuid, qemu_uuid, sizeof(uuid)); VAR_7 = xc_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid); if (VAR_7 < 0) { fprintf(stderr, "xen: xc_domain_create() failed\n"); goto err; } qemu_log("xen: created domain %d\n", xen_domid); atexit(xen_domain_cleanup); xen_domain_watcher(); xenstore_domain_init1(VAR_0, VAR_1, VAR_2); VAR_7 = xc_domain_max_vcpus(xen_xc, xen_domid, smp_cpus); if (VAR_7 < 0) { fprintf(stderr, "xen: xc_domain_max_vcpus() failed\n"); goto err; } #if 0
VAR_7 = xc_domain_setcpuweight(xen_xc, xen_domid, 256); if (VAR_7 < 0) { fprintf(stderr, "xen: xc_domain_setcpuweight() failed\n"); goto err; } #endif
VAR_7 = xc_domain_setmaxmem(xen_xc, xen_domid, ram_size >> 10); if (VAR_7 < 0) { fprintf(stderr, "xen: xc_domain_setmaxmem() failed\n"); goto err; } VAR_3 = xc_evtchn_alloc_unbound(xen_xc, xen_domid, 0); VAR_4 = xc_evtchn_alloc_unbound(xen_xc, xen_domid, 0); VAR_7 = xc_linux_build(xen_xc, xen_domid, ram_size >> 20,
VAR_0, VAR_1, VAR_2,
0, flags,
VAR_3, &VAR_5,
VAR_4, &VAR_6); if (VAR_7 < 0) { fprintf(stderr, "xen: xc_linux_build() failed\n"); goto err; } xenstore_domain_init2(VAR_3, VAR_5,
VAR_4, VAR_6); qemu_log("xen: unpausing domain %d\n", xen_domid); VAR_7 = xc_domain_unpause(xen_xc, xen_domid); if (VAR_7 < 0) { fprintf(stderr, "xen: xc_domain_unpause() failed\n"); goto err; } xen_poll = qemu_new_timer(rt_clock, xen_domain_poll, NULL); qemu_mod_timer(xen_poll, qemu_get_clock(rt_clock) + 1000); return 0; err:
return -1; }