[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 25 of 25] libxc: finalise transition to hypercall buffers
# HG changeset patch # User Ian Campbell <ian.campbell@xxxxxxxxxx> # Date 1287650255 -3600 # Node ID a4e1a2dbc215e601acf69b212f82cea767f3330c # Parent 42caa87197dfe69901d4d20c6432b5914b62ac07 libxc: finalise transition to hypercall buffers. Rename xc_set_xen_guest_handle to set_xen_guest_handle[0] and remove now unused functions: - xc_memalign - lock_pages - unlock_pages - hcall_buf_prep - hcall_buf_release [0] sed -i -e 's/xc_set_xen_guest_handle/set_xen_guest_handle/g' \ tools/libxc/*.[ch] \ tools/python/xen/lowlevel/xc/xc.c \ tools/python/xen/lowlevel/acm/acm.c \ tools/libxc/ia64/xc_ia64_stubs.c \ tools/security/secpol_tool.c \ tools/misc/xenpm.c Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> diff -r 42caa87197df -r a4e1a2dbc215 tools/libxc/xc_cpupool.c --- a/tools/libxc/xc_cpupool.c Thu Oct 21 09:37:35 2010 +0100 +++ b/tools/libxc/xc_cpupool.c Thu Oct 21 09:37:35 2010 +0100 @@ -88,7 +88,7 @@ int xc_cpupool_getinfo(xc_interface *xch sysctl.cmd = XEN_SYSCTL_cpupool_op; sysctl.u.cpupool_op.op = XEN_SYSCTL_CPUPOOL_OP_INFO; sysctl.u.cpupool_op.cpupool_id = poolid; - xc_set_xen_guest_handle(sysctl.u.cpupool_op.cpumap.bitmap, local); + set_xen_guest_handle(sysctl.u.cpupool_op.cpumap.bitmap, local); sysctl.u.cpupool_op.cpumap.nr_cpus = sizeof(info->cpumap) * 8; err = do_sysctl_save(xch, &sysctl); @@ -165,7 +165,7 @@ int xc_cpupool_freeinfo(xc_interface *xc sysctl.cmd = XEN_SYSCTL_cpupool_op; sysctl.u.cpupool_op.op = XEN_SYSCTL_CPUPOOL_OP_FREEINFO; - xc_set_xen_guest_handle(sysctl.u.cpupool_op.cpumap.bitmap, local); + set_xen_guest_handle(sysctl.u.cpupool_op.cpumap.bitmap, local); sysctl.u.cpupool_op.cpumap.nr_cpus = sizeof(*cpumap) * 8; err = do_sysctl_save(xch, &sysctl); diff -r 42caa87197df -r a4e1a2dbc215 tools/libxc/xc_dom_boot.c --- a/tools/libxc/xc_dom_boot.c Thu Oct 21 09:37:35 2010 +0100 +++ b/tools/libxc/xc_dom_boot.c Thu Oct 21 09:37:35 2010 +0100 @@ -72,7 +72,7 @@ static int launch_vm(xc_interface *xch, domctl.cmd = XEN_DOMCTL_setvcpucontext; domctl.domain = domid; domctl.u.vcpucontext.vcpu = 0; - xc_set_xen_guest_handle(domctl.u.vcpucontext.ctxt, ctxt); + set_xen_guest_handle(domctl.u.vcpucontext.ctxt, ctxt); rc = do_domctl(xch, &domctl); if ( rc != 0 ) xc_dom_panic(xch, XC_INTERNAL_ERROR, diff -r 42caa87197df -r a4e1a2dbc215 tools/libxc/xc_domain.c --- a/tools/libxc/xc_domain.c Thu Oct 21 09:37:35 2010 +0100 +++ b/tools/libxc/xc_domain.c Thu Oct 21 09:37:35 2010 +0100 @@ -132,7 +132,7 @@ int xc_vcpu_setaffinity(xc_interface *xc bitmap_64_to_byte(local, cpumap, cpusize * 8); - xc_set_xen_guest_handle(domctl.u.vcpuaffinity.cpumap.bitmap, local); + set_xen_guest_handle(domctl.u.vcpuaffinity.cpumap.bitmap, local); domctl.u.vcpuaffinity.cpumap.nr_cpus = cpusize * 8; @@ -165,7 +165,7 @@ int xc_vcpu_getaffinity(xc_interface *xc domctl.domain = (domid_t)domid; domctl.u.vcpuaffinity.vcpu = vcpu; - xc_set_xen_guest_handle(domctl.u.vcpuaffinity.cpumap.bitmap, local); + set_xen_guest_handle(domctl.u.vcpuaffinity.cpumap.bitmap, local); domctl.u.vcpuaffinity.cpumap.nr_cpus = cpusize * 8; ret = do_domctl(xch, &domctl); @@ -254,7 +254,7 @@ int xc_domain_getinfolist(xc_interface * sysctl.cmd = XEN_SYSCTL_getdomaininfolist; sysctl.u.getdomaininfolist.first_domain = first_domain; sysctl.u.getdomaininfolist.max_domains = max_domains; - xc_set_xen_guest_handle(sysctl.u.getdomaininfolist.buffer, info); + set_xen_guest_handle(sysctl.u.getdomaininfolist.buffer, info); if ( xc_sysctl(xch, &sysctl) < 0 ) ret = -1; @@ -282,7 +282,7 @@ int xc_domain_hvm_getcontext(xc_interfac domctl.cmd = XEN_DOMCTL_gethvmcontext; domctl.domain = (domid_t)domid; domctl.u.hvmcontext.size = size; - xc_set_xen_guest_handle(domctl.u.hvmcontext.buffer, ctxt_buf); + set_xen_guest_handle(domctl.u.hvmcontext.buffer, ctxt_buf); ret = do_domctl(xch, &domctl); @@ -311,7 +311,7 @@ int xc_domain_hvm_getcontext_partial(xc_ domctl.domain = (domid_t) domid; domctl.u.hvmcontext_partial.type = typecode; domctl.u.hvmcontext_partial.instance = instance; - xc_set_xen_guest_handle(domctl.u.hvmcontext_partial.buffer, ctxt_buf); + set_xen_guest_handle(domctl.u.hvmcontext_partial.buffer, ctxt_buf); ret = do_domctl(xch, &domctl); @@ -337,7 +337,7 @@ int xc_domain_hvm_setcontext(xc_interfac domctl.cmd = XEN_DOMCTL_sethvmcontext; domctl.domain = domid; domctl.u.hvmcontext.size = size; - xc_set_xen_guest_handle(domctl.u.hvmcontext.buffer, ctxt_buf); + set_xen_guest_handle(domctl.u.hvmcontext.buffer, ctxt_buf); ret = do_domctl(xch, &domctl); @@ -361,7 +361,7 @@ int xc_vcpu_getcontext(xc_interface *xch domctl.cmd = XEN_DOMCTL_getvcpucontext; domctl.domain = (domid_t)domid; domctl.u.vcpucontext.vcpu = (uint16_t)vcpu; - xc_set_xen_guest_handle(domctl.u.vcpucontext.ctxt, ctxt); + set_xen_guest_handle(domctl.u.vcpucontext.ctxt, ctxt); rc = do_domctl(xch, &domctl); @@ -420,7 +420,7 @@ int xc_shadow_control(xc_interface *xch, domctl.u.shadow_op.mb = mb ? *mb : 0; domctl.u.shadow_op.mode = mode; if (dirty_bitmap != NULL) - xc_set_xen_guest_handle(domctl.u.shadow_op.dirty_bitmap, + set_xen_guest_handle(domctl.u.shadow_op.dirty_bitmap, dirty_bitmap); rc = do_domctl(xch, &domctl); @@ -486,7 +486,7 @@ int xc_domain_set_memmap_limit(xc_interf e820->size = (uint64_t)map_limitkb << 10; e820->type = E820_RAM; - xc_set_xen_guest_handle(fmap.map.buffer, e820); + set_xen_guest_handle(fmap.map.buffer, e820); rc = do_memory_op(xch, XENMEM_set_memory_map, &fmap, sizeof(fmap)); @@ -559,7 +559,7 @@ int xc_domain_get_tsc_info(xc_interface domctl.cmd = XEN_DOMCTL_gettscinfo; domctl.domain = (domid_t)domid; - xc_set_xen_guest_handle(domctl.u.tsc_info.out_info, info); + set_xen_guest_handle(domctl.u.tsc_info.out_info, info); rc = do_domctl(xch, &domctl); if ( rc == 0 ) { @@ -601,7 +601,7 @@ int xc_domain_increase_reservation(xc_in return -1; } - xc_set_xen_guest_handle(reservation.extent_start, extent_start); + set_xen_guest_handle(reservation.extent_start, extent_start); err = do_memory_op(xch, XENMEM_increase_reservation, &reservation, sizeof(reservation)); @@ -664,7 +664,7 @@ int xc_domain_decrease_reservation(xc_in PERROR("Could not bounce memory for XENMEM_decrease_reservation hypercall"); return -1; } - xc_set_xen_guest_handle(reservation.extent_start, extent_start); + set_xen_guest_handle(reservation.extent_start, extent_start); err = do_memory_op(xch, XENMEM_decrease_reservation, &reservation, sizeof(reservation)); @@ -734,7 +734,7 @@ int xc_domain_populate_physmap(xc_interf PERROR("Could not bounce memory for XENMEM_populate_physmap hypercall"); return -1; } - xc_set_xen_guest_handle(reservation.extent_start, extent_start); + set_xen_guest_handle(reservation.extent_start, extent_start); err = do_memory_op(xch, XENMEM_populate_physmap, &reservation, sizeof(reservation)); @@ -796,8 +796,8 @@ int xc_domain_memory_exchange_pages(xc_i xc_hypercall_bounce_pre(xch, out_extents)) goto out; - xc_set_xen_guest_handle(exchange.in.extent_start, in_extents); - xc_set_xen_guest_handle(exchange.out.extent_start, out_extents); + set_xen_guest_handle(exchange.in.extent_start, in_extents); + set_xen_guest_handle(exchange.out.extent_start, out_extents); rc = do_memory_op(xch, XENMEM_exchange, &exchange, sizeof(exchange)); @@ -976,7 +976,7 @@ int xc_vcpu_setcontext(xc_interface *xch domctl.cmd = XEN_DOMCTL_setvcpucontext; domctl.domain = domid; domctl.u.vcpucontext.vcpu = vcpu; - xc_set_xen_guest_handle(domctl.u.vcpucontext.ctxt, ctxt); + set_xen_guest_handle(domctl.u.vcpucontext.ctxt, ctxt); rc = do_domctl(xch, &domctl); @@ -1124,7 +1124,7 @@ int xc_get_device_group( domctl.u.get_device_group.machine_bdf = machine_bdf; domctl.u.get_device_group.max_sdevs = max_sdevs; - xc_set_xen_guest_handle(domctl.u.get_device_group.sdev_array, sdev_array); + set_xen_guest_handle(domctl.u.get_device_group.sdev_array, sdev_array); rc = do_domctl(xch, &domctl); diff -r 42caa87197df -r a4e1a2dbc215 tools/libxc/xc_domain_restore.c --- a/tools/libxc/xc_domain_restore.c Thu Oct 21 09:37:35 2010 +0100 +++ b/tools/libxc/xc_domain_restore.c Thu Oct 21 09:37:35 2010 +0100 @@ -1639,7 +1639,7 @@ int xc_domain_restore(xc_interface *xch, domctl.cmd = XEN_DOMCTL_setvcpucontext; domctl.domain = (domid_t)dom; domctl.u.vcpucontext.vcpu = i; - xc_set_xen_guest_handle(domctl.u.vcpucontext.ctxt, ctxt); + set_xen_guest_handle(domctl.u.vcpucontext.ctxt, ctxt); frc = xc_domctl(xch, &domctl); if ( frc != 0 ) { diff -r 42caa87197df -r a4e1a2dbc215 tools/libxc/xc_linux.c --- a/tools/libxc/xc_linux.c Thu Oct 21 09:37:35 2010 +0100 +++ b/tools/libxc/xc_linux.c Thu Oct 21 09:37:35 2010 +0100 @@ -686,7 +686,7 @@ static void *_gnttab_map_table(xc_interf setup.dom = domid; setup.nr_frames = query.nr_frames; - xc_set_xen_guest_handle(setup.frame_list, frame_list); + set_xen_guest_handle(setup.frame_list, frame_list); /* XXX Any race with other setup_table hypercall? */ rc = xc_gnttab_op(xch, GNTTABOP_setup_table, &setup, sizeof(setup), diff -r 42caa87197df -r a4e1a2dbc215 tools/libxc/xc_misc.c --- a/tools/libxc/xc_misc.c Thu Oct 21 09:37:35 2010 +0100 +++ b/tools/libxc/xc_misc.c Thu Oct 21 09:37:35 2010 +0100 @@ -35,7 +35,7 @@ int xc_readconsolering(xc_interface *xch return -1; sysctl.cmd = XEN_SYSCTL_readconsole; - xc_set_xen_guest_handle(sysctl.u.readconsole.buffer, buffer); + set_xen_guest_handle(sysctl.u.readconsole.buffer, buffer); sysctl.u.readconsole.count = nr_chars; sysctl.u.readconsole.clear = clear; sysctl.u.readconsole.incremental = 0; @@ -67,7 +67,7 @@ int xc_send_debug_keys(xc_interface *xch return -1; sysctl.cmd = XEN_SYSCTL_debug_keys; - xc_set_xen_guest_handle(sysctl.u.debug_keys.keys, keys); + set_xen_guest_handle(sysctl.u.debug_keys.keys, keys); sysctl.u.debug_keys.nr_keys = len; ret = do_sysctl(xch, &sysctl); @@ -176,8 +176,8 @@ int xc_perfc_reset(xc_interface *xch) sysctl.cmd = XEN_SYSCTL_perfc_op; sysctl.u.perfc_op.cmd = XEN_SYSCTL_PERFCOP_reset; - xc_set_xen_guest_handle(sysctl.u.perfc_op.desc, HYPERCALL_BUFFER_NULL); - xc_set_xen_guest_handle(sysctl.u.perfc_op.val, HYPERCALL_BUFFER_NULL); + set_xen_guest_handle(sysctl.u.perfc_op.desc, HYPERCALL_BUFFER_NULL); + set_xen_guest_handle(sysctl.u.perfc_op.val, HYPERCALL_BUFFER_NULL); return do_sysctl(xch, &sysctl); } @@ -191,8 +191,8 @@ int xc_perfc_query_number(xc_interface * sysctl.cmd = XEN_SYSCTL_perfc_op; sysctl.u.perfc_op.cmd = XEN_SYSCTL_PERFCOP_query; - xc_set_xen_guest_handle(sysctl.u.perfc_op.desc, HYPERCALL_BUFFER_NULL); - xc_set_xen_guest_handle(sysctl.u.perfc_op.val, HYPERCALL_BUFFER_NULL); + set_xen_guest_handle(sysctl.u.perfc_op.desc, HYPERCALL_BUFFER_NULL); + set_xen_guest_handle(sysctl.u.perfc_op.val, HYPERCALL_BUFFER_NULL); rc = do_sysctl(xch, &sysctl); @@ -214,8 +214,8 @@ int xc_perfc_query(xc_interface *xch, sysctl.cmd = XEN_SYSCTL_perfc_op; sysctl.u.perfc_op.cmd = XEN_SYSCTL_PERFCOP_query; - xc_set_xen_guest_handle(sysctl.u.perfc_op.desc, desc); - xc_set_xen_guest_handle(sysctl.u.perfc_op.val, val); + set_xen_guest_handle(sysctl.u.perfc_op.desc, desc); + set_xen_guest_handle(sysctl.u.perfc_op.val, val); return do_sysctl(xch, &sysctl); } @@ -226,7 +226,7 @@ int xc_lockprof_reset(xc_interface *xch) sysctl.cmd = XEN_SYSCTL_lockprof_op; sysctl.u.lockprof_op.cmd = XEN_SYSCTL_LOCKPROF_reset; - xc_set_xen_guest_handle(sysctl.u.lockprof_op.data, HYPERCALL_BUFFER_NULL); + set_xen_guest_handle(sysctl.u.lockprof_op.data, HYPERCALL_BUFFER_NULL); return do_sysctl(xch, &sysctl); } @@ -239,7 +239,7 @@ int xc_lockprof_query_number(xc_interfac sysctl.cmd = XEN_SYSCTL_lockprof_op; sysctl.u.lockprof_op.cmd = XEN_SYSCTL_LOCKPROF_query; - xc_set_xen_guest_handle(sysctl.u.lockprof_op.data, HYPERCALL_BUFFER_NULL); + set_xen_guest_handle(sysctl.u.lockprof_op.data, HYPERCALL_BUFFER_NULL); rc = do_sysctl(xch, &sysctl); @@ -260,7 +260,7 @@ int xc_lockprof_query(xc_interface *xch, sysctl.cmd = XEN_SYSCTL_lockprof_op; sysctl.u.lockprof_op.cmd = XEN_SYSCTL_LOCKPROF_query; sysctl.u.lockprof_op.max_elem = *n_elems; - xc_set_xen_guest_handle(sysctl.u.lockprof_op.data, data); + set_xen_guest_handle(sysctl.u.lockprof_op.data, data); rc = do_sysctl(xch, &sysctl); @@ -281,7 +281,7 @@ int xc_getcpuinfo(xc_interface *xch, int sysctl.cmd = XEN_SYSCTL_getcpuinfo; sysctl.u.getcpuinfo.max_cpus = max_cpus; - xc_set_xen_guest_handle(sysctl.u.getcpuinfo.info, info); + set_xen_guest_handle(sysctl.u.getcpuinfo.info, info); rc = do_sysctl(xch, &sysctl); @@ -413,7 +413,7 @@ int xc_hvm_track_dirty_vram( arg->domid = dom; arg->first_pfn = first_pfn; arg->nr = nr; - xc_set_xen_guest_handle(arg->dirty_bitmap, dirty_bitmap); + set_xen_guest_handle(arg->dirty_bitmap, dirty_bitmap); rc = do_xen_hypercall(xch, &hypercall); diff -r 42caa87197df -r a4e1a2dbc215 tools/libxc/xc_offline_page.c --- a/tools/libxc/xc_offline_page.c Thu Oct 21 09:37:35 2010 +0100 +++ b/tools/libxc/xc_offline_page.c Thu Oct 21 09:37:35 2010 +0100 @@ -82,7 +82,7 @@ int xc_mark_page_online(xc_interface *xc sysctl.u.page_offline.start = start; sysctl.u.page_offline.cmd = sysctl_page_online; sysctl.u.page_offline.end = end; - xc_set_xen_guest_handle(sysctl.u.page_offline.status, status); + set_xen_guest_handle(sysctl.u.page_offline.status, status); ret = xc_sysctl(xch, &sysctl); xc_hypercall_bounce_post(xch, status); @@ -110,7 +110,7 @@ int xc_mark_page_offline(xc_interface *x sysctl.u.page_offline.start = start; sysctl.u.page_offline.cmd = sysctl_page_offline; sysctl.u.page_offline.end = end; - xc_set_xen_guest_handle(sysctl.u.page_offline.status, status); + set_xen_guest_handle(sysctl.u.page_offline.status, status); ret = xc_sysctl(xch, &sysctl); xc_hypercall_bounce_post(xch, status); @@ -138,7 +138,7 @@ int xc_query_page_offline_status(xc_inte sysctl.u.page_offline.start = start; sysctl.u.page_offline.cmd = sysctl_query_page_offline; sysctl.u.page_offline.end = end; - xc_set_xen_guest_handle(sysctl.u.page_offline.status, status); + set_xen_guest_handle(sysctl.u.page_offline.status, status); ret = xc_sysctl(xch, &sysctl); xc_hypercall_bounce_post(xch, status); diff -r 42caa87197df -r a4e1a2dbc215 tools/libxc/xc_pm.c --- a/tools/libxc/xc_pm.c Thu Oct 21 09:37:35 2010 +0100 +++ b/tools/libxc/xc_pm.c Thu Oct 21 09:37:35 2010 +0100 @@ -73,8 +73,8 @@ int xc_pm_get_pxstat(xc_interface *xch, sysctl.u.get_pmstat.type = PMSTAT_get_pxstat; sysctl.u.get_pmstat.cpuid = cpuid; sysctl.u.get_pmstat.u.getpx.total = max_px; - xc_set_xen_guest_handle(sysctl.u.get_pmstat.u.getpx.trans_pt, trans); - xc_set_xen_guest_handle(sysctl.u.get_pmstat.u.getpx.pt, pt); + set_xen_guest_handle(sysctl.u.get_pmstat.u.getpx.trans_pt, trans); + set_xen_guest_handle(sysctl.u.get_pmstat.u.getpx.pt, pt); ret = xc_sysctl(xch, &sysctl); if ( ret ) @@ -146,8 +146,8 @@ int xc_pm_get_cxstat(xc_interface *xch, sysctl.cmd = XEN_SYSCTL_get_pmstat; sysctl.u.get_pmstat.type = PMSTAT_get_cxstat; sysctl.u.get_pmstat.cpuid = cpuid; - xc_set_xen_guest_handle(sysctl.u.get_pmstat.u.getcx.triggers, triggers); - xc_set_xen_guest_handle(sysctl.u.get_pmstat.u.getcx.residencies, residencies); + set_xen_guest_handle(sysctl.u.get_pmstat.u.getcx.triggers, triggers); + set_xen_guest_handle(sysctl.u.get_pmstat.u.getcx.residencies, residencies); if ( (ret = xc_sysctl(xch, &sysctl)) ) goto unlock_2; @@ -219,9 +219,9 @@ int xc_get_cpufreq_para(xc_interface *xc if ( xc_hypercall_bounce_pre(xch, scaling_available_governors) ) goto unlock_3; - xc_set_xen_guest_handle(sys_para->affected_cpus, affected_cpus); - xc_set_xen_guest_handle(sys_para->scaling_available_frequencies, scaling_available_frequencies); - xc_set_xen_guest_handle(sys_para->scaling_available_governors, scaling_available_governors); + set_xen_guest_handle(sys_para->affected_cpus, affected_cpus); + set_xen_guest_handle(sys_para->scaling_available_frequencies, scaling_available_frequencies); + set_xen_guest_handle(sys_para->scaling_available_governors, scaling_available_governors); } sysctl.cmd = XEN_SYSCTL_pm_op; diff -r 42caa87197df -r a4e1a2dbc215 tools/libxc/xc_private.c --- a/tools/libxc/xc_private.c Thu Oct 21 09:37:35 2010 +0100 +++ b/tools/libxc/xc_private.c Thu Oct 21 09:37:35 2010 +0100 @@ -71,8 +71,6 @@ xc_interface *xc_interface_open(xentooll return 0; } -static void xc_clean_hcall_buf(xc_interface *xch); - int xc_interface_close(xc_interface *xch) { int rc = 0; @@ -84,8 +82,6 @@ int xc_interface_close(xc_interface *xch rc = xc_interface_close_core(xch, xch->fd); if (rc) PERROR("Could not close hypervisor interface"); } - - xc_clean_hcall_buf(xch); free(xch); return rc; @@ -191,133 +187,6 @@ void xc_report_progress_step(xc_interfac done, total); } -#ifdef __sun__ - -int lock_pages(xc_interface *xch, void *addr, size_t len) { return 0; } -void unlock_pages(xc_interface *xch, void *addr, size_t len) { } - -int hcall_buf_prep(xc_interface *xch, void **addr, size_t len) { return 0; } -void hcall_buf_release(xc_interface *xch, void **addr, size_t len) { } - -static void xc_clean_hcall_buf(xc_interface *xch) { } - -#else /* !__sun__ */ - -int lock_pages(xc_interface *xch, void *addr, size_t len) -{ - int e; - void *laddr = (void *)((unsigned long)addr & PAGE_MASK); - size_t llen = (len + ((unsigned long)addr - (unsigned long)laddr) + - PAGE_SIZE - 1) & PAGE_MASK; - e = mlock(laddr, llen); - return e; -} - -void unlock_pages(xc_interface *xch, void *addr, size_t len) -{ - void *laddr = (void *)((unsigned long)addr & PAGE_MASK); - size_t llen = (len + ((unsigned long)addr - (unsigned long)laddr) + - PAGE_SIZE - 1) & PAGE_MASK; - int saved_errno = errno; - (void)munlock(laddr, llen); - errno = saved_errno; -} - -static pthread_key_t hcall_buf_pkey; -static pthread_once_t hcall_buf_pkey_once = PTHREAD_ONCE_INIT; -struct hcall_buf { - xc_interface *xch; - void *buf; - void *oldbuf; -}; - -static void _xc_clean_hcall_buf(void *m) -{ - struct hcall_buf *hcall_buf = m; - - if ( hcall_buf ) - { - if ( hcall_buf->buf ) - { - unlock_pages(hcall_buf->xch, hcall_buf->buf, PAGE_SIZE); - free(hcall_buf->buf); - } - - free(hcall_buf); - } - - pthread_setspecific(hcall_buf_pkey, NULL); -} - -static void _xc_init_hcall_buf(void) -{ - pthread_key_create(&hcall_buf_pkey, _xc_clean_hcall_buf); -} - -static void xc_clean_hcall_buf(xc_interface *xch) -{ - pthread_once(&hcall_buf_pkey_once, _xc_init_hcall_buf); - - _xc_clean_hcall_buf(pthread_getspecific(hcall_buf_pkey)); -} - -int hcall_buf_prep(xc_interface *xch, void **addr, size_t len) -{ - struct hcall_buf *hcall_buf; - - pthread_once(&hcall_buf_pkey_once, _xc_init_hcall_buf); - - hcall_buf = pthread_getspecific(hcall_buf_pkey); - if ( !hcall_buf ) - { - hcall_buf = calloc(1, sizeof(*hcall_buf)); - if ( !hcall_buf ) - goto out; - hcall_buf->xch = xch; - pthread_setspecific(hcall_buf_pkey, hcall_buf); - } - - if ( !hcall_buf->buf ) - { - hcall_buf->buf = xc_memalign(PAGE_SIZE, PAGE_SIZE); - if ( !hcall_buf->buf || lock_pages(xch, hcall_buf->buf, PAGE_SIZE) ) - { - free(hcall_buf->buf); - hcall_buf->buf = NULL; - goto out; - } - } - - if ( (len < PAGE_SIZE) && !hcall_buf->oldbuf ) - { - memcpy(hcall_buf->buf, *addr, len); - hcall_buf->oldbuf = *addr; - *addr = hcall_buf->buf; - return 0; - } - - out: - return lock_pages(xch, *addr, len); -} - -void hcall_buf_release(xc_interface *xch, void **addr, size_t len) -{ - struct hcall_buf *hcall_buf = pthread_getspecific(hcall_buf_pkey); - - if ( hcall_buf && (hcall_buf->buf == *addr) ) - { - memcpy(hcall_buf->oldbuf, *addr, len); - *addr = hcall_buf->oldbuf; - hcall_buf->oldbuf = NULL; - } - else - { - unlock_pages(xch, *addr, len); - } -} - -#endif - /* NB: arr must be locked */ int xc_get_pfn_type_batch(xc_interface *xch, uint32_t dom, unsigned int num, xen_pfn_t *arr) @@ -330,7 +199,7 @@ int xc_get_pfn_type_batch(xc_interface * domctl.cmd = XEN_DOMCTL_getpageframeinfo3; domctl.domain = (domid_t)dom; domctl.u.getpageframeinfo3.num = num; - xc_set_xen_guest_handle(domctl.u.getpageframeinfo3.array, arr); + set_xen_guest_handle(domctl.u.getpageframeinfo3.array, arr); rc = do_domctl(xch, &domctl); xc_hypercall_bounce_post(xch, arr); return rc; @@ -488,7 +357,7 @@ int xc_machphys_mfn_list(xc_interface *x return -1; } - xc_set_xen_guest_handle(xmml.extent_start, extent_start); + set_xen_guest_handle(xmml.extent_start, extent_start); rc = do_memory_op(xch, XENMEM_machphys_mfn_list, &xmml, sizeof(xmml)); if (rc || xmml.nr_extents != max_extents) rc = -1; @@ -522,7 +391,7 @@ int xc_get_pfn_list(xc_interface *xch, domctl.cmd = XEN_DOMCTL_getmemlist; domctl.domain = (domid_t)domid; domctl.u.getmemlist.max_pfns = max_pfns; - xc_set_xen_guest_handle(domctl.u.getmemlist.buffer, pfn_buf); + set_xen_guest_handle(domctl.u.getmemlist.buffer, pfn_buf); ret = do_domctl(xch, &domctl); @@ -782,22 +651,6 @@ int xc_ffs64(uint64_t x) return l ? xc_ffs32(l) : h ? xc_ffs32(h) + 32 : 0; } -void *xc_memalign(size_t alignment, size_t size) -{ -#if defined(_POSIX_C_SOURCE) && !defined(__sun__) - int ret; - void *ptr; - ret = posix_memalign(&ptr, alignment, size); - if (ret != 0) - return NULL; - return ptr; -#elif defined(__NetBSD__) || defined(__OpenBSD__) - return valloc(size); -#else - return memalign(alignment, size); -#endif -} - /* * Local variables: * mode: C diff -r 42caa87197df -r a4e1a2dbc215 tools/libxc/xc_private.h --- a/tools/libxc/xc_private.h Thu Oct 21 09:37:35 2010 +0100 +++ b/tools/libxc/xc_private.h Thu Oct 21 09:37:35 2010 +0100 @@ -97,14 +97,6 @@ void xc_report_progress_step(xc_interfac #define ERROR(_m, _a...) xc_report_error(xch,XC_INTERNAL_ERROR,_m , ## _a ) #define PERROR(_m, _a...) xc_report_error(xch,XC_INTERNAL_ERROR,_m \ " (%d = %s)", ## _a , errno, safe_strerror(errno)) - -void *xc_memalign(size_t alignment, size_t size); - -int lock_pages(xc_interface *xch, void *addr, size_t len); -void unlock_pages(xc_interface *xch, void *addr, size_t len); - -int hcall_buf_prep(xc_interface *xch, void **addr, size_t len); -void hcall_buf_release(xc_interface *xch, void **addr, size_t len); /* * HYPERCALL ARGUMENT BUFFERS diff -r 42caa87197df -r a4e1a2dbc215 tools/libxc/xc_tbuf.c --- a/tools/libxc/xc_tbuf.c Thu Oct 21 09:37:35 2010 +0100 +++ b/tools/libxc/xc_tbuf.c Thu Oct 21 09:37:35 2010 +0100 @@ -132,7 +132,7 @@ int xc_tbuf_set_cpu_mask(xc_interface *x bitmap_64_to_byte(bytemap, &mask64, sizeof (mask64) * 8); - xc_set_xen_guest_handle(sysctl.u.tbuf_op.cpu_mask.bitmap, bytemap); + set_xen_guest_handle(sysctl.u.tbuf_op.cpu_mask.bitmap, bytemap); sysctl.u.tbuf_op.cpu_mask.nr_cpus = sizeof(bytemap) * 8; ret = do_sysctl(xch, &sysctl); diff -r 42caa87197df -r a4e1a2dbc215 tools/libxc/xc_tmem.c --- a/tools/libxc/xc_tmem.c Thu Oct 21 09:37:35 2010 +0100 +++ b/tools/libxc/xc_tmem.c Thu Oct 21 09:37:35 2010 +0100 @@ -86,7 +86,7 @@ int xc_tmem_control(xc_interface *xch, } } - xc_set_xen_guest_handle(op.u.ctrl.buf, buf); + set_xen_guest_handle(op.u.ctrl.buf, buf); rc = do_tmem_op(xch, &op); @@ -136,7 +136,7 @@ int xc_tmem_control_oid(xc_interface *xc } } - xc_set_xen_guest_handle(op.u.ctrl.buf, buf); + set_xen_guest_handle(op.u.ctrl.buf, buf); rc = do_tmem_op(xch, &op); diff -r 42caa87197df -r a4e1a2dbc215 tools/libxc/xenctrl.h --- a/tools/libxc/xenctrl.h Thu Oct 21 09:37:35 2010 +0100 +++ b/tools/libxc/xenctrl.h Thu Oct 21 09:37:35 2010 +0100 @@ -252,7 +252,8 @@ typedef struct xc_hypercall_buffer xc_hy * Set a xen_guest_handle in a type safe manner, ensuring that the * data pointer has been correctly allocated. */ -#define xc_set_xen_guest_handle(_hnd, _val) \ +#undef set_xen_guest_handle +#define set_xen_guest_handle(_hnd, _val) \ do { \ xc_hypercall_buffer_t _val1; \ typeof(XC__HYPERCALL_BUFFER_NAME(_val)) *_val2 = HYPERCALL_BUFFER(_val); \ @@ -260,7 +261,7 @@ typedef struct xc_hypercall_buffer xc_hy set_xen_guest_handle_raw(_hnd, (_val2)->hbuf); \ } while (0) -/* Use with xc_set_xen_guest_handle in place of NULL */ +/* Use with set_xen_guest_handle in place of NULL */ extern xc_hypercall_buffer_t XC__HYPERCALL_BUFFER_NAME(HYPERCALL_BUFFER_NULL); /* diff -r 42caa87197df -r a4e1a2dbc215 tools/misc/xenpm.c --- a/tools/misc/xenpm.c Thu Oct 21 09:37:35 2010 +0100 +++ b/tools/misc/xenpm.c Thu Oct 21 09:37:35 2010 +0100 @@ -395,9 +395,9 @@ static void signal_int_handler(int signo } } - xc_set_xen_guest_handle(info.cpu_to_core, cpu_to_core); - xc_set_xen_guest_handle(info.cpu_to_socket, cpu_to_socket); - xc_set_xen_guest_handle(info.cpu_to_node, cpu_to_node); + set_xen_guest_handle(info.cpu_to_core, cpu_to_core); + set_xen_guest_handle(info.cpu_to_socket, cpu_to_socket); + set_xen_guest_handle(info.cpu_to_node, cpu_to_node); info.max_cpu_index = MAX_NR_CPU - 1; ret = xc_topologyinfo(xc_handle, &info); @@ -964,9 +964,9 @@ void cpu_topology_func(int argc, char *a goto out; } - xc_set_xen_guest_handle(info.cpu_to_core, cpu_to_core); - xc_set_xen_guest_handle(info.cpu_to_socket, cpu_to_socket); - xc_set_xen_guest_handle(info.cpu_to_node, cpu_to_node); + set_xen_guest_handle(info.cpu_to_core, cpu_to_core); + set_xen_guest_handle(info.cpu_to_socket, cpu_to_socket); + set_xen_guest_handle(info.cpu_to_node, cpu_to_node); info.max_cpu_index = MAX_NR_CPU-1; if ( xc_topologyinfo(xc_handle, &info) ) diff -r 42caa87197df -r a4e1a2dbc215 tools/python/xen/lowlevel/acm/acm.c --- a/tools/python/xen/lowlevel/acm/acm.c Thu Oct 21 09:37:35 2010 +0100 +++ b/tools/python/xen/lowlevel/acm/acm.c Thu Oct 21 09:37:35 2010 +0100 @@ -53,7 +53,7 @@ static void *__getssid(xc_interface *xc_ } memset(buf, 0, SSID_BUFFER_SIZE); - xc_set_xen_guest_handle(getssid.ssidbuf, buffer); + set_xen_guest_handle(getssid.ssidbuf, buffer); getssid.ssidbuf_size = SSID_BUFFER_SIZE; getssid.get_ssid_by = ACM_GETBY_domainid; getssid.id.domainid = domid; @@ -254,10 +254,10 @@ static PyObject *chgpolicy(PyObject *sel chgpolicy.delarray_size = del_arr_len; chgpolicy.chgarray_size = chg_arr_len; chgpolicy.errarray_size = sizeof(*error_array)*errarray_mbrs; - xc_set_xen_guest_handle(chgpolicy.policy_pushcache, bin_pol_buf); - xc_set_xen_guest_handle(chgpolicy.del_array, del_arr_buf); - xc_set_xen_guest_handle(chgpolicy.chg_array, chg_arr_buf); - xc_set_xen_guest_handle(chgpolicy.err_array, error_array); + set_xen_guest_handle(chgpolicy.policy_pushcache, bin_pol_buf); + set_xen_guest_handle(chgpolicy.del_array, del_arr_buf); + set_xen_guest_handle(chgpolicy.chg_array, chg_arr_buf); + set_xen_guest_handle(chgpolicy.err_array, error_array); rc = xc_acm_op(xc_handle, ACMOP_chgpolicy, &chgpolicy, sizeof(chgpolicy)); @@ -299,7 +299,7 @@ static PyObject *getpolicy(PyObject *sel goto out; memset(&getpolicy, 0x0, sizeof(getpolicy)); - xc_set_xen_guest_handle(getpolicy.pullcache, pull_buffer); + set_xen_guest_handle(getpolicy.pullcache, pull_buffer); getpolicy.pullcache_size = sizeof(pull_buffer); rc = xc_acm_op(xc_handle, ACMOP_getpolicy, &getpolicy, sizeof(getpolicy)); @@ -356,8 +356,8 @@ static PyObject *relabel_domains(PyObjec reldoms.relabel_map_size = rel_rules_len; reldoms.errarray_size = sizeof(error_array); - xc_set_xen_guest_handle(reldoms.relabel_map, relabel_rules_buf); - xc_set_xen_guest_handle(reldoms.err_array, error_array); + set_xen_guest_handle(reldoms.relabel_map, relabel_rules_buf); + set_xen_guest_handle(reldoms.err_array, error_array); rc = xc_acm_op(xc_handle, ACMOP_relabeldoms, &reldoms, sizeof(reldoms)); diff -r 42caa87197df -r a4e1a2dbc215 tools/python/xen/lowlevel/xc/xc.c --- a/tools/python/xen/lowlevel/xc/xc.c Thu Oct 21 09:37:35 2010 +0100 +++ b/tools/python/xen/lowlevel/xc/xc.c Thu Oct 21 09:37:35 2010 +0100 @@ -1222,9 +1222,9 @@ static PyObject *pyxc_topologyinfo(XcObj if ( nodemap == NULL ) goto out; - xc_set_xen_guest_handle(tinfo.cpu_to_core, coremap); - xc_set_xen_guest_handle(tinfo.cpu_to_socket, socketmap); - xc_set_xen_guest_handle(tinfo.cpu_to_node, nodemap); + set_xen_guest_handle(tinfo.cpu_to_core, coremap); + set_xen_guest_handle(tinfo.cpu_to_socket, socketmap); + set_xen_guest_handle(tinfo.cpu_to_node, nodemap); tinfo.max_cpu_index = MAX_CPU_INDEX; if ( xc_topologyinfo(self->xc_handle, &tinfo) != 0 ) @@ -1316,9 +1316,9 @@ static PyObject *pyxc_numainfo(XcObject if ( nodes_dist == NULL ) goto out; - xc_set_xen_guest_handle(ninfo.node_to_memsize, node_memsize); - xc_set_xen_guest_handle(ninfo.node_to_memfree, node_memfree); - xc_set_xen_guest_handle(ninfo.node_to_node_distance, nodes_dist); + set_xen_guest_handle(ninfo.node_to_memsize, node_memsize); + set_xen_guest_handle(ninfo.node_to_memfree, node_memfree); + set_xen_guest_handle(ninfo.node_to_node_distance, nodes_dist); ninfo.max_node_index = MAX_NODE_INDEX; if ( xc_numainfo(self->xc_handle, &ninfo) != 0 ) diff -r 42caa87197df -r a4e1a2dbc215 tools/security/secpol_tool.c --- a/tools/security/secpol_tool.c Thu Oct 21 09:37:35 2010 +0100 +++ b/tools/security/secpol_tool.c Thu Oct 21 09:37:35 2010 +0100 @@ -248,7 +248,7 @@ int acm_get_ssidref(xc_interface *xc_han ssid = xc_hypercall_buffer_alloc(xc_handle, ssid, ssid_buffer_size); if ( ssid == NULL ) return 1; - xc_set_xen_guest_handle(getssid.ssidbuf, ssid); + set_xen_guest_handle(getssid.ssidbuf, ssid); getssid.ssidbuf_size = ssid_buffer_size; getssid.get_ssid_by = ACM_GETBY_domainid; getssid.id.domainid = domid; @@ -276,7 +276,7 @@ int acm_domain_getpolicy(xc_interface *x return -1; memset(pull_buffer, 0x00, pull_cache_size); - xc_set_xen_guest_handle(getpolicy.pullcache, pull_buffer); + set_xen_guest_handle(getpolicy.pullcache, pull_buffer); getpolicy.pullcache_size = pull_cache_size; ret = xc_acm_op(xc_handle, ACMOP_getpolicy, &getpolicy, sizeof(getpolicy)); if (ret >= 0) { @@ -389,7 +389,7 @@ int acm_domain_loadpolicy(xc_interface * /* dump it and then push it down into xen/acm */ acm_dump_policy_buffer(buffer, len, chwall_ssidref, ste_ssidref); - xc_set_xen_guest_handle(setpolicy.pushcache, buffer); + set_xen_guest_handle(setpolicy.pushcache, buffer); setpolicy.pushcache_size = len; ret = xc_acm_op(xc_handle, ACMOP_setpolicy, &setpolicy, sizeof(setpolicy)); @@ -437,7 +437,7 @@ int acm_domain_dumpstats(xc_interface *x return -1; memset(stats_buffer, 0x00, pull_stats_size); - xc_set_xen_guest_handle(dumpstats.pullcache, stats_buffer); + set_xen_guest_handle(dumpstats.pullcache, stats_buffer); dumpstats.pullcache_size = pull_stats_size; ret = xc_acm_op(xc_handle, ACMOP_dumpstats, &dumpstats, sizeof(dumpstats)); _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |