diff options
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/examples/xc_dom_control.py | 2 | ||||
| -rw-r--r-- | tools/xc/lib/xc.h | 78 | ||||
| -rw-r--r-- | tools/xc/lib/xc_atropos.c | 4 | ||||
| -rw-r--r-- | tools/xc/lib/xc_bvtsched.c | 10 | ||||
| -rw-r--r-- | tools/xc/lib/xc_domain.c | 59 | ||||
| -rw-r--r-- | tools/xc/lib/xc_evtchn.c | 10 | ||||
| -rw-r--r-- | tools/xc/lib/xc_linux_build.c | 12 | ||||
| -rw-r--r-- | tools/xc/lib/xc_linux_restore.c | 382 | ||||
| -rw-r--r-- | tools/xc/lib/xc_linux_save.c | 793 | ||||
| -rw-r--r-- | tools/xc/lib/xc_misc.c | 4 | ||||
| -rw-r--r-- | tools/xc/lib/xc_netbsd_build.c | 12 | ||||
| -rw-r--r-- | tools/xc/lib/xc_physdev.c | 2 | ||||
| -rw-r--r-- | tools/xc/lib/xc_private.c | 115 | ||||
| -rw-r--r-- | tools/xc/lib/xc_vbd.c | 16 | ||||
| -rw-r--r-- | tools/xc/lib/xc_vif.c | 6 | ||||
| -rw-r--r-- | tools/xc/py/Xc.c | 731 | ||||
| -rw-r--r-- | tools/xend/lib/blkif.py | 14 | ||||
| -rw-r--r-- | tools/xend/lib/netif.py | 8 | ||||
| -rw-r--r-- | tools/xend/lib/utils.c | 15 |
19 files changed, 1133 insertions, 1140 deletions
diff --git a/tools/examples/xc_dom_control.py b/tools/examples/xc_dom_control.py index 9feab009e3..9a73d4533f 100755 --- a/tools/examples/xc_dom_control.py +++ b/tools/examples/xc_dom_control.py @@ -50,7 +50,7 @@ dom = None if len( sys.argv ) > 2 and re.match('\d+$', sys.argv[2]): - dom = long(sys.argv[2]) + dom = int(sys.argv[2]) if cmd == 'stop': rc = xc.domain_stop( dom=dom ) diff --git a/tools/xc/lib/xc.h b/tools/xc/lib/xc.h index 3423c4ec46..1523e2c84a 100644 --- a/tools/xc/lib/xc.h +++ b/tools/xc/lib/xc.h @@ -23,7 +23,7 @@ int xc_interface_open(void); int xc_interface_close(int xc_handle); typedef struct { - u64 domid; + u32 domid; unsigned int cpu; int has_cpu; int stopped; @@ -39,24 +39,24 @@ int xc_domain_create(int xc_handle, unsigned int mem_kb, const char *name, int cpu, - u64 *pdomid); + u32 *pdomid); int xc_domain_start(int xc_handle, - u64 domid); + u32 domid); int xc_domain_stop(int xc_handle, - u64 domid); + u32 domid); int xc_domain_destroy(int xc_handle, - u64 domid, + u32 domid, int force); int xc_domain_pincpu(int xc_handle, - u64 domid, + u32 domid, int cpu); int xc_domain_getinfo(int xc_handle, - u64 first_domid, + u32 first_domid, unsigned int max_doms, xc_dominfo_t *info); int xc_shadow_control(int xc_handle, - u64 domid, + u32 domid, unsigned int sop, unsigned long *dirty_bitmap, unsigned long pages, @@ -69,27 +69,27 @@ int xc_shadow_control(int xc_handle, #define XCFLAGS_DEBUG 4 int xc_linux_save(int xc_handle, - u64 domid, + u32 domid, unsigned int flags, int (*writerfn)(void *, const void *, size_t), void *writerst ); int xc_linux_restore(int xc_handle, - u64 domid, + u32 domid, unsigned int flags, int (*readerfn)(void *, void *, size_t), void *readerst, - u64 *pdomid); + u32 *pdomid); int xc_linux_build(int xc_handle, - u64 domid, + u32 domid, const char *image_name, const char *ramdisk_name, const char *cmdline, unsigned int control_evtchn); int xc_netbsd_build(int xc_handle, - u64 domid, + u32 domid, const char *image_name, const char *cmdline, unsigned int control_evtchn); @@ -98,7 +98,7 @@ int xc_bvtsched_global_set(int xc_handle, unsigned long ctx_allow); int xc_bvtsched_domain_set(int xc_handle, - u64 domid, + u32 domid, unsigned long mcuadv, unsigned long warp, unsigned long warpl, @@ -108,19 +108,19 @@ int xc_bvtsched_global_get(int xc_handle, unsigned long *ctx_allow); int xc_bvtsched_domain_get(int xc_handle, - u64 domid, + u32 domid, unsigned long *mcuadv, unsigned long *warp, unsigned long *warpl, unsigned long *warpu); int xc_atropos_domain_set(int xc_handle, - u64 domid, + u32 domid, u64 period, u64 slice, u64 latency, int xtratime); int xc_atropos_domain_get(int xc_handle, - u64 domid, + u32 domid, u64* period, u64 *slice, u64 *latency, int *xtratime); @@ -139,21 +139,21 @@ typedef struct { } xc_vif_stats_t; int xc_vif_scheduler_set(int xc_handle, - u64 domid, + u32 domid, unsigned int vifid, xc_vif_sched_params_t *params); int xc_vif_scheduler_get(int xc_handle, - u64 domid, + u32 domid, unsigned int vifid, xc_vif_sched_params_t *params); int xc_vif_stats_get(int xc_handle, - u64 domid, + u32 domid, unsigned int vifid, xc_vif_stats_t *stats); typedef struct { -#define XC_VBDDOM_PROBE_ALL (~0ULL) - u64 domid; +#define XC_VBDDOM_PROBE_ALL (0x7FFFFFFFU) + u32 domid; unsigned short vbdid; #define XC_VBDF_WRITEABLE (1<<0) unsigned long flags; @@ -175,36 +175,36 @@ typedef struct { } xc_physinfo_t; int xc_vbd_create(int xc_handle, - u64 domid, + u32 domid, unsigned short vbdid, int writeable); int xc_vbd_destroy(int xc_handle, - u64 domid, + u32 domid, unsigned short vbdid); int xc_vbd_grow(int xc_handle, - u64 domid, + u32 domid, unsigned short vbdid, xc_vbdextent_t *extent); int xc_vbd_shrink(int xc_handle, - u64 domid, + u32 domid, unsigned short vbdid); int xc_vbd_setextents(int xc_handle, - u64 domid, + u32 domid, unsigned short vbdid, unsigned int nr_extents, xc_vbdextent_t *extents); int xc_vbd_getextents(int xc_handle, - u64 domid, + u32 domid, unsigned short vbdid, unsigned int max_extents, xc_vbdextent_t *extents, int *writeable); int xc_vbd_probe(int xc_handle, - u64 domid, + u32 domid, unsigned int max_vbds, xc_vbd_t *vbds); -#define DOMID_SELF (~1ULL) +#define DOMID_SELF (0x7FFFFFFEU) typedef struct { #define EVTCHNSTAT_closed 0 /* Chennel is not in use. */ @@ -215,7 +215,7 @@ typedef struct { int status; union { struct { - u64 dom; + u32 dom; int port; } interdomain; int pirq; @@ -224,22 +224,22 @@ typedef struct { } xc_evtchn_status_t; int xc_evtchn_bind_interdomain(int xc_handle, - u64 dom1, /* may be DOMID_SELF */ - u64 dom2, /* may be DOMID_SELF */ + u32 dom1, /* may be DOMID_SELF */ + u32 dom2, /* may be DOMID_SELF */ int *port1, int *port2); int xc_evtchn_close(int xc_handle, - u64 dom, /* may be DOMID_SELF */ + u32 dom, /* may be DOMID_SELF */ int port); int xc_evtchn_send(int xc_handle, int local_port); int xc_evtchn_status(int xc_handle, - u64 dom, /* may be DOMID_SELF */ + u32 dom, /* may be DOMID_SELF */ int port, xc_evtchn_status_t *status); int xc_physdev_pci_access_modify(int xc_handle, - u64 domid, + u32 domid, int bus, int dev, int func, @@ -254,15 +254,15 @@ int xc_physinfo(int xc_handle, xc_physinfo_t *info); int xc_domain_setname(int xc_handle, - u64 domid, + u32 domid, char *name); int xc_domain_setinitialmem(int xc_handle, - u64 domid, + u32 domid, unsigned int initial_memkb); int xc_domain_setmaxmem(int xc_handle, - u64 domid, + u32 domid, unsigned int max_memkb); diff --git a/tools/xc/lib/xc_atropos.c b/tools/xc/lib/xc_atropos.c index 279324854c..13d07ca440 100644 --- a/tools/xc/lib/xc_atropos.c +++ b/tools/xc/lib/xc_atropos.c @@ -9,7 +9,7 @@ #include "xc_private.h" int xc_atropos_domain_set(int xc_handle, - u64 domid, u64 period, u64 slice, u64 latency, + u32 domid, u64 period, u64 slice, u64 latency, int xtratime) { dom0_op_t op; @@ -28,7 +28,7 @@ int xc_atropos_domain_set(int xc_handle, return do_dom0_op(xc_handle, &op); } -int xc_atropos_domain_get(int xc_handle, u64 domid, u64 *period, +int xc_atropos_domain_get(int xc_handle, u32 domid, u64 *period, u64 *slice, u64 *latency, int *xtratime) { dom0_op_t op; diff --git a/tools/xc/lib/xc_bvtsched.c b/tools/xc/lib/xc_bvtsched.c index e5106b561b..aeaddcfb04 100644 --- a/tools/xc/lib/xc_bvtsched.c +++ b/tools/xc/lib/xc_bvtsched.c @@ -22,7 +22,7 @@ int xc_bvtsched_global_set(int xc_handle, } int xc_bvtsched_global_get(int xc_handle, - unsigned long *ctx_allow) + unsigned long *ctx_allow) { dom0_op_t op; int ret; @@ -39,7 +39,7 @@ int xc_bvtsched_global_get(int xc_handle, } int xc_bvtsched_domain_set(int xc_handle, - u64 domid, + u32 domid, unsigned long mcuadv, unsigned long warp, unsigned long warpl, @@ -62,9 +62,9 @@ int xc_bvtsched_domain_set(int xc_handle, int xc_bvtsched_domain_get(int xc_handle, - u64 domid, - unsigned long *mcuadv, - unsigned long *warp, + u32 domid, + unsigned long *mcuadv, + unsigned long *warp, unsigned long *warpl, unsigned long *warpu) { diff --git a/tools/xc/lib/xc_domain.c b/tools/xc/lib/xc_domain.c index dd8b4ec35f..97a919f8d6 100644 --- a/tools/xc/lib/xc_domain.c +++ b/tools/xc/lib/xc_domain.c @@ -11,8 +11,8 @@ int xc_domain_create(int xc_handle, unsigned int mem_kb, const char *name, - int cpu, - u64 *pdomid) + int cpu, + u32 *pdomid) { int err; dom0_op_t op; @@ -24,14 +24,14 @@ int xc_domain_create(int xc_handle, op.u.createdomain.cpu = cpu; if ( (err = do_dom0_op(xc_handle, &op)) == 0 ) - *pdomid = (u64)op.u.createdomain.domain; + *pdomid = (u32)op.u.createdomain.domain; return err; } int xc_domain_start(int xc_handle, - u64 domid) + u32 domid) { dom0_op_t op; op.cmd = DOM0_STARTDOMAIN; @@ -41,18 +41,18 @@ int xc_domain_start(int xc_handle, int xc_domain_stop(int xc_handle, - u64 domid) + u32 domid) { dom0_op_t op; op.cmd = DOM0_STOPDOMAIN; op.u.stopdomain.domain = (domid_t)domid; - op.u.stopdomain.sync = 0; // async + op.u.stopdomain.sync = 0; /* async */ return do_dom0_op(xc_handle, &op); } int xc_domain_destroy(int xc_handle, - u64 domid, + u32 domid, int force) { dom0_op_t op; @@ -63,7 +63,7 @@ int xc_domain_destroy(int xc_handle, } int xc_domain_pincpu(int xc_handle, - u64 domid, + u32 domid, int cpu) { dom0_op_t op; @@ -75,22 +75,22 @@ int xc_domain_pincpu(int xc_handle, int xc_domain_getinfo(int xc_handle, - u64 first_domid, + u32 first_domid, unsigned int max_doms, xc_dominfo_t *info) { unsigned int nr_doms; - u64 next_domid = first_domid; + u32 next_domid = first_domid; dom0_op_t op; for ( nr_doms = 0; nr_doms < max_doms; nr_doms++ ) { op.cmd = DOM0_GETDOMAININFO; op.u.getdomaininfo.domain = (domid_t)next_domid; - op.u.getdomaininfo.ctxt = NULL; // no exec context info, thanks. + op.u.getdomaininfo.ctxt = NULL; /* no exec context info, thanks. */ if ( do_dom0_op(xc_handle, &op) < 0 ) break; - info->domid = (u64)op.u.getdomaininfo.domain; + info->domid = (u32)op.u.getdomaininfo.domain; info->cpu = op.u.getdomaininfo.processor; info->has_cpu = op.u.getdomaininfo.has_cpu; info->stopped = (op.u.getdomaininfo.state == DOMSTATE_STOPPED); @@ -101,7 +101,7 @@ int xc_domain_getinfo(int xc_handle, strncpy(info->name, op.u.getdomaininfo.name, XC_DOMINFO_MAXNAME); info->name[XC_DOMINFO_MAXNAME-1] = '\0'; - next_domid = (u64)op.u.getdomaininfo.domain + 1; + next_domid = (u32)op.u.getdomaininfo.domain + 1; info++; } @@ -109,12 +109,12 @@ int xc_domain_getinfo(int xc_handle, } int xc_shadow_control(int xc_handle, - u64 domid, + u32 domid, unsigned int sop, - unsigned long *dirty_bitmap, - unsigned long pages, - unsigned long *fault_count, - unsigned long *dirty_count) + unsigned long *dirty_bitmap, + unsigned long pages, + unsigned long *fault_count, + unsigned long *dirty_count) { int rc; dom0_op_t op; @@ -126,18 +126,17 @@ int xc_shadow_control(int xc_handle, rc = do_dom0_op(xc_handle, &op); - if(fault_count) *fault_count = op.u.shadow_control.fault_count; - if(dirty_count) *dirty_count = op.u.shadow_control.dirty_count; + if ( fault_count ) + *fault_count = op.u.shadow_control.fault_count; + if ( dirty_count ) + *dirty_count = op.u.shadow_control.dirty_count; - if ( rc == 0 ) - return op.u.shadow_control.pages; - else - return rc; + return (rc == 0) ? op.u.shadow_control.pages : rc; } int xc_domain_setname(int xc_handle, - u64 domid, - char *name) + u32 domid, + char *name) { dom0_op_t op; op.cmd = DOM0_SETDOMAINNAME; @@ -147,8 +146,8 @@ int xc_domain_setname(int xc_handle, } int xc_domain_setinitialmem(int xc_handle, - u64 domid, - unsigned int initial_memkb) + u32 domid, + unsigned int initial_memkb) { dom0_op_t op; op.cmd = DOM0_SETDOMAININITIALMEM; @@ -158,8 +157,8 @@ int xc_domain_setinitialmem(int xc_handle, } int xc_domain_setmaxmem(int xc_handle, - u64 domid, - unsigned int max_memkb) + u32 domid, + unsigned int max_memkb) { dom0_op_t op; op.cmd = DOM0_SETDOMAINMAXMEM; diff --git a/tools/xc/lib/xc_evtchn.c b/tools/xc/lib/xc_evtchn.c index a92cc5b903..22654be515 100644 --- a/tools/xc/lib/xc_evtchn.c +++ b/tools/xc/lib/xc_evtchn.c @@ -30,8 +30,8 @@ static int do_evtchn_op(int xc_handle, evtchn_op_t *op) } int xc_evtchn_bind_interdomain(int xc_handle, - u64 dom1, - u64 dom2, + u32 dom1, + u32 dom2, int *port1, int *port2) { @@ -55,7 +55,7 @@ int xc_evtchn_bind_interdomain(int xc_handle, int xc_evtchn_close(int xc_handle, - u64 dom, + u32 dom, int port) { evtchn_op_t op; @@ -77,7 +77,7 @@ int xc_evtchn_send(int xc_handle, int xc_evtchn_status(int xc_handle, - u64 dom, + u32 dom, int port, xc_evtchn_status_t *status) { @@ -93,7 +93,7 @@ int xc_evtchn_status(int xc_handle, switch ( status->status = op.u.status.status ) { case EVTCHNSTAT_interdomain: - status->u.interdomain.dom = (u64)op.u.status.u.interdomain.dom; + status->u.interdomain.dom = (u32)op.u.status.u.interdomain.dom; status->u.interdomain.port = op.u.status.u.interdomain.port; break; case EVTCHNSTAT_pirq: diff --git a/tools/xc/lib/xc_linux_build.c b/tools/xc/lib/xc_linux_build.c index 98a3fb6a60..e5b1c01bbc 100644 --- a/tools/xc/lib/xc_linux_build.c +++ b/tools/xc/lib/xc_linux_build.c @@ -21,7 +21,7 @@ static int readelfimage_base_and_size(char *elfbase, static int loadelfimage(char *elfbase, int pmh, unsigned long *parray, unsigned long vstart); -static long get_tot_pages(int xc_handle, u64 domid) +static long get_tot_pages(int xc_handle, u32 domid) { dom0_op_t op; op.cmd = DOM0_GETDOMAININFO; @@ -32,7 +32,7 @@ static long get_tot_pages(int xc_handle, u64 domid) } static int get_pfn_list(int xc_handle, - u64 domid, + u32 domid, unsigned long *pfn_buf, unsigned long max_pfns) { @@ -66,12 +66,12 @@ static int copy_to_domain_page(int pm_handle, } static int setup_guestos(int xc_handle, - u64 dom, + u32 dom, char *image, unsigned long image_size, gzFile initrd_gfd, unsigned long initrd_len, unsigned long nr_pages, unsigned long *pvsi, unsigned long *pvke, - full_execution_context_t *ctxt, + full_execution_context_t *ctxt, const char *cmdline, unsigned long shared_info_frame, unsigned int control_evtchn) @@ -377,7 +377,7 @@ static char *read_kernel_image(const char *filename, unsigned long *size) } int xc_linux_build(int xc_handle, - u64 domid, + u32 domid, const char *image_name, const char *ramdisk_name, const char *cmdline, @@ -429,7 +429,7 @@ int xc_linux_build(int xc_handle, op.u.getdomaininfo.domain = (domid_t)domid; op.u.getdomaininfo.ctxt = ctxt; if ( (do_dom0_op(xc_handle, &op) < 0) || - ((u64)op.u.getdomaininfo.domain != domid) ) + ((u32)op.u.getdomaininfo.domain != domid) ) { PERROR("Could not get info on domain"); goto error_out; diff --git a/tools/xc/lib/xc_linux_restore.c b/tools/xc/lib/xc_linux_restore.c index e756ad6ffd..42a158e127 100644 --- a/tools/xc/lib/xc_linux_restore.c +++ b/tools/xc/lib/xc_linux_restore.c @@ -30,7 +30,7 @@ } while ( 0 ) static int get_pfn_list(int xc_handle, - u64 domain_id, + u32 domain_id, unsigned long *pfn_buf, unsigned long max_pfns) { @@ -56,11 +56,11 @@ static int get_pfn_list(int xc_handle, int xc_linux_restore(int xc_handle, - u64 dom, + u32 dom, unsigned int flags, - int (*readerfn)(void *, void *, size_t), - void *readerst, - u64 *pdomid) + int (*readerfn)(void *, void *, size_t), + void *readerst, + u32 *pdomid) { dom0_op_t op; int rc = 1, i, j, n, k; @@ -118,7 +118,7 @@ int xc_linux_restore(int xc_handle, if ( mlock(&ctxt, sizeof(ctxt) ) ) { /* needed for when we do the build dom0 op, - but might as well do early */ + but might as well do early */ PERROR("Unable to mlock ctxt"); return 1; } @@ -162,7 +162,7 @@ int xc_linux_restore(int xc_handle, region_mfn = calloc(1, 4 * MAX_BATCH_SIZE); if ( (pfn_to_mfn_table == NULL) || (pfn_type == NULL) || - (region_mfn == NULL) ) + (region_mfn == NULL) ) { errno = ENOMEM; goto out; @@ -184,7 +184,8 @@ int xc_linux_restore(int xc_handle, /* Set the domain's initial memory allocation to that from the restore file */ - if ( xc_domain_setinitialmem( xc_handle, dom, nr_pfns * (PAGE_SIZE / 1024)) ) + if ( xc_domain_setinitialmem(xc_handle, dom, + nr_pfns * (PAGE_SIZE / 1024)) ) { ERROR("Could not set domain initial memory"); goto out; @@ -230,8 +231,8 @@ int xc_linux_restore(int xc_handle, n=0; while(1) { - int j; - unsigned long region_pfn_type[MAX_BATCH_SIZE]; + int j; + unsigned long region_pfn_type[MAX_BATCH_SIZE]; this_pc = (n * 100) / nr_pfns; if ( (this_pc - prev_pc) >= 5 ) @@ -246,168 +247,180 @@ int xc_linux_restore(int xc_handle, goto out; } - DPRINTF("batch %d\n",j); - - if (j == -1) - { - verify = 1; - printf("Entering page verify mode\n"); - continue; - } - - if (j == 0) - { - break; // our work here is done - } - - if( j > MAX_BATCH_SIZE ) - { - ERROR("Max batch size exceeded. Giving up."); - goto out; - } - + DPRINTF("batch %d\n",j); + + if ( j == -1 ) + { + verify = 1; + printf("Entering page verify mode\n"); + continue; + } + + if ( j == 0 ) + break; /* our work here is done */ + + if( j > MAX_BATCH_SIZE ) + { + ERROR("Max batch size exceeded. Giving up."); + goto out; + } + if ( (*readerfn)(readerst, region_pfn_type, j*sizeof(unsigned long)) ) { ERROR("Error when reading from state file"); goto out; } - for(i=0;i<j;i++) - { + for(i=0;i<j;i++) + { if ( (region_pfn_type[i] & LTAB_MASK) == XTAB) - region_mfn[i] = 0; // we know map will fail, but don't care - else - { - pfn = region_pfn_type[i] & ~LTAB_MASK; - region_mfn[i] = pfn_to_mfn_table[pfn]; - } - } - - if ( (region_base = mfn_mapper_map_batch( xc_handle, dom, - PROT_WRITE, - region_mfn, - j )) == 0) - { - PERROR("map batch failed"); - goto out; - } - - for(i=0;i<j;i++) - { - unsigned long *ppage; - - pfn = region_pfn_type[i] & ~LTAB_MASK; + { + region_mfn[i] = 0; /* we know map will fail, but don't care */ + } + else + { + pfn = region_pfn_type[i] & ~LTAB_MASK; + region_mfn[i] = pfn_to_mfn_table[pfn]; + } + } + + if ( (region_base = mfn_mapper_map_batch( xc_handle, dom, + PROT_WRITE, + region_mfn, + j )) == 0) + { + PERROR("map batch failed"); + goto out; + } + + for(i=0;i<j;i++) + { + unsigned long *ppage; + + pfn = region_pfn_type[i] & ~LTAB_MASK; if ( (region_pfn_type[i] & LTAB_MASK) == XTAB) - continue; + continue; if (pfn>nr_pfns) - { - ERROR("pfn out of range"); - goto out; - } - - region_pfn_type[i] &= LTAB_MASK; - - pfn_type[pfn] = region_pfn_type[i]; - - mfn = pfn_to_mfn_table[pfn]; - - if ( verify ) - ppage = (unsigned long*) buf; // debug case - else - ppage = (unsigned long*) (region_base + i*PAGE_SIZE); - - if ( (*readerfn)(readerst, ppage, PAGE_SIZE) ) - { - ERROR("Error when reading from state file"); - goto out; - } - - switch( region_pfn_type[i] ) - { - case 0: - break; - - case L1TAB: - { - for ( k = 0; k < 1024; k++ ) - { - if ( ppage[k] & _PAGE_PRESENT ) - { - xpfn = ppage[k] >> PAGE_SHIFT; - - if ( xpfn >= nr_pfns ) - { - ERROR("Frame number in type %d page table is out of range. i=%d k=%d pfn=0x%x nr_pfns=%d",region_pfn_type[i]>>28,i,k,xpfn,nr_pfns); - goto out; - } - - ppage[k] &= (PAGE_SIZE - 1) & ~(_PAGE_GLOBAL | _PAGE_PAT); - ppage[k] |= pfn_to_mfn_table[xpfn] << PAGE_SHIFT; - } - } - } - break; - - case L2TAB: - { - for ( k = 0; k < (HYPERVISOR_VIRT_START>>L2_PAGETABLE_SHIFT); k++ ) - { - if ( ppage[k] & _PAGE_PRESENT ) - { - xpfn = ppage[k] >> PAGE_SHIFT; - - if ( xpfn >= nr_pfns ) - { - ERROR("Frame number in type %d page table is out of range. i=%d k=%d pfn=%d nr_pfns=%d",region_pfn_type[i]>>28,i,k,xpfn,nr_pfns); - - goto out; - } - - ppage[k] &= (PAGE_SIZE - 1) & ~(_PAGE_GLOBAL | _PAGE_PSE); - ppage[k] |= pfn_to_mfn_table[xpfn] << PAGE_SHIFT; - } - } - } - break; - - default: - ERROR("Bogus page type %x page table is out of range. i=%d nr_pfns=%d",region_pfn_type[i],i,nr_pfns); - goto out; - - } // end of page type switch statement - - if ( verify ) - { - int res = memcmp(buf, (region_base + i*PAGE_SIZE), PAGE_SIZE ); - if (res) - { - int v; - printf("************** pfn=%x type=%x gotcs=%08lx actualcs=%08lx\n",pfn,pfn_type[pfn],csum_page(region_base + i*PAGE_SIZE),csum_page(buf)); - for(v=0;v<4;v++) - { - unsigned long * p = (unsigned long *) (region_base + i*PAGE_SIZE); - if ( buf[v] != p[v] ) - printf(" %d: %08lx %08lx\n", - v, buf[v], p[v] ); - } - - } - } - - if ( add_mmu_update(xc_handle, mmu, - (mfn<<PAGE_SHIFT) | MMU_MACHPHYS_UPDATE, pfn) ) - { - printf("machpys mfn=%ld pfn=%ld\n",mfn,pfn); - goto out; - } - - } // end of 'batch' for loop - - munmap( region_base, j*PAGE_SIZE ); - n+=j; // crude stats + { + ERROR("pfn out of range"); + goto out; + } + + region_pfn_type[i] &= LTAB_MASK; + + pfn_type[pfn] = region_pfn_type[i]; + + mfn = pfn_to_mfn_table[pfn]; + + if ( verify ) + ppage = (unsigned long*) buf; /* debug case */ + else + ppage = (unsigned long*) (region_base + i*PAGE_SIZE); + + if ( (*readerfn)(readerst, ppage, PAGE_SIZE) ) + { + ERROR("Error when reading from state file"); + goto out; + } + + switch( region_pfn_type[i] ) + { + case 0: + break; + + case L1TAB: + { + for ( k = 0; k < 1024; k++ ) + { + if ( ppage[k] & _PAGE_PRESENT ) + { + xpfn = ppage[k] >> PAGE_SHIFT; + + if ( xpfn >= nr_pfns ) + { + ERROR("Frame number in type %d page table is " + "out of range. i=%d k=%d pfn=0x%x " + "nr_pfns=%d", region_pfn_type[i]>>28, i, + k, xpfn,nr_pfns); + goto out; + } + + ppage[k] &= (PAGE_SIZE - 1) & + ~(_PAGE_GLOBAL | _PAGE_PAT); + ppage[k] |= pfn_to_mfn_table[xpfn] << PAGE_SHIFT; + } + } + } + break; + + case L2TAB: + { + for ( k = 0; + k < (HYPERVISOR_VIRT_START>>L2_PAGETABLE_SHIFT); + k++ ) + { + if ( ppage[k] & _PAGE_PRESENT ) + { + xpfn = ppage[k] >> PAGE_SHIFT; + + if ( xpfn >= nr_pfns ) + { + ERROR("Frame number in type %d page table is " + "out of range. i=%d k=%d pfn=%d nr_pfns=%d", + region_pfn_type[i]>>28, i, k, xpfn, nr_pfns); + + goto out; + } + + ppage[k] &= (PAGE_SIZE - 1) & + ~(_PAGE_GLOBAL | _PAGE_PSE); + ppage[k] |= pfn_to_mfn_table[xpfn] << PAGE_SHIFT; + } + } + } + break; + + default: + ERROR("Bogus page type %x page table is out of range." + " i=%d nr_pfns=%d", region_pfn_type[i], i, nr_pfns); + goto out; + + } /* end of page type switch statement */ + + if ( verify ) + { + int res = memcmp(buf, (region_base + i*PAGE_SIZE), PAGE_SIZE ); + if (res) + { + int v; + printf("************** pfn=%x type=%x gotcs=%08lx " + "actualcs=%08lx\n", pfn, pfn_type[pfn], + csum_page(region_base + i*PAGE_SIZE), + csum_page(buf)); + for ( v = 0; v < 4; v++ ) + { + unsigned long *p = (unsigned long *) + (region_base + i*PAGE_SIZE); + if ( buf[v] != p[v] ) + printf(" %d: %08lx %08lx\n", + v, buf[v], p[v] ); + } + } + } + + if ( add_mmu_update(xc_handle, mmu, + (mfn<<PAGE_SHIFT) | MMU_MACHPHYS_UPDATE, pfn) ) + { + printf("machpys mfn=%ld pfn=%ld\n",mfn,pfn); + goto out; + } + + } /* end of 'batch' for loop */ + munmap( region_base, j*PAGE_SIZE ); + n+=j; /* crude stats */ } printf("Received all pages\n"); @@ -426,11 +439,11 @@ int xc_linux_restore(int xc_handle, (pfn_to_mfn_table[i]<<PAGE_SHIFT) | MMU_EXTENDED_COMMAND, MMUEXT_PIN_L1_TABLE) ) - { - printf("ERR pin L1 pfn=%lx mfn=%lx\n", - i, pfn_to_mfn_table[i]); + { + printf("ERR pin L1 pfn=%lx mfn=%lx\n", + i, pfn_to_mfn_table[i]); goto out; - } + } } else if ( pfn_type[i] == L2TAB ) { @@ -438,11 +451,11 @@ int xc_linux_restore(int xc_handle, (pfn_to_mfn_table[i]<<PAGE_SHIFT) | MMU_EXTENDED_COMMAND, MMUEXT_PIN_L2_TABLE) ) - { - printf("ERR pin L2 pfn=%lx mfn=%lx\n", - i, pfn_to_mfn_table[i]); + { + printf("ERR pin L2 pfn=%lx mfn=%lx\n", + i, pfn_to_mfn_table[i]); goto out; - } + } } } @@ -495,7 +508,7 @@ int xc_linux_restore(int xc_handle, if ( (pfn >= nr_pfns) || (pfn_type[pfn] != L2TAB) ) { printf("PT base is bad. pfn=%d nr=%d type=%08lx %08lx\n", - pfn, nr_pfns, pfn_type[pfn], L2TAB); + pfn, nr_pfns, pfn_type[pfn], L2TAB); ERROR("PT base is bad."); goto out; } @@ -504,8 +517,8 @@ int xc_linux_restore(int xc_handle, /* clear any pending events and the selector */ memset( &(((shared_info_t *)shared_info)->evtchn_pending[0]), - 0, sizeof (((shared_info_t *)shared_info)->evtchn_pending)+ - sizeof(((shared_info_t *)shared_info)->evtchn_pending_sel) ); + 0, sizeof (((shared_info_t *)shared_info)->evtchn_pending)+ + sizeof(((shared_info_t *)shared_info)->evtchn_pending_sel) ); /* Copy saved contents of shared-info page. No checking needed. */ ppage = map_pfn_writeable(pm_handle, shared_info_frame); @@ -516,7 +529,7 @@ int xc_linux_restore(int xc_handle, /* Uncanonicalise the pfn-to-mfn table frame-number list. */ for ( i = 0; i < (nr_pfns+1023)/1024; i++ ) { - unsigned long pfn, mfn; + unsigned long pfn, mfn; pfn = pfn_to_mfn_frame_list[i]; if ( (pfn >= nr_pfns) || (pfn_type[pfn] != NOTAB) ) @@ -524,21 +537,22 @@ int xc_linux_restore(int xc_handle, ERROR("PFN-to-MFN frame number is bad"); goto out; } - mfn = pfn_to_mfn_table[pfn]; - pfn_to_mfn_frame_list[i] = mfn; + mfn = pfn_to_mfn_table[pfn]; + pfn_to_mfn_frame_list[i] = mfn; } - if ( (live_pfn_to_mfn_table = mfn_mapper_map_batch( xc_handle, dom, - PROT_WRITE, - pfn_to_mfn_frame_list, - (nr_pfns+1023)/1024 )) == 0 ) + if ( (live_pfn_to_mfn_table = + mfn_mapper_map_batch(xc_handle, dom, + PROT_WRITE, + pfn_to_mfn_frame_list, + (nr_pfns+1023)/1024 )) == 0 ) { ERROR("Couldn't map pfn_to_mfn table"); goto out; } memcpy( live_pfn_to_mfn_table, pfn_to_mfn_table, - nr_pfns*sizeof(unsigned long) ); + nr_pfns*sizeof(unsigned long) ); munmap( live_pfn_to_mfn_table, ((nr_pfns+1023)/1024)*PAGE_SIZE ); @@ -586,18 +600,18 @@ int xc_linux_restore(int xc_handle, if( rc == 0 ) { - /* Success: print the domain id. */ - verbose_printf("DOM=%llu\n", dom); - return 0; + /* Success: print the domain id. */ + verbose_printf("DOM=%u\n", dom); + return 0; } out: - if ( rc != 0 ) // destroy if something went wrong + if ( rc != 0 ) { if ( dom != 0 ) { - xc_domain_destroy( xc_handle, dom, 1 ); + xc_domain_destroy( xc_handle, dom, 1 ); } } diff --git a/tools/xc/lib/xc_linux_save.c b/tools/xc/lib/xc_linux_save.c index 4913a8527f..35fe92f32d 100644 --- a/tools/xc/lib/xc_linux_save.c +++ b/tools/xc/lib/xc_linux_save.c @@ -47,8 +47,8 @@ (live_pfn_to_mfn_table[live_mfn_to_pfn_table[_mfn]] == (_mfn)) ) || \ \ (live_mfn_to_pfn_table[_mfn] >= 0x80000000 && \ - live_mfn_to_pfn_table[_mfn] <= 0x80000003 ) || \ - live_pfn_to_mfn_table[live_mfn_to_pfn_table[_mfn]] == 0x80000004 ) ) + live_mfn_to_pfn_table[_mfn] <= 0x80000003 ) || \ + live_pfn_to_mfn_table[live_mfn_to_pfn_table[_mfn]] == 0x80000004 ) ) /* Returns TRUE if MFN is successfully converted to a PFN. */ #define translate_mfn_to_pfn(_pmfn) \ @@ -67,19 +67,19 @@ static inline int test_bit ( int nr, volatile void * addr) { return ( ((unsigned long*)addr)[nr/(sizeof(unsigned long)*8)] >> - (nr % (sizeof(unsigned long)*8) ) ) & 1; + (nr % (sizeof(unsigned long)*8) ) ) & 1; } static inline void clear_bit ( int nr, volatile void * addr) { ((unsigned long*)addr)[nr/(sizeof(unsigned long)*8)] &= - ~(1 << (nr % (sizeof(unsigned long)*8) ) ); + ~(1 << (nr % (sizeof(unsigned long)*8) ) ); } static inline void set_bit ( int nr, volatile void * addr) { ((unsigned long*)addr)[nr/(sizeof(unsigned long)*8)] |= - (1 << (nr % (sizeof(unsigned long)*8) ) ); + (1 << (nr % (sizeof(unsigned long)*8) ) ); } /* * hweightN: returns the hamming weight (i.e. the number @@ -88,20 +88,20 @@ static inline void set_bit ( int nr, volatile void * addr) static inline unsigned int hweight32(unsigned int w) { - unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555); - res = (res & 0x33333333) + ((res >> 2) & 0x33333333); - res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F); - res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF); - return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF); + unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555); + res = (res & 0x33333333) + ((res >> 2) & 0x33333333); + res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F); + res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF); + return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF); } static inline int count_bits ( int nr, volatile void *addr) { int i, count = 0; unsigned long *p = (unsigned long *)addr; - // we know the array is padded to unsigned long + /* we know the array is padded to unsigned long */ for(i=0;i<nr/(sizeof(unsigned long)*8);i++,p++) - count += hweight32( *p ); + count += hweight32( *p ); return count; } @@ -131,10 +131,10 @@ static inline int permute( int i, int nr, int order_nr ) do { - i = ( ( i>>(order_nr-10)) | ( i<<10 ) ) & - ((1<<order_nr)-1); + i = ( ( i>>(order_nr-10)) | ( i<<10 ) ) & + ((1<<order_nr)-1); } - while ( i >= nr ); // this won't ever loop if nr is a power of 2 + while ( i >= nr ); /* this won't ever loop if nr is a power of 2 */ return i; } @@ -147,11 +147,11 @@ static long long tv_to_us( struct timeval *new ) static long long tvdelta( struct timeval *new, struct timeval *old ) { return ((new->tv_sec - old->tv_sec)*1000000 ) + - (new->tv_usec - old->tv_usec); + (new->tv_usec - old->tv_usec); } -static int track_cpu_usage( int xc_handle, u64 domid, int faults, - int pages_sent, int pages_dirtied, int print ) +static int track_cpu_usage( int xc_handle, u32 domid, int faults, + int pages_sent, int pages_dirtied, int print ) { static struct timeval wall_last; static long long d0_cpu_last; @@ -168,9 +168,9 @@ static int track_cpu_usage( int xc_handle, u64 domid, int faults, d0_cpu_now = xc_domain_get_cpu_usage( xc_handle, 0 )/1000; d1_cpu_now = xc_domain_get_cpu_usage( xc_handle, domid )/1000; - if ( d0_cpu_now == -1 || d1_cpu_now == -1 ) + if ( d0_cpu_now == -1 || d1_cpu_now == -1 ) { - printf("ARRHHH!!\n"); + printf("ARRHHH!!\n"); } wall_delta = tvdelta(&wall_now,&wall_last)/1000; @@ -181,27 +181,28 @@ static int track_cpu_usage( int xc_handle, u64 domid, int faults, d1_cpu_delta = (d1_cpu_now - d1_cpu_last)/1000; if(print) - printf("delta %lldms, dom0 %d%%, target %d%%, sent %dMb/s, dirtied %dMb/s\n", - wall_delta, - (int)((d0_cpu_delta*100)/wall_delta), - (int)((d1_cpu_delta*100)/wall_delta), - (int)((pages_sent*PAGE_SIZE*8)/(wall_delta*1000)), - (int)((pages_dirtied*PAGE_SIZE*8)/(wall_delta*1000)) - ); + printf("delta %lldms, dom0 %d%%, target %d%%, " + "sent %dMb/s, dirtied %dMb/s\n", + wall_delta, + (int)((d0_cpu_delta*100)/wall_delta), + (int)((d1_cpu_delta*100)/wall_delta), + (int)((pages_sent*PAGE_SIZE*8)/(wall_delta*1000)), + (int)((pages_dirtied*PAGE_SIZE*8)/(wall_delta*1000)) + ); d0_cpu_last = d0_cpu_now; d1_cpu_last = d1_cpu_now; - wall_last = wall_now; + wall_last = wall_now; return 0; } int xc_linux_save(int xc_handle, - u64 domid, - unsigned int flags, - int (*writerfn)(void *, const void *, size_t), - void *writerst ) + u32 domid, + unsigned int flags, + int (*writerfn)(void *, const void *, size_t), + void *writerst ) { dom0_op_t op; int rc = 1, i, j, k, last_iter, iter = 0; @@ -213,8 +214,8 @@ int xc_linux_save(int xc_handle, unsigned long dirtied_this_iter, faults_this_iter; /* Important tuning parameters */ - int max_iters = 29; // limit us to 30 times round loop - int max_factor = 3; // never send more than 3x nr_pfns + int max_iters = 29; /* limit us to 30 times round loop */ + int max_factor = 3; /* never send more than 3x nr_pfns */ /* The new domain's shared-info frame number. */ unsigned long shared_info_frame; @@ -275,8 +276,8 @@ int xc_linux_save(int xc_handle, if ( xc_domain_stop_sync( xc_handle, domid, &op, &ctxt ) ) { - PERROR("Could not sync stop domain"); - goto out; + PERROR("Could not sync stop domain"); + goto out; } memcpy(name, op.u.getdomaininfo.name, sizeof(name)); @@ -292,8 +293,8 @@ int xc_linux_save(int xc_handle, /* Map the suspend-record MFN to pin it. The page must be owned by domid for this to succeed. */ p_srec = mfn_mapper_map_single(xc_handle, domid, - sizeof(*p_srec), PROT_READ, - ctxt.cpu_ctxt.esi ); + sizeof(*p_srec), PROT_READ, + ctxt.cpu_ctxt.esi ); if (!p_srec) { @@ -312,9 +313,9 @@ int xc_linux_save(int xc_handle, /* the pfn_to_mfn_frame_list fits in a single page */ live_pfn_to_mfn_frame_list = - mfn_mapper_map_single(xc_handle, domid, - PAGE_SIZE, PROT_READ, - p_srec->pfn_to_mfn_frame_list ); + mfn_mapper_map_single(xc_handle, domid, + PAGE_SIZE, PROT_READ, + p_srec->pfn_to_mfn_frame_list ); if (!live_pfn_to_mfn_frame_list) { @@ -324,20 +325,20 @@ int xc_linux_save(int xc_handle, /* Track the mfn_to_pfn table down from the domains PT */ { - unsigned long *pgd; - unsigned long mfn_to_pfn_table_start_mfn; + unsigned long *pgd; + unsigned long mfn_to_pfn_table_start_mfn; - pgd = mfn_mapper_map_single(xc_handle, domid, - PAGE_SIZE, PROT_READ, - ctxt.pt_base>>PAGE_SHIFT); + pgd = mfn_mapper_map_single(xc_handle, domid, + PAGE_SIZE, PROT_READ, + ctxt.pt_base>>PAGE_SHIFT); - mfn_to_pfn_table_start_mfn = - pgd[HYPERVISOR_VIRT_START>>L2_PAGETABLE_SHIFT]>>PAGE_SHIFT; + mfn_to_pfn_table_start_mfn = + pgd[HYPERVISOR_VIRT_START>>L2_PAGETABLE_SHIFT]>>PAGE_SHIFT; - live_mfn_to_pfn_table = - mfn_mapper_map_single(xc_handle, ~0ULL, - PAGE_SIZE*1024, PROT_READ, - mfn_to_pfn_table_start_mfn ); + live_mfn_to_pfn_table = + mfn_mapper_map_single(xc_handle, DOMID_SELF, + PAGE_SIZE*1024, PROT_READ, + mfn_to_pfn_table_start_mfn ); } /* Map all the frames of the pfn->mfn table. For migrate to succeed, @@ -346,9 +347,9 @@ int xc_linux_save(int xc_handle, from a safety POV anyhow. */ live_pfn_to_mfn_table = mfn_mapper_map_batch( xc_handle, domid, - PROT_READ, - live_pfn_to_mfn_frame_list, - (nr_pfns+1023)/1024 ); + PROT_READ, + live_pfn_to_mfn_frame_list, + (nr_pfns+1023)/1024 ); if( !live_pfn_to_mfn_table ) { PERROR("Couldn't map pfn_to_mfn table"); @@ -372,64 +373,64 @@ int xc_linux_save(int xc_handle, if( live ) { - if ( xc_shadow_control( xc_handle, domid, - DOM0_SHADOW_CONTROL_OP_ENABLE_LOGDIRTY, - NULL, 0, NULL, NULL ) < 0 ) - { - ERROR("Couldn't enable shadow mode"); - goto out; - } - - if ( xc_domain_start( xc_handle, domid ) < 0 ) - { - ERROR("Couldn't restart domain"); - goto out; - } - - last_iter = 0; - sent_last_iter = 1<<20; // 4GB's worth of pages + if ( xc_shadow_control( xc_handle, domid, + DOM0_SHADOW_CONTROL_OP_ENABLE_LOGDIRTY, + NULL, 0, NULL, NULL ) < 0 ) + { + ERROR("Couldn't enable shadow mode"); + goto out; + } + + if ( xc_domain_start( xc_handle, domid ) < 0 ) + { + ERROR("Couldn't restart domain"); + goto out; + } + + last_iter = 0; + sent_last_iter = 1<<20; /* 4GB's worth of pages */ } else - last_iter = 1; + last_iter = 1; /* Setup to_send bitmap */ { - int sz = (nr_pfns/8) + 8; // includes slop at end of array - - to_send = malloc( sz ); - to_fix = calloc( 1, sz ); - to_skip = malloc( sz ); - - if (!to_send || !to_fix || !to_skip) - { - ERROR("Couldn't allocate to_send array"); - goto out; - } - - memset( to_send, 0xff, sz ); - - if ( mlock( to_send, sz ) ) - { - PERROR("Unable to mlock to_send"); - return 1; - } - - /* (to fix is local only) */ - - if ( mlock( to_skip, sz ) ) - { - PERROR("Unable to mlock to_skip"); - return 1; - } + int sz = (nr_pfns/8) + 8; /* includes slop at end of array */ + + to_send = malloc( sz ); + to_fix = calloc( 1, sz ); + to_skip = malloc( sz ); + + if (!to_send || !to_fix || !to_skip) + { + ERROR("Couldn't allocate to_send array"); + goto out; + } + + memset( to_send, 0xff, sz ); + + if ( mlock( to_send, sz ) ) + { + PERROR("Unable to mlock to_send"); + return 1; + } + + /* (to fix is local only) */ + + if ( mlock( to_skip, sz ) ) + { + PERROR("Unable to mlock to_skip"); + return 1; + } } /* calculate the power of 2 order of nr_pfns, e.g. - 15->4 16->4 17->5 */ + 15->4 16->4 17->5 */ for( i=nr_pfns-1, order_nr=0; i ; i>>=1, order_nr++ ); -printf("nr_pfns=%d order_nr=%d\n",nr_pfns, order_nr); + printf("nr_pfns=%d order_nr=%d\n",nr_pfns, order_nr); /* We want zeroed memory so use calloc rather than malloc. */ pfn_type = calloc(BATCH_SIZE, sizeof(unsigned long)); @@ -443,8 +444,8 @@ printf("nr_pfns=%d order_nr=%d\n",nr_pfns, order_nr); if ( mlock( pfn_type, BATCH_SIZE * sizeof(unsigned long) ) ) { - ERROR("Unable to mlock"); - goto out; + ERROR("Unable to mlock"); + goto out; } @@ -456,16 +457,16 @@ printf("nr_pfns=%d order_nr=%d\n",nr_pfns, order_nr); { mfn = live_pfn_to_mfn_table[i]; - if( (live_mfn_to_pfn_table[mfn] != i) && (mfn != 0x80000004) ) - printf("i=0x%x mfn=%x live_mfn_to_pfn_table=%x\n", - i,mfn,live_mfn_to_pfn_table[mfn]); + if( (live_mfn_to_pfn_table[mfn] != i) && (mfn != 0x80000004) ) + printf("i=0x%x mfn=%x live_mfn_to_pfn_table=%x\n", + i,mfn,live_mfn_to_pfn_table[mfn]); } #endif /* Map the shared info frame */ live_shinfo = mfn_mapper_map_single(xc_handle, domid, - PAGE_SIZE, PROT_READ, - shared_info_frame); + PAGE_SIZE, PROT_READ, + shared_info_frame); if (!live_shinfo) { @@ -490,297 +491,289 @@ printf("nr_pfns=%d order_nr=%d\n",nr_pfns, order_nr); while(1) { - unsigned int prev_pc, sent_this_iter, N, batch; - - iter++; - sent_this_iter = 0; - skip_this_iter = 0; - prev_pc = 0; - N=0; - - verbose_printf("Saving memory pages: iter %d 0%%", iter); - - while( N < nr_pfns ) - { - unsigned int this_pc = (N * 100) / nr_pfns; - - if ( (this_pc - prev_pc) >= 5 ) - { - verbose_printf("\b\b\b\b%3d%%", this_pc); - prev_pc = this_pc; - } - - /* slightly wasteful to peek the whole array evey time, - but this is fast enough for the moment. */ - - if ( !last_iter && - xc_shadow_control(xc_handle, domid, - DOM0_SHADOW_CONTROL_OP_PEEK, - to_skip, nr_pfns, NULL, NULL) != nr_pfns ) - { - ERROR("Error peeking shadow bitmap"); - goto out; - } - - - /* load pfn_type[] with the mfn of all the pages we're doing in - this batch. */ - - for( batch = 0; batch < BATCH_SIZE && N < nr_pfns ; N++ ) - { - int n = permute(N, nr_pfns, order_nr ); - - if(0 && debug) - fprintf(stderr,"%d pfn= %08lx mfn= %08lx %d [mfn]= %08lx\n", - iter, n, live_pfn_to_mfn_table[n], - test_bit(n,to_send), - live_mfn_to_pfn_table[live_pfn_to_mfn_table[n]&0xFFFFF]); - - if (!last_iter && test_bit(n, to_send) && test_bit(n, to_skip)) - skip_this_iter++; // stats keeping - - if (! ( (test_bit(n, to_send) && !test_bit(n, to_skip)) || - (test_bit(n, to_send) && last_iter) || - (test_bit(n, to_fix) && last_iter) ) ) - continue; - - /* we get here if: - 1. page is marked to_send & hasn't already been re-dirtied - 2. (ignore to_skip in last iteration) - 3. add in pages that still need fixup (net bufs) - */ - - pfn_batch[batch] = n; - pfn_type[batch] = live_pfn_to_mfn_table[n]; - - if( pfn_type[batch] == 0x80000004 ) - { - /* not currently in pusedo-physical map -- set bit - in to_fix that we must send this page in last_iter - unless its sent sooner anyhow */ - - set_bit( n, to_fix ); - if( iter>1 ) - DDPRINTF("Urk! netbuf race: iter %d, pfn %lx. mfn %lx\n", - iter,n,pfn_type[batch]); - continue; - } - - if ( last_iter && test_bit(n, to_fix ) && !test_bit(n, to_send )) - { - needed_to_fix++; - DPRINTF("Fix! iter %d, pfn %lx. mfn %lx\n", - iter,n,pfn_type[batch]); - } - - clear_bit( n, to_fix ); - - batch++; - } - - DDPRINTF("batch %d:%d (n=%d)\n",iter,batch,n); - - if(batch == 0) goto skip; // vanishingly unlikely... - - if ( (region_base = mfn_mapper_map_batch( xc_handle, domid, - PROT_READ, - pfn_type, - batch )) == 0) - { - PERROR("map batch failed"); - goto out; - } - - if ( get_pfn_type_batch(xc_handle, domid, batch, pfn_type) ) - { - ERROR("get_pfn_type_batch failed"); - goto out; - } - - for( j = 0; j < batch; j++ ) - { - if( (pfn_type[j] & LTAB_MASK) == XTAB) - { - DDPRINTF("type fail: page %i mfn %08lx\n",j,pfn_type[j]); - continue; - } - - if(0 && debug) - fprintf(stderr,"%d pfn= %08lx mfn= %08lx [mfn]= %08lx sum= %08lx\n", - iter, - (pfn_type[j] & LTAB_MASK) | pfn_batch[j], - pfn_type[j], - live_mfn_to_pfn_table[pfn_type[j]&(~LTAB_MASK)], - csum_page(region_base + (PAGE_SIZE*j)) - ); - - /* canonicalise mfn->pfn */ - pfn_type[j] = (pfn_type[j] & LTAB_MASK) | - pfn_batch[j]; - //live_mfn_to_pfn_table[pfn_type[j]&~LTAB_MASK]; - - } - - - if ( (*writerfn)(writerst, &batch, sizeof(int) ) ) - { - ERROR("Error when writing to state file (2)"); - goto out; - } - - if ( (*writerfn)(writerst, pfn_type, sizeof(unsigned long)*j ) ) - { - ERROR("Error when writing to state file (3)"); - goto out; - } - - /* entering this loop, pfn_type is now in pfns (Not mfns) */ - for( j = 0; j < batch; j++ ) - { - /* write out pages in batch */ - - if( (pfn_type[j] & LTAB_MASK) == XTAB) - { - DDPRINTF("SKIP BOGUS page %i mfn %08lx\n",j,pfn_type[j]); - continue; - } - - if ( ((pfn_type[j] & LTAB_MASK) == L1TAB) || - ((pfn_type[j] & LTAB_MASK) == L2TAB) ) - { - - memcpy(page, region_base + (PAGE_SIZE*j), PAGE_SIZE); - - for ( k = 0; - k < (((pfn_type[j] & LTAB_MASK) == L2TAB) ? - (HYPERVISOR_VIRT_START >> L2_PAGETABLE_SHIFT) : 1024); - k++ ) - { - unsigned long pfn; - - if ( !(page[k] & _PAGE_PRESENT) ) continue; - mfn = page[k] >> PAGE_SHIFT; - pfn = live_mfn_to_pfn_table[mfn]; - - if ( !MFN_IS_IN_PSEUDOPHYS_MAP(mfn) ) - { - // I don't think this should ever happen - - printf("FNI %d : [%08lx,%d] pte=%08lx, mfn=%08lx, pfn=%08lx [mfn]=%08lx\n", - j, pfn_type[j], k, - page[k], mfn, live_mfn_to_pfn_table[mfn], - (live_mfn_to_pfn_table[mfn]<nr_pfns)? - live_pfn_to_mfn_table[live_mfn_to_pfn_table[mfn]]: 0xdeadbeef); - - pfn = 0; // be suspicious, very suspicious - - //goto out; // let's try our luck - - - } - page[k] &= PAGE_SIZE - 1; - page[k] |= pfn << PAGE_SHIFT; - -#if 0 - printf("L%d i=%d pfn=%d mfn=%d k=%d pte=%08lx xpfn=%d\n", - pfn_type[j]>>28, - j,i,mfn,k,page[k],page[k]>>PAGE_SHIFT); -#endif - - } /* end of page table rewrite for loop */ - - if ( (*writerfn)(writerst, page, PAGE_SIZE) ) - { - ERROR("Error when writing to state file (4)"); - goto out; - } - - } /* end of it's a PT page */ - else - { /* normal page */ - - if ( (*writerfn)(writerst, region_base + (PAGE_SIZE*j), PAGE_SIZE) ) - { - ERROR("Error when writing to state file (5)"); - goto out; - } - } - } /* end of the write out for this batch */ - - sent_this_iter += batch; - - } /* end of this while loop for this iteration */ - - munmap(region_base, batch*PAGE_SIZE); + unsigned int prev_pc, sent_this_iter, N, batch; + + iter++; + sent_this_iter = 0; + skip_this_iter = 0; + prev_pc = 0; + N=0; + + verbose_printf("Saving memory pages: iter %d 0%%", iter); + + while( N < nr_pfns ) + { + unsigned int this_pc = (N * 100) / nr_pfns; + + if ( (this_pc - prev_pc) >= 5 ) + { + verbose_printf("\b\b\b\b%3d%%", this_pc); + prev_pc = this_pc; + } + + /* slightly wasteful to peek the whole array evey time, + but this is fast enough for the moment. */ + + if ( !last_iter && + xc_shadow_control(xc_handle, domid, + DOM0_SHADOW_CONTROL_OP_PEEK, + to_skip, nr_pfns, NULL, NULL) != nr_pfns ) + { + ERROR("Error peeking shadow bitmap"); + goto out; + } + + + /* load pfn_type[] with the mfn of all the pages we're doing in + this batch. */ + + for( batch = 0; batch < BATCH_SIZE && N < nr_pfns ; N++ ) + { + int n = permute(N, nr_pfns, order_nr ); + + if(0 && debug) + fprintf(stderr,"%d pfn= %08lx mfn= %08lx %d " + "[mfn]= %08lx\n", + iter, n, live_pfn_to_mfn_table[n], + test_bit(n,to_send), + live_mfn_to_pfn_table[ + live_pfn_to_mfn_table[n]&0xFFFFF]); + + if (!last_iter && test_bit(n, to_send) && test_bit(n, to_skip)) + skip_this_iter++; /* stats keeping */ + + if (! ( (test_bit(n, to_send) && !test_bit(n, to_skip)) || + (test_bit(n, to_send) && last_iter) || + (test_bit(n, to_fix) && last_iter) ) ) + continue; + + /* we get here if: + 1. page is marked to_send & hasn't already been re-dirtied + 2. (ignore to_skip in last iteration) + 3. add in pages that still need fixup (net bufs) + */ + + pfn_batch[batch] = n; + pfn_type[batch] = live_pfn_to_mfn_table[n]; + + if( pfn_type[batch] == 0x80000004 ) + { + /* not currently in pusedo-physical map -- set bit + in to_fix that we must send this page in last_iter + unless its sent sooner anyhow */ + + set_bit( n, to_fix ); + if( iter>1 ) + DDPRINTF("Urk! netbuf race: iter %d, pfn %lx." + " mfn %lx\n", + iter,n,pfn_type[batch]); + continue; + } + + if ( last_iter && test_bit(n, to_fix) && + !test_bit(n, to_send) ) + { + needed_to_fix++; + DPRINTF("Fix! iter %d, pfn %lx. mfn %lx\n", + iter,n,pfn_type[batch]); + } + + clear_bit( n, to_fix ); + + batch++; + } + + DDPRINTF("batch %d:%d (n=%d)\n",iter,batch,n); + + if ( batch == 0 ) + goto skip; /* very unlikely */ + + if ( (region_base = mfn_mapper_map_batch(xc_handle, domid, + PROT_READ, + pfn_type, + batch)) == 0 ) + { + PERROR("map batch failed"); + goto out; + } + + if ( get_pfn_type_batch(xc_handle, domid, batch, pfn_type) ) + { + ERROR("get_pfn_type_batch failed"); + goto out; + } + + for ( j = 0; j < batch; j++ ) + { + if ( (pfn_type[j] & LTAB_MASK) == XTAB ) + { + DDPRINTF("type fail: page %i mfn %08lx\n",j,pfn_type[j]); + continue; + } + + if ( 0 && debug ) + fprintf(stderr,"%d pfn= %08lx mfn= %08lx " + "[mfn]= %08lx sum= %08lx\n", + iter, + (pfn_type[j] & LTAB_MASK) | pfn_batch[j], + pfn_type[j], + live_mfn_to_pfn_table[pfn_type[j]&(~LTAB_MASK)], + csum_page(region_base + (PAGE_SIZE*j)) + ); + + /* canonicalise mfn->pfn */ + pfn_type[j] = (pfn_type[j] & LTAB_MASK) | + pfn_batch[j]; + } + + + if ( (*writerfn)(writerst, &batch, sizeof(int) ) ) + { + ERROR("Error when writing to state file (2)"); + goto out; + } + + if ( (*writerfn)(writerst, pfn_type, sizeof(unsigned long)*j ) ) + { + ERROR("Error when writing to state file (3)"); + goto out; + } + + /* entering this loop, pfn_type is now in pfns (Not mfns) */ + for( j = 0; j < batch; j++ ) + { + /* write out pages in batch */ + + if( (pfn_type[j] & LTAB_MASK) == XTAB) + { + DDPRINTF("SKIP BOGUS page %i mfn %08lx\n",j,pfn_type[j]); + continue; + } + + if ( ((pfn_type[j] & LTAB_MASK) == L1TAB) || + ((pfn_type[j] & LTAB_MASK) == L2TAB) ) + { + + memcpy(page, region_base + (PAGE_SIZE*j), PAGE_SIZE); + + for ( k = 0; + k < (((pfn_type[j] & LTAB_MASK) == L2TAB) ? + (HYPERVISOR_VIRT_START >> L2_PAGETABLE_SHIFT) : + 1024); + k++ ) + { + unsigned long pfn; + + if ( !(page[k] & _PAGE_PRESENT) ) continue; + mfn = page[k] >> PAGE_SHIFT; + pfn = live_mfn_to_pfn_table[mfn]; + + if ( !MFN_IS_IN_PSEUDOPHYS_MAP(mfn) ) + { + /* I don't think this should ever happen */ + printf("FNI %d : [%08lx,%d] pte=%08lx, " + "mfn=%08lx, pfn=%08lx [mfn]=%08lx\n", + j, pfn_type[j], k, + page[k], mfn, live_mfn_to_pfn_table[mfn], + (live_mfn_to_pfn_table[mfn]<nr_pfns)? + live_pfn_to_mfn_table[ + live_mfn_to_pfn_table[mfn]]:0xdeadbeef); + pfn = 0; /* be suspicious, very suspicious */ + } + page[k] &= PAGE_SIZE - 1; + page[k] |= pfn << PAGE_SHIFT; + } /* end of page table rewrite for loop */ + + if ( (*writerfn)(writerst, page, PAGE_SIZE) ) + { + ERROR("Error when writing to state file (4)"); + goto out; + } + + } /* end of it's a PT page */ + else + { /* normal page */ + + if ( (*writerfn)(writerst, region_base + (PAGE_SIZE*j), + PAGE_SIZE) ) + { + ERROR("Error when writing to state file (5)"); + goto out; + } + } + } /* end of the write out for this batch */ + + sent_this_iter += batch; + + } /* end of this while loop for this iteration */ + + munmap(region_base, batch*PAGE_SIZE); skip: - total_sent += sent_this_iter; + total_sent += sent_this_iter; - verbose_printf("\r %d: sent %d, skipped %d, ", - iter, sent_this_iter, skip_this_iter ); + verbose_printf("\r %d: sent %d, skipped %d, ", + iter, sent_this_iter, skip_this_iter ); - if ( last_iter ) - { - track_cpu_usage( xc_handle, domid, 0, sent_this_iter, 0, 1); + if ( last_iter ) + { + track_cpu_usage( xc_handle, domid, 0, sent_this_iter, 0, 1); - verbose_printf("Total pages sent= %d (%.2fx)\n", - total_sent, ((float)total_sent)/nr_pfns ); - verbose_printf("(of which %d were fixups)\n", needed_to_fix ); - } + verbose_printf("Total pages sent= %d (%.2fx)\n", + total_sent, ((float)total_sent)/nr_pfns ); + verbose_printf("(of which %d were fixups)\n", needed_to_fix ); + } - if ( debug && last_iter ) - { - int minusone = -1; - memset( to_send, 0xff, nr_pfns/8 ); - debug = 0; - printf("Entering debug resend-all mode\n"); + if ( debug && last_iter ) + { + int minusone = -1; + memset( to_send, 0xff, nr_pfns/8 ); + debug = 0; + printf("Entering debug resend-all mode\n"); - /* send "-1" to put receiver into debug mode */ - if ( (*writerfn)(writerst, &minusone, sizeof(int)) ) - { - ERROR("Error when writing to state file (6)"); - goto out; - } - - continue; - } - - if ( last_iter ) - break; - - if ( live ) - { - if ( - // ( sent_this_iter > (sent_last_iter * 0.95) ) || - (iter >= max_iters) || - (sent_this_iter+skip_this_iter < 50) || - (total_sent > nr_pfns*max_factor) ) - { - DPRINTF("Start last iteration\n"); - last_iter = 1; - - xc_domain_stop_sync( xc_handle, domid, &op, NULL ); - - } - - if ( xc_shadow_control( xc_handle, domid, - DOM0_SHADOW_CONTROL_OP_CLEAN2, - to_send, nr_pfns, &faults_this_iter, - &dirtied_this_iter) != nr_pfns ) - { - ERROR("Error flushing shadow PT"); - goto out; - } - - sent_last_iter = sent_this_iter; - - //dirtied_this_iter = count_bits( nr_pfns, to_send ); - track_cpu_usage( xc_handle, domid, faults_this_iter, - sent_this_iter, dirtied_this_iter, 1); - - } + /* send "-1" to put receiver into debug mode */ + if ( (*writerfn)(writerst, &minusone, sizeof(int)) ) + { + ERROR("Error when writing to state file (6)"); + goto out; + } + + continue; + } + if ( last_iter ) + break; + + if ( live ) + { + if ( (iter >= max_iters) || + (sent_this_iter+skip_this_iter < 50) || + (total_sent > nr_pfns*max_factor) ) + { + DPRINTF("Start last iteration\n"); + last_iter = 1; + + xc_domain_stop_sync( xc_handle, domid, &op, NULL ); + + } + + if ( xc_shadow_control( xc_handle, domid, + DOM0_SHADOW_CONTROL_OP_CLEAN2, + to_send, nr_pfns, &faults_this_iter, + &dirtied_this_iter) != nr_pfns ) + { + ERROR("Error flushing shadow PT"); + goto out; + } + + sent_last_iter = sent_this_iter; + + /* dirtied_this_iter = count_bits( nr_pfns, to_send ); */ + track_cpu_usage( xc_handle, domid, faults_this_iter, + sent_this_iter, dirtied_this_iter, 1); + + } } /* end of while 1 */ @@ -792,8 +785,8 @@ printf("nr_pfns=%d order_nr=%d\n",nr_pfns, order_nr); /* Zero terminate */ if ( (*writerfn)(writerst, &rc, sizeof(int)) ) { - ERROR("Error when writing to state file (6)"); - goto out; + ERROR("Error when writing to state file (6)"); + goto out; } /* Get the final execution context */ @@ -801,10 +794,10 @@ printf("nr_pfns=%d order_nr=%d\n",nr_pfns, order_nr); op.u.getdomaininfo.domain = (domid_t)domid; op.u.getdomaininfo.ctxt = &ctxt; if ( (do_dom0_op(xc_handle, &op) < 0) || - ((u64)op.u.getdomaininfo.domain != domid) ) + ((u32)op.u.getdomaininfo.domain != domid) ) { - PERROR("Could not get info on domain"); - goto out; + PERROR("Could not get info on domain"); + goto out; } /* Canonicalise the suspend-record frame number. */ @@ -830,18 +823,18 @@ printf("nr_pfns=%d order_nr=%d\n",nr_pfns, order_nr); ERROR("PT base is not in range of pseudophys map"); goto out; } - ctxt.pt_base = live_mfn_to_pfn_table[ctxt.pt_base >> PAGE_SHIFT] << PAGE_SHIFT; + ctxt.pt_base = live_mfn_to_pfn_table[ctxt.pt_base >> PAGE_SHIFT] << + PAGE_SHIFT; - if ( (*writerfn)(writerst, &ctxt, sizeof(ctxt)) || - (*writerfn)(writerst, live_shinfo, PAGE_SIZE) ) + if ( (*writerfn)(writerst, &ctxt, sizeof(ctxt)) || + (*writerfn)(writerst, live_shinfo, PAGE_SIZE) ) { ERROR("Error when writing to state file (1)"); goto out; } munmap(live_shinfo, PAGE_SIZE); -out: - + out: if ( pfn_type != NULL ) free(pfn_type); diff --git a/tools/xc/lib/xc_misc.c b/tools/xc/lib/xc_misc.c index 9f087d56fb..0019ffe96b 100644 --- a/tools/xc/lib/xc_misc.c +++ b/tools/xc/lib/xc_misc.c @@ -20,7 +20,7 @@ int xc_interface_close(int xc_handle) } -#define CONSOLE_RING_CLEAR 1 +#define CONSOLE_RING_CLEAR 1 int xc_readconsolering(int xc_handle, char *str, @@ -48,7 +48,7 @@ int xc_readconsolering(int xc_handle, int xc_physinfo(int xc_handle, - xc_physinfo_t *put_info) + xc_physinfo_t *put_info) { int ret; dom0_op_t op; diff --git a/tools/xc/lib/xc_netbsd_build.c b/tools/xc/lib/xc_netbsd_build.c index 7c67d57d71..b3dfcc7314 100644 --- a/tools/xc/lib/xc_netbsd_build.c +++ b/tools/xc/lib/xc_netbsd_build.c @@ -22,7 +22,7 @@ static int loadelfimage(gzFile, int, unsigned long *, unsigned long, #define L1_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED) #define L2_PROT (_PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER) -static long get_tot_pages(int xc_handle, u64 domid) +static long get_tot_pages(int xc_handle, u32 domid) { dom0_op_t op; op.cmd = DOM0_GETDOMAININFO; @@ -33,7 +33,7 @@ static long get_tot_pages(int xc_handle, u64 domid) } static int get_pfn_list(int xc_handle, - u64 domid, + u32 domid, unsigned long *pfn_buf, unsigned long max_pfns) { @@ -55,12 +55,12 @@ static int get_pfn_list(int xc_handle, } static int setup_guestos(int xc_handle, - u64 dom, + u32 dom, gzFile kernel_gfd, unsigned long tot_pages, unsigned long *virt_startinfo_addr, unsigned long *virt_load_addr, - full_execution_context_t *ctxt, + full_execution_context_t *ctxt, const char *cmdline, unsigned long shared_info_frame, unsigned int control_evtchn) @@ -209,7 +209,7 @@ static int setup_guestos(int xc_handle, } int xc_netbsd_build(int xc_handle, - u64 domid, + u32 domid, const char *image_name, const char *cmdline, unsigned int control_evtchn) @@ -253,7 +253,7 @@ int xc_netbsd_build(int xc_handle, op.u.getdomaininfo.domain = (domid_t)domid; op.u.getdomaininfo.ctxt = ctxt; if ( (do_dom0_op(xc_handle, &op) < 0) || - ((u64)op.u.getdomaininfo.domain != domid) ) + ((u32)op.u.getdomaininfo.domain != domid) ) { PERROR("Could not get info on domain"); goto error_out; diff --git a/tools/xc/lib/xc_physdev.c b/tools/xc/lib/xc_physdev.c index fb35843586..ba5dd9ccdc 100644 --- a/tools/xc/lib/xc_physdev.c +++ b/tools/xc/lib/xc_physdev.c @@ -10,7 +10,7 @@ #include "xc_private.h" int xc_physdev_pci_access_modify(int xc_handle, - u64 domid, + u32 domid, int bus, int dev, int func, diff --git a/tools/xc/lib/xc_private.c b/tools/xc/lib/xc_private.c index 32cc908d40..c602a56630 100644 --- a/tools/xc/lib/xc_private.c +++ b/tools/xc/lib/xc_private.c @@ -10,10 +10,7 @@ int init_pfn_mapper(domid_t domid) { int fd = open("/dev/mem", O_RDWR); if ( fd >= 0 ) - { - (void)ioctl(fd, _IO('M', 1), (unsigned long)(domid>> 0)); /* low */ - (void)ioctl(fd, _IO('M', 2), (unsigned long)(domid>>32)); /* high */ - } + (void)ioctl(fd, _IO('M', 1), (unsigned long)domid); return fd; } @@ -48,23 +45,23 @@ void unmap_pfn(int pm_handle, void *vaddr) /*******************/ void * mfn_mapper_map_batch(int xc_handle, domid_t dom, int prot, - unsigned long *arr, int num ) + unsigned long *arr, int num ) { privcmd_mmapbatch_t ioctlx; void *addr; addr = mmap( NULL, num*PAGE_SIZE, prot, MAP_SHARED, xc_handle, 0 ); if (addr) { - ioctlx.num=num; - ioctlx.dom=dom; - ioctlx.addr=(unsigned long)addr; - ioctlx.arr=arr; - if ( ioctl( xc_handle, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx ) <0 ) - { - perror("XXXXXXXX"); - munmap(addr, num*PAGE_SIZE); - return 0; - } + ioctlx.num=num; + ioctlx.dom=dom; + ioctlx.addr=(unsigned long)addr; + ioctlx.arr=arr; + if ( ioctl( xc_handle, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx ) < 0 ) + { + perror("XXXXXXXX"); + munmap(addr, num*PAGE_SIZE); + return 0; + } } return addr; @@ -73,8 +70,8 @@ void * mfn_mapper_map_batch(int xc_handle, domid_t dom, int prot, /*******************/ void * mfn_mapper_map_single(int xc_handle, domid_t dom, - int size, int prot, - unsigned long mfn ) + int size, int prot, + unsigned long mfn ) { privcmd_mmap_t ioctlx; privcmd_mmap_entry_t entry; @@ -82,17 +79,17 @@ void * mfn_mapper_map_single(int xc_handle, domid_t dom, addr = mmap( NULL, size, prot, MAP_SHARED, xc_handle, 0 ); if (addr) { - ioctlx.num=1; - ioctlx.dom=dom; - ioctlx.entry=&entry; - entry.va=(unsigned long) addr; - entry.mfn=mfn; - entry.npages=(size+PAGE_SIZE-1)>>PAGE_SHIFT; - if ( ioctl( xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx ) <0 ) - { - munmap(addr, size); - return 0; - } + ioctlx.num=1; + ioctlx.dom=dom; + ioctlx.entry=&entry; + entry.va=(unsigned long) addr; + entry.mfn=mfn; + entry.npages=(size+PAGE_SIZE-1)>>PAGE_SHIFT; + if ( ioctl( xc_handle, IOCTL_PRIVCMD_MMAP, &ioctlx ) <0 ) + { + munmap(addr, size); + return 0; + } } return addr; } @@ -101,7 +98,7 @@ void * mfn_mapper_map_single(int xc_handle, domid_t dom, /* NB: arr must be mlock'ed */ int get_pfn_type_batch(int xc_handle, - u64 dom, int num, unsigned long *arr) + u32 dom, int num, unsigned long *arr) { dom0_op_t op; op.cmd = DOM0_GETPAGEFRAMEINFO2; @@ -113,8 +110,8 @@ int get_pfn_type_batch(int xc_handle, #define GETPFN_ERR (~0U) unsigned int get_pfn_type(int xc_handle, - unsigned long mfn, - u64 dom) + unsigned long mfn, + u32 dom) { dom0_op_t op; op.cmd = DOM0_GETPAGEFRAMEINFO; @@ -132,7 +129,7 @@ unsigned int get_pfn_type(int xc_handle, /*******************/ -#define FIRST_MMU_UPDATE 2 +#define FIRST_MMU_UPDATE 1 static int flush_mmu_updates(int xc_handle, mmu_t *mmu) { @@ -145,12 +142,8 @@ static int flush_mmu_updates(int xc_handle, mmu_t *mmu) /* The first two requests set the correct subject domain (PTS and GPS). */ mmu->updates[0].val = (unsigned long)(mmu->subject<<16) & ~0xFFFFUL; mmu->updates[0].ptr = (unsigned long)(mmu->subject<< 0) & ~0xFFFFUL; - mmu->updates[1].val = (unsigned long)(mmu->subject>>16) & ~0xFFFFUL; - mmu->updates[1].ptr = (unsigned long)(mmu->subject>>32) & ~0xFFFFUL; mmu->updates[0].ptr |= MMU_EXTENDED_COMMAND; - mmu->updates[0].val |= MMUEXT_SET_SUBJECTDOM_L; - mmu->updates[1].ptr |= MMU_EXTENDED_COMMAND; - mmu->updates[1].val |= MMUEXT_SET_SUBJECTDOM_H | SET_PAGETABLE_SUBJECTDOM; + mmu->updates[0].val |= MMUEXT_SET_SUBJECTDOM | SET_PAGETABLE_SUBJECTDOM; hypercall.op = __HYPERVISOR_mmu_update; hypercall.arg[0] = (unsigned long)mmu->updates; @@ -211,46 +204,43 @@ int finish_mmu_updates(int xc_handle, mmu_t *mmu) /* this function is a hack until we get proper synchronous domain stop */ int xc_domain_stop_sync( int xc_handle, domid_t domid, - dom0_op_t *op, full_execution_context_t *ctxt) + dom0_op_t *op, full_execution_context_t *ctxt) { int i; printf("Sleep:"); - for(i=0;;i++) + for( i = 0; ; i++ ) { - op->cmd = DOM0_STOPDOMAIN; - op->u.stopdomain.domain = (domid_t)domid; - op->u.stopdomain.sync = 1; - do_dom0_op(xc_handle, op); - /* can't trust return code due to sync stop hack :-(( */ + op->cmd = DOM0_STOPDOMAIN; + op->u.stopdomain.domain = (domid_t)domid; + op->u.stopdomain.sync = 1; + do_dom0_op(xc_handle, op); + /* can't trust return code due to sync stop hack :-(( */ - op->cmd = DOM0_GETDOMAININFO; op->u.getdomaininfo.domain = (domid_t)domid; op->u.getdomaininfo.ctxt = ctxt; if ( (do_dom0_op(xc_handle, op) < 0) || - ((u64)op->u.getdomaininfo.domain != domid) ) + ((u32)op->u.getdomaininfo.domain != domid) ) { PERROR("Could not get info on domain"); goto out; } if ( op->u.getdomaininfo.state == DOMSTATE_STOPPED ) - { - printf("Domain %lld stopped\n",domid); + { + printf("Domain %u stopped\n",domid); return 0; - } - - printf("."); - - //usleep(1000); + } + + printf("."); } printf("\n"); -out: + out: return -1; } @@ -262,10 +252,10 @@ long long xc_domain_get_cpu_usage( int xc_handle, domid_t domid ) op.u.getdomaininfo.domain = (domid_t)domid; op.u.getdomaininfo.ctxt = NULL; if ( (do_dom0_op(xc_handle, &op) < 0) || - ((u64)op.u.getdomaininfo.domain != domid) ) + ((u32)op.u.getdomaininfo.domain != domid) ) { - PERROR("Could not get info on domain"); - return -1; + PERROR("Could not get info on domain"); + return -1; } return op.u.getdomaininfo.cpu_time; } @@ -273,18 +263,15 @@ long long xc_domain_get_cpu_usage( int xc_handle, domid_t domid ) /**********************************************************************/ -// this is shared between save and restore, and may be useful. - -unsigned long csum_page ( void * page ) +/* This is shared between save and restore, and may generally be useful. */ +unsigned long csum_page (void * page) { int i; unsigned long *p = page; unsigned long long sum=0; - for (i=0;i<PAGE_SIZE/sizeof(unsigned long);i++) - { - sum += p[i]; - } + for ( i = 0; i < (PAGE_SIZE/sizeof(unsigned long)); i++ ) + sum += p[i]; return sum ^ (sum>>32); } diff --git a/tools/xc/lib/xc_vbd.c b/tools/xc/lib/xc_vbd.c index 00d166d03d..a23e0b0603 100644 --- a/tools/xc/lib/xc_vbd.c +++ b/tools/xc/lib/xc_vbd.c @@ -10,7 +10,7 @@ #include "xc_private.h" int xc_vbd_create(int xc_handle, - u64 domid, + u32 domid, unsigned short vbdid, int writeable) { @@ -24,7 +24,7 @@ int xc_vbd_create(int xc_handle, int xc_vbd_destroy(int xc_handle, - u64 domid, + u32 domid, unsigned short vbdid) { block_io_op_t op; @@ -36,7 +36,7 @@ int xc_vbd_destroy(int xc_handle, int xc_vbd_grow(int xc_handle, - u64 domid, + u32 domid, unsigned short vbdid, xc_vbdextent_t *extent) { @@ -52,7 +52,7 @@ int xc_vbd_grow(int xc_handle, int xc_vbd_shrink(int xc_handle, - u64 domid, + u32 domid, unsigned short vbdid) { block_io_op_t op; @@ -64,7 +64,7 @@ int xc_vbd_shrink(int xc_handle, int xc_vbd_setextents(int xc_handle, - u64 domid, + u32 domid, unsigned short vbdid, unsigned int nr_extents, xc_vbdextent_t *extents) @@ -112,7 +112,7 @@ int xc_vbd_setextents(int xc_handle, int xc_vbd_getextents(int xc_handle, - u64 domid, + u32 domid, unsigned short vbdid, unsigned int max_extents, xc_vbdextent_t *extents, @@ -161,7 +161,7 @@ int xc_vbd_getextents(int xc_handle, int xc_vbd_probe(int xc_handle, - u64 domid, + u32 domid, unsigned int max_vbds, xc_vbd_t *vbds) { @@ -194,7 +194,7 @@ int xc_vbd_probe(int xc_handle, if ( !(xdi->disks[i].info & XD_FLAG_VIRT) ) continue; - vbds[j].domid = (u64)xdi->disks[i].domain; + vbds[j].domid = (u32)xdi->disks[i].domain; vbds[j].vbdid = xdi->disks[i].device; vbds[j].flags = (xdi->disks[i].info & XD_FLAG_RO) ? 0 : XC_VBDF_WRITEABLE; diff --git a/tools/xc/lib/xc_vif.c b/tools/xc/lib/xc_vif.c index 518abfa0e3..cae5e3438c 100644 --- a/tools/xc/lib/xc_vif.c +++ b/tools/xc/lib/xc_vif.c @@ -9,7 +9,7 @@ #include "xc_private.h" int xc_vif_scheduler_set(int xc_handle, - u64 domid, + u32 domid, unsigned int vifid, xc_vif_sched_params_t *params) { @@ -24,7 +24,7 @@ int xc_vif_scheduler_set(int xc_handle, int xc_vif_scheduler_get(int xc_handle, - u64 domid, + u32 domid, unsigned int vifid, xc_vif_sched_params_t *params) { @@ -46,7 +46,7 @@ int xc_vif_scheduler_get(int xc_handle, int xc_vif_stats_get(int xc_handle, - u64 domid, + u32 domid, unsigned int vifid, xc_vif_stats_t *stats) { diff --git a/tools/xc/py/Xc.c b/tools/xc/py/Xc.c index d2a291e4c8..eadb14f146 100644 --- a/tools/xc/py/Xc.c +++ b/tools/xc/py/Xc.c @@ -40,7 +40,7 @@ static PyObject *pyxc_domain_create(PyObject *self, unsigned int mem_kb = 0; char *name = "(anon)"; int cpu = -1; - u64 dom; + u32 dom; int ret; static char *kwd_list[] = { "mem_kb", "name", "cpu", NULL }; @@ -52,7 +52,7 @@ static PyObject *pyxc_domain_create(PyObject *self, if ( (ret = xc_domain_create(xc->xc_handle, mem_kb, name, cpu, &dom)) < 0 ) return PyErr_SetFromErrno(xc_error); - return PyLong_FromUnsignedLongLong(dom); + return PyInt_FromLong(dom); } static PyObject *pyxc_domain_start(PyObject *self, @@ -61,11 +61,11 @@ static PyObject *pyxc_domain_start(PyObject *self, { XcObject *xc = (XcObject *)self; - u64 dom; + u32 dom; static char *kwd_list[] = { "dom", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "L", kwd_list, &dom) ) + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) ) return NULL; if ( xc_domain_start(xc->xc_handle, dom) != 0 ) @@ -81,11 +81,11 @@ static PyObject *pyxc_domain_stop(PyObject *self, { XcObject *xc = (XcObject *)self; - u64 dom; + u32 dom; static char *kwd_list[] = { "dom", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "L", kwd_list, &dom) ) + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) ) return NULL; if ( xc_domain_stop(xc->xc_handle, dom) != 0 ) @@ -101,12 +101,12 @@ static PyObject *pyxc_domain_destroy(PyObject *self, { XcObject *xc = (XcObject *)self; - u64 dom; + u32 dom; int force = 0; static char *kwd_list[] = { "dom", "force", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "L|i", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list, &dom, &force) ) return NULL; @@ -118,17 +118,17 @@ static PyObject *pyxc_domain_destroy(PyObject *self, } static PyObject *pyxc_domain_pincpu(PyObject *self, - PyObject *args, - PyObject *kwds) + PyObject *args, + PyObject *kwds) { XcObject *xc = (XcObject *)self; - u64 dom; + u32 dom; int cpu = -1; static char *kwd_list[] = { "dom", "cpu", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "L|i", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list, &dom, &cpu) ) return NULL; @@ -146,13 +146,13 @@ static PyObject *pyxc_domain_getinfo(PyObject *self, XcObject *xc = (XcObject *)self; PyObject *list; - u64 first_dom = 0; + u32 first_dom = 0; int max_doms = 1024, nr_doms, i; xc_dominfo_t *info; static char *kwd_list[] = { "first_dom", "max_doms", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|Li", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|ii", kwd_list, &first_dom, &max_doms) ) return NULL; @@ -166,7 +166,7 @@ static PyObject *pyxc_domain_getinfo(PyObject *self, { PyList_SetItem( list, i, - Py_BuildValue("{s:L,s:i,s:i,s:i,s:l,s:L,s:s,s:l}", + Py_BuildValue("{s:i,s:i,s:i,s:i,s:l,s:L,s:s,s:l}", "dom", info[i].domid, "cpu", info[i].cpu, "running", info[i].has_cpu, @@ -175,7 +175,7 @@ static PyObject *pyxc_domain_getinfo(PyObject *self, "cpu_time", info[i].cpu_time, "name", info[i].name, "maxmem_kb",info[i].max_memkb - )); + )); } free(info); @@ -189,15 +189,17 @@ static PyObject *pyxc_linux_save(PyObject *self, { XcObject *xc = (XcObject *)self; - u64 dom; + u32 dom; char *state_file; int progress = 1, live = -1, debug = 0; unsigned int flags = 0; - static char *kwd_list[] = { "dom", "state_file", "progress", "live", "debug", NULL }; + static char *kwd_list[] = { "dom", "state_file", "progress", + "live", "debug", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Ls|iii", kwd_list, - &dom, &state_file, &progress, &live, &debug) ) + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is|iii", kwd_list, + &dom, &state_file, &progress, + &live, &debug) ) return NULL; if (progress) flags |= XCFLAGS_VERBOSE; @@ -207,136 +209,136 @@ static PyObject *pyxc_linux_save(PyObject *self, if ( strncmp(state_file,"tcp:", strlen("tcp:")) == 0 ) { #define max_namelen 64 - char server[max_namelen]; - char *port_s; - int port=777; - int sd = -1; - struct hostent *h; - struct sockaddr_in s; - int sockbufsize; - int rc = -1; - - int writerfn(void *fd, const void *buf, size_t count) - { - int tot = 0, rc; - do { - rc = write( (int) fd, ((char*)buf)+tot, count-tot ); - if ( rc < 0 ) { perror("WRITE"); return rc; }; - tot += rc; - } - while ( tot < count ); - return 0; - } - - if (live == -1) flags |= XCFLAGS_LIVE; // default to live for tcp - - strncpy( server, state_file+strlen("tcp://"), max_namelen); - server[max_namelen-1]='\0'; - if ( (port_s = strchr(server,':')) != NULL ) - { - *port_s = '\0'; - port = atoi(port_s+1); - } - - printf("X server=%s port=%d\n",server,port); - - h = gethostbyname(server); - sd = socket (AF_INET,SOCK_STREAM,0); - if ( sd < 0 ) + char server[max_namelen]; + char *port_s; + int port=777; + int sd = -1; + struct hostent *h; + struct sockaddr_in s; + int sockbufsize; + int rc = -1; + + int writerfn(void *fd, const void *buf, size_t count) + { + int tot = 0, rc; + do { + rc = write( (int) fd, ((char*)buf)+tot, count-tot ); + if ( rc < 0 ) { perror("WRITE"); return rc; }; + tot += rc; + } + while ( tot < count ); + return 0; + } + + if (live == -1) flags |= XCFLAGS_LIVE; /* default to live for tcp */ + + strncpy( server, state_file+strlen("tcp://"), max_namelen); + server[max_namelen-1]='\0'; + if ( (port_s = strchr(server,':')) != NULL ) + { + *port_s = '\0'; + port = atoi(port_s+1); + } + + printf("X server=%s port=%d\n",server,port); + + h = gethostbyname(server); + sd = socket (AF_INET,SOCK_STREAM,0); + if ( sd < 0 ) + goto serr; + s.sin_family = AF_INET; + bcopy ( h->h_addr, &(s.sin_addr.s_addr), h->h_length); + s.sin_port = htons(port); + if ( connect(sd, (struct sockaddr *) &s, sizeof(s)) ) goto serr; - s.sin_family = AF_INET; - bcopy ( h->h_addr, &(s.sin_addr.s_addr), h->h_length); - s.sin_port = htons(port); - if ( connect(sd, (struct sockaddr *) &s, sizeof(s)) ) - goto serr; - - sockbufsize=128*1024; - if ( setsockopt(sd, SOL_SOCKET, SO_SNDBUF, + + sockbufsize=128*1024; + if ( setsockopt(sd, SOL_SOCKET, SO_SNDBUF, &sockbufsize, sizeof sockbufsize) < 0 ) - goto serr; + goto serr; - if ( xc_linux_save(xc->xc_handle, dom, flags, + if ( xc_linux_save(xc->xc_handle, dom, flags, writerfn, (void*)sd) == 0 ) - { - if ( read( sd, &rc, sizeof(int) ) != sizeof(int) ) - goto serr; - - if ( rc == 0 ) - { - printf("Migration succesful -- destroy local copy\n"); - xc_domain_destroy( xc->xc_handle, dom, 1 ); - close(sd); - Py_INCREF(zero); - return zero; - } - else - errno = rc; - } + { + if ( read( sd, &rc, sizeof(int) ) != sizeof(int) ) + goto serr; + + if ( rc == 0 ) + { + printf("Migration succesful -- destroy local copy\n"); + xc_domain_destroy( xc->xc_handle, dom, 1 ); + close(sd); + Py_INCREF(zero); + return zero; + } + else + errno = rc; + } serr: - printf("Migration failed -- restart local copy\n"); - xc_domain_start( xc->xc_handle, dom ); - PyErr_SetFromErrno(xc_error); - if ( sd >= 0 ) close(sd); - return NULL; + printf("Migration failed -- restart local copy\n"); + xc_domain_start( xc->xc_handle, dom ); + PyErr_SetFromErrno(xc_error); + if ( sd >= 0 ) close(sd); + return NULL; } else { - int fd = -1; - gzFile gfd = NULL; - - int writerfn(void *fd, const void *buf, size_t count) - { - int rc; - while ( ((rc = gzwrite( (gzFile*)fd, (void*)buf, count)) == -1) && - (errno = EINTR) ) - continue; - return ! (rc == count); - } - - if (strncmp(state_file,"file:",strlen("file:")) == 0) - state_file += strlen("file:"); - - if ( (fd = open(state_file, O_CREAT|O_EXCL|O_WRONLY, 0644)) == -1 ) - { - perror("Could not open file for writing"); - goto err; - } - - /* - * Compression rate 1: we want speed over compression. - * We're mainly going for those zero pages, after all. - */ - - if ( (gfd = gzdopen(fd, "wb1")) == NULL ) - { - perror("Could not allocate compression state for state file"); - close(fd); - goto err; - } - - - if ( xc_linux_save(xc->xc_handle, dom, flags, writerfn, gfd) == 0 ) - { - /* kill domain. We don't want to do this for checkpointing, but - if we don't do it here I think people will hurt themselves - by accident... */ - xc_domain_destroy( xc->xc_handle, dom, 1 ); - gzclose(gfd); - close(fd); - - Py_INCREF(zero); - return zero; - } + int fd = -1; + gzFile gfd = NULL; + + int writerfn(void *fd, const void *buf, size_t count) + { + int rc; + while ( ((rc = gzwrite( (gzFile*)fd, (void*)buf, count)) == -1) && + (errno = EINTR) ) + continue; + return ! (rc == count); + } + + if (strncmp(state_file,"file:",strlen("file:")) == 0) + state_file += strlen("file:"); + + if ( (fd = open(state_file, O_CREAT|O_EXCL|O_WRONLY, 0644)) == -1 ) + { + perror("Could not open file for writing"); + goto err; + } + + /* + * Compression rate 1: we want speed over compression. + * We're mainly going for those zero pages, after all. + */ + + if ( (gfd = gzdopen(fd, "wb1")) == NULL ) + { + perror("Could not allocate compression state for state file"); + close(fd); + goto err; + } + + + if ( xc_linux_save(xc->xc_handle, dom, flags, writerfn, gfd) == 0 ) + { + /* kill domain. We don't want to do this for checkpointing, but + if we don't do it here I think people will hurt themselves + by accident... */ + xc_domain_destroy( xc->xc_handle, dom, 1 ); + gzclose(gfd); + close(fd); + + Py_INCREF(zero); + return zero; + } err: - PyErr_SetFromErrno(xc_error); - if ( gfd != NULL ) + PyErr_SetFromErrno(xc_error); + if ( gfd != NULL ) gzclose(gfd); - if ( fd >= 0 ) + if ( fd >= 0 ) close(fd); - unlink(state_file); - return NULL; + unlink(state_file); + return NULL; } } @@ -349,12 +351,12 @@ static PyObject *pyxc_linux_restore(PyObject *self, char *state_file; int progress = 1; - u64 dom; + u32 dom; unsigned int flags = 0; static char *kwd_list[] = { "dom", "state_file", "progress", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Ls|i", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is|i", kwd_list, &dom, &state_file, &progress) ) return NULL; @@ -364,142 +366,141 @@ static PyObject *pyxc_linux_restore(PyObject *self, if ( strncmp(state_file,"tcp:", strlen("tcp:")) == 0 ) { #define max_namelen 64 - char server[max_namelen]; - char *port_s; - int port=777; - int ld = -1, sd = -1; - struct hostent *h; - struct sockaddr_in s, d, p; - socklen_t dlen, plen; - int sockbufsize; - int on = 1, rc = -1; - - int readerfn(void *fd, void *buf, size_t count) - { - int rc, tot = 0; - do { - rc = read( (int) fd, ((char*)buf)+tot, count-tot ); - if ( rc < 0 ) { perror("READ"); return rc; } - if ( rc == 0 ) { printf("read: need %d, tot=%d got zero\n",count-tot,tot); return -1; } - tot += rc; - } + char server[max_namelen]; + char *port_s; + int port=777; + int ld = -1, sd = -1; + struct hostent *h; + struct sockaddr_in s, d, p; + socklen_t dlen, plen; + int sockbufsize; + int on = 1, rc = -1; + + int readerfn(void *fd, void *buf, size_t count) + { + int rc, tot = 0; + do { + rc = read( (int) fd, ((char*)buf)+tot, count-tot ); + if ( rc < 0 ) { perror("READ"); return rc; } + if ( rc == 0 ) { printf("read: need %d, tot=%d got zero\n", + count-tot, tot); return -1; } + tot += rc; + } while ( tot < count ); - return 0; - } - - strncpy( server, state_file+strlen("tcp://"), max_namelen); - server[max_namelen-1]='\0'; - if ( (port_s = strchr(server,':')) != NULL ) - { - *port_s = '\0'; - port = atoi(port_s+1); - } - - printf("X server=%s port=%d\n",server,port); - - h = gethostbyname(server); - ld = socket (AF_INET,SOCK_STREAM,0); - if ( ld < 0 ) goto serr; - s.sin_family = AF_INET; - //bcopy ( h->h_addr, &(s.sin_addr.s_addr), h->h_length); - s.sin_addr.s_addr = htonl(INADDR_ANY); - s.sin_port = htons(port); - - if ( setsockopt(ld, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0 ) - goto serr; - - if ( bind(ld, (struct sockaddr *) &s, sizeof(s)) ) - goto serr; - - if ( listen(ld, 1) ) - goto serr; - - dlen=sizeof(struct sockaddr); - if ( (sd = accept(ld, (struct sockaddr *) &d, &dlen )) < 0 ) - goto serr; + return 0; + } + + strncpy( server, state_file+strlen("tcp://"), max_namelen); + server[max_namelen-1]='\0'; + if ( (port_s = strchr(server,':')) != NULL ) + { + *port_s = '\0'; + port = atoi(port_s+1); + } + + printf("X server=%s port=%d\n",server,port); + + h = gethostbyname(server); + ld = socket (AF_INET,SOCK_STREAM,0); + if ( ld < 0 ) goto serr; + s.sin_family = AF_INET; + s.sin_addr.s_addr = htonl(INADDR_ANY); + s.sin_port = htons(port); + + if ( setsockopt(ld, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0 ) + goto serr; + + if ( bind(ld, (struct sockaddr *) &s, sizeof(s)) ) + goto serr; + + if ( listen(ld, 1) ) + goto serr; + + dlen=sizeof(struct sockaddr); + if ( (sd = accept(ld, (struct sockaddr *) &d, &dlen )) < 0 ) + goto serr; plen = sizeof(p); - if ( getpeername(sd, (struct sockaddr_in *) &p, + if ( getpeername(sd, (struct sockaddr_in *) &p, &plen) < 0 ) - goto serr; + goto serr; - printf("Accepted connection from %s\n", inet_ntoa(p.sin_addr)); - - sockbufsize=128*1024; - if ( setsockopt(sd, SOL_SOCKET, SO_SNDBUF, &sockbufsize, + printf("Accepted connection from %s\n", inet_ntoa(p.sin_addr)); + + sockbufsize=128*1024; + if ( setsockopt(sd, SOL_SOCKET, SO_SNDBUF, &sockbufsize, sizeof sockbufsize) < 0 ) - goto serr; + goto serr; - rc = xc_linux_restore(xc->xc_handle, dom, flags, + rc = xc_linux_restore(xc->xc_handle, dom, flags, readerfn, (void*)sd, &dom); - write( sd, &rc, sizeof(int) ); + write( sd, &rc, sizeof(int) ); - if (rc == 0) - { - close(sd); - Py_INCREF(zero); - return zero; - } - errno = rc; + if (rc == 0) + { + close(sd); + Py_INCREF(zero); + return zero; + } + errno = rc; serr: - PyErr_SetFromErrno(xc_error); - if ( ld >= 0 ) close(ld); - if ( sd >= 0 ) close(sd); - return NULL; + PyErr_SetFromErrno(xc_error); + if ( ld >= 0 ) close(ld); + if ( sd >= 0 ) close(sd); + return NULL; } else { - int fd = -1; - gzFile gfd = NULL; - - int readerfn(void *fd, void *buf, size_t count) - { - int rc; - while ( ((rc = gzread( (gzFile*)fd, (void*)buf, count)) == -1) && - (errno = EINTR) ) - continue; - return ! (rc == count); - } - - if ( strncmp(state_file,"file:",strlen("file:")) == 0 ) - state_file += strlen("file:"); - - if ( (fd = open(state_file, O_RDONLY)) == -1 ) - { - perror("Could not open file for writing"); - goto err; - } - - /* - * Compression rate 1: we want speed over compression. - * We're mainly going for those zero pages, after all. - */ - - if ( (gfd = gzdopen(fd, "rb")) == NULL ) - { - perror("Could not allocate compression state for state file"); - close(fd); - goto err; - } - - - if ( xc_linux_restore(xc->xc_handle, dom, flags, + int fd = -1; + gzFile gfd = NULL; + + int readerfn(void *fd, void *buf, size_t count) + { + int rc; + while ( ((rc = gzread( (gzFile*)fd, (void*)buf, count)) == -1) && + (errno = EINTR) ) + continue; + return ! (rc == count); + } + + if ( strncmp(state_file,"file:",strlen("file:")) == 0 ) + state_file += strlen("file:"); + + if ( (fd = open(state_file, O_RDONLY)) == -1 ) + { + perror("Could not open file for writing"); + goto err; + } + + /* + * Compression rate 1: we want speed over compression. + * We're mainly going for those zero pages, after all. + */ + if ( (gfd = gzdopen(fd, "rb")) == NULL ) + { + perror("Could not allocate compression state for state file"); + close(fd); + goto err; + } + + + if ( xc_linux_restore(xc->xc_handle, dom, flags, readerfn, gfd, &dom) == 0 ) - { - gzclose(gfd); - close(fd); + { + gzclose(gfd); + close(fd); - Py_INCREF(zero); - return zero; - } + Py_INCREF(zero); + return zero; + } err: - PyErr_SetFromErrno(xc_error); - if ( gfd != NULL ) gzclose(gfd); - if ( fd >= 0 ) close(fd); - return NULL; + PyErr_SetFromErrno(xc_error); + if ( gfd != NULL ) gzclose(gfd); + if ( fd >= 0 ) close(fd); + return NULL; } } @@ -510,14 +511,14 @@ static PyObject *pyxc_linux_build(PyObject *self, { XcObject *xc = (XcObject *)self; - u64 dom; + u32 dom; char *image, *ramdisk = NULL, *cmdline = ""; int control_evtchn; static char *kwd_list[] = { "dom", "control_evtchn", "image", "ramdisk", "cmdline", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Lis|ss", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|ss", kwd_list, &dom, &control_evtchn, &image, &ramdisk, &cmdline) ) return NULL; @@ -536,14 +537,14 @@ static PyObject *pyxc_netbsd_build(PyObject *self, { XcObject *xc = (XcObject *)self; - u64 dom; + u32 dom; char *image, *ramdisk = NULL, *cmdline = ""; int control_evtchn; static char *kwd_list[] = { "dom", "control_evtchn", "image", "ramdisk", "cmdline", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Lis|ssi", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|ssi", kwd_list, &dom, &control_evtchn, &image, &ramdisk, &cmdline) ) return NULL; @@ -577,8 +578,8 @@ static PyObject *pyxc_bvtsched_global_set(PyObject *self, } static PyObject *pyxc_bvtsched_global_get(PyObject *self, - PyObject *args, - PyObject *kwds) + PyObject *args, + PyObject *kwds) { XcObject *xc = (XcObject *)self; @@ -599,13 +600,13 @@ static PyObject *pyxc_bvtsched_domain_set(PyObject *self, { XcObject *xc = (XcObject *)self; - u64 dom; + u32 dom; unsigned long mcuadv, warp, warpl, warpu; static char *kwd_list[] = { "dom", "mcuadv", "warp", "warpl", "warpu", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Lllll", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "illll", kwd_list, &dom, &mcuadv, &warp, &warpl, &warpu) ) return NULL; @@ -622,19 +623,19 @@ static PyObject *pyxc_bvtsched_domain_get(PyObject *self, PyObject *kwds) { XcObject *xc = (XcObject *)self; - u64 dom; + u32 dom; unsigned long mcuadv, warp, warpl, warpu; static char *kwd_list[] = { "dom", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "L", kwd_list, &dom) ) + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &dom) ) return NULL; if ( xc_bvtsched_domain_get(xc->xc_handle, dom, &mcuadv, &warp, &warpl, &warpu) != 0 ) return PyErr_SetFromErrno(xc_error); - return Py_BuildValue("{s:L,s:l,s:l,s:l,s:l}", + return Py_BuildValue("{s:i,s:l,s:l,s:l,s:l}", "domain", dom, "mcuadv", mcuadv, "warp", warp, @@ -648,14 +649,14 @@ static PyObject *pyxc_vif_scheduler_set(PyObject *self, { XcObject *xc = (XcObject *)self; - u64 dom; + u32 dom; unsigned int vif; xc_vif_sched_params_t sched = { 0, 0 }; static char *kwd_list[] = { "dom", "vif", "credit_bytes", "credit_usecs", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Li|ll", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii|ll", kwd_list, &dom, &vif, &sched.credit_bytes, &sched.credit_usec) ) @@ -674,13 +675,13 @@ static PyObject *pyxc_vif_scheduler_get(PyObject *self, { XcObject *xc = (XcObject *)self; - u64 dom; + u32 dom; unsigned int vif; xc_vif_sched_params_t sched; static char *kwd_list[] = { "dom", "vif", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Li", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list, &dom, &vif) ) return NULL; @@ -698,13 +699,13 @@ static PyObject *pyxc_vif_stats_get(PyObject *self, { XcObject *xc = (XcObject *)self; - u64 dom; + u32 dom; unsigned int vif; xc_vif_stats_t stats; static char *kwd_list[] = { "dom", "vif", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Li", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list, &dom, &vif) ) return NULL; @@ -724,13 +725,13 @@ static PyObject *pyxc_vbd_create(PyObject *self, { XcObject *xc = (XcObject *)self; - u64 dom; + u32 dom; unsigned int vbd; int writeable; static char *kwd_list[] = { "dom", "vbd", "writeable", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Lii", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iii", kwd_list, &dom, &vbd, &writeable) ) return NULL; @@ -747,12 +748,12 @@ static PyObject *pyxc_vbd_destroy(PyObject *self, { XcObject *xc = (XcObject *)self; - u64 dom; + u32 dom; unsigned int vbd; static char *kwd_list[] = { "dom", "vbd", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Li", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list, &dom, &vbd) ) return NULL; @@ -769,14 +770,14 @@ static PyObject *pyxc_vbd_grow(PyObject *self, { XcObject *xc = (XcObject *)self; - u64 dom; + u32 dom; unsigned int vbd; xc_vbdextent_t extent; static char *kwd_list[] = { "dom", "vbd", "device", "start_sector", "nr_sectors", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "LiiLL", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiLL", kwd_list, &dom, &vbd, &extent.real_device, &extent.start_sector, @@ -796,12 +797,12 @@ static PyObject *pyxc_vbd_shrink(PyObject *self, { XcObject *xc = (XcObject *)self; - u64 dom; + u32 dom; unsigned int vbd; static char *kwd_list[] = { "dom", "vbd", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Li", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list, &dom, &vbd) ) return NULL; @@ -819,14 +820,14 @@ static PyObject *pyxc_vbd_setextents(PyObject *self, XcObject *xc = (XcObject *)self; PyObject *list, *dict, *obj; - u64 dom; + u32 dom; unsigned int vbd; xc_vbdextent_t *extents = NULL; int i, nr_extents; static char *kwd_list[] = { "dom", "vbd", "extents", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "LiO", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiO", kwd_list, &dom, &vbd, &list) ) return NULL; @@ -941,14 +942,14 @@ static PyObject *pyxc_vbd_getextents(PyObject *self, XcObject *xc = (XcObject *)self; PyObject *list; - u64 dom; + u32 dom; unsigned int vbd; xc_vbdextent_t *extents; int i, nr_extents; static char *kwd_list[] = { "dom", "vbd", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Li", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list, &dom, &vbd) ) return NULL; @@ -987,14 +988,14 @@ static PyObject *pyxc_vbd_probe(PyObject *self, XcObject *xc = (XcObject *)self; PyObject *list; - u64 dom = XC_VBDDOM_PROBE_ALL; + u32 dom = XC_VBDDOM_PROBE_ALL; unsigned int max_vbds = 1024; xc_vbd_t *info; int nr_vbds, i; static char *kwd_list[] = { "dom", "max_vbds", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|Li", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|ii", kwd_list, &dom, &max_vbds) ) return NULL; @@ -1012,7 +1013,7 @@ static PyObject *pyxc_vbd_probe(PyObject *self, { PyList_SetItem( list, i, - Py_BuildValue("{s:L,s:i,s:i,s:L}", + Py_BuildValue("{s:i,s:i,s:i,s:L}", "dom", info[i].domid, "vbd", info[i].vbdid, "writeable", !!(info[i].flags & XC_VBDF_WRITEABLE), @@ -1030,12 +1031,12 @@ static PyObject *pyxc_evtchn_bind_interdomain(PyObject *self, { XcObject *xc = (XcObject *)self; - u64 dom1 = DOMID_SELF, dom2 = DOMID_SELF; + u32 dom1 = DOMID_SELF, dom2 = DOMID_SELF; int port1, port2; static char *kwd_list[] = { "dom1", "dom2", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|LL", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "|ii", kwd_list, &dom1, &dom2) ) return NULL; @@ -1054,12 +1055,12 @@ static PyObject *pyxc_evtchn_close(PyObject *self, { XcObject *xc = (XcObject *)self; - u64 dom = DOMID_SELF; + u32 dom = DOMID_SELF; int port; static char *kwd_list[] = { "port", "dom", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|L", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list, &port, &dom) ) return NULL; @@ -1097,13 +1098,13 @@ static PyObject *pyxc_evtchn_status(PyObject *self, XcObject *xc = (XcObject *)self; PyObject *dict; - u64 dom = DOMID_SELF; + u32 dom = DOMID_SELF; int port, ret; xc_evtchn_status_t status; static char *kwd_list[] = { "port", "dom", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|L", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list, &port, &dom) ) return NULL; @@ -1122,7 +1123,7 @@ static PyObject *pyxc_evtchn_status(PyObject *self, "status", "unbound"); break; case EVTCHNSTAT_interdomain: - dict = Py_BuildValue("{s:s,s:L,s:i}", + dict = Py_BuildValue("{s:s,s:i,s:i}", "status", "interdomain", "dom", status.u.interdomain.dom, "port", status.u.interdomain.port); @@ -1150,12 +1151,12 @@ static PyObject *pyxc_physdev_pci_access_modify(PyObject *self, PyObject *kwds) { XcObject *xc = (XcObject *)self; - u64 dom; + u32 dom; int bus, dev, func, enable, ret; static char *kwd_list[] = { "dom", "bus", "dev", "func", "enable", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Liiii", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iiiii", kwd_list, &dom, &bus, &dev, &func, &enable) ) return NULL; @@ -1191,8 +1192,8 @@ static PyObject *pyxc_readconsolering(PyObject *self, } static PyObject *pyxc_physinfo(PyObject *self, - PyObject *args, - PyObject *kwds) + PyObject *args, + PyObject *kwds) { XcObject *xc = (XcObject *)self; xc_physinfo_t info; @@ -1216,19 +1217,19 @@ static PyObject *pyxc_atropos_domain_set(PyObject *self, PyObject *kwds) { XcObject *xc = (XcObject *)self; - u64 domid; + u32 domid; u64 period, slice, latency; int xtratime; static char *kwd_list[] = { "dom", "period", "slice", "latency", - "xtratime", NULL }; + "xtratime", NULL }; - if( !PyArg_ParseTupleAndKeywords(args, kwds, "LLLLi", kwd_list, &domid, + if( !PyArg_ParseTupleAndKeywords(args, kwds, "iLLLi", kwd_list, &domid, &period, &slice, &latency, &xtratime) ) return NULL; if ( xc_atropos_domain_set(xc->xc_handle, domid, period, slice, - latency, xtratime) != 0 ) + latency, xtratime) != 0 ) return PyErr_SetFromErrno(xc_error); Py_INCREF(zero); @@ -1240,20 +1241,20 @@ static PyObject *pyxc_atropos_domain_get(PyObject *self, PyObject *kwds) { XcObject *xc = (XcObject *)self; - u64 domid; + u32 domid; u64 period, slice, latency; int xtratime; static char *kwd_list[] = { "dom", NULL }; - if( !PyArg_ParseTupleAndKeywords(args, kwds, "L", kwd_list, &domid) ) + if( !PyArg_ParseTupleAndKeywords(args, kwds, "i", kwd_list, &domid) ) return NULL; if ( xc_atropos_domain_get( xc->xc_handle, domid, &period, &slice, &latency, &xtratime ) ) return PyErr_SetFromErrno(xc_error); - return Py_BuildValue("{s:L,s:L,s:L,s:L,s:i}", + return Py_BuildValue("{s:i,s:L,s:L,s:L,s:i}", "domain", domid, "period", period, "slice", slice, @@ -1287,12 +1288,12 @@ static PyObject *pyxc_shadow_control(PyObject *self, { XcObject *xc = (XcObject *)self; - u64 dom; + u32 dom; int op=0; static char *kwd_list[] = { "dom", "op", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "L|i", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|i", kwd_list, &dom, &op) ) return NULL; @@ -1324,12 +1325,12 @@ static PyObject *pyxc_domain_setname(PyObject *self, PyObject *kwds) { XcObject *xc = (XcObject *)self; - u64 dom; + u32 dom; char *name; static char *kwd_list[] = { "dom", "name", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Ls", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "is", kwd_list, &dom, &name) ) return NULL; @@ -1341,17 +1342,17 @@ static PyObject *pyxc_domain_setname(PyObject *self, } static PyObject *pyxc_domain_setmaxmem(PyObject *self, - PyObject *args, - PyObject *kwds) + PyObject *args, + PyObject *kwds) { XcObject *xc = (XcObject *)self; - u64 dom; + u32 dom; unsigned long max_memkb; static char *kwd_list[] = { "dom", "max_memkb", NULL }; - if ( !PyArg_ParseTupleAndKeywords(args, kwds, "Li", kwd_list, + if ( !PyArg_ParseTupleAndKeywords(args, kwds, "ii", kwd_list, &dom, &max_memkb) ) return NULL; @@ -1370,27 +1371,27 @@ static PyMethodDef pyxc_methods[] = { "Create a new domain.\n" " mem_kb [int, 65536]: Memory allocation, in kilobytes.\n" " name [str, '(anon)']: Informative textual name.\n\n" - "Returns: [long] new domain identifier; -1 on error.\n" }, + "Returns: [int] new domain identifier; -1 on error.\n" }, { "domain_start", (PyCFunction)pyxc_domain_start, METH_VARARGS | METH_KEYWORDS, "\n" "Start execution of a domain.\n" - " dom [long]: Identifier of domain to be started.\n\n" + " dom [int]: Identifier of domain to be started.\n\n" "Returns: [int] 0 on success; -1 on error.\n" }, { "domain_stop", (PyCFunction)pyxc_domain_stop, METH_VARARGS | METH_KEYWORDS, "\n" "Stop execution of a domain.\n" - " dom [long]: Identifier of domain to be stopped.\n\n" + " dom [int]: Identifier of domain to be stopped.\n\n" "Returns: [int] 0 on success; -1 on error.\n" }, { "domain_destroy", (PyCFunction)pyxc_domain_destroy, METH_VARARGS | METH_KEYWORDS, "\n" "Destroy a domain.\n" - " dom [long]: Identifier of domain to be destroyed.\n" + " dom [int]: Identifier of domain to be destroyed.\n" " force [int, 0]: Bool - force immediate destruction?\n\n" "Returns: [int] 0 on success; -1 on error.\n" }, @@ -1398,7 +1399,7 @@ static PyMethodDef pyxc_methods[] = { (PyCFunction)pyxc_domain_pincpu, METH_VARARGS | METH_KEYWORDS, "\n" "Pin a domain to a specified CPU.\n" - " dom [long]: Identifier of domain to be pinned.\n" + " dom [int]: Identifier of domain to be pinned.\n" " cpu [int, -1]: CPU to pin to, or -1 to unpin\n\n" "Returns: [int] 0 on success; -1 on error.\n" }, @@ -1406,13 +1407,13 @@ static PyMethodDef pyxc_methods[] = { (PyCFunction)pyxc_domain_getinfo, METH_VARARGS | METH_KEYWORDS, "\n" "Get information regarding a set of domains, in increasing id order.\n" - " first_dom [long, 0]: First domain to retrieve info about.\n" + " first_dom [int, 0]: First domain to retrieve info about.\n" " max_doms [int, 1024]: Maximum number of domains to retrieve info" " about.\n\n" "Returns: [list of dicts] if list length is less than 'max_doms'\n" " parameter then there was an error, or the end of the\n" " domain-id space was reached.\n" - " dom [long]: Identifier of domain to which this info pertains\n" + " dom [int]: Identifier of domain to which this info pertains\n" " cpu [int]: CPU to which this domain is bound\n" " running [int]: Bool - is the domain currently running?\n" " stopped [int]: Bool - is the domain suspended?\n" @@ -1424,7 +1425,7 @@ static PyMethodDef pyxc_methods[] = { (PyCFunction)pyxc_linux_save, METH_VARARGS | METH_KEYWORDS, "\n" "Save the CPU and memory state of a Linux guest OS.\n" - " dom [long]: Identifier of domain to be saved.\n" + " dom [int]: Identifier of domain to be saved.\n" " state_file [str]: Name of state file. Must not currently exist.\n" " progress [int, 1]: Bool - display a running progress indication?\n\n" "Returns: [int] 0 on success; -1 on error.\n" }, @@ -1435,13 +1436,13 @@ static PyMethodDef pyxc_methods[] = { "Restore the CPU and memory state of a Linux guest OS.\n" " state_file [str]: Name of state file. Must not currently exist.\n" " progress [int, 1]: Bool - display a running progress indication?\n\n" - "Returns: [long] new domain identifier on success; -1 on error.\n" }, + "Returns: [int] new domain identifier on success; -1 on error.\n" }, { "linux_build", (PyCFunction)pyxc_linux_build, METH_VARARGS | METH_KEYWORDS, "\n" "Build a new Linux guest OS.\n" - " dom [long]: Identifier of domain to build into.\n" + " dom [int]: Identifier of domain to build into.\n" " image [str]: Name of kernel image file. May be gzipped.\n" " ramdisk [str, n/a]: Name of ramdisk file, if any.\n" " cmdline [str, n/a]: Kernel parameters, if any.\n\n" @@ -1451,7 +1452,7 @@ static PyMethodDef pyxc_methods[] = { (PyCFunction)pyxc_netbsd_build, METH_VARARGS | METH_KEYWORDS, "\n" "Build a new NetBSD guest OS.\n" - " dom [long]: Identifier of domain to build into.\n" + " dom [int]: Identifier of domain to build into.\n" " image [str]: Name of kernel image file. May be gzipped.\n" " cmdline [str, n/a]: Kernel parameters, if any.\n\n" "Returns: [int] 0 on success; -1 on error.\n" }, @@ -1474,20 +1475,20 @@ static PyMethodDef pyxc_methods[] = { (PyCFunction)pyxc_bvtsched_domain_set, METH_VARARGS | METH_KEYWORDS, "\n" "Set per-domain tuning parameters for Borrowed Virtual Time scheduler.\n" - " dom [long]: Identifier of domain to be tuned.\n" - " mcuadv [int]: Proportional to the inverse of the domain's weight.\n" - " warp [int]: How far to warp domain's EVT on unblock.\n" - " warpl [int]: How long the domain can run warped.\n" - " warpu [int]: How long before the domain can warp again.\n\n" + " dom [int]: Identifier of domain to be tuned.\n" + " mcuadv [int]: Proportional to the inverse of the domain's weight.\n" + " warp [int]: How far to warp domain's EVT on unblock.\n" + " warpl [int]: How long the domain can run warped.\n" + " warpu [int]: How long before the domain can warp again.\n\n" "Returns: [int] 0 on success; -1 on error.\n" }, { "bvtsched_domain_get", (PyCFunction)pyxc_bvtsched_domain_get, METH_KEYWORDS, "\n" "Get per-domain tuning parameters under the BVT scheduler.\n" - " dom [long]: Identifier of domain to be queried.\n" + " dom [int]: Identifier of domain to be queried.\n" "Returns [dict]:\n" - " domain [long]: Domain ID.\n" + " domain [int]: Domain ID.\n" " mcuadv [long]: MCU Advance.\n" " warp [long]: Warp.\n" " warpu [long]: Unwarp requirement.\n" @@ -1498,7 +1499,7 @@ static PyMethodDef pyxc_methods[] = { (PyCFunction)pyxc_atropos_domain_set, METH_KEYWORDS, "\n" "Set the scheduling parameters for a domain when running with Atropos.\n" - " dom [long]: domain to set\n" + " dom [int]: domain to set\n" " period [long]: domain's scheduling period\n" " slice [long]: domain's slice per period\n" " latency [long]: wakeup latency hint\n" @@ -1510,9 +1511,9 @@ static PyMethodDef pyxc_methods[] = { METH_KEYWORDS, "\n" "Get the current scheduling parameters for a domain when running with\n" "the Atropos scheduler." - " dom [long]: domain to query\n" + " dom [int]: domain to query\n" "Returns: [dict]\n" - " domain [long]: domain ID\n" + " domain [int]: domain ID\n" " period [long]: scheduler period\n" " slice [long]: CPU reservation per period\n" " latency [long]: unblocking latency hint\n" @@ -1536,7 +1537,7 @@ static PyMethodDef pyxc_methods[] = { (PyCFunction)pyxc_vif_scheduler_set, METH_VARARGS | METH_KEYWORDS, "\n" "Set per-network-interface scheduling parameters.\n" - " dom [long]: Identifier of domain to be adjusted.\n" + " dom [int]: Identifier of domain to be adjusted.\n" " vif [int]: Identifier of VIF to be adjusted.\n" " credit_bytes [int, 0]: Tx bytes permitted each interval.\n" " credit_usecs [int, 0]: Interval, in usecs. 0 == no scheduling.\n\n" @@ -1546,8 +1547,8 @@ static PyMethodDef pyxc_methods[] = { (PyCFunction)pyxc_vif_scheduler_get, METH_VARARGS | METH_KEYWORDS, "\n" "Query the per-network-interface scheduling parameters.\n" - " dom [long]: Identifier of domain to be queried.\n" - " vif [int]: Identifier of VIF to be queried.\n\n" + " dom [int]: Identifier of domain to be queried.\n" + " vif [int]: Identifier of VIF to be queried.\n\n" "Returns: [dict] dictionary is empty on failure.\n" " credit_bytes [int]: Tx bytes permitted each interval.\n" " credit_usecs [int]: Interval, in usecs. 0 == no scheduling.\n" }, @@ -1556,7 +1557,7 @@ static PyMethodDef pyxc_methods[] = { (PyCFunction)pyxc_vif_stats_get, METH_VARARGS | METH_KEYWORDS, "\n" "Query the per-network-interface statistics.\n" - " dom [long]: Identifier of domain to be queried.\n" + " dom [int]: Identifier of domain to be queried.\n" " vif [int]: Identifier of VIF to be queried.\n\n" "Returns: [dict] dictionary is empty on failure.\n" " tx_bytes [long]: Bytes transmitted.\n" @@ -1568,7 +1569,7 @@ static PyMethodDef pyxc_methods[] = { (PyCFunction)pyxc_vbd_create, METH_VARARGS | METH_KEYWORDS, "\n" "Create a new virtual block device associated with a given domain.\n" - " dom [long]: Identifier of domain to get a new VBD.\n" + " dom [int]: Identifier of domain to get a new VBD.\n" " vbd [int]: Identifier for new VBD.\n" " writeable [int]: Bool - is the new VBD writeable?\n\n" "Returns: [int] 0 on success; -1 on error.\n" }, @@ -1577,7 +1578,7 @@ static PyMethodDef pyxc_methods[] = { (PyCFunction)pyxc_vbd_destroy, METH_VARARGS | METH_KEYWORDS, "\n" "Destroy a virtual block device.\n" - " dom [long]: Identifier of domain containing the VBD.\n" + " dom [int]: Identifier of domain containing the VBD.\n" " vbd [int]: Identifier of the VBD.\n\n" "Returns: [int] 0 on success; -1 on error.\n" }, @@ -1585,7 +1586,7 @@ static PyMethodDef pyxc_methods[] = { (PyCFunction)pyxc_vbd_grow, METH_VARARGS | METH_KEYWORDS, "\n" "Grow a virtual block device by appending a new extent.\n" - " dom [long]: Identifier of domain containing the VBD.\n" + " dom [int]: Identifier of domain containing the VBD.\n" " vbd [int]: Identifier of the VBD.\n" " device [int]: Identifier of the real underlying block device.\n" " start_sector [long]: Real start sector of this extent.\n" @@ -1596,7 +1597,7 @@ static PyMethodDef pyxc_methods[] = { (PyCFunction)pyxc_vbd_shrink, METH_VARARGS | METH_KEYWORDS, "\n" "Shrink a virtual block device by deleting its final extent.\n" - " dom [long]: Identifier of domain containing the VBD.\n" + " dom [int]: Identifier of domain containing the VBD.\n" " vbd [int]: Identifier of the VBD.\n\n" "Returns: [int] 0 on success; -1 on error.\n" }, @@ -1604,7 +1605,7 @@ static PyMethodDef pyxc_methods[] = { (PyCFunction)pyxc_vbd_setextents, METH_VARARGS | METH_KEYWORDS, "\n" "Set all the extent information for a virtual block device.\n" - " dom [long]: Identifier of domain containing the VBD.\n" + " dom [int]: Identifier of domain containing the VBD.\n" " vbd [int]: Identifier of the VBD.\n" " extents [list of dicts]: Per-extent information.\n" " device [int]: Id of the real underlying block device.\n" @@ -1616,7 +1617,7 @@ static PyMethodDef pyxc_methods[] = { (PyCFunction)pyxc_vbd_getextents, METH_VARARGS | METH_KEYWORDS, "\n" "Get info on all the extents in a virtual block device.\n" - " dom [long]: Identifier of domain containing the VBD.\n" + " dom [int]: Identifier of domain containing the VBD.\n" " vbd [int]: Identifier of the VBD.\n\n" "Returns: [list of dicts] per-extent information; empty on error.\n" " device [int]: Identifier of the real underlying block device.\n" @@ -1627,11 +1628,11 @@ static PyMethodDef pyxc_methods[] = { (PyCFunction)pyxc_vbd_probe, METH_VARARGS | METH_KEYWORDS, "\n" "Get information regarding extant virtual block devices.\n" - " dom [long, ALL]: Domain to query (default is to query all).\n" + " dom [int, ALL]: Domain to query (default is to query all).\n" " max_vbds [int, 1024]: Maximum VBDs to query.\n\n" "Returns: [list of dicts] if list length is less than 'max_vbds'\n" " parameter then there was an error, or there were fewer vbds.\n" - " dom [long]: Domain containing this VBD.\n" + " dom [int]: Domain containing this VBD.\n" " vbd [int]: Domain-specific identifier of this VBD.\n" " writeable [int]: Bool - is this VBD writeable?\n" " nr_sectors [long]: Size of this VBD, in 512-byte sectors.\n" }, @@ -1640,8 +1641,8 @@ static PyMethodDef pyxc_methods[] = { (PyCFunction)pyxc_evtchn_bind_interdomain, METH_VARARGS | METH_KEYWORDS, "\n" "Open an event channel between two domains.\n" - " dom1 [long, SELF]: First domain to be connected.\n" - " dom2 [long, SELF]: Second domain to be connected.\n\n" + " dom1 [int, SELF]: First domain to be connected.\n" + " dom2 [int, SELF]: Second domain to be connected.\n\n" "Returns: [dict] dictionary is empty on failure.\n" " port1 [int]: Port-id for endpoint at dom1.\n" " port2 [int]: Port-id for endpoint at dom2.\n" }, @@ -1650,8 +1651,8 @@ static PyMethodDef pyxc_methods[] = { (PyCFunction)pyxc_evtchn_close, METH_VARARGS | METH_KEYWORDS, "\n" "Close an event channel.\n" - " dom [long, SELF]: Dom-id of one endpoint of the channel.\n" - " port [int]: Port-id of one endpoint of the channel.\n\n" + " dom [int, SELF]: Dom-id of one endpoint of the channel.\n" + " port [int]: Port-id of one endpoint of the channel.\n\n" "Returns: [int] 0 on success; -1 on error.\n" }, { "evtchn_send", @@ -1665,26 +1666,26 @@ static PyMethodDef pyxc_methods[] = { (PyCFunction)pyxc_evtchn_status, METH_VARARGS | METH_KEYWORDS, "\n" "Query the status of an event channel.\n" - " dom [long, SELF]: Dom-id of one endpoint of the channel.\n" - " port [int]: Port-id of one endpoint of the channel.\n\n" + " dom [int, SELF]: Dom-id of one endpoint of the channel.\n" + " port [int]: Port-id of one endpoint of the channel.\n\n" "Returns: [dict] dictionary is empty on failure.\n" " status [str]: 'closed', 'unbound', 'interdomain', 'pirq'," " or 'virq'.\n" "The following are returned if 'status' is 'interdomain':\n" - " dom [long]: Dom-id of remote endpoint.\n" - " port [int]: Port-id of remote endpoint.\n" + " dom [int]: Dom-id of remote endpoint.\n" + " port [int]: Port-id of remote endpoint.\n" "The following are returned if 'status' is 'pirq' or 'virq':\n" - " irq [int]: IRQ number.\n" }, + " irq [int]: IRQ number.\n" }, { "physdev_pci_access_modify", (PyCFunction)pyxc_physdev_pci_access_modify, METH_VARARGS | METH_KEYWORDS, "\n" "Allow a domain access to a PCI device\n" - " dom [long]: Identifier of domain to be allowed access.\n" - " bus [int]: PCI bus\n" - " dev [int]: PCI slot\n" - " func [int]: PCI function\n" - " enable [int]: Non-zero means enable access; else disable access\n\n" + " dom [int]: Identifier of domain to be allowed access.\n" + " bus [int]: PCI bus\n" + " dev [int]: PCI slot\n" + " func [int]: PCI function\n" + " enable [int]: Non-zero means enable access; else disable access\n\n" "Returns: [int] 0 on success; -1 on error.\n" }, { "readconsolering", @@ -1705,7 +1706,7 @@ static PyMethodDef pyxc_methods[] = { (PyCFunction)pyxc_shadow_control, METH_VARARGS | METH_KEYWORDS, "\n" "Set parameter for shadow pagetable interface\n" - " dom [long]: Identifier of domain.\n" + " dom [int]: Identifier of domain.\n" " op [int, 0]: operation\n\n" "Returns: [int] 0 on success; -1 on error.\n" }, @@ -1713,7 +1714,7 @@ static PyMethodDef pyxc_methods[] = { (PyCFunction)pyxc_domain_setname, METH_VARARGS | METH_KEYWORDS, "\n" "Set domain informative textual name\n" - " dom [long]: Identifier of domain.\n" + " dom [int]: Identifier of domain.\n" " name [str]: Text string.\n\n" "Returns: [int] 0 on success; -1 on error.\n" }, @@ -1721,7 +1722,7 @@ static PyMethodDef pyxc_methods[] = { (PyCFunction)pyxc_domain_setname, METH_VARARGS | METH_KEYWORDS, "\n" "Set a domain's memory limit\n" - " dom [long]: Identifier of domain.\n" + " dom [int]: Identifier of domain.\n" " max_memkb [long]: .\n" "Returns: [int] 0 on success; -1 on error.\n" }, @@ -1747,7 +1748,7 @@ static PyObject *PyXc_new(PyObject *self, PyObject *args) if ( (xc->xc_handle = xc_interface_open()) == -1 ) { PyObject_Del((PyObject *)xc); - return PyErr_SetFromErrno(xc_error); + return PyErr_SetFromErrno(xc_error); } return (PyObject *)xc; diff --git a/tools/xend/lib/blkif.py b/tools/xend/lib/blkif.py index 94e058f7ce..c0f4784e68 100644 --- a/tools/xend/lib/blkif.py +++ b/tools/xend/lib/blkif.py @@ -43,18 +43,18 @@ def backend_rx_rsp(port, msg): rsp = { 'success': True } xend.main.send_management_response(rsp, xend.blkif.pendaddr) elif subtype == CMSG_BLKIF_BE_CONNECT: - (dom,hnd,evtchn,frame,st) = struct.unpack("QIILI", msg.get_payload()) + (dom,hnd,evtchn,frame,st) = struct.unpack("IIILI", msg.get_payload()) blkif = interface.list[xend.main.port_from_dom(dom).local_port] msg = xend.utils.message(CMSG_BLKIF_FE, \ CMSG_BLKIF_FE_INTERFACE_STATUS_CHANGED, 0) msg.append_payload(struct.pack("III",0,2,blkif.evtchn['port2'])) blkif.ctrlif_tx_req(xend.main.port_list[blkif.key], msg) elif subtype == CMSG_BLKIF_BE_VBD_CREATE: - (dom,hnd,vdev,ro,st) = struct.unpack("QIHII", msg.get_payload()) + (dom,hnd,vdev,ro,st) = struct.unpack("IIHII", msg.get_payload()) blkif = interface.list[xend.main.port_from_dom(dom).local_port] (pdev, start_sect, nr_sect, readonly) = blkif.devices[vdev] msg = xend.utils.message(CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_GROW, 0) - msg.append_payload(struct.pack("QIHHHQQI",dom,0,vdev,0, \ + msg.append_payload(struct.pack("IIHHHQQI",dom,0,vdev,0, \ pdev,start_sect,nr_sect,0)) backend_tx_req(msg) elif subtype == CMSG_BLKIF_BE_VBD_GROW: @@ -84,7 +84,7 @@ class interface: self.pendmsg = None interface.list[key] = self msg = xend.utils.message(CMSG_BLKIF_BE, CMSG_BLKIF_BE_CREATE, 0) - msg.append_payload(struct.pack("QII",dom,0,0)) + msg.append_payload(struct.pack("III",dom,0,0)) xend.blkif.pendaddr = xend.main.mgmt_req_addr backend_tx_req(msg) @@ -94,7 +94,7 @@ class interface: return False self.devices[vdev] = (pdev, start_sect, nr_sect, readonly) msg = xend.utils.message(CMSG_BLKIF_BE, CMSG_BLKIF_BE_VBD_CREATE, 0) - msg.append_payload(struct.pack("QIHII",self.dom,0,vdev,readonly,0)) + msg.append_payload(struct.pack("IIHII",self.dom,0,vdev,readonly,0)) xend.blkif.pendaddr = xend.main.mgmt_req_addr backend_tx_req(msg) return True @@ -104,7 +104,7 @@ class interface: def destroy(self): del interface.list[self.key] msg = xend.utils.message(CMSG_BLKIF_BE, CMSG_BLKIF_BE_DESTROY, 0) - msg.append_payload(struct.pack("QII",self.dom,0,0)) + msg.append_payload(struct.pack("III",self.dom,0,0)) backend_tx_req(msg) @@ -138,6 +138,6 @@ class interface: self.evtchn = xc.evtchn_bind_interdomain(dom1=0,dom2=self.dom) msg = xend.utils.message(CMSG_BLKIF_BE, \ CMSG_BLKIF_BE_CONNECT, 0) - msg.append_payload(struct.pack("QIILI",self.dom,0, \ + msg.append_payload(struct.pack("IIILI",self.dom,0, \ self.evtchn['port1'],frame,0)) backend_tx_req(msg) diff --git a/tools/xend/lib/netif.py b/tools/xend/lib/netif.py index 11756c5e56..525baa6585 100644 --- a/tools/xend/lib/netif.py +++ b/tools/xend/lib/netif.py @@ -40,7 +40,7 @@ def backend_rx_rsp(port, msg): xend.main.send_management_response(rsp, xend.netif.pendaddr) elif subtype == CMSG_NETIF_BE_CONNECT: (dom,hnd,evtchn,tx_frame,rx_frame,st) = \ - struct.unpack("QIILLI", msg.get_payload()) + struct.unpack("IIILLI", msg.get_payload()) netif = interface.list[xend.main.port_from_dom(dom).local_port] msg = xend.utils.message(CMSG_NETIF_FE, \ CMSG_NETIF_FE_INTERFACE_STATUS_CHANGED, 0) @@ -88,7 +88,7 @@ class interface: interface.list[key] = self msg = xend.utils.message(CMSG_NETIF_BE, CMSG_NETIF_BE_CREATE, 0) - msg.append_payload(struct.pack("QIBBBBBBBBI",dom,0, \ + msg.append_payload(struct.pack("IIBBBBBBBBI",dom,0, \ self.mac[0],self.mac[1], \ self.mac[2],self.mac[3], \ self.mac[4],self.mac[5], \ @@ -101,7 +101,7 @@ class interface: def destroy(self): del interface.list[self.key] msg = xend.utils.message(CMSG_NETIF_BE, CMSG_NETIF_BE_DESTROY, 0) - msg.append_payload(struct.pack("QII",self.dom,0,0)) + msg.append_payload(struct.pack("III",self.dom,0,0)) backend_tx_req(msg) @@ -138,7 +138,7 @@ class interface: self.evtchn = xc.evtchn_bind_interdomain(dom1=0,dom2=self.dom) msg = xend.utils.message(CMSG_NETIF_BE, \ CMSG_NETIF_BE_CONNECT, 0) - msg.append_payload(struct.pack("QIILLI",self.dom,0, \ + msg.append_payload(struct.pack("IIILLI",self.dom,0, \ self.evtchn['port1'],tx_frame, \ rx_frame,0)) backend_tx_req(msg) diff --git a/tools/xend/lib/utils.c b/tools/xend/lib/utils.c index 441b62f153..56d0b4899d 100644 --- a/tools/xend/lib/utils.c +++ b/tools/xend/lib/utils.c @@ -408,7 +408,7 @@ typedef struct { PyObject_HEAD; int mem_fd; int xc_handle; - u64 remote_dom; + u32 remote_dom; int local_port, remote_port; control_if_t *interface; CONTROL_RING_IDX tx_req_cons, tx_resp_prod; @@ -661,11 +661,11 @@ staticforward PyTypeObject xu_port_type; static PyObject *xu_port_new(PyObject *self, PyObject *args) { xu_port_object *xup; - u64 dom; + u32 dom; int port1, port2; xc_dominfo_t info; - if ( !PyArg_ParseTuple(args, "L", &dom) ) + if ( !PyArg_ParseTuple(args, "i", &dom) ) return NULL; xup = PyObject_New(xu_port_object, &xu_port_type); @@ -677,8 +677,7 @@ static PyObject *xu_port_new(PyObject *self, PyObject *args) } /* Set the General-Purpose Subject whose page frame will be mapped. */ - (void)ioctl(xup->mem_fd, _IO('M', 1), (unsigned long)(dom>> 0)); /* low */ - (void)ioctl(xup->mem_fd, _IO('M', 2), (unsigned long)(dom>>32)); /* high */ + (void)ioctl(xup->mem_fd, _IO('M', 1), (unsigned long)dom); if ( (xup->xc_handle = xc_interface_open()) == -1 ) { @@ -686,7 +685,7 @@ static PyObject *xu_port_new(PyObject *self, PyObject *args) goto fail2; } - if ( dom == 0ULL ) + if ( dom == 0 ) { /* * The control-interface event channel for DOM0 is already set up. @@ -758,7 +757,7 @@ static PyObject *xu_port_getattr(PyObject *obj, char *name) if ( strcmp(name, "remote_port") == 0 ) return PyInt_FromLong(xup->remote_port); if ( strcmp(name, "remote_dom") == 0 ) - return PyLong_FromUnsignedLongLong(xup->remote_dom); + return PyInt_FromLong(xup->remote_dom); return Py_FindMethod(xu_port_methods, obj, name); } @@ -766,7 +765,7 @@ static void xu_port_dealloc(PyObject *self) { xu_port_object *xup = (xu_port_object *)self; unmap_control_interface(xup->mem_fd, xup->interface); - if ( xup->remote_dom != 0ULL ) + if ( xup->remote_dom != 0 ) (void)xc_evtchn_close(xup->xc_handle, DOMID_SELF, xup->local_port); (void)xc_interface_close(xup->xc_handle); (void)close(xup->mem_fd); |
