All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 00/31] tools: move most libraries into tools/libs
@ 2020-08-28 15:07 Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 01/31] tools: generate pkg-config files from make variables Juergen Gross
                   ` (30 more replies)
  0 siblings, 31 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel, xen-devel
  Cc: Juergen Gross, Ian Jackson, Wei Liu, Samuel Thibault,
	Anthony PERARD, Marek Marczykowski-Górecki, Andrew Cooper,
	George Dunlap, Jan Beulich, Julien Grall, Stefano Stabellini,
	Josh Whitehead, Stewart Hildebrand, Christian Lindig,
	David Scott, Shriram Rajagopalan, Yang Hongyang

Move most remaining libraries under tools/libs, including libxenctrl
and libxl. This is resulting in a lot of cleanup work regarding
building libs and restructuring of the tools directory.

After this huge cleanup all dependencies between libraries are defined
in a single rather small file tools/libs/uselibs.mk, which is used to
create the needed make variables and to control the stubdom build
dependencies as well.

Another bonus of the rework is the automation of setting the versions
of unstable libraries. This removes the need to bump those versions
manually for each Xen release.

libfsimage is not moved by this series, as IMO there are some open
questions:
- should it really be unstable?
- is the support of adding external fs-support used in practice, i.e.
  shouldn't the fs-specific sub-libraries be just included into
  libfsimage instead of being loaded dynamically?

The complete series is available via:

git://xenbits.xen.org/people/jgross/xen.git libbuild-v4

Changes in V4:
- removed already applied patches (1-8, 10)
- added new patches 1, 29
- replaced (old) patch 37 with new patch 30
- especially fixed qemu build and parallel make
- rebased to current staging

Changes in V3:
- more cleanup added
- added moving libxenguest, libxl and libxlutil
- split out dependencies into uselibs.mk
- use uselibs.mk for stubdoms build

Juergen Gross (31):
  tools: generate pkg-config files from make variables
  tools: drop explicit path specifications for qemu build
  tools/python: drop libxenguest from setup.py
  tools: fix pkg-config file for libxenguest
  tools: don't assume libxenguest and libxenctrl to be in same directory
  tools/misc: don't use libxenctrl internals from xen-hptool
  tools/misc: don't include xg_save_restore.h from xen-mfndump.c
  tools/misc: replace PAGE_SIZE with XC_PAGE_SIZE in xen-mfndump.c
  tools/misc: drop all libxc internals from xen-mfndump.c
  tools/libxc: remove unused headers xc_efi.h and xc_elf.h
  tools/libxc: move xc_[un]map_domain_meminfo() into new source
    xg_domain.c
  tools/libxc: rename all libxenguest sources to xg_*
  tools/libxc: rename libxenguest internal headers
  tools/misc: rename xc_dom.h do xenctrl_dom.h
  tools/libxc: untangle libxenctrl from libxenguest
  tools/xcutils: use official headers in readnotes
  tools/xenpaging: remove libxc internals
  tools: move libxenctrl below tools/libs
  tools/libxc: move libxenguest to tools/libs/guest
  tools: split libxenstore into new tools/libs/store directory
  tools: split libxenvchan into new tools/libs/vchan directory
  tools: split libxenstat into new tools/libs/stat directory
  tools/libxl: fix dependencies of libxl tests
  tools/libxl: don't include libxl_osdeps.h from libxlutil sources
  tools/libxl: add missing items to clean target
  tools/libxl: move xl parsing checks to tools/xl
  tools/xl: don't assume libxl and libxlutil are in one directory
  tools/libxl: move libxenlight to tools/libs/light
  tools: rename global libxlutil make variables
  tools/libs: add option for library names not starting with libxen
  tools: move libxlutil to tools/libs/util

 .gitignore                                    |  74 ++--
 MAINTAINERS                                   |   2 +-
 stubdom/Makefile                              |  36 +-
 stubdom/grub/Makefile                         |   4 +-
 stubdom/grub/kexec.c                          |   2 +-
 stubdom/mini-os.mk                            |   6 +-
 tools/Makefile                                |  34 +-
 tools/Rules.mk                                | 102 ++---
 tools/configure                               |   2 +-
 tools/configure.ac                            |   2 +-
 tools/helpers/init-xenstore-domain.c          |   2 +-
 tools/libs/Makefile                           |   7 +
 tools/libs/call/xencall.pc.in                 |  10 -
 tools/libs/ctrl/Makefile                      |  72 ++++
 tools/{libxc => libs/ctrl}/include/xenctrl.h  |   0
 .../ctrl}/include/xenctrl_compat.h            |   0
 .../ctrl/include/xenctrl_dom.h}               |  10 +-
 tools/{libxc => libs/ctrl}/xc_altp2m.c        |   0
 tools/{libxc => libs/ctrl}/xc_arinc653.c      |   0
 tools/{libxc => libs/ctrl}/xc_bitops.h        |   0
 tools/{libxc => libs/ctrl}/xc_core.c          |   5 +-
 tools/{libxc => libs/ctrl}/xc_core.h          |   2 +-
 tools/{libxc => libs/ctrl}/xc_core_arm.c      |   2 +-
 tools/{libxc => libs/ctrl}/xc_core_arm.h      |   0
 tools/{libxc => libs/ctrl}/xc_core_x86.c      |   6 +-
 tools/{libxc => libs/ctrl}/xc_core_x86.h      |   0
 tools/{libxc => libs/ctrl}/xc_cpu_hotplug.c   |   0
 tools/{libxc => libs/ctrl}/xc_cpupool.c       |   0
 tools/{libxc => libs/ctrl}/xc_csched.c        |   0
 tools/{libxc => libs/ctrl}/xc_csched2.c       |   0
 .../ctrl}/xc_devicemodel_compat.c             |   0
 tools/{libxc => libs/ctrl}/xc_domain.c        | 129 +-----
 tools/{libxc => libs/ctrl}/xc_evtchn.c        |   0
 tools/{libxc => libs/ctrl}/xc_evtchn_compat.c |   0
 tools/{libxc => libs/ctrl}/xc_flask.c         |   0
 .../{libxc => libs/ctrl}/xc_foreign_memory.c  |   0
 tools/{libxc => libs/ctrl}/xc_freebsd.c       |   0
 tools/{libxc => libs/ctrl}/xc_gnttab.c        |   0
 tools/{libxc => libs/ctrl}/xc_gnttab_compat.c |   0
 tools/{libxc => libs/ctrl}/xc_hcall_buf.c     |   1 -
 tools/{libxc => libs/ctrl}/xc_kexec.c         |   0
 tools/{libxc => libs/ctrl}/xc_linux.c         |   0
 tools/{libxc => libs/ctrl}/xc_mem_access.c    |   0
 tools/{libxc => libs/ctrl}/xc_mem_paging.c    |   0
 tools/{libxc => libs/ctrl}/xc_memshr.c        |   0
 tools/{libxc => libs/ctrl}/xc_minios.c        |   0
 tools/{libxc => libs/ctrl}/xc_misc.c          |   0
 tools/{libxc => libs/ctrl}/xc_monitor.c       |   0
 tools/{libxc => libs/ctrl}/xc_msr_x86.h       |   0
 tools/{libxc => libs/ctrl}/xc_netbsd.c        |   0
 tools/{libxc => libs/ctrl}/xc_pagetab.c       |   0
 tools/{libxc => libs/ctrl}/xc_physdev.c       |   0
 tools/{libxc => libs/ctrl}/xc_pm.c            |   0
 tools/{libxc => libs/ctrl}/xc_private.c       |   3 +-
 tools/{libxc => libs/ctrl}/xc_private.h       |  36 ++
 tools/{libxc => libs/ctrl}/xc_psr.c           |   0
 tools/{libxc => libs/ctrl}/xc_resource.c      |   0
 tools/{libxc => libs/ctrl}/xc_resume.c        |   2 -
 tools/{libxc => libs/ctrl}/xc_rt.c            |   0
 tools/{libxc => libs/ctrl}/xc_solaris.c       |   0
 tools/{libxc => libs/ctrl}/xc_tbuf.c          |   0
 tools/{libxc => libs/ctrl}/xc_vm_event.c      |   0
 tools/libs/devicemodel/xendevicemodel.pc.in   |  10 -
 tools/libs/evtchn/xenevtchn.pc.in             |  10 -
 .../libs/foreignmemory/xenforeignmemory.pc.in |  10 -
 tools/libs/gnttab/xengnttab.pc.in             |  10 -
 tools/{libxc => libs/guest}/COPYING           |   0
 tools/libs/guest/Makefile                     | 121 ++++++
 .../{libxc => libs/guest}/include/xenguest.h  |   8 +-
 .../guest/xg_cpuid_x86.c}                     |   0
 .../xc_dom_arm.c => libs/guest/xg_dom_arm.c}  |   2 +-
 .../guest/xg_dom_armzimageloader.c}           |   2 +-
 .../guest/xg_dom_binloader.c}                 |   2 +-
 .../guest/xg_dom_boot.c}                      |   2 +-
 .../guest/xg_dom_bzimageloader.c}             |   2 +-
 .../guest/xg_dom_compat_linux.c}              |   2 +-
 .../guest/xg_dom_core.c}                      |   2 +-
 .../guest/xg_dom_decompress.h}                |   4 +-
 .../guest/xg_dom_decompress_lz4.c}            |   2 +-
 .../guest/xg_dom_decompress_unsafe.c}         |   2 +-
 .../guest/xg_dom_decompress_unsafe.h}         |   2 +-
 .../guest/xg_dom_decompress_unsafe_bzip2.c}   |   2 +-
 .../guest/xg_dom_decompress_unsafe_lzma.c}    |   2 +-
 .../guest/xg_dom_decompress_unsafe_lzo1x.c}   |   2 +-
 .../guest/xg_dom_decompress_unsafe_xz.c}      |   2 +-
 .../guest/xg_dom_elfloader.c}                 |   2 +-
 .../guest/xg_dom_hvmloader.c}                 |   2 +-
 .../xc_dom_x86.c => libs/guest/xg_dom_x86.c}  |   2 +-
 tools/libs/guest/xg_domain.c                  | 149 +++++++
 .../guest/xg_nomigrate.c}                     |   0
 .../guest/xg_offline_page.c}                  |   2 +-
 tools/{libxc => libs/guest}/xg_private.c      |   0
 tools/{libxc => libs/guest}/xg_private.h      |  22 -
 tools/{libxc => libs/guest}/xg_save_restore.h |  13 -
 .../guest/xg_sr_common.c}                     |   2 +-
 .../guest/xg_sr_common.h}                     |   4 +-
 .../guest/xg_sr_common_x86.c}                 |   2 +-
 .../guest/xg_sr_common_x86.h}                 |   2 +-
 .../guest/xg_sr_common_x86_pv.c}              |   2 +-
 .../guest/xg_sr_common_x86_pv.h}              |   2 +-
 .../guest/xg_sr_restore.c}                    |   2 +-
 .../guest/xg_sr_restore_x86_hvm.c}            |   2 +-
 .../guest/xg_sr_restore_x86_pv.c}             |   2 +-
 .../xc_sr_save.c => libs/guest/xg_sr_save.c}  |   2 +-
 .../guest/xg_sr_save_x86_hvm.c}               |   2 +-
 .../guest/xg_sr_save_x86_pv.c}                |   2 +-
 .../guest/xg_sr_stream_format.h}              |   0
 .../xc_suspend.c => libs/guest/xg_suspend.c}  |   0
 tools/libs/hypfs/xenhypfs.pc.in               |  10 -
 tools/libs/libs.mk                            |  47 ++-
 tools/{libxl => libs/light}/CODING_STYLE      |   0
 tools/libs/light/Makefile                     | 291 ++++++++++++++
 .../light}/check-libxl-api-rules              |   0
 tools/{libxl => libs/light}/flexarray.c       |   0
 tools/{libxl => libs/light}/flexarray.h       |   0
 tools/{libxl => libs/light}/gentest.py        |   0
 tools/{libxl => libs/light}/gentypes.py       |   0
 tools/{libxl => libs/light}/idl.py            |   0
 tools/{libxl => libs/light}/idl.txt           |   0
 tools/{libxl => libs/light/include}/libxl.h   |   0
 .../light/include}/libxl_event.h              |   0
 .../light/include}/libxl_json.h               |   0
 .../light/include}/libxl_utils.h              |   0
 .../light/include}/libxl_uuid.h               |   0
 tools/{libxl => libs/light}/libxl.c           |   0
 tools/{libxl => libs/light}/libxl_9pfs.c      |   0
 tools/{libxl => libs/light}/libxl_aoutils.c   |   0
 tools/{libxl => libs/light}/libxl_arch.h      |   0
 tools/{libxl => libs/light}/libxl_arm.c       |   2 +-
 tools/{libxl => libs/light}/libxl_arm.h       |   2 +-
 tools/{libxl => libs/light}/libxl_arm_acpi.c  |   0
 .../{libxl => libs/light}/libxl_arm_no_acpi.c |   0
 .../{libxl => libs/light}/libxl_bootloader.c  |   0
 .../light}/libxl_checkpoint_device.c          |   0
 tools/{libxl => libs/light}/libxl_colo.h      |   0
 tools/{libxl => libs/light}/libxl_colo_nic.c  |   0
 .../{libxl => libs/light}/libxl_colo_proxy.c  |   0
 .../{libxl => libs/light}/libxl_colo_qdisk.c  |   0
 .../light}/libxl_colo_restore.c               |   0
 tools/{libxl => libs/light}/libxl_colo_save.c |   0
 tools/{libxl => libs/light}/libxl_console.c   |   0
 .../light}/libxl_convert_callout.c            |   0
 tools/{libxl => libs/light}/libxl_cpuid.c     |   0
 tools/{libxl => libs/light}/libxl_cpupool.c   |   0
 tools/{libxl => libs/light}/libxl_create.c    |   2 +-
 tools/{libxl => libs/light}/libxl_device.c    |   0
 tools/{libxl => libs/light}/libxl_disk.c      |   0
 tools/{libxl => libs/light}/libxl_dm.c        |   2 +-
 tools/{libxl => libs/light}/libxl_dom.c       |   2 +-
 tools/{libxl => libs/light}/libxl_dom_save.c  |   0
 .../{libxl => libs/light}/libxl_dom_suspend.c |   0
 tools/{libxl => libs/light}/libxl_domain.c    |   0
 tools/{libxl => libs/light}/libxl_event.c     |   0
 tools/{libxl => libs/light}/libxl_exec.c      |   0
 tools/{libxl => libs/light}/libxl_flask.c     |   0
 tools/{libxl => libs/light}/libxl_fork.c      |   0
 tools/{libxl => libs/light}/libxl_freebsd.c   |   0
 tools/{libxl => libs/light}/libxl_genid.c     |   0
 tools/{libxl => libs/light}/libxl_internal.c  |   0
 tools/{libxl => libs/light}/libxl_internal.h  |   2 +-
 tools/{libxl => libs/light}/libxl_json.c      |   0
 .../light}/libxl_libfdt_compat.c              |   0
 .../light}/libxl_libfdt_compat.h              |   0
 tools/{libxl => libs/light}/libxl_linux.c     |   0
 tools/{libxl => libs/light}/libxl_mem.c       |   0
 tools/{libxl => libs/light}/libxl_netbsd.c    |   0
 tools/{libxl => libs/light}/libxl_netbuffer.c |   0
 tools/{libxl => libs/light}/libxl_nic.c       |   0
 tools/{libxl => libs/light}/libxl_no_colo.c   |   0
 .../light}/libxl_no_convert_callout.c         |   0
 tools/{libxl => libs/light}/libxl_nocpuid.c   |   0
 .../{libxl => libs/light}/libxl_nonetbuffer.c |   0
 tools/{libxl => libs/light}/libxl_numa.c      |   0
 tools/{libxl => libs/light}/libxl_osdeps.h    |   0
 tools/{libxl => libs/light}/libxl_paths.c     |   0
 tools/{libxl => libs/light}/libxl_pci.c       |   0
 tools/{libxl => libs/light}/libxl_psr.c       |   0
 tools/{libxl => libs/light}/libxl_pvcalls.c   |   0
 tools/{libxl => libs/light}/libxl_qmp.c       |   0
 tools/{libxl => libs/light}/libxl_remus.c     |   0
 .../light}/libxl_remus_disk_drbd.c            |   0
 .../light}/libxl_save_callout.c               |   0
 .../{libxl => libs/light}/libxl_save_helper.c |   0
 .../light}/libxl_save_msgs_gen.pl             |   0
 tools/{libxl => libs/light}/libxl_sched.c     |   0
 .../light}/libxl_sr_stream_format.h           |   0
 .../{libxl => libs/light}/libxl_stream_read.c |   0
 .../light}/libxl_stream_write.c               |   0
 .../light}/libxl_test_fdevent.c               |   0
 .../light}/libxl_test_fdevent.h               |   0
 .../light}/libxl_test_timedereg.c             |   0
 .../light}/libxl_test_timedereg.h             |   0
 tools/{libxl => libs/light}/libxl_tmem.c      |   0
 tools/{libxl => libs/light}/libxl_types.idl   |   0
 .../light}/libxl_types_internal.idl           |   0
 tools/{libxl => libs/light}/libxl_usb.c       |   0
 tools/{libxl => libs/light}/libxl_utils.c     |   0
 tools/{libxl => libs/light}/libxl_uuid.c      |   0
 tools/{libxl => libs/light}/libxl_vdispl.c    |   0
 tools/{libxl => libs/light}/libxl_vkb.c       |   0
 tools/{libxl => libs/light}/libxl_vnuma.c     |   2 +-
 tools/{libxl => libs/light}/libxl_vsnd.c      |   0
 tools/{libxl => libs/light}/libxl_vtpm.c      |   0
 tools/{libxl => libs/light}/libxl_x86.c       |   2 +-
 tools/{libxl => libs/light}/libxl_x86_acpi.c  |   2 +-
 tools/{libxl => libs/light}/libxl_x86_acpi.h  |   0
 tools/{libxl => libs/light}/libxl_xshelp.c    |   0
 tools/{libxl => libs/light}/osdeps.c          |   0
 tools/{libxl => libs/light}/test_common.c     |   0
 tools/{libxl => libs/light}/test_common.h     |   0
 .../{libxl => libs/light}/test_fdderegrace.c  |   0
 tools/{libxl => libs/light}/test_timedereg.c  |   0
 .../{xenstat/libxenstat => libs/stat}/COPYING |   0
 .../libxenstat => libs/stat}/Makefile         | 100 +----
 .../stat}/bindings/swig/perl/.empty           |   0
 .../stat}/bindings/swig/python/.empty         |   0
 .../stat}/bindings/swig/xenstat.i             |   0
 .../src => libs/stat/include}/xenstat.h       |   3 +
 .../libxenstat/src => libs/stat}/xenstat.c    |   0
 .../src => libs/stat}/xenstat_freebsd.c       |   0
 .../src => libs/stat}/xenstat_linux.c         |   4 +-
 .../src => libs/stat}/xenstat_netbsd.c        |   0
 .../src => libs/stat}/xenstat_priv.h          |   0
 .../src => libs/stat}/xenstat_qmp.c           |   0
 .../src => libs/stat}/xenstat_solaris.c       |   0
 tools/libs/store/Makefile                     |  64 +++
 .../store}/include/compat/xs.h                |   0
 .../store}/include/compat/xs_lib.h            |   0
 .../store}/include/xenstore.h                 |   0
 tools/libs/store/libxenstore.map              |  49 +++
 tools/{xenstore => libs/store}/xs.c           |   0
 tools/libs/toolcore/Makefile                  |   1 +
 tools/libs/toolcore/xentoolcore.pc.in         |   9 -
 tools/libs/toollog/xentoollog.pc.in           |   9 -
 tools/libs/uselibs.mk                         |  15 +
 tools/libs/util/CODING_STYLE                  | 330 +++++++++++++++
 tools/libs/util/Makefile                      |  63 +++
 .../{libxl => libs/util/include}/libxlutil.h  |   0
 tools/{libxl => libs/util}/libxlu_cfg.c       |   3 +-
 tools/{libxl => libs/util}/libxlu_cfg_i.h     |   1 -
 tools/{libxl => libs/util}/libxlu_cfg_l.c     |   0
 tools/{libxl => libs/util}/libxlu_cfg_l.h     |   0
 tools/{libxl => libs/util}/libxlu_cfg_l.l     |   0
 tools/{libxl => libs/util}/libxlu_cfg_y.c     |   0
 tools/{libxl => libs/util}/libxlu_cfg_y.h     |   0
 tools/{libxl => libs/util}/libxlu_cfg_y.y     |   0
 tools/{libxl => libs/util}/libxlu_disk.c      |   1 -
 tools/{libxl => libs/util}/libxlu_disk_i.h    |   0
 tools/{libxl => libs/util}/libxlu_disk_l.c    |  14 +-
 tools/{libxl => libs/util}/libxlu_disk_l.h    |   8 +-
 tools/{libxl => libs/util}/libxlu_disk_l.l    |   2 +-
 tools/{libxl => libs/util}/libxlu_internal.h  |   0
 tools/{libxl => libs/util}/libxlu_pci.c       |   3 +-
 tools/{libxl => libs/util}/libxlu_vif.c       |   3 +-
 tools/libs/vchan/Makefile                     |  20 +
 .../vchan/include}/libxenvchan.h              |   0
 tools/{libvchan => libs/vchan}/init.c         |   0
 tools/{libvchan => libs/vchan}/io.c           |   0
 tools/libvchan/Makefile                       |  95 -----
 tools/libvchan/xenvchan.pc.in                 |  10 -
 tools/libxc/Makefile                          | 280 -------------
 tools/libxc/xc_efi.h                          | 158 --------
 tools/libxc/xc_elf.h                          |  16 -
 tools/libxc/xencontrol.pc.in                  |  10 -
 tools/libxc/xenguest.pc.in                    |  10 -
 tools/libxl/Makefile                          | 375 ------------------
 tools/libxl/xenlight.pc.in                    |  12 -
 tools/libxl/xlutil.pc.in                      |  10 -
 tools/misc/Makefile                           |   5 +-
 tools/misc/xen-hptool.c                       |   8 +-
 tools/misc/xen-mfndump.c                      |  44 +-
 tools/ocaml/libs/xl/Makefile                  |   8 +-
 tools/ocaml/xenstored/Makefile                |   2 +-
 tools/python/Makefile                         |   2 +-
 tools/python/setup.py                         |  12 +-
 tools/python/xen/lowlevel/xc/xc.c             |   2 +-
 tools/vchan/Makefile                          |  37 ++
 tools/{libvchan => vchan}/node-select.c       |   0
 tools/{libvchan => vchan}/node.c              |   0
 .../{libvchan => vchan}/vchan-socket-proxy.c  |   0
 tools/xcutils/Makefile                        |   3 +-
 tools/xcutils/readnotes.c                     |   5 +-
 tools/xenpaging/Makefile                      |   3 +-
 tools/xenpaging/file_ops.c                    |   8 +-
 tools/xenpaging/pagein.c                      |   2 +-
 tools/xenpaging/policy_default.c              |   2 +-
 tools/xenpaging/xenpaging.c                   |  32 +-
 tools/xenpaging/xenpaging.h                   |  70 +++-
 tools/xenstat/Makefile                        |  10 -
 tools/xenstat/libxenstat/xenstat.pc.in        |  10 -
 tools/xenstore/Makefile                       |  82 +---
 tools/xenstore/xenstore.pc.in                 |  11 -
 tools/xenstore/{include => }/xenstore_lib.h   |   0
 tools/{xenstat => }/xentop/Makefile           |   2 +-
 tools/{xenstat => }/xentop/TODO               |   0
 tools/{xenstat => }/xentop/xentop.c           |   0
 tools/xl/Makefile                             |   3 +-
 tools/{libxl => xl}/check-xl-disk-parse       |   0
 tools/{libxl => xl}/check-xl-vcpupin-parse    |   0
 .../check-xl-vcpupin-parse.data-example       |   0
 tools/{libxl => xl}/check-xl-vif-parse        |   0
 301 files changed, 1643 insertions(+), 1734 deletions(-)
 delete mode 100644 tools/libs/call/xencall.pc.in
 create mode 100644 tools/libs/ctrl/Makefile
 rename tools/{libxc => libs/ctrl}/include/xenctrl.h (100%)
 rename tools/{libxc => libs/ctrl}/include/xenctrl_compat.h (100%)
 rename tools/{libxc/include/xc_dom.h => libs/ctrl/include/xenctrl_dom.h} (98%)
 rename tools/{libxc => libs/ctrl}/xc_altp2m.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_arinc653.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_bitops.h (100%)
 rename tools/{libxc => libs/ctrl}/xc_core.c (99%)
 rename tools/{libxc => libs/ctrl}/xc_core.h (99%)
 rename tools/{libxc => libs/ctrl}/xc_core_arm.c (99%)
 rename tools/{libxc => libs/ctrl}/xc_core_arm.h (100%)
 rename tools/{libxc => libs/ctrl}/xc_core_x86.c (98%)
 rename tools/{libxc => libs/ctrl}/xc_core_x86.h (100%)
 rename tools/{libxc => libs/ctrl}/xc_cpu_hotplug.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_cpupool.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_csched.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_csched2.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_devicemodel_compat.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_domain.c (94%)
 rename tools/{libxc => libs/ctrl}/xc_evtchn.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_evtchn_compat.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_flask.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_foreign_memory.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_freebsd.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_gnttab.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_gnttab_compat.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_hcall_buf.c (99%)
 rename tools/{libxc => libs/ctrl}/xc_kexec.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_linux.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_mem_access.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_mem_paging.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_memshr.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_minios.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_misc.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_monitor.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_msr_x86.h (100%)
 rename tools/{libxc => libs/ctrl}/xc_netbsd.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_pagetab.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_physdev.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_pm.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_private.c (99%)
 rename tools/{libxc => libs/ctrl}/xc_private.h (91%)
 rename tools/{libxc => libs/ctrl}/xc_psr.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_resource.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_resume.c (99%)
 rename tools/{libxc => libs/ctrl}/xc_rt.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_solaris.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_tbuf.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_vm_event.c (100%)
 delete mode 100644 tools/libs/devicemodel/xendevicemodel.pc.in
 delete mode 100644 tools/libs/evtchn/xenevtchn.pc.in
 delete mode 100644 tools/libs/foreignmemory/xenforeignmemory.pc.in
 delete mode 100644 tools/libs/gnttab/xengnttab.pc.in
 rename tools/{libxc => libs/guest}/COPYING (100%)
 create mode 100644 tools/libs/guest/Makefile
 rename tools/{libxc => libs/guest}/include/xenguest.h (99%)
 rename tools/{libxc/xc_cpuid_x86.c => libs/guest/xg_cpuid_x86.c} (100%)
 rename tools/{libxc/xc_dom_arm.c => libs/guest/xg_dom_arm.c} (99%)
 rename tools/{libxc/xc_dom_armzimageloader.c => libs/guest/xg_dom_armzimageloader.c} (99%)
 rename tools/{libxc/xc_dom_binloader.c => libs/guest/xg_dom_binloader.c} (99%)
 rename tools/{libxc/xc_dom_boot.c => libs/guest/xg_dom_boot.c} (99%)
 rename tools/{libxc/xc_dom_bzimageloader.c => libs/guest/xg_dom_bzimageloader.c} (99%)
 rename tools/{libxc/xc_dom_compat_linux.c => libs/guest/xg_dom_compat_linux.c} (99%)
 rename tools/{libxc/xc_dom_core.c => libs/guest/xg_dom_core.c} (99%)
 rename tools/{libxc/xc_dom_decompress.h => libs/guest/xg_dom_decompress.h} (62%)
 rename tools/{libxc/xc_dom_decompress_lz4.c => libs/guest/xg_dom_decompress_lz4.c} (98%)
 rename tools/{libxc/xc_dom_decompress_unsafe.c => libs/guest/xg_dom_decompress_unsafe.c} (96%)
 rename tools/{libxc/xc_dom_decompress_unsafe.h => libs/guest/xg_dom_decompress_unsafe.h} (97%)
 rename tools/{libxc/xc_dom_decompress_unsafe_bzip2.c => libs/guest/xg_dom_decompress_unsafe_bzip2.c} (87%)
 rename tools/{libxc/xc_dom_decompress_unsafe_lzma.c => libs/guest/xg_dom_decompress_unsafe_lzma.c} (87%)
 rename tools/{libxc/xc_dom_decompress_unsafe_lzo1x.c => libs/guest/xg_dom_decompress_unsafe_lzo1x.c} (96%)
 rename tools/{libxc/xc_dom_decompress_unsafe_xz.c => libs/guest/xg_dom_decompress_unsafe_xz.c} (95%)
 rename tools/{libxc/xc_dom_elfloader.c => libs/guest/xg_dom_elfloader.c} (99%)
 rename tools/{libxc/xc_dom_hvmloader.c => libs/guest/xg_dom_hvmloader.c} (99%)
 rename tools/{libxc/xc_dom_x86.c => libs/guest/xg_dom_x86.c} (99%)
 create mode 100644 tools/libs/guest/xg_domain.c
 rename tools/{libxc/xc_nomigrate.c => libs/guest/xg_nomigrate.c} (100%)
 rename tools/{libxc/xc_offline_page.c => libs/guest/xg_offline_page.c} (99%)
 rename tools/{libxc => libs/guest}/xg_private.c (100%)
 rename tools/{libxc => libs/guest}/xg_private.h (81%)
 rename tools/{libxc => libs/guest}/xg_save_restore.h (91%)
 rename tools/{libxc/xc_sr_common.c => libs/guest/xg_sr_common.c} (99%)
 rename tools/{libxc/xc_sr_common.h => libs/guest/xg_sr_common.h} (99%)
 rename tools/{libxc/xc_sr_common_x86.c => libs/guest/xg_sr_common_x86.c} (99%)
 rename tools/{libxc/xc_sr_common_x86.h => libs/guest/xg_sr_common_x86.h} (98%)
 rename tools/{libxc/xc_sr_common_x86_pv.c => libs/guest/xg_sr_common_x86_pv.c} (99%)
 rename tools/{libxc/xc_sr_common_x86_pv.h => libs/guest/xg_sr_common_x86_pv.h} (98%)
 rename tools/{libxc/xc_sr_restore.c => libs/guest/xg_sr_restore.c} (99%)
 rename tools/{libxc/xc_sr_restore_x86_hvm.c => libs/guest/xg_sr_restore_x86_hvm.c} (99%)
 rename tools/{libxc/xc_sr_restore_x86_pv.c => libs/guest/xg_sr_restore_x86_pv.c} (99%)
 rename tools/{libxc/xc_sr_save.c => libs/guest/xg_sr_save.c} (99%)
 rename tools/{libxc/xc_sr_save_x86_hvm.c => libs/guest/xg_sr_save_x86_hvm.c} (99%)
 rename tools/{libxc/xc_sr_save_x86_pv.c => libs/guest/xg_sr_save_x86_pv.c} (99%)
 rename tools/{libxc/xc_sr_stream_format.h => libs/guest/xg_sr_stream_format.h} (100%)
 rename tools/{libxc/xc_suspend.c => libs/guest/xg_suspend.c} (100%)
 delete mode 100644 tools/libs/hypfs/xenhypfs.pc.in
 rename tools/{libxl => libs/light}/CODING_STYLE (100%)
 create mode 100644 tools/libs/light/Makefile
 rename tools/{libxl => libs/light}/check-libxl-api-rules (100%)
 rename tools/{libxl => libs/light}/flexarray.c (100%)
 rename tools/{libxl => libs/light}/flexarray.h (100%)
 rename tools/{libxl => libs/light}/gentest.py (100%)
 rename tools/{libxl => libs/light}/gentypes.py (100%)
 rename tools/{libxl => libs/light}/idl.py (100%)
 rename tools/{libxl => libs/light}/idl.txt (100%)
 rename tools/{libxl => libs/light/include}/libxl.h (100%)
 rename tools/{libxl => libs/light/include}/libxl_event.h (100%)
 rename tools/{libxl => libs/light/include}/libxl_json.h (100%)
 rename tools/{libxl => libs/light/include}/libxl_utils.h (100%)
 rename tools/{libxl => libs/light/include}/libxl_uuid.h (100%)
 rename tools/{libxl => libs/light}/libxl.c (100%)
 rename tools/{libxl => libs/light}/libxl_9pfs.c (100%)
 rename tools/{libxl => libs/light}/libxl_aoutils.c (100%)
 rename tools/{libxl => libs/light}/libxl_arch.h (100%)
 rename tools/{libxl => libs/light}/libxl_arm.c (99%)
 rename tools/{libxl => libs/light}/libxl_arm.h (98%)
 rename tools/{libxl => libs/light}/libxl_arm_acpi.c (100%)
 rename tools/{libxl => libs/light}/libxl_arm_no_acpi.c (100%)
 rename tools/{libxl => libs/light}/libxl_bootloader.c (100%)
 rename tools/{libxl => libs/light}/libxl_checkpoint_device.c (100%)
 rename tools/{libxl => libs/light}/libxl_colo.h (100%)
 rename tools/{libxl => libs/light}/libxl_colo_nic.c (100%)
 rename tools/{libxl => libs/light}/libxl_colo_proxy.c (100%)
 rename tools/{libxl => libs/light}/libxl_colo_qdisk.c (100%)
 rename tools/{libxl => libs/light}/libxl_colo_restore.c (100%)
 rename tools/{libxl => libs/light}/libxl_colo_save.c (100%)
 rename tools/{libxl => libs/light}/libxl_console.c (100%)
 rename tools/{libxl => libs/light}/libxl_convert_callout.c (100%)
 rename tools/{libxl => libs/light}/libxl_cpuid.c (100%)
 rename tools/{libxl => libs/light}/libxl_cpupool.c (100%)
 rename tools/{libxl => libs/light}/libxl_create.c (99%)
 rename tools/{libxl => libs/light}/libxl_device.c (100%)
 rename tools/{libxl => libs/light}/libxl_disk.c (100%)
 rename tools/{libxl => libs/light}/libxl_dm.c (99%)
 rename tools/{libxl => libs/light}/libxl_dom.c (99%)
 rename tools/{libxl => libs/light}/libxl_dom_save.c (100%)
 rename tools/{libxl => libs/light}/libxl_dom_suspend.c (100%)
 rename tools/{libxl => libs/light}/libxl_domain.c (100%)
 rename tools/{libxl => libs/light}/libxl_event.c (100%)
 rename tools/{libxl => libs/light}/libxl_exec.c (100%)
 rename tools/{libxl => libs/light}/libxl_flask.c (100%)
 rename tools/{libxl => libs/light}/libxl_fork.c (100%)
 rename tools/{libxl => libs/light}/libxl_freebsd.c (100%)
 rename tools/{libxl => libs/light}/libxl_genid.c (100%)
 rename tools/{libxl => libs/light}/libxl_internal.c (100%)
 rename tools/{libxl => libs/light}/libxl_internal.h (99%)
 rename tools/{libxl => libs/light}/libxl_json.c (100%)
 rename tools/{libxl => libs/light}/libxl_libfdt_compat.c (100%)
 rename tools/{libxl => libs/light}/libxl_libfdt_compat.h (100%)
 rename tools/{libxl => libs/light}/libxl_linux.c (100%)
 rename tools/{libxl => libs/light}/libxl_mem.c (100%)
 rename tools/{libxl => libs/light}/libxl_netbsd.c (100%)
 rename tools/{libxl => libs/light}/libxl_netbuffer.c (100%)
 rename tools/{libxl => libs/light}/libxl_nic.c (100%)
 rename tools/{libxl => libs/light}/libxl_no_colo.c (100%)
 rename tools/{libxl => libs/light}/libxl_no_convert_callout.c (100%)
 rename tools/{libxl => libs/light}/libxl_nocpuid.c (100%)
 rename tools/{libxl => libs/light}/libxl_nonetbuffer.c (100%)
 rename tools/{libxl => libs/light}/libxl_numa.c (100%)
 rename tools/{libxl => libs/light}/libxl_osdeps.h (100%)
 rename tools/{libxl => libs/light}/libxl_paths.c (100%)
 rename tools/{libxl => libs/light}/libxl_pci.c (100%)
 rename tools/{libxl => libs/light}/libxl_psr.c (100%)
 rename tools/{libxl => libs/light}/libxl_pvcalls.c (100%)
 rename tools/{libxl => libs/light}/libxl_qmp.c (100%)
 rename tools/{libxl => libs/light}/libxl_remus.c (100%)
 rename tools/{libxl => libs/light}/libxl_remus_disk_drbd.c (100%)
 rename tools/{libxl => libs/light}/libxl_save_callout.c (100%)
 rename tools/{libxl => libs/light}/libxl_save_helper.c (100%)
 rename tools/{libxl => libs/light}/libxl_save_msgs_gen.pl (100%)
 rename tools/{libxl => libs/light}/libxl_sched.c (100%)
 rename tools/{libxl => libs/light}/libxl_sr_stream_format.h (100%)
 rename tools/{libxl => libs/light}/libxl_stream_read.c (100%)
 rename tools/{libxl => libs/light}/libxl_stream_write.c (100%)
 rename tools/{libxl => libs/light}/libxl_test_fdevent.c (100%)
 rename tools/{libxl => libs/light}/libxl_test_fdevent.h (100%)
 rename tools/{libxl => libs/light}/libxl_test_timedereg.c (100%)
 rename tools/{libxl => libs/light}/libxl_test_timedereg.h (100%)
 rename tools/{libxl => libs/light}/libxl_tmem.c (100%)
 rename tools/{libxl => libs/light}/libxl_types.idl (100%)
 rename tools/{libxl => libs/light}/libxl_types_internal.idl (100%)
 rename tools/{libxl => libs/light}/libxl_usb.c (100%)
 rename tools/{libxl => libs/light}/libxl_utils.c (100%)
 rename tools/{libxl => libs/light}/libxl_uuid.c (100%)
 rename tools/{libxl => libs/light}/libxl_vdispl.c (100%)
 rename tools/{libxl => libs/light}/libxl_vkb.c (100%)
 rename tools/{libxl => libs/light}/libxl_vnuma.c (99%)
 rename tools/{libxl => libs/light}/libxl_vsnd.c (100%)
 rename tools/{libxl => libs/light}/libxl_vtpm.c (100%)
 rename tools/{libxl => libs/light}/libxl_x86.c (99%)
 rename tools/{libxl => libs/light}/libxl_x86_acpi.c (99%)
 rename tools/{libxl => libs/light}/libxl_x86_acpi.h (100%)
 rename tools/{libxl => libs/light}/libxl_xshelp.c (100%)
 rename tools/{libxl => libs/light}/osdeps.c (100%)
 rename tools/{libxl => libs/light}/test_common.c (100%)
 rename tools/{libxl => libs/light}/test_common.h (100%)
 rename tools/{libxl => libs/light}/test_fdderegrace.c (100%)
 rename tools/{libxl => libs/light}/test_timedereg.c (100%)
 rename tools/{xenstat/libxenstat => libs/stat}/COPYING (100%)
 rename tools/{xenstat/libxenstat => libs/stat}/Makefile (55%)
 rename tools/{xenstat/libxenstat => libs/stat}/bindings/swig/perl/.empty (100%)
 rename tools/{xenstat/libxenstat => libs/stat}/bindings/swig/python/.empty (100%)
 rename tools/{xenstat/libxenstat => libs/stat}/bindings/swig/xenstat.i (100%)
 rename tools/{xenstat/libxenstat/src => libs/stat/include}/xenstat.h (98%)
 rename tools/{xenstat/libxenstat/src => libs/stat}/xenstat.c (100%)
 rename tools/{xenstat/libxenstat/src => libs/stat}/xenstat_freebsd.c (100%)
 rename tools/{xenstat/libxenstat/src => libs/stat}/xenstat_linux.c (98%)
 rename tools/{xenstat/libxenstat/src => libs/stat}/xenstat_netbsd.c (100%)
 rename tools/{xenstat/libxenstat/src => libs/stat}/xenstat_priv.h (100%)
 rename tools/{xenstat/libxenstat/src => libs/stat}/xenstat_qmp.c (100%)
 rename tools/{xenstat/libxenstat/src => libs/stat}/xenstat_solaris.c (100%)
 create mode 100644 tools/libs/store/Makefile
 rename tools/{xenstore => libs/store}/include/compat/xs.h (100%)
 rename tools/{xenstore => libs/store}/include/compat/xs_lib.h (100%)
 rename tools/{xenstore => libs/store}/include/xenstore.h (100%)
 create mode 100644 tools/libs/store/libxenstore.map
 rename tools/{xenstore => libs/store}/xs.c (100%)
 delete mode 100644 tools/libs/toolcore/xentoolcore.pc.in
 delete mode 100644 tools/libs/toollog/xentoollog.pc.in
 create mode 100644 tools/libs/util/CODING_STYLE
 create mode 100644 tools/libs/util/Makefile
 rename tools/{libxl => libs/util/include}/libxlutil.h (100%)
 rename tools/{libxl => libs/util}/libxlu_cfg.c (99%)
 rename tools/{libxl => libs/util}/libxlu_cfg_i.h (96%)
 rename tools/{libxl => libs/util}/libxlu_cfg_l.c (100%)
 rename tools/{libxl => libs/util}/libxlu_cfg_l.h (100%)
 rename tools/{libxl => libs/util}/libxlu_cfg_l.l (100%)
 rename tools/{libxl => libs/util}/libxlu_cfg_y.c (100%)
 rename tools/{libxl => libs/util}/libxlu_cfg_y.h (100%)
 rename tools/{libxl => libs/util}/libxlu_cfg_y.y (100%)
 rename tools/{libxl => libs/util}/libxlu_disk.c (97%)
 rename tools/{libxl => libs/util}/libxlu_disk_i.h (100%)
 rename tools/{libxl => libs/util}/libxlu_disk_l.c (99%)
 rename tools/{libxl => libs/util}/libxlu_disk_l.h (99%)
 rename tools/{libxl => libs/util}/libxlu_disk_l.l (99%)
 rename tools/{libxl => libs/util}/libxlu_internal.h (100%)
 rename tools/{libxl => libs/util}/libxlu_pci.c (99%)
 rename tools/{libxl => libs/util}/libxlu_vif.c (98%)
 create mode 100644 tools/libs/vchan/Makefile
 rename tools/{libvchan => libs/vchan/include}/libxenvchan.h (100%)
 rename tools/{libvchan => libs/vchan}/init.c (100%)
 rename tools/{libvchan => libs/vchan}/io.c (100%)
 delete mode 100644 tools/libvchan/Makefile
 delete mode 100644 tools/libvchan/xenvchan.pc.in
 delete mode 100644 tools/libxc/Makefile
 delete mode 100644 tools/libxc/xc_efi.h
 delete mode 100644 tools/libxc/xc_elf.h
 delete mode 100644 tools/libxc/xencontrol.pc.in
 delete mode 100644 tools/libxc/xenguest.pc.in
 delete mode 100644 tools/libxl/Makefile
 delete mode 100644 tools/libxl/xenlight.pc.in
 delete mode 100644 tools/libxl/xlutil.pc.in
 create mode 100644 tools/vchan/Makefile
 rename tools/{libvchan => vchan}/node-select.c (100%)
 rename tools/{libvchan => vchan}/node.c (100%)
 rename tools/{libvchan => vchan}/vchan-socket-proxy.c (100%)
 delete mode 100644 tools/xenstat/Makefile
 delete mode 100644 tools/xenstat/libxenstat/xenstat.pc.in
 delete mode 100644 tools/xenstore/xenstore.pc.in
 rename tools/xenstore/{include => }/xenstore_lib.h (100%)
 rename tools/{xenstat => }/xentop/Makefile (97%)
 rename tools/{xenstat => }/xentop/TODO (100%)
 rename tools/{xenstat => }/xentop/xentop.c (100%)
 rename tools/{libxl => xl}/check-xl-disk-parse (100%)
 rename tools/{libxl => xl}/check-xl-vcpupin-parse (100%)
 rename tools/{libxl => xl}/check-xl-vcpupin-parse.data-example (100%)
 rename tools/{libxl => xl}/check-xl-vif-parse (100%)

-- 
2.26.2



^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH v4 01/31] tools: generate pkg-config files from make variables
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-09-07 14:25   ` Wei Liu
  2020-08-28 15:07 ` [PATCH v4 02/31] tools: drop explicit path specifications for qemu build Juergen Gross
                   ` (29 subsequent siblings)
  30 siblings, 1 reply; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel
  Cc: Juergen Gross, Ian Jackson, Wei Liu, Samuel Thibault, Anthony PERARD

For each library built two variants of pkg-config files are created
from a per-library template: an "official" one for installation on
the user's system, and one used for building internal tools, like e.g.
qemu.

Instead of the template which is looking very similar for all libraries
generate the pkg-config files directly from make variables.

This will reduce the need to specify some pkg-config file entries in
the templates, as the contents can easily be generated from available
data (e.g. "Version:" and "Requires.private:" entries).

Especially the variant used for building internal tools needs to gain
additional runtime link parameters for the internally used libraries,
as otherwise those won't be found by the users (e.g. qemu).

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 stubdom/Makefile                              |  1 -
 tools/Rules.mk                                | 52 +++++++++++--------
 tools/libs/call/xencall.pc.in                 | 10 ----
 tools/libs/devicemodel/xendevicemodel.pc.in   | 10 ----
 tools/libs/evtchn/xenevtchn.pc.in             | 10 ----
 .../libs/foreignmemory/xenforeignmemory.pc.in | 10 ----
 tools/libs/gnttab/xengnttab.pc.in             | 10 ----
 tools/libs/hypfs/xenhypfs.pc.in               | 10 ----
 tools/libs/libs.mk                            |  8 +++
 tools/libs/toolcore/Makefile                  |  1 +
 tools/libs/toolcore/xentoolcore.pc.in         |  9 ----
 tools/libs/toollog/xentoollog.pc.in           |  9 ----
 tools/libvchan/Makefile                       |  5 ++
 tools/libvchan/xenvchan.pc.in                 | 10 ----
 tools/libxc/Makefile                          | 22 ++++++++
 tools/libxc/xencontrol.pc.in                  | 10 ----
 tools/libxc/xenguest.pc.in                    | 10 ----
 tools/libxl/Makefile                          | 22 ++++++++
 tools/libxl/xenlight.pc.in                    | 12 -----
 tools/libxl/xlutil.pc.in                      | 10 ----
 tools/xenstat/libxenstat/Makefile             |  5 ++
 tools/xenstat/libxenstat/xenstat.pc.in        | 10 ----
 tools/xenstore/Makefile                       |  8 ++-
 tools/xenstore/xenstore.pc.in                 | 11 ----
 24 files changed, 98 insertions(+), 177 deletions(-)
 delete mode 100644 tools/libs/call/xencall.pc.in
 delete mode 100644 tools/libs/devicemodel/xendevicemodel.pc.in
 delete mode 100644 tools/libs/evtchn/xenevtchn.pc.in
 delete mode 100644 tools/libs/foreignmemory/xenforeignmemory.pc.in
 delete mode 100644 tools/libs/gnttab/xengnttab.pc.in
 delete mode 100644 tools/libs/hypfs/xenhypfs.pc.in
 delete mode 100644 tools/libs/toolcore/xentoolcore.pc.in
 delete mode 100644 tools/libs/toollog/xentoollog.pc.in
 delete mode 100644 tools/libvchan/xenvchan.pc.in
 delete mode 100644 tools/libxc/xencontrol.pc.in
 delete mode 100644 tools/libxc/xenguest.pc.in
 delete mode 100644 tools/libxl/xenlight.pc.in
 delete mode 100644 tools/libxl/xlutil.pc.in
 delete mode 100644 tools/xenstat/libxenstat/xenstat.pc.in
 delete mode 100644 tools/xenstore/xenstore.pc.in

diff --git a/stubdom/Makefile b/stubdom/Makefile
index 4fd86dd44b..c466858db0 100644
--- a/stubdom/Makefile
+++ b/stubdom/Makefile
@@ -342,7 +342,6 @@ define do_links
   cd $(dir $@); \
   ln -sf $(dir $<)include/*.h include/; \
   ln -sf $(dir $<)*.[ch] .; \
-  ln -sf $(dir $<)*.pc.in .; \
   ln -sf $(dir $<)Makefile .
   touch $@
 endef
diff --git a/tools/Rules.mk b/tools/Rules.mk
index 7e019a8a65..7ad72bebd3 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -209,27 +209,33 @@ endif
 
 PKG_CONFIG_DIR ?= $(XEN_ROOT)/tools/pkg-config
 
-PKG_CONFIG_FILTER = $(foreach l,$(PKG_CONFIG_REMOVE),-e 's!\([ ,]\)$(l),!\1!g' -e 's![ ,]$(l)$$!!g')
-
-$(PKG_CONFIG_DIR)/%.pc: %.pc.in Makefile $(XEN_ROOT)/tools/Rules.mk
+$(PKG_CONFIG_DIR):
 	mkdir -p $(PKG_CONFIG_DIR)
-	@sed -e 's!@@version@@!$(PKG_CONFIG_VERSION)!g' \
-	     -e 's!@@prefix@@!$(PKG_CONFIG_PREFIX)!g' \
-	     -e 's!@@incdir@@!$(PKG_CONFIG_INCDIR)!g' \
-	     -e 's!@@libdir@@!$(PKG_CONFIG_LIBDIR)!g' \
-	     -e 's!@@firmwaredir@@!$(XENFIRMWAREDIR)!g' \
-	     -e 's!@@libexecbin@@!$(LIBEXEC_BIN)!g' \
-	     -e 's!@@cflagslocal@@!$(PKG_CONFIG_CFLAGS_LOCAL)!g' \
-	     -e 's!@@libsflag@@\([^ ]*\)!-L\1 -Wl,-rpath-link=\1!g' \
-	     $(PKG_CONFIG_FILTER) < $< > $@
-
-%.pc: %.pc.in Makefile $(XEN_ROOT)/tools/Rules.mk
-	@sed -e 's!@@version@@!$(PKG_CONFIG_VERSION)!g' \
-	     -e 's!@@prefix@@!$(PKG_CONFIG_PREFIX)!g' \
-	     -e 's!@@incdir@@!$(PKG_CONFIG_INCDIR)!g' \
-	     -e 's!@@libdir@@!$(PKG_CONFIG_LIBDIR)!g' \
-	     -e 's!@@firmwaredir@@!$(XENFIRMWAREDIR)!g' \
-	     -e 's!@@libexecbin@@!$(LIBEXEC_BIN)!g' \
-	     -e 's!@@cflagslocal@@!!g' \
-	     -e 's!@@libsflag@@!-L!g' \
-	     $(PKG_CONFIG_FILTER) < $< > $@
+
+$(PKG_CONFIG_DIR)/%.pc: Makefile $(XEN_ROOT)/tools/Rules.mk $(PKG_CONFIG_DIR)
+	$(file >$@,prefix=$(PKG_CONFIG_PREFIX))
+	$(file >>$@,includedir=$(PKG_CONFIG_INCDIR))
+	$(file >>$@,libdir=$(PKG_CONFIG_LIBDIR))
+	$(foreach var,$(PKG_CONFIG_VARS),$(file >>$@,$(var)))
+	$(file >>$@,)
+	$(file >>$@,Name: $(PKG_CONFIG_NAME))
+	$(file >>$@,Description: $(PKG_CONFIG_DESC))
+	$(file >>$@,Version: $(PKG_CONFIG_VERSION))
+	$(file >>$@,Cflags: -I$${includedir} $(CFLAGS_xeninclude))
+	$(file >>$@,Libs: -L$${libdir} $(PKG_CONFIG_USELIBS) -l$(PKG_CONFIG_LIB))
+	$(file >>$@,Libs.private: $(PKG_CONFIG_LIBSPRIV))
+	$(file >>$@,Requires.private: $(PKG_CONFIG_REQPRIV))
+
+%.pc: Makefile $(XEN_ROOT)/tools/Rules.mk
+	$(file >$@,prefix=$(PKG_CONFIG_PREFIX))
+	$(file >>$@,includedir=$(PKG_CONFIG_INCDIR))
+	$(file >>$@,libdir=$(PKG_CONFIG_LIBDIR))
+	$(foreach var,$(PKG_CONFIG_VARS),$(file >>$@,$(var)))
+	$(file >>$@,)
+	$(file >>$@,Name: $(PKG_CONFIG_NAME))
+	$(file >>$@,Description: $(PKG_CONFIG_DESC))
+	$(file >>$@,Version: $(PKG_CONFIG_VERSION))
+	$(file >>$@,Cflags: -I$${includedir})
+	$(file >>$@,Libs: -L$${libdir} -l$(PKG_CONFIG_LIB))
+	$(file >>$@,Libs.private: $(PKG_CONFIG_LIBSPRIV))
+	$(file >>$@,Requires.private: $(PKG_CONFIG_REQPRIV))
diff --git a/tools/libs/call/xencall.pc.in b/tools/libs/call/xencall.pc.in
deleted file mode 100644
index 409773e535..0000000000
--- a/tools/libs/call/xencall.pc.in
+++ /dev/null
@@ -1,10 +0,0 @@
-prefix=@@prefix@@
-includedir=@@incdir@@
-libdir=@@libdir@@
-
-Name: Xencall
-Description: The Xencall library for Xen hypervisor
-Version: @@version@@
-Cflags: -I${includedir} @@cflagslocal@@
-Libs: @@libsflag@@${libdir} -lxencall
-Requires.private: xentoollog,xentoolcore
diff --git a/tools/libs/devicemodel/xendevicemodel.pc.in b/tools/libs/devicemodel/xendevicemodel.pc.in
deleted file mode 100644
index 8bd04faf47..0000000000
--- a/tools/libs/devicemodel/xendevicemodel.pc.in
+++ /dev/null
@@ -1,10 +0,0 @@
-prefix=@@prefix@@
-includedir=@@incdir@@
-libdir=@@libdir@@
-
-Name: Xendevicemodel
-Description: The Xendevicemodel library for Xen hypervisor
-Version: @@version@@
-Cflags: -I${includedir} @@cflagslocal@@
-Libs: @@libsflag@@${libdir} -lxendevicemodel
-Requires.private: xentoolcore,xentoollog,xencall
diff --git a/tools/libs/evtchn/xenevtchn.pc.in b/tools/libs/evtchn/xenevtchn.pc.in
deleted file mode 100644
index c74af1ece4..0000000000
--- a/tools/libs/evtchn/xenevtchn.pc.in
+++ /dev/null
@@ -1,10 +0,0 @@
-prefix=@@prefix@@
-includedir=@@incdir@@
-libdir=@@libdir@@
-
-Name: Xenevtchn
-Description: The Xenevtchn library for Xen hypervisor
-Version: @@version@@
-Cflags: -I${includedir}
-Libs: @@libsflag@@${libdir} -lxenevtchn
-Requires.private: xentoollog
diff --git a/tools/libs/foreignmemory/xenforeignmemory.pc.in b/tools/libs/foreignmemory/xenforeignmemory.pc.in
deleted file mode 100644
index 61c9def69c..0000000000
--- a/tools/libs/foreignmemory/xenforeignmemory.pc.in
+++ /dev/null
@@ -1,10 +0,0 @@
-prefix=@@prefix@@
-includedir=@@incdir@@
-libdir=@@libdir@@
-
-Name: Xenforeignmemory
-Description: The Xenforeignmemory library for Xen hypervisor
-Version: @@version@@
-Cflags: -I${includedir} @@cflagslocal@@
-Libs: @@libsflag@@${libdir} -lxenforeignmemory
-Requires.private: xentoollog,xentoolcore
diff --git a/tools/libs/gnttab/xengnttab.pc.in b/tools/libs/gnttab/xengnttab.pc.in
deleted file mode 100644
index 4c3beed5dc..0000000000
--- a/tools/libs/gnttab/xengnttab.pc.in
+++ /dev/null
@@ -1,10 +0,0 @@
-prefix=@@prefix@@
-includedir=@@incdir@@
-libdir=@@libdir@@
-
-Name: Xengnttab
-Description: The Xengnttab library for Xen hypervisor
-Version: @@version@@
-Cflags: -I${includedir} @@cflagslocal@@
-Libs: @@libsflag@@${libdir} -lxengnttab
-Requires.private: xentoollog,xentoolcore
diff --git a/tools/libs/hypfs/xenhypfs.pc.in b/tools/libs/hypfs/xenhypfs.pc.in
deleted file mode 100644
index ef9fcc87bf..0000000000
--- a/tools/libs/hypfs/xenhypfs.pc.in
+++ /dev/null
@@ -1,10 +0,0 @@
-prefix=@@prefix@@
-includedir=@@incdir@@
-libdir=@@libdir@@
-
-Name: Xenhypfs
-Description: The Xenhypfs library for Xen hypervisor
-Version: @@version@@
-Cflags: -I${includedir} @@cflagslocal@@
-Libs: @@libsflag@@${libdir} -lxenhypfs
-Requires.private: xentoolcore,xentoollog,xencall,zlib
diff --git a/tools/libs/libs.mk b/tools/libs/libs.mk
index 8b1ca2aa62..4679268fc2 100644
--- a/tools/libs/libs.mk
+++ b/tools/libs/libs.mk
@@ -25,8 +25,16 @@ ifneq ($(nosharedlibs),y)
 LIB += libxen$(LIBNAME).so
 endif
 
+comma:= ,
+empty:=
+space:= $(empty) $(empty)
 PKG_CONFIG ?= xen$(LIBNAME).pc
+PKG_CONFIG_NAME ?= Xen$(LIBNAME)
+PKG_CONFIG_DESC ?= The $(PKG_CONFIG_NAME) library for Xen hypervisor
 PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
+PKG_CONFIG_USELIBS := $(SHLIB_libxen$(LIBNAME))
+PKG_CONFIG_LIB := xen$(LIBNAME)
+PKG_CONFIG_REQPRIV := $(subst $(space),$(comma),$(strip $(foreach lib,$(USELIBS_$(LIBNAME)),xen$(lib))))
 
 ifneq ($(CONFIG_LIBXC_MINIOS),y)
 PKG_CONFIG_INST := $(PKG_CONFIG)
diff --git a/tools/libs/toolcore/Makefile b/tools/libs/toolcore/Makefile
index 34b08a4236..5819bbc8ee 100644
--- a/tools/libs/toolcore/Makefile
+++ b/tools/libs/toolcore/Makefile
@@ -9,6 +9,7 @@ SRCS-y	+= handlereg.c
 
 include $(XEN_ROOT)/tools/libs/libs.mk
 
+PKG_CONFIG_DESC := Central support for Xen Hypervisor userland libraries
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxentoolcore)/include
 
 $(LIB_OBJS): $(AUTOINCS)
diff --git a/tools/libs/toolcore/xentoolcore.pc.in b/tools/libs/toolcore/xentoolcore.pc.in
deleted file mode 100644
index 55ff4e25e4..0000000000
--- a/tools/libs/toolcore/xentoolcore.pc.in
+++ /dev/null
@@ -1,9 +0,0 @@
-prefix=@@prefix@@
-includedir=@@incdir@@
-libdir=@@libdir@@
-
-Name: Xentoolcore
-Description: Central support for Xen Hypervisor userland libraries
-Version: @@version@@
-Cflags: -I${includedir}
-Libs: @@libsflag@@${libdir} -lxentoolcore
diff --git a/tools/libs/toollog/xentoollog.pc.in b/tools/libs/toollog/xentoollog.pc.in
deleted file mode 100644
index 554e4d5b34..0000000000
--- a/tools/libs/toollog/xentoollog.pc.in
+++ /dev/null
@@ -1,9 +0,0 @@
-prefix=@@prefix@@
-includedir=@@incdir@@
-libdir=@@libdir@@
-
-Name: Xentoollog
-Description: The Xentoollog library for Xen hypervisor
-Version: @@version@@
-Cflags: -I${includedir}
-Libs: @@libsflag@@${libdir} -lxentoollog
diff --git a/tools/libvchan/Makefile b/tools/libvchan/Makefile
index a5441162a0..e718447977 100644
--- a/tools/libvchan/Makefile
+++ b/tools/libvchan/Makefile
@@ -23,7 +23,12 @@ CFLAGS += -I../include -I.
 io.o io.opic: CFLAGS += $(CFLAGS_libxenctrl) # for xen_mb et al
 
 PKG_CONFIG := xenvchan.pc
+PKG_CONFIG_NAME := Xenvchan
+PKG_CONFIG_DESC := The Xenvchan library for Xen hypervisor
 PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
+PKG_CONFIG_USELIBS := $(SHLIB_libxenvchan)
+PKG_CONFIG_LIB := xenvchan
+PKG_CONFIG_REQPRIV := xentoollog,xenstore,xenevtchn,xengnttab
 
 ifneq ($(CONFIG_LIBXC_MINIOS),y)
 PKG_CONFIG_INST := $(PKG_CONFIG)
diff --git a/tools/libvchan/xenvchan.pc.in b/tools/libvchan/xenvchan.pc.in
deleted file mode 100644
index 6fd13108d2..0000000000
--- a/tools/libvchan/xenvchan.pc.in
+++ /dev/null
@@ -1,10 +0,0 @@
-prefix=@@prefix@@
-includedir=@@incdir@@
-libdir=@@libdir@@
-
-Name: Xenvchan
-Description: The Xenvchan library for Xen hypervisor
-Version: @@version@@
-Cflags: -I${includedir} @@cflagslocal@@
-Libs: @@libsflag@@${libdir} -lxenvchan
-Requires.private: xentoollog,xenstore,xenevtchn,xengnttab
diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile
index c1e41a8ee9..315ac0b4f3 100644
--- a/tools/libxc/Makefile
+++ b/tools/libxc/Makefile
@@ -158,6 +158,28 @@ $(CTRL_PIC_OBJS) $(GUEST_PIC_OBJS): xc_private.h
 PKG_CONFIG := xencontrol.pc xenguest.pc
 PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
 
+xencontrol.pc: PKG_CONFIG_NAME = Xencontrol
+xencontrol.pc: PKG_CONFIG_DESC = The Xencontrol library for Xen hypervisor
+xencontrol.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenctrl)
+xencontrol.pc: PKG_CONFIG_LIB = xenctrl
+xencontrol.pc: PKG_CONFIG_REQPRIV = xenevtchn,xengnttab,xencall,xenforeignmemory,xendevicemodel,xentoollog
+xenguest.pc: PKG_CONFIG_NAME = Xenguest
+xenguest.pc: PKG_CONFIG_DESC = The Xenguest library for Xen hypervisor
+xenguest.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenguest)
+xenguest.pc: PKG_CONFIG_LIB = xenguest
+xenguest.pc: PKG_CONFIG_REQPRIV = xentoollog,xencall,xenforeignmemory,xenevtchn
+
+$(PKG_CONFIG_DIR)/xencontrol.pc: PKG_CONFIG_NAME = Xencontrol
+$(PKG_CONFIG_DIR)/xencontrol.pc: PKG_CONFIG_DESC = The Xencontrol library for Xen hypervisor
+$(PKG_CONFIG_DIR)/xencontrol.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenctrl)
+$(PKG_CONFIG_DIR)/xencontrol.pc: PKG_CONFIG_LIB = xenctrl
+$(PKG_CONFIG_DIR)/xencontrol.pc: PKG_CONFIG_REQPRIV = xenevtchn,xengnttab,xencall,xenforeignmemory,xendevicemodel,xentoollog
+$(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_NAME = Xenguest
+$(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_DESC = The Xenguest library for Xen hypervisor
+$(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenguest)
+$(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_LIB = xenguest
+$(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_REQPRIV = xentoollog,xencall,xenforeignmemory,xenevtchn
+
 ifneq ($(CONFIG_LIBXC_MINIOS),y)
 PKG_CONFIG_INST := $(PKG_CONFIG)
 $(PKG_CONFIG_INST): PKG_CONFIG_PREFIX = $(prefix)
diff --git a/tools/libxc/xencontrol.pc.in b/tools/libxc/xencontrol.pc.in
deleted file mode 100644
index e653ba2543..0000000000
--- a/tools/libxc/xencontrol.pc.in
+++ /dev/null
@@ -1,10 +0,0 @@
-prefix=@@prefix@@
-includedir=@@incdir@@
-libdir=@@libdir@@
-
-Name: Xencontrol
-Description: The Xencontrol library for Xen hypervisor
-Version: @@version@@
-Cflags: -I${includedir} @@cflagslocal@@
-Libs: @@libsflag@@${libdir} -lxenctrl
-Requires.private: xenevtchn,xengnttab,xencall,xenforeignmemory,xendevicemodel,xentoollog
diff --git a/tools/libxc/xenguest.pc.in b/tools/libxc/xenguest.pc.in
deleted file mode 100644
index 225ac0b9c8..0000000000
--- a/tools/libxc/xenguest.pc.in
+++ /dev/null
@@ -1,10 +0,0 @@
-prefix=@@prefix@@
-includedir=@@incdir@@
-libdir=@@libdir@@
-
-Name: Xenguest
-Description: The Xenguest library for Xen hypervisor
-Version: @@version@@
-Cflags: -I${includedir}
-Libs: @@libsflag@@${libdir} -lxenguest
-Requires.private: xentoollog,xencall,xenforeignmemory,xenevtchn
diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 0e8dfc6193..684da32a5b 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -195,8 +195,19 @@ PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
 
 ifneq ($(CONFIG_LIBXC_MINIOS),y)
 PKG_CONFIG_INST := $(PKG_CONFIG)
+xenlight.pc: PKG_CONFIG_NAME = Xenlight
+xenlight.pc: PKG_CONFIG_DESC = The Xenlight library for Xen hypervisor
 xenlight.pc: PKG_CONFIG_VERSION = $(MAJOR).$(MINOR)
+xenlight.pc: PKG_CONFIG_VARS = xenfirmwaredir=$(XENFIRMWAREDIR) libexec_bin=$(LIBEXEC_BIN)
+xenlight.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenlight)
+xenlight.pc: PKG_CONFIG_LIB = xenlight
+xenlight.pc: PKG_CONFIG_REQPRIV = xentoollog,xenevtchn,xencontrol,xenguest,xenstore,xenhypfs
+xlutil.pc: PKG_CONFIG_NAME = Xlutil
+xlutil.pc: PKG_CONFIG_DESC = The xl utility library for Xen hypervisor
 xlutil.pc: PKG_CONFIG_VERSION = $(XLUMAJOR).$(XLUMINOR)
+xlutil.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxlutil)
+xlutil.pc: PKG_CONFIG_LIB = xlutil
+xlutil.pc: PKG_CONFIG_REQPRIV = xenlight
 $(PKG_CONFIG_INST): PKG_CONFIG_PREFIX = $(prefix)
 $(PKG_CONFIG_INST): PKG_CONFIG_INCDIR = $(includedir)
 $(PKG_CONFIG_INST): PKG_CONFIG_LIBDIR = $(libdir)
@@ -204,8 +215,19 @@ endif
 
 PKG_CONFIG_LOCAL := $(foreach pc,$(PKG_CONFIG),$(PKG_CONFIG_DIR)/$(pc))
 
+$(PKG_CONFIG_DIR)/xenlight.pc: PKG_CONFIG_NAME = Xenlight
+$(PKG_CONFIG_DIR)/xenlight.pc: PKG_CONFIG_DESC = The Xenlight library for Xen hypervisor
 $(PKG_CONFIG_DIR)/xenlight.pc: PKG_CONFIG_VERSION = $(MAJOR).$(MINOR)
+$(PKG_CONFIG_DIR)/xenlight.pc: PKG_CONFIG_VARS = xenfirmwaredir=$(XENFIRMWAREDIR) libexec_bin=$(LIBEXEC_BIN)
+$(PKG_CONFIG_DIR)/xenlight.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenlight)
+$(PKG_CONFIG_DIR)/xenlight.pc: PKG_CONFIG_LIB = xenlight
+$(PKG_CONFIG_DIR)/xenlight.pc: PKG_CONFIG_REQPRIV = xentoollog,xenevtchn,xencontrol,xenguest,xenstore,xenhypfs
+$(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_NAME = Xlutil
+$(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_DESC = The xl utility library for Xen hypervisor
 $(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_VERSION = $(XLUMAJOR).$(XLUMINOR)
+$(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxlutil)
+$(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_LIB = xlutil
+$(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_REQPRIV = xenlight
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_PREFIX = $(XEN_ROOT)
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(CURDIR)
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
diff --git a/tools/libxl/xenlight.pc.in b/tools/libxl/xenlight.pc.in
deleted file mode 100644
index 6b351ba096..0000000000
--- a/tools/libxl/xenlight.pc.in
+++ /dev/null
@@ -1,12 +0,0 @@
-prefix=@@prefix@@
-includedir=@@incdir@@
-libdir=@@libdir@@
-xenfirmwaredir=@@firmwaredir@@
-libexec_bin=@@libexecbin@@
-
-Name: Xenlight
-Description: The Xenlight library for Xen hypervisor
-Version: @@version@@
-Cflags: -I${includedir}
-Libs: @@libsflag@@${libdir} -lxenlight
-Requires.private: xentoollog,xenevtchn,xencontrol,xenguest,xenstore,xenhypfs
diff --git a/tools/libxl/xlutil.pc.in b/tools/libxl/xlutil.pc.in
deleted file mode 100644
index cdd98fba74..0000000000
--- a/tools/libxl/xlutil.pc.in
+++ /dev/null
@@ -1,10 +0,0 @@
-prefix=@@prefix@@
-includedir=@@incdir@@
-libdir=@@libdir@@
-
-Name: Xlutil
-Description: The xl utility library for Xen hypervisor
-Version: @@version@@
-Cflags: -I${includedir}
-Libs: @@libsflag@@${libdir} -lxlutil
-Requires.private: xenlight
diff --git a/tools/xenstat/libxenstat/Makefile b/tools/xenstat/libxenstat/Makefile
index b5e623b155..bdd5a0f469 100644
--- a/tools/xenstat/libxenstat/Makefile
+++ b/tools/xenstat/libxenstat/Makefile
@@ -38,7 +38,12 @@ LDLIBS-y = $(LDLIBS_libxenstore) $(LDLIBS_libxenctrl) -lyajl
 LDLIBS-$(CONFIG_SunOS) += -lkstat
 
 PKG_CONFIG := xenstat.pc
+PKG_CONFIG_NAME := Xenstat
+PKG_CONFIG_DESC := The Xenstat library for Xen hypervisor
 PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
+PKG_CONFIG_USELIBS := $(SHLIB_libxenstat)
+PKG_CONFIG_LIB := xenstat
+PKG_CONFIG_REQPRIV := xencontrol,xenstore
 
 ifneq ($(CONFIG_LIBXC_MINIOS),y)
 PKG_CONFIG_INST := $(PKG_CONFIG)
diff --git a/tools/xenstat/libxenstat/xenstat.pc.in b/tools/xenstat/libxenstat/xenstat.pc.in
deleted file mode 100644
index ad00577c89..0000000000
--- a/tools/xenstat/libxenstat/xenstat.pc.in
+++ /dev/null
@@ -1,10 +0,0 @@
-prefix=@@prefix@@
-includedir=@@incdir@@
-libdir=@@libdir@@
-
-Name: Xenstat
-Description: The Xenstat library for Xen hypervisor
-Version: @@version@@
-Cflags: -I${includedir}
-Libs: @@libsflag@@${libdir} -lxenstat
-Requires.private: xencontrol,xenstore
diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
index 0a64ac1571..574be8d15c 100644
--- a/tools/xenstore/Makefile
+++ b/tools/xenstore/Makefile
@@ -105,8 +105,7 @@ xs.opic: CFLAGS += -DUSE_PTHREAD
 ifeq ($(CONFIG_Linux),y)
 xs.opic: CFLAGS += -DUSE_DLSYM
 libxenstore.so.$(MAJOR).$(MINOR): APPEND_LDFLAGS += -ldl
-else
-PKG_CONFIG_REMOVE += -ldl
+PKG_CONFIG_LIBSPRIV := -ldl
 endif
 
 libxenstore.so.$(MAJOR).$(MINOR): xs.opic xs_lib.opic
@@ -116,7 +115,12 @@ libxenstore.a: xs.o xs_lib.o
 	$(AR) rcs $@ $^
 
 PKG_CONFIG := xenstore.pc
+PKG_CONFIG_NAME := Xenstore
+PKG_CONFIG_DESC := The Xenstore library for Xen hypervisor
 PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
+PKG_CONFIG_USELIBS := $(SHLIB_libxenstore)
+PKG_CONFIG_LIB := xenstore
+PKG_CONFIG_REQPRIV := xenevtchn,xencontrol,xengnttab,xentoolcore
 
 ifneq ($(CONFIG_LIBXC_MINIOS),y)
 PKG_CONFIG_INST := $(PKG_CONFIG)
diff --git a/tools/xenstore/xenstore.pc.in b/tools/xenstore/xenstore.pc.in
deleted file mode 100644
index 2f64a6b824..0000000000
--- a/tools/xenstore/xenstore.pc.in
+++ /dev/null
@@ -1,11 +0,0 @@
-prefix=@@prefix@@
-includedir=@@incdir@@
-libdir=@@libdir@@
-
-Name: Xenstore
-Description: The Xenstore library for Xen hypervisor
-Version: @@version@@
-Cflags: -I${includedir} @@cflagslocal@@
-Libs: @@libsflag@@${libdir} -lxenstore
-Libs.private: -ldl
-Requires.private: xenevtchn,xencontrol,xengnttab,xentoolcore
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 02/31] tools: drop explicit path specifications for qemu build
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 01/31] tools: generate pkg-config files from make variables Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-09-07 14:25   ` Wei Liu
  2020-08-28 15:07 ` [PATCH v4 03/31] tools/python: drop libxenguest from setup.py Juergen Gross
                   ` (28 subsequent siblings)
  30 siblings, 1 reply; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu

Since more than three years now qemu is capable to set the needed
include and library paths for the Xen libraries via pkg-config.

So drop the specification of those paths in tools/Makefile. This will
enable to move libxenctrl away from tools/libxc, as qemu's configure
script has special treatment of this path.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 tools/Makefile | 26 +-------------------------
 1 file changed, 1 insertion(+), 25 deletions(-)

diff --git a/tools/Makefile b/tools/Makefile
index 198b239edc..7c9f9fc900 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -245,32 +245,8 @@ subdir-all-qemu-xen-dir: qemu-xen-dir-find
 		-DXC_WANT_COMPAT_GNTTAB_API=1 \
 		-DXC_WANT_COMPAT_MAP_FOREIGN_API=1 \
 		-DXC_WANT_COMPAT_DEVICEMODEL_API=1 \
-		-I$(XEN_ROOT)/tools/include \
-		-I$(XEN_ROOT)/tools/libs/toolcore/include \
-		-I$(XEN_ROOT)/tools/libs/toollog/include \
-		-I$(XEN_ROOT)/tools/libs/evtchn/include \
-		-I$(XEN_ROOT)/tools/libs/gnttab/include \
-		-I$(XEN_ROOT)/tools/libs/foreignmemory/include \
-		-I$(XEN_ROOT)/tools/libs/devicemodel/include \
-		-I$(XEN_ROOT)/tools/libxc/include \
-		-I$(XEN_ROOT)/tools/xenstore/include \
-		-I$(XEN_ROOT)/tools/xenstore/compat/include \
 		$(EXTRA_CFLAGS_QEMU_XEN)" \
-		--extra-ldflags="-L$(XEN_ROOT)/tools/libxc \
-		-L$(XEN_ROOT)/tools/xenstore \
-		-L$(XEN_ROOT)/tools/libs/toolcore \
-		-L$(XEN_ROOT)/tools/libs/evtchn \
-		-L$(XEN_ROOT)/tools/libs/gnttab \
-		-L$(XEN_ROOT)/tools/libs/foreignmemory \
-		-L$(XEN_ROOT)/tools/libs/devicemodel \
-		-Wl,-rpath-link=$(XEN_ROOT)/tools/libs/toolcore \
-		-Wl,-rpath-link=$(XEN_ROOT)/tools/libs/toollog \
-		-Wl,-rpath-link=$(XEN_ROOT)/tools/libs/evtchn \
-		-Wl,-rpath-link=$(XEN_ROOT)/tools/libs/gnttab \
-		-Wl,-rpath-link=$(XEN_ROOT)/tools/libs/call \
-		-Wl,-rpath-link=$(XEN_ROOT)/tools/libs/foreignmemory \
-		-Wl,-rpath-link=$(XEN_ROOT)/tools/libs/devicemodel \
-		$(QEMU_UPSTREAM_RPATH)" \
+		--extra-ldflags="$(QEMU_UPSTREAM_RPATH)" \
 		--bindir=$(LIBEXEC_BIN) \
 		--datadir=$(SHAREDIR)/qemu-xen \
 		--localstatedir=$(localstatedir) \
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 03/31] tools/python: drop libxenguest from setup.py
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 01/31] tools: generate pkg-config files from make variables Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 02/31] tools: drop explicit path specifications for qemu build Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 04/31] tools: fix pkg-config file for libxenguest Juergen Gross
                   ` (27 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel
  Cc: Juergen Gross, Marek Marczykowski-Górecki, Ian Jackson, Wei Liu

There is not a single wrapper for a libxenguest function defined.
So drop libxenguest from tools/python/setup.py.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
---
 tools/python/setup.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/python/setup.py b/tools/python/setup.py
index 8faf1c0ddc..44696b3998 100644
--- a/tools/python/setup.py
+++ b/tools/python/setup.py
@@ -21,8 +21,8 @@ xc = Extension("xc",
                                       PATH_LIBXC + "/include",
                                       "xen/lowlevel/xc" ],
                library_dirs       = [ PATH_LIBXC ],
-               libraries          = [ "xenctrl", "xenguest" ],
-               depends            = [ PATH_LIBXC + "/libxenctrl.so", PATH_LIBXC + "/libxenguest.so" ],
+               libraries          = [ "xenctrl" ],
+               depends            = [ PATH_LIBXC + "/libxenctrl.so" ],
                extra_link_args    = [ "-Wl,-rpath-link="+PATH_LIBXENTOOLLOG ],
                sources            = [ "xen/lowlevel/xc/xc.c" ])
 
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 04/31] tools: fix pkg-config file for libxenguest
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (2 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 03/31] tools/python: drop libxenguest from setup.py Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 05/31] tools: don't assume libxenguest and libxenctrl to be in same directory Juergen Gross
                   ` (26 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu

The pkg-config file for libxenguest is missing the private dependency
on libxenctrl.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
 tools/libxc/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile
index 315ac0b4f3..763231065c 100644
--- a/tools/libxc/Makefile
+++ b/tools/libxc/Makefile
@@ -178,7 +178,7 @@ $(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_NAME = Xenguest
 $(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_DESC = The Xenguest library for Xen hypervisor
 $(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenguest)
 $(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_LIB = xenguest
-$(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_REQPRIV = xentoollog,xencall,xenforeignmemory,xenevtchn
+$(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_REQPRIV = xentoollog,xencall,xenforeignmemory,xenevtchn,xencontrol
 
 ifneq ($(CONFIG_LIBXC_MINIOS),y)
 PKG_CONFIG_INST := $(PKG_CONFIG)
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 05/31] tools: don't assume libxenguest and libxenctrl to be in same directory
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (3 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 04/31] tools: fix pkg-config file for libxenguest Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 06/31] tools/misc: don't use libxenctrl internals from xen-hptool Juergen Gross
                   ` (25 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu, Anthony PERARD

There are quite some places in Makefiles assuming libxenguest and
libxenctrl being built in the same directory via a single Makefile.

Drop this assumption by specifying the dependencies and path variables
for both libraries correctly.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
 tools/Rules.mk       | 7 +++----
 tools/libxl/Makefile | 2 +-
 tools/misc/Makefile  | 1 +
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/Rules.mk b/tools/Rules.mk
index 7ad72bebd3..4f3aaaacd3 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -16,8 +16,7 @@ XEN_INCLUDE        = $(XEN_ROOT)/tools/include
 include $(XEN_ROOT)/tools/libs/uselibs.mk
 
 XEN_libxenctrl     = $(XEN_ROOT)/tools/libxc
-# Currently libxenguest lives in the same directory as libxenctrl
-XEN_libxenguest    = $(XEN_libxenctrl)
+XEN_libxenguest    = $(XEN_ROOT)/tools/libxc
 XEN_libxenlight    = $(XEN_ROOT)/tools/libxl
 # Currently libxlutil lives in the same directory as libxenlight
 XEN_libxlutil      = $(XEN_libxenlight)
@@ -117,7 +116,7 @@ LDLIBS_libxenguest = $(SHDEPS_libxenguest) $(XEN_libxenguest)/libxenguest$(libex
 SHLIB_libxenguest  = $(SHDEPS_libxenguest) -Wl,-rpath-link=$(XEN_libxenguest)
 
 CFLAGS_libxenstore = -I$(XEN_libxenstore)/include $(CFLAGS_xeninclude)
-SHDEPS_libxenstore = $(SHLIB_libxentoolcore)
+SHDEPS_libxenstore = $(SHLIB_libxentoolcore) $(SHLIB_libxenctrl)
 LDLIBS_libxenstore = $(SHDEPS_libxenstore) $(XEN_libxenstore)/libxenstore$(libextension)
 SHLIB_libxenstore  = $(SHDEPS_libxenstore) -Wl,-rpath-link=$(XEN_libxenstore)
 ifeq ($(CONFIG_Linux),y)
@@ -144,7 +143,7 @@ CFLAGS += -O2 -fomit-frame-pointer
 endif
 
 CFLAGS_libxenlight = -I$(XEN_libxenlight) $(CFLAGS_libxenctrl) $(CFLAGS_xeninclude)
-SHDEPS_libxenlight = $(SHLIB_libxenctrl) $(SHLIB_libxenstore) $(SHLIB_libxenhypfs)
+SHDEPS_libxenlight = $(SHLIB_libxenctrl) $(SHLIB_libxenstore) $(SHLIB_libxenhypfs) $(SHLIB_libxenguest)
 LDLIBS_libxenlight = $(SHDEPS_libxenlight) $(XEN_libxenlight)/libxenlight$(libextension)
 SHLIB_libxenlight  = $(SHDEPS_libxenlight) -Wl,-rpath-link=$(XEN_libxenlight)
 
diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 684da32a5b..b815c548de 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -188,7 +188,7 @@ libxl_dom.o: CFLAGS += -I$(XEN_ROOT)/tools  # include libacpi/x86.h
 libxl_x86_acpi.o: CFLAGS += -I$(XEN_ROOT)/tools
 
 SAVE_HELPER_OBJS = libxl_save_helper.o _libxl_save_msgs_helper.o
-$(SAVE_HELPER_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenevtchn)
+$(SAVE_HELPER_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenevtchn) $(CFLAGS_libxenguest)
 
 PKG_CONFIG = xenlight.pc xlutil.pc
 PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
diff --git a/tools/misc/Makefile b/tools/misc/Makefile
index 9fdb13597f..e7e74db85f 100644
--- a/tools/misc/Makefile
+++ b/tools/misc/Makefile
@@ -6,6 +6,7 @@ CFLAGS += -Werror
 CFLAGS += -include $(XEN_ROOT)/tools/config.h
 CFLAGS += $(CFLAGS_libxenevtchn)
 CFLAGS += $(CFLAGS_libxenctrl)
+CFLAGS += $(CFLAGS_libxenguest)
 CFLAGS += $(CFLAGS_xeninclude)
 CFLAGS += $(CFLAGS_libxenstore)
 
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 06/31] tools/misc: don't use libxenctrl internals from xen-hptool
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (4 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 05/31] tools: don't assume libxenguest and libxenctrl to be in same directory Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 07/31] tools/misc: don't include xg_save_restore.h from xen-mfndump.c Juergen Gross
                   ` (24 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu

xen-hptool is including private headers from tools/libxc without any
need. Switch it to use official headers only.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
 tools/misc/Makefile     | 2 --
 tools/misc/xen-hptool.c | 8 +++++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/misc/Makefile b/tools/misc/Makefile
index e7e74db85f..2a7f2ec42d 100644
--- a/tools/misc/Makefile
+++ b/tools/misc/Makefile
@@ -94,8 +94,6 @@ xenhypfs: xenhypfs.o
 xenlockprof: xenlockprof.o
 	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
 
-# xen-hptool incorrectly uses libxc internals
-xen-hptool.o: CFLAGS += -I$(XEN_ROOT)/tools/libxc $(CFLAGS_libxencall)
 xen-hptool: xen-hptool.o
 	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) $(APPEND_LDFLAGS)
 
diff --git a/tools/misc/xen-hptool.c b/tools/misc/xen-hptool.c
index 6e27d9cf43..7f17f24942 100644
--- a/tools/misc/xen-hptool.c
+++ b/tools/misc/xen-hptool.c
@@ -1,9 +1,11 @@
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
 #include <xenevtchn.h>
 #include <xenctrl.h>
-#include <xc_private.h>
-#include <xc_core.h>
+#include <xenguest.h>
 #include <xenstore.h>
-#include <unistd.h>
+#include <xen-tools/libs.h>
 
 static xc_interface *xch;
 
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 07/31] tools/misc: don't include xg_save_restore.h from xen-mfndump.c
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (5 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 06/31] tools/misc: don't use libxenctrl internals from xen-hptool Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 08/31] tools/misc: replace PAGE_SIZE with XC_PAGE_SIZE in xen-mfndump.c Juergen Gross
                   ` (23 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu

xen-mfndump.c is including the libxc private header xg_save_restore.h.
Avoid that by moving the definition of is_mapped() to xen-mfndump.c
(it is used there only) and by duplicating the definition of
M2P_SIZE() in xen-mfndump.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
 tools/libxc/xg_save_restore.h | 4 ----
 tools/misc/xen-mfndump.c      | 5 ++++-
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/tools/libxc/xg_save_restore.h b/tools/libxc/xg_save_restore.h
index 303081df0d..b904296997 100644
--- a/tools/libxc/xg_save_restore.h
+++ b/tools/libxc/xg_save_restore.h
@@ -109,10 +109,6 @@ static inline int get_platform_info(xc_interface *xch, uint32_t dom,
 #define M2P_SIZE(_m)    ROUNDUP(((_m) * sizeof(xen_pfn_t)), M2P_SHIFT)
 #define M2P_CHUNKS(_m)  (M2P_SIZE((_m)) >> M2P_SHIFT)
 
-/* Returns TRUE if the PFN is currently mapped */
-#define is_mapped(pfn_type) (!((pfn_type) & 0x80000000UL))
-
-
 #define GET_FIELD(_p, _f, _w) (((_w) == 8) ? ((_p)->x64._f) : ((_p)->x32._f))
 
 #define SET_FIELD(_p, _f, _v, _w) do {          \
diff --git a/tools/misc/xen-mfndump.c b/tools/misc/xen-mfndump.c
index 858bd0e26b..cb15d08c7e 100644
--- a/tools/misc/xen-mfndump.c
+++ b/tools/misc/xen-mfndump.c
@@ -5,7 +5,10 @@
 #include <unistd.h>
 #include <inttypes.h>
 
-#include "xg_save_restore.h"
+#include <xen-tools/libs.h>
+
+#define M2P_SIZE(_m)    ROUNDUP(((_m) * sizeof(xen_pfn_t)), 21)
+#define is_mapped(pfn_type) (!((pfn_type) & 0x80000000UL))
 
 static xc_interface *xch;
 
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 08/31] tools/misc: replace PAGE_SIZE with XC_PAGE_SIZE in xen-mfndump.c
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (6 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 07/31] tools/misc: don't include xg_save_restore.h from xen-mfndump.c Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 09/31] tools/misc: drop all libxc internals from xen-mfndump.c Juergen Gross
                   ` (22 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu

The definition of PAGE_SIZE comes from xc_private.h, which shouldn't be
used by xen-mfndump.c. Replace PAGE_SIZE by XC_PAGE_SIZE, as
xc_private.h contains:

#define PAGE_SIZE XC_PAGE_SIZE

For the same reason PAGE_SHIFT_X86 needs to replaced with
XC_PAGE_SHIFT.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
 tools/misc/xen-mfndump.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/tools/misc/xen-mfndump.c b/tools/misc/xen-mfndump.c
index cb15d08c7e..92bc954ce0 100644
--- a/tools/misc/xen-mfndump.c
+++ b/tools/misc/xen-mfndump.c
@@ -207,7 +207,7 @@ int dump_ptes_func(int argc, char *argv[])
         goto out;
     }
 
-    page = xc_map_foreign_range(xch, domid, PAGE_SIZE, PROT_READ,
+    page = xc_map_foreign_range(xch, domid, XC_PAGE_SIZE, PROT_READ,
                                 minfo.p2m_table[pfn]);
     if ( !page )
     {
@@ -216,7 +216,7 @@ int dump_ptes_func(int argc, char *argv[])
         goto out;
     }
 
-    pte_num = PAGE_SIZE / 8;
+    pte_num = XC_PAGE_SIZE / 8;
 
     printf(" --- Dumping %d PTEs for domain %d ---\n", pte_num, domid);
     printf(" Guest Width: %u, PT Levels: %u P2M size: = %lu\n",
@@ -252,7 +252,7 @@ int dump_ptes_func(int argc, char *argv[])
 
  out:
     if ( page )
-        munmap(page, PAGE_SIZE);
+        munmap(page, XC_PAGE_SIZE);
     xc_unmap_domain_meminfo(xch, &minfo);
     munmap(m2p_table, M2P_SIZE(max_mfn));
     return rc;
@@ -290,7 +290,7 @@ int lookup_pte_func(int argc, char *argv[])
         return -1;
     }
 
-    pte_num = PAGE_SIZE / 8;
+    pte_num = XC_PAGE_SIZE / 8;
 
     printf(" --- Lookig for PTEs mapping mfn 0x%lx for domain %d ---\n",
            mfn, domid);
@@ -302,7 +302,7 @@ int lookup_pte_func(int argc, char *argv[])
         if ( !(minfo.pfn_type[i] & XEN_DOMCTL_PFINFO_LTABTYPE_MASK) )
             continue;
 
-        page = xc_map_foreign_range(xch, domid, PAGE_SIZE, PROT_READ,
+        page = xc_map_foreign_range(xch, domid, XC_PAGE_SIZE, PROT_READ,
                                     minfo.p2m_table[i]);
         if ( !page )
             continue;
@@ -312,15 +312,15 @@ int lookup_pte_func(int argc, char *argv[])
             uint64_t pte = ((const uint64_t*)page)[j];
 
 #define __MADDR_BITS_X86  ((minfo.guest_width == 8) ? 52 : 44)
-#define __MFN_MASK_X86    ((1ULL << (__MADDR_BITS_X86 - PAGE_SHIFT_X86)) - 1)
-            if ( ((pte >> PAGE_SHIFT_X86) & __MFN_MASK_X86) == mfn)
+#define __MFN_MASK_X86    ((1ULL << (__MADDR_BITS_X86 - XC_PAGE_SHIFT)) - 1)
+            if ( ((pte >> XC_PAGE_SHIFT) & __MFN_MASK_X86) == mfn)
                 printf("  0x%lx <-- [0x%lx][%lu]: 0x%"PRIx64"\n",
                        mfn, minfo.p2m_table[i], j, pte);
 #undef __MADDR_BITS_X86
 #undef __MFN_MASK_X8
         }
 
-        munmap(page, PAGE_SIZE);
+        munmap(page, XC_PAGE_SIZE);
         page = NULL;
     }
 
@@ -355,8 +355,8 @@ int memcmp_mfns_func(int argc, char *argv[])
         return -1;
     }
 
-    page1 = xc_map_foreign_range(xch, domid1, PAGE_SIZE, PROT_READ, mfn1);
-    page2 = xc_map_foreign_range(xch, domid2, PAGE_SIZE, PROT_READ, mfn2);
+    page1 = xc_map_foreign_range(xch, domid1, XC_PAGE_SIZE, PROT_READ, mfn1);
+    page2 = xc_map_foreign_range(xch, domid2, XC_PAGE_SIZE, PROT_READ, mfn2);
     if ( !page1 || !page2 )
     {
         ERROR("Failed to map either 0x%lx[dom %d] or 0x%lx[dom %d]\n",
@@ -368,13 +368,13 @@ int memcmp_mfns_func(int argc, char *argv[])
     printf(" --- Comparing the content of 2 MFNs ---\n");
     printf(" 1: 0x%lx[dom %d], 2: 0x%lx[dom %d]\n",
            mfn1, domid1, mfn2, domid2);
-    printf("  memcpy(1, 2) = %d\n", memcmp(page1, page2, PAGE_SIZE));
+    printf("  memcpy(1, 2) = %d\n", memcmp(page1, page2, XC_PAGE_SIZE));
 
  out:
     if ( page1 )
-        munmap(page1, PAGE_SIZE);
+        munmap(page1, XC_PAGE_SIZE);
     if ( page2 )
-        munmap(page2, PAGE_SIZE);
+        munmap(page2, XC_PAGE_SIZE);
     return rc;
 }
 
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 09/31] tools/misc: drop all libxc internals from xen-mfndump.c
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (7 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 08/31] tools/misc: replace PAGE_SIZE with XC_PAGE_SIZE in xen-mfndump.c Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 10/31] tools/libxc: remove unused headers xc_efi.h and xc_elf.h Juergen Gross
                   ` (21 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu

The last libxc internal used by xen-mfndump.c is the ERROR() macro.
Add a simple definition for that macro to xen-mfndump.c and replace
the libxc private header includes by official ones.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
 tools/misc/Makefile      |  2 --
 tools/misc/xen-mfndump.c | 13 +++++++++----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/tools/misc/Makefile b/tools/misc/Makefile
index 2a7f2ec42d..7d37f297a9 100644
--- a/tools/misc/Makefile
+++ b/tools/misc/Makefile
@@ -99,8 +99,6 @@ xen-hptool: xen-hptool.o
 
 xenhypfs.o: CFLAGS += $(CFLAGS_libxenhypfs)
 
-# xen-mfndump incorrectly uses libxc internals
-xen-mfndump.o: CFLAGS += -I$(XEN_ROOT)/tools/libxc $(CFLAGS_libxencall)
 xen-mfndump: xen-mfndump.o
 	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(APPEND_LDFLAGS)
 
diff --git a/tools/misc/xen-mfndump.c b/tools/misc/xen-mfndump.c
index 92bc954ce0..62121bd241 100644
--- a/tools/misc/xen-mfndump.c
+++ b/tools/misc/xen-mfndump.c
@@ -1,15 +1,20 @@
-#define XC_WANT_COMPAT_MAP_FOREIGN_API
-#include <xenctrl.h>
-#include <xc_private.h>
-#include <xc_core.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
 #include <unistd.h>
 #include <inttypes.h>
 
+#define XC_WANT_COMPAT_MAP_FOREIGN_API
+#include <xenctrl.h>
+#include <xenguest.h>
+
 #include <xen-tools/libs.h>
 
 #define M2P_SIZE(_m)    ROUNDUP(((_m) * sizeof(xen_pfn_t)), 21)
 #define is_mapped(pfn_type) (!((pfn_type) & 0x80000000UL))
 
+#define ERROR(msg, args...) fprintf(stderr, msg, ## args)
+
 static xc_interface *xch;
 
 int help_func(int argc, char *argv[])
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 10/31] tools/libxc: remove unused headers xc_efi.h and xc_elf.h
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (8 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 09/31] tools/misc: drop all libxc internals from xen-mfndump.c Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 11/31] tools/libxc: move xc_[un]map_domain_meminfo() into new source xg_domain.c Juergen Gross
                   ` (20 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu

Remove xc_efi.h and xc_elf.h as they aren't used anywhere.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
 tools/libxc/xc_efi.h | 158 -------------------------------------------
 tools/libxc/xc_elf.h |  16 -----
 2 files changed, 174 deletions(-)
 delete mode 100644 tools/libxc/xc_efi.h
 delete mode 100644 tools/libxc/xc_elf.h

diff --git a/tools/libxc/xc_efi.h b/tools/libxc/xc_efi.h
deleted file mode 100644
index dbe105be8f..0000000000
--- a/tools/libxc/xc_efi.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Extensible Firmware Interface
- * Based on 'Extensible Firmware Interface Specification' version 0.9, April 30, 1999
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; If not, see <http://www.gnu.org/licenses/>.
- *
- * Copyright (C) 1999 VA Linux Systems
- * Copyright (C) 1999 Walt Drummond <drummond@valinux.com>
- * Copyright (C) 1999, 2002-2003 Hewlett-Packard Co.
- *      David Mosberger-Tang <davidm@hpl.hp.com>
- *      Stephane Eranian <eranian@hpl.hp.com>
- */
-
-#ifndef XC_EFI_H
-#define XC_EFI_H
-
-/* definitions from xen/include/asm-ia64/linux-xen/linux/efi.h */
-
-typedef struct {
-        uint8_t b[16];
-} efi_guid_t;
-
-#define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \
-((efi_guid_t) \
-{{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
-  (b) & 0xff, ((b) >> 8) & 0xff, \
-  (c) & 0xff, ((c) >> 8) & 0xff, \
-  (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
-
-/*
- * Generic EFI table header
- */
-typedef struct {
-	uint64_t signature;
-	uint32_t revision;
-	uint32_t headersize;
-	uint32_t crc32;
-	uint32_t reserved;
-} efi_table_hdr_t;
-
-/*
- * Memory map descriptor:
- */
-
-/* Memory types: */
-#define EFI_RESERVED_TYPE                0
-#define EFI_LOADER_CODE                  1
-#define EFI_LOADER_DATA                  2
-#define EFI_BOOT_SERVICES_CODE           3
-#define EFI_BOOT_SERVICES_DATA           4
-#define EFI_RUNTIME_SERVICES_CODE        5
-#define EFI_RUNTIME_SERVICES_DATA        6
-#define EFI_CONVENTIONAL_MEMORY          7
-#define EFI_UNUSABLE_MEMORY              8
-#define EFI_ACPI_RECLAIM_MEMORY          9
-#define EFI_ACPI_MEMORY_NVS             10
-#define EFI_MEMORY_MAPPED_IO            11
-#define EFI_MEMORY_MAPPED_IO_PORT_SPACE 12
-#define EFI_PAL_CODE                    13
-#define EFI_MAX_MEMORY_TYPE             14
-
-/* Attribute values: */
-#define EFI_MEMORY_UC           ((uint64_t)0x0000000000000001ULL)    /* uncached */
-#define EFI_MEMORY_WC           ((uint64_t)0x0000000000000002ULL)    /* write-coalescing */
-#define EFI_MEMORY_WT           ((uint64_t)0x0000000000000004ULL)    /* write-through */
-#define EFI_MEMORY_WB           ((uint64_t)0x0000000000000008ULL)    /* write-back */
-#define EFI_MEMORY_WP           ((uint64_t)0x0000000000001000ULL)    /* write-protect */
-#define EFI_MEMORY_RP           ((uint64_t)0x0000000000002000ULL)    /* read-protect */
-#define EFI_MEMORY_XP           ((uint64_t)0x0000000000004000ULL)    /* execute-protect */
-#define EFI_MEMORY_RUNTIME      ((uint64_t)0x8000000000000000ULL)    /* range requires runtime mapping */
-#define EFI_MEMORY_DESCRIPTOR_VERSION   1
-
-#define EFI_PAGE_SHIFT          12
-
-/*
- * For current x86 implementations of EFI, there is
- * additional padding in the mem descriptors.  This is not
- * the case in ia64.  Need to have this fixed in the f/w.
- */
-typedef struct {
-        uint32_t type;
-        uint32_t pad;
-        uint64_t phys_addr;
-        uint64_t virt_addr;
-        uint64_t num_pages;
-        uint64_t attribute;
-#if defined (__i386__)
-        uint64_t pad1;
-#endif
-} efi_memory_desc_t;
-
-/*
- * EFI Runtime Services table
- */
-#define EFI_RUNTIME_SERVICES_SIGNATURE	((uint64_t)0x5652453544e5552ULL)
-#define EFI_RUNTIME_SERVICES_REVISION	0x00010000
-
-typedef struct {
-	efi_table_hdr_t hdr;
-	unsigned long get_time;
-	unsigned long set_time;
-	unsigned long get_wakeup_time;
-	unsigned long set_wakeup_time;
-	unsigned long set_virtual_address_map;
-	unsigned long convert_pointer;
-	unsigned long get_variable;
-	unsigned long get_next_variable;
-	unsigned long set_variable;
-	unsigned long get_next_high_mono_count;
-	unsigned long reset_system;
-} efi_runtime_services_t;
-
-/*
- *  EFI Configuration Table and GUID definitions
- */
-#define NULL_GUID \
-    EFI_GUID(  0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 )
-#define ACPI_20_TABLE_GUID    \
-    EFI_GUID(  0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 )
-#define SAL_SYSTEM_TABLE_GUID    \
-    EFI_GUID(  0xeb9d2d32, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d )
-
-typedef struct {
-	efi_guid_t guid;
-	unsigned long table;
-} efi_config_table_t;
-
-#define EFI_SYSTEM_TABLE_SIGNATURE ((uint64_t)0x5453595320494249ULL)
-#define EFI_SYSTEM_TABLE_REVISION  ((1 << 16) | 00)
-
-typedef struct {
-	efi_table_hdr_t hdr;
-	unsigned long fw_vendor;	/* physical addr of CHAR16 vendor string */
-	uint32_t fw_revision;
-	unsigned long con_in_handle;
-	unsigned long con_in;
-	unsigned long con_out_handle;
-	unsigned long con_out;
-	unsigned long stderr_handle;
-	unsigned long stderr;
-	efi_runtime_services_t *runtime;
-	unsigned long boottime;
-	unsigned long nr_tables;
-	unsigned long tables;
-} efi_system_table_t;
-
-#endif /* XC_EFI_H */
diff --git a/tools/libxc/xc_elf.h b/tools/libxc/xc_elf.h
deleted file mode 100644
index acbc0280bd..0000000000
--- a/tools/libxc/xc_elf.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <xen/libelf/elfstructs.h>
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 11/31] tools/libxc: move xc_[un]map_domain_meminfo() into new source xg_domain.c
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (9 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 10/31] tools/libxc: remove unused headers xc_efi.h and xc_elf.h Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 12/31] tools/libxc: rename all libxenguest sources to xg_* Juergen Gross
                   ` (19 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu

Move xc_[un]map_domain_meminfo() functions to new source xg_domain.c as
they are defined in include/xenguest.h and should be in libxenguest.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
 tools/libxc/Makefile    |   4 +-
 tools/libxc/xc_domain.c | 126 ---------------------------------
 tools/libxc/xg_domain.c | 149 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 152 insertions(+), 127 deletions(-)
 create mode 100644 tools/libxc/xg_domain.c

diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile
index 763231065c..7b81f8c193 100644
--- a/tools/libxc/Makefile
+++ b/tools/libxc/Makefile
@@ -52,7 +52,9 @@ CTRL_SRCS-y       += xc_gnttab_compat.c
 CTRL_SRCS-y       += xc_devicemodel_compat.c
 
 GUEST_SRCS-y :=
-GUEST_SRCS-y += xg_private.c xc_suspend.c
+GUEST_SRCS-y += xg_private.c
+GUEST_SRCS-y += xg_domain.c
+GUEST_SRCS-y += xc_suspend.c
 ifeq ($(CONFIG_MIGRATE),y)
 GUEST_SRCS-y += xc_sr_common.c
 GUEST_SRCS-$(CONFIG_X86) += xc_sr_common_x86.c
diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
index 71829c2bce..fbc22c4df6 100644
--- a/tools/libxc/xc_domain.c
+++ b/tools/libxc/xc_domain.c
@@ -1892,132 +1892,6 @@ int xc_domain_unbind_pt_spi_irq(xc_interface *xch,
                                         PT_IRQ_TYPE_SPI, 0, 0, 0, 0, spi));
 }
 
-int xc_unmap_domain_meminfo(xc_interface *xch, struct xc_domain_meminfo *minfo)
-{
-    struct domain_info_context _di = { .guest_width = minfo->guest_width,
-                                       .p2m_size = minfo->p2m_size};
-    struct domain_info_context *dinfo = &_di;
-
-    free(minfo->pfn_type);
-    if ( minfo->p2m_table )
-        munmap(minfo->p2m_table, P2M_FL_ENTRIES * PAGE_SIZE);
-    minfo->p2m_table = NULL;
-
-    return 0;
-}
-
-int xc_map_domain_meminfo(xc_interface *xch, uint32_t domid,
-                          struct xc_domain_meminfo *minfo)
-{
-    struct domain_info_context _di;
-    struct domain_info_context *dinfo = &_di;
-
-    xc_dominfo_t info;
-    shared_info_any_t *live_shinfo;
-    xen_capabilities_info_t xen_caps = "";
-    int i;
-
-    /* Only be initialized once */
-    if ( minfo->pfn_type || minfo->p2m_table )
-    {
-        errno = EINVAL;
-        return -1;
-    }
-
-    if ( xc_domain_getinfo(xch, domid, 1, &info) != 1 )
-    {
-        PERROR("Could not get domain info");
-        return -1;
-    }
-
-    if ( xc_domain_get_guest_width(xch, domid, &minfo->guest_width) )
-    {
-        PERROR("Could not get domain address size");
-        return -1;
-    }
-    _di.guest_width = minfo->guest_width;
-
-    /* Get page table levels (see get_platform_info() in xg_save_restore.h */
-    if ( xc_version(xch, XENVER_capabilities, &xen_caps) )
-    {
-        PERROR("Could not get Xen capabilities (for page table levels)");
-        return -1;
-    }
-    if ( strstr(xen_caps, "xen-3.0-x86_64") )
-        /* Depends on whether it's a compat 32-on-64 guest */
-        minfo->pt_levels = ( (minfo->guest_width == 8) ? 4 : 3 );
-    else if ( strstr(xen_caps, "xen-3.0-x86_32p") )
-        minfo->pt_levels = 3;
-    else if ( strstr(xen_caps, "xen-3.0-x86_32") )
-        minfo->pt_levels = 2;
-    else
-    {
-        errno = EFAULT;
-        return -1;
-    }
-
-    /* We need the shared info page for mapping the P2M */
-    live_shinfo = xc_map_foreign_range(xch, domid, PAGE_SIZE, PROT_READ,
-                                       info.shared_info_frame);
-    if ( !live_shinfo )
-    {
-        PERROR("Could not map the shared info frame (MFN 0x%lx)",
-               info.shared_info_frame);
-        return -1;
-    }
-
-    if ( xc_core_arch_map_p2m_writable(xch, minfo->guest_width, &info,
-                                       live_shinfo, &minfo->p2m_table,
-                                       &minfo->p2m_size) )
-    {
-        PERROR("Could not map the P2M table");
-        munmap(live_shinfo, PAGE_SIZE);
-        return -1;
-    }
-    munmap(live_shinfo, PAGE_SIZE);
-    _di.p2m_size = minfo->p2m_size;
-
-    /* Make space and prepare for getting the PFN types */
-    minfo->pfn_type = calloc(sizeof(*minfo->pfn_type), minfo->p2m_size);
-    if ( !minfo->pfn_type )
-    {
-        PERROR("Could not allocate memory for the PFN types");
-        goto failed;
-    }
-    for ( i = 0; i < minfo->p2m_size; i++ )
-        minfo->pfn_type[i] = xc_pfn_to_mfn(i, minfo->p2m_table,
-                                           minfo->guest_width);
-
-    /* Retrieve PFN types in batches */
-    for ( i = 0; i < minfo->p2m_size ; i+=1024 )
-    {
-        int count = ((minfo->p2m_size - i ) > 1024 ) ?
-                        1024: (minfo->p2m_size - i);
-
-        if ( xc_get_pfn_type_batch(xch, domid, count, minfo->pfn_type + i) )
-        {
-            PERROR("Could not get %d-eth batch of PFN types", (i+1)/1024);
-            goto failed;
-        }
-    }
-
-    return 0;
-
-failed:
-    if ( minfo->pfn_type )
-    {
-        free(minfo->pfn_type);
-        minfo->pfn_type = NULL;
-    }
-    if ( minfo->p2m_table )
-    {
-        munmap(minfo->p2m_table, P2M_FL_ENTRIES * PAGE_SIZE);
-        minfo->p2m_table = NULL;
-    }
-
-    return -1;
-}
-
 int xc_domain_memory_mapping(
     xc_interface *xch,
     uint32_t domid,
diff --git a/tools/libxc/xg_domain.c b/tools/libxc/xg_domain.c
new file mode 100644
index 0000000000..58713cd35d
--- /dev/null
+++ b/tools/libxc/xg_domain.c
@@ -0,0 +1,149 @@
+/******************************************************************************
+ * xg_domain.c
+ *
+ * API for manipulating and obtaining information on domains.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (c) 2003, K A Fraser.
+ */
+
+#include "xg_private.h"
+#include "xc_core.h"
+
+int xc_unmap_domain_meminfo(xc_interface *xch, struct xc_domain_meminfo *minfo)
+{
+    struct domain_info_context _di = { .guest_width = minfo->guest_width,
+                                       .p2m_size = minfo->p2m_size};
+    struct domain_info_context *dinfo = &_di;
+
+    free(minfo->pfn_type);
+    if ( minfo->p2m_table )
+        munmap(minfo->p2m_table, P2M_FL_ENTRIES * PAGE_SIZE);
+    minfo->p2m_table = NULL;
+
+    return 0;
+}
+
+int xc_map_domain_meminfo(xc_interface *xch, uint32_t domid,
+                          struct xc_domain_meminfo *minfo)
+{
+    struct domain_info_context _di;
+    struct domain_info_context *dinfo = &_di;
+
+    xc_dominfo_t info;
+    shared_info_any_t *live_shinfo;
+    xen_capabilities_info_t xen_caps = "";
+    int i;
+
+    /* Only be initialized once */
+    if ( minfo->pfn_type || minfo->p2m_table )
+    {
+        errno = EINVAL;
+        return -1;
+    }
+
+    if ( xc_domain_getinfo(xch, domid, 1, &info) != 1 )
+    {
+        PERROR("Could not get domain info");
+        return -1;
+    }
+
+    if ( xc_domain_get_guest_width(xch, domid, &minfo->guest_width) )
+    {
+        PERROR("Could not get domain address size");
+        return -1;
+    }
+    _di.guest_width = minfo->guest_width;
+
+    /* Get page table levels (see get_platform_info() in xg_save_restore.h */
+    if ( xc_version(xch, XENVER_capabilities, &xen_caps) )
+    {
+        PERROR("Could not get Xen capabilities (for page table levels)");
+        return -1;
+    }
+    if ( strstr(xen_caps, "xen-3.0-x86_64") )
+        /* Depends on whether it's a compat 32-on-64 guest */
+        minfo->pt_levels = ( (minfo->guest_width == 8) ? 4 : 3 );
+    else if ( strstr(xen_caps, "xen-3.0-x86_32p") )
+        minfo->pt_levels = 3;
+    else if ( strstr(xen_caps, "xen-3.0-x86_32") )
+        minfo->pt_levels = 2;
+    else
+    {
+        errno = EFAULT;
+        return -1;
+    }
+
+    /* We need the shared info page for mapping the P2M */
+    live_shinfo = xc_map_foreign_range(xch, domid, PAGE_SIZE, PROT_READ,
+                                       info.shared_info_frame);
+    if ( !live_shinfo )
+    {
+        PERROR("Could not map the shared info frame (MFN 0x%lx)",
+               info.shared_info_frame);
+        return -1;
+    }
+
+    if ( xc_core_arch_map_p2m_writable(xch, minfo->guest_width, &info,
+                                       live_shinfo, &minfo->p2m_table,
+                                       &minfo->p2m_size) )
+    {
+        PERROR("Could not map the P2M table");
+        munmap(live_shinfo, PAGE_SIZE);
+        return -1;
+    }
+    munmap(live_shinfo, PAGE_SIZE);
+    _di.p2m_size = minfo->p2m_size;
+
+    /* Make space and prepare for getting the PFN types */
+    minfo->pfn_type = calloc(sizeof(*minfo->pfn_type), minfo->p2m_size);
+    if ( !minfo->pfn_type )
+    {
+        PERROR("Could not allocate memory for the PFN types");
+        goto failed;
+    }
+    for ( i = 0; i < minfo->p2m_size; i++ )
+        minfo->pfn_type[i] = xc_pfn_to_mfn(i, minfo->p2m_table,
+                                           minfo->guest_width);
+
+    /* Retrieve PFN types in batches */
+    for ( i = 0; i < minfo->p2m_size ; i+=1024 )
+    {
+        int count = ((minfo->p2m_size - i ) > 1024 ) ?
+                        1024: (minfo->p2m_size - i);
+
+        if ( xc_get_pfn_type_batch(xch, domid, count, minfo->pfn_type + i) )
+        {
+            PERROR("Could not get %d-eth batch of PFN types", (i+1)/1024);
+            goto failed;
+        }
+    }
+
+    return 0;
+
+failed:
+    if ( minfo->pfn_type )
+    {
+        free(minfo->pfn_type);
+        minfo->pfn_type = NULL;
+    }
+    if ( minfo->p2m_table )
+    {
+        munmap(minfo->p2m_table, P2M_FL_ENTRIES * PAGE_SIZE);
+        minfo->p2m_table = NULL;
+    }
+
+    return -1;
+}
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 12/31] tools/libxc: rename all libxenguest sources to xg_*
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (10 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 11/31] tools/libxc: move xc_[un]map_domain_meminfo() into new source xg_domain.c Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 13/31] tools/libxc: rename libxenguest internal headers Juergen Gross
                   ` (18 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu

Some sources of libxenguest are named xg_*.c and some xc_*.c. Rename
the xc_*.c files to xg_*.c.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
 tools/libxc/Makefile                          | 59 ++++++++++---------
 .../libxc/{xc_cpuid_x86.c => xg_cpuid_x86.c}  |  0
 tools/libxc/{xc_dom_arm.c => xg_dom_arm.c}    |  0
 ...imageloader.c => xg_dom_armzimageloader.c} |  0
 ...{xc_dom_binloader.c => xg_dom_binloader.c} |  0
 tools/libxc/{xc_dom_boot.c => xg_dom_boot.c}  |  0
 ...bzimageloader.c => xg_dom_bzimageloader.c} |  0
 ...m_compat_linux.c => xg_dom_compat_linux.c} |  0
 tools/libxc/{xc_dom_core.c => xg_dom_core.c}  |  0
 ...compress_lz4.c => xg_dom_decompress_lz4.c} |  0
 ...ss_unsafe.c => xg_dom_decompress_unsafe.c} |  0
 ...ip2.c => xg_dom_decompress_unsafe_bzip2.c} |  0
 ...lzma.c => xg_dom_decompress_unsafe_lzma.c} |  0
 ...o1x.c => xg_dom_decompress_unsafe_lzo1x.c} |  0
 ...afe_xz.c => xg_dom_decompress_unsafe_xz.c} |  0
 ...{xc_dom_elfloader.c => xg_dom_elfloader.c} |  0
 ...{xc_dom_hvmloader.c => xg_dom_hvmloader.c} |  0
 tools/libxc/{xc_dom_x86.c => xg_dom_x86.c}    |  0
 .../libxc/{xc_nomigrate.c => xg_nomigrate.c}  |  0
 .../{xc_offline_page.c => xg_offline_page.c}  |  0
 .../libxc/{xc_sr_common.c => xg_sr_common.c}  |  0
 ...{xc_sr_common_x86.c => xg_sr_common_x86.c} |  0
 ..._common_x86_pv.c => xg_sr_common_x86_pv.c} |  0
 .../{xc_sr_restore.c => xg_sr_restore.c}      |  0
 ...tore_x86_hvm.c => xg_sr_restore_x86_hvm.c} |  0
 ...estore_x86_pv.c => xg_sr_restore_x86_pv.c} |  0
 tools/libxc/{xc_sr_save.c => xg_sr_save.c}    |  0
 ...sr_save_x86_hvm.c => xg_sr_save_x86_hvm.c} |  0
 ...c_sr_save_x86_pv.c => xg_sr_save_x86_pv.c} |  0
 tools/libxc/{xc_suspend.c => xg_suspend.c}    |  0
 30 files changed, 30 insertions(+), 29 deletions(-)
 rename tools/libxc/{xc_cpuid_x86.c => xg_cpuid_x86.c} (100%)
 rename tools/libxc/{xc_dom_arm.c => xg_dom_arm.c} (100%)
 rename tools/libxc/{xc_dom_armzimageloader.c => xg_dom_armzimageloader.c} (100%)
 rename tools/libxc/{xc_dom_binloader.c => xg_dom_binloader.c} (100%)
 rename tools/libxc/{xc_dom_boot.c => xg_dom_boot.c} (100%)
 rename tools/libxc/{xc_dom_bzimageloader.c => xg_dom_bzimageloader.c} (100%)
 rename tools/libxc/{xc_dom_compat_linux.c => xg_dom_compat_linux.c} (100%)
 rename tools/libxc/{xc_dom_core.c => xg_dom_core.c} (100%)
 rename tools/libxc/{xc_dom_decompress_lz4.c => xg_dom_decompress_lz4.c} (100%)
 rename tools/libxc/{xc_dom_decompress_unsafe.c => xg_dom_decompress_unsafe.c} (100%)
 rename tools/libxc/{xc_dom_decompress_unsafe_bzip2.c => xg_dom_decompress_unsafe_bzip2.c} (100%)
 rename tools/libxc/{xc_dom_decompress_unsafe_lzma.c => xg_dom_decompress_unsafe_lzma.c} (100%)
 rename tools/libxc/{xc_dom_decompress_unsafe_lzo1x.c => xg_dom_decompress_unsafe_lzo1x.c} (100%)
 rename tools/libxc/{xc_dom_decompress_unsafe_xz.c => xg_dom_decompress_unsafe_xz.c} (100%)
 rename tools/libxc/{xc_dom_elfloader.c => xg_dom_elfloader.c} (100%)
 rename tools/libxc/{xc_dom_hvmloader.c => xg_dom_hvmloader.c} (100%)
 rename tools/libxc/{xc_dom_x86.c => xg_dom_x86.c} (100%)
 rename tools/libxc/{xc_nomigrate.c => xg_nomigrate.c} (100%)
 rename tools/libxc/{xc_offline_page.c => xg_offline_page.c} (100%)
 rename tools/libxc/{xc_sr_common.c => xg_sr_common.c} (100%)
 rename tools/libxc/{xc_sr_common_x86.c => xg_sr_common_x86.c} (100%)
 rename tools/libxc/{xc_sr_common_x86_pv.c => xg_sr_common_x86_pv.c} (100%)
 rename tools/libxc/{xc_sr_restore.c => xg_sr_restore.c} (100%)
 rename tools/libxc/{xc_sr_restore_x86_hvm.c => xg_sr_restore_x86_hvm.c} (100%)
 rename tools/libxc/{xc_sr_restore_x86_pv.c => xg_sr_restore_x86_pv.c} (100%)
 rename tools/libxc/{xc_sr_save.c => xg_sr_save.c} (100%)
 rename tools/libxc/{xc_sr_save_x86_hvm.c => xg_sr_save_x86_hvm.c} (100%)
 rename tools/libxc/{xc_sr_save_x86_pv.c => xg_sr_save_x86_pv.c} (100%)
 rename tools/libxc/{xc_suspend.c => xg_suspend.c} (100%)

diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile
index 7b81f8c193..0fd5511143 100644
--- a/tools/libxc/Makefile
+++ b/tools/libxc/Makefile
@@ -54,20 +54,20 @@ CTRL_SRCS-y       += xc_devicemodel_compat.c
 GUEST_SRCS-y :=
 GUEST_SRCS-y += xg_private.c
 GUEST_SRCS-y += xg_domain.c
-GUEST_SRCS-y += xc_suspend.c
+GUEST_SRCS-y += xg_suspend.c
 ifeq ($(CONFIG_MIGRATE),y)
-GUEST_SRCS-y += xc_sr_common.c
-GUEST_SRCS-$(CONFIG_X86) += xc_sr_common_x86.c
-GUEST_SRCS-$(CONFIG_X86) += xc_sr_common_x86_pv.c
-GUEST_SRCS-$(CONFIG_X86) += xc_sr_restore_x86_pv.c
-GUEST_SRCS-$(CONFIG_X86) += xc_sr_restore_x86_hvm.c
-GUEST_SRCS-$(CONFIG_X86) += xc_sr_save_x86_pv.c
-GUEST_SRCS-$(CONFIG_X86) += xc_sr_save_x86_hvm.c
-GUEST_SRCS-y += xc_sr_restore.c
-GUEST_SRCS-y += xc_sr_save.c
-GUEST_SRCS-y += xc_offline_page.c
+GUEST_SRCS-y += xg_sr_common.c
+GUEST_SRCS-$(CONFIG_X86) += xg_sr_common_x86.c
+GUEST_SRCS-$(CONFIG_X86) += xg_sr_common_x86_pv.c
+GUEST_SRCS-$(CONFIG_X86) += xg_sr_restore_x86_pv.c
+GUEST_SRCS-$(CONFIG_X86) += xg_sr_restore_x86_hvm.c
+GUEST_SRCS-$(CONFIG_X86) += xg_sr_save_x86_pv.c
+GUEST_SRCS-$(CONFIG_X86) += xg_sr_save_x86_hvm.c
+GUEST_SRCS-y += xg_sr_restore.c
+GUEST_SRCS-y += xg_sr_save.c
+GUEST_SRCS-y += xg_offline_page.c
 else
-GUEST_SRCS-y += xc_nomigrate.c
+GUEST_SRCS-y += xg_nomigrate.c
 endif
 
 vpath %.c ../../xen/common/libelf
@@ -88,25 +88,26 @@ GUEST_SRCS-y                 += cpuid.c msr.c
 endif
 
 # new domain builder
-GUEST_SRCS-y                 += xc_dom_core.c xc_dom_boot.c
-GUEST_SRCS-y                 += xc_dom_elfloader.c
-GUEST_SRCS-$(CONFIG_X86)     += xc_dom_bzimageloader.c
-GUEST_SRCS-$(CONFIG_X86)     += xc_dom_decompress_lz4.c
-GUEST_SRCS-$(CONFIG_X86)     += xc_dom_hvmloader.c
-GUEST_SRCS-$(CONFIG_ARM)     += xc_dom_armzimageloader.c
-GUEST_SRCS-y                 += xc_dom_binloader.c
-GUEST_SRCS-y                 += xc_dom_compat_linux.c
-
-GUEST_SRCS-$(CONFIG_X86)     += xc_dom_x86.c
-GUEST_SRCS-$(CONFIG_X86)     += xc_cpuid_x86.c
-GUEST_SRCS-$(CONFIG_ARM)     += xc_dom_arm.c
+GUEST_SRCS-y                 += xg_dom_core.c
+GUEST_SRCS-y                 += xg_dom_boot.c
+GUEST_SRCS-y                 += xg_dom_elfloader.c
+GUEST_SRCS-$(CONFIG_X86)     += xg_dom_bzimageloader.c
+GUEST_SRCS-$(CONFIG_X86)     += xg_dom_decompress_lz4.c
+GUEST_SRCS-$(CONFIG_X86)     += xg_dom_hvmloader.c
+GUEST_SRCS-$(CONFIG_ARM)     += xg_dom_armzimageloader.c
+GUEST_SRCS-y                 += xg_dom_binloader.c
+GUEST_SRCS-y                 += xg_dom_compat_linux.c
+
+GUEST_SRCS-$(CONFIG_X86)     += xg_dom_x86.c
+GUEST_SRCS-$(CONFIG_X86)     += xg_cpuid_x86.c
+GUEST_SRCS-$(CONFIG_ARM)     += xg_dom_arm.c
 
 ifeq ($(CONFIG_LIBXC_MINIOS),y)
-GUEST_SRCS-y                 += xc_dom_decompress_unsafe.c
-GUEST_SRCS-y                 += xc_dom_decompress_unsafe_bzip2.c
-GUEST_SRCS-y                 += xc_dom_decompress_unsafe_lzma.c
-GUEST_SRCS-y                 += xc_dom_decompress_unsafe_lzo1x.c
-GUEST_SRCS-y                 += xc_dom_decompress_unsafe_xz.c
+GUEST_SRCS-y                 += xg_dom_decompress_unsafe.c
+GUEST_SRCS-y                 += xg_dom_decompress_unsafe_bzip2.c
+GUEST_SRCS-y                 += xg_dom_decompress_unsafe_lzma.c
+GUEST_SRCS-y                 += xg_dom_decompress_unsafe_lzo1x.c
+GUEST_SRCS-y                 += xg_dom_decompress_unsafe_xz.c
 endif
 
 -include $(XEN_TARGET_ARCH)/Makefile
diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xg_cpuid_x86.c
similarity index 100%
rename from tools/libxc/xc_cpuid_x86.c
rename to tools/libxc/xg_cpuid_x86.c
diff --git a/tools/libxc/xc_dom_arm.c b/tools/libxc/xg_dom_arm.c
similarity index 100%
rename from tools/libxc/xc_dom_arm.c
rename to tools/libxc/xg_dom_arm.c
diff --git a/tools/libxc/xc_dom_armzimageloader.c b/tools/libxc/xg_dom_armzimageloader.c
similarity index 100%
rename from tools/libxc/xc_dom_armzimageloader.c
rename to tools/libxc/xg_dom_armzimageloader.c
diff --git a/tools/libxc/xc_dom_binloader.c b/tools/libxc/xg_dom_binloader.c
similarity index 100%
rename from tools/libxc/xc_dom_binloader.c
rename to tools/libxc/xg_dom_binloader.c
diff --git a/tools/libxc/xc_dom_boot.c b/tools/libxc/xg_dom_boot.c
similarity index 100%
rename from tools/libxc/xc_dom_boot.c
rename to tools/libxc/xg_dom_boot.c
diff --git a/tools/libxc/xc_dom_bzimageloader.c b/tools/libxc/xg_dom_bzimageloader.c
similarity index 100%
rename from tools/libxc/xc_dom_bzimageloader.c
rename to tools/libxc/xg_dom_bzimageloader.c
diff --git a/tools/libxc/xc_dom_compat_linux.c b/tools/libxc/xg_dom_compat_linux.c
similarity index 100%
rename from tools/libxc/xc_dom_compat_linux.c
rename to tools/libxc/xg_dom_compat_linux.c
diff --git a/tools/libxc/xc_dom_core.c b/tools/libxc/xg_dom_core.c
similarity index 100%
rename from tools/libxc/xc_dom_core.c
rename to tools/libxc/xg_dom_core.c
diff --git a/tools/libxc/xc_dom_decompress_lz4.c b/tools/libxc/xg_dom_decompress_lz4.c
similarity index 100%
rename from tools/libxc/xc_dom_decompress_lz4.c
rename to tools/libxc/xg_dom_decompress_lz4.c
diff --git a/tools/libxc/xc_dom_decompress_unsafe.c b/tools/libxc/xg_dom_decompress_unsafe.c
similarity index 100%
rename from tools/libxc/xc_dom_decompress_unsafe.c
rename to tools/libxc/xg_dom_decompress_unsafe.c
diff --git a/tools/libxc/xc_dom_decompress_unsafe_bzip2.c b/tools/libxc/xg_dom_decompress_unsafe_bzip2.c
similarity index 100%
rename from tools/libxc/xc_dom_decompress_unsafe_bzip2.c
rename to tools/libxc/xg_dom_decompress_unsafe_bzip2.c
diff --git a/tools/libxc/xc_dom_decompress_unsafe_lzma.c b/tools/libxc/xg_dom_decompress_unsafe_lzma.c
similarity index 100%
rename from tools/libxc/xc_dom_decompress_unsafe_lzma.c
rename to tools/libxc/xg_dom_decompress_unsafe_lzma.c
diff --git a/tools/libxc/xc_dom_decompress_unsafe_lzo1x.c b/tools/libxc/xg_dom_decompress_unsafe_lzo1x.c
similarity index 100%
rename from tools/libxc/xc_dom_decompress_unsafe_lzo1x.c
rename to tools/libxc/xg_dom_decompress_unsafe_lzo1x.c
diff --git a/tools/libxc/xc_dom_decompress_unsafe_xz.c b/tools/libxc/xg_dom_decompress_unsafe_xz.c
similarity index 100%
rename from tools/libxc/xc_dom_decompress_unsafe_xz.c
rename to tools/libxc/xg_dom_decompress_unsafe_xz.c
diff --git a/tools/libxc/xc_dom_elfloader.c b/tools/libxc/xg_dom_elfloader.c
similarity index 100%
rename from tools/libxc/xc_dom_elfloader.c
rename to tools/libxc/xg_dom_elfloader.c
diff --git a/tools/libxc/xc_dom_hvmloader.c b/tools/libxc/xg_dom_hvmloader.c
similarity index 100%
rename from tools/libxc/xc_dom_hvmloader.c
rename to tools/libxc/xg_dom_hvmloader.c
diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xg_dom_x86.c
similarity index 100%
rename from tools/libxc/xc_dom_x86.c
rename to tools/libxc/xg_dom_x86.c
diff --git a/tools/libxc/xc_nomigrate.c b/tools/libxc/xg_nomigrate.c
similarity index 100%
rename from tools/libxc/xc_nomigrate.c
rename to tools/libxc/xg_nomigrate.c
diff --git a/tools/libxc/xc_offline_page.c b/tools/libxc/xg_offline_page.c
similarity index 100%
rename from tools/libxc/xc_offline_page.c
rename to tools/libxc/xg_offline_page.c
diff --git a/tools/libxc/xc_sr_common.c b/tools/libxc/xg_sr_common.c
similarity index 100%
rename from tools/libxc/xc_sr_common.c
rename to tools/libxc/xg_sr_common.c
diff --git a/tools/libxc/xc_sr_common_x86.c b/tools/libxc/xg_sr_common_x86.c
similarity index 100%
rename from tools/libxc/xc_sr_common_x86.c
rename to tools/libxc/xg_sr_common_x86.c
diff --git a/tools/libxc/xc_sr_common_x86_pv.c b/tools/libxc/xg_sr_common_x86_pv.c
similarity index 100%
rename from tools/libxc/xc_sr_common_x86_pv.c
rename to tools/libxc/xg_sr_common_x86_pv.c
diff --git a/tools/libxc/xc_sr_restore.c b/tools/libxc/xg_sr_restore.c
similarity index 100%
rename from tools/libxc/xc_sr_restore.c
rename to tools/libxc/xg_sr_restore.c
diff --git a/tools/libxc/xc_sr_restore_x86_hvm.c b/tools/libxc/xg_sr_restore_x86_hvm.c
similarity index 100%
rename from tools/libxc/xc_sr_restore_x86_hvm.c
rename to tools/libxc/xg_sr_restore_x86_hvm.c
diff --git a/tools/libxc/xc_sr_restore_x86_pv.c b/tools/libxc/xg_sr_restore_x86_pv.c
similarity index 100%
rename from tools/libxc/xc_sr_restore_x86_pv.c
rename to tools/libxc/xg_sr_restore_x86_pv.c
diff --git a/tools/libxc/xc_sr_save.c b/tools/libxc/xg_sr_save.c
similarity index 100%
rename from tools/libxc/xc_sr_save.c
rename to tools/libxc/xg_sr_save.c
diff --git a/tools/libxc/xc_sr_save_x86_hvm.c b/tools/libxc/xg_sr_save_x86_hvm.c
similarity index 100%
rename from tools/libxc/xc_sr_save_x86_hvm.c
rename to tools/libxc/xg_sr_save_x86_hvm.c
diff --git a/tools/libxc/xc_sr_save_x86_pv.c b/tools/libxc/xg_sr_save_x86_pv.c
similarity index 100%
rename from tools/libxc/xc_sr_save_x86_pv.c
rename to tools/libxc/xg_sr_save_x86_pv.c
diff --git a/tools/libxc/xc_suspend.c b/tools/libxc/xg_suspend.c
similarity index 100%
rename from tools/libxc/xc_suspend.c
rename to tools/libxc/xg_suspend.c
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 13/31] tools/libxc: rename libxenguest internal headers
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (11 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 12/31] tools/libxc: rename all libxenguest sources to xg_* Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 14/31] tools/misc: rename xc_dom.h do xenctrl_dom.h Juergen Gross
                   ` (17 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu

Rename the header files private to libxenguest from xc_*.h to xg_*.h.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
 tools/libxc/xg_dom_bzimageloader.c                              | 2 +-
 tools/libxc/{xc_dom_decompress.h => xg_dom_decompress.h}        | 2 +-
 tools/libxc/xg_dom_decompress_lz4.c                             | 2 +-
 tools/libxc/xg_dom_decompress_unsafe.c                          | 2 +-
 .../{xc_dom_decompress_unsafe.h => xg_dom_decompress_unsafe.h}  | 0
 tools/libxc/xg_dom_decompress_unsafe_bzip2.c                    | 2 +-
 tools/libxc/xg_dom_decompress_unsafe_lzma.c                     | 2 +-
 tools/libxc/xg_dom_decompress_unsafe_lzo1x.c                    | 2 +-
 tools/libxc/xg_dom_decompress_unsafe_xz.c                       | 2 +-
 tools/libxc/xg_sr_common.c                                      | 2 +-
 tools/libxc/{xc_sr_common.h => xg_sr_common.h}                  | 2 +-
 tools/libxc/xg_sr_common_x86.c                                  | 2 +-
 tools/libxc/{xc_sr_common_x86.h => xg_sr_common_x86.h}          | 2 +-
 tools/libxc/xg_sr_common_x86_pv.c                               | 2 +-
 tools/libxc/{xc_sr_common_x86_pv.h => xg_sr_common_x86_pv.h}    | 2 +-
 tools/libxc/xg_sr_restore.c                                     | 2 +-
 tools/libxc/xg_sr_restore_x86_hvm.c                             | 2 +-
 tools/libxc/xg_sr_restore_x86_pv.c                              | 2 +-
 tools/libxc/xg_sr_save.c                                        | 2 +-
 tools/libxc/xg_sr_save_x86_hvm.c                                | 2 +-
 tools/libxc/xg_sr_save_x86_pv.c                                 | 2 +-
 tools/libxc/{xc_sr_stream_format.h => xg_sr_stream_format.h}    | 0
 22 files changed, 20 insertions(+), 20 deletions(-)
 rename tools/libxc/{xc_dom_decompress.h => xg_dom_decompress.h} (77%)
 rename tools/libxc/{xc_dom_decompress_unsafe.h => xg_dom_decompress_unsafe.h} (100%)
 rename tools/libxc/{xc_sr_common.h => xg_sr_common.h} (99%)
 rename tools/libxc/{xc_sr_common_x86.h => xg_sr_common_x86.h} (98%)
 rename tools/libxc/{xc_sr_common_x86_pv.h => xg_sr_common_x86_pv.h} (98%)
 rename tools/libxc/{xc_sr_stream_format.h => xg_sr_stream_format.h} (100%)

diff --git a/tools/libxc/xg_dom_bzimageloader.c b/tools/libxc/xg_dom_bzimageloader.c
index a7d70cc7c6..f959a77602 100644
--- a/tools/libxc/xg_dom_bzimageloader.c
+++ b/tools/libxc/xg_dom_bzimageloader.c
@@ -32,7 +32,7 @@
 #include <inttypes.h>
 
 #include "xg_private.h"
-#include "xc_dom_decompress.h"
+#include "xg_dom_decompress.h"
 
 #include <xen-tools/libs.h>
 
diff --git a/tools/libxc/xc_dom_decompress.h b/tools/libxc/xg_dom_decompress.h
similarity index 77%
rename from tools/libxc/xc_dom_decompress.h
rename to tools/libxc/xg_dom_decompress.h
index 42cefa3f0e..d9a21cf297 100644
--- a/tools/libxc/xc_dom_decompress.h
+++ b/tools/libxc/xg_dom_decompress.h
@@ -1,7 +1,7 @@
 #ifndef __MINIOS__
 # include "xc_dom.h"
 #else
-# include "xc_dom_decompress_unsafe.h"
+# include "xg_dom_decompress_unsafe.h"
 #endif
 
 int xc_try_lz4_decode(struct xc_dom_image *dom, void **blob, size_t *size);
diff --git a/tools/libxc/xg_dom_decompress_lz4.c b/tools/libxc/xg_dom_decompress_lz4.c
index b6a33f27a8..97ba620d86 100644
--- a/tools/libxc/xg_dom_decompress_lz4.c
+++ b/tools/libxc/xg_dom_decompress_lz4.c
@@ -4,7 +4,7 @@
 #include <stdint.h>
 
 #include "xg_private.h"
-#include "xc_dom_decompress.h"
+#include "xg_dom_decompress.h"
 
 #define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
 
diff --git a/tools/libxc/xg_dom_decompress_unsafe.c b/tools/libxc/xg_dom_decompress_unsafe.c
index 164e35558f..21d964787d 100644
--- a/tools/libxc/xg_dom_decompress_unsafe.c
+++ b/tools/libxc/xg_dom_decompress_unsafe.c
@@ -3,7 +3,7 @@
 #include <inttypes.h>
 
 #include "xg_private.h"
-#include "xc_dom_decompress_unsafe.h"
+#include "xg_dom_decompress_unsafe.h"
 
 static struct xc_dom_image *unsafe_dom;
 static unsigned char *output_blob;
diff --git a/tools/libxc/xc_dom_decompress_unsafe.h b/tools/libxc/xg_dom_decompress_unsafe.h
similarity index 100%
rename from tools/libxc/xc_dom_decompress_unsafe.h
rename to tools/libxc/xg_dom_decompress_unsafe.h
diff --git a/tools/libxc/xg_dom_decompress_unsafe_bzip2.c b/tools/libxc/xg_dom_decompress_unsafe_bzip2.c
index 4dcabe4061..9d3709e6cc 100644
--- a/tools/libxc/xg_dom_decompress_unsafe_bzip2.c
+++ b/tools/libxc/xg_dom_decompress_unsafe_bzip2.c
@@ -3,7 +3,7 @@
 #include <inttypes.h>
 
 #include "xg_private.h"
-#include "xc_dom_decompress_unsafe.h"
+#include "xg_dom_decompress_unsafe.h"
 
 #include "../../xen/common/bunzip2.c"
 
diff --git a/tools/libxc/xg_dom_decompress_unsafe_lzma.c b/tools/libxc/xg_dom_decompress_unsafe_lzma.c
index 4ee8cdbab1..5d178f0c43 100644
--- a/tools/libxc/xg_dom_decompress_unsafe_lzma.c
+++ b/tools/libxc/xg_dom_decompress_unsafe_lzma.c
@@ -3,7 +3,7 @@
 #include <inttypes.h>
 
 #include "xg_private.h"
-#include "xc_dom_decompress_unsafe.h"
+#include "xg_dom_decompress_unsafe.h"
 
 #include "../../xen/common/unlzma.c"
 
diff --git a/tools/libxc/xg_dom_decompress_unsafe_lzo1x.c b/tools/libxc/xg_dom_decompress_unsafe_lzo1x.c
index 59888b9da2..a4f8ebd42d 100644
--- a/tools/libxc/xg_dom_decompress_unsafe_lzo1x.c
+++ b/tools/libxc/xg_dom_decompress_unsafe_lzo1x.c
@@ -5,7 +5,7 @@
 #include <stdint.h>
 
 #include "xg_private.h"
-#include "xc_dom_decompress_unsafe.h"
+#include "xg_dom_decompress_unsafe.h"
 
 typedef uint8_t u8;
 typedef uint32_t u32;
diff --git a/tools/libxc/xg_dom_decompress_unsafe_xz.c b/tools/libxc/xg_dom_decompress_unsafe_xz.c
index fe7a7f49b4..ff6824b38d 100644
--- a/tools/libxc/xg_dom_decompress_unsafe_xz.c
+++ b/tools/libxc/xg_dom_decompress_unsafe_xz.c
@@ -6,7 +6,7 @@
 #include <inttypes.h>
 
 #include "xg_private.h"
-#include "xc_dom_decompress_unsafe.h"
+#include "xg_dom_decompress_unsafe.h"
 
 // TODO
 #define XZ_DEC_X86
diff --git a/tools/libxc/xg_sr_common.c b/tools/libxc/xg_sr_common.c
index 7c54b03414..17567ab133 100644
--- a/tools/libxc/xg_sr_common.c
+++ b/tools/libxc/xg_sr_common.c
@@ -1,6 +1,6 @@
 #include <assert.h>
 
-#include "xc_sr_common.h"
+#include "xg_sr_common.h"
 
 #include <xen-tools/libs.h>
 
diff --git a/tools/libxc/xc_sr_common.h b/tools/libxc/xg_sr_common.h
similarity index 99%
rename from tools/libxc/xc_sr_common.h
rename to tools/libxc/xg_sr_common.h
index f3bdea8006..35f23fabb5 100644
--- a/tools/libxc/xc_sr_common.h
+++ b/tools/libxc/xg_sr_common.h
@@ -8,7 +8,7 @@
 #include "xc_dom.h"
 #include "xc_bitops.h"
 
-#include "xc_sr_stream_format.h"
+#include "xg_sr_stream_format.h"
 
 /* String representation of Domain Header types. */
 const char *dhdr_type_to_str(uint32_t type);
diff --git a/tools/libxc/xg_sr_common_x86.c b/tools/libxc/xg_sr_common_x86.c
index 77ea044a74..6f12483907 100644
--- a/tools/libxc/xg_sr_common_x86.c
+++ b/tools/libxc/xg_sr_common_x86.c
@@ -1,4 +1,4 @@
-#include "xc_sr_common_x86.h"
+#include "xg_sr_common_x86.h"
 
 int write_x86_tsc_info(struct xc_sr_context *ctx)
 {
diff --git a/tools/libxc/xc_sr_common_x86.h b/tools/libxc/xg_sr_common_x86.h
similarity index 98%
rename from tools/libxc/xc_sr_common_x86.h
rename to tools/libxc/xg_sr_common_x86.h
index e08d81e0e7..b55758c96d 100644
--- a/tools/libxc/xc_sr_common_x86.h
+++ b/tools/libxc/xg_sr_common_x86.h
@@ -1,7 +1,7 @@
 #ifndef __COMMON_X86__H
 #define __COMMON_X86__H
 
-#include "xc_sr_common.h"
+#include "xg_sr_common.h"
 
 /*
  * Obtains a domains TSC information from Xen and writes a X86_TSC_INFO record
diff --git a/tools/libxc/xg_sr_common_x86_pv.c b/tools/libxc/xg_sr_common_x86_pv.c
index d3d425cb82..cd33406aab 100644
--- a/tools/libxc/xg_sr_common_x86_pv.c
+++ b/tools/libxc/xg_sr_common_x86_pv.c
@@ -1,6 +1,6 @@
 #include <assert.h>
 
-#include "xc_sr_common_x86_pv.h"
+#include "xg_sr_common_x86_pv.h"
 
 xen_pfn_t mfn_to_pfn(struct xc_sr_context *ctx, xen_pfn_t mfn)
 {
diff --git a/tools/libxc/xc_sr_common_x86_pv.h b/tools/libxc/xg_sr_common_x86_pv.h
similarity index 98%
rename from tools/libxc/xc_sr_common_x86_pv.h
rename to tools/libxc/xg_sr_common_x86_pv.h
index 2ed03309af..953b5bfb8d 100644
--- a/tools/libxc/xc_sr_common_x86_pv.h
+++ b/tools/libxc/xg_sr_common_x86_pv.h
@@ -1,7 +1,7 @@
 #ifndef __COMMON_X86_PV_H
 #define __COMMON_X86_PV_H
 
-#include "xc_sr_common_x86.h"
+#include "xg_sr_common_x86.h"
 
 /* Virtual address ranges reserved for hypervisor. */
 #define HYPERVISOR_VIRT_START_X86_64 0xFFFF800000000000ULL
diff --git a/tools/libxc/xg_sr_restore.c b/tools/libxc/xg_sr_restore.c
index bc811e6e3a..b57a787519 100644
--- a/tools/libxc/xg_sr_restore.c
+++ b/tools/libxc/xg_sr_restore.c
@@ -2,7 +2,7 @@
 
 #include <assert.h>
 
-#include "xc_sr_common.h"
+#include "xg_sr_common.h"
 
 /*
  * Read and validate the Image and Domain headers.
diff --git a/tools/libxc/xg_sr_restore_x86_hvm.c b/tools/libxc/xg_sr_restore_x86_hvm.c
index a77624cc9d..d6ea6f3012 100644
--- a/tools/libxc/xg_sr_restore_x86_hvm.c
+++ b/tools/libxc/xg_sr_restore_x86_hvm.c
@@ -1,7 +1,7 @@
 #include <assert.h>
 #include <arpa/inet.h>
 
-#include "xc_sr_common_x86.h"
+#include "xg_sr_common_x86.h"
 
 /*
  * Process an HVM_CONTEXT record from the stream.
diff --git a/tools/libxc/xg_sr_restore_x86_pv.c b/tools/libxc/xg_sr_restore_x86_pv.c
index d086271efb..dc50b0f5a8 100644
--- a/tools/libxc/xg_sr_restore_x86_pv.c
+++ b/tools/libxc/xg_sr_restore_x86_pv.c
@@ -1,6 +1,6 @@
 #include <assert.h>
 
-#include "xc_sr_common_x86_pv.h"
+#include "xg_sr_common_x86_pv.h"
 
 static xen_pfn_t pfn_to_mfn(const struct xc_sr_context *ctx, xen_pfn_t pfn)
 {
diff --git a/tools/libxc/xg_sr_save.c b/tools/libxc/xg_sr_save.c
index 80b1d5de1f..d74c72cba6 100644
--- a/tools/libxc/xg_sr_save.c
+++ b/tools/libxc/xg_sr_save.c
@@ -1,7 +1,7 @@
 #include <assert.h>
 #include <arpa/inet.h>
 
-#include "xc_sr_common.h"
+#include "xg_sr_common.h"
 
 /*
  * Writes an Image header and Domain header into the stream.
diff --git a/tools/libxc/xg_sr_save_x86_hvm.c b/tools/libxc/xg_sr_save_x86_hvm.c
index 0b2abb26bd..1634a7bc43 100644
--- a/tools/libxc/xg_sr_save_x86_hvm.c
+++ b/tools/libxc/xg_sr_save_x86_hvm.c
@@ -1,6 +1,6 @@
 #include <assert.h>
 
-#include "xc_sr_common_x86.h"
+#include "xg_sr_common_x86.h"
 
 #include <xen/hvm/params.h>
 
diff --git a/tools/libxc/xg_sr_save_x86_pv.c b/tools/libxc/xg_sr_save_x86_pv.c
index c7e246ef4f..4964f1f7b8 100644
--- a/tools/libxc/xg_sr_save_x86_pv.c
+++ b/tools/libxc/xg_sr_save_x86_pv.c
@@ -1,7 +1,7 @@
 #include <assert.h>
 #include <limits.h>
 
-#include "xc_sr_common_x86_pv.h"
+#include "xg_sr_common_x86_pv.h"
 
 /* Check a 64 bit virtual address for being canonical. */
 static inline bool is_canonical_address(xen_vaddr_t vaddr)
diff --git a/tools/libxc/xc_sr_stream_format.h b/tools/libxc/xg_sr_stream_format.h
similarity index 100%
rename from tools/libxc/xc_sr_stream_format.h
rename to tools/libxc/xg_sr_stream_format.h
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 14/31] tools/misc: rename xc_dom.h do xenctrl_dom.h
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (12 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 13/31] tools/libxc: rename libxenguest internal headers Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 15/31] tools/libxc: untangle libxenctrl from libxenguest Juergen Gross
                   ` (16 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel
  Cc: Juergen Gross, Samuel Thibault, Ian Jackson, Wei Liu,
	Anthony PERARD, Marek Marczykowski-Górecki

For being able to disentangle lixenctrl and libxenguest headers
xc_dom.h will need to be public. Prepare that by renaming xc_dom.h
to xenctrl_dom.h.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
Acked-by: Wei Liu <wl@xen.org>
---
 stubdom/grub/kexec.c                            | 2 +-
 tools/helpers/init-xenstore-domain.c            | 2 +-
 tools/libxc/include/{xc_dom.h => xenctrl_dom.h} | 0
 tools/libxc/xc_core.c                           | 2 +-
 tools/libxc/xc_private.c                        | 2 +-
 tools/libxc/xg_dom_arm.c                        | 2 +-
 tools/libxc/xg_dom_armzimageloader.c            | 2 +-
 tools/libxc/xg_dom_binloader.c                  | 2 +-
 tools/libxc/xg_dom_boot.c                       | 2 +-
 tools/libxc/xg_dom_compat_linux.c               | 2 +-
 tools/libxc/xg_dom_core.c                       | 2 +-
 tools/libxc/xg_dom_decompress.h                 | 2 +-
 tools/libxc/xg_dom_decompress_unsafe.h          | 2 +-
 tools/libxc/xg_dom_elfloader.c                  | 2 +-
 tools/libxc/xg_dom_hvmloader.c                  | 2 +-
 tools/libxc/xg_dom_x86.c                        | 2 +-
 tools/libxc/xg_offline_page.c                   | 2 +-
 tools/libxc/xg_sr_common.h                      | 2 +-
 tools/libxl/libxl_arm.c                         | 2 +-
 tools/libxl/libxl_arm.h                         | 2 +-
 tools/libxl/libxl_create.c                      | 2 +-
 tools/libxl/libxl_dm.c                          | 2 +-
 tools/libxl/libxl_dom.c                         | 2 +-
 tools/libxl/libxl_internal.h                    | 2 +-
 tools/libxl/libxl_vnuma.c                       | 2 +-
 tools/libxl/libxl_x86.c                         | 2 +-
 tools/libxl/libxl_x86_acpi.c                    | 2 +-
 tools/python/xen/lowlevel/xc/xc.c               | 2 +-
 tools/xcutils/readnotes.c                       | 2 +-
 29 files changed, 28 insertions(+), 28 deletions(-)
 rename tools/libxc/include/{xc_dom.h => xenctrl_dom.h} (100%)

diff --git a/stubdom/grub/kexec.c b/stubdom/grub/kexec.c
index 0e68b969a2..24001220a9 100644
--- a/stubdom/grub/kexec.c
+++ b/stubdom/grub/kexec.c
@@ -20,7 +20,7 @@
 #include <sys/mman.h>
 
 #include <xenctrl.h>
-#include <xc_dom.h>
+#include <xenctrl_dom.h>
 
 #include <kernel.h>
 #include <console.h>
diff --git a/tools/helpers/init-xenstore-domain.c b/tools/helpers/init-xenstore-domain.c
index 4ce8299c3c..5bdb48dc80 100644
--- a/tools/helpers/init-xenstore-domain.c
+++ b/tools/helpers/init-xenstore-domain.c
@@ -8,7 +8,7 @@
 #include <sys/ioctl.h>
 #include <sys/mman.h>
 #include <xenctrl.h>
-#include <xc_dom.h>
+#include <xenctrl_dom.h>
 #include <xenstore.h>
 #include <xen/sys/xenbus_dev.h>
 #include <xen-xsm/flask/flask.h>
diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xenctrl_dom.h
similarity index 100%
rename from tools/libxc/include/xc_dom.h
rename to tools/libxc/include/xenctrl_dom.h
diff --git a/tools/libxc/xc_core.c b/tools/libxc/xc_core.c
index 2ee1d205b4..7df1fccd62 100644
--- a/tools/libxc/xc_core.c
+++ b/tools/libxc/xc_core.c
@@ -62,7 +62,7 @@
 
 #include "xg_private.h"
 #include "xc_core.h"
-#include "xc_dom.h"
+#include "xenctrl_dom.h"
 #include <stdlib.h>
 #include <unistd.h>
 
diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c
index 90974d572e..6ecdf6953f 100644
--- a/tools/libxc/xc_private.c
+++ b/tools/libxc/xc_private.c
@@ -19,7 +19,7 @@
 
 #include "xc_private.h"
 #include "xg_private.h"
-#include "xc_dom.h"
+#include "xenctrl_dom.h"
 #include <stdarg.h>
 #include <stdlib.h>
 #include <unistd.h>
diff --git a/tools/libxc/xg_dom_arm.c b/tools/libxc/xg_dom_arm.c
index 931404c222..3f66f1d890 100644
--- a/tools/libxc/xg_dom_arm.c
+++ b/tools/libxc/xg_dom_arm.c
@@ -24,7 +24,7 @@
 #include <xen-tools/libs.h>
 
 #include "xg_private.h"
-#include "xc_dom.h"
+#include "xenctrl_dom.h"
 
 #define NR_MAGIC_PAGES 4
 #define CONSOLE_PFN_OFFSET 0
diff --git a/tools/libxc/xg_dom_armzimageloader.c b/tools/libxc/xg_dom_armzimageloader.c
index 0df8c2a4b1..4246c8e5fa 100644
--- a/tools/libxc/xg_dom_armzimageloader.c
+++ b/tools/libxc/xg_dom_armzimageloader.c
@@ -25,7 +25,7 @@
 #include <inttypes.h>
 
 #include "xg_private.h"
-#include "xc_dom.h"
+#include "xenctrl_dom.h"
 
 #include <arpa/inet.h> /* XXX ntohl is not the right function... */
 
diff --git a/tools/libxc/xg_dom_binloader.c b/tools/libxc/xg_dom_binloader.c
index d6f7f2a500..870a921427 100644
--- a/tools/libxc/xg_dom_binloader.c
+++ b/tools/libxc/xg_dom_binloader.c
@@ -83,7 +83,7 @@
 #include <inttypes.h>
 
 #include "xg_private.h"
-#include "xc_dom.h"
+#include "xenctrl_dom.h"
 
 #define round_pgup(_p)    (((_p)+(PAGE_SIZE_X86-1))&PAGE_MASK_X86)
 #define round_pgdown(_p)  ((_p)&PAGE_MASK_X86)
diff --git a/tools/libxc/xg_dom_boot.c b/tools/libxc/xg_dom_boot.c
index bb599b33ba..1e31e92244 100644
--- a/tools/libxc/xg_dom_boot.c
+++ b/tools/libxc/xg_dom_boot.c
@@ -31,7 +31,7 @@
 #include <zlib.h>
 
 #include "xg_private.h"
-#include "xc_dom.h"
+#include "xenctrl_dom.h"
 #include "xc_core.h"
 #include <xen/hvm/params.h>
 #include <xen/grant_table.h>
diff --git a/tools/libxc/xg_dom_compat_linux.c b/tools/libxc/xg_dom_compat_linux.c
index b3d43feed9..b645f0b14b 100644
--- a/tools/libxc/xg_dom_compat_linux.c
+++ b/tools/libxc/xg_dom_compat_linux.c
@@ -30,7 +30,7 @@
 
 #include "xenctrl.h"
 #include "xg_private.h"
-#include "xc_dom.h"
+#include "xenctrl_dom.h"
 
 /* ------------------------------------------------------------------------ */
 
diff --git a/tools/libxc/xg_dom_core.c b/tools/libxc/xg_dom_core.c
index 327c8a8575..1c91cce315 100644
--- a/tools/libxc/xg_dom_core.c
+++ b/tools/libxc/xg_dom_core.c
@@ -32,7 +32,7 @@
 #include <assert.h>
 
 #include "xg_private.h"
-#include "xc_dom.h"
+#include "xenctrl_dom.h"
 #include "_paths.h"
 
 /* ------------------------------------------------------------------------ */
diff --git a/tools/libxc/xg_dom_decompress.h b/tools/libxc/xg_dom_decompress.h
index d9a21cf297..c5ab2e59eb 100644
--- a/tools/libxc/xg_dom_decompress.h
+++ b/tools/libxc/xg_dom_decompress.h
@@ -1,5 +1,5 @@
 #ifndef __MINIOS__
-# include "xc_dom.h"
+# include "xenctrl_dom.h"
 #else
 # include "xg_dom_decompress_unsafe.h"
 #endif
diff --git a/tools/libxc/xg_dom_decompress_unsafe.h b/tools/libxc/xg_dom_decompress_unsafe.h
index 64f68864b1..fb84b6add8 100644
--- a/tools/libxc/xg_dom_decompress_unsafe.h
+++ b/tools/libxc/xg_dom_decompress_unsafe.h
@@ -1,4 +1,4 @@
-#include "xc_dom.h"
+#include "xenctrl_dom.h"
 
 typedef int decompress_fn(unsigned char *inbuf, unsigned int len,
                           int (*fill)(void*, unsigned int),
diff --git a/tools/libxc/xg_dom_elfloader.c b/tools/libxc/xg_dom_elfloader.c
index b327db219d..7043c3bbba 100644
--- a/tools/libxc/xg_dom_elfloader.c
+++ b/tools/libxc/xg_dom_elfloader.c
@@ -26,7 +26,7 @@
 #include <inttypes.h>
 
 #include "xg_private.h"
-#include "xc_dom.h"
+#include "xenctrl_dom.h"
 #include "xc_bitops.h"
 
 #define XEN_VER "xen-3.0"
diff --git a/tools/libxc/xg_dom_hvmloader.c b/tools/libxc/xg_dom_hvmloader.c
index 3f0bd65547..995a0f3dc3 100644
--- a/tools/libxc/xg_dom_hvmloader.c
+++ b/tools/libxc/xg_dom_hvmloader.c
@@ -26,7 +26,7 @@
 #include <assert.h>
 
 #include "xg_private.h"
-#include "xc_dom.h"
+#include "xenctrl_dom.h"
 #include "xc_bitops.h"
 
 /* ------------------------------------------------------------------------ */
diff --git a/tools/libxc/xg_dom_x86.c b/tools/libxc/xg_dom_x86.c
index 9439805eaa..842dbcccdd 100644
--- a/tools/libxc/xg_dom_x86.c
+++ b/tools/libxc/xg_dom_x86.c
@@ -38,7 +38,7 @@
 #include <xen-tools/libs.h>
 
 #include "xg_private.h"
-#include "xc_dom.h"
+#include "xenctrl_dom.h"
 #include "xenctrl.h"
 
 /* ------------------------------------------------------------------------ */
diff --git a/tools/libxc/xg_offline_page.c b/tools/libxc/xg_offline_page.c
index 19538fc436..77e8889b11 100644
--- a/tools/libxc/xg_offline_page.c
+++ b/tools/libxc/xg_offline_page.c
@@ -28,7 +28,7 @@
 #include <xc_core.h>
 
 #include "xc_private.h"
-#include "xc_dom.h"
+#include "xenctrl_dom.h"
 #include "xg_private.h"
 #include "xg_save_restore.h"
 
diff --git a/tools/libxc/xg_sr_common.h b/tools/libxc/xg_sr_common.h
index 35f23fabb5..13fcc47420 100644
--- a/tools/libxc/xg_sr_common.h
+++ b/tools/libxc/xg_sr_common.h
@@ -5,7 +5,7 @@
 
 #include "xg_private.h"
 #include "xg_save_restore.h"
-#include "xc_dom.h"
+#include "xenctrl_dom.h"
 #include "xc_bitops.h"
 
 #include "xg_sr_stream_format.h"
diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
index 34f8a29056..975a4d730a 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -3,7 +3,7 @@
 #include "libxl_libfdt_compat.h"
 #include "libxl_arm.h"
 
-#include <xc_dom.h>
+#include <xenctrl_dom.h>
 #include <stdbool.h>
 #include <libfdt.h>
 #include <assert.h>
diff --git a/tools/libxl/libxl_arm.h b/tools/libxl/libxl_arm.h
index 8aef210d4c..52c2ab5e3a 100644
--- a/tools/libxl/libxl_arm.h
+++ b/tools/libxl/libxl_arm.h
@@ -17,7 +17,7 @@
 #include "libxl_internal.h"
 #include "libxl_arch.h"
 
-#include <xc_dom.h>
+#include <xenctrl_dom.h>
 
 _hidden
 int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info,
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 2814818e34..1031b75159 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -20,7 +20,7 @@
 #include "libxl_internal.h"
 #include "libxl_arch.h"
 
-#include <xc_dom.h>
+#include <xenctrl_dom.h>
 #include <xenguest.h>
 #include <xen/hvm/hvm_info_table.h>
 #include <xen/hvm/e820.h>
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index f2dc5696b9..fec4e0fbe5 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -19,7 +19,7 @@
 
 #include "libxl_internal.h"
 
-#include <xc_dom.h>
+#include <xenctrl_dom.h>
 #include <xen/hvm/e820.h>
 #include <sys/types.h>
 #include <pwd.h>
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index f8661e90d4..e2dca64aa1 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -20,7 +20,7 @@
 #include "libxl_internal.h"
 #include "libxl_arch.h"
 
-#include <xc_dom.h>
+#include <xenctrl_dom.h>
 #include <xen/hvm/hvm_info_table.h>
 #include <xen/hvm/hvm_xs_strings.h>
 #include <xen/hvm/e820.h>
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index c63d0686fd..e16ae9630b 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -57,7 +57,7 @@
 #include <xenctrl.h>
 #include <xenguest.h>
 #include <xenhypfs.h>
-#include <xc_dom.h>
+#include <xenctrl_dom.h>
 
 #include <xen-tools/libs.h>
 
diff --git a/tools/libxl/libxl_vnuma.c b/tools/libxl/libxl_vnuma.c
index 8ec2abb2e6..c2e144ceae 100644
--- a/tools/libxl/libxl_vnuma.c
+++ b/tools/libxl/libxl_vnuma.c
@@ -17,7 +17,7 @@
 #include "libxl_arch.h"
 #include <stdlib.h>
 
-#include <xc_dom.h>
+#include <xenctrl_dom.h>
 
 bool libxl__vnuma_configured(const libxl_domain_build_info *b_info)
 {
diff --git a/tools/libxl/libxl_x86.c b/tools/libxl/libxl_x86.c
index e57f63282e..7d95506e00 100644
--- a/tools/libxl/libxl_x86.c
+++ b/tools/libxl/libxl_x86.c
@@ -1,7 +1,7 @@
 #include "libxl_internal.h"
 #include "libxl_arch.h"
 
-#include <xc_dom.h>
+#include <xenctrl_dom.h>
 
 int libxl__arch_domain_prepare_config(libxl__gc *gc,
                                       libxl_domain_config *d_config,
diff --git a/tools/libxl/libxl_x86_acpi.c b/tools/libxl/libxl_x86_acpi.c
index ed6610c84e..3df86c7be5 100644
--- a/tools/libxl/libxl_x86_acpi.c
+++ b/tools/libxl/libxl_x86_acpi.c
@@ -18,7 +18,7 @@
 #include <xen/hvm/e820.h>
 #include "libacpi/libacpi.h"
 
-#include <xc_dom.h>
+#include <xenctrl_dom.h>
 
  /* Number of pages holding ACPI tables */
 #define NUM_ACPI_PAGES 16
diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c
index 8fde5f311f..8c7b184f0b 100644
--- a/tools/python/xen/lowlevel/xc/xc.c
+++ b/tools/python/xen/lowlevel/xc/xc.c
@@ -17,7 +17,7 @@
 #include <arpa/inet.h>
 
 #include <xen/elfnote.h>
-#include "xc_dom.h"
+#include "xenctrl_dom.h"
 #include <xen/hvm/hvm_info_table.h>
 #include <xen/hvm/params.h>
 
diff --git a/tools/xcutils/readnotes.c b/tools/xcutils/readnotes.c
index e682dd1a21..a6b7358e70 100644
--- a/tools/xcutils/readnotes.c
+++ b/tools/xcutils/readnotes.c
@@ -12,7 +12,7 @@
 #include <sys/mman.h>
 
 #include <xg_private.h>
-#include <xc_dom.h> /* gunzip bits */
+#include <xenctrl_dom.h> /* gunzip bits */
 
 #include <xen/libelf/libelf.h>
 
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 15/31] tools/libxc: untangle libxenctrl from libxenguest
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (13 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 14/31] tools/misc: rename xc_dom.h do xenctrl_dom.h Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 16/31] tools/xcutils: use official headers in readnotes Juergen Gross
                   ` (15 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu

Sources of libxenctrl and libxenguest are completely entangled. In
practice libxenguest is a user of libxenctrl, so don't let any source
libxenctrl include xg_private.h.

This can be achieved by moving all definitions used by libxenctrl from
xg_private.h to xc_private.h.

Export xenctrl_dom.h as it will now be included by other public
headers.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
 tools/libxc/Makefile              |  3 ++-
 tools/libxc/include/xenctrl_dom.h | 10 +++++++--
 tools/libxc/include/xenguest.h    |  8 ++-----
 tools/libxc/xc_core.c             |  5 +++--
 tools/libxc/xc_core.h             |  2 +-
 tools/libxc/xc_core_arm.c         |  2 +-
 tools/libxc/xc_core_x86.c         |  6 ++----
 tools/libxc/xc_domain.c           |  3 +--
 tools/libxc/xc_hcall_buf.c        |  1 -
 tools/libxc/xc_private.c          |  1 -
 tools/libxc/xc_private.h          | 36 +++++++++++++++++++++++++++++++
 tools/libxc/xc_resume.c           |  2 --
 tools/libxc/xg_private.h          | 22 -------------------
 tools/libxc/xg_save_restore.h     |  9 --------
 14 files changed, 56 insertions(+), 54 deletions(-)

diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile
index 0fd5511143..faf2639894 100644
--- a/tools/libxc/Makefile
+++ b/tools/libxc/Makefile
@@ -215,7 +215,7 @@ install: build
 	$(INSTALL_DATA) libxenctrl.a $(DESTDIR)$(libdir)
 	$(SYMLINK_SHLIB) libxenctrl.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenctrl.so.$(MAJOR)
 	$(SYMLINK_SHLIB) libxenctrl.so.$(MAJOR) $(DESTDIR)$(libdir)/libxenctrl.so
-	$(INSTALL_DATA) include/xenctrl.h include/xenctrl_compat.h $(DESTDIR)$(includedir)
+	$(INSTALL_DATA) include/xenctrl.h include/xenctrl_compat.h include/xenctrl_dom.h $(DESTDIR)$(includedir)
 	$(INSTALL_SHLIB) libxenguest.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)
 	$(INSTALL_DATA) libxenguest.a $(DESTDIR)$(libdir)
 	$(SYMLINK_SHLIB) libxenguest.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenguest.so.$(MAJOR)
@@ -235,6 +235,7 @@ uninstall:
 	rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xencontrol.pc
 	rm -f $(DESTDIR)$(includedir)/xenctrl.h
 	rm -f $(DESTDIR)$(includedir)/xenctrl_compat.h
+	rm -f $(DESTDIR)$(includedir)/xenctrl_dom.h
 	rm -f $(DESTDIR)$(libdir)/libxenctrl.so
 	rm -f $(DESTDIR)$(libdir)/libxenctrl.so.$(MAJOR)
 	rm -f $(DESTDIR)$(libdir)/libxenctrl.so.$(MAJOR).$(MINOR)
diff --git a/tools/libxc/include/xenctrl_dom.h b/tools/libxc/include/xenctrl_dom.h
index 52a4d6c8c0..40b85b7755 100644
--- a/tools/libxc/include/xenctrl_dom.h
+++ b/tools/libxc/include/xenctrl_dom.h
@@ -17,9 +17,7 @@
 #define _XC_DOM_H
 
 #include <xen/libelf/libelf.h>
-#include <xenguest.h>
 
-#define INVALID_PFN ((xen_pfn_t)-1)
 #define X86_HVM_NR_SPECIAL_PAGES    8
 #define X86_HVM_END_SPECIAL_REGION  0xff000u
 #define XG_MAX_MODULES 2
@@ -38,6 +36,12 @@ struct xc_dom_seg {
     xen_pfn_t pages;
 };
 
+struct xc_hvm_firmware_module {
+    uint8_t  *data;
+    uint32_t  length;
+    uint64_t  guest_addr_out;
+};
+
 struct xc_dom_mem {
     struct xc_dom_mem *next;
     void *ptr;
@@ -255,6 +259,8 @@ struct xc_dom_arch {
     int (*setup_pgtables) (struct xc_dom_image * dom);
 
     /* arch-specific data structs setup */
+    /* in Mini-OS environment start_info might be a macro, avoid collision. */
+#undef start_info
     int (*start_info) (struct xc_dom_image * dom);
     int (*shared_info) (struct xc_dom_image * dom, void *shared_info);
     int (*vcpu) (struct xc_dom_image * dom);
diff --git a/tools/libxc/include/xenguest.h b/tools/libxc/include/xenguest.h
index 7a12d21ff2..4643384790 100644
--- a/tools/libxc/include/xenguest.h
+++ b/tools/libxc/include/xenguest.h
@@ -22,6 +22,8 @@
 #ifndef XENGUEST_H
 #define XENGUEST_H
 
+#include <xenctrl_dom.h>
+
 #define XC_NUMA_NO_NODE   (~0U)
 
 #define XCFLAGS_LIVE      (1 << 0)
@@ -249,12 +251,6 @@ int xc_linux_build(xc_interface *xch,
                    unsigned int console_evtchn,
                    unsigned long *console_mfn);
 
-struct xc_hvm_firmware_module {
-    uint8_t  *data;
-    uint32_t  length;
-    uint64_t  guest_addr_out;
-};
-
 /*
  * Sets *lockfd to -1.
  * Has deallocated everything even on error.
diff --git a/tools/libxc/xc_core.c b/tools/libxc/xc_core.c
index 7df1fccd62..e8c6fb96f9 100644
--- a/tools/libxc/xc_core.c
+++ b/tools/libxc/xc_core.c
@@ -60,12 +60,13 @@
  *
  */
 
-#include "xg_private.h"
+#include "xc_private.h"
 #include "xc_core.h"
-#include "xenctrl_dom.h"
 #include <stdlib.h>
 #include <unistd.h>
 
+#include <xen/libelf/libelf.h>
+
 /* number of pages to write at a time */
 #define DUMP_INCREMENT (4 * 1024)
 
diff --git a/tools/libxc/xc_core.h b/tools/libxc/xc_core.h
index ed7ed53ca5..36fb755da2 100644
--- a/tools/libxc/xc_core.h
+++ b/tools/libxc/xc_core.h
@@ -21,7 +21,7 @@
 #define XC_CORE_H
 
 #include "xen/version.h"
-#include "xg_private.h"
+#include "xc_private.h"
 #include "xen/libelf/elfstructs.h"
 
 /* section names */
diff --git a/tools/libxc/xc_core_arm.c b/tools/libxc/xc_core_arm.c
index c3c492c971..7b587b4cc5 100644
--- a/tools/libxc/xc_core_arm.c
+++ b/tools/libxc/xc_core_arm.c
@@ -16,7 +16,7 @@
  *
  */
 
-#include "xg_private.h"
+#include "xc_private.h"
 #include "xc_core.h"
 
 #include <xen-tools/libs.h>
diff --git a/tools/libxc/xc_core_x86.c b/tools/libxc/xc_core_x86.c
index 54852a2d1a..cb76e6207b 100644
--- a/tools/libxc/xc_core_x86.c
+++ b/tools/libxc/xc_core_x86.c
@@ -17,12 +17,10 @@
  *
  */
 
-#include "xg_private.h"
+#include "xc_private.h"
 #include "xc_core.h"
 #include <xen/hvm/e820.h>
 
-#define GET_FIELD(_p, _f) ((dinfo->guest_width==8) ? ((_p)->x64._f) : ((_p)->x32._f))
-
 int
 xc_core_arch_gpfn_may_present(struct xc_core_arch_context *arch_ctxt,
                               unsigned long pfn)
@@ -98,7 +96,7 @@ xc_core_arch_map_p2m_rw(xc_interface *xch, struct domain_info_context *dinfo, xc
 
     live_p2m_frame_list_list =
         xc_map_foreign_range(xch, dom, PAGE_SIZE, PROT_READ,
-                             GET_FIELD(live_shinfo, arch.pfn_to_mfn_frame_list_list));
+                             GET_FIELD(live_shinfo, arch.pfn_to_mfn_frame_list_list, dinfo->guest_width));
 
     if ( !live_p2m_frame_list_list )
     {
diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
index fbc22c4df6..43fab50c06 100644
--- a/tools/libxc/xc_domain.c
+++ b/tools/libxc/xc_domain.c
@@ -21,8 +21,7 @@
 
 #include "xc_private.h"
 #include "xc_core.h"
-#include "xg_private.h"
-#include "xg_save_restore.h"
+#include "xc_private.h"
 #include <xen/memory.h>
 #include <xen/hvm/hvm_op.h>
 
diff --git a/tools/libxc/xc_hcall_buf.c b/tools/libxc/xc_hcall_buf.c
index c1230a1e2b..200671f36f 100644
--- a/tools/libxc/xc_hcall_buf.c
+++ b/tools/libxc/xc_hcall_buf.c
@@ -19,7 +19,6 @@
 #include <string.h>
 
 #include "xc_private.h"
-#include "xg_private.h"
 
 xc_hypercall_buffer_t XC__HYPERCALL_BUFFER_NAME(HYPERCALL_BUFFER_NULL) = {
     .hbuf = NULL,
diff --git a/tools/libxc/xc_private.c b/tools/libxc/xc_private.c
index 6ecdf6953f..8af96b1b7e 100644
--- a/tools/libxc/xc_private.c
+++ b/tools/libxc/xc_private.c
@@ -18,7 +18,6 @@
  */
 
 #include "xc_private.h"
-#include "xg_private.h"
 #include "xenctrl_dom.h"
 #include <stdarg.h>
 #include <stdlib.h>
diff --git a/tools/libxc/xc_private.h b/tools/libxc/xc_private.h
index c77edb3c4c..f0b5f83ac8 100644
--- a/tools/libxc/xc_private.h
+++ b/tools/libxc/xc_private.h
@@ -26,6 +26,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <stdlib.h>
+#include <limits.h>
 #include <sys/ioctl.h>
 
 #include "_paths.h"
@@ -62,6 +63,39 @@ struct iovec {
 #include <sys/uio.h>
 #endif
 
+#define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1))
+
+#define GET_FIELD(_p, _f, _w) (((_w) == 8) ? ((_p)->x64._f) : ((_p)->x32._f))
+
+#define SET_FIELD(_p, _f, _v, _w) do {          \
+    if ((_w) == 8)                              \
+        (_p)->x64._f = (_v);                    \
+    else                                        \
+        (_p)->x32._f = (_v);                    \
+} while (0)
+
+/* XXX SMH: following skanky macros rely on variable p2m_size being set */
+/* XXX TJD: also, "guest_width" should be the guest's sizeof(unsigned long) */
+
+struct domain_info_context {
+    unsigned int guest_width;
+    unsigned long p2m_size;
+};
+
+/* Number of xen_pfn_t in a page */
+#define FPP             (PAGE_SIZE/(dinfo->guest_width))
+
+/* Number of entries in the pfn_to_mfn_frame_list_list */
+#define P2M_FLL_ENTRIES (((dinfo->p2m_size)+(FPP*FPP)-1)/(FPP*FPP))
+
+/* Number of entries in the pfn_to_mfn_frame_list */
+#define P2M_FL_ENTRIES  (((dinfo->p2m_size)+FPP-1)/FPP)
+
+/* Size in bytes of the pfn_to_mfn_frame_list     */
+#define P2M_GUEST_FL_SIZE ((P2M_FL_ENTRIES) * (dinfo->guest_width))
+#define P2M_TOOLS_FL_SIZE ((P2M_FL_ENTRIES) *                           \
+                           max_t(size_t, sizeof(xen_pfn_t), dinfo->guest_width))
+
 #define DECLARE_DOMCTL struct xen_domctl domctl
 #define DECLARE_SYSCTL struct xen_sysctl sysctl
 #define DECLARE_PHYSDEV_OP struct physdev_op physdev_op
@@ -75,6 +109,8 @@ struct iovec {
 #define PAGE_SIZE               XC_PAGE_SIZE
 #define PAGE_MASK               XC_PAGE_MASK
 
+#define INVALID_PFN ((xen_pfn_t)-1)
+
 /*
 ** Define max dirty page cache to permit during save/restore -- need to balance 
 ** keeping cache usage down with CPU impact of invalidating too often.
diff --git a/tools/libxc/xc_resume.c b/tools/libxc/xc_resume.c
index c169204fac..94c6c9fb31 100644
--- a/tools/libxc/xc_resume.c
+++ b/tools/libxc/xc_resume.c
@@ -14,8 +14,6 @@
  */
 
 #include "xc_private.h"
-#include "xg_private.h"
-#include "xg_save_restore.h"
 
 #if defined(__i386__) || defined(__x86_64__)
 
diff --git a/tools/libxc/xg_private.h b/tools/libxc/xg_private.h
index 40b5baecde..0000b2b9b6 100644
--- a/tools/libxc/xg_private.h
+++ b/tools/libxc/xg_private.h
@@ -97,15 +97,6 @@ typedef uint64_t x86_pgentry_t;
 
 #define NRPAGES(x) (ROUNDUP(x, PAGE_SHIFT) >> PAGE_SHIFT)
 
-
-/* XXX SMH: following skanky macros rely on variable p2m_size being set */
-/* XXX TJD: also, "guest_width" should be the guest's sizeof(unsigned long) */
-
-struct domain_info_context {
-    unsigned int guest_width;
-    unsigned long p2m_size;
-};
-
 static inline xen_pfn_t xc_pfn_to_mfn(xen_pfn_t pfn, xen_pfn_t *p2m,
                                       unsigned gwidth)
 {
@@ -121,19 +112,6 @@ static inline xen_pfn_t xc_pfn_to_mfn(xen_pfn_t pfn, xen_pfn_t *p2m,
     }
 }
 
-/* Number of xen_pfn_t in a page */
-#define FPP             (PAGE_SIZE/(dinfo->guest_width))
-
-/* Number of entries in the pfn_to_mfn_frame_list_list */
-#define P2M_FLL_ENTRIES (((dinfo->p2m_size)+(FPP*FPP)-1)/(FPP*FPP))
-
-/* Number of entries in the pfn_to_mfn_frame_list */
-#define P2M_FL_ENTRIES  (((dinfo->p2m_size)+FPP-1)/FPP)
-
-/* Size in bytes of the pfn_to_mfn_frame_list     */
-#define P2M_GUEST_FL_SIZE ((P2M_FL_ENTRIES) * (dinfo->guest_width))
-#define P2M_TOOLS_FL_SIZE ((P2M_FL_ENTRIES) *                           \
-                           max_t(size_t, sizeof(xen_pfn_t), dinfo->guest_width))
 
 /* Masks for PTE<->PFN conversions */
 #define MADDR_BITS_X86  ((dinfo->guest_width == 8) ? 52 : 44)
diff --git a/tools/libxc/xg_save_restore.h b/tools/libxc/xg_save_restore.h
index b904296997..88120eb54b 100644
--- a/tools/libxc/xg_save_restore.h
+++ b/tools/libxc/xg_save_restore.h
@@ -109,15 +109,6 @@ static inline int get_platform_info(xc_interface *xch, uint32_t dom,
 #define M2P_SIZE(_m)    ROUNDUP(((_m) * sizeof(xen_pfn_t)), M2P_SHIFT)
 #define M2P_CHUNKS(_m)  (M2P_SIZE((_m)) >> M2P_SHIFT)
 
-#define GET_FIELD(_p, _f, _w) (((_w) == 8) ? ((_p)->x64._f) : ((_p)->x32._f))
-
-#define SET_FIELD(_p, _f, _v, _w) do {          \
-    if ((_w) == 8)                              \
-        (_p)->x64._f = (_v);                    \
-    else                                        \
-        (_p)->x32._f = (_v);                    \
-} while (0)
-
 #define UNFOLD_CR3(_c)                                                  \
   ((uint64_t)((dinfo->guest_width == 8)                                 \
               ? ((_c) >> 12)                                            \
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 16/31] tools/xcutils: use official headers in readnotes
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (14 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 15/31] tools/libxc: untangle libxenctrl from libxenguest Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 17/31] tools/xenpaging: remove libxc internals Juergen Gross
                   ` (14 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu

readnotes.c is including xg_private.h. Now that the xenctrl headers
are structured better this is no longer needed.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
 tools/xcutils/Makefile    | 3 +--
 tools/xcutils/readnotes.c | 5 +++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/xcutils/Makefile b/tools/xcutils/Makefile
index 2811893980..82d42624c8 100644
--- a/tools/xcutils/Makefile
+++ b/tools/xcutils/Makefile
@@ -15,8 +15,7 @@ PROGRAMS = readnotes lsevtchn
 
 CFLAGS += -Werror
 
-# incorrectly uses libxc internals
-CFLAGS_readnotes.o  := $(CFLAGS_libxenevtchn) $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest) -I$(XEN_ROOT)/tools/libxc $(CFLAGS_libxencall)
+CFLAGS_readnotes.o  := $(CFLAGS_libxenevtchn) $(CFLAGS_libxenctrl) $(CFLAGS_libxenguest)
 CFLAGS_lsevtchn.o   := $(CFLAGS_libxenevtchn) $(CFLAGS_libxenctrl)
 
 .PHONY: all
diff --git a/tools/xcutils/readnotes.c b/tools/xcutils/readnotes.c
index a6b7358e70..ff684c7dcb 100644
--- a/tools/xcutils/readnotes.c
+++ b/tools/xcutils/readnotes.c
@@ -11,8 +11,9 @@
 #include <sys/stat.h>
 #include <sys/mman.h>
 
-#include <xg_private.h>
-#include <xenctrl_dom.h> /* gunzip bits */
+#include <xen/xen.h>
+#include <xenctrl.h>
+#include <xenguest.h>
 
 #include <xen/libelf/libelf.h>
 
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 17/31] tools/xenpaging: remove libxc internals
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (15 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 16/31] tools/xcutils: use official headers in readnotes Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 18/31] tools: move libxenctrl below tools/libs Juergen Gross
                   ` (13 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu

xenpaging is using libxc internals. Fix that.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
 tools/xenpaging/Makefile         |  3 +-
 tools/xenpaging/file_ops.c       |  8 ++--
 tools/xenpaging/pagein.c         |  2 +-
 tools/xenpaging/policy_default.c |  2 +-
 tools/xenpaging/xenpaging.c      | 32 +++++++--------
 tools/xenpaging/xenpaging.h      | 70 +++++++++++++++++++++++++++++++-
 6 files changed, 92 insertions(+), 25 deletions(-)

diff --git a/tools/xenpaging/Makefile b/tools/xenpaging/Makefile
index 968678c4e8..04743b335c 100644
--- a/tools/xenpaging/Makefile
+++ b/tools/xenpaging/Makefile
@@ -1,8 +1,7 @@
 XEN_ROOT=$(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-# xenpaging.c and file_ops.c incorrectly use libxc internals
-CFLAGS += $(CFLAGS_libxentoollog) $(CFLAGS_libxenevtchn) $(CFLAGS_libxenctrl) $(CFLAGS_libxenstore) $(PTHREAD_CFLAGS) -I$(XEN_ROOT)/tools/libxc $(CFLAGS_libxencall)
+CFLAGS += $(CFLAGS_libxentoollog) $(CFLAGS_libxenevtchn) $(CFLAGS_libxenctrl) $(CFLAGS_libxenstore) $(PTHREAD_CFLAGS) $(CFLAGS_libxencall)
 LDLIBS += $(LDLIBS_libxentoollog) $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(LDLIBS_libxenstore) $(PTHREAD_LIBS)
 LDFLAGS += $(PTHREAD_LDFLAGS)
 
diff --git a/tools/xenpaging/file_ops.c b/tools/xenpaging/file_ops.c
index 8210f426df..301fb3427c 100644
--- a/tools/xenpaging/file_ops.c
+++ b/tools/xenpaging/file_ops.c
@@ -20,7 +20,7 @@
 
 
 #include <unistd.h>
-#include <xc_private.h>
+#include <xenctrl.h>
 
 static int file_op(int fd, void *page, int i,
                    ssize_t (*fn)(int, void *, size_t))
@@ -29,13 +29,13 @@ static int file_op(int fd, void *page, int i,
     int total = 0;
     int bytes;
 
-    offset = lseek(fd, offset << PAGE_SHIFT, SEEK_SET);
+    offset = lseek(fd, offset << XC_PAGE_SHIFT, SEEK_SET);
     if ( offset == (off_t)-1 )
         return -1;
 
-    while ( total < PAGE_SIZE )
+    while ( total < XC_PAGE_SIZE )
     {
-        bytes = fn(fd, page + total, PAGE_SIZE - total);
+        bytes = fn(fd, page + total, XC_PAGE_SIZE - total);
         if ( bytes <= 0 )
             return -1;
 
diff --git a/tools/xenpaging/pagein.c b/tools/xenpaging/pagein.c
index 2a298b436c..1c8a7d983d 100644
--- a/tools/xenpaging/pagein.c
+++ b/tools/xenpaging/pagein.c
@@ -43,7 +43,7 @@ static void *page_in(void *arg)
         /* Ignore errors */
         page = xc_map_foreign_pages(pia->xch, pia->dom, PROT_READ, gfns, num);
         if (page)
-            munmap(page, PAGE_SIZE * num);
+            munmap(page, XC_PAGE_SIZE * num);
     }
     page_in_possible = 0;
     pthread_exit(NULL);
diff --git a/tools/xenpaging/policy_default.c b/tools/xenpaging/policy_default.c
index 3324835957..979d251230 100644
--- a/tools/xenpaging/policy_default.c
+++ b/tools/xenpaging/policy_default.c
@@ -18,8 +18,8 @@
  * along with this program; If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <errno.h>
 
-#include "xc_bitops.h"
 #include "policy.h"
 
 
diff --git a/tools/xenpaging/xenpaging.c b/tools/xenpaging/xenpaging.c
index d0571cabac..33098046c2 100644
--- a/tools/xenpaging/xenpaging.c
+++ b/tools/xenpaging/xenpaging.c
@@ -30,7 +30,6 @@
 #include <xenstore.h>
 #include <getopt.h>
 
-#include "xc_bitops.h"
 #include "file_ops.h"
 #include "policy.h"
 #include "xenpaging.h"
@@ -183,12 +182,12 @@ static void *init_page(void)
     void *buffer;
 
     /* Allocated page memory */
-    errno = posix_memalign(&buffer, PAGE_SIZE, PAGE_SIZE);
+    errno = posix_memalign(&buffer, XC_PAGE_SIZE, XC_PAGE_SIZE);
     if ( errno != 0 )
         return NULL;
 
     /* Lock buffer in memory so it can't be paged out */
-    if ( mlock(buffer, PAGE_SIZE) < 0 )
+    if ( mlock(buffer, XC_PAGE_SIZE) < 0 )
     {
         free(buffer);
         buffer = NULL;
@@ -277,7 +276,6 @@ static struct xenpaging *xenpaging_init(int argc, char *argv[])
     struct xenpaging *paging;
     xc_domaininfo_t domain_info;
     xc_interface *xch = NULL;
-    xentoollog_logger *dbg = NULL;
     char *p;
     int rc;
     unsigned long ring_pfn, mmap_pfn;
@@ -291,12 +289,11 @@ static struct xenpaging *xenpaging_init(int argc, char *argv[])
     if ( xenpaging_getopts(paging, argc, argv) )
         goto err;
 
-    /* Enable debug output */
-    if ( paging->debug )
-        dbg = (xentoollog_logger *)xtl_createlogger_stdiostream(stderr, XTL_DEBUG, 0);
+    paging->logger = (xentoollog_logger *)xtl_createlogger_stdiostream(stderr,
+                         paging->debug ? XTL_DEBUG : XTL_PROGRESS, 0);
 
     /* Open connection to xen */
-    paging->xc_handle = xch = xc_interface_open(dbg, NULL, 0);
+    paging->xc_handle = xch = xc_interface_open(paging->logger, NULL, 0);
     if ( !xch )
         goto err;
 
@@ -416,7 +413,7 @@ static struct xenpaging *xenpaging_init(int argc, char *argv[])
     SHARED_RING_INIT((vm_event_sring_t *)paging->vm_event.ring_page);
     BACK_RING_INIT(&paging->vm_event.back_ring,
                    (vm_event_sring_t *)paging->vm_event.ring_page,
-                   PAGE_SIZE);
+                   XC_PAGE_SIZE);
 
     /* Now that the ring is set, remove it from the guest's physmap */
     if ( xc_domain_decrease_reservation_exact(xch, 
@@ -490,15 +487,17 @@ static struct xenpaging *xenpaging_init(int argc, char *argv[])
             xs_close(paging->xs_handle);
         if ( xch )
             xc_interface_close(xch);
+        if ( paging->logger )
+            xtl_logger_destroy(paging->logger);
         if ( paging->paging_buffer )
         {
-            munlock(paging->paging_buffer, PAGE_SIZE);
+            munlock(paging->paging_buffer, XC_PAGE_SIZE);
             free(paging->paging_buffer);
         }
 
         if ( paging->vm_event.ring_page )
         {
-            munmap(paging->vm_event.ring_page, PAGE_SIZE);
+            munmap(paging->vm_event.ring_page, XC_PAGE_SIZE);
         }
 
         free(dom_path);
@@ -523,7 +522,7 @@ static void xenpaging_teardown(struct xenpaging *paging)
 
     paging->xc_handle = NULL;
     /* Tear down domain paging in Xen */
-    munmap(paging->vm_event.ring_page, PAGE_SIZE);
+    munmap(paging->vm_event.ring_page, XC_PAGE_SIZE);
     rc = xc_mem_paging_disable(xch, paging->vm_event.domain_id);
     if ( rc != 0 )
     {
@@ -551,6 +550,8 @@ static void xenpaging_teardown(struct xenpaging *paging)
 
     /* Close connection to Xen */
     xc_interface_close(xch);
+
+    xtl_logger_destroy(paging->logger);
 }
 
 static void get_request(struct vm_event *vm_event, vm_event_request_t *req)
@@ -598,8 +599,7 @@ static int xenpaging_evict_page(struct xenpaging *paging, unsigned long gfn, int
     void *page;
     xen_pfn_t victim = gfn;
     int ret;
-
-    DECLARE_DOMCTL;
+    struct xen_domctl domctl;
 
     /* Nominate page */
     ret = xc_mem_paging_nominate(xch, paging->vm_event.domain_id, gfn);
@@ -627,13 +627,13 @@ static int xenpaging_evict_page(struct xenpaging *paging, unsigned long gfn, int
     if ( ret < 0 )
     {
         PERROR("Error copying page %lx", gfn);
-        munmap(page, PAGE_SIZE);
+        munmap(page, XC_PAGE_SIZE);
         ret = -1;
         goto out;
     }
 
     /* Release page */
-    munmap(page, PAGE_SIZE);
+    munmap(page, XC_PAGE_SIZE);
 
     /* Tell Xen to evict page */
     ret = xc_mem_paging_evict(xch, paging->vm_event.domain_id, gfn);
diff --git a/tools/xenpaging/xenpaging.h b/tools/xenpaging/xenpaging.h
index d6c8ee5221..e0fc7b31b8 100644
--- a/tools/xenpaging/xenpaging.h
+++ b/tools/xenpaging/xenpaging.h
@@ -23,11 +23,17 @@
 #ifndef __XEN_PAGING2_H__
 #define __XEN_PAGING2_H__
 
+#include <malloc.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/mman.h>
 
 #include <xenevtchn.h>
 #define XC_WANT_COMPAT_MAP_FOREIGN_API
 #include <xenctrl.h>
-#include <xc_private.h>
+// #include <xc_private.h>
 #include <xen/event_channel.h>
 #include <xen/vm_event.h>
 
@@ -44,6 +50,7 @@ struct vm_event {
 
 struct xenpaging {
     xc_interface *xc_handle;
+    xentoollog_logger *logger;
     struct xs_handle *xs_handle;
 
     unsigned long *bitmap;
@@ -67,9 +74,70 @@ struct xenpaging {
     unsigned long pagein_queue[XENPAGING_PAGEIN_QUEUE_SIZE];
 };
 
+#define DPRINTF(msg, args...) xtl_log(paging->logger, XTL_DETAIL, 0,      \
+                                      "paging", msg, ## args)
+#define ERROR(msg, args...)   xtl_log(paging->logger, XTL_ERROR, -1,      \
+                                      "paging", msg, ## args)
+#define PERROR(msg, args...)  xtl_log(paging->logger, XTL_ERROR, -1,      \
+                                      "paging", msg "(%d = %s)", ## args, \
+                                      errno, strerror(errno))
+
 extern void create_page_in_thread(struct xenpaging *paging);
 extern void page_in_trigger(void);
 
+#define BITS_PER_LONG (sizeof(unsigned long) * 8)
+#define ORDER_LONG (sizeof(unsigned long) == 4 ? 5 : 6)
+
+#define BITMAP_ENTRY(_nr,_bmap) ((_bmap))[(_nr) / 8]
+#define BITMAP_SHIFT(_nr) ((_nr) % 8)
+
+static inline int bitmap_size(int nr_bits)
+{
+    return (nr_bits + 7) / 8;
+}
+
+static inline void *bitmap_alloc(int nr_bits)
+{
+    return calloc(1, bitmap_size(nr_bits));
+}
+
+static inline void bitmap_clear(void *addr, int nr_bits)
+{
+    memset(addr, 0, bitmap_size(nr_bits));
+}
+
+static inline int test_bit(int nr, const void *_addr)
+{
+    const char *addr = _addr;
+    return (BITMAP_ENTRY(nr, addr) >> BITMAP_SHIFT(nr)) & 1;
+}
+
+static inline void clear_bit(int nr, void *_addr)
+{
+    char *addr = _addr;
+    BITMAP_ENTRY(nr, addr) &= ~(1UL << BITMAP_SHIFT(nr));
+}
+
+static inline void set_bit(int nr, void *_addr)
+{
+    char *addr = _addr;
+    BITMAP_ENTRY(nr, addr) |= (1UL << BITMAP_SHIFT(nr));
+}
+
+static inline int test_and_clear_bit(int nr, void *addr)
+{
+    int oldbit = test_bit(nr, addr);
+    clear_bit(nr, addr);
+    return oldbit;
+}
+
+static inline int test_and_set_bit(int nr, void *addr)
+{
+    int oldbit = test_bit(nr, addr);
+    set_bit(nr, addr);
+    return oldbit;
+}
+
 #endif // __XEN_PAGING_H__
 
 
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 18/31] tools: move libxenctrl below tools/libs
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (16 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 17/31] tools/xenpaging: remove libxc internals Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 19/31] tools/libxc: move libxenguest to tools/libs/guest Juergen Gross
                   ` (12 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel, xen-devel
  Cc: Juergen Gross, Andrew Cooper, George Dunlap, Ian Jackson,
	Jan Beulich, Julien Grall, Stefano Stabellini, Wei Liu,
	Samuel Thibault, Josh Whitehead, Stewart Hildebrand,
	Christian Lindig, David Scott, Marek Marczykowski-Górecki

Today tools/libxc needs to be built after tools/libs as libxenctrl is
depending on some libraries in tools/libs. This in turn blocks moving
other libraries depending on libxenctrl below tools/libs.

So carve out libxenctrl from tools/libxc and move it into
tools/libs/ctrl.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org> (stubdom parts)
Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com> (python parts)
Acked-by: Wei Liu <wl@xen.org>
---
 .gitignore                                    |   8 ++
 MAINTAINERS                                   |   2 +-
 stubdom/Makefile                              |   9 +-
 stubdom/grub/Makefile                         |   4 +-
 stubdom/mini-os.mk                            |   2 +-
 tools/Rules.mk                                |   8 +-
 tools/libs/Makefile                           |   1 +
 tools/libs/ctrl/Makefile                      |  72 ++++++++++++
 tools/{libxc => libs/ctrl}/include/xenctrl.h  |   0
 .../ctrl}/include/xenctrl_compat.h            |   0
 .../ctrl}/include/xenctrl_dom.h               |   0
 tools/{libxc => libs/ctrl}/xc_altp2m.c        |   0
 tools/{libxc => libs/ctrl}/xc_arinc653.c      |   0
 tools/{libxc => libs/ctrl}/xc_bitops.h        |   0
 tools/{libxc => libs/ctrl}/xc_core.c          |   0
 tools/{libxc => libs/ctrl}/xc_core.h          |   0
 tools/{libxc => libs/ctrl}/xc_core_arm.c      |   0
 tools/{libxc => libs/ctrl}/xc_core_arm.h      |   0
 tools/{libxc => libs/ctrl}/xc_core_x86.c      |   0
 tools/{libxc => libs/ctrl}/xc_core_x86.h      |   0
 tools/{libxc => libs/ctrl}/xc_cpu_hotplug.c   |   0
 tools/{libxc => libs/ctrl}/xc_cpupool.c       |   0
 tools/{libxc => libs/ctrl}/xc_csched.c        |   0
 tools/{libxc => libs/ctrl}/xc_csched2.c       |   0
 .../ctrl}/xc_devicemodel_compat.c             |   0
 tools/{libxc => libs/ctrl}/xc_domain.c        |   0
 tools/{libxc => libs/ctrl}/xc_evtchn.c        |   0
 tools/{libxc => libs/ctrl}/xc_evtchn_compat.c |   0
 tools/{libxc => libs/ctrl}/xc_flask.c         |   0
 .../{libxc => libs/ctrl}/xc_foreign_memory.c  |   0
 tools/{libxc => libs/ctrl}/xc_freebsd.c       |   0
 tools/{libxc => libs/ctrl}/xc_gnttab.c        |   0
 tools/{libxc => libs/ctrl}/xc_gnttab_compat.c |   0
 tools/{libxc => libs/ctrl}/xc_hcall_buf.c     |   0
 tools/{libxc => libs/ctrl}/xc_kexec.c         |   0
 tools/{libxc => libs/ctrl}/xc_linux.c         |   0
 tools/{libxc => libs/ctrl}/xc_mem_access.c    |   0
 tools/{libxc => libs/ctrl}/xc_mem_paging.c    |   0
 tools/{libxc => libs/ctrl}/xc_memshr.c        |   0
 tools/{libxc => libs/ctrl}/xc_minios.c        |   0
 tools/{libxc => libs/ctrl}/xc_misc.c          |   0
 tools/{libxc => libs/ctrl}/xc_monitor.c       |   0
 tools/{libxc => libs/ctrl}/xc_msr_x86.h       |   0
 tools/{libxc => libs/ctrl}/xc_netbsd.c        |   0
 tools/{libxc => libs/ctrl}/xc_pagetab.c       |   0
 tools/{libxc => libs/ctrl}/xc_physdev.c       |   0
 tools/{libxc => libs/ctrl}/xc_pm.c            |   0
 tools/{libxc => libs/ctrl}/xc_private.c       |   0
 tools/{libxc => libs/ctrl}/xc_private.h       |   0
 tools/{libxc => libs/ctrl}/xc_psr.c           |   0
 tools/{libxc => libs/ctrl}/xc_resource.c      |   0
 tools/{libxc => libs/ctrl}/xc_resume.c        |   0
 tools/{libxc => libs/ctrl}/xc_rt.c            |   0
 tools/{libxc => libs/ctrl}/xc_solaris.c       |   0
 tools/{libxc => libs/ctrl}/xc_tbuf.c          |   0
 tools/{libxc => libs/ctrl}/xc_vm_event.c      |   0
 tools/libs/uselibs.mk                         |   2 +
 tools/libxc/Makefile                          | 109 ++----------------
 tools/ocaml/xenstored/Makefile                |   2 +-
 tools/python/Makefile                         |   2 +-
 tools/python/setup.py                         |   8 +-
 61 files changed, 111 insertions(+), 118 deletions(-)
 create mode 100644 tools/libs/ctrl/Makefile
 rename tools/{libxc => libs/ctrl}/include/xenctrl.h (100%)
 rename tools/{libxc => libs/ctrl}/include/xenctrl_compat.h (100%)
 rename tools/{libxc => libs/ctrl}/include/xenctrl_dom.h (100%)
 rename tools/{libxc => libs/ctrl}/xc_altp2m.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_arinc653.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_bitops.h (100%)
 rename tools/{libxc => libs/ctrl}/xc_core.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_core.h (100%)
 rename tools/{libxc => libs/ctrl}/xc_core_arm.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_core_arm.h (100%)
 rename tools/{libxc => libs/ctrl}/xc_core_x86.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_core_x86.h (100%)
 rename tools/{libxc => libs/ctrl}/xc_cpu_hotplug.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_cpupool.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_csched.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_csched2.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_devicemodel_compat.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_domain.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_evtchn.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_evtchn_compat.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_flask.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_foreign_memory.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_freebsd.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_gnttab.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_gnttab_compat.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_hcall_buf.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_kexec.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_linux.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_mem_access.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_mem_paging.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_memshr.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_minios.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_misc.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_monitor.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_msr_x86.h (100%)
 rename tools/{libxc => libs/ctrl}/xc_netbsd.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_pagetab.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_physdev.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_pm.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_private.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_private.h (100%)
 rename tools/{libxc => libs/ctrl}/xc_psr.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_resource.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_resume.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_rt.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_solaris.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_tbuf.c (100%)
 rename tools/{libxc => libs/ctrl}/xc_vm_event.c (100%)

diff --git a/.gitignore b/.gitignore
index 823f4743dc..d22b031ed2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -114,6 +114,9 @@ tools/libs/hypfs/headers.chk
 tools/libs/hypfs/xenhypfs.pc
 tools/libs/call/headers.chk
 tools/libs/call/xencall.pc
+tools/libs/ctrl/_*.[ch]
+tools/libs/ctrl/libxenctrl.map
+tools/libs/ctrl/xencontrol.pc
 tools/libs/foreignmemory/headers.chk
 tools/libs/foreignmemory/xenforeignmemory.pc
 tools/libs/devicemodel/headers.chk
@@ -195,6 +198,11 @@ tools/include/xen-foreign/*.(c|h|size)
 tools/include/xen-foreign/checker
 tools/libvchan/xenvchan.pc
 tools/libxc/*.pc
+tools/libxc/xc_bitops.h
+tools/libxc/xc_core.h
+tools/libxc/xc_core_arm.h
+tools/libxc/xc_core_x86.h
+tools/libxc/xc_private.h
 tools/libxl/_libxl.api-for-check
 tools/libxl/*.api-ok
 tools/libxl/*.pc
diff --git a/MAINTAINERS b/MAINTAINERS
index ffe2310294..26c5382075 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -226,7 +226,7 @@ M:	Stewart Hildebrand <stewart.hildebrand@dornerworks.com>
 S:	Supported
 L:	xen-devel@dornerworks.com
 F:	xen/common/sched/arinc653.c
-F:	tools/libxc/xc_arinc653.c
+F:	tools/libs/ctrl/xc_arinc653.c
 
 ARM (W/ VIRTUALISATION EXTENSIONS) ARCHITECTURE
 M:	Stefano Stabellini <sstabellini@kernel.org>
diff --git a/stubdom/Makefile b/stubdom/Makefile
index c466858db0..961a9f8704 100644
--- a/stubdom/Makefile
+++ b/stubdom/Makefile
@@ -331,7 +331,7 @@ endif
 # libraries under tools/libs
 #######
 
-STUB_LIBS := toolcore toollog evtchn gnttab call foreignmemory devicemodel
+STUB_LIBS := toolcore toollog evtchn gnttab call foreignmemory devicemodel ctrl
 
 #######
 # common handling
@@ -396,12 +396,11 @@ $(TARGETS_MINIOS): mini-os-%:
 #######
 
 .PHONY: libxc
-libxc: libxc-$(XEN_TARGET_ARCH)/libxenctrl.a libxc-$(XEN_TARGET_ARCH)/libxenguest.a
-libxc-$(XEN_TARGET_ARCH)/libxenctrl.a: mk-headers-$(XEN_TARGET_ARCH) libxentoollog libxenevtchn libxengnttab libxencall libxenforeignmemory libxendevicemodel cross-zlib
+libxc: libxc-$(XEN_TARGET_ARCH)/libxenguest.a
+libxc-$(XEN_TARGET_ARCH)/libxenguest.a: libxenevtchn libxenctrl cross-zlib
+libxc-$(XEN_TARGET_ARCH)/libxenguest.a: mk-headers-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE)
 	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= CONFIG_LIBXC_MINIOS=y -C libxc-$(XEN_TARGET_ARCH)
 
- libxc-$(XEN_TARGET_ARCH)/libxenguest.a: libxc-$(XEN_TARGET_ARCH)/libxenctrl.a
-
 #######
 # ioemu
 #######
diff --git a/stubdom/grub/Makefile b/stubdom/grub/Makefile
index 26dff45a8f..d33fa2f71e 100644
--- a/stubdom/grub/Makefile
+++ b/stubdom/grub/Makefile
@@ -6,7 +6,9 @@ vpath %.c ../grub-upstream
 BOOT=$(OBJ_DIR)/boot-$(XEN_TARGET_ARCH).o
 
 DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/libs/toollog/include
-DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/libxc/include -I$(XEN_ROOT)/tools/include -I.
+DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/libs/ctrl/include
+DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/libxc/include
+DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/include -I.
 DEF_CPPFLAGS += -I../grub-upstream/stage1
 DEF_CPPFLAGS += -I../grub-upstream/stage2
 DEF_CPPFLAGS += -I../grub-upstream/netboot
diff --git a/stubdom/mini-os.mk b/stubdom/mini-os.mk
index 32528bb91f..b1387df3f8 100644
--- a/stubdom/mini-os.mk
+++ b/stubdom/mini-os.mk
@@ -13,5 +13,5 @@ GNTTAB_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/gnttab
 CALL_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/call
 FOREIGNMEMORY_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/foreignmemory
 DEVICEMODEL_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/devicemodel
-CTRL_PATH = $(XEN_ROOT)/stubdom/libxc-$(MINIOS_TARGET_ARCH)
+CTRL_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/ctrl
 GUEST_PATH = $(XEN_ROOT)/stubdom/libxc-$(MINIOS_TARGET_ARCH)
diff --git a/tools/Rules.mk b/tools/Rules.mk
index 4f3aaaacd3..1cc56e9ab8 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -15,7 +15,6 @@ XEN_INCLUDE        = $(XEN_ROOT)/tools/include
 
 include $(XEN_ROOT)/tools/libs/uselibs.mk
 
-XEN_libxenctrl     = $(XEN_ROOT)/tools/libxc
 XEN_libxenguest    = $(XEN_ROOT)/tools/libxc
 XEN_libxenlight    = $(XEN_ROOT)/tools/libxl
 # Currently libxlutil lives in the same directory as libxenlight
@@ -105,13 +104,10 @@ $(foreach lib,$(LIBS_LIBS),$(eval $(call LIB_defs,$(lib))))
 
 # code which compiles against libxenctrl get __XEN_TOOLS__ and
 # therefore sees the unstable hypercall interfaces.
-CFLAGS_libxenctrl = -I$(XEN_libxenctrl)/include $(CFLAGS_libxentoollog) $(CFLAGS_libxenforeignmemory) $(CFLAGS_libxendevicemodel) $(CFLAGS_xeninclude) -D__XEN_TOOLS__
-SHDEPS_libxenctrl = $(SHLIB_libxentoollog) $(SHLIB_libxenevtchn) $(SHLIB_libxengnttab) $(SHLIB_libxencall) $(SHLIB_libxenforeignmemory) $(SHLIB_libxendevicemodel)
-LDLIBS_libxenctrl = $(SHDEPS_libxenctrl) $(XEN_libxenctrl)/libxenctrl$(libextension)
-SHLIB_libxenctrl  = $(SHDEPS_libxenctrl) -Wl,-rpath-link=$(XEN_libxenctrl)
+CFLAGS_libxenctrl += $(CFLAGS_libxentoollog) $(CFLAGS_libxenforeignmemory) $(CFLAGS_libxendevicemodel) -D__XEN_TOOLS__
 
 CFLAGS_libxenguest = -I$(XEN_libxenguest)/include $(CFLAGS_libxenevtchn) $(CFLAGS_libxenforeignmemory) $(CFLAGS_xeninclude)
-SHDEPS_libxenguest = $(SHLIB_libxenevtchn)
+SHDEPS_libxenguest = $(SHLIB_libxenevtchn) $(SHLIB_libxenctrl)
 LDLIBS_libxenguest = $(SHDEPS_libxenguest) $(XEN_libxenguest)/libxenguest$(libextension)
 SHLIB_libxenguest  = $(SHDEPS_libxenguest) -Wl,-rpath-link=$(XEN_libxenguest)
 
diff --git a/tools/libs/Makefile b/tools/libs/Makefile
index 69cdfb5975..7648ea0e4c 100644
--- a/tools/libs/Makefile
+++ b/tools/libs/Makefile
@@ -9,6 +9,7 @@ SUBDIRS-y += gnttab
 SUBDIRS-y += call
 SUBDIRS-y += foreignmemory
 SUBDIRS-y += devicemodel
+SUBDIRS-y += ctrl
 SUBDIRS-y += hypfs
 
 ifeq ($(CONFIG_RUMP),y)
diff --git a/tools/libs/ctrl/Makefile b/tools/libs/ctrl/Makefile
new file mode 100644
index 0000000000..ec93fb5b73
--- /dev/null
+++ b/tools/libs/ctrl/Makefile
@@ -0,0 +1,72 @@
+XEN_ROOT = $(CURDIR)/../../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+SRCS-y       += xc_altp2m.c
+SRCS-y       += xc_core.c
+SRCS-$(CONFIG_X86) += xc_core_x86.c
+SRCS-$(CONFIG_ARM) += xc_core_arm.c
+SRCS-y       += xc_cpupool.c
+SRCS-y       += xc_domain.c
+SRCS-y       += xc_evtchn.c
+SRCS-y       += xc_gnttab.c
+SRCS-y       += xc_misc.c
+SRCS-y       += xc_flask.c
+SRCS-y       += xc_physdev.c
+SRCS-y       += xc_private.c
+SRCS-y       += xc_csched.c
+SRCS-y       += xc_csched2.c
+SRCS-y       += xc_arinc653.c
+SRCS-y       += xc_rt.c
+SRCS-y       += xc_tbuf.c
+SRCS-y       += xc_pm.c
+SRCS-y       += xc_cpu_hotplug.c
+SRCS-y       += xc_resume.c
+SRCS-y       += xc_vm_event.c
+SRCS-y       += xc_monitor.c
+SRCS-y       += xc_mem_paging.c
+SRCS-y       += xc_mem_access.c
+SRCS-y       += xc_memshr.c
+SRCS-y       += xc_hcall_buf.c
+SRCS-y       += xc_foreign_memory.c
+SRCS-y       += xc_kexec.c
+SRCS-y       += xc_resource.c
+SRCS-$(CONFIG_X86) += xc_psr.c
+SRCS-$(CONFIG_X86) += xc_pagetab.c
+SRCS-$(CONFIG_Linux) += xc_linux.c
+SRCS-$(CONFIG_FreeBSD) += xc_freebsd.c
+SRCS-$(CONFIG_SunOS) += xc_solaris.c
+SRCS-$(CONFIG_NetBSD) += xc_netbsd.c
+SRCS-$(CONFIG_NetBSDRump) += xc_netbsd.c
+SRCS-$(CONFIG_MiniOS) += xc_minios.c
+SRCS-y       += xc_evtchn_compat.c
+SRCS-y       += xc_gnttab_compat.c
+SRCS-y       += xc_devicemodel_compat.c
+
+CFLAGS   += -D__XEN_TOOLS__
+CFLAGS	+= $(PTHREAD_CFLAGS)
+CFLAGS += -include $(XEN_ROOT)/tools/config.h
+
+# Needed for posix_fadvise64() in xc_linux.c
+CFLAGS-$(CONFIG_Linux) += -D_GNU_SOURCE
+
+LIBHEADER := xenctrl.h xenctrl_compat.h xenctrl_dom.h
+PKG_CONFIG := xencontrol.pc
+PKG_CONFIG_NAME := Xencontrol
+
+NO_HEADERS_CHK := y
+
+include $(XEN_ROOT)/tools/libs/libs.mk
+
+genpath-target = $(call buildmakevars2header,_paths.h)
+$(eval $(genpath-target))
+
+$(LIB_OBJS) $(PIC_OBJS): _paths.h
+
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxenctrl)/include
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL = $(CFLAGS_xeninclude)
+
+clean: cleanlocal
+
+.PHONY: cleanlocal
+cleanlocal:
+	rm -f libxenctrl.map
diff --git a/tools/libxc/include/xenctrl.h b/tools/libs/ctrl/include/xenctrl.h
similarity index 100%
rename from tools/libxc/include/xenctrl.h
rename to tools/libs/ctrl/include/xenctrl.h
diff --git a/tools/libxc/include/xenctrl_compat.h b/tools/libs/ctrl/include/xenctrl_compat.h
similarity index 100%
rename from tools/libxc/include/xenctrl_compat.h
rename to tools/libs/ctrl/include/xenctrl_compat.h
diff --git a/tools/libxc/include/xenctrl_dom.h b/tools/libs/ctrl/include/xenctrl_dom.h
similarity index 100%
rename from tools/libxc/include/xenctrl_dom.h
rename to tools/libs/ctrl/include/xenctrl_dom.h
diff --git a/tools/libxc/xc_altp2m.c b/tools/libs/ctrl/xc_altp2m.c
similarity index 100%
rename from tools/libxc/xc_altp2m.c
rename to tools/libs/ctrl/xc_altp2m.c
diff --git a/tools/libxc/xc_arinc653.c b/tools/libs/ctrl/xc_arinc653.c
similarity index 100%
rename from tools/libxc/xc_arinc653.c
rename to tools/libs/ctrl/xc_arinc653.c
diff --git a/tools/libxc/xc_bitops.h b/tools/libs/ctrl/xc_bitops.h
similarity index 100%
rename from tools/libxc/xc_bitops.h
rename to tools/libs/ctrl/xc_bitops.h
diff --git a/tools/libxc/xc_core.c b/tools/libs/ctrl/xc_core.c
similarity index 100%
rename from tools/libxc/xc_core.c
rename to tools/libs/ctrl/xc_core.c
diff --git a/tools/libxc/xc_core.h b/tools/libs/ctrl/xc_core.h
similarity index 100%
rename from tools/libxc/xc_core.h
rename to tools/libs/ctrl/xc_core.h
diff --git a/tools/libxc/xc_core_arm.c b/tools/libs/ctrl/xc_core_arm.c
similarity index 100%
rename from tools/libxc/xc_core_arm.c
rename to tools/libs/ctrl/xc_core_arm.c
diff --git a/tools/libxc/xc_core_arm.h b/tools/libs/ctrl/xc_core_arm.h
similarity index 100%
rename from tools/libxc/xc_core_arm.h
rename to tools/libs/ctrl/xc_core_arm.h
diff --git a/tools/libxc/xc_core_x86.c b/tools/libs/ctrl/xc_core_x86.c
similarity index 100%
rename from tools/libxc/xc_core_x86.c
rename to tools/libs/ctrl/xc_core_x86.c
diff --git a/tools/libxc/xc_core_x86.h b/tools/libs/ctrl/xc_core_x86.h
similarity index 100%
rename from tools/libxc/xc_core_x86.h
rename to tools/libs/ctrl/xc_core_x86.h
diff --git a/tools/libxc/xc_cpu_hotplug.c b/tools/libs/ctrl/xc_cpu_hotplug.c
similarity index 100%
rename from tools/libxc/xc_cpu_hotplug.c
rename to tools/libs/ctrl/xc_cpu_hotplug.c
diff --git a/tools/libxc/xc_cpupool.c b/tools/libs/ctrl/xc_cpupool.c
similarity index 100%
rename from tools/libxc/xc_cpupool.c
rename to tools/libs/ctrl/xc_cpupool.c
diff --git a/tools/libxc/xc_csched.c b/tools/libs/ctrl/xc_csched.c
similarity index 100%
rename from tools/libxc/xc_csched.c
rename to tools/libs/ctrl/xc_csched.c
diff --git a/tools/libxc/xc_csched2.c b/tools/libs/ctrl/xc_csched2.c
similarity index 100%
rename from tools/libxc/xc_csched2.c
rename to tools/libs/ctrl/xc_csched2.c
diff --git a/tools/libxc/xc_devicemodel_compat.c b/tools/libs/ctrl/xc_devicemodel_compat.c
similarity index 100%
rename from tools/libxc/xc_devicemodel_compat.c
rename to tools/libs/ctrl/xc_devicemodel_compat.c
diff --git a/tools/libxc/xc_domain.c b/tools/libs/ctrl/xc_domain.c
similarity index 100%
rename from tools/libxc/xc_domain.c
rename to tools/libs/ctrl/xc_domain.c
diff --git a/tools/libxc/xc_evtchn.c b/tools/libs/ctrl/xc_evtchn.c
similarity index 100%
rename from tools/libxc/xc_evtchn.c
rename to tools/libs/ctrl/xc_evtchn.c
diff --git a/tools/libxc/xc_evtchn_compat.c b/tools/libs/ctrl/xc_evtchn_compat.c
similarity index 100%
rename from tools/libxc/xc_evtchn_compat.c
rename to tools/libs/ctrl/xc_evtchn_compat.c
diff --git a/tools/libxc/xc_flask.c b/tools/libs/ctrl/xc_flask.c
similarity index 100%
rename from tools/libxc/xc_flask.c
rename to tools/libs/ctrl/xc_flask.c
diff --git a/tools/libxc/xc_foreign_memory.c b/tools/libs/ctrl/xc_foreign_memory.c
similarity index 100%
rename from tools/libxc/xc_foreign_memory.c
rename to tools/libs/ctrl/xc_foreign_memory.c
diff --git a/tools/libxc/xc_freebsd.c b/tools/libs/ctrl/xc_freebsd.c
similarity index 100%
rename from tools/libxc/xc_freebsd.c
rename to tools/libs/ctrl/xc_freebsd.c
diff --git a/tools/libxc/xc_gnttab.c b/tools/libs/ctrl/xc_gnttab.c
similarity index 100%
rename from tools/libxc/xc_gnttab.c
rename to tools/libs/ctrl/xc_gnttab.c
diff --git a/tools/libxc/xc_gnttab_compat.c b/tools/libs/ctrl/xc_gnttab_compat.c
similarity index 100%
rename from tools/libxc/xc_gnttab_compat.c
rename to tools/libs/ctrl/xc_gnttab_compat.c
diff --git a/tools/libxc/xc_hcall_buf.c b/tools/libs/ctrl/xc_hcall_buf.c
similarity index 100%
rename from tools/libxc/xc_hcall_buf.c
rename to tools/libs/ctrl/xc_hcall_buf.c
diff --git a/tools/libxc/xc_kexec.c b/tools/libs/ctrl/xc_kexec.c
similarity index 100%
rename from tools/libxc/xc_kexec.c
rename to tools/libs/ctrl/xc_kexec.c
diff --git a/tools/libxc/xc_linux.c b/tools/libs/ctrl/xc_linux.c
similarity index 100%
rename from tools/libxc/xc_linux.c
rename to tools/libs/ctrl/xc_linux.c
diff --git a/tools/libxc/xc_mem_access.c b/tools/libs/ctrl/xc_mem_access.c
similarity index 100%
rename from tools/libxc/xc_mem_access.c
rename to tools/libs/ctrl/xc_mem_access.c
diff --git a/tools/libxc/xc_mem_paging.c b/tools/libs/ctrl/xc_mem_paging.c
similarity index 100%
rename from tools/libxc/xc_mem_paging.c
rename to tools/libs/ctrl/xc_mem_paging.c
diff --git a/tools/libxc/xc_memshr.c b/tools/libs/ctrl/xc_memshr.c
similarity index 100%
rename from tools/libxc/xc_memshr.c
rename to tools/libs/ctrl/xc_memshr.c
diff --git a/tools/libxc/xc_minios.c b/tools/libs/ctrl/xc_minios.c
similarity index 100%
rename from tools/libxc/xc_minios.c
rename to tools/libs/ctrl/xc_minios.c
diff --git a/tools/libxc/xc_misc.c b/tools/libs/ctrl/xc_misc.c
similarity index 100%
rename from tools/libxc/xc_misc.c
rename to tools/libs/ctrl/xc_misc.c
diff --git a/tools/libxc/xc_monitor.c b/tools/libs/ctrl/xc_monitor.c
similarity index 100%
rename from tools/libxc/xc_monitor.c
rename to tools/libs/ctrl/xc_monitor.c
diff --git a/tools/libxc/xc_msr_x86.h b/tools/libs/ctrl/xc_msr_x86.h
similarity index 100%
rename from tools/libxc/xc_msr_x86.h
rename to tools/libs/ctrl/xc_msr_x86.h
diff --git a/tools/libxc/xc_netbsd.c b/tools/libs/ctrl/xc_netbsd.c
similarity index 100%
rename from tools/libxc/xc_netbsd.c
rename to tools/libs/ctrl/xc_netbsd.c
diff --git a/tools/libxc/xc_pagetab.c b/tools/libs/ctrl/xc_pagetab.c
similarity index 100%
rename from tools/libxc/xc_pagetab.c
rename to tools/libs/ctrl/xc_pagetab.c
diff --git a/tools/libxc/xc_physdev.c b/tools/libs/ctrl/xc_physdev.c
similarity index 100%
rename from tools/libxc/xc_physdev.c
rename to tools/libs/ctrl/xc_physdev.c
diff --git a/tools/libxc/xc_pm.c b/tools/libs/ctrl/xc_pm.c
similarity index 100%
rename from tools/libxc/xc_pm.c
rename to tools/libs/ctrl/xc_pm.c
diff --git a/tools/libxc/xc_private.c b/tools/libs/ctrl/xc_private.c
similarity index 100%
rename from tools/libxc/xc_private.c
rename to tools/libs/ctrl/xc_private.c
diff --git a/tools/libxc/xc_private.h b/tools/libs/ctrl/xc_private.h
similarity index 100%
rename from tools/libxc/xc_private.h
rename to tools/libs/ctrl/xc_private.h
diff --git a/tools/libxc/xc_psr.c b/tools/libs/ctrl/xc_psr.c
similarity index 100%
rename from tools/libxc/xc_psr.c
rename to tools/libs/ctrl/xc_psr.c
diff --git a/tools/libxc/xc_resource.c b/tools/libs/ctrl/xc_resource.c
similarity index 100%
rename from tools/libxc/xc_resource.c
rename to tools/libs/ctrl/xc_resource.c
diff --git a/tools/libxc/xc_resume.c b/tools/libs/ctrl/xc_resume.c
similarity index 100%
rename from tools/libxc/xc_resume.c
rename to tools/libs/ctrl/xc_resume.c
diff --git a/tools/libxc/xc_rt.c b/tools/libs/ctrl/xc_rt.c
similarity index 100%
rename from tools/libxc/xc_rt.c
rename to tools/libs/ctrl/xc_rt.c
diff --git a/tools/libxc/xc_solaris.c b/tools/libs/ctrl/xc_solaris.c
similarity index 100%
rename from tools/libxc/xc_solaris.c
rename to tools/libs/ctrl/xc_solaris.c
diff --git a/tools/libxc/xc_tbuf.c b/tools/libs/ctrl/xc_tbuf.c
similarity index 100%
rename from tools/libxc/xc_tbuf.c
rename to tools/libs/ctrl/xc_tbuf.c
diff --git a/tools/libxc/xc_vm_event.c b/tools/libs/ctrl/xc_vm_event.c
similarity index 100%
rename from tools/libxc/xc_vm_event.c
rename to tools/libs/ctrl/xc_vm_event.c
diff --git a/tools/libs/uselibs.mk b/tools/libs/uselibs.mk
index db73fe314e..8e45e8d917 100644
--- a/tools/libs/uselibs.mk
+++ b/tools/libs/uselibs.mk
@@ -16,3 +16,5 @@ LIBS_LIBS += devicemodel
 USELIBS_devicemodel := toollog toolcore call
 LIBS_LIBS += hypfs
 USELIBS_hypfs := toollog toolcore call
+LIBS_LIBS += ctrl
+USELIBS_ctrl := toollog call evtchn gnttab foreignmemory devicemodel
diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile
index faf2639894..44fa0488c9 100644
--- a/tools/libxc/Makefile
+++ b/tools/libxc/Makefile
@@ -9,47 +9,10 @@ ifeq ($(CONFIG_LIBXC_MINIOS),y)
 override CONFIG_MIGRATE := n
 endif
 
-CTRL_SRCS-y       :=
-CTRL_SRCS-y       += xc_altp2m.c
-CTRL_SRCS-y       += xc_core.c
-CTRL_SRCS-$(CONFIG_X86) += xc_core_x86.c
-CTRL_SRCS-$(CONFIG_ARM) += xc_core_arm.c
-CTRL_SRCS-y       += xc_cpupool.c
-CTRL_SRCS-y       += xc_domain.c
-CTRL_SRCS-y       += xc_evtchn.c
-CTRL_SRCS-y       += xc_gnttab.c
-CTRL_SRCS-y       += xc_misc.c
-CTRL_SRCS-y       += xc_flask.c
-CTRL_SRCS-y       += xc_physdev.c
-CTRL_SRCS-y       += xc_private.c
-CTRL_SRCS-y       += xc_csched.c
-CTRL_SRCS-y       += xc_csched2.c
-CTRL_SRCS-y       += xc_arinc653.c
-CTRL_SRCS-y       += xc_rt.c
-CTRL_SRCS-y       += xc_tbuf.c
-CTRL_SRCS-y       += xc_pm.c
-CTRL_SRCS-y       += xc_cpu_hotplug.c
-CTRL_SRCS-y       += xc_resume.c
-CTRL_SRCS-y       += xc_vm_event.c
-CTRL_SRCS-y       += xc_monitor.c
-CTRL_SRCS-y       += xc_mem_paging.c
-CTRL_SRCS-y       += xc_mem_access.c
-CTRL_SRCS-y       += xc_memshr.c
-CTRL_SRCS-y       += xc_hcall_buf.c
-CTRL_SRCS-y       += xc_foreign_memory.c
-CTRL_SRCS-y       += xc_kexec.c
-CTRL_SRCS-y       += xc_resource.c
-CTRL_SRCS-$(CONFIG_X86) += xc_psr.c
-CTRL_SRCS-$(CONFIG_X86) += xc_pagetab.c
-CTRL_SRCS-$(CONFIG_Linux) += xc_linux.c
-CTRL_SRCS-$(CONFIG_FreeBSD) += xc_freebsd.c
-CTRL_SRCS-$(CONFIG_SunOS) += xc_solaris.c
-CTRL_SRCS-$(CONFIG_NetBSD) += xc_netbsd.c
-CTRL_SRCS-$(CONFIG_NetBSDRump) += xc_netbsd.c
-CTRL_SRCS-$(CONFIG_MiniOS) += xc_minios.c
-CTRL_SRCS-y       += xc_evtchn_compat.c
-CTRL_SRCS-y       += xc_gnttab_compat.c
-CTRL_SRCS-y       += xc_devicemodel_compat.c
+LINK_FILES := xc_private.h xc_core.h xc_core_x86.h xc_core_arm.h xc_bitops.h
+
+$(LINK_FILES):
+	ln -sf $(XEN_ROOT)/tools/libs/ctrl/$(notdir $@) $@
 
 GUEST_SRCS-y :=
 GUEST_SRCS-y += xg_private.c
@@ -124,26 +87,14 @@ CFLAGS	+= $(CFLAGS_libxentoollog)
 CFLAGS	+= $(CFLAGS_libxenevtchn)
 CFLAGS	+= $(CFLAGS_libxendevicemodel)
 
-CTRL_LIB_OBJS := $(patsubst %.c,%.o,$(CTRL_SRCS-y))
-CTRL_PIC_OBJS := $(patsubst %.c,%.opic,$(CTRL_SRCS-y))
-
 GUEST_LIB_OBJS := $(patsubst %.c,%.o,$(GUEST_SRCS-y))
 GUEST_PIC_OBJS := $(patsubst %.c,%.opic,$(GUEST_SRCS-y))
 
-$(CTRL_LIB_OBJS) $(GUEST_LIB_OBJS) \
-$(CTRL_PIC_OBJS) $(GUEST_PIC_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h
+$(GUEST_LIB_OBJS) $(GUEST_PIC_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h
 
 # libxenguest includes xc_private.h, so needs this despite not using
 # this functionality directly.
-$(CTRL_LIB_OBJS) $(GUEST_LIB_OBJS) \
-$(CTRL_PIC_OBJS) $(GUEST_PIC_OBJS): CFLAGS += $(CFLAGS_libxencall) $(CFLAGS_libxenforeignmemory)
-
-$(CTRL_LIB_OBJS) $(CTRL_PIC_OBJS): CFLAGS += $(CFLAGS_libxengnttab)
-
-LIB := libxenctrl.a
-ifneq ($(nosharedlibs),y)
-LIB += libxenctrl.so libxenctrl.so.$(MAJOR) libxenctrl.so.$(MAJOR).$(MINOR)
-endif
+$(GUEST_LIB_OBJS) $(GUEST_PIC_OBJS): CFLAGS += $(CFLAGS_libxencall) $(CFLAGS_libxenforeignmemory)
 
 LIB += libxenguest.a
 ifneq ($(nosharedlibs),y)
@@ -155,28 +106,17 @@ $(eval $(genpath-target))
 
 xc_private.h: _paths.h
 
-$(CTRL_LIB_OBJS) $(GUEST_LIB_OBJS) \
-$(CTRL_PIC_OBJS) $(GUEST_PIC_OBJS): xc_private.h
+$(GUEST_LIB_OBJS) $(GUEST_PIC_OBJS): $(LINK_FILES)
 
-PKG_CONFIG := xencontrol.pc xenguest.pc
+PKG_CONFIG := xenguest.pc
 PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
 
-xencontrol.pc: PKG_CONFIG_NAME = Xencontrol
-xencontrol.pc: PKG_CONFIG_DESC = The Xencontrol library for Xen hypervisor
-xencontrol.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenctrl)
-xencontrol.pc: PKG_CONFIG_LIB = xenctrl
-xencontrol.pc: PKG_CONFIG_REQPRIV = xenevtchn,xengnttab,xencall,xenforeignmemory,xendevicemodel,xentoollog
 xenguest.pc: PKG_CONFIG_NAME = Xenguest
 xenguest.pc: PKG_CONFIG_DESC = The Xenguest library for Xen hypervisor
 xenguest.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenguest)
 xenguest.pc: PKG_CONFIG_LIB = xenguest
 xenguest.pc: PKG_CONFIG_REQPRIV = xentoollog,xencall,xenforeignmemory,xenevtchn
 
-$(PKG_CONFIG_DIR)/xencontrol.pc: PKG_CONFIG_NAME = Xencontrol
-$(PKG_CONFIG_DIR)/xencontrol.pc: PKG_CONFIG_DESC = The Xencontrol library for Xen hypervisor
-$(PKG_CONFIG_DIR)/xencontrol.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenctrl)
-$(PKG_CONFIG_DIR)/xencontrol.pc: PKG_CONFIG_LIB = xenctrl
-$(PKG_CONFIG_DIR)/xencontrol.pc: PKG_CONFIG_REQPRIV = xenevtchn,xengnttab,xencall,xenforeignmemory,xendevicemodel,xentoollog
 $(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_NAME = Xenguest
 $(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_DESC = The Xenguest library for Xen hypervisor
 $(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenguest)
@@ -211,17 +151,11 @@ libs: $(LIB) $(PKG_CONFIG_INST) $(PKG_CONFIG_LOCAL)
 install: build
 	$(INSTALL_DIR) $(DESTDIR)$(libdir)
 	$(INSTALL_DIR) $(DESTDIR)$(includedir)
-	$(INSTALL_SHLIB) libxenctrl.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)
-	$(INSTALL_DATA) libxenctrl.a $(DESTDIR)$(libdir)
-	$(SYMLINK_SHLIB) libxenctrl.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenctrl.so.$(MAJOR)
-	$(SYMLINK_SHLIB) libxenctrl.so.$(MAJOR) $(DESTDIR)$(libdir)/libxenctrl.so
-	$(INSTALL_DATA) include/xenctrl.h include/xenctrl_compat.h include/xenctrl_dom.h $(DESTDIR)$(includedir)
 	$(INSTALL_SHLIB) libxenguest.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)
 	$(INSTALL_DATA) libxenguest.a $(DESTDIR)$(libdir)
 	$(SYMLINK_SHLIB) libxenguest.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenguest.so.$(MAJOR)
 	$(SYMLINK_SHLIB) libxenguest.so.$(MAJOR) $(DESTDIR)$(libdir)/libxenguest.so
 	$(INSTALL_DATA) include/xenguest.h $(DESTDIR)$(includedir)
-	$(INSTALL_DATA) xencontrol.pc $(DESTDIR)$(PKG_INSTALLDIR)
 	$(INSTALL_DATA) xenguest.pc $(DESTDIR)$(PKG_INSTALLDIR)
 
 .PHONY: uninstall
@@ -232,14 +166,6 @@ uninstall:
 	rm -f $(DESTDIR)$(libdir)/libxenguest.so.$(MAJOR)
 	rm -f $(DESTDIR)$(libdir)/libxenguest.so.$(MAJOR).$(MINOR)
 	rm -f $(DESTDIR)$(libdir)/libxenguest.a
-	rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xencontrol.pc
-	rm -f $(DESTDIR)$(includedir)/xenctrl.h
-	rm -f $(DESTDIR)$(includedir)/xenctrl_compat.h
-	rm -f $(DESTDIR)$(includedir)/xenctrl_dom.h
-	rm -f $(DESTDIR)$(libdir)/libxenctrl.so
-	rm -f $(DESTDIR)$(libdir)/libxenctrl.so.$(MAJOR)
-	rm -f $(DESTDIR)$(libdir)/libxenctrl.so.$(MAJOR).$(MINOR)
-	rm -f $(DESTDIR)$(libdir)/libxenctrl.a
 
 .PHONY: TAGS
 TAGS:
@@ -249,8 +175,8 @@ TAGS:
 clean:
 	rm -rf *.rpm $(LIB) *~ $(DEPS_RM) \
             _paths.h \
-	    xencontrol.pc xenguest.pc \
-            $(CTRL_LIB_OBJS) $(CTRL_PIC_OBJS) \
+	    $(LINK_FILES) \
+	    xenguest.pc \
             $(GUEST_LIB_OBJS) $(GUEST_PIC_OBJS)
 
 .PHONY: distclean
@@ -266,19 +192,6 @@ rpm: build
 	mv staging/i386/*.rpm .
 	rm -rf staging
 
-# libxenctrl
-
-libxenctrl.a: $(CTRL_LIB_OBJS)
-	$(AR) rc $@ $^
-
-libxenctrl.so: libxenctrl.so.$(MAJOR)
-	$(SYMLINK_SHLIB) $< $@
-libxenctrl.so.$(MAJOR): libxenctrl.so.$(MAJOR).$(MINOR)
-	$(SYMLINK_SHLIB) $< $@
-
-libxenctrl.so.$(MAJOR).$(MINOR): $(CTRL_PIC_OBJS)
-	$(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenctrl.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS_libxentoollog) $(LDLIBS_libxenevtchn) $(LDLIBS_libxengnttab) $(LDLIBS_libxencall) $(LDLIBS_libxenforeignmemory) $(LDLIBS_libxendevicemodel) $(PTHREAD_LIBS) $(APPEND_LDFLAGS)
-
 # libxenguest
 
 libxenguest.a: $(GUEST_LIB_OBJS)
@@ -299,7 +212,7 @@ xc_dom_bzimageloader.o: CFLAGS += $(filter -D%,$(zlib-options))
 xc_dom_bzimageloader.opic: CFLAGS += $(filter -D%,$(zlib-options))
 
 libxenguest.so.$(MAJOR).$(MINOR): COMPRESSION_LIBS = $(filter -l%,$(zlib-options))
-libxenguest.so.$(MAJOR).$(MINOR): $(GUEST_PIC_OBJS) libxenctrl.so
+libxenguest.so.$(MAJOR).$(MINOR): $(GUEST_PIC_OBJS)
 	$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenguest.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $(GUEST_PIC_OBJS) $(COMPRESSION_LIBS) -lz $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(PTHREAD_LIBS) $(APPEND_LDFLAGS)
 
 -include $(DEPS_INCLUDE)
diff --git a/tools/ocaml/xenstored/Makefile b/tools/ocaml/xenstored/Makefile
index 692a62584e..89ec3ec76a 100644
--- a/tools/ocaml/xenstored/Makefile
+++ b/tools/ocaml/xenstored/Makefile
@@ -69,7 +69,7 @@ XENSTOREDLIBS = \
 	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/eventchn $(OCAML_TOPLEVEL)/libs/eventchn/xeneventchn.cmxa \
 	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xc $(OCAML_TOPLEVEL)/libs/xc/xenctrl.cmxa \
 	-ccopt -L -ccopt $(OCAML_TOPLEVEL)/libs/xb $(OCAML_TOPLEVEL)/libs/xb/xenbus.cmxa \
-	-ccopt -L -ccopt $(XEN_ROOT)/tools/libxc
+	-ccopt -L -ccopt $(XEN_ROOT)/tools/libs/ctrl
 
 PROGRAMS = oxenstored
 
diff --git a/tools/python/Makefile b/tools/python/Makefile
index 8d22c03676..8dc755d6e8 100644
--- a/tools/python/Makefile
+++ b/tools/python/Makefile
@@ -33,7 +33,7 @@ uninstall:
 
 .PHONY: test
 test:
-	LD_LIBRARY_PATH=$$(readlink -f ../libxc):$$(readlink -f ../xenstore) $(PYTHON) -m unittest discover
+	LD_LIBRARY_PATH=$$(readlink -f ../libs/ctrl):$$(readlink -f ../xenstore) $(PYTHON) -m unittest discover
 
 .PHONY: clean
 clean:
diff --git a/tools/python/setup.py b/tools/python/setup.py
index 44696b3998..24b284af39 100644
--- a/tools/python/setup.py
+++ b/tools/python/setup.py
@@ -9,7 +9,7 @@ extra_compile_args  = [ "-fno-strict-aliasing", "-Werror" ]
 PATH_XEN      = XEN_ROOT + "/tools/include"
 PATH_LIBXENTOOLLOG = XEN_ROOT + "/tools/libs/toollog"
 PATH_LIBXENEVTCHN = XEN_ROOT + "/tools/libs/evtchn"
-PATH_LIBXC    = XEN_ROOT + "/tools/libxc"
+PATH_LIBXENCTRL = XEN_ROOT + "/tools/libs/ctrl"
 PATH_LIBXL    = XEN_ROOT + "/tools/libxl"
 PATH_XENSTORE = XEN_ROOT + "/tools/xenstore"
 
@@ -18,11 +18,11 @@ xc = Extension("xc",
                include_dirs       = [ PATH_XEN,
                                       PATH_LIBXENTOOLLOG + "/include",
                                       PATH_LIBXENEVTCHN + "/include",
-                                      PATH_LIBXC + "/include",
+                                      PATH_LIBXENCTRL + "/include",
                                       "xen/lowlevel/xc" ],
-               library_dirs       = [ PATH_LIBXC ],
+               library_dirs       = [ PATH_LIBXENCTRL ],
                libraries          = [ "xenctrl" ],
-               depends            = [ PATH_LIBXC + "/libxenctrl.so" ],
+               depends            = [ PATH_LIBXENCTRL + "/libxenctrl.so" ],
                extra_link_args    = [ "-Wl,-rpath-link="+PATH_LIBXENTOOLLOG ],
                sources            = [ "xen/lowlevel/xc/xc.c" ])
 
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 19/31] tools/libxc: move libxenguest to tools/libs/guest
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (17 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 18/31] tools: move libxenctrl below tools/libs Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 20/31] tools: split libxenstore into new tools/libs/store directory Juergen Gross
                   ` (11 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel
  Cc: Juergen Gross, Andrew Cooper, George Dunlap, Ian Jackson,
	Jan Beulich, Julien Grall, Stefano Stabellini, Wei Liu,
	Samuel Thibault

tools/libxc now contains libxenguest only. Move it to tools/libs/guest.

When generating the pkg-config file for libxenguest a filter is now
required for replacing "xenctrl" by "xencontrol" in the
"Requires.private:" entry. Add this filter to tools/libs/libs.mk.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org> (stubdom parts)
---
 .gitignore                                    |  16 +-
 stubdom/Makefile                              |  34 +--
 stubdom/grub/Makefile                         |   2 +-
 stubdom/mini-os.mk                            |   2 +-
 tools/Makefile                                |   3 +-
 tools/Rules.mk                                |   7 +-
 tools/libs/Makefile                           |   1 +
 tools/{libxc => libs/guest}/COPYING           |   0
 tools/libs/guest/Makefile                     | 121 ++++++++++
 .../{libxc => libs/guest}/include/xenguest.h  |   0
 tools/{libxc => libs/guest}/xg_cpuid_x86.c    |   0
 tools/{libxc => libs/guest}/xg_dom_arm.c      |   0
 .../guest}/xg_dom_armzimageloader.c           |   0
 .../{libxc => libs/guest}/xg_dom_binloader.c  |   0
 tools/{libxc => libs/guest}/xg_dom_boot.c     |   0
 .../guest}/xg_dom_bzimageloader.c             |   0
 .../guest}/xg_dom_compat_linux.c              |   0
 tools/{libxc => libs/guest}/xg_dom_core.c     |   0
 .../{libxc => libs/guest}/xg_dom_decompress.h |   0
 .../guest}/xg_dom_decompress_lz4.c            |   0
 .../guest}/xg_dom_decompress_unsafe.c         |   0
 .../guest}/xg_dom_decompress_unsafe.h         |   0
 .../guest}/xg_dom_decompress_unsafe_bzip2.c   |   0
 .../guest}/xg_dom_decompress_unsafe_lzma.c    |   0
 .../guest}/xg_dom_decompress_unsafe_lzo1x.c   |   0
 .../guest}/xg_dom_decompress_unsafe_xz.c      |   0
 .../{libxc => libs/guest}/xg_dom_elfloader.c  |   0
 .../{libxc => libs/guest}/xg_dom_hvmloader.c  |   0
 tools/{libxc => libs/guest}/xg_dom_x86.c      |   0
 tools/{libxc => libs/guest}/xg_domain.c       |   0
 tools/{libxc => libs/guest}/xg_nomigrate.c    |   0
 tools/{libxc => libs/guest}/xg_offline_page.c |   0
 tools/{libxc => libs/guest}/xg_private.c      |   0
 tools/{libxc => libs/guest}/xg_private.h      |   0
 tools/{libxc => libs/guest}/xg_save_restore.h |   0
 tools/{libxc => libs/guest}/xg_sr_common.c    |   0
 tools/{libxc => libs/guest}/xg_sr_common.h    |   0
 .../{libxc => libs/guest}/xg_sr_common_x86.c  |   0
 .../{libxc => libs/guest}/xg_sr_common_x86.h  |   0
 .../guest}/xg_sr_common_x86_pv.c              |   0
 .../guest}/xg_sr_common_x86_pv.h              |   0
 tools/{libxc => libs/guest}/xg_sr_restore.c   |   0
 .../guest}/xg_sr_restore_x86_hvm.c            |   0
 .../guest}/xg_sr_restore_x86_pv.c             |   0
 tools/{libxc => libs/guest}/xg_sr_save.c      |   0
 .../guest}/xg_sr_save_x86_hvm.c               |   0
 .../{libxc => libs/guest}/xg_sr_save_x86_pv.c |   0
 .../guest}/xg_sr_stream_format.h              |   0
 tools/{libxc => libs/guest}/xg_suspend.c      |   0
 tools/libs/libs.mk                            |   2 +-
 tools/libs/uselibs.mk                         |   2 +
 tools/libxc/Makefile                          | 219 ------------------
 52 files changed, 148 insertions(+), 261 deletions(-)
 rename tools/{libxc => libs/guest}/COPYING (100%)
 create mode 100644 tools/libs/guest/Makefile
 rename tools/{libxc => libs/guest}/include/xenguest.h (100%)
 rename tools/{libxc => libs/guest}/xg_cpuid_x86.c (100%)
 rename tools/{libxc => libs/guest}/xg_dom_arm.c (100%)
 rename tools/{libxc => libs/guest}/xg_dom_armzimageloader.c (100%)
 rename tools/{libxc => libs/guest}/xg_dom_binloader.c (100%)
 rename tools/{libxc => libs/guest}/xg_dom_boot.c (100%)
 rename tools/{libxc => libs/guest}/xg_dom_bzimageloader.c (100%)
 rename tools/{libxc => libs/guest}/xg_dom_compat_linux.c (100%)
 rename tools/{libxc => libs/guest}/xg_dom_core.c (100%)
 rename tools/{libxc => libs/guest}/xg_dom_decompress.h (100%)
 rename tools/{libxc => libs/guest}/xg_dom_decompress_lz4.c (100%)
 rename tools/{libxc => libs/guest}/xg_dom_decompress_unsafe.c (100%)
 rename tools/{libxc => libs/guest}/xg_dom_decompress_unsafe.h (100%)
 rename tools/{libxc => libs/guest}/xg_dom_decompress_unsafe_bzip2.c (100%)
 rename tools/{libxc => libs/guest}/xg_dom_decompress_unsafe_lzma.c (100%)
 rename tools/{libxc => libs/guest}/xg_dom_decompress_unsafe_lzo1x.c (100%)
 rename tools/{libxc => libs/guest}/xg_dom_decompress_unsafe_xz.c (100%)
 rename tools/{libxc => libs/guest}/xg_dom_elfloader.c (100%)
 rename tools/{libxc => libs/guest}/xg_dom_hvmloader.c (100%)
 rename tools/{libxc => libs/guest}/xg_dom_x86.c (100%)
 rename tools/{libxc => libs/guest}/xg_domain.c (100%)
 rename tools/{libxc => libs/guest}/xg_nomigrate.c (100%)
 rename tools/{libxc => libs/guest}/xg_offline_page.c (100%)
 rename tools/{libxc => libs/guest}/xg_private.c (100%)
 rename tools/{libxc => libs/guest}/xg_private.h (100%)
 rename tools/{libxc => libs/guest}/xg_save_restore.h (100%)
 rename tools/{libxc => libs/guest}/xg_sr_common.c (100%)
 rename tools/{libxc => libs/guest}/xg_sr_common.h (100%)
 rename tools/{libxc => libs/guest}/xg_sr_common_x86.c (100%)
 rename tools/{libxc => libs/guest}/xg_sr_common_x86.h (100%)
 rename tools/{libxc => libs/guest}/xg_sr_common_x86_pv.c (100%)
 rename tools/{libxc => libs/guest}/xg_sr_common_x86_pv.h (100%)
 rename tools/{libxc => libs/guest}/xg_sr_restore.c (100%)
 rename tools/{libxc => libs/guest}/xg_sr_restore_x86_hvm.c (100%)
 rename tools/{libxc => libs/guest}/xg_sr_restore_x86_pv.c (100%)
 rename tools/{libxc => libs/guest}/xg_sr_save.c (100%)
 rename tools/{libxc => libs/guest}/xg_sr_save_x86_hvm.c (100%)
 rename tools/{libxc => libs/guest}/xg_sr_save_x86_pv.c (100%)
 rename tools/{libxc => libs/guest}/xg_sr_stream_format.h (100%)
 rename tools/{libxc => libs/guest}/xg_suspend.c (100%)
 delete mode 100644 tools/libxc/Makefile

diff --git a/.gitignore b/.gitignore
index d22b031ed2..eb637a98e9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -71,7 +71,6 @@ stubdom/include
 stubdom/ioemu
 stubdom/ioemu/
 stubdom/libs-*
-stubdom/libxc-*
 stubdom/libxencall-*
 stubdom/libxenevtchn-*
 stubdom/libxenforeignmemory-*
@@ -121,6 +120,14 @@ tools/libs/foreignmemory/headers.chk
 tools/libs/foreignmemory/xenforeignmemory.pc
 tools/libs/devicemodel/headers.chk
 tools/libs/devicemodel/xendevicemodel.pc
+tools/libs/guest/_*.[ch]
+tools/libs/guest/libxenguest.map
+tools/libs/guest/xenguest.pc
+tools/libs/guest/xc_bitops.h
+tools/libs/guest/xc_core.h
+tools/libs/guest/xc_core_arm.h
+tools/libs/guest/xc_core_x86.h
+tools/libs/guest/xc_private.h
 tools/console/xenconsole
 tools/console/xenconsoled
 tools/console/client/_paths.h
@@ -197,12 +204,6 @@ tools/include/xen-xsm/*
 tools/include/xen-foreign/*.(c|h|size)
 tools/include/xen-foreign/checker
 tools/libvchan/xenvchan.pc
-tools/libxc/*.pc
-tools/libxc/xc_bitops.h
-tools/libxc/xc_core.h
-tools/libxc/xc_core_arm.h
-tools/libxc/xc_core_x86.h
-tools/libxc/xc_private.h
 tools/libxl/_libxl.api-for-check
 tools/libxl/*.api-ok
 tools/libxl/*.pc
@@ -370,7 +371,6 @@ tools/include/xen-foreign/arm64.h
 tools/misc/xen-hptool
 tools/misc/xen-mfndump
 tools/libs/toolcore/include/_*.h
-tools/libxc/_*.[ch]
 tools/libxl/_*.[ch]
 tools/libxl/testidl
 tools/libxl/testidl.c
diff --git a/stubdom/Makefile b/stubdom/Makefile
index 961a9f8704..de10281ca3 100644
--- a/stubdom/Makefile
+++ b/stubdom/Makefile
@@ -331,7 +331,9 @@ endif
 # libraries under tools/libs
 #######
 
-STUB_LIBS := toolcore toollog evtchn gnttab call foreignmemory devicemodel ctrl
+STUB_LIBS := toolcore toollog evtchn gnttab call foreignmemory devicemodel ctrl guest
+
+LIBDEP_guest := cross-zlib
 
 #######
 # common handling
@@ -362,13 +364,10 @@ endef
 
 $(foreach lib,$(STUB_LIBS),$(eval $(call BUILD_lib,$(lib))))
 
-libxc-$(XEN_TARGET_ARCH)/stamp: $(XEN_ROOT)/tools/libxc/Makefile
-	$(do_links)
-
 xenstore/stamp: $(XEN_ROOT)/tools/xenstore/Makefile
 	$(do_links)
 
-LINK_DIRS := libxc-$(XEN_TARGET_ARCH) xenstore $(foreach dir,$(STUB_LIBS),libs-$(XEN_TARGET_ARCH)/$(dir))
+LINK_DIRS := xenstore $(foreach dir,$(STUB_LIBS),libs-$(XEN_TARGET_ARCH)/$(dir))
 LINK_STAMPS := $(foreach dir,$(LINK_DIRS),$(dir)/stamp)
 
 mk-headers-$(XEN_TARGET_ARCH): $(IOEMU_LINKFARM_TARGET) $(LINK_STAMPS)
@@ -391,16 +390,6 @@ $(TARGETS_MINIOS): mini-os-%:
                 mkdir -p $@/$$i ; \
 	done
 
-#######
-# libxc
-#######
-
-.PHONY: libxc
-libxc: libxc-$(XEN_TARGET_ARCH)/libxenguest.a
-libxc-$(XEN_TARGET_ARCH)/libxenguest.a: libxenevtchn libxenctrl cross-zlib
-libxc-$(XEN_TARGET_ARCH)/libxenguest.a: mk-headers-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE)
-	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) DESTDIR= CONFIG_LIBXC_MINIOS=y -C libxc-$(XEN_TARGET_ARCH)
-
 #######
 # ioemu
 #######
@@ -409,7 +398,7 @@ ioemu-minios-config.mk: $(CURDIR)/ioemu-minios.cfg
 	MINIOS_CONFIG="$<" CONFIG_FILE="$(CURDIR)/$@" $(MAKE) DESTDIR= -C $(MINI_OS) config
 
 .PHONY: ioemu
-ioemu: cross-zlib cross-libpci libxc ioemu-minios-config.mk
+ioemu: cross-zlib cross-libpci libxenguest ioemu-minios-config.mk
 	[ -f ioemu/config-host.mak ] || \
 	  ( $(buildmakevars2shellvars); \
 	    cd ioemu ; \
@@ -503,15 +492,15 @@ xenstore: $(CROSS_ROOT) xenstore-minios-config.mk
 
 .PHONY: ioemu-stubdom
 ioemu-stubdom: APP_OBJS=$(CURDIR)/ioemu/i386-stubdom/qemu.a $(CURDIR)/ioemu/i386-stubdom/libqemu.a $(CURDIR)/ioemu/libqemu_common.a
-ioemu-stubdom: mini-os-$(XEN_TARGET_ARCH)-ioemu lwip-$(XEN_TARGET_ARCH) libxc ioemu
+ioemu-stubdom: mini-os-$(XEN_TARGET_ARCH)-ioemu lwip-$(XEN_TARGET_ARCH) libxenguest ioemu
 	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="$(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" MINIOS_CONFIG="$(CURDIR)/ioemu-minios.cfg" $(MAKE) DESTDIR= -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS="$(APP_OBJS)"
 
 .PHONY: caml-stubdom
-caml-stubdom: mini-os-$(XEN_TARGET_ARCH)-caml lwip-$(XEN_TARGET_ARCH) libxc cross-ocaml caml
+caml-stubdom: mini-os-$(XEN_TARGET_ARCH)-caml lwip-$(XEN_TARGET_ARCH) libxenguest cross-ocaml caml
 	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="$(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" MINIOS_CONFIG="$(CURDIR)/caml/minios.cfg" $(MAKE) DESTDIR= -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS="$(CURDIR)/caml/main-caml.o $(CURDIR)/caml/caml.o $(CAMLLIB)/libasmrun.a"
 
 .PHONY: c-stubdom
-c-stubdom: mini-os-$(XEN_TARGET_ARCH)-c lwip-$(XEN_TARGET_ARCH) libxc c
+c-stubdom: mini-os-$(XEN_TARGET_ARCH)-c lwip-$(XEN_TARGET_ARCH) libxenguest c
 	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="$(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" MINIOS_CONFIG="$(CURDIR)/c/minios.cfg" $(MAKE) DESTDIR= -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS=$(CURDIR)/c/main.a
 
 .PHONY: vtpm-stubdom
@@ -523,11 +512,11 @@ vtpmmgr-stubdom: mini-os-$(XEN_TARGET_ARCH)-vtpmmgr vtpmmgr
 	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="$(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" MINIOS_CONFIG="$(CURDIR)/vtpmmgr/minios.cfg" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< APP_OBJS="$(CURDIR)/vtpmmgr/vtpmmgr.a" APP_LDLIBS="-lm -lpolarssl"
 
 .PHONY: pv-grub
-pv-grub: mini-os-$(XEN_TARGET_ARCH)-grub libxc grub
+pv-grub: mini-os-$(XEN_TARGET_ARCH)-grub libxenguest grub
 	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="$(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" MINIOS_CONFIG="$(CURDIR)/grub/minios.cfg" $(MAKE) DESTDIR= -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< APP_OBJS=$(CURDIR)/grub-$(XEN_TARGET_ARCH)/main.a
 
 .PHONY: xenstore-stubdom
-xenstore-stubdom: mini-os-$(XEN_TARGET_ARCH)-xenstore libxc xenstore
+xenstore-stubdom: mini-os-$(XEN_TARGET_ARCH)-xenstore libxenguest xenstore
 	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="$(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" MINIOS_CONFIG="$(CURDIR)/xenstore-minios.cfg" $(MAKE) DESTDIR= -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< APP_OBJS=$(CURDIR)/xenstore/xenstored.a
 
 #########
@@ -621,7 +610,6 @@ clean:
 	rm -f $(STUBDOMPATH)
 	rm -f *-minios-config.mk
 	rm -fr pkg-config
-	[ ! -e libxc-$(XEN_TARGET_ARCH)/Makefile ] || $(MAKE) DESTDIR= -C libxc-$(XEN_TARGET_ARCH) clean
 	-[ ! -d ioemu ] || $(MAKE) DESTDIR= -C ioemu clean
 	-[ ! -d xenstore ] || $(MAKE) DESTDIR= -C xenstore clean
 
@@ -632,7 +620,7 @@ crossclean: clean
 	rm -fr newlib-$(XEN_TARGET_ARCH)
 	rm -fr zlib-$(XEN_TARGET_ARCH) pciutils-$(XEN_TARGET_ARCH)
 	rm -fr libs-$(XEN_TARGET_ARCH)
-	rm -fr libxc-$(XEN_TARGET_ARCH) ioemu xenstore
+	rm -fr ioemu xenstore
 	rm -fr gmp-$(XEN_TARGET_ARCH)
 	rm -fr polarssl-$(XEN_TARGET_ARCH)
 	rm -fr openssl-$(XEN_TARGET_ARCH)
diff --git a/stubdom/grub/Makefile b/stubdom/grub/Makefile
index d33fa2f71e..7397661c9b 100644
--- a/stubdom/grub/Makefile
+++ b/stubdom/grub/Makefile
@@ -7,7 +7,7 @@ BOOT=$(OBJ_DIR)/boot-$(XEN_TARGET_ARCH).o
 
 DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/libs/toollog/include
 DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/libs/ctrl/include
-DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/libxc/include
+DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/libs/guest/include
 DEF_CPPFLAGS += -I$(XEN_ROOT)/tools/include -I.
 DEF_CPPFLAGS += -I../grub-upstream/stage1
 DEF_CPPFLAGS += -I../grub-upstream/stage2
diff --git a/stubdom/mini-os.mk b/stubdom/mini-os.mk
index b1387df3f8..e1640a7cbc 100644
--- a/stubdom/mini-os.mk
+++ b/stubdom/mini-os.mk
@@ -14,4 +14,4 @@ CALL_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/call
 FOREIGNMEMORY_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/foreignmemory
 DEVICEMODEL_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/devicemodel
 CTRL_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/ctrl
-GUEST_PATH = $(XEN_ROOT)/stubdom/libxc-$(MINIOS_TARGET_ARCH)
+GUEST_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/guest
diff --git a/tools/Makefile b/tools/Makefile
index 7c9f9fc900..f9b4012290 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -6,7 +6,6 @@ include $(XEN_ROOT)/tools/Rules.mk
 
 SUBDIRS-y :=
 SUBDIRS-y += libs
-SUBDIRS-y += libxc
 SUBDIRS-y += flask
 SUBDIRS-y += fuzz
 SUBDIRS-y += xenstore
@@ -44,7 +43,7 @@ SUBDIRS-y += pygrub
 SUBDIRS-$(OCAML_TOOLS) += ocaml
 
 ifeq ($(CONFIG_RUMP),y)
-SUBDIRS-y := libs libxc xenstore
+SUBDIRS-y := libs xenstore
 endif
 
 # For the sake of linking, set the sys-root
diff --git a/tools/Rules.mk b/tools/Rules.mk
index 1cc56e9ab8..914c79bfb9 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -15,7 +15,6 @@ XEN_INCLUDE        = $(XEN_ROOT)/tools/include
 
 include $(XEN_ROOT)/tools/libs/uselibs.mk
 
-XEN_libxenguest    = $(XEN_ROOT)/tools/libxc
 XEN_libxenlight    = $(XEN_ROOT)/tools/libxl
 # Currently libxlutil lives in the same directory as libxenlight
 XEN_libxlutil      = $(XEN_libxenlight)
@@ -105,11 +104,7 @@ $(foreach lib,$(LIBS_LIBS),$(eval $(call LIB_defs,$(lib))))
 # code which compiles against libxenctrl get __XEN_TOOLS__ and
 # therefore sees the unstable hypercall interfaces.
 CFLAGS_libxenctrl += $(CFLAGS_libxentoollog) $(CFLAGS_libxenforeignmemory) $(CFLAGS_libxendevicemodel) -D__XEN_TOOLS__
-
-CFLAGS_libxenguest = -I$(XEN_libxenguest)/include $(CFLAGS_libxenevtchn) $(CFLAGS_libxenforeignmemory) $(CFLAGS_xeninclude)
-SHDEPS_libxenguest = $(SHLIB_libxenevtchn) $(SHLIB_libxenctrl)
-LDLIBS_libxenguest = $(SHDEPS_libxenguest) $(XEN_libxenguest)/libxenguest$(libextension)
-SHLIB_libxenguest  = $(SHDEPS_libxenguest) -Wl,-rpath-link=$(XEN_libxenguest)
+CFLAGS_libxenguest += $(CFLAGS_libxenevtchn) $(CFLAGS_libxenforeignmemory)
 
 CFLAGS_libxenstore = -I$(XEN_libxenstore)/include $(CFLAGS_xeninclude)
 SHDEPS_libxenstore = $(SHLIB_libxentoolcore) $(SHLIB_libxenctrl)
diff --git a/tools/libs/Makefile b/tools/libs/Makefile
index 7648ea0e4c..f15c1688f7 100644
--- a/tools/libs/Makefile
+++ b/tools/libs/Makefile
@@ -10,6 +10,7 @@ SUBDIRS-y += call
 SUBDIRS-y += foreignmemory
 SUBDIRS-y += devicemodel
 SUBDIRS-y += ctrl
+SUBDIRS-y += guest
 SUBDIRS-y += hypfs
 
 ifeq ($(CONFIG_RUMP),y)
diff --git a/tools/libxc/COPYING b/tools/libs/guest/COPYING
similarity index 100%
rename from tools/libxc/COPYING
rename to tools/libs/guest/COPYING
diff --git a/tools/libs/guest/Makefile b/tools/libs/guest/Makefile
new file mode 100644
index 0000000000..e53aeabd3e
--- /dev/null
+++ b/tools/libs/guest/Makefile
@@ -0,0 +1,121 @@
+XEN_ROOT = $(CURDIR)/../../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+ifeq ($(CONFIG_LIBXC_MINIOS),y)
+# Save/restore of a domain is currently incompatible with a stubdom environment
+override CONFIG_MIGRATE := n
+endif
+
+LINK_FILES := xc_private.h xc_core.h xc_core_x86.h xc_core_arm.h xc_bitops.h
+
+$(LINK_FILES):
+	ln -sf $(XEN_ROOT)/tools/libs/ctrl/$(notdir $@) $@
+
+SRCS-y += xg_private.c
+SRCS-y += xg_domain.c
+SRCS-y += xg_suspend.c
+ifeq ($(CONFIG_MIGRATE),y)
+SRCS-y += xg_sr_common.c
+SRCS-$(CONFIG_X86) += xg_sr_common_x86.c
+SRCS-$(CONFIG_X86) += xg_sr_common_x86_pv.c
+SRCS-$(CONFIG_X86) += xg_sr_restore_x86_pv.c
+SRCS-$(CONFIG_X86) += xg_sr_restore_x86_hvm.c
+SRCS-$(CONFIG_X86) += xg_sr_save_x86_pv.c
+SRCS-$(CONFIG_X86) += xg_sr_save_x86_hvm.c
+SRCS-y += xg_sr_restore.c
+SRCS-y += xg_sr_save.c
+SRCS-y += xg_offline_page.c
+else
+SRCS-y += xg_nomigrate.c
+endif
+
+vpath %.c ../../../xen/common/libelf
+CFLAGS += -I../../../xen/common/libelf
+
+ELF_SRCS-y += libelf-tools.c libelf-loader.c
+ELF_SRCS-y += libelf-dominfo.c
+
+SRCS-y += $(ELF_SRCS-y)
+
+$(patsubst %.c,%.o,$(ELF_SRCS-y)): CFLAGS += -Wno-pointer-sign
+$(patsubst %.c,%.opic,$(ELF_SRCS-y)): CFLAGS += -Wno-pointer-sign
+
+ifeq ($(CONFIG_X86),y) # Add libx86 to the build
+vpath %.c ../../../xen/lib/x86
+
+SRCS-y                 += cpuid.c msr.c
+endif
+
+# new domain builder
+SRCS-y                 += xg_dom_core.c
+SRCS-y                 += xg_dom_boot.c
+SRCS-y                 += xg_dom_elfloader.c
+SRCS-$(CONFIG_X86)     += xg_dom_bzimageloader.c
+SRCS-$(CONFIG_X86)     += xg_dom_decompress_lz4.c
+SRCS-$(CONFIG_X86)     += xg_dom_hvmloader.c
+SRCS-$(CONFIG_ARM)     += xg_dom_armzimageloader.c
+SRCS-y                 += xg_dom_binloader.c
+SRCS-y                 += xg_dom_compat_linux.c
+
+SRCS-$(CONFIG_X86)     += xg_dom_x86.c
+SRCS-$(CONFIG_X86)     += xg_cpuid_x86.c
+SRCS-$(CONFIG_ARM)     += xg_dom_arm.c
+
+ifeq ($(CONFIG_LIBXC_MINIOS),y)
+SRCS-y                 += xg_dom_decompress_unsafe.c
+SRCS-y                 += xg_dom_decompress_unsafe_bzip2.c
+SRCS-y                 += xg_dom_decompress_unsafe_lzma.c
+SRCS-y                 += xg_dom_decompress_unsafe_lzo1x.c
+SRCS-y                 += xg_dom_decompress_unsafe_xz.c
+endif
+
+-include $(XEN_TARGET_ARCH)/Makefile
+
+CFLAGS   += -Werror -Wmissing-prototypes
+CFLAGS   += -I. -I./include $(CFLAGS_xeninclude)
+CFLAGS   += -D__XEN_TOOLS__
+CFLAGS   += -include $(XEN_ROOT)/tools/config.h
+
+# Needed for posix_fadvise64() in xc_linux.c
+CFLAGS-$(CONFIG_Linux) += -D_GNU_SOURCE
+
+CFLAGS	+= $(PTHREAD_CFLAGS)
+CFLAGS	+= $(CFLAGS_libxentoollog)
+CFLAGS	+= $(CFLAGS_libxenevtchn)
+CFLAGS	+= $(CFLAGS_libxendevicemodel)
+
+# libxenguest includes xc_private.h, so needs this despite not using
+# this functionality directly.
+CFLAGS += $(CFLAGS_libxencall) $(CFLAGS_libxenforeignmemory)
+
+ifeq ($(CONFIG_MiniOS),y)
+zlib-options =
+else
+zlib-options = $(ZLIB)
+endif
+
+xc_dom_bzimageloader.o: CFLAGS += $(filter -D%,$(zlib-options))
+xc_dom_bzimageloader.opic: CFLAGS += $(filter -D%,$(zlib-options))
+
+LIBHEADER := xenguest.h
+
+NO_HEADERS_CHK := y
+
+include $(XEN_ROOT)/tools/libs/libs.mk
+
+libxenguest.so.$(MAJOR).$(MINOR): COMPRESSION_LIBS = $(filter -l%,$(zlib-options))
+libxenguest.so.$(MAJOR).$(MINOR): APPEND_LDFLAGS += $(COMPRESSION_LIBS) -lz
+
+genpath-target = $(call buildmakevars2header,_paths.h)
+$(eval $(genpath-target))
+
+xc_private.h: _paths.h
+
+$(LIB_OBJS) $(PIC_OBJS): $(LINK_FILES)
+
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxenctrl)/include
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL = $(CFLAGS_xeninclude)
+
+.PHONY: cleanlocal
+cleanlocal:
+	rm -f libxenguest.map
diff --git a/tools/libxc/include/xenguest.h b/tools/libs/guest/include/xenguest.h
similarity index 100%
rename from tools/libxc/include/xenguest.h
rename to tools/libs/guest/include/xenguest.h
diff --git a/tools/libxc/xg_cpuid_x86.c b/tools/libs/guest/xg_cpuid_x86.c
similarity index 100%
rename from tools/libxc/xg_cpuid_x86.c
rename to tools/libs/guest/xg_cpuid_x86.c
diff --git a/tools/libxc/xg_dom_arm.c b/tools/libs/guest/xg_dom_arm.c
similarity index 100%
rename from tools/libxc/xg_dom_arm.c
rename to tools/libs/guest/xg_dom_arm.c
diff --git a/tools/libxc/xg_dom_armzimageloader.c b/tools/libs/guest/xg_dom_armzimageloader.c
similarity index 100%
rename from tools/libxc/xg_dom_armzimageloader.c
rename to tools/libs/guest/xg_dom_armzimageloader.c
diff --git a/tools/libxc/xg_dom_binloader.c b/tools/libs/guest/xg_dom_binloader.c
similarity index 100%
rename from tools/libxc/xg_dom_binloader.c
rename to tools/libs/guest/xg_dom_binloader.c
diff --git a/tools/libxc/xg_dom_boot.c b/tools/libs/guest/xg_dom_boot.c
similarity index 100%
rename from tools/libxc/xg_dom_boot.c
rename to tools/libs/guest/xg_dom_boot.c
diff --git a/tools/libxc/xg_dom_bzimageloader.c b/tools/libs/guest/xg_dom_bzimageloader.c
similarity index 100%
rename from tools/libxc/xg_dom_bzimageloader.c
rename to tools/libs/guest/xg_dom_bzimageloader.c
diff --git a/tools/libxc/xg_dom_compat_linux.c b/tools/libs/guest/xg_dom_compat_linux.c
similarity index 100%
rename from tools/libxc/xg_dom_compat_linux.c
rename to tools/libs/guest/xg_dom_compat_linux.c
diff --git a/tools/libxc/xg_dom_core.c b/tools/libs/guest/xg_dom_core.c
similarity index 100%
rename from tools/libxc/xg_dom_core.c
rename to tools/libs/guest/xg_dom_core.c
diff --git a/tools/libxc/xg_dom_decompress.h b/tools/libs/guest/xg_dom_decompress.h
similarity index 100%
rename from tools/libxc/xg_dom_decompress.h
rename to tools/libs/guest/xg_dom_decompress.h
diff --git a/tools/libxc/xg_dom_decompress_lz4.c b/tools/libs/guest/xg_dom_decompress_lz4.c
similarity index 100%
rename from tools/libxc/xg_dom_decompress_lz4.c
rename to tools/libs/guest/xg_dom_decompress_lz4.c
diff --git a/tools/libxc/xg_dom_decompress_unsafe.c b/tools/libs/guest/xg_dom_decompress_unsafe.c
similarity index 100%
rename from tools/libxc/xg_dom_decompress_unsafe.c
rename to tools/libs/guest/xg_dom_decompress_unsafe.c
diff --git a/tools/libxc/xg_dom_decompress_unsafe.h b/tools/libs/guest/xg_dom_decompress_unsafe.h
similarity index 100%
rename from tools/libxc/xg_dom_decompress_unsafe.h
rename to tools/libs/guest/xg_dom_decompress_unsafe.h
diff --git a/tools/libxc/xg_dom_decompress_unsafe_bzip2.c b/tools/libs/guest/xg_dom_decompress_unsafe_bzip2.c
similarity index 100%
rename from tools/libxc/xg_dom_decompress_unsafe_bzip2.c
rename to tools/libs/guest/xg_dom_decompress_unsafe_bzip2.c
diff --git a/tools/libxc/xg_dom_decompress_unsafe_lzma.c b/tools/libs/guest/xg_dom_decompress_unsafe_lzma.c
similarity index 100%
rename from tools/libxc/xg_dom_decompress_unsafe_lzma.c
rename to tools/libs/guest/xg_dom_decompress_unsafe_lzma.c
diff --git a/tools/libxc/xg_dom_decompress_unsafe_lzo1x.c b/tools/libs/guest/xg_dom_decompress_unsafe_lzo1x.c
similarity index 100%
rename from tools/libxc/xg_dom_decompress_unsafe_lzo1x.c
rename to tools/libs/guest/xg_dom_decompress_unsafe_lzo1x.c
diff --git a/tools/libxc/xg_dom_decompress_unsafe_xz.c b/tools/libs/guest/xg_dom_decompress_unsafe_xz.c
similarity index 100%
rename from tools/libxc/xg_dom_decompress_unsafe_xz.c
rename to tools/libs/guest/xg_dom_decompress_unsafe_xz.c
diff --git a/tools/libxc/xg_dom_elfloader.c b/tools/libs/guest/xg_dom_elfloader.c
similarity index 100%
rename from tools/libxc/xg_dom_elfloader.c
rename to tools/libs/guest/xg_dom_elfloader.c
diff --git a/tools/libxc/xg_dom_hvmloader.c b/tools/libs/guest/xg_dom_hvmloader.c
similarity index 100%
rename from tools/libxc/xg_dom_hvmloader.c
rename to tools/libs/guest/xg_dom_hvmloader.c
diff --git a/tools/libxc/xg_dom_x86.c b/tools/libs/guest/xg_dom_x86.c
similarity index 100%
rename from tools/libxc/xg_dom_x86.c
rename to tools/libs/guest/xg_dom_x86.c
diff --git a/tools/libxc/xg_domain.c b/tools/libs/guest/xg_domain.c
similarity index 100%
rename from tools/libxc/xg_domain.c
rename to tools/libs/guest/xg_domain.c
diff --git a/tools/libxc/xg_nomigrate.c b/tools/libs/guest/xg_nomigrate.c
similarity index 100%
rename from tools/libxc/xg_nomigrate.c
rename to tools/libs/guest/xg_nomigrate.c
diff --git a/tools/libxc/xg_offline_page.c b/tools/libs/guest/xg_offline_page.c
similarity index 100%
rename from tools/libxc/xg_offline_page.c
rename to tools/libs/guest/xg_offline_page.c
diff --git a/tools/libxc/xg_private.c b/tools/libs/guest/xg_private.c
similarity index 100%
rename from tools/libxc/xg_private.c
rename to tools/libs/guest/xg_private.c
diff --git a/tools/libxc/xg_private.h b/tools/libs/guest/xg_private.h
similarity index 100%
rename from tools/libxc/xg_private.h
rename to tools/libs/guest/xg_private.h
diff --git a/tools/libxc/xg_save_restore.h b/tools/libs/guest/xg_save_restore.h
similarity index 100%
rename from tools/libxc/xg_save_restore.h
rename to tools/libs/guest/xg_save_restore.h
diff --git a/tools/libxc/xg_sr_common.c b/tools/libs/guest/xg_sr_common.c
similarity index 100%
rename from tools/libxc/xg_sr_common.c
rename to tools/libs/guest/xg_sr_common.c
diff --git a/tools/libxc/xg_sr_common.h b/tools/libs/guest/xg_sr_common.h
similarity index 100%
rename from tools/libxc/xg_sr_common.h
rename to tools/libs/guest/xg_sr_common.h
diff --git a/tools/libxc/xg_sr_common_x86.c b/tools/libs/guest/xg_sr_common_x86.c
similarity index 100%
rename from tools/libxc/xg_sr_common_x86.c
rename to tools/libs/guest/xg_sr_common_x86.c
diff --git a/tools/libxc/xg_sr_common_x86.h b/tools/libs/guest/xg_sr_common_x86.h
similarity index 100%
rename from tools/libxc/xg_sr_common_x86.h
rename to tools/libs/guest/xg_sr_common_x86.h
diff --git a/tools/libxc/xg_sr_common_x86_pv.c b/tools/libs/guest/xg_sr_common_x86_pv.c
similarity index 100%
rename from tools/libxc/xg_sr_common_x86_pv.c
rename to tools/libs/guest/xg_sr_common_x86_pv.c
diff --git a/tools/libxc/xg_sr_common_x86_pv.h b/tools/libs/guest/xg_sr_common_x86_pv.h
similarity index 100%
rename from tools/libxc/xg_sr_common_x86_pv.h
rename to tools/libs/guest/xg_sr_common_x86_pv.h
diff --git a/tools/libxc/xg_sr_restore.c b/tools/libs/guest/xg_sr_restore.c
similarity index 100%
rename from tools/libxc/xg_sr_restore.c
rename to tools/libs/guest/xg_sr_restore.c
diff --git a/tools/libxc/xg_sr_restore_x86_hvm.c b/tools/libs/guest/xg_sr_restore_x86_hvm.c
similarity index 100%
rename from tools/libxc/xg_sr_restore_x86_hvm.c
rename to tools/libs/guest/xg_sr_restore_x86_hvm.c
diff --git a/tools/libxc/xg_sr_restore_x86_pv.c b/tools/libs/guest/xg_sr_restore_x86_pv.c
similarity index 100%
rename from tools/libxc/xg_sr_restore_x86_pv.c
rename to tools/libs/guest/xg_sr_restore_x86_pv.c
diff --git a/tools/libxc/xg_sr_save.c b/tools/libs/guest/xg_sr_save.c
similarity index 100%
rename from tools/libxc/xg_sr_save.c
rename to tools/libs/guest/xg_sr_save.c
diff --git a/tools/libxc/xg_sr_save_x86_hvm.c b/tools/libs/guest/xg_sr_save_x86_hvm.c
similarity index 100%
rename from tools/libxc/xg_sr_save_x86_hvm.c
rename to tools/libs/guest/xg_sr_save_x86_hvm.c
diff --git a/tools/libxc/xg_sr_save_x86_pv.c b/tools/libs/guest/xg_sr_save_x86_pv.c
similarity index 100%
rename from tools/libxc/xg_sr_save_x86_pv.c
rename to tools/libs/guest/xg_sr_save_x86_pv.c
diff --git a/tools/libxc/xg_sr_stream_format.h b/tools/libs/guest/xg_sr_stream_format.h
similarity index 100%
rename from tools/libxc/xg_sr_stream_format.h
rename to tools/libs/guest/xg_sr_stream_format.h
diff --git a/tools/libxc/xg_suspend.c b/tools/libs/guest/xg_suspend.c
similarity index 100%
rename from tools/libxc/xg_suspend.c
rename to tools/libs/guest/xg_suspend.c
diff --git a/tools/libs/libs.mk b/tools/libs/libs.mk
index 4679268fc2..9d0ed08846 100644
--- a/tools/libs/libs.mk
+++ b/tools/libs/libs.mk
@@ -34,7 +34,7 @@ PKG_CONFIG_DESC ?= The $(PKG_CONFIG_NAME) library for Xen hypervisor
 PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
 PKG_CONFIG_USELIBS := $(SHLIB_libxen$(LIBNAME))
 PKG_CONFIG_LIB := xen$(LIBNAME)
-PKG_CONFIG_REQPRIV := $(subst $(space),$(comma),$(strip $(foreach lib,$(USELIBS_$(LIBNAME)),xen$(lib))))
+PKG_CONFIG_REQPRIV := $(subst $(space),$(comma),$(strip $(foreach lib,$(patsubst ctrl,control,$(USELIBS_$(LIBNAME))),xen$(lib))))
 
 ifneq ($(CONFIG_LIBXC_MINIOS),y)
 PKG_CONFIG_INST := $(PKG_CONFIG)
diff --git a/tools/libs/uselibs.mk b/tools/libs/uselibs.mk
index 8e45e8d917..9619c576ba 100644
--- a/tools/libs/uselibs.mk
+++ b/tools/libs/uselibs.mk
@@ -18,3 +18,5 @@ LIBS_LIBS += hypfs
 USELIBS_hypfs := toollog toolcore call
 LIBS_LIBS += ctrl
 USELIBS_ctrl := toollog call evtchn gnttab foreignmemory devicemodel
+LIBS_LIBS += guest
+USELIBS_guest := evtchn ctrl
diff --git a/tools/libxc/Makefile b/tools/libxc/Makefile
deleted file mode 100644
index 44fa0488c9..0000000000
--- a/tools/libxc/Makefile
+++ /dev/null
@@ -1,219 +0,0 @@
-XEN_ROOT = $(CURDIR)/../..
-include $(XEN_ROOT)/tools/Rules.mk
-
-MAJOR    = 4.15
-MINOR    = 0
-
-ifeq ($(CONFIG_LIBXC_MINIOS),y)
-# Save/restore of a domain is currently incompatible with a stubdom environment
-override CONFIG_MIGRATE := n
-endif
-
-LINK_FILES := xc_private.h xc_core.h xc_core_x86.h xc_core_arm.h xc_bitops.h
-
-$(LINK_FILES):
-	ln -sf $(XEN_ROOT)/tools/libs/ctrl/$(notdir $@) $@
-
-GUEST_SRCS-y :=
-GUEST_SRCS-y += xg_private.c
-GUEST_SRCS-y += xg_domain.c
-GUEST_SRCS-y += xg_suspend.c
-ifeq ($(CONFIG_MIGRATE),y)
-GUEST_SRCS-y += xg_sr_common.c
-GUEST_SRCS-$(CONFIG_X86) += xg_sr_common_x86.c
-GUEST_SRCS-$(CONFIG_X86) += xg_sr_common_x86_pv.c
-GUEST_SRCS-$(CONFIG_X86) += xg_sr_restore_x86_pv.c
-GUEST_SRCS-$(CONFIG_X86) += xg_sr_restore_x86_hvm.c
-GUEST_SRCS-$(CONFIG_X86) += xg_sr_save_x86_pv.c
-GUEST_SRCS-$(CONFIG_X86) += xg_sr_save_x86_hvm.c
-GUEST_SRCS-y += xg_sr_restore.c
-GUEST_SRCS-y += xg_sr_save.c
-GUEST_SRCS-y += xg_offline_page.c
-else
-GUEST_SRCS-y += xg_nomigrate.c
-endif
-
-vpath %.c ../../xen/common/libelf
-CFLAGS += -I../../xen/common/libelf
-
-ELF_SRCS-y += libelf-tools.c libelf-loader.c
-ELF_SRCS-y += libelf-dominfo.c
-
-GUEST_SRCS-y += $(ELF_SRCS-y)
-
-$(patsubst %.c,%.o,$(ELF_SRCS-y)): CFLAGS += -Wno-pointer-sign
-$(patsubst %.c,%.opic,$(ELF_SRCS-y)): CFLAGS += -Wno-pointer-sign
-
-ifeq ($(CONFIG_X86),y) # Add libx86 to the build
-vpath %.c ../../xen/lib/x86
-
-GUEST_SRCS-y                 += cpuid.c msr.c
-endif
-
-# new domain builder
-GUEST_SRCS-y                 += xg_dom_core.c
-GUEST_SRCS-y                 += xg_dom_boot.c
-GUEST_SRCS-y                 += xg_dom_elfloader.c
-GUEST_SRCS-$(CONFIG_X86)     += xg_dom_bzimageloader.c
-GUEST_SRCS-$(CONFIG_X86)     += xg_dom_decompress_lz4.c
-GUEST_SRCS-$(CONFIG_X86)     += xg_dom_hvmloader.c
-GUEST_SRCS-$(CONFIG_ARM)     += xg_dom_armzimageloader.c
-GUEST_SRCS-y                 += xg_dom_binloader.c
-GUEST_SRCS-y                 += xg_dom_compat_linux.c
-
-GUEST_SRCS-$(CONFIG_X86)     += xg_dom_x86.c
-GUEST_SRCS-$(CONFIG_X86)     += xg_cpuid_x86.c
-GUEST_SRCS-$(CONFIG_ARM)     += xg_dom_arm.c
-
-ifeq ($(CONFIG_LIBXC_MINIOS),y)
-GUEST_SRCS-y                 += xg_dom_decompress_unsafe.c
-GUEST_SRCS-y                 += xg_dom_decompress_unsafe_bzip2.c
-GUEST_SRCS-y                 += xg_dom_decompress_unsafe_lzma.c
-GUEST_SRCS-y                 += xg_dom_decompress_unsafe_lzo1x.c
-GUEST_SRCS-y                 += xg_dom_decompress_unsafe_xz.c
-endif
-
--include $(XEN_TARGET_ARCH)/Makefile
-
-CFLAGS   += -Werror -Wmissing-prototypes
-CFLAGS   += -I. -I./include $(CFLAGS_xeninclude)
-CFLAGS   += -D__XEN_TOOLS__
-
-# Needed for posix_fadvise64() in xc_linux.c
-CFLAGS-$(CONFIG_Linux) += -D_GNU_SOURCE
-
-CFLAGS	+= $(PTHREAD_CFLAGS)
-CFLAGS	+= $(CFLAGS_libxentoollog)
-CFLAGS	+= $(CFLAGS_libxenevtchn)
-CFLAGS	+= $(CFLAGS_libxendevicemodel)
-
-GUEST_LIB_OBJS := $(patsubst %.c,%.o,$(GUEST_SRCS-y))
-GUEST_PIC_OBJS := $(patsubst %.c,%.opic,$(GUEST_SRCS-y))
-
-$(GUEST_LIB_OBJS) $(GUEST_PIC_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h
-
-# libxenguest includes xc_private.h, so needs this despite not using
-# this functionality directly.
-$(GUEST_LIB_OBJS) $(GUEST_PIC_OBJS): CFLAGS += $(CFLAGS_libxencall) $(CFLAGS_libxenforeignmemory)
-
-LIB += libxenguest.a
-ifneq ($(nosharedlibs),y)
-LIB += libxenguest.so libxenguest.so.$(MAJOR) libxenguest.so.$(MAJOR).$(MINOR)
-endif
-
-genpath-target = $(call buildmakevars2header,_paths.h)
-$(eval $(genpath-target))
-
-xc_private.h: _paths.h
-
-$(GUEST_LIB_OBJS) $(GUEST_PIC_OBJS): $(LINK_FILES)
-
-PKG_CONFIG := xenguest.pc
-PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
-
-xenguest.pc: PKG_CONFIG_NAME = Xenguest
-xenguest.pc: PKG_CONFIG_DESC = The Xenguest library for Xen hypervisor
-xenguest.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenguest)
-xenguest.pc: PKG_CONFIG_LIB = xenguest
-xenguest.pc: PKG_CONFIG_REQPRIV = xentoollog,xencall,xenforeignmemory,xenevtchn
-
-$(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_NAME = Xenguest
-$(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_DESC = The Xenguest library for Xen hypervisor
-$(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenguest)
-$(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_LIB = xenguest
-$(PKG_CONFIG_DIR)/xenguest.pc: PKG_CONFIG_REQPRIV = xentoollog,xencall,xenforeignmemory,xenevtchn,xencontrol
-
-ifneq ($(CONFIG_LIBXC_MINIOS),y)
-PKG_CONFIG_INST := $(PKG_CONFIG)
-$(PKG_CONFIG_INST): PKG_CONFIG_PREFIX = $(prefix)
-$(PKG_CONFIG_INST): PKG_CONFIG_INCDIR = $(includedir)
-$(PKG_CONFIG_INST): PKG_CONFIG_LIBDIR = $(libdir)
-endif
-
-PKG_CONFIG_LOCAL := $(foreach pc,$(PKG_CONFIG),$(PKG_CONFIG_DIR)/$(pc))
-
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_PREFIX = $(XEN_ROOT)
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxenctrl)/include
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL = $(CFLAGS_xeninclude)
-
-.PHONY: all
-all: build
-
-.PHONY: build
-build:
-	$(MAKE) libs
-
-.PHONY: libs
-libs: $(LIB) $(PKG_CONFIG_INST) $(PKG_CONFIG_LOCAL)
-
-.PHONY: install
-install: build
-	$(INSTALL_DIR) $(DESTDIR)$(libdir)
-	$(INSTALL_DIR) $(DESTDIR)$(includedir)
-	$(INSTALL_SHLIB) libxenguest.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)
-	$(INSTALL_DATA) libxenguest.a $(DESTDIR)$(libdir)
-	$(SYMLINK_SHLIB) libxenguest.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenguest.so.$(MAJOR)
-	$(SYMLINK_SHLIB) libxenguest.so.$(MAJOR) $(DESTDIR)$(libdir)/libxenguest.so
-	$(INSTALL_DATA) include/xenguest.h $(DESTDIR)$(includedir)
-	$(INSTALL_DATA) xenguest.pc $(DESTDIR)$(PKG_INSTALLDIR)
-
-.PHONY: uninstall
-uninstall:
-	rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xenguest.pc
-	rm -f $(DESTDIR)$(includedir)/xenguest.h
-	rm -f $(DESTDIR)$(libdir)/libxenguest.so
-	rm -f $(DESTDIR)$(libdir)/libxenguest.so.$(MAJOR)
-	rm -f $(DESTDIR)$(libdir)/libxenguest.so.$(MAJOR).$(MINOR)
-	rm -f $(DESTDIR)$(libdir)/libxenguest.a
-
-.PHONY: TAGS
-TAGS:
-	etags -t *.c *.h
-
-.PHONY: clean
-clean:
-	rm -rf *.rpm $(LIB) *~ $(DEPS_RM) \
-            _paths.h \
-	    $(LINK_FILES) \
-	    xenguest.pc \
-            $(GUEST_LIB_OBJS) $(GUEST_PIC_OBJS)
-
-.PHONY: distclean
-distclean: clean
-
-.PHONY: rpm
-rpm: build
-	rm -rf staging
-	mkdir staging
-	mkdir staging/i386
-	rpmbuild --define "staging$$PWD/staging" --define '_builddir.' \
-		--define "_rpmdir$$PWD/staging" -bb rpm.spec
-	mv staging/i386/*.rpm .
-	rm -rf staging
-
-# libxenguest
-
-libxenguest.a: $(GUEST_LIB_OBJS)
-	$(AR) rc $@ $^
-
-libxenguest.so: libxenguest.so.$(MAJOR)
-	$(SYMLINK_SHLIB) $< $@
-libxenguest.so.$(MAJOR): libxenguest.so.$(MAJOR).$(MINOR)
-	$(SYMLINK_SHLIB) $< $@
-
-ifeq ($(CONFIG_MiniOS),y)
-zlib-options =
-else
-zlib-options = $(ZLIB)
-endif
-
-xc_dom_bzimageloader.o: CFLAGS += $(filter -D%,$(zlib-options))
-xc_dom_bzimageloader.opic: CFLAGS += $(filter -D%,$(zlib-options))
-
-libxenguest.so.$(MAJOR).$(MINOR): COMPRESSION_LIBS = $(filter -l%,$(zlib-options))
-libxenguest.so.$(MAJOR).$(MINOR): $(GUEST_PIC_OBJS)
-	$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenguest.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $(GUEST_PIC_OBJS) $(COMPRESSION_LIBS) -lz $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(PTHREAD_LIBS) $(APPEND_LDFLAGS)
-
--include $(DEPS_INCLUDE)
-
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 20/31] tools: split libxenstore into new tools/libs/store directory
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (18 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 19/31] tools/libxc: move libxenguest to tools/libs/guest Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 21/31] tools: split libxenvchan into new tools/libs/vchan directory Juergen Gross
                   ` (10 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel
  Cc: Juergen Gross, Andrew Cooper, George Dunlap, Ian Jackson,
	Jan Beulich, Julien Grall, Stefano Stabellini, Wei Liu,
	Samuel Thibault, Marek Marczykowski-Górecki

There is no reason why libxenstore is not placed in the tools/libs
directory.

The common files between libxenstore and xenstored are kept in the
tools/xenstore directory to be easily accessible by xenstore-stubdom
which needs the xenstored files to be built.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
 .gitignore                                    |  7 +-
 stubdom/mini-os.mk                            |  2 +-
 tools/Makefile                                |  2 +-
 tools/Rules.mk                                |  5 --
 tools/libs/Makefile                           |  1 +
 tools/libs/store/Makefile                     | 64 ++++++++++++++
 .../store}/include/compat/xs.h                |  0
 .../store}/include/compat/xs_lib.h            |  0
 .../store}/include/xenstore.h                 |  0
 tools/libs/store/libxenstore.map              | 49 +++++++++++
 tools/{xenstore => libs/store}/xs.c           |  0
 tools/libs/uselibs.mk                         |  2 +
 tools/python/setup.py                         |  2 +-
 tools/xenstore/Makefile                       | 86 +------------------
 tools/xenstore/{include => }/xenstore_lib.h   |  0
 15 files changed, 129 insertions(+), 91 deletions(-)
 create mode 100644 tools/libs/store/Makefile
 rename tools/{xenstore => libs/store}/include/compat/xs.h (100%)
 rename tools/{xenstore => libs/store}/include/compat/xs_lib.h (100%)
 rename tools/{xenstore => libs/store}/include/xenstore.h (100%)
 create mode 100644 tools/libs/store/libxenstore.map
 rename tools/{xenstore => libs/store}/xs.c (100%)
 rename tools/xenstore/{include => }/xenstore_lib.h (100%)

diff --git a/.gitignore b/.gitignore
index eb637a98e9..1335034fd3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -128,6 +128,12 @@ tools/libs/guest/xc_core.h
 tools/libs/guest/xc_core_arm.h
 tools/libs/guest/xc_core_x86.h
 tools/libs/guest/xc_private.h
+tools/libs/store/headers.chk
+tools/libs/store/list.h
+tools/libs/store/utils.h
+tools/libs/store/xenstore.pc
+tools/libs/store/xs_lib.c
+tools/libs/store/include/xenstore_lib.h
 tools/console/xenconsole
 tools/console/xenconsoled
 tools/console/client/_paths.h
@@ -282,7 +288,6 @@ tools/xenstore/xenstore-control
 tools/xenstore/xenstore-ls
 tools/xenstore/xenstored
 tools/xenstore/xenstored_test
-tools/xenstore/xenstore.pc
 tools/xenstore/xs_tdb_dump
 tools/xentrace/xentrace_setsize
 tools/xentrace/tbctl
diff --git a/stubdom/mini-os.mk b/stubdom/mini-os.mk
index e1640a7cbc..420e9a8771 100644
--- a/stubdom/mini-os.mk
+++ b/stubdom/mini-os.mk
@@ -5,7 +5,7 @@
 # XEN_ROOT
 # MINIOS_TARGET_ARCH
 
-XENSTORE_CPPFLAGS = -isystem $(XEN_ROOT)/tools/xenstore/include
+XENSTORE_CPPFLAGS = -isystem $(XEN_ROOT)/tools/libs/store/include
 TOOLCORE_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/toolcore
 TOOLLOG_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/toollog
 EVTCHN_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/evtchn
diff --git a/tools/Makefile b/tools/Makefile
index f9b4012290..4a3646871c 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -43,7 +43,7 @@ SUBDIRS-y += pygrub
 SUBDIRS-$(OCAML_TOOLS) += ocaml
 
 ifeq ($(CONFIG_RUMP),y)
-SUBDIRS-y := libs xenstore
+SUBDIRS-y := libs
 endif
 
 # For the sake of linking, set the sys-root
diff --git a/tools/Rules.mk b/tools/Rules.mk
index 914c79bfb9..557fd1e757 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -18,7 +18,6 @@ include $(XEN_ROOT)/tools/libs/uselibs.mk
 XEN_libxenlight    = $(XEN_ROOT)/tools/libxl
 # Currently libxlutil lives in the same directory as libxenlight
 XEN_libxlutil      = $(XEN_libxenlight)
-XEN_libxenstore    = $(XEN_ROOT)/tools/xenstore
 XEN_libxenstat     = $(XEN_ROOT)/tools/xenstat/libxenstat/src
 XEN_libxenvchan    = $(XEN_ROOT)/tools/libvchan
 
@@ -106,10 +105,6 @@ $(foreach lib,$(LIBS_LIBS),$(eval $(call LIB_defs,$(lib))))
 CFLAGS_libxenctrl += $(CFLAGS_libxentoollog) $(CFLAGS_libxenforeignmemory) $(CFLAGS_libxendevicemodel) -D__XEN_TOOLS__
 CFLAGS_libxenguest += $(CFLAGS_libxenevtchn) $(CFLAGS_libxenforeignmemory)
 
-CFLAGS_libxenstore = -I$(XEN_libxenstore)/include $(CFLAGS_xeninclude)
-SHDEPS_libxenstore = $(SHLIB_libxentoolcore) $(SHLIB_libxenctrl)
-LDLIBS_libxenstore = $(SHDEPS_libxenstore) $(XEN_libxenstore)/libxenstore$(libextension)
-SHLIB_libxenstore  = $(SHDEPS_libxenstore) -Wl,-rpath-link=$(XEN_libxenstore)
 ifeq ($(CONFIG_Linux),y)
 LDLIBS_libxenstore += -ldl
 endif
diff --git a/tools/libs/Makefile b/tools/libs/Makefile
index f15c1688f7..62bd8f5292 100644
--- a/tools/libs/Makefile
+++ b/tools/libs/Makefile
@@ -12,6 +12,7 @@ SUBDIRS-y += devicemodel
 SUBDIRS-y += ctrl
 SUBDIRS-y += guest
 SUBDIRS-y += hypfs
+SUBDIRS-y += store
 
 ifeq ($(CONFIG_RUMP),y)
 SUBDIRS-y := toolcore
diff --git a/tools/libs/store/Makefile b/tools/libs/store/Makefile
new file mode 100644
index 0000000000..4da502646e
--- /dev/null
+++ b/tools/libs/store/Makefile
@@ -0,0 +1,64 @@
+XEN_ROOT=$(CURDIR)/../../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+MAJOR = 3.0
+MINOR = 3
+
+ifeq ($(CONFIG_Linux),y)
+APPEND_LDFLAGS += -ldl
+endif
+
+SRCS-y   += xs_lib.c
+SRCS-y   += xs.c
+
+LIBHEADER = xenstore.h xenstore_lib.h
+
+include ../libs.mk
+
+# Include configure output (config.h)
+CFLAGS += -include $(XEN_ROOT)/tools/config.h
+CFLAGS += $(CFLAGS_libxentoolcore)
+CFLAGS += -DXEN_LIB_STORED="\"$(XEN_LIB_STORED)\""
+CFLAGS += -DXEN_RUN_STORED="\"$(XEN_RUN_STORED)\""
+
+LINK_FILES = xs_lib.c include/xenstore_lib.h list.h utils.h
+
+$(LIB_OBJS): $(LINK_FILES)
+
+$(LINK_FILES):
+	ln -sf $(XEN_ROOT)/tools/xenstore/$(notdir $@) $@
+
+xs.opic: CFLAGS += -DUSE_PTHREAD
+ifeq ($(CONFIG_Linux),y)
+xs.opic: CFLAGS += -DUSE_DLSYM
+else
+PKG_CONFIG_REMOVE += -ldl
+endif
+
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxenstore)/include
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL = $(CFLAGS_xeninclude)
+
+.PHONY: install
+install: install-headers
+
+.PHONY: install-headers
+install-headers:
+	$(INSTALL_DIR) $(DESTDIR)$(includedir)
+	$(INSTALL_DIR) $(DESTDIR)$(includedir)/xenstore-compat
+	$(INSTALL_DATA) include/compat/xs.h $(DESTDIR)$(includedir)/xenstore-compat/xs.h
+	$(INSTALL_DATA) include/compat/xs_lib.h $(DESTDIR)$(includedir)/xenstore-compat/xs_lib.h
+	ln -sf xenstore-compat/xs.h  $(DESTDIR)$(includedir)/xs.h
+	ln -sf xenstore-compat/xs_lib.h $(DESTDIR)$(includedir)/xs_lib.h
+
+.PHONY: uninstall
+uninstall: uninstall-headers
+
+.PHONY: uninstall-headers
+uninstall-headers:
+	rm -f $(DESTDIR)$(includedir)/xs_lib.h
+	rm -f $(DESTDIR)$(includedir)/xs.h
+	rm -f $(DESTDIR)$(includedir)/xenstore-compat/xs_lib.h
+	rm -f $(DESTDIR)$(includedir)/xenstore-compat/xs.h
+	if [ -d $(DESTDIR)$(includedir)/xenstore-compat ]; then \
+		rmdir --ignore-fail-on-non-empty $(DESTDIR)$(includedir)/xenstore-compat; \
+	fi
diff --git a/tools/xenstore/include/compat/xs.h b/tools/libs/store/include/compat/xs.h
similarity index 100%
rename from tools/xenstore/include/compat/xs.h
rename to tools/libs/store/include/compat/xs.h
diff --git a/tools/xenstore/include/compat/xs_lib.h b/tools/libs/store/include/compat/xs_lib.h
similarity index 100%
rename from tools/xenstore/include/compat/xs_lib.h
rename to tools/libs/store/include/compat/xs_lib.h
diff --git a/tools/xenstore/include/xenstore.h b/tools/libs/store/include/xenstore.h
similarity index 100%
rename from tools/xenstore/include/xenstore.h
rename to tools/libs/store/include/xenstore.h
diff --git a/tools/libs/store/libxenstore.map b/tools/libs/store/libxenstore.map
new file mode 100644
index 0000000000..9854305a2c
--- /dev/null
+++ b/tools/libs/store/libxenstore.map
@@ -0,0 +1,49 @@
+VERS_3.0.3 {
+	global:
+		xs_open;
+		xs_close;
+		xs_daemon_open;
+		xs_domain_open;
+		xs_daemon_open_readonly;
+		xs_daemon_close;
+		xs_daemon_destroy_postfork;
+		xs_directory;
+		xs_read;
+		xs_write;
+		xs_mkdir;
+		xs_rm;
+		xs_restrict;
+		xs_get_permissions;
+		xs_set_permissions;
+		xs_watch;
+		xs_fileno;
+		xs_check_watch;
+		xs_read_watch;
+		xs_unwatch;
+		xs_transaction_start;
+		xs_transaction_end;
+		xs_introduce_domain;
+		xs_set_target;
+		xs_resume_domain;
+		xs_release_domain;
+		xs_get_domain_path;
+		xs_path_is_subpath;
+		xs_is_domain_introduced;
+		xs_control_command;
+		xs_debug_command;
+		xs_suspend_evtchn_port;
+		xs_daemon_rootdir;
+		xs_daemon_rundir;
+		xs_daemon_socket;
+		xs_daemon_socket_ro;
+		xs_domain_dev;
+		xs_daemon_tdb;
+		xs_write_all;
+		xs_strings_to_perms;
+		xs_perm_to_string;
+		xs_count_strings;
+		expanding_buffer_ensure;
+		sanitise_value;
+		unsanitise_value;
+	local: *; /* Do not expose anything by default */
+};
diff --git a/tools/xenstore/xs.c b/tools/libs/store/xs.c
similarity index 100%
rename from tools/xenstore/xs.c
rename to tools/libs/store/xs.c
diff --git a/tools/libs/uselibs.mk b/tools/libs/uselibs.mk
index 9619c576ba..a0fe0402ff 100644
--- a/tools/libs/uselibs.mk
+++ b/tools/libs/uselibs.mk
@@ -20,3 +20,5 @@ LIBS_LIBS += ctrl
 USELIBS_ctrl := toollog call evtchn gnttab foreignmemory devicemodel
 LIBS_LIBS += guest
 USELIBS_guest := evtchn ctrl
+LIBS_LIBS += store
+USELIBS_store := toolcore
diff --git a/tools/python/setup.py b/tools/python/setup.py
index 24b284af39..8254464aff 100644
--- a/tools/python/setup.py
+++ b/tools/python/setup.py
@@ -11,7 +11,7 @@ PATH_LIBXENTOOLLOG = XEN_ROOT + "/tools/libs/toollog"
 PATH_LIBXENEVTCHN = XEN_ROOT + "/tools/libs/evtchn"
 PATH_LIBXENCTRL = XEN_ROOT + "/tools/libs/ctrl"
 PATH_LIBXL    = XEN_ROOT + "/tools/libxl"
-PATH_XENSTORE = XEN_ROOT + "/tools/xenstore"
+PATH_XENSTORE = XEN_ROOT + "/tools/libs/store"
 
 xc = Extension("xc",
                extra_compile_args = extra_compile_args,
diff --git a/tools/xenstore/Makefile b/tools/xenstore/Makefile
index 574be8d15c..9a0f0d012d 100644
--- a/tools/xenstore/Makefile
+++ b/tools/xenstore/Makefile
@@ -34,17 +34,7 @@ XENSTORED_OBJS_$(CONFIG_MiniOS) = xenstored_minios.o
 XENSTORED_OBJS += $(XENSTORED_OBJS_y)
 LDLIBS_xenstored += -lrt
 
-ifneq ($(XENSTORE_STATIC_CLIENTS),y)
-LIBXENSTORE := libxenstore.so
-else
-LIBXENSTORE := libxenstore.a
-xenstore xenstore-control: CFLAGS += -static
-endif
-
-ALL_TARGETS = libxenstore.a clients
-ifneq ($(nosharedlibs),y)
-ALL_TARGETS += libxenstore.so
-endif
+ALL_TARGETS = clients
 ifeq ($(XENSTORE_XENSTORED),y)
 ALL_TARGETS += xs_tdb_dump xenstored
 endif
@@ -87,64 +77,21 @@ xenstored.a: $(XENSTORED_OBJS)
 $(CLIENTS): xenstore
 	ln -f xenstore $@
 
-xenstore: xenstore_client.o $(LIBXENSTORE)
+xenstore: xenstore_client.o
 	$(CC) $< $(LDFLAGS) $(LDLIBS_libxenstore) $(LDLIBS_libxentoolcore) $(SOCKET_LIBS) -o $@ $(APPEND_LDFLAGS)
 
-xenstore-control: xenstore_control.o $(LIBXENSTORE)
+xenstore-control: xenstore_control.o
 	$(CC) $< $(LDFLAGS) $(LDLIBS_libxenstore) $(LDLIBS_libxentoolcore) $(SOCKET_LIBS) -o $@ $(APPEND_LDFLAGS)
 
 xs_tdb_dump: xs_tdb_dump.o utils.o tdb.o talloc.o
 	$(CC) $^ $(LDFLAGS) -o $@ $(APPEND_LDFLAGS)
 
-libxenstore.so: libxenstore.so.$(MAJOR)
-	ln -sf $< $@
-libxenstore.so.$(MAJOR): libxenstore.so.$(MAJOR).$(MINOR)
-	ln -sf $< $@
-
-xs.opic: CFLAGS += -DUSE_PTHREAD
-ifeq ($(CONFIG_Linux),y)
-xs.opic: CFLAGS += -DUSE_DLSYM
-libxenstore.so.$(MAJOR).$(MINOR): APPEND_LDFLAGS += -ldl
-PKG_CONFIG_LIBSPRIV := -ldl
-endif
-
-libxenstore.so.$(MAJOR).$(MINOR): xs.opic xs_lib.opic
-	$(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenstore.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDLIBS_libxentoolcore) $(SOCKET_LIBS) $(PTHREAD_LIBS) $(APPEND_LDFLAGS)
-
-libxenstore.a: xs.o xs_lib.o
-	$(AR) rcs $@ $^
-
-PKG_CONFIG := xenstore.pc
-PKG_CONFIG_NAME := Xenstore
-PKG_CONFIG_DESC := The Xenstore library for Xen hypervisor
-PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
-PKG_CONFIG_USELIBS := $(SHLIB_libxenstore)
-PKG_CONFIG_LIB := xenstore
-PKG_CONFIG_REQPRIV := xenevtchn,xencontrol,xengnttab,xentoolcore
-
-ifneq ($(CONFIG_LIBXC_MINIOS),y)
-PKG_CONFIG_INST := $(PKG_CONFIG)
-$(PKG_CONFIG_INST): PKG_CONFIG_PREFIX = $(prefix)
-$(PKG_CONFIG_INST): PKG_CONFIG_INCDIR = $(includedir)
-$(PKG_CONFIG_INST): PKG_CONFIG_LIBDIR = $(libdir)
-endif
-
-PKG_CONFIG_LOCAL := $(foreach pc,$(PKG_CONFIG),$(PKG_CONFIG_DIR)/$(pc))
-
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_PREFIX = $(XEN_ROOT)
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxenstore)/include
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL = $(CFLAGS_xeninclude)
-
-$(LIBXENSTORE): $(PKG_CONFIG_INST) $(PKG_CONFIG_LOCAL)
-
 .PHONY: clean
 clean:
-	rm -f *.a *.o *.opic *.so* xenstored_probes.h
+	rm -f *.a *.o xenstored_probes.h
 	rm -f xenstored xs_random xs_stress xs_crashme
 	rm -f xs_tdb_dump xenstore-control init-xenstore-domain
 	rm -f xenstore $(CLIENTS)
-	rm -f xenstore.pc
 	$(RM) $(DEPS_RM)
 
 .PHONY: distclean
@@ -161,8 +108,6 @@ tarball: clean
 .PHONY: install
 install: all
 	$(INSTALL_DIR) $(DESTDIR)$(bindir)
-	$(INSTALL_DIR) $(DESTDIR)$(includedir)
-	$(INSTALL_DIR) $(DESTDIR)$(includedir)/xenstore-compat
 ifeq ($(XENSTORE_XENSTORED),y)
 	$(INSTALL_DIR) $(DESTDIR)$(sbindir)
 	$(INSTALL_DIR) $(DESTDIR)$(XEN_LIB_STORED)
@@ -173,32 +118,9 @@ endif
 	set -e ; for c in $(CLIENTS) ; do \
 		ln -f $(DESTDIR)$(bindir)/xenstore $(DESTDIR)$(bindir)/$${c} ; \
 	done
-	$(INSTALL_DIR) $(DESTDIR)$(libdir)
-	$(INSTALL_SHLIB) libxenstore.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)
-	ln -sf libxenstore.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenstore.so.$(MAJOR)
-	ln -sf libxenstore.so.$(MAJOR) $(DESTDIR)$(libdir)/libxenstore.so
-	$(INSTALL_DATA) libxenstore.a $(DESTDIR)$(libdir)
-	$(INSTALL_DATA) include/xenstore.h $(DESTDIR)$(includedir)
-	$(INSTALL_DATA) include/xenstore_lib.h $(DESTDIR)$(includedir)
-	$(INSTALL_DATA) include/compat/xs.h $(DESTDIR)$(includedir)/xenstore-compat/xs.h
-	$(INSTALL_DATA) include/compat/xs_lib.h $(DESTDIR)$(includedir)/xenstore-compat/xs_lib.h
-	ln -sf xenstore-compat/xs.h  $(DESTDIR)$(includedir)/xs.h
-	ln -sf xenstore-compat/xs_lib.h $(DESTDIR)$(includedir)/xs_lib.h
-	$(INSTALL_DATA) xenstore.pc $(DESTDIR)$(PKG_INSTALLDIR)
 
 .PHONY: uninstall
 uninstall:
-	rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xenstore.pc
-	rm -f $(DESTDIR)$(includedir)/xs_lib.h
-	rm -f $(DESTDIR)$(includedir)/xs.h
-	rm -f $(DESTDIR)$(includedir)/xenstore-compat/xs_lib.h
-	rm -f $(DESTDIR)$(includedir)/xenstore-compat/xs.h
-	rm -f $(DESTDIR)$(includedir)/xenstore_lib.h
-	rm -f $(DESTDIR)$(includedir)/xenstore.h
-	rm -f $(DESTDIR)$(libdir)/libxenstore.a
-	rm -f $(DESTDIR)$(libdir)/libxenstore.so
-	rm -f $(DESTDIR)$(libdir)/libxenstore.so.$(MAJOR)
-	rm -f $(DESTDIR)$(libdir)/libxenstore.so.$(MAJOR).$(MINOR)
 	rm -f $(addprefix $(DESTDIR)$(bindir)/, $(CLIENTS))
 	rm -f $(DESTDIR)$(bindir)/xenstore
 	rm -f $(DESTDIR)$(bindir)/xenstore-control
diff --git a/tools/xenstore/include/xenstore_lib.h b/tools/xenstore/xenstore_lib.h
similarity index 100%
rename from tools/xenstore/include/xenstore_lib.h
rename to tools/xenstore/xenstore_lib.h
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 21/31] tools: split libxenvchan into new tools/libs/vchan directory
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (19 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 20/31] tools: split libxenstore into new tools/libs/store directory Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 22/31] tools: split libxenstat into new tools/libs/stat directory Juergen Gross
                   ` (9 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel
  Cc: Juergen Gross, Andrew Cooper, George Dunlap, Ian Jackson,
	Jan Beulich, Julien Grall, Stefano Stabellini, Wei Liu

There is no reason why libvchan is not placed in the tools/libs
directory.

At the same time move libxenvchan.h to a dedicated include directory
in tools/libs/vchan in order to follow the same pattern as the other
libraries in tools/libs.

As tools/libvchan now contains no library any longer rename it to
tools/vchan.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
 .gitignore                                    |   8 +-
 tools/Makefile                                |   2 +-
 tools/Rules.mk                                |   6 --
 tools/libs/Makefile                           |   1 +
 tools/libs/uselibs.mk                         |   2 +
 tools/libs/vchan/Makefile                     |  20 ++++
 .../vchan/include}/libxenvchan.h              |   0
 tools/{libvchan => libs/vchan}/init.c         |   0
 tools/{libvchan => libs/vchan}/io.c           |   0
 tools/libvchan/Makefile                       | 100 ------------------
 tools/vchan/Makefile                          |  37 +++++++
 tools/{libvchan => vchan}/node-select.c       |   0
 tools/{libvchan => vchan}/node.c              |   0
 .../{libvchan => vchan}/vchan-socket-proxy.c  |   0
 14 files changed, 66 insertions(+), 110 deletions(-)
 create mode 100644 tools/libs/vchan/Makefile
 rename tools/{libvchan => libs/vchan/include}/libxenvchan.h (100%)
 rename tools/{libvchan => libs/vchan}/init.c (100%)
 rename tools/{libvchan => libs/vchan}/io.c (100%)
 delete mode 100644 tools/libvchan/Makefile
 create mode 100644 tools/vchan/Makefile
 rename tools/{libvchan => vchan}/node-select.c (100%)
 rename tools/{libvchan => vchan}/node.c (100%)
 rename tools/{libvchan => vchan}/vchan-socket-proxy.c (100%)

diff --git a/.gitignore b/.gitignore
index 1335034fd3..364b09506b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -134,6 +134,9 @@ tools/libs/store/utils.h
 tools/libs/store/xenstore.pc
 tools/libs/store/xs_lib.c
 tools/libs/store/include/xenstore_lib.h
+tools/libs/vchan/headers.chk
+tools/libs/vchan/libxenvchan.map
+tools/libs/vchan/xenvchan.pc
 tools/console/xenconsole
 tools/console/xenconsoled
 tools/console/client/_paths.h
@@ -209,7 +212,6 @@ tools/include/xen/*
 tools/include/xen-xsm/*
 tools/include/xen-foreign/*.(c|h|size)
 tools/include/xen-foreign/checker
-tools/libvchan/xenvchan.pc
 tools/libxl/_libxl.api-for-check
 tools/libxl/*.api-ok
 tools/libxl/*.pc
@@ -389,8 +391,8 @@ tools/misc/xenhypfs
 tools/misc/xenwatchdogd
 tools/misc/xen-hvmcrash
 tools/misc/xen-lowmemd
-tools/libvchan/vchan-node[12]
-tools/libvchan/vchan-socket-proxy
+tools/vchan/vchan-node[12]
+tools/vchan/vchan-socket-proxy
 tools/ocaml/*/.ocamldep.make
 tools/ocaml/*/*.cm[ixao]
 tools/ocaml/*/*.cmxa
diff --git a/tools/Makefile b/tools/Makefile
index 4a3646871c..0db01707a4 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -20,7 +20,7 @@ SUBDIRS-y += xenmon
 SUBDIRS-y += xenstat
 SUBDIRS-$(CONFIG_NetBSD) += xenbackendd
 SUBDIRS-y += libfsimage
-SUBDIRS-$(CONFIG_Linux) += libvchan
+SUBDIRS-$(CONFIG_Linux) += vchan
 
 # do not recurse in to a dir we are about to delete
 ifneq "$(MAKECMDGOALS)" "distclean"
diff --git a/tools/Rules.mk b/tools/Rules.mk
index 557fd1e757..071fe364a3 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -19,7 +19,6 @@ XEN_libxenlight    = $(XEN_ROOT)/tools/libxl
 # Currently libxlutil lives in the same directory as libxenlight
 XEN_libxlutil      = $(XEN_libxenlight)
 XEN_libxenstat     = $(XEN_ROOT)/tools/xenstat/libxenstat/src
-XEN_libxenvchan    = $(XEN_ROOT)/tools/libvchan
 
 CFLAGS_xeninclude = -I$(XEN_INCLUDE)
 
@@ -114,11 +113,6 @@ SHDEPS_libxenstat  = $(SHLIB_libxenctrl) $(SHLIB_libxenstore)
 LDLIBS_libxenstat  = $(SHDEPS_libxenstat) $(XEN_libxenstat)/libxenstat$(libextension)
 SHLIB_libxenstat   = $(SHDEPS_libxenstat) -Wl,-rpath-link=$(XEN_libxenstat)
 
-CFLAGS_libxenvchan = -I$(XEN_libxenvchan) $(CFLAGS_libxengnttab) $(CFLAGS_libxenevtchn)
-SHDEPS_libxenvchan = $(SHLIB_libxentoollog) $(SHLIB_libxenstore) $(SHLIB_libxenevtchn) $(SHLIB_libxengnttab)
-LDLIBS_libxenvchan = $(SHDEPS_libxenvchan) $(XEN_libxenvchan)/libxenvchan$(libextension)
-SHLIB_libxenvchan  = $(SHDEPS_libxenvchan) -Wl,-rpath-link=$(XEN_libxenvchan)
-
 ifeq ($(debug),y)
 # Disable optimizations
 CFLAGS += -O0 -fno-omit-frame-pointer
diff --git a/tools/libs/Makefile b/tools/libs/Makefile
index 62bd8f5292..756d059ee7 100644
--- a/tools/libs/Makefile
+++ b/tools/libs/Makefile
@@ -13,6 +13,7 @@ SUBDIRS-y += ctrl
 SUBDIRS-y += guest
 SUBDIRS-y += hypfs
 SUBDIRS-y += store
+SUBDIRS-$(CONFIG_Linux) += vchan
 
 ifeq ($(CONFIG_RUMP),y)
 SUBDIRS-y := toolcore
diff --git a/tools/libs/uselibs.mk b/tools/libs/uselibs.mk
index a0fe0402ff..edb4b34256 100644
--- a/tools/libs/uselibs.mk
+++ b/tools/libs/uselibs.mk
@@ -22,3 +22,5 @@ LIBS_LIBS += guest
 USELIBS_guest := evtchn ctrl
 LIBS_LIBS += store
 USELIBS_store := toolcore
+LIBS_LIBS += vchan
+USELIBS_vchan := toollog store gnttab evtchn
diff --git a/tools/libs/vchan/Makefile b/tools/libs/vchan/Makefile
new file mode 100644
index 0000000000..87ff608f45
--- /dev/null
+++ b/tools/libs/vchan/Makefile
@@ -0,0 +1,20 @@
+XEN_ROOT = $(CURDIR)/../../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+CFLAGS += $(CFLAGS_libxenctrl)
+
+LIBHEADER := libxenvchan.h
+
+SRCS-y += init.c
+SRCS-y += io.c
+
+include $(XEN_ROOT)/tools/libs/libs.mk
+
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxenvchan)/include
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL = $(CFLAGS_xeninclude)
+
+clean: cleanlocal
+
+.PHONY: cleanlocal
+cleanlocal:
+	rm -f libxenvchan.map
diff --git a/tools/libvchan/libxenvchan.h b/tools/libs/vchan/include/libxenvchan.h
similarity index 100%
rename from tools/libvchan/libxenvchan.h
rename to tools/libs/vchan/include/libxenvchan.h
diff --git a/tools/libvchan/init.c b/tools/libs/vchan/init.c
similarity index 100%
rename from tools/libvchan/init.c
rename to tools/libs/vchan/init.c
diff --git a/tools/libvchan/io.c b/tools/libs/vchan/io.c
similarity index 100%
rename from tools/libvchan/io.c
rename to tools/libs/vchan/io.c
diff --git a/tools/libvchan/Makefile b/tools/libvchan/Makefile
deleted file mode 100644
index e718447977..0000000000
--- a/tools/libvchan/Makefile
+++ /dev/null
@@ -1,100 +0,0 @@
-#
-# tools/libvchan/Makefile
-#
-
-XEN_ROOT = $(CURDIR)/../..
-include $(XEN_ROOT)/tools/Rules.mk
-
-LIBVCHAN_OBJS = init.o io.o
-NODE_OBJS = node.o
-NODE2_OBJS = node-select.o
-
-LIBVCHAN_PIC_OBJS = $(patsubst %.o,%.opic,$(LIBVCHAN_OBJS))
-LIBVCHAN_LIBS = $(LDLIBS_libxenstore) $(LDLIBS_libxengnttab) $(LDLIBS_libxenevtchn)
-$(LIBVCHAN_OBJS) $(LIBVCHAN_PIC_OBJS): CFLAGS += $(CFLAGS_libxenstore) $(CFLAGS_libxengnttab) $(CFLAGS_libxenevtchn)
-$(NODE_OBJS) $(NODE2_OBJS): CFLAGS += $(CFLAGS_libxengnttab) $(CFLAGS_libxenevtchn)
-vchan-socket-proxy.o: CFLAGS += $(CFLAGS_libxenstore) $(CFLAGS_libxenctrl) $(CFLAGS_libxengnttab) $(CFLAGS_libxenevtchn)
-
-MAJOR = 4.15
-MINOR = 0
-
-CFLAGS += -I../include -I.
-
-io.o io.opic: CFLAGS += $(CFLAGS_libxenctrl) # for xen_mb et al
-
-PKG_CONFIG := xenvchan.pc
-PKG_CONFIG_NAME := Xenvchan
-PKG_CONFIG_DESC := The Xenvchan library for Xen hypervisor
-PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
-PKG_CONFIG_USELIBS := $(SHLIB_libxenvchan)
-PKG_CONFIG_LIB := xenvchan
-PKG_CONFIG_REQPRIV := xentoollog,xenstore,xenevtchn,xengnttab
-
-ifneq ($(CONFIG_LIBXC_MINIOS),y)
-PKG_CONFIG_INST := $(PKG_CONFIG)
-$(PKG_CONFIG_INST): PKG_CONFIG_PREFIX = $(prefix)
-$(PKG_CONFIG_INST): PKG_CONFIG_INCDIR = $(includedir)
-$(PKG_CONFIG_INST): PKG_CONFIG_LIBDIR = $(libdir)
-endif
-
-PKG_CONFIG_LOCAL := $(foreach pc,$(PKG_CONFIG),$(PKG_CONFIG_DIR)/$(pc))
-
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_PREFIX = $(XEN_ROOT)
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxenvchan)
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL = $(CFLAGS_xeninclude)
-
-.PHONY: all
-all: libxenvchan.so vchan-node1 vchan-node2 vchan-socket-proxy libxenvchan.a $(PKG_CONFIG_INST) $(PKG_CONFIG_LOCAL)
-
-libxenvchan.so: libxenvchan.so.$(MAJOR)
-	ln -sf $< $@
-
-libxenvchan.so.$(MAJOR): libxenvchan.so.$(MAJOR).$(MINOR)
-	ln -sf $< $@
-
-libxenvchan.so.$(MAJOR).$(MINOR): $(LIBVCHAN_PIC_OBJS)
-	$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenvchan.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LIBVCHAN_LIBS) $(APPEND_LDFLAGS)
-
-libxenvchan.a: $(LIBVCHAN_OBJS)
-	$(AR) rcs libxenvchan.a $^
-
-vchan-node1: $(NODE_OBJS) libxenvchan.so
-	$(CC) $(LDFLAGS) -o $@ $(NODE_OBJS) $(LDLIBS_libxenvchan) $(APPEND_LDFLAGS)
-
-vchan-node2: $(NODE2_OBJS) libxenvchan.so
-	$(CC) $(LDFLAGS) -o $@ $(NODE2_OBJS) $(LDLIBS_libxenvchan) $(APPEND_LDFLAGS)
-
-vchan-socket-proxy: vchan-socket-proxy.o libxenvchan.so
-	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenvchan) $(LDLIBS_libxenstore) $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
-
-.PHONY: install
-install: all
-	$(INSTALL_DIR) $(DESTDIR)$(libdir)
-	$(INSTALL_DIR) $(DESTDIR)$(includedir)
-	$(INSTALL_DIR) $(DESTDIR)$(bindir)
-	$(INSTALL_PROG) libxenvchan.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)
-	ln -sf libxenvchan.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenvchan.so.$(MAJOR)
-	ln -sf libxenvchan.so.$(MAJOR) $(DESTDIR)$(libdir)/libxenvchan.so
-	$(INSTALL_PROG) vchan-socket-proxy $(DESTDIR)$(bindir)
-	$(INSTALL_DATA) libxenvchan.h $(DESTDIR)$(includedir)
-	$(INSTALL_DATA) libxenvchan.a $(DESTDIR)$(libdir)
-	$(INSTALL_DATA) xenvchan.pc $(DESTDIR)$(PKG_INSTALLDIR)
-
-.PHONY: uninstall
-uninstall:
-	rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xenvchan.pc
-	rm -f $(DESTDIR)$(libdir)/libxenvchan.a
-	rm -f $(DESTDIR)$(includedir)/libxenvchan.h
-	rm -f $(DESTDIR)$(libdir)/libxenvchan.so
-	rm -f $(DESTDIR)$(libdir)/libxenvchan.so.$(MAJOR)
-	rm -f $(DESTDIR)$(libdir)/libxenvchan.so.$(MAJOR).$(MINOR)
-
-.PHONY: clean
-clean:
-	$(RM) -f *.o *.opic *.so* *.a vchan-node1 vchan-node2 $(DEPS_RM)
-	$(RM) -f xenvchan.pc
-
-distclean: clean
-
--include $(DEPS_INCLUDE)
diff --git a/tools/vchan/Makefile b/tools/vchan/Makefile
new file mode 100644
index 0000000000..a731e0e073
--- /dev/null
+++ b/tools/vchan/Makefile
@@ -0,0 +1,37 @@
+#
+# tools/vchan/Makefile
+#
+
+XEN_ROOT = $(CURDIR)/../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+NODE_OBJS = node.o
+NODE2_OBJS = node-select.o
+
+$(NODE_OBJS) $(NODE2_OBJS): CFLAGS += $(CFLAGS_libxenvchan) $(CFLAGS_libxengnttab) $(CFLAGS_libxenevtchn)
+vchan-socket-proxy.o: CFLAGS += $(CFLAGS_libxenvchan) $(CFLAGS_libxenstore) $(CFLAGS_libxenctrl) $(CFLAGS_libxengnttab) $(CFLAGS_libxenevtchn)
+
+.PHONY: all
+all: vchan-node1 vchan-node2 vchan-socket-proxy
+
+vchan-node1: $(NODE_OBJS)
+	$(CC) $(LDFLAGS) -o $@ $(NODE_OBJS) $(LDLIBS_libxenvchan) $(APPEND_LDFLAGS)
+
+vchan-node2: $(NODE2_OBJS)
+	$(CC) $(LDFLAGS) -o $@ $(NODE2_OBJS) $(LDLIBS_libxenvchan) $(APPEND_LDFLAGS)
+
+vchan-socket-proxy: vchan-socket-proxy.o
+	$(CC) $(LDFLAGS) -o $@ $< $(LDLIBS_libxenvchan) $(LDLIBS_libxenstore) $(LDLIBS_libxenctrl) $(APPEND_LDFLAGS)
+
+.PHONY: install
+install: all
+	$(INSTALL_DIR) $(DESTDIR)$(bindir)
+	$(INSTALL_PROG) vchan-socket-proxy $(DESTDIR)$(bindir)
+
+.PHONY: clean
+clean:
+	$(RM) -f *.o vchan-node1 vchan-node2 $(DEPS_RM)
+
+distclean: clean
+
+-include $(DEPS_INCLUDE)
diff --git a/tools/libvchan/node-select.c b/tools/vchan/node-select.c
similarity index 100%
rename from tools/libvchan/node-select.c
rename to tools/vchan/node-select.c
diff --git a/tools/libvchan/node.c b/tools/vchan/node.c
similarity index 100%
rename from tools/libvchan/node.c
rename to tools/vchan/node.c
diff --git a/tools/libvchan/vchan-socket-proxy.c b/tools/vchan/vchan-socket-proxy.c
similarity index 100%
rename from tools/libvchan/vchan-socket-proxy.c
rename to tools/vchan/vchan-socket-proxy.c
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 22/31] tools: split libxenstat into new tools/libs/stat directory
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (20 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 21/31] tools: split libxenvchan into new tools/libs/vchan directory Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 23/31] tools/libxl: fix dependencies of libxl tests Juergen Gross
                   ` (8 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel
  Cc: Juergen Gross, Andrew Cooper, George Dunlap, Ian Jackson,
	Jan Beulich, Julien Grall, Stefano Stabellini, Wei Liu

There is no reason why libxenstat is not placed in the tools/libs
directory.

At the same time move xenstat.h to a dedicated include directory
in tools/libs/stat in order to follow the same pattern as the other
libraries in tools/libs.

As now xentop is the only left directory in xenstat move it directly
under tools and get rid of tools/xenstat.

Fix some missing prototype errors (add one prototype and make two
functions static).

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
 .gitignore                                    |   8 +-
 tools/Makefile                                |   2 +-
 tools/Rules.mk                                |   6 -
 tools/libs/Makefile                           |   1 +
 .../{xenstat/libxenstat => libs/stat}/COPYING |   0
 .../libxenstat => libs/stat}/Makefile         | 105 ++++--------------
 .../stat}/bindings/swig/perl/.empty           |   0
 .../stat}/bindings/swig/python/.empty         |   0
 .../stat}/bindings/swig/xenstat.i             |   0
 .../src => libs/stat/include}/xenstat.h       |   3 +
 .../libxenstat/src => libs/stat}/xenstat.c    |   0
 .../src => libs/stat}/xenstat_freebsd.c       |   0
 .../src => libs/stat}/xenstat_linux.c         |   4 +-
 .../src => libs/stat}/xenstat_netbsd.c        |   0
 .../src => libs/stat}/xenstat_priv.h          |   0
 .../src => libs/stat}/xenstat_qmp.c           |   0
 .../src => libs/stat}/xenstat_solaris.c       |   0
 tools/libs/uselibs.mk                         |   2 +
 tools/xenstat/Makefile                        |  10 --
 tools/{xenstat => }/xentop/Makefile           |   2 +-
 tools/{xenstat => }/xentop/TODO               |   0
 tools/{xenstat => }/xentop/xentop.c           |   0
 22 files changed, 36 insertions(+), 107 deletions(-)
 rename tools/{xenstat/libxenstat => libs/stat}/COPYING (100%)
 rename tools/{xenstat/libxenstat => libs/stat}/Makefile (54%)
 rename tools/{xenstat/libxenstat => libs/stat}/bindings/swig/perl/.empty (100%)
 rename tools/{xenstat/libxenstat => libs/stat}/bindings/swig/python/.empty (100%)
 rename tools/{xenstat/libxenstat => libs/stat}/bindings/swig/xenstat.i (100%)
 rename tools/{xenstat/libxenstat/src => libs/stat/include}/xenstat.h (98%)
 rename tools/{xenstat/libxenstat/src => libs/stat}/xenstat.c (100%)
 rename tools/{xenstat/libxenstat/src => libs/stat}/xenstat_freebsd.c (100%)
 rename tools/{xenstat/libxenstat/src => libs/stat}/xenstat_linux.c (98%)
 rename tools/{xenstat/libxenstat/src => libs/stat}/xenstat_netbsd.c (100%)
 rename tools/{xenstat/libxenstat/src => libs/stat}/xenstat_priv.h (100%)
 rename tools/{xenstat/libxenstat/src => libs/stat}/xenstat_qmp.c (100%)
 rename tools/{xenstat/libxenstat/src => libs/stat}/xenstat_solaris.c (100%)
 delete mode 100644 tools/xenstat/Makefile
 rename tools/{xenstat => }/xentop/Makefile (97%)
 rename tools/{xenstat => }/xentop/TODO (100%)
 rename tools/{xenstat => }/xentop/xentop.c (100%)

diff --git a/.gitignore b/.gitignore
index 364b09506b..5e8c47e2db 100644
--- a/.gitignore
+++ b/.gitignore
@@ -128,6 +128,10 @@ tools/libs/guest/xc_core.h
 tools/libs/guest/xc_core_arm.h
 tools/libs/guest/xc_core_x86.h
 tools/libs/guest/xc_private.h
+tools/libs/stat/_paths.h
+tools/libs/stat/headers.chk
+tools/libs/stat/libxenstat.map
+tools/libs/stat/xenstat.pc
 tools/libs/store/headers.chk
 tools/libs/store/list.h
 tools/libs/store/utils.h
@@ -276,9 +280,6 @@ tools/xenmon/xentrace_setmask
 tools/xenmon/xenbaked
 tools/xenpaging/xenpaging
 tools/xenpmd/xenpmd
-tools/xenstat/libxenstat/src/_paths.h
-tools/xenstat/libxenstat/xenstat.pc
-tools/xenstat/xentop/xentop
 tools/xenstore/xenstore
 tools/xenstore/xenstore-chmod
 tools/xenstore/xenstore-exists
@@ -291,6 +292,7 @@ tools/xenstore/xenstore-ls
 tools/xenstore/xenstored
 tools/xenstore/xenstored_test
 tools/xenstore/xs_tdb_dump
+tools/xentop/xentop
 tools/xentrace/xentrace_setsize
 tools/xentrace/tbctl
 tools/xentrace/xenctx
diff --git a/tools/Makefile b/tools/Makefile
index 0db01707a4..ea69675cca 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -17,7 +17,7 @@ SUBDIRS-$(CONFIG_XCUTILS) += xcutils
 SUBDIRS-$(CONFIG_X86) += firmware
 SUBDIRS-y += console
 SUBDIRS-y += xenmon
-SUBDIRS-y += xenstat
+SUBDIRS-y += xentop
 SUBDIRS-$(CONFIG_NetBSD) += xenbackendd
 SUBDIRS-y += libfsimage
 SUBDIRS-$(CONFIG_Linux) += vchan
diff --git a/tools/Rules.mk b/tools/Rules.mk
index 071fe364a3..fc121d0d75 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -18,7 +18,6 @@ include $(XEN_ROOT)/tools/libs/uselibs.mk
 XEN_libxenlight    = $(XEN_ROOT)/tools/libxl
 # Currently libxlutil lives in the same directory as libxenlight
 XEN_libxlutil      = $(XEN_libxenlight)
-XEN_libxenstat     = $(XEN_ROOT)/tools/xenstat/libxenstat/src
 
 CFLAGS_xeninclude = -I$(XEN_INCLUDE)
 
@@ -108,11 +107,6 @@ ifeq ($(CONFIG_Linux),y)
 LDLIBS_libxenstore += -ldl
 endif
 
-CFLAGS_libxenstat  = -I$(XEN_libxenstat)
-SHDEPS_libxenstat  = $(SHLIB_libxenctrl) $(SHLIB_libxenstore)
-LDLIBS_libxenstat  = $(SHDEPS_libxenstat) $(XEN_libxenstat)/libxenstat$(libextension)
-SHLIB_libxenstat   = $(SHDEPS_libxenstat) -Wl,-rpath-link=$(XEN_libxenstat)
-
 ifeq ($(debug),y)
 # Disable optimizations
 CFLAGS += -O0 -fno-omit-frame-pointer
diff --git a/tools/libs/Makefile b/tools/libs/Makefile
index 756d059ee7..e8fcd59214 100644
--- a/tools/libs/Makefile
+++ b/tools/libs/Makefile
@@ -13,6 +13,7 @@ SUBDIRS-y += ctrl
 SUBDIRS-y += guest
 SUBDIRS-y += hypfs
 SUBDIRS-y += store
+SUBDIRS-y += stat
 SUBDIRS-$(CONFIG_Linux) += vchan
 
 ifeq ($(CONFIG_RUMP),y)
diff --git a/tools/xenstat/libxenstat/COPYING b/tools/libs/stat/COPYING
similarity index 100%
rename from tools/xenstat/libxenstat/COPYING
rename to tools/libs/stat/COPYING
diff --git a/tools/xenstat/libxenstat/Makefile b/tools/libs/stat/Makefile
similarity index 54%
rename from tools/xenstat/libxenstat/Makefile
rename to tools/libs/stat/Makefile
index bdd5a0f469..5463f5f7ca 100644
--- a/tools/xenstat/libxenstat/Makefile
+++ b/tools/libs/stat/Makefile
@@ -15,85 +15,24 @@
 XEN_ROOT=$(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-LDCONFIG=ldconfig
-MAKE_LINK=ln -sf
-
-MAJOR=4.15
-MINOR=0
-
-LIB=src/libxenstat.a
-SHLIB=src/libxenstat.so.$(MAJOR).$(MINOR)
-SHLIB_LINKS=src/libxenstat.so.$(MAJOR) src/libxenstat.so
-OBJECTS-y=src/xenstat.o src/xenstat_qmp.o
-OBJECTS-$(CONFIG_Linux) += src/xenstat_linux.o
-OBJECTS-$(CONFIG_SunOS) += src/xenstat_solaris.o
-OBJECTS-$(CONFIG_NetBSD) += src/xenstat_netbsd.o
-OBJECTS-$(CONFIG_FreeBSD) += src/xenstat_freebsd.o
-SONAME_FLAGS=-Wl,$(SONAME_LDFLAG) -Wl,libxenstat.so.$(MAJOR)
-
-CFLAGS+=-fPIC -Werror
-CFLAGS+=-Isrc $(CFLAGS_libxenctrl) $(CFLAGS_libxenstore) $(CFLAGS_xeninclude) -include $(XEN_ROOT)/tools/config.h
-
-LDLIBS-y = $(LDLIBS_libxenstore) $(LDLIBS_libxenctrl) -lyajl
-LDLIBS-$(CONFIG_SunOS) += -lkstat
-
-PKG_CONFIG := xenstat.pc
-PKG_CONFIG_NAME := Xenstat
-PKG_CONFIG_DESC := The Xenstat library for Xen hypervisor
-PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
-PKG_CONFIG_USELIBS := $(SHLIB_libxenstat)
-PKG_CONFIG_LIB := xenstat
-PKG_CONFIG_REQPRIV := xencontrol,xenstore
-
-ifneq ($(CONFIG_LIBXC_MINIOS),y)
-PKG_CONFIG_INST := $(PKG_CONFIG)
-$(PKG_CONFIG_INST): PKG_CONFIG_PREFIX = $(prefix)
-$(PKG_CONFIG_INST): PKG_CONFIG_INCDIR = $(includedir)
-$(PKG_CONFIG_INST): PKG_CONFIG_LIBDIR = $(libdir)
-endif
-
-PKG_CONFIG_LOCAL := $(foreach pc,$(PKG_CONFIG),$(PKG_CONFIG_DIR)/$(pc))
-
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_PREFIX = $(XEN_ROOT)
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxenstat)
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
+CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenstore) $(CFLAGS_xeninclude) -include $(XEN_ROOT)/tools/config.h
 
-.PHONY: all
-all: $(LIB) $(SHLIB) $(SHLIB_LINKS) $(PKG_CONFIG_INST) $(PKG_CONFIG_LOCAL)
-
-$(OBJECTS-y): src/_paths.h
-
-$(LIB): $(OBJECTS-y)
-	$(AR) rc $@ $^
-	$(RANLIB) $@
+SRCS-y += xenstat.c
+SRCS-y += xenstat_qmp.c
+SRCS-$(CONFIG_Linux) += xenstat_linux.c
+SRCS-$(CONFIG_SunOS) += xenstat_solaris.c
+SRCS-$(CONFIG_NetBSD) += xenstat_netbsd.c
+SRCS-$(CONFIG_FreeBSD) += xenstat_freebsd.c
 
-$(SHLIB): $(OBJECTS-y)
-	$(CC) $(LDFLAGS) $(SONAME_FLAGS) $(SHLIB_LDFLAGS) -o $@ \
-	    $(OBJECTS-y) $(LDLIBS-y) $(APPEND_LDFLAGS)
+LDLIBS-y += -lyajl
+LDLIBS-$(CONFIG_SunOS) += -lkstat
+APPEND_LDFLAGS += $(LDLIBS-y)
 
-src/libxenstat.so.$(MAJOR): $(SHLIB)
-	$(MAKE_LINK) $(<F) $@
+include $(XEN_ROOT)/tools/libs/libs.mk
 
-src/libxenstat.so: src/libxenstat.so.$(MAJOR)
-	$(MAKE_LINK) $(<F) $@
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxenstat)/include
 
-.PHONY: install
-install: all
-	$(INSTALL_DATA) src/xenstat.h $(DESTDIR)$(includedir)
-	$(INSTALL_DATA) $(LIB) $(DESTDIR)$(libdir)/libxenstat.a
-	$(INSTALL_PROG) src/libxenstat.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)
-	ln -sf libxenstat.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenstat.so.$(MAJOR)
-	ln -sf libxenstat.so.$(MAJOR) $(DESTDIR)$(libdir)/libxenstat.so
-	$(INSTALL_DATA) xenstat.pc $(DESTDIR)$(PKG_INSTALLDIR)
-
-.PHONY: uninstall
-uninstall:
-	rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xenstat.pc
-	rm -f $(DESTDIR)$(libdir)/libxenstat.so
-	rm -f $(DESTDIR)$(libdir)/libxenstat.so.$(MAJOR)
-	rm -f $(DESTDIR)$(libdir)/libxenstat.so.$(MAJOR).$(MINOR)
-	rm -f $(DESTDIR)$(libdir)/libxenstat.a
-	rm -f $(DESTDIR)$(includedir)/xenstat.h
+$(LIB_OBJS): _paths.h
 
 PYLIB=bindings/swig/python/_xenstat.so
 PYMOD=bindings/swig/python/xenstat.py
@@ -114,9 +53,9 @@ install-bindings: install-perl-bindings install-python-bindings
 .PHONY: uninstall-bindings
 uninstall-bindings: uninstall-perl-bindings uninstall-python-bindings
 
-$(BINDINGS): $(SHLIB) $(SHLIB_LINKS) src/xenstat.h
+$(BINDINGS): $(SHLIB) $(SHLIB_LINKS) include/xenstat.h
 
-SWIG_FLAGS=-module xenstat -Isrc
+SWIG_FLAGS=-module xenstat -Iinclude -I.
 
 # Python bindings
 PYTHON_VERSION=$(PYTHON:python%=%)
@@ -180,16 +119,14 @@ install: install-perl-bindings
 uninstall: uninstall-perl-bindings
 endif
 
-.PHONY: clean
-clean:
-	rm -f $(LIB) $(SHLIB) $(SHLIB_LINKS) $(OBJECTS-y) \
-	      $(BINDINGS) $(BINDINGSRC) $(DEPS_RM) src/_paths.h
-	rm -f xenstat.pc
+clean: cleanlocal
 
-.PHONY: distclean
-distclean: clean
+.PHONY: cleanlocal
+cleanlocal:
+	rm -f $(BINDINGS) $(BINDINGSRC) $(DEPS_RM) _paths.h
+	rm -f libxenstat.map
 
 -include $(DEPS_INCLUDE)
 
-genpath-target = $(call buildmakevars2header,src/_paths.h)
+genpath-target = $(call buildmakevars2header,_paths.h)
 $(eval $(genpath-target))
diff --git a/tools/xenstat/libxenstat/bindings/swig/perl/.empty b/tools/libs/stat/bindings/swig/perl/.empty
similarity index 100%
rename from tools/xenstat/libxenstat/bindings/swig/perl/.empty
rename to tools/libs/stat/bindings/swig/perl/.empty
diff --git a/tools/xenstat/libxenstat/bindings/swig/python/.empty b/tools/libs/stat/bindings/swig/python/.empty
similarity index 100%
rename from tools/xenstat/libxenstat/bindings/swig/python/.empty
rename to tools/libs/stat/bindings/swig/python/.empty
diff --git a/tools/xenstat/libxenstat/bindings/swig/xenstat.i b/tools/libs/stat/bindings/swig/xenstat.i
similarity index 100%
rename from tools/xenstat/libxenstat/bindings/swig/xenstat.i
rename to tools/libs/stat/bindings/swig/xenstat.i
diff --git a/tools/xenstat/libxenstat/src/xenstat.h b/tools/libs/stat/include/xenstat.h
similarity index 98%
rename from tools/xenstat/libxenstat/src/xenstat.h
rename to tools/libs/stat/include/xenstat.h
index 76a660f321..c3b98909dd 100644
--- a/tools/xenstat/libxenstat/src/xenstat.h
+++ b/tools/libs/stat/include/xenstat.h
@@ -71,6 +71,9 @@ unsigned long long xenstat_node_tot_mem(xenstat_node * node);
 /* Get amount of free memory on a node */
 unsigned long long xenstat_node_free_mem(xenstat_node * node);
 
+/* Get amount of freeable memory on a node */
+long xenstat_node_freeable_mb(xenstat_node * node);
+
 /* Find the number of domains existing on a node */
 unsigned int xenstat_node_num_domains(xenstat_node * node);
 
diff --git a/tools/xenstat/libxenstat/src/xenstat.c b/tools/libs/stat/xenstat.c
similarity index 100%
rename from tools/xenstat/libxenstat/src/xenstat.c
rename to tools/libs/stat/xenstat.c
diff --git a/tools/xenstat/libxenstat/src/xenstat_freebsd.c b/tools/libs/stat/xenstat_freebsd.c
similarity index 100%
rename from tools/xenstat/libxenstat/src/xenstat_freebsd.c
rename to tools/libs/stat/xenstat_freebsd.c
diff --git a/tools/xenstat/libxenstat/src/xenstat_linux.c b/tools/libs/stat/xenstat_linux.c
similarity index 98%
rename from tools/xenstat/libxenstat/src/xenstat_linux.c
rename to tools/libs/stat/xenstat_linux.c
index 7530349eee..793263f2b6 100644
--- a/tools/xenstat/libxenstat/src/xenstat_linux.c
+++ b/tools/libs/stat/xenstat_linux.c
@@ -64,7 +64,7 @@ static const char PROCNETDEV_HEADER[] =
 
 /* We need to get the name of the bridge interface for use with bonding interfaces */
 /* Use excludeName parameter to avoid adding bridges we don't care about, eg. virbr0 */
-void getBridge(char *excludeName, char *result, size_t resultLen)
+static void getBridge(char *excludeName, char *result, size_t resultLen)
 {
 	struct dirent *de;
 	DIR *d;
@@ -89,7 +89,7 @@ void getBridge(char *excludeName, char *result, size_t resultLen)
 
 /* parseNetLine provides regular expression based parsing for lines from /proc/net/dev, all the */
 /* information are parsed but not all are used in our case, ie. for xenstat */
-int parseNetDevLine(char *line, char *iface, unsigned long long *rxBytes, unsigned long long *rxPackets,
+static int parseNetDevLine(char *line, char *iface, unsigned long long *rxBytes, unsigned long long *rxPackets,
 		unsigned long long *rxErrs, unsigned long long *rxDrops, unsigned long long *rxFifo,
 		unsigned long long *rxFrames, unsigned long long *rxComp, unsigned long long *rxMcast,
 		unsigned long long *txBytes, unsigned long long *txPackets, unsigned long long *txErrs,
diff --git a/tools/xenstat/libxenstat/src/xenstat_netbsd.c b/tools/libs/stat/xenstat_netbsd.c
similarity index 100%
rename from tools/xenstat/libxenstat/src/xenstat_netbsd.c
rename to tools/libs/stat/xenstat_netbsd.c
diff --git a/tools/xenstat/libxenstat/src/xenstat_priv.h b/tools/libs/stat/xenstat_priv.h
similarity index 100%
rename from tools/xenstat/libxenstat/src/xenstat_priv.h
rename to tools/libs/stat/xenstat_priv.h
diff --git a/tools/xenstat/libxenstat/src/xenstat_qmp.c b/tools/libs/stat/xenstat_qmp.c
similarity index 100%
rename from tools/xenstat/libxenstat/src/xenstat_qmp.c
rename to tools/libs/stat/xenstat_qmp.c
diff --git a/tools/xenstat/libxenstat/src/xenstat_solaris.c b/tools/libs/stat/xenstat_solaris.c
similarity index 100%
rename from tools/xenstat/libxenstat/src/xenstat_solaris.c
rename to tools/libs/stat/xenstat_solaris.c
diff --git a/tools/libs/uselibs.mk b/tools/libs/uselibs.mk
index edb4b34256..a9dc2ce994 100644
--- a/tools/libs/uselibs.mk
+++ b/tools/libs/uselibs.mk
@@ -24,3 +24,5 @@ LIBS_LIBS += store
 USELIBS_store := toolcore
 LIBS_LIBS += vchan
 USELIBS_vchan := toollog store gnttab evtchn
+LIBS_LIBS += stat
+USELIBS_stat := ctrl store
diff --git a/tools/xenstat/Makefile b/tools/xenstat/Makefile
deleted file mode 100644
index b300f31289..0000000000
--- a/tools/xenstat/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-XEN_ROOT = $(CURDIR)/../..
-include $(XEN_ROOT)/tools/Rules.mk
-
-SUBDIRS :=
-SUBDIRS += libxenstat
-SUBDIRS += xentop
-
-.PHONY: all install clean distclean uninstall
-
-all install clean distclean uninstall: %: subdirs-%
diff --git a/tools/xenstat/xentop/Makefile b/tools/xentop/Makefile
similarity index 97%
rename from tools/xenstat/xentop/Makefile
rename to tools/xentop/Makefile
index ec612db2a2..0034114684 100644
--- a/tools/xenstat/xentop/Makefile
+++ b/tools/xentop/Makefile
@@ -10,7 +10,7 @@
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.
 
-XEN_ROOT=$(CURDIR)/../../..
+XEN_ROOT=$(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
 ifneq ($(XENSTAT_XENTOP),y)
diff --git a/tools/xenstat/xentop/TODO b/tools/xentop/TODO
similarity index 100%
rename from tools/xenstat/xentop/TODO
rename to tools/xentop/TODO
diff --git a/tools/xenstat/xentop/xentop.c b/tools/xentop/xentop.c
similarity index 100%
rename from tools/xenstat/xentop/xentop.c
rename to tools/xentop/xentop.c
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 23/31] tools/libxl: fix dependencies of libxl tests
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (21 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 22/31] tools: split libxenstat into new tools/libs/stat directory Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 24/31] tools/libxl: don't include libxl_osdeps.h from libxlutil sources Juergen Gross
                   ` (7 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu, Anthony PERARD

Today building the libxl internal tests depends on libxlutil having
been built, in spite of the tests not using any functionality of
libxlutil. Fix this by dropping the dependency.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
 tools/libxl/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index b815c548de..d3dd9efadf 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -339,14 +339,14 @@ libxlutil.so.$(XLUMAJOR).$(XLUMINOR): $(LIBXLU_OBJS) libxenlight.so
 libxlutil.a: $(LIBXLU_OBJS)
 	$(AR) rcs libxlutil.a $^
 
-test_%: test_%.o test_common.o libxlutil.so libxenlight_test.so
+test_%: test_%.o test_common.o libxenlight_test.so
 	$(CC) $(LDFLAGS) -o $@ $^ $(filter-out %libxenlight.so, $(LDLIBS_libxenlight)) $(LDLIBS_libxentoollog) $(LDLIBS_libxentoolcore) -lyajl $(APPEND_LDFLAGS)
 
 libxl-save-helper: $(SAVE_HELPER_OBJS) libxenlight.so
 	$(CC) $(LDFLAGS) -o $@ $(SAVE_HELPER_OBJS) $(LDLIBS_libxentoollog) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxentoolcore) $(APPEND_LDFLAGS)
 
-testidl: testidl.o libxlutil.so libxenlight.so
-	$(CC) $(LDFLAGS) -o $@ testidl.o libxlutil.so $(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) $(LDLIBS_libxentoolcore) $(APPEND_LDFLAGS)
+testidl: testidl.o libxenlight.so
+	$(CC) $(LDFLAGS) -o $@ testidl.o $(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) $(LDLIBS_libxentoolcore) $(APPEND_LDFLAGS)
 
 .PHONY: install
 install: all
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 24/31] tools/libxl: don't include libxl_osdeps.h from libxlutil sources
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (22 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 23/31] tools/libxl: fix dependencies of libxl tests Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 25/31] tools/libxl: add missing items to clean target Juergen Gross
                   ` (6 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu, Anthony PERARD

There is no need for the sources of libxlutil to include libxl_osdeps.h
as the only dependency is the leading

#define _GNU_SOURCE

in libxl_osdeps.h. So replace including libxl_osdeps.h by the needed
define.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
 tools/libxl/libxlu_cfg.c    |  3 +--
 tools/libxl/libxlu_cfg_i.h  |  1 -
 tools/libxl/libxlu_disk.c   |  1 -
 tools/libxl/libxlu_disk_l.c | 14 +++++++-------
 tools/libxl/libxlu_disk_l.h |  8 ++++----
 tools/libxl/libxlu_disk_l.l |  2 +-
 tools/libxl/libxlu_pci.c    |  3 ++-
 tools/libxl/libxlu_vif.c    |  3 ++-
 8 files changed, 17 insertions(+), 18 deletions(-)

diff --git a/tools/libxl/libxlu_cfg.c b/tools/libxl/libxlu_cfg.c
index f9e8aa2f3a..874f5abfb9 100644
--- a/tools/libxl/libxlu_cfg.c
+++ b/tools/libxl/libxlu_cfg.c
@@ -15,8 +15,7 @@
  * GNU Lesser General Public License for more details.
  */
 
-
-#include "libxl_osdeps.h" /* must come before any other headers */
+#define _GNU_SOURCE
 
 #include <limits.h>
 
diff --git a/tools/libxl/libxlu_cfg_i.h b/tools/libxl/libxlu_cfg_i.h
index 87b19df311..4217f5b28d 100644
--- a/tools/libxl/libxlu_cfg_i.h
+++ b/tools/libxl/libxlu_cfg_i.h
@@ -18,7 +18,6 @@
 #ifndef LIBXLU_CFG_I_H
 #define LIBXLU_CFG_I_H
 
-#include "libxl_osdeps.h" /* must come before any other headers */
 #include "libxlu_internal.h"
 #include "libxlu_cfg_y.h"
 
diff --git a/tools/libxl/libxlu_disk.c b/tools/libxl/libxlu_disk.c
index 18fe386dbe..1de16a6a06 100644
--- a/tools/libxl/libxlu_disk.c
+++ b/tools/libxl/libxlu_disk.c
@@ -1,4 +1,3 @@
-#include "libxl_osdeps.h" /* must come before any other headers */
 #include "libxlu_internal.h"
 #include "libxlu_disk_l.h"
 #include "libxlu_disk_i.h"
diff --git a/tools/libxl/libxlu_disk_l.c b/tools/libxl/libxlu_disk_l.c
index 05f7ac74a0..32d4b74b58 100644
--- a/tools/libxl/libxlu_disk_l.c
+++ b/tools/libxl/libxlu_disk_l.c
@@ -1,7 +1,7 @@
-#line 2 "libxlu_disk_l.c"
-#include "libxl_osdeps.h" /* must come before any other headers */
+#line 1 "libxlu_disk_l.c"
+#define _GNU_SOURCE
 
-#line 5 "libxlu_disk_l.c"
+#line 4 "libxlu_disk_l.c"
 
 #define  YY_INT_ALIGNED short int
 
@@ -1199,9 +1199,9 @@ static int vdev_and_devtype(DiskParseContext *dpc, char *str) {
 #undef DPC /* needs to be defined differently the actual lexer */
 #define DPC ((DiskParseContext*)yyextra)
 
-#line 1203 "libxlu_disk_l.c"
+#line 1202 "libxlu_disk_l.c"
 
-#line 1205 "libxlu_disk_l.c"
+#line 1204 "libxlu_disk_l.c"
 
 #define INITIAL 0
 #define LEXERR 1
@@ -1483,7 +1483,7 @@ YY_DECL
 #line 180 "libxlu_disk_l.l"
  /*----- the scanner rules which do the parsing -----*/
 
-#line 1487 "libxlu_disk_l.c"
+#line 1486 "libxlu_disk_l.c"
 
 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
 		{
@@ -1836,7 +1836,7 @@ YY_RULE_SETUP
 #line 291 "libxlu_disk_l.l"
 YY_FATAL_ERROR( "flex scanner jammed" );
 	YY_BREAK
-#line 1840 "libxlu_disk_l.c"
+#line 1839 "libxlu_disk_l.c"
 			case YY_STATE_EOF(INITIAL):
 			case YY_STATE_EOF(LEXERR):
 				yyterminate();
diff --git a/tools/libxl/libxlu_disk_l.h b/tools/libxl/libxlu_disk_l.h
index 54f4662d7a..6abeecf279 100644
--- a/tools/libxl/libxlu_disk_l.h
+++ b/tools/libxl/libxlu_disk_l.h
@@ -2,10 +2,10 @@
 #define xlu__disk_yyHEADER_H 1
 #define xlu__disk_yyIN_HEADER 1
 
-#line 6 "libxlu_disk_l.h"
-#include "libxl_osdeps.h" /* must come before any other headers */
+#line 5 "libxlu_disk_l.h"
+#define _GNU_SOURCE
 
-#line 9 "libxlu_disk_l.h"
+#line 8 "libxlu_disk_l.h"
 
 #define  YY_INT_ALIGNED short int
 
@@ -696,6 +696,6 @@ extern int yylex (yyscan_t yyscanner);
 
 #line 291 "libxlu_disk_l.l"
 
-#line 700 "libxlu_disk_l.h"
+#line 699 "libxlu_disk_l.h"
 #undef xlu__disk_yyIN_HEADER
 #endif /* xlu__disk_yyHEADER_H */
diff --git a/tools/libxl/libxlu_disk_l.l b/tools/libxl/libxlu_disk_l.l
index 7a46f4a30c..3bd639aab0 100644
--- a/tools/libxl/libxlu_disk_l.l
+++ b/tools/libxl/libxlu_disk_l.l
@@ -28,7 +28,7 @@
  */
 
 %top{
-#include "libxl_osdeps.h" /* must come before any other headers */
+#define _GNU_SOURCE
 }
 
 %{
diff --git a/tools/libxl/libxlu_pci.c b/tools/libxl/libxlu_pci.c
index e2709c5f89..12fc0b3a7f 100644
--- a/tools/libxl/libxlu_pci.c
+++ b/tools/libxl/libxlu_pci.c
@@ -1,4 +1,5 @@
-#include "libxl_osdeps.h" /* must come before any other headers */
+#define _GNU_SOURCE
+
 #include "libxlu_internal.h"
 #include "libxlu_disk_l.h"
 #include "libxlu_disk_i.h"
diff --git a/tools/libxl/libxlu_vif.c b/tools/libxl/libxlu_vif.c
index 0665e624dc..ccf0cbdf57 100644
--- a/tools/libxl/libxlu_vif.c
+++ b/tools/libxl/libxlu_vif.c
@@ -1,4 +1,5 @@
-#include "libxl_osdeps.h" /* must come before any other headers */
+#define _GNU_SOURCE
+
 #include "libxlu_internal.h"
 
 static const char *vif_bytes_per_sec_re = "^[0-9]+[GMK]?[Bb]/s$";
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 25/31] tools/libxl: add missing items to clean target
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (23 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 24/31] tools/libxl: don't include libxl_osdeps.h from libxlutil sources Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 26/31] tools/libxl: move xl parsing checks to tools/xl Juergen Gross
                   ` (5 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu, Anthony PERARD

Some generated files are not removed by "make clean". Add them.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
 tools/libxl/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index d3dd9efadf..3cc868d9e9 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -385,8 +385,10 @@ clean:
 	$(RM) -f _*.h *.o *.so* *.a $(CLIENTS) $(DEPS_RM)
 	$(RM) -f _*.c *.pyc _paths.*.tmp _*.api-for-check
 	$(RM) -f testidl.c.new testidl.c *.api-ok
+	$(RM) -f $(TEST_PROGS)
 	$(RM) -f xenlight.pc
 	$(RM) -f xlutil.pc
+	$(RM) -rf __pycache__
 	$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) clean
 
 distclean: clean
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 26/31] tools/libxl: move xl parsing checks to tools/xl
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (24 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 25/31] tools/libxl: add missing items to clean target Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 27/31] tools/xl: don't assume libxl and libxlutil are in one directory Juergen Gross
                   ` (4 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu, Anthony PERARD

check-xl-* scripts and data are not libxl- but xl-specific. Move them
from tools/libxl/ to tools/xl/.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
 tools/{libxl => xl}/check-xl-disk-parse                 | 0
 tools/{libxl => xl}/check-xl-vcpupin-parse              | 0
 tools/{libxl => xl}/check-xl-vcpupin-parse.data-example | 0
 tools/{libxl => xl}/check-xl-vif-parse                  | 0
 4 files changed, 0 insertions(+), 0 deletions(-)
 rename tools/{libxl => xl}/check-xl-disk-parse (100%)
 rename tools/{libxl => xl}/check-xl-vcpupin-parse (100%)
 rename tools/{libxl => xl}/check-xl-vcpupin-parse.data-example (100%)
 rename tools/{libxl => xl}/check-xl-vif-parse (100%)

diff --git a/tools/libxl/check-xl-disk-parse b/tools/xl/check-xl-disk-parse
similarity index 100%
rename from tools/libxl/check-xl-disk-parse
rename to tools/xl/check-xl-disk-parse
diff --git a/tools/libxl/check-xl-vcpupin-parse b/tools/xl/check-xl-vcpupin-parse
similarity index 100%
rename from tools/libxl/check-xl-vcpupin-parse
rename to tools/xl/check-xl-vcpupin-parse
diff --git a/tools/libxl/check-xl-vcpupin-parse.data-example b/tools/xl/check-xl-vcpupin-parse.data-example
similarity index 100%
rename from tools/libxl/check-xl-vcpupin-parse.data-example
rename to tools/xl/check-xl-vcpupin-parse.data-example
diff --git a/tools/libxl/check-xl-vif-parse b/tools/xl/check-xl-vif-parse
similarity index 100%
rename from tools/libxl/check-xl-vif-parse
rename to tools/xl/check-xl-vif-parse
-- 
2.26.2



^ permalink raw reply	[flat|nested] 48+ messages in thread

* [PATCH v4 27/31] tools/xl: don't assume libxl and libxlutil are in one directory
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (25 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 26/31] tools/libxl: move xl parsing checks to tools/xl Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 28/31] tools/libxl: move libxenlight to tools/libs/light Juergen Gross
                   ` (3 subsequent siblings)
  30 siblings, 0 replies; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu, Anthony PERARD

Add the correct flags for both, libxenlight and libxlutil, when
building xl.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
 tools/xl/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/xl/Makefile b/tools/xl/Makefile
index af4912e67a..407dd7554c 100644
--- a/tools/xl/Makefile
+++ b/tools/xl/Makefile
@@ -13,6 +13,7 @@ CFLAGS += $(PTHREAD_CFLAGS)
 LDFLAGS += $(PTHREAD_LDFLAGS)
 
 CFLAGS_XL += $(CFLAGS_libxenlight)
+CFLAGS_XL += $(CFLAGS_libxlutil)
 CFLAGS_XL += -Wshadow
 
 XL_OBJS-$(CONFIG_X86) = xl_psr.o
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 28/31] tools/libxl: move libxenlight to tools/libs/light
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (26 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 27/31] tools/xl: don't assume libxl and libxlutil are in one directory Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 16:05   ` Wei Liu
  2020-08-28 15:07 ` [PATCH v4 29/31] tools: rename global libxlutil make variables Juergen Gross
                   ` (2 subsequent siblings)
  30 siblings, 1 reply; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel
  Cc: Juergen Gross, Andrew Cooper, George Dunlap, Ian Jackson,
	Jan Beulich, Julien Grall, Stefano Stabellini, Wei Liu,
	Anthony PERARD, Shriram Rajagopalan, Yang Hongyang,
	Christian Lindig, David Scott

Carve out all libxenlight related sources and move them to
tools/libs/light in order to use the generic library build environment.

The closely related sources for libxl-save-helper and the libxl test
environment are being moved, too.

Signed-off-by: Juergen Gross <jgross@suse.com>
Acked-by: Wei Liu <wl@xen.org>
---
 .gitignore                                    |  31 +-
 tools/Rules.mk                                |  11 +-
 tools/configure                               |   2 +-
 tools/configure.ac                            |   2 +-
 tools/libs/Makefile                           |   1 +
 tools/libs/light/CODING_STYLE                 | 330 ++++++++++++++++++
 tools/libs/light/Makefile                     | 291 +++++++++++++++
 .../light}/check-libxl-api-rules              |   0
 tools/{libxl => libs/light}/flexarray.c       |   0
 tools/{libxl => libs/light}/flexarray.h       |   0
 tools/{libxl => libs/light}/gentest.py        |   0
 tools/{libxl => libs/light}/gentypes.py       |   0
 tools/{libxl => libs/light}/idl.py            |   0
 tools/{libxl => libs/light}/idl.txt           |   0
 tools/{libxl => libs/light/include}/libxl.h   |   0
 .../light/include}/libxl_event.h              |   0
 .../light/include}/libxl_json.h               |   0
 .../light/include}/libxl_utils.h              |   0
 .../light/include}/libxl_uuid.h               |   0
 tools/{libxl => libs/light}/libxl.c           |   0
 tools/{libxl => libs/light}/libxl_9pfs.c      |   0
 tools/{libxl => libs/light}/libxl_aoutils.c   |   0
 tools/{libxl => libs/light}/libxl_arch.h      |   0
 tools/{libxl => libs/light}/libxl_arm.c       |   0
 tools/{libxl => libs/light}/libxl_arm.h       |   0
 tools/{libxl => libs/light}/libxl_arm_acpi.c  |   0
 .../{libxl => libs/light}/libxl_arm_no_acpi.c |   0
 .../{libxl => libs/light}/libxl_bootloader.c  |   0
 .../light}/libxl_checkpoint_device.c          |   0
 tools/{libxl => libs/light}/libxl_colo.h      |   0
 tools/{libxl => libs/light}/libxl_colo_nic.c  |   0
 .../{libxl => libs/light}/libxl_colo_proxy.c  |   0
 .../{libxl => libs/light}/libxl_colo_qdisk.c  |   0
 .../light}/libxl_colo_restore.c               |   0
 tools/{libxl => libs/light}/libxl_colo_save.c |   0
 tools/{libxl => libs/light}/libxl_console.c   |   0
 .../light}/libxl_convert_callout.c            |   0
 tools/{libxl => libs/light}/libxl_cpuid.c     |   0
 tools/{libxl => libs/light}/libxl_cpupool.c   |   0
 tools/{libxl => libs/light}/libxl_create.c    |   0
 tools/{libxl => libs/light}/libxl_device.c    |   0
 tools/{libxl => libs/light}/libxl_disk.c      |   0
 tools/{libxl => libs/light}/libxl_dm.c        |   0
 tools/{libxl => libs/light}/libxl_dom.c       |   0
 tools/{libxl => libs/light}/libxl_dom_save.c  |   0
 .../{libxl => libs/light}/libxl_dom_suspend.c |   0
 tools/{libxl => libs/light}/libxl_domain.c    |   0
 tools/{libxl => libs/light}/libxl_event.c     |   0
 tools/{libxl => libs/light}/libxl_exec.c      |   0
 tools/{libxl => libs/light}/libxl_flask.c     |   0
 tools/{libxl => libs/light}/libxl_fork.c      |   0
 tools/{libxl => libs/light}/libxl_freebsd.c   |   0
 tools/{libxl => libs/light}/libxl_genid.c     |   0
 tools/{libxl => libs/light}/libxl_internal.c  |   0
 tools/{libxl => libs/light}/libxl_internal.h  |   0
 tools/{libxl => libs/light}/libxl_json.c      |   0
 .../light}/libxl_libfdt_compat.c              |   0
 .../light}/libxl_libfdt_compat.h              |   0
 tools/{libxl => libs/light}/libxl_linux.c     |   0
 tools/{libxl => libs/light}/libxl_mem.c       |   0
 tools/{libxl => libs/light}/libxl_netbsd.c    |   0
 tools/{libxl => libs/light}/libxl_netbuffer.c |   0
 tools/{libxl => libs/light}/libxl_nic.c       |   0
 tools/{libxl => libs/light}/libxl_no_colo.c   |   0
 .../light}/libxl_no_convert_callout.c         |   0
 tools/{libxl => libs/light}/libxl_nocpuid.c   |   0
 .../{libxl => libs/light}/libxl_nonetbuffer.c |   0
 tools/{libxl => libs/light}/libxl_numa.c      |   0
 tools/{libxl => libs/light}/libxl_osdeps.h    |   0
 tools/{libxl => libs/light}/libxl_paths.c     |   0
 tools/{libxl => libs/light}/libxl_pci.c       |   0
 tools/{libxl => libs/light}/libxl_psr.c       |   0
 tools/{libxl => libs/light}/libxl_pvcalls.c   |   0
 tools/{libxl => libs/light}/libxl_qmp.c       |   0
 tools/{libxl => libs/light}/libxl_remus.c     |   0
 .../light}/libxl_remus_disk_drbd.c            |   0
 .../light}/libxl_save_callout.c               |   0
 .../{libxl => libs/light}/libxl_save_helper.c |   0
 .../light}/libxl_save_msgs_gen.pl             |   0
 tools/{libxl => libs/light}/libxl_sched.c     |   0
 .../light}/libxl_sr_stream_format.h           |   0
 .../{libxl => libs/light}/libxl_stream_read.c |   0
 .../light}/libxl_stream_write.c               |   0
 .../light}/libxl_test_fdevent.c               |   0
 .../light}/libxl_test_fdevent.h               |   0
 .../light}/libxl_test_timedereg.c             |   0
 .../light}/libxl_test_timedereg.h             |   0
 tools/{libxl => libs/light}/libxl_tmem.c      |   0
 tools/{libxl => libs/light}/libxl_types.idl   |   0
 .../light}/libxl_types_internal.idl           |   0
 tools/{libxl => libs/light}/libxl_usb.c       |   0
 tools/{libxl => libs/light}/libxl_utils.c     |   0
 tools/{libxl => libs/light}/libxl_uuid.c      |   0
 tools/{libxl => libs/light}/libxl_vdispl.c    |   0
 tools/{libxl => libs/light}/libxl_vkb.c       |   0
 tools/{libxl => libs/light}/libxl_vnuma.c     |   0
 tools/{libxl => libs/light}/libxl_vsnd.c      |   0
 tools/{libxl => libs/light}/libxl_vtpm.c      |   0
 tools/{libxl => libs/light}/libxl_x86.c       |   0
 tools/{libxl => libs/light}/libxl_x86_acpi.c  |   0
 tools/{libxl => libs/light}/libxl_x86_acpi.h  |   0
 tools/{libxl => libs/light}/libxl_xshelp.c    |   0
 tools/{libxl => libs/light}/osdeps.c          |   0
 tools/{libxl => libs/light}/test_common.c     |   0
 tools/{libxl => libs/light}/test_common.h     |   0
 .../{libxl => libs/light}/test_fdderegrace.c  |   0
 tools/{libxl => libs/light}/test_timedereg.c  |   0
 tools/libs/uselibs.mk                         |   2 +
 tools/libxl/Makefile                          | 293 +---------------
 tools/ocaml/libs/xl/Makefile                  |   8 +-
 110 files changed, 658 insertions(+), 313 deletions(-)
 create mode 100644 tools/libs/light/CODING_STYLE
 create mode 100644 tools/libs/light/Makefile
 rename tools/{libxl => libs/light}/check-libxl-api-rules (100%)
 rename tools/{libxl => libs/light}/flexarray.c (100%)
 rename tools/{libxl => libs/light}/flexarray.h (100%)
 rename tools/{libxl => libs/light}/gentest.py (100%)
 rename tools/{libxl => libs/light}/gentypes.py (100%)
 rename tools/{libxl => libs/light}/idl.py (100%)
 rename tools/{libxl => libs/light}/idl.txt (100%)
 rename tools/{libxl => libs/light/include}/libxl.h (100%)
 rename tools/{libxl => libs/light/include}/libxl_event.h (100%)
 rename tools/{libxl => libs/light/include}/libxl_json.h (100%)
 rename tools/{libxl => libs/light/include}/libxl_utils.h (100%)
 rename tools/{libxl => libs/light/include}/libxl_uuid.h (100%)
 rename tools/{libxl => libs/light}/libxl.c (100%)
 rename tools/{libxl => libs/light}/libxl_9pfs.c (100%)
 rename tools/{libxl => libs/light}/libxl_aoutils.c (100%)
 rename tools/{libxl => libs/light}/libxl_arch.h (100%)
 rename tools/{libxl => libs/light}/libxl_arm.c (100%)
 rename tools/{libxl => libs/light}/libxl_arm.h (100%)
 rename tools/{libxl => libs/light}/libxl_arm_acpi.c (100%)
 rename tools/{libxl => libs/light}/libxl_arm_no_acpi.c (100%)
 rename tools/{libxl => libs/light}/libxl_bootloader.c (100%)
 rename tools/{libxl => libs/light}/libxl_checkpoint_device.c (100%)
 rename tools/{libxl => libs/light}/libxl_colo.h (100%)
 rename tools/{libxl => libs/light}/libxl_colo_nic.c (100%)
 rename tools/{libxl => libs/light}/libxl_colo_proxy.c (100%)
 rename tools/{libxl => libs/light}/libxl_colo_qdisk.c (100%)
 rename tools/{libxl => libs/light}/libxl_colo_restore.c (100%)
 rename tools/{libxl => libs/light}/libxl_colo_save.c (100%)
 rename tools/{libxl => libs/light}/libxl_console.c (100%)
 rename tools/{libxl => libs/light}/libxl_convert_callout.c (100%)
 rename tools/{libxl => libs/light}/libxl_cpuid.c (100%)
 rename tools/{libxl => libs/light}/libxl_cpupool.c (100%)
 rename tools/{libxl => libs/light}/libxl_create.c (100%)
 rename tools/{libxl => libs/light}/libxl_device.c (100%)
 rename tools/{libxl => libs/light}/libxl_disk.c (100%)
 rename tools/{libxl => libs/light}/libxl_dm.c (100%)
 rename tools/{libxl => libs/light}/libxl_dom.c (100%)
 rename tools/{libxl => libs/light}/libxl_dom_save.c (100%)
 rename tools/{libxl => libs/light}/libxl_dom_suspend.c (100%)
 rename tools/{libxl => libs/light}/libxl_domain.c (100%)
 rename tools/{libxl => libs/light}/libxl_event.c (100%)
 rename tools/{libxl => libs/light}/libxl_exec.c (100%)
 rename tools/{libxl => libs/light}/libxl_flask.c (100%)
 rename tools/{libxl => libs/light}/libxl_fork.c (100%)
 rename tools/{libxl => libs/light}/libxl_freebsd.c (100%)
 rename tools/{libxl => libs/light}/libxl_genid.c (100%)
 rename tools/{libxl => libs/light}/libxl_internal.c (100%)
 rename tools/{libxl => libs/light}/libxl_internal.h (100%)
 rename tools/{libxl => libs/light}/libxl_json.c (100%)
 rename tools/{libxl => libs/light}/libxl_libfdt_compat.c (100%)
 rename tools/{libxl => libs/light}/libxl_libfdt_compat.h (100%)
 rename tools/{libxl => libs/light}/libxl_linux.c (100%)
 rename tools/{libxl => libs/light}/libxl_mem.c (100%)
 rename tools/{libxl => libs/light}/libxl_netbsd.c (100%)
 rename tools/{libxl => libs/light}/libxl_netbuffer.c (100%)
 rename tools/{libxl => libs/light}/libxl_nic.c (100%)
 rename tools/{libxl => libs/light}/libxl_no_colo.c (100%)
 rename tools/{libxl => libs/light}/libxl_no_convert_callout.c (100%)
 rename tools/{libxl => libs/light}/libxl_nocpuid.c (100%)
 rename tools/{libxl => libs/light}/libxl_nonetbuffer.c (100%)
 rename tools/{libxl => libs/light}/libxl_numa.c (100%)
 rename tools/{libxl => libs/light}/libxl_osdeps.h (100%)
 rename tools/{libxl => libs/light}/libxl_paths.c (100%)
 rename tools/{libxl => libs/light}/libxl_pci.c (100%)
 rename tools/{libxl => libs/light}/libxl_psr.c (100%)
 rename tools/{libxl => libs/light}/libxl_pvcalls.c (100%)
 rename tools/{libxl => libs/light}/libxl_qmp.c (100%)
 rename tools/{libxl => libs/light}/libxl_remus.c (100%)
 rename tools/{libxl => libs/light}/libxl_remus_disk_drbd.c (100%)
 rename tools/{libxl => libs/light}/libxl_save_callout.c (100%)
 rename tools/{libxl => libs/light}/libxl_save_helper.c (100%)
 rename tools/{libxl => libs/light}/libxl_save_msgs_gen.pl (100%)
 rename tools/{libxl => libs/light}/libxl_sched.c (100%)
 rename tools/{libxl => libs/light}/libxl_sr_stream_format.h (100%)
 rename tools/{libxl => libs/light}/libxl_stream_read.c (100%)
 rename tools/{libxl => libs/light}/libxl_stream_write.c (100%)
 rename tools/{libxl => libs/light}/libxl_test_fdevent.c (100%)
 rename tools/{libxl => libs/light}/libxl_test_fdevent.h (100%)
 rename tools/{libxl => libs/light}/libxl_test_timedereg.c (100%)
 rename tools/{libxl => libs/light}/libxl_test_timedereg.h (100%)
 rename tools/{libxl => libs/light}/libxl_tmem.c (100%)
 rename tools/{libxl => libs/light}/libxl_types.idl (100%)
 rename tools/{libxl => libs/light}/libxl_types_internal.idl (100%)
 rename tools/{libxl => libs/light}/libxl_usb.c (100%)
 rename tools/{libxl => libs/light}/libxl_utils.c (100%)
 rename tools/{libxl => libs/light}/libxl_uuid.c (100%)
 rename tools/{libxl => libs/light}/libxl_vdispl.c (100%)
 rename tools/{libxl => libs/light}/libxl_vkb.c (100%)
 rename tools/{libxl => libs/light}/libxl_vnuma.c (100%)
 rename tools/{libxl => libs/light}/libxl_vsnd.c (100%)
 rename tools/{libxl => libs/light}/libxl_vtpm.c (100%)
 rename tools/{libxl => libs/light}/libxl_x86.c (100%)
 rename tools/{libxl => libs/light}/libxl_x86_acpi.c (100%)
 rename tools/{libxl => libs/light}/libxl_x86_acpi.h (100%)
 rename tools/{libxl => libs/light}/libxl_xshelp.c (100%)
 rename tools/{libxl => libs/light}/osdeps.c (100%)
 rename tools/{libxl => libs/light}/test_common.c (100%)
 rename tools/{libxl => libs/light}/test_common.h (100%)
 rename tools/{libxl => libs/light}/test_fdderegrace.c (100%)
 rename tools/{libxl => libs/light}/test_timedereg.c (100%)

diff --git a/.gitignore b/.gitignore
index 5e8c47e2db..f30550255f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -128,6 +128,22 @@ tools/libs/guest/xc_core.h
 tools/libs/guest/xc_core_arm.h
 tools/libs/guest/xc_core_x86.h
 tools/libs/guest/xc_private.h
+tools/libs/light/_*.[ch]
+tools/libs/light/*.pyc
+tools/libs/light/_libxl.api-for-check
+tools/libs/light/*.api-ok
+tools/libs/light/libxenlight.map
+tools/libs/light/libxl-save-helper
+tools/libs/light/dsdt*
+tools/libs/light/mk_dsdt
+tools/libs/light/ssdt*
+tools/libs/light/testidl
+tools/libs/light/testidl.c
+tools/libs/light/test_timedereg
+tools/libs/light/test_fdderegrace
+tools/libs/light/tmp.*
+tools/libs/light/xenlight.pc
+tools/libs/light/include/_*.h
 tools/libs/stat/_paths.h
 tools/libs/stat/headers.chk
 tools/libs/stat/libxenstat.map
@@ -216,16 +232,8 @@ tools/include/xen/*
 tools/include/xen-xsm/*
 tools/include/xen-foreign/*.(c|h|size)
 tools/include/xen-foreign/checker
-tools/libxl/_libxl.api-for-check
-tools/libxl/*.api-ok
 tools/libxl/*.pc
-tools/libxl/dsdt*
 tools/libxl/libxlu_cfg_y.output
-tools/libxl/mk_dsdt
-tools/libxl/ssdt*
-tools/libxl/testenum
-tools/libxl/testenum.c
-tools/libxl/tmp.*
 tools/misc/cpuperf/cpuperf-perfcntr
 tools/misc/cpuperf/cpuperf-xen
 tools/misc/xc_shadow
@@ -380,13 +388,6 @@ tools/include/xen-foreign/arm64.h
 tools/misc/xen-hptool
 tools/misc/xen-mfndump
 tools/libs/toolcore/include/_*.h
-tools/libxl/_*.[ch]
-tools/libxl/testidl
-tools/libxl/testidl.c
-tools/libxl/*.pyc
-tools/libxl/libxl-save-helper
-tools/libxl/test_timedereg
-tools/libxl/test_fdderegrace
 tools/firmware/etherboot/eb-roms.h
 tools/firmware/etherboot/gpxe-git-snapshot.tar.gz
 tools/misc/xenhypfs
diff --git a/tools/Rules.mk b/tools/Rules.mk
index fc121d0d75..a80a633190 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -15,9 +15,7 @@ XEN_INCLUDE        = $(XEN_ROOT)/tools/include
 
 include $(XEN_ROOT)/tools/libs/uselibs.mk
 
-XEN_libxenlight    = $(XEN_ROOT)/tools/libxl
-# Currently libxlutil lives in the same directory as libxenlight
-XEN_libxlutil      = $(XEN_libxenlight)
+XEN_libxlutil      = $(XEN_ROOT)/tools/libxl
 
 CFLAGS_xeninclude = -I$(XEN_INCLUDE)
 
@@ -107,6 +105,8 @@ ifeq ($(CONFIG_Linux),y)
 LDLIBS_libxenstore += -ldl
 endif
 
+CFLAGS_libxenlight += $(CFLAGS_libxenctrl)
+
 ifeq ($(debug),y)
 # Disable optimizations
 CFLAGS += -O0 -fno-omit-frame-pointer
@@ -116,11 +116,6 @@ else
 CFLAGS += -O2 -fomit-frame-pointer
 endif
 
-CFLAGS_libxenlight = -I$(XEN_libxenlight) $(CFLAGS_libxenctrl) $(CFLAGS_xeninclude)
-SHDEPS_libxenlight = $(SHLIB_libxenctrl) $(SHLIB_libxenstore) $(SHLIB_libxenhypfs) $(SHLIB_libxenguest)
-LDLIBS_libxenlight = $(SHDEPS_libxenlight) $(XEN_libxenlight)/libxenlight$(libextension)
-SHLIB_libxenlight  = $(SHDEPS_libxenlight) -Wl,-rpath-link=$(XEN_libxenlight)
-
 CFLAGS_libxlutil = -I$(XEN_libxlutil)
 SHDEPS_libxlutil = $(SHLIB_libxenlight)
 LDLIBS_libxlutil = $(SHDEPS_libxlutil) $(XEN_libxlutil)/libxlutil$(libextension)
diff --git a/tools/configure b/tools/configure
index edcdcf4f73..8a708e9baa 100755
--- a/tools/configure
+++ b/tools/configure
@@ -585,7 +585,7 @@ PACKAGE_STRING='Xen Hypervisor Tools 4.15'
 PACKAGE_BUGREPORT='xen-devel@lists.xen.org'
 PACKAGE_URL='https://www.xen.org/'
 
-ac_unique_file="libxl/libxl.c"
+ac_unique_file="libs/light/libxl.c"
 # Factoring default headers for most tests.
 ac_includes_default="\
 #include <stdio.h>
diff --git a/tools/configure.ac b/tools/configure.ac
index 6614a4f130..ee8ba5ff24 100644
--- a/tools/configure.ac
+++ b/tools/configure.ac
@@ -4,7 +4,7 @@
 AC_PREREQ([2.67])
 AC_INIT([Xen Hypervisor Tools], m4_esyscmd([../version.sh ../xen/Makefile]),
     [xen-devel@lists.xen.org], [xen], [https://www.xen.org/])
-AC_CONFIG_SRCDIR([libxl/libxl.c])
+AC_CONFIG_SRCDIR([libs/light/libxl.c])
 AC_CONFIG_FILES([
 ../config/Tools.mk
 hotplug/FreeBSD/rc.d/xencommons
diff --git a/tools/libs/Makefile b/tools/libs/Makefile
index e8fcd59214..c41455c604 100644
--- a/tools/libs/Makefile
+++ b/tools/libs/Makefile
@@ -15,6 +15,7 @@ SUBDIRS-y += hypfs
 SUBDIRS-y += store
 SUBDIRS-y += stat
 SUBDIRS-$(CONFIG_Linux) += vchan
+SUBDIRS-y += light
 
 ifeq ($(CONFIG_RUMP),y)
 SUBDIRS-y := toolcore
diff --git a/tools/libs/light/CODING_STYLE b/tools/libs/light/CODING_STYLE
new file mode 100644
index 0000000000..3d572f6925
--- /dev/null
+++ b/tools/libs/light/CODING_STYLE
@@ -0,0 +1,330 @@
+LIBXENLIGHT CODING STYLE
+========================
+
+
+AN APOLOGY AND WARNING
+----------------------
+
+Much of the code in libxl does not yet follow this coding style
+document in every respect.  However, new code is expected to conform.
+
+Patches to improve the style of existing code are welcome.  Please
+separate these out from functional changes.
+
+If it is not feasible to conform fully to the style while patching old
+code, without doing substantial style reengineering first, we may
+accept patches which contain nonconformant elements, provided that
+they don't make the coding style problem worse overall.
+
+In this case, the new code should conform to the prevailing style in
+the area being touched.
+
+
+MEMORY ALLOCATION
+-----------------
+
+Memory allocation for libxl-internal purposes should normally be done
+with the provided gc mechanisms; there is then no need to free.  See
+"libxl memory management" in libxl.h.
+
+
+CONVENTIONAL VARIABLE NAMES
+---------------------------
+
+The following local variable names should be used where applicable:
+
+  int rc;    /* a libxl error code - and not anything else */
+  int r;     /* the return value from a system call (or libxc call) */
+  bool ok;   /* the success return value from a boolean function */
+
+  uint32_t domid;
+  libxl__gc *gc;
+  libxl__egc *egc;
+  libxl__ao *ao;
+
+  libxl_foo_bar_state *fbs;    /* local variable */
+  libxl_foo_bar_state foo_bar; /* inside another state struct */
+
+
+CONVENIENCE MACROS
+------------------
+
+There are a number of convenience macros which shorten the program and
+avoid opportunity for mistakes.  In some cases non-use of the macros
+produces functional bugs or incorrect error handling.  Use the macros
+whenever they are applicable.  For example:
+
+ Usually, don't use:     Instead, use (see libxl_internal.h):
+  libxl__log[v]           LOG, LOGE, LOGEV
+  libxl__sprintf          GCSPRINTF
+  libxl__*alloc et al.    GCNEW, GCNEW_ARRAY, GCREALLOC_ARRAY
+  isalnum etc. directly   CTYPE
+  libxl__ctx_[un]lock     CTX_LOCK, CTX_UNLOCK
+  gc=...; ao=...;         EGC_GC, AO_GC, STATE_AO_GC
+  explicit gc creation    GC_INIT, GC_FREE
+  memset(..,0,sizeof..)   FILLZERO
+
+Instead of malloc et al one should (as an exception to the above) use
+libxl__{zalloc,calloc,realloc} etc but passing NOGC.
+
+ERROR HANDLING
+--------------
+
+Unless, there are good reasons to do otherwise, the following error
+handling and cleanup paradigm should be used:
+
+  * All local variables referring to resources which might need
+    cleaning up are declared at the top of the function, and
+    initialised to a sentinel value indicating "nothing allocated".
+    For example,
+            libxl_evgen_disk_eject *evg = NULL;
+            int nullfd = -1;
+
+  * If the function is to return a libxl error value, `rc' is
+    used to contain the error code, but it is NOT initialised:
+            int rc;
+
+  * There is only one error cleanup path out of the function.  It
+    starts with a label `out:'.  That error cleanup path checks for
+    each allocated resource and frees it iff necessary.  It then
+    returns rc.  For example,
+         out:
+             if (evg) libxl__evdisable_disk_eject(gc, evg);
+             if (nullfd >= 0) close(nullfd);
+             return rc;
+
+  * Function calls which might fail (ie most function calls) are
+    handled by putting the return/status value into a variable, and
+    then checking it in a separate statement:
+            char *dompath = libxl__xs_get_dompath(gc, bl->domid);
+            if (!dompath) { rc = ERROR_FAIL; goto out; }
+
+  * If a resource is freed in the main body of the function (for
+    example, in a loop), the corresponding variable has to be reset to
+    the sentinel at the point where it's freed.
+
+Whether to use the `out' path for successful returns as well as error
+returns is a matter of taste and convenience for the specific
+function.  Not reusing the out path is fine if the duplicated function
+exit code is only `CTX_UNLOCK; GC_FREE;' (or similar).
+
+If you reuse the `out' path for successful returns, there may be
+resources which are to be returned to the caller rather than freed.
+In that case you have to reset the local variable to `nothing here',
+to avoid the resource being freed on the out path.  That resetting
+should be done immediately after the resource value is stored at the
+applicable _r function parameter (or equivalent).  Do not test `rc' in
+the out section, to discover whether to free things.
+
+The uses of the single-line formatting in the examples above are
+permitted exceptions to the usual libxl code formatting rules.
+
+
+
+IDEMPOTENT DATA STRUCTURE CONSTRUCTION/DESTRUCTION
+--------------------------------------------------
+
+Nontrivial data structures (in structs) should come with an idempotent
+_dispose function, which must free all resources associated with the
+data structure (but not free the struct itself).
+
+Such a struct should also come with an _init function which
+initialises the struct so that _dispose is a no-op.
+
+
+ASYNCHRONOUS/LONG-RUNNING OPERATIONS
+------------------------------------
+
+All long-running operations in libxl need to use the asynchronous
+operation machinery.  Consult the programmer documentation in
+libxl_internal.h for details - search for "Machinery for asynchronous
+operations".
+
+The code for asynchronous operations should be laid out in
+chronological order.  That is, where there is a chain of callback
+functions, each subsequent function should be, textually, the next
+function in the file.  This will normally involve predeclaring the
+callback functions.  Synchronous helper functions should be separated
+out into a section preceding the main callback chain.
+
+Control flow arrangements in asynchronous operations should be made as
+simple as possible, because it can otherwise be very hard to see
+through the tangle.
+
+
+When inventing a new sub-operation in asynchronous code, consider
+whether to structure it formally as a sub-operation with its own state
+structure.  (See, for example, libxl__datacopier_*.)
+
+An ao-suboperation state structure should contain, in this order:
+  * fields that the caller must fill in, and which are,
+    effectively, the parameters to the operation, including:
+      - libxl__ao *ao
+      - the callback function pointer(s), which
+        should be named callback or callback_*.
+  * shared information fields or ones used for returning information
+    to the calling operation
+  * private fields
+These sections should be clearly demarcated by comments.
+
+An asynchronous operation should normally have an idempotent stop or
+cancel function.  It should normally also have an _init function for
+its state struct, which arranges that the stop is a no-op.
+
+The permitted order of calls into your ao operation's methods must be
+documented in comments, if it is nontrivial.
+
+
+When using an ao sub-operation, you should normally:
+ * Physically include the sub-operation state struct in your
+   own state struct;
+ * Use CONTAINER_OF to find your own state struct at the start of
+   your implementations of the sub-operation callback functions;
+ * Unconditionally initialise the sub-operation's struct (with its
+   _init method) in your own _init method.
+ * Unconditionally cancel or destroy the sub-operation in your own
+   cancel or destroy method.
+
+
+FORMATTING AND NAMING
+---------------------
+
+Blatantly copied from qemu and linux with few modifications.
+
+
+1. Whitespace
+
+Of course, the most important aspect in any coding style is whitespace.
+Crusty old coders who have trouble spotting the glasses on their noses
+can tell the difference between a tab and eight spaces from a distance
+of approximately fifteen parsecs.  Many a flamewar have been fought and
+lost on this issue.
+
+Libxenlight indents are four spaces.  Tabs are never used, except in
+Makefiles where they have been irreversibly coded into the syntax.
+Spaces of course are superior to tabs because:
+
+ - You have just one way to specify whitespace, not two.  Ambiguity breeds
+   mistakes.
+ - The confusion surrounding 'use tabs to indent, spaces to justify' is gone.
+ - Tab indents push your code to the right, making your screen seriously
+   unbalanced.
+ - Tabs will be rendered incorrectly on editors who are misconfigured not
+   to use tab stops of eight positions.
+ - Tabs are rendered badly in patches, causing off-by-one errors in almost
+   every line.
+ - It is the libxenlight coding style.
+
+Do not leave whitespace dangling off the ends of lines.
+
+
+2. Line width
+
+Lines are limited to 75 characters.
+
+Rationale:
+ - Some people like to tile their 24" screens with a 6x4 matrix of 80x24
+   xterms and use vi in all of them.  The best way to punish them is to
+   let them keep doing it.
+ - In an 80 column terminal, some room needs to be left for > quoting
+   characters, +/- diff characters, and so on, in emails.
+ - Code and especially patches is much more readable if limited to a sane
+   line length.  Eighty is traditional.
+ - It is the libxenlight coding style.
+
+
+3. Naming
+
+C is a Spartan language, and so should your naming be.  Unlike Modula-2
+and Pascal programmers, C programmers do not use cute names like
+ThisVariableIsATemporaryCounter.  A C programmer would call that
+variable "tmp", which is much easier to write, and not the least more
+difficult to understand.
+
+HOWEVER, while mixed-case names are frowned upon, descriptive names for
+global variables are a must.  To call a global function "foo" is a
+shooting offense.
+
+GLOBAL variables (to be used only if you _really_ need them) need to
+have descriptive names, as do global functions.  If you have a function
+that counts the number of active users, you should call that
+"count_active_users()" or similar, you should _not_ call it "cntusr()".
+
+Encoding the type of a function into the name (so-called Hungarian
+notation) is brain damaged - the compiler knows the types anyway and can
+check those, and it only confuses the programmer.
+
+LOCAL variable names should be short, and to the point.  If you have
+some random integer loop counter, it should probably be called "i".
+Calling it "loop_counter" is non-productive, if there is no chance of it
+being mis-understood.  Similarly, "tmp" can be just about any type of
+variable that is used to hold a temporary value.
+
+Local variables used to store return values should have descriptive name
+like "rc" or "ret". Following the same reasoning the label used as exit
+path should be called "out".
+
+Function arguments which are used to return values to the caller
+should be suffixed `_r' or `_out'.
+
+Variables, type names and function names are
+lower_case_with_underscores.
+Type names and function names use the prefix libxl__ when internal to
+libxenlight and libxl_ when exported in libxl.h.
+Xl should avoid using libxl_ and libxl__ as prefix for its own function
+names.
+
+When wrapping standard library functions, use the prefix libxl_ to alert
+readers that they are seeing a wrapped version; otherwise avoid this prefix.
+
+Typedefs are used to eliminate the redundant 'struct' keyword.
+It is the libxenlight coding style.
+
+
+4. Statements
+
+Don't put multiple statements on a single line.
+Don't put multiple assignments on a single line either.
+Error code paths with an if statement and a goto or a return on the same
+line are allowed. Examples:
+
+    if (rc) goto out;
+    if (rc < 0) return;
+
+Libxenlight coding style is super simple.  Avoid tricky expressions.
+
+
+5. Block structure
+
+Every indented statement is braced, but blocks that contain just one
+statement may have the braces omitted.  To avoid confusion, either all
+the blocks in an if...else chain have braces, or none of them do.
+
+The opening brace is on the line that contains the control flow
+statement that introduces the new block; the closing brace is on the
+same line as the else keyword, or on a line by itself if there is no
+else keyword.  Examples:
+
+    if (a == 5) {
+        printf("a was 5.\n");
+    } else if (a == 6) {
+        printf("a was 6.\n");
+    } else {
+        printf("a was something else entirely.\n");
+    }
+
+    if (a == 5)
+        printf("a was 5.\n");
+
+An exception is the opening brace for a function; for reasons of tradition
+and clarity it comes on a line by itself:
+
+    void a_function(void)
+    {
+        do_something();
+    }
+
+Rationale: a consistent (except for functions...) bracing style reduces
+ambiguity and avoids needless churn when lines are added or removed.
+Furthermore, it is the libxenlight coding style.
+
diff --git a/tools/libs/light/Makefile b/tools/libs/light/Makefile
new file mode 100644
index 0000000000..5d663e87b4
--- /dev/null
+++ b/tools/libs/light/Makefile
@@ -0,0 +1,291 @@
+XEN_ROOT = $(CURDIR)/../../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+SRCS-y += osdeps.c
+SRCS-y += libxl_paths.c
+SRCS-y += libxl_bootloader.c
+SRCS-y += flexarray.c
+ifeq ($(CONFIG_LIBNL),y)
+SRCS-y += libxl_netbuffer.c
+else
+SRCS-y += libxl_nonetbuffer.c
+endif
+ifeq ($(CONFIG_X86),y)
+SRCS-y += libxl_convert_callout.c
+else
+SRCS-y += libxl_no_convert_callout.c
+endif
+SRCS-y += libxl_remus.c
+SRCS-y += libxl_checkpoint_device.c
+SRCS-y += libxl_remus_disk_drbd.c
+ifeq ($(CONFIG_LIBNL),y)
+SRCS-y += libxl_colo_restore.c
+SRCS-y += libxl_colo_save.c
+SRCS-y += libxl_colo_qdisk.c
+SRCS-y += libxl_colo_proxy.c
+SRCS-y += libxl_colo_nic.c
+else
+SRCS-y += libxl_no_colo.c
+endif
+
+ACPI_PATH  = $(XEN_ROOT)/tools/libacpi
+DSDT_FILES-$(CONFIG_X86) = dsdt_pvh.c
+ACPI_OBJS  = $(patsubst %.c,%.o,$(DSDT_FILES-y)) build.o static_tables.o
+ACPI_PIC_OBJS = $(patsubst %.o,%.opic,$(ACPI_OBJS))
+$(DSDT_FILES-y): acpi
+vpath build.c $(ACPI_PATH)/
+vpath static_tables.c $(ACPI_PATH)/
+
+.PHONY: acpi
+acpi:
+	$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) DSDT_FILES="$(DSDT_FILES-y)"
+
+SRCS-$(CONFIG_X86) += $(ACPI_OBJS:.o=.c)
+
+CFLAGS += -Wno-format-zero-length -Wmissing-declarations \
+	-Wno-declaration-after-statement -Wformat-nonliteral
+CFLAGS += -I.
+
+SRCS-$(CONFIG_X86) += libxl_cpuid.c
+SRCS-$(CONFIG_X86) += libxl_x86.c
+SRCS-$(CONFIG_X86) += libxl_psr.c
+SRCS-$(CONFIG_X86) += libxl_x86_acpi.c
+SRCS-$(CONFIG_ARM) += libxl_nocpuid.c
+SRCS-$(CONFIG_ARM) += libxl_arm.c
+SRCS-$(CONFIG_ARM) += libxl_libfdt_compat.c
+ifeq ($(CONFIG_ARM_64),y)
+DSDT_FILES-y = dsdt_anycpu_arm.c
+SRCS-y += libxl_arm_acpi.c
+SRCS-y += $(DSDT_FILES-y)
+dsdt_anycpu_arm.c:
+	$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) DSDT_FILES="$(DSDT_FILES-y)"
+else
+SRCS-$(CONFIG_ARM) += libxl_arm_no_acpi.c
+endif
+
+SRCS-OS-$(CONFIG_NetBSD) = libxl_netbsd.c
+SRCS-OS-$(CONFIG_Linux) = libxl_linux.c
+SRCS-OS-$(CONFIG_FreeBSD) = libxl_freebsd.c
+ifeq ($(SRCS-OS-y),)
+$(error Your Operating System is not supported by libxenlight, \
+please check libxl_linux.c and libxl_netbsd.c to see how to get it ported)
+endif
+SRCS-y += $(SRCS-OS-y)
+
+SRCS-y += libxl.c
+SRCS-y += libxl_create.c
+SRCS-y += libxl_dm.c
+SRCS-y += libxl_pci.c
+SRCS-y += libxl_dom.c
+SRCS-y += libxl_exec.c
+SRCS-y += libxl_xshelp.c
+SRCS-y += libxl_device.c
+SRCS-y += libxl_internal.c
+SRCS-y += libxl_utils.c
+SRCS-y += libxl_uuid.c
+SRCS-y += libxl_json.c
+SRCS-y += libxl_aoutils.c
+SRCS-y += libxl_numa.c
+SRCS-y += libxl_vnuma.c
+SRCS-y += libxl_stream_read.c
+SRCS-y += libxl_stream_write.c
+SRCS-y += libxl_save_callout.c
+SRCS-y += _libxl_save_msgs_callout.c
+SRCS-y += libxl_qmp.c
+SRCS-y += libxl_event.c
+SRCS-y += libxl_fork.c
+SRCS-y += libxl_dom_suspend.c
+SRCS-y += libxl_dom_save.c
+SRCS-y += libxl_usb.c
+SRCS-y += libxl_vtpm.c
+SRCS-y += libxl_nic.c
+SRCS-y += libxl_disk.c
+SRCS-y += libxl_console.c
+SRCS-y += libxl_cpupool.c
+SRCS-y += libxl_mem.c
+SRCS-y += libxl_sched.c
+SRCS-y += libxl_tmem.c
+SRCS-y += libxl_9pfs.c
+SRCS-y += libxl_domain.c
+SRCS-y += libxl_vdispl.c
+SRCS-y += libxl_pvcalls.c
+SRCS-y += libxl_vsnd.c
+SRCS-y += libxl_vkb.c
+SRCS-y += libxl_genid.c
+SRCS-y += _libxl_types.c
+SRCS-y += libxl_flask.c
+SRCS-y += _libxl_types_internal.c
+
+ifeq ($(CONFIG_LIBNL),y)
+CFLAGS_LIBXL += $(LIBNL3_CFLAGS)
+endif
+CFLAGS_LIBXL += -Wshadow
+ifeq ($(debug),y)
+CFLAGS_LIBXL += -DCONFIG_DEBUG
+endif
+
+CFLAGS += $(PTHREAD_CFLAGS)
+LDFLAGS += $(PTHREAD_LDFLAGS)
+
+LIBXL_TESTS += timedereg
+LIBXL_TESTS_PROGS = $(LIBXL_TESTS) fdderegrace
+LIBXL_TESTS_INSIDE = $(LIBXL_TESTS) fdevent
+
+# Each entry FOO in LIBXL_TESTS has two main .c files:
+#   libxl_test_FOO.c  "inside libxl" code to support the test case
+#   test_FOO.c        "outside libxl" code to exercise the test case
+# Conventionally there will also be:
+#   libxl_test_FOO.h  interface between the "inside" and "outside" parts
+# The "inside libxl" file is compiled exactly like a piece of libxl, and the
+# "outside libxl" file is compiled exactly like a piece of application
+# code.  They must share information via explicit libxl entrypoints.
+# Unlike proper parts of libxl, it is permissible for libxl_test_FOO.c
+# to use private global variables for its state.  Note that all the
+# "inside" parts are compiled into a single test library, so their
+# symbol names must be unique.
+#
+# To run these tests, either use LD_PRELOAD to get libxenlight_test.so
+# loaded, or rename it to libxenlight.so so it is the target of the
+# appropriate symlinks.
+
+LIBXL_TEST_OBJS += $(foreach t, $(LIBXL_TESTS_INSIDE),libxl_test_$t.opic)
+TEST_PROG_OBJS += $(foreach t, $(LIBXL_TESTS_PROGS),test_$t.o) test_common.o
+TEST_PROGS += $(foreach t, $(LIBXL_TESTS_PROGS),test_$t)
+
+AUTOINCS = _libxl_list.h _paths.h _libxl_save_msgs_callout.h _libxl_save_msgs_helper.h
+AUTOSRCS = _libxl_save_msgs_callout.c _libxl_save_msgs_helper.c
+
+CLIENTS = testidl libxl-save-helper
+
+SAVE_HELPER_OBJS = libxl_save_helper.o _libxl_save_msgs_helper.o
+
+LIBHEADER := libxl.h libxl_event.h libxl_json.h _libxl_types.h _libxl_types_json.h _libxl_list.h libxl_utils.h libxl_uuid.h
+
+NO_HEADERS_CHK := y
+
+include $(XEN_ROOT)/tools/libs/libs.mk
+
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(CURDIR)
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL = $(CFLAGS_xeninclude)
+
+LDUSELIBS-y += $(PTYFUNCS_LIBS)
+LDUSELIBS-$(CONFIG_LIBNL) += $(LIBNL3_LIBS)
+LDUSELIBS-$(CONFIG_Linux) += -luuid
+LDUSELIBS-$(CONFIG_Linux) += -lrt
+LDUSELIBS-$(CONFIG_ARM) += -lfdt
+LDUSELIBS-y += $(PTHREAD_LIBS)
+LDUSELIBS-y += -lyajl
+LDUSELIBS += $(LDUSELIBS-y)
+
+$(LIB_OBJS) $(PIC_OBJS) $(LIBXL_TEST_OBJS): CFLAGS += $(CFLAGS_LIBXL) -include $(XEN_ROOT)/tools/config.h
+$(ACPI_OBJS) $(ACPI_PIC_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"$(CURDIR)/libxl_x86_acpi.h\"
+$(TEST_PROG_OBJS) _libxl.api-for-check: CFLAGS += $(CFLAGS_libxentoollog) $(CFLAGS_libxentoolcore)
+libxl_dom.o libxl_dom.opic: CFLAGS += -I$(XEN_ROOT)/tools  # include libacpi/x86.h
+libxl_x86_acpi.o libxl_x86_acpi.opic: CFLAGS += -I$(XEN_ROOT)/tools
+$(SAVE_HELPER_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenevtchn) $(CFLAGS_libxenguest)
+
+testidl.o: CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenlight)
+testidl.c: libxl_types.idl gentest.py include/libxl.h $(AUTOINCS)
+	$(PYTHON) gentest.py libxl_types.idl testidl.c.new
+	mv testidl.c.new testidl.c
+
+build: $(CLIENTS) $(TEST_PROGS) $(AUTOSRCS) $(AUTOINCS) idl-external
+
+$(LIB_OBJS) $(PIC_OBJS) $(SAVE_HELPER_OBJS) $(LIBXL_TEST_OBJS) $(TEST_PROG_OBJS): $(AUTOINCS) libxl.api-ok
+
+genpath-target = $(call buildmakevars2header,_paths.h)
+$(eval $(genpath-target))
+
+libxl.api-ok: check-libxl-api-rules _libxl.api-for-check
+	$(PERL) $^
+	touch $@
+
+_%.api-for-check: include/%.h $(AUTOINCS)
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_$*.o) -c -E $< $(APPEND_CFLAGS) \
+		-DLIBXL_EXTERNAL_CALLERS_ONLY=LIBXL_EXTERNAL_CALLERS_ONLY \
+		>$@.new
+	mv -f $@.new $@
+
+_libxl_list.h: $(XEN_INCLUDE)/xen-external/bsd-sys-queue-h-seddery $(XEN_INCLUDE)/xen-external/bsd-sys-queue.h
+	$(PERL) $^ --prefix=libxl >$@.new
+	$(call move-if-changed,$@.new,$@)
+
+_libxl_save_msgs_helper.c _libxl_save_msgs_callout.c \
+_libxl_save_msgs_helper.h _libxl_save_msgs_callout.h: \
+		libxl_save_msgs_gen.pl
+	$(PERL) -w $< $@ >$@.new
+	$(call move-if-changed,$@.new,$@)
+
+include/libxl.h: _libxl_types.h _libxl_list.h
+include/libxl_json.h: _libxl_types_json.h
+libxl_internal.h: _libxl_types_internal.h _libxl_types_private.h _libxl_types_internal_private.h _paths.h
+libxl_internal_json.h: _libxl_types_internal_json.h
+xl.h: _paths.h
+
+$(LIB_OBJS) $(PIC_OBJS) $(LIBXL_TEST_OBJS) $(TEST_PROG_OBJS) $(SAVE_HELPER_OBJS): include/libxl.h
+$(LIB_OBJS) $(PIC_OBJS) $(LIBXL_TEST_OBJS): libxl_internal.h
+
+_libxl_type%.h _libxl_type%_json.h _libxl_type%_private.h _libxl_type%.c: libxl_type%.idl gentypes.py idl.py
+	$(eval stem = $(notdir $*))
+	$(PYTHON) gentypes.py libxl_type$(stem).idl __libxl_type$(stem).h __libxl_type$(stem)_private.h \
+		__libxl_type$(stem)_json.h  __libxl_type$(stem).c
+	$(call move-if-changed,__libxl_type$(stem).h,_libxl_type$(stem).h)
+	$(call move-if-changed,__libxl_type$(stem)_private.h,_libxl_type$(stem)_private.h)
+	$(call move-if-changed,__libxl_type$(stem)_json.h,_libxl_type$(stem)_json.h)
+	$(call move-if-changed,__libxl_type$(stem).c,_libxl_type$(stem).c)
+
+include/_%.h: _%.h
+	cp $< $@
+
+# NOTE: This is safe to do at the moment because idl-external and
+# idl-gen are only called from libxl/Makefile:all, which must return
+# before golang/Makefile is callid.  idl-external and idl-gen must
+# never be called from another part of the make system without careful thought
+# about races with tools/golang/xenlight/Makefile:all
+.PHONY: idl-external
+idl-external:
+	$(MAKE) -C $(XEN_ROOT)/tools/golang/xenlight idl-gen
+
+LIBXL_IDLGEN_FILES = include/_libxl_types.h include/_libxl_types_json.h _libxl_types_private.h _libxl_types.c \
+	_libxl_types_internal.h _libxl_types_internal_json.h _libxl_types_internal_private.h _libxl_types_internal.c
+
+idl-gen: $(LIBXL_GEN_FILES) idl-external
+
+libxenlight_test.so: $(PIC_OBJS) $(LIBXL_TEST_OBJS)
+	$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenlight.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LDUSELIBS) $(APPEND_LDFLAGS)
+
+test_%: test_%.o test_common.o libxenlight_test.so
+	$(CC) $(LDFLAGS) -o $@ $^ $(filter-out %libxenlight.so, $(LDLIBS_libxenlight)) $(LDLIBS_libxentoollog) $(LDLIBS_libxentoolcore) -lyajl $(APPEND_LDFLAGS)
+
+libxl-save-helper: $(SAVE_HELPER_OBJS) libxenlight.so
+	$(CC) $(LDFLAGS) -o $@ $(SAVE_HELPER_OBJS) $(LDLIBS_libxentoollog) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxentoolcore) $(APPEND_LDFLAGS)
+
+testidl: testidl.o libxenlight.so
+	$(CC) $(LDFLAGS) -o $@ testidl.o $(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) $(LDLIBS_libxentoolcore) $(APPEND_LDFLAGS)
+
+install: installlocal $(LIBHEADERS)
+
+.PHONY: installlocal
+installlocal: libxl-save-helper
+	$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
+	$(INSTALL_PROG) libxl-save-helper $(DESTDIR)$(LIBEXEC_BIN)
+
+uninstall: uninstalllocal
+
+.PHONY: uninstalllocal
+uninstalllocal:
+	rm -f $(DESTDIR)$(LIBEXEC_BIN)/libxl-save-helper
+
+clean: cleanlocal
+
+.PHONY: cleanlocal
+cleanlocal:
+	$(RM) -f $(LIBXL_IDLGEN_FILES) *.o $(CLIENTS)
+	$(RM) -f *.pyc _paths.*.tmp _*.api-for-check
+	$(RM) -f testidl.c.new testidl.c *.api-ok
+	$(RM) -f $(TEST_PROGS)
+	$(RM) -rf __pycache__
+	$(RM) -f include/_*.h
+	$(RM) -f libxenlight.map
+	$(RM) -f $(AUTOSRCS) $(AUTOINCS)
+	$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) clean
diff --git a/tools/libxl/check-libxl-api-rules b/tools/libs/light/check-libxl-api-rules
similarity index 100%
rename from tools/libxl/check-libxl-api-rules
rename to tools/libs/light/check-libxl-api-rules
diff --git a/tools/libxl/flexarray.c b/tools/libs/light/flexarray.c
similarity index 100%
rename from tools/libxl/flexarray.c
rename to tools/libs/light/flexarray.c
diff --git a/tools/libxl/flexarray.h b/tools/libs/light/flexarray.h
similarity index 100%
rename from tools/libxl/flexarray.h
rename to tools/libs/light/flexarray.h
diff --git a/tools/libxl/gentest.py b/tools/libs/light/gentest.py
similarity index 100%
rename from tools/libxl/gentest.py
rename to tools/libs/light/gentest.py
diff --git a/tools/libxl/gentypes.py b/tools/libs/light/gentypes.py
similarity index 100%
rename from tools/libxl/gentypes.py
rename to tools/libs/light/gentypes.py
diff --git a/tools/libxl/idl.py b/tools/libs/light/idl.py
similarity index 100%
rename from tools/libxl/idl.py
rename to tools/libs/light/idl.py
diff --git a/tools/libxl/idl.txt b/tools/libs/light/idl.txt
similarity index 100%
rename from tools/libxl/idl.txt
rename to tools/libs/light/idl.txt
diff --git a/tools/libxl/libxl.h b/tools/libs/light/include/libxl.h
similarity index 100%
rename from tools/libxl/libxl.h
rename to tools/libs/light/include/libxl.h
diff --git a/tools/libxl/libxl_event.h b/tools/libs/light/include/libxl_event.h
similarity index 100%
rename from tools/libxl/libxl_event.h
rename to tools/libs/light/include/libxl_event.h
diff --git a/tools/libxl/libxl_json.h b/tools/libs/light/include/libxl_json.h
similarity index 100%
rename from tools/libxl/libxl_json.h
rename to tools/libs/light/include/libxl_json.h
diff --git a/tools/libxl/libxl_utils.h b/tools/libs/light/include/libxl_utils.h
similarity index 100%
rename from tools/libxl/libxl_utils.h
rename to tools/libs/light/include/libxl_utils.h
diff --git a/tools/libxl/libxl_uuid.h b/tools/libs/light/include/libxl_uuid.h
similarity index 100%
rename from tools/libxl/libxl_uuid.h
rename to tools/libs/light/include/libxl_uuid.h
diff --git a/tools/libxl/libxl.c b/tools/libs/light/libxl.c
similarity index 100%
rename from tools/libxl/libxl.c
rename to tools/libs/light/libxl.c
diff --git a/tools/libxl/libxl_9pfs.c b/tools/libs/light/libxl_9pfs.c
similarity index 100%
rename from tools/libxl/libxl_9pfs.c
rename to tools/libs/light/libxl_9pfs.c
diff --git a/tools/libxl/libxl_aoutils.c b/tools/libs/light/libxl_aoutils.c
similarity index 100%
rename from tools/libxl/libxl_aoutils.c
rename to tools/libs/light/libxl_aoutils.c
diff --git a/tools/libxl/libxl_arch.h b/tools/libs/light/libxl_arch.h
similarity index 100%
rename from tools/libxl/libxl_arch.h
rename to tools/libs/light/libxl_arch.h
diff --git a/tools/libxl/libxl_arm.c b/tools/libs/light/libxl_arm.c
similarity index 100%
rename from tools/libxl/libxl_arm.c
rename to tools/libs/light/libxl_arm.c
diff --git a/tools/libxl/libxl_arm.h b/tools/libs/light/libxl_arm.h
similarity index 100%
rename from tools/libxl/libxl_arm.h
rename to tools/libs/light/libxl_arm.h
diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libs/light/libxl_arm_acpi.c
similarity index 100%
rename from tools/libxl/libxl_arm_acpi.c
rename to tools/libs/light/libxl_arm_acpi.c
diff --git a/tools/libxl/libxl_arm_no_acpi.c b/tools/libs/light/libxl_arm_no_acpi.c
similarity index 100%
rename from tools/libxl/libxl_arm_no_acpi.c
rename to tools/libs/light/libxl_arm_no_acpi.c
diff --git a/tools/libxl/libxl_bootloader.c b/tools/libs/light/libxl_bootloader.c
similarity index 100%
rename from tools/libxl/libxl_bootloader.c
rename to tools/libs/light/libxl_bootloader.c
diff --git a/tools/libxl/libxl_checkpoint_device.c b/tools/libs/light/libxl_checkpoint_device.c
similarity index 100%
rename from tools/libxl/libxl_checkpoint_device.c
rename to tools/libs/light/libxl_checkpoint_device.c
diff --git a/tools/libxl/libxl_colo.h b/tools/libs/light/libxl_colo.h
similarity index 100%
rename from tools/libxl/libxl_colo.h
rename to tools/libs/light/libxl_colo.h
diff --git a/tools/libxl/libxl_colo_nic.c b/tools/libs/light/libxl_colo_nic.c
similarity index 100%
rename from tools/libxl/libxl_colo_nic.c
rename to tools/libs/light/libxl_colo_nic.c
diff --git a/tools/libxl/libxl_colo_proxy.c b/tools/libs/light/libxl_colo_proxy.c
similarity index 100%
rename from tools/libxl/libxl_colo_proxy.c
rename to tools/libs/light/libxl_colo_proxy.c
diff --git a/tools/libxl/libxl_colo_qdisk.c b/tools/libs/light/libxl_colo_qdisk.c
similarity index 100%
rename from tools/libxl/libxl_colo_qdisk.c
rename to tools/libs/light/libxl_colo_qdisk.c
diff --git a/tools/libxl/libxl_colo_restore.c b/tools/libs/light/libxl_colo_restore.c
similarity index 100%
rename from tools/libxl/libxl_colo_restore.c
rename to tools/libs/light/libxl_colo_restore.c
diff --git a/tools/libxl/libxl_colo_save.c b/tools/libs/light/libxl_colo_save.c
similarity index 100%
rename from tools/libxl/libxl_colo_save.c
rename to tools/libs/light/libxl_colo_save.c
diff --git a/tools/libxl/libxl_console.c b/tools/libs/light/libxl_console.c
similarity index 100%
rename from tools/libxl/libxl_console.c
rename to tools/libs/light/libxl_console.c
diff --git a/tools/libxl/libxl_convert_callout.c b/tools/libs/light/libxl_convert_callout.c
similarity index 100%
rename from tools/libxl/libxl_convert_callout.c
rename to tools/libs/light/libxl_convert_callout.c
diff --git a/tools/libxl/libxl_cpuid.c b/tools/libs/light/libxl_cpuid.c
similarity index 100%
rename from tools/libxl/libxl_cpuid.c
rename to tools/libs/light/libxl_cpuid.c
diff --git a/tools/libxl/libxl_cpupool.c b/tools/libs/light/libxl_cpupool.c
similarity index 100%
rename from tools/libxl/libxl_cpupool.c
rename to tools/libs/light/libxl_cpupool.c
diff --git a/tools/libxl/libxl_create.c b/tools/libs/light/libxl_create.c
similarity index 100%
rename from tools/libxl/libxl_create.c
rename to tools/libs/light/libxl_create.c
diff --git a/tools/libxl/libxl_device.c b/tools/libs/light/libxl_device.c
similarity index 100%
rename from tools/libxl/libxl_device.c
rename to tools/libs/light/libxl_device.c
diff --git a/tools/libxl/libxl_disk.c b/tools/libs/light/libxl_disk.c
similarity index 100%
rename from tools/libxl/libxl_disk.c
rename to tools/libs/light/libxl_disk.c
diff --git a/tools/libxl/libxl_dm.c b/tools/libs/light/libxl_dm.c
similarity index 100%
rename from tools/libxl/libxl_dm.c
rename to tools/libs/light/libxl_dm.c
diff --git a/tools/libxl/libxl_dom.c b/tools/libs/light/libxl_dom.c
similarity index 100%
rename from tools/libxl/libxl_dom.c
rename to tools/libs/light/libxl_dom.c
diff --git a/tools/libxl/libxl_dom_save.c b/tools/libs/light/libxl_dom_save.c
similarity index 100%
rename from tools/libxl/libxl_dom_save.c
rename to tools/libs/light/libxl_dom_save.c
diff --git a/tools/libxl/libxl_dom_suspend.c b/tools/libs/light/libxl_dom_suspend.c
similarity index 100%
rename from tools/libxl/libxl_dom_suspend.c
rename to tools/libs/light/libxl_dom_suspend.c
diff --git a/tools/libxl/libxl_domain.c b/tools/libs/light/libxl_domain.c
similarity index 100%
rename from tools/libxl/libxl_domain.c
rename to tools/libs/light/libxl_domain.c
diff --git a/tools/libxl/libxl_event.c b/tools/libs/light/libxl_event.c
similarity index 100%
rename from tools/libxl/libxl_event.c
rename to tools/libs/light/libxl_event.c
diff --git a/tools/libxl/libxl_exec.c b/tools/libs/light/libxl_exec.c
similarity index 100%
rename from tools/libxl/libxl_exec.c
rename to tools/libs/light/libxl_exec.c
diff --git a/tools/libxl/libxl_flask.c b/tools/libs/light/libxl_flask.c
similarity index 100%
rename from tools/libxl/libxl_flask.c
rename to tools/libs/light/libxl_flask.c
diff --git a/tools/libxl/libxl_fork.c b/tools/libs/light/libxl_fork.c
similarity index 100%
rename from tools/libxl/libxl_fork.c
rename to tools/libs/light/libxl_fork.c
diff --git a/tools/libxl/libxl_freebsd.c b/tools/libs/light/libxl_freebsd.c
similarity index 100%
rename from tools/libxl/libxl_freebsd.c
rename to tools/libs/light/libxl_freebsd.c
diff --git a/tools/libxl/libxl_genid.c b/tools/libs/light/libxl_genid.c
similarity index 100%
rename from tools/libxl/libxl_genid.c
rename to tools/libs/light/libxl_genid.c
diff --git a/tools/libxl/libxl_internal.c b/tools/libs/light/libxl_internal.c
similarity index 100%
rename from tools/libxl/libxl_internal.c
rename to tools/libs/light/libxl_internal.c
diff --git a/tools/libxl/libxl_internal.h b/tools/libs/light/libxl_internal.h
similarity index 100%
rename from tools/libxl/libxl_internal.h
rename to tools/libs/light/libxl_internal.h
diff --git a/tools/libxl/libxl_json.c b/tools/libs/light/libxl_json.c
similarity index 100%
rename from tools/libxl/libxl_json.c
rename to tools/libs/light/libxl_json.c
diff --git a/tools/libxl/libxl_libfdt_compat.c b/tools/libs/light/libxl_libfdt_compat.c
similarity index 100%
rename from tools/libxl/libxl_libfdt_compat.c
rename to tools/libs/light/libxl_libfdt_compat.c
diff --git a/tools/libxl/libxl_libfdt_compat.h b/tools/libs/light/libxl_libfdt_compat.h
similarity index 100%
rename from tools/libxl/libxl_libfdt_compat.h
rename to tools/libs/light/libxl_libfdt_compat.h
diff --git a/tools/libxl/libxl_linux.c b/tools/libs/light/libxl_linux.c
similarity index 100%
rename from tools/libxl/libxl_linux.c
rename to tools/libs/light/libxl_linux.c
diff --git a/tools/libxl/libxl_mem.c b/tools/libs/light/libxl_mem.c
similarity index 100%
rename from tools/libxl/libxl_mem.c
rename to tools/libs/light/libxl_mem.c
diff --git a/tools/libxl/libxl_netbsd.c b/tools/libs/light/libxl_netbsd.c
similarity index 100%
rename from tools/libxl/libxl_netbsd.c
rename to tools/libs/light/libxl_netbsd.c
diff --git a/tools/libxl/libxl_netbuffer.c b/tools/libs/light/libxl_netbuffer.c
similarity index 100%
rename from tools/libxl/libxl_netbuffer.c
rename to tools/libs/light/libxl_netbuffer.c
diff --git a/tools/libxl/libxl_nic.c b/tools/libs/light/libxl_nic.c
similarity index 100%
rename from tools/libxl/libxl_nic.c
rename to tools/libs/light/libxl_nic.c
diff --git a/tools/libxl/libxl_no_colo.c b/tools/libs/light/libxl_no_colo.c
similarity index 100%
rename from tools/libxl/libxl_no_colo.c
rename to tools/libs/light/libxl_no_colo.c
diff --git a/tools/libxl/libxl_no_convert_callout.c b/tools/libs/light/libxl_no_convert_callout.c
similarity index 100%
rename from tools/libxl/libxl_no_convert_callout.c
rename to tools/libs/light/libxl_no_convert_callout.c
diff --git a/tools/libxl/libxl_nocpuid.c b/tools/libs/light/libxl_nocpuid.c
similarity index 100%
rename from tools/libxl/libxl_nocpuid.c
rename to tools/libs/light/libxl_nocpuid.c
diff --git a/tools/libxl/libxl_nonetbuffer.c b/tools/libs/light/libxl_nonetbuffer.c
similarity index 100%
rename from tools/libxl/libxl_nonetbuffer.c
rename to tools/libs/light/libxl_nonetbuffer.c
diff --git a/tools/libxl/libxl_numa.c b/tools/libs/light/libxl_numa.c
similarity index 100%
rename from tools/libxl/libxl_numa.c
rename to tools/libs/light/libxl_numa.c
diff --git a/tools/libxl/libxl_osdeps.h b/tools/libs/light/libxl_osdeps.h
similarity index 100%
rename from tools/libxl/libxl_osdeps.h
rename to tools/libs/light/libxl_osdeps.h
diff --git a/tools/libxl/libxl_paths.c b/tools/libs/light/libxl_paths.c
similarity index 100%
rename from tools/libxl/libxl_paths.c
rename to tools/libs/light/libxl_paths.c
diff --git a/tools/libxl/libxl_pci.c b/tools/libs/light/libxl_pci.c
similarity index 100%
rename from tools/libxl/libxl_pci.c
rename to tools/libs/light/libxl_pci.c
diff --git a/tools/libxl/libxl_psr.c b/tools/libs/light/libxl_psr.c
similarity index 100%
rename from tools/libxl/libxl_psr.c
rename to tools/libs/light/libxl_psr.c
diff --git a/tools/libxl/libxl_pvcalls.c b/tools/libs/light/libxl_pvcalls.c
similarity index 100%
rename from tools/libxl/libxl_pvcalls.c
rename to tools/libs/light/libxl_pvcalls.c
diff --git a/tools/libxl/libxl_qmp.c b/tools/libs/light/libxl_qmp.c
similarity index 100%
rename from tools/libxl/libxl_qmp.c
rename to tools/libs/light/libxl_qmp.c
diff --git a/tools/libxl/libxl_remus.c b/tools/libs/light/libxl_remus.c
similarity index 100%
rename from tools/libxl/libxl_remus.c
rename to tools/libs/light/libxl_remus.c
diff --git a/tools/libxl/libxl_remus_disk_drbd.c b/tools/libs/light/libxl_remus_disk_drbd.c
similarity index 100%
rename from tools/libxl/libxl_remus_disk_drbd.c
rename to tools/libs/light/libxl_remus_disk_drbd.c
diff --git a/tools/libxl/libxl_save_callout.c b/tools/libs/light/libxl_save_callout.c
similarity index 100%
rename from tools/libxl/libxl_save_callout.c
rename to tools/libs/light/libxl_save_callout.c
diff --git a/tools/libxl/libxl_save_helper.c b/tools/libs/light/libxl_save_helper.c
similarity index 100%
rename from tools/libxl/libxl_save_helper.c
rename to tools/libs/light/libxl_save_helper.c
diff --git a/tools/libxl/libxl_save_msgs_gen.pl b/tools/libs/light/libxl_save_msgs_gen.pl
similarity index 100%
rename from tools/libxl/libxl_save_msgs_gen.pl
rename to tools/libs/light/libxl_save_msgs_gen.pl
diff --git a/tools/libxl/libxl_sched.c b/tools/libs/light/libxl_sched.c
similarity index 100%
rename from tools/libxl/libxl_sched.c
rename to tools/libs/light/libxl_sched.c
diff --git a/tools/libxl/libxl_sr_stream_format.h b/tools/libs/light/libxl_sr_stream_format.h
similarity index 100%
rename from tools/libxl/libxl_sr_stream_format.h
rename to tools/libs/light/libxl_sr_stream_format.h
diff --git a/tools/libxl/libxl_stream_read.c b/tools/libs/light/libxl_stream_read.c
similarity index 100%
rename from tools/libxl/libxl_stream_read.c
rename to tools/libs/light/libxl_stream_read.c
diff --git a/tools/libxl/libxl_stream_write.c b/tools/libs/light/libxl_stream_write.c
similarity index 100%
rename from tools/libxl/libxl_stream_write.c
rename to tools/libs/light/libxl_stream_write.c
diff --git a/tools/libxl/libxl_test_fdevent.c b/tools/libs/light/libxl_test_fdevent.c
similarity index 100%
rename from tools/libxl/libxl_test_fdevent.c
rename to tools/libs/light/libxl_test_fdevent.c
diff --git a/tools/libxl/libxl_test_fdevent.h b/tools/libs/light/libxl_test_fdevent.h
similarity index 100%
rename from tools/libxl/libxl_test_fdevent.h
rename to tools/libs/light/libxl_test_fdevent.h
diff --git a/tools/libxl/libxl_test_timedereg.c b/tools/libs/light/libxl_test_timedereg.c
similarity index 100%
rename from tools/libxl/libxl_test_timedereg.c
rename to tools/libs/light/libxl_test_timedereg.c
diff --git a/tools/libxl/libxl_test_timedereg.h b/tools/libs/light/libxl_test_timedereg.h
similarity index 100%
rename from tools/libxl/libxl_test_timedereg.h
rename to tools/libs/light/libxl_test_timedereg.h
diff --git a/tools/libxl/libxl_tmem.c b/tools/libs/light/libxl_tmem.c
similarity index 100%
rename from tools/libxl/libxl_tmem.c
rename to tools/libs/light/libxl_tmem.c
diff --git a/tools/libxl/libxl_types.idl b/tools/libs/light/libxl_types.idl
similarity index 100%
rename from tools/libxl/libxl_types.idl
rename to tools/libs/light/libxl_types.idl
diff --git a/tools/libxl/libxl_types_internal.idl b/tools/libs/light/libxl_types_internal.idl
similarity index 100%
rename from tools/libxl/libxl_types_internal.idl
rename to tools/libs/light/libxl_types_internal.idl
diff --git a/tools/libxl/libxl_usb.c b/tools/libs/light/libxl_usb.c
similarity index 100%
rename from tools/libxl/libxl_usb.c
rename to tools/libs/light/libxl_usb.c
diff --git a/tools/libxl/libxl_utils.c b/tools/libs/light/libxl_utils.c
similarity index 100%
rename from tools/libxl/libxl_utils.c
rename to tools/libs/light/libxl_utils.c
diff --git a/tools/libxl/libxl_uuid.c b/tools/libs/light/libxl_uuid.c
similarity index 100%
rename from tools/libxl/libxl_uuid.c
rename to tools/libs/light/libxl_uuid.c
diff --git a/tools/libxl/libxl_vdispl.c b/tools/libs/light/libxl_vdispl.c
similarity index 100%
rename from tools/libxl/libxl_vdispl.c
rename to tools/libs/light/libxl_vdispl.c
diff --git a/tools/libxl/libxl_vkb.c b/tools/libs/light/libxl_vkb.c
similarity index 100%
rename from tools/libxl/libxl_vkb.c
rename to tools/libs/light/libxl_vkb.c
diff --git a/tools/libxl/libxl_vnuma.c b/tools/libs/light/libxl_vnuma.c
similarity index 100%
rename from tools/libxl/libxl_vnuma.c
rename to tools/libs/light/libxl_vnuma.c
diff --git a/tools/libxl/libxl_vsnd.c b/tools/libs/light/libxl_vsnd.c
similarity index 100%
rename from tools/libxl/libxl_vsnd.c
rename to tools/libs/light/libxl_vsnd.c
diff --git a/tools/libxl/libxl_vtpm.c b/tools/libs/light/libxl_vtpm.c
similarity index 100%
rename from tools/libxl/libxl_vtpm.c
rename to tools/libs/light/libxl_vtpm.c
diff --git a/tools/libxl/libxl_x86.c b/tools/libs/light/libxl_x86.c
similarity index 100%
rename from tools/libxl/libxl_x86.c
rename to tools/libs/light/libxl_x86.c
diff --git a/tools/libxl/libxl_x86_acpi.c b/tools/libs/light/libxl_x86_acpi.c
similarity index 100%
rename from tools/libxl/libxl_x86_acpi.c
rename to tools/libs/light/libxl_x86_acpi.c
diff --git a/tools/libxl/libxl_x86_acpi.h b/tools/libs/light/libxl_x86_acpi.h
similarity index 100%
rename from tools/libxl/libxl_x86_acpi.h
rename to tools/libs/light/libxl_x86_acpi.h
diff --git a/tools/libxl/libxl_xshelp.c b/tools/libs/light/libxl_xshelp.c
similarity index 100%
rename from tools/libxl/libxl_xshelp.c
rename to tools/libs/light/libxl_xshelp.c
diff --git a/tools/libxl/osdeps.c b/tools/libs/light/osdeps.c
similarity index 100%
rename from tools/libxl/osdeps.c
rename to tools/libs/light/osdeps.c
diff --git a/tools/libxl/test_common.c b/tools/libs/light/test_common.c
similarity index 100%
rename from tools/libxl/test_common.c
rename to tools/libs/light/test_common.c
diff --git a/tools/libxl/test_common.h b/tools/libs/light/test_common.h
similarity index 100%
rename from tools/libxl/test_common.h
rename to tools/libs/light/test_common.h
diff --git a/tools/libxl/test_fdderegrace.c b/tools/libs/light/test_fdderegrace.c
similarity index 100%
rename from tools/libxl/test_fdderegrace.c
rename to tools/libs/light/test_fdderegrace.c
diff --git a/tools/libxl/test_timedereg.c b/tools/libs/light/test_timedereg.c
similarity index 100%
rename from tools/libxl/test_timedereg.c
rename to tools/libs/light/test_timedereg.c
diff --git a/tools/libs/uselibs.mk b/tools/libs/uselibs.mk
index a9dc2ce994..685f368aed 100644
--- a/tools/libs/uselibs.mk
+++ b/tools/libs/uselibs.mk
@@ -26,3 +26,5 @@ LIBS_LIBS += vchan
 USELIBS_vchan := toollog store gnttab evtchn
 LIBS_LIBS += stat
 USELIBS_stat := ctrl store
+LIBS_LIBS += light
+USELIBS_light := toollog evtchn toolcore ctrl store hypfs guest
diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 3cc868d9e9..8ab7c9d3f0 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -5,9 +5,6 @@
 XEN_ROOT = $(CURDIR)/../..
 include $(XEN_ROOT)/tools/Rules.mk
 
-MAJOR = 4.15
-MINOR = 0
-
 XLUMAJOR = 4.15
 XLUMINOR = 0
 
@@ -15,107 +12,11 @@ CFLAGS += -Werror -Wno-format-zero-length -Wmissing-declarations \
 	-Wno-declaration-after-statement -Wformat-nonliteral
 CFLAGS += -I. -fPIC
 
-ifeq ($(CONFIG_Linux),y)
-LIBUUID_LIBS += -luuid
-endif
-
-LIBXL_LIBS =
-LIBXL_LIBS = $(LDLIBS_libxentoollog) $(LDLIBS_libxenevtchn) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenhypfs) $(LDLIBS_libxenstore) $(LDLIBS_libxentoolcore) $(PTYFUNCS_LIBS) $(LIBUUID_LIBS)
-ifeq ($(CONFIG_LIBNL),y)
-LIBXL_LIBS += $(LIBNL3_LIBS)
-endif
-ifeq ($(CONFIG_Linux),y)
-LIBXL_LIBS += -lrt
-endif
-
-CFLAGS_LIBXL += $(CFLAGS_libxentoollog)
-CFLAGS_LIBXL += $(CFLAGS_libxentoolcore)
-CFLAGS_LIBXL += $(CFLAGS_libxenevtchn)
-CFLAGS_LIBXL += $(CFLAGS_libxenctrl)
-CFLAGS_LIBXL += $(CFLAGS_libxenguest)
-CFLAGS_LIBXL += $(CFLAGS_libxenhypfs)
-CFLAGS_LIBXL += $(CFLAGS_libxenstore)
-ifeq ($(CONFIG_LIBNL),y)
-CFLAGS_LIBXL += $(LIBNL3_CFLAGS)
-endif
-CFLAGS_LIBXL += -Wshadow
-ifeq ($(debug),y)
-CFLAGS_LIBXL += -DCONFIG_DEBUG
-endif
-
-LIBXL_LIBS-$(CONFIG_ARM) += -lfdt
-
 CFLAGS += $(PTHREAD_CFLAGS)
 LDFLAGS += $(PTHREAD_LDFLAGS)
-LIBXL_LIBS += $(PTHREAD_LIBS)
-LIBXL_LIBS += $(LIBXL_LIBS-y)
 
 LIBXLU_LIBS = $(LDLIBS_libxenlight)
 
-LIBXL_OBJS-y = osdeps.o libxl_paths.o libxl_bootloader.o flexarray.o
-
-ifeq ($(CONFIG_LIBNL),y)
-LIBXL_OBJS-y += libxl_netbuffer.o
-else
-LIBXL_OBJS-y += libxl_nonetbuffer.o
-endif
-
-ifeq ($(CONFIG_X86),y)
-LIBXL_OBJS-y += libxl_convert_callout.o
-else
-LIBXL_OBJS-y += libxl_no_convert_callout.o
-endif
-
-LIBXL_OBJS-y += libxl_remus.o libxl_checkpoint_device.o libxl_remus_disk_drbd.o
-
-ifeq ($(CONFIG_LIBNL),y)
-LIBXL_OBJS-y += libxl_colo_restore.o libxl_colo_save.o
-LIBXL_OBJS-y += libxl_colo_qdisk.o
-LIBXL_OBJS-y += libxl_colo_proxy.o
-LIBXL_OBJS-y += libxl_colo_nic.o
-else
-LIBXL_OBJS-y += libxl_no_colo.o
-endif
-
-ACPI_PATH  = $(XEN_ROOT)/tools/libacpi
-DSDT_FILES-$(CONFIG_X86) = dsdt_pvh.c
-ACPI_OBJS  = $(patsubst %.c,%.o,$(DSDT_FILES-y)) build.o static_tables.o
-$(DSDT_FILES-y): acpi
-$(ACPI_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"$(CURDIR)/libxl_x86_acpi.h\"
-vpath build.c $(ACPI_PATH)/
-vpath static_tables.c $(ACPI_PATH)/
-LIBXL_OBJS-$(CONFIG_X86) += $(ACPI_OBJS)
-
-.PHONY: acpi
-acpi:
-	$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) DSDT_FILES="$(DSDT_FILES-y)"
-
-LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o libxl_x86_acpi.o
-LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o
-ifeq ($(CONFIG_ARM_64),y)
-DSDT_FILES-y = dsdt_anycpu_arm.c
-LIBXL_OBJS-y += libxl_arm_acpi.o $(patsubst %.c,%.o,$(DSDT_FILES-y))
-dsdt_anycpu_arm.c:
-	$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) DSDT_FILES="$(DSDT_FILES-y)"
-else
-LIBXL_OBJS-$(CONFIG_ARM) += libxl_arm_no_acpi.o
-endif
-
-ifeq ($(CONFIG_NetBSD),y)
-LIBXL_OBJS-y += libxl_netbsd.o
-else
-ifeq ($(CONFIG_Linux),y)
-LIBXL_OBJS-y += libxl_linux.o
-else
-ifeq ($(CONFIG_FreeBSD),y)
-LIBXL_OBJS-y += libxl_freebsd.o
-else
-$(error Your Operating System is not supported by libxenlight, \
-please check libxl_linux.c and libxl_netbsd.c to see how to get it ported)
-endif
-endif
-endif
-
 ifeq ($(FLEX),)
 %.c %.h:: %.l
 	$(warning Flex is needed to rebuild some libxl parsers and \
@@ -128,80 +29,16 @@ ifeq ($(BISON),)
 		  scanners, please install it an rerun configure)
 endif
 
-LIBXL_LIBS += -lyajl
-
-LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \
-			libxl_dom.o libxl_exec.o libxl_xshelp.o libxl_device.o \
-			libxl_internal.o libxl_utils.o libxl_uuid.o \
-			libxl_json.o libxl_aoutils.o libxl_numa.o libxl_vnuma.o \
-			libxl_stream_read.o libxl_stream_write.o \
-			libxl_save_callout.o _libxl_save_msgs_callout.o \
-			libxl_qmp.o libxl_event.o libxl_fork.o \
-			libxl_dom_suspend.o libxl_dom_save.o libxl_usb.o \
-			libxl_vtpm.o libxl_nic.o libxl_disk.o libxl_console.o \
-			libxl_cpupool.o libxl_mem.o libxl_sched.o libxl_tmem.o \
-			libxl_9pfs.o libxl_domain.o libxl_vdispl.o \
-			libxl_pvcalls.o libxl_vsnd.o libxl_vkb.o $(LIBXL_OBJS-y)
-LIBXL_OBJS += libxl_genid.o
-LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
-
-LIBXL_TESTS += timedereg
-LIBXL_TESTS_PROGS = $(LIBXL_TESTS) fdderegrace
-LIBXL_TESTS_INSIDE = $(LIBXL_TESTS) fdevent
-
-# Each entry FOO in LIBXL_TESTS has two main .c files:
-#   libxl_test_FOO.c  "inside libxl" code to support the test case
-#   test_FOO.c        "outside libxl" code to exercise the test case
-# Conventionally there will also be:
-#   libxl_test_FOO.h  interface between the "inside" and "outside" parts
-# The "inside libxl" file is compiled exactly like a piece of libxl, and the
-# "outside libxl" file is compiled exactly like a piece of application
-# code.  They must share information via explicit libxl entrypoints.
-# Unlike proper parts of libxl, it is permissible for libxl_test_FOO.c
-# to use private global variables for its state.  Note that all the
-# "inside" parts are compiled into a single test library, so their
-# symbol names must be unique.
-#
-# To run these tests, either use LD_PRELOAD to get libxenlight_test.so
-# loaded, or rename it to libxenlight.so so it is the target of the
-# appropriate symlinks.
-
-LIBXL_TEST_OBJS += $(foreach t, $(LIBXL_TESTS_INSIDE),libxl_test_$t.o)
-TEST_PROG_OBJS += $(foreach t, $(LIBXL_TESTS_PROGS),test_$t.o) test_common.o
-TEST_PROGS += $(foreach t, $(LIBXL_TESTS_PROGS),test_$t)
-
-$(LIBXL_OBJS) $(LIBXL_TEST_OBJS): CFLAGS += $(CFLAGS_LIBXL) -include $(XEN_ROOT)/tools/config.h
-
-AUTOINCS= libxlu_cfg_y.h libxlu_cfg_l.h _libxl_list.h _paths.h \
-	libxlu_disk_l.h _libxl_save_msgs_callout.h _libxl_save_msgs_helper.h
+AUTOINCS= libxlu_cfg_y.h libxlu_cfg_l.h libxlu_disk_l.h
 AUTOSRCS= libxlu_cfg_y.c libxlu_cfg_l.c
-AUTOSRCS += _libxl_save_msgs_callout.c _libxl_save_msgs_helper.c
 LIBXLU_OBJS = libxlu_cfg_y.o libxlu_cfg_l.o libxlu_cfg.o \
 	libxlu_disk_l.o libxlu_disk.o libxlu_vif.o libxlu_pci.o
 $(LIBXLU_OBJS): CFLAGS += $(CFLAGS_libxenctrl) # For xentoollog.h
 
-$(TEST_PROG_OBJS) _libxl.api-for-check: CFLAGS += $(CFLAGS_libxentoollog) $(CFLAGS_libxentoolcore)
-
-CLIENTS = testidl libxl-save-helper
-
-libxl_dom.o: CFLAGS += -I$(XEN_ROOT)/tools  # include libacpi/x86.h
-libxl_x86_acpi.o: CFLAGS += -I$(XEN_ROOT)/tools
-
-SAVE_HELPER_OBJS = libxl_save_helper.o _libxl_save_msgs_helper.o
-$(SAVE_HELPER_OBJS): CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenevtchn) $(CFLAGS_libxenguest)
-
-PKG_CONFIG = xenlight.pc xlutil.pc
-PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
+PKG_CONFIG = xlutil.pc
 
 ifneq ($(CONFIG_LIBXC_MINIOS),y)
 PKG_CONFIG_INST := $(PKG_CONFIG)
-xenlight.pc: PKG_CONFIG_NAME = Xenlight
-xenlight.pc: PKG_CONFIG_DESC = The Xenlight library for Xen hypervisor
-xenlight.pc: PKG_CONFIG_VERSION = $(MAJOR).$(MINOR)
-xenlight.pc: PKG_CONFIG_VARS = xenfirmwaredir=$(XENFIRMWAREDIR) libexec_bin=$(LIBEXEC_BIN)
-xenlight.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenlight)
-xenlight.pc: PKG_CONFIG_LIB = xenlight
-xenlight.pc: PKG_CONFIG_REQPRIV = xentoollog,xenevtchn,xencontrol,xenguest,xenstore,xenhypfs
 xlutil.pc: PKG_CONFIG_NAME = Xlutil
 xlutil.pc: PKG_CONFIG_DESC = The xl utility library for Xen hypervisor
 xlutil.pc: PKG_CONFIG_VERSION = $(XLUMAJOR).$(XLUMINOR)
@@ -215,13 +52,6 @@ endif
 
 PKG_CONFIG_LOCAL := $(foreach pc,$(PKG_CONFIG),$(PKG_CONFIG_DIR)/$(pc))
 
-$(PKG_CONFIG_DIR)/xenlight.pc: PKG_CONFIG_NAME = Xenlight
-$(PKG_CONFIG_DIR)/xenlight.pc: PKG_CONFIG_DESC = The Xenlight library for Xen hypervisor
-$(PKG_CONFIG_DIR)/xenlight.pc: PKG_CONFIG_VERSION = $(MAJOR).$(MINOR)
-$(PKG_CONFIG_DIR)/xenlight.pc: PKG_CONFIG_VARS = xenfirmwaredir=$(XENFIRMWAREDIR) libexec_bin=$(LIBEXEC_BIN)
-$(PKG_CONFIG_DIR)/xenlight.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenlight)
-$(PKG_CONFIG_DIR)/xenlight.pc: PKG_CONFIG_LIB = xenlight
-$(PKG_CONFIG_DIR)/xenlight.pc: PKG_CONFIG_REQPRIV = xentoollog,xenevtchn,xencontrol,xenguest,xenstore,xenhypfs
 $(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_NAME = Xlutil
 $(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_DESC = The xl utility library for Xen hypervisor
 $(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_VERSION = $(XLUMAJOR).$(XLUMINOR)
@@ -233,19 +63,10 @@ $(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(CURDIR)
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL = $(CFLAGS_xeninclude)
 
-testidl.o: CFLAGS += $(CFLAGS_libxenctrl) $(CFLAGS_libxenlight)
-testidl.c: libxl_types.idl gentest.py libxl.h $(AUTOINCS)
-	$(PYTHON) gentest.py libxl_types.idl testidl.c.new
-	mv testidl.c.new testidl.c
-
 .PHONY: all
-all: $(CLIENTS) $(TEST_PROGS) $(PKG_CONFIG) $(PKG_CONFIG_LOCAL) \
-		libxenlight.so libxenlight.a libxlutil.so libxlutil.a \
-	$(AUTOSRCS) $(AUTOINCS) idl-external
+all: libxlutil.so libxlutil.a $(AUTOSRCS) $(AUTOINCS) $(PKG_CONFIG) $(PKG_CONFIG_LOCAL)
 
-$(LIBXL_OBJS) $(LIBXLU_OBJS) $(SAVE_HELPER_OBJS) \
-		$(LIBXL_TEST_OBJS) $(TEST_PROG_OBJS): \
-	$(AUTOINCS) libxl.api-ok
+$(LIBXLU_OBJS): $(AUTOINCS)
 
 %.c %.h:: %.y
 	@rm -f $*.[ch]
@@ -258,138 +79,42 @@ $(LIBXL_OBJS) $(LIBXLU_OBJS) $(SAVE_HELPER_OBJS) \
 genpath-target = $(call buildmakevars2header,_paths.h)
 $(eval $(genpath-target))
 
-libxl.api-ok: check-libxl-api-rules _libxl.api-for-check
-	$(PERL) $^
-	touch $@
-
-_%.api-for-check: %.h $(AUTOINCS)
-	$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_$*.o) -c -E $< $(APPEND_CFLAGS) \
-		-DLIBXL_EXTERNAL_CALLERS_ONLY=LIBXL_EXTERNAL_CALLERS_ONLY \
-		>$@.new
-	mv -f $@.new $@
-
-_libxl_list.h: $(XEN_INCLUDE)/xen-external/bsd-sys-queue-h-seddery $(XEN_INCLUDE)/xen-external/bsd-sys-queue.h
-	$(PERL) $^ --prefix=libxl >$@.new
-	$(call move-if-changed,$@.new,$@)
-
-_libxl_save_msgs_helper.c _libxl_save_msgs_callout.c \
-_libxl_save_msgs_helper.h _libxl_save_msgs_callout.h: \
-		libxl_save_msgs_gen.pl
-	$(PERL) -w $< $@ >$@.new
-	$(call move-if-changed,$@.new,$@)
-
-libxl.h: _libxl_types.h _libxl_list.h
-libxl_json.h: _libxl_types_json.h
-libxl_internal.h: _libxl_types_internal.h _libxl_types_private.h _libxl_types_internal_private.h _paths.h
-libxl_internal_json.h: _libxl_types_internal_json.h
-xl.h: _paths.h
-
-$(LIBXL_OBJS) $(LIBXL_TEST_OBJS) $(LIBXLU_OBJS) \
-	$(TEST_PROG_OBJS) $(SAVE_HELPER_OBJS): libxl.h
-$(LIBXL_OBJS) $(LIBXL_TEST_OBJS): libxl_internal.h
-
-_libxl_type%.h _libxl_type%_json.h _libxl_type%_private.h _libxl_type%.c: libxl_type%.idl gentypes.py idl.py
-	$(eval stem = $(notdir $*))
-	$(PYTHON) gentypes.py libxl_type$(stem).idl __libxl_type$(stem).h __libxl_type$(stem)_private.h \
-		__libxl_type$(stem)_json.h  __libxl_type$(stem).c
-	$(call move-if-changed,__libxl_type$(stem).h,_libxl_type$(stem).h)
-	$(call move-if-changed,__libxl_type$(stem)_private.h,_libxl_type$(stem)_private.h)
-	$(call move-if-changed,__libxl_type$(stem)_json.h,_libxl_type$(stem)_json.h)
-	$(call move-if-changed,__libxl_type$(stem).c,_libxl_type$(stem).c)
-
-# NOTE: This is safe to do at the moment because idl-external and
-# idl-gen are only called from libxl/Makefile:all, which must return
-# before golang/Makefile is callid.  idl-external and idl-gen must
-# never be called from another part of the make system without careful thought
-# about races with tools/golang/xenlight/Makefile:all
-.PHONY: idl-external
-idl-external:
-	$(MAKE) -C $(XEN_ROOT)/tools/golang/xenlight idl-gen
-
-LIBXL_IDLGEN_FILES = _libxl_types.h _libxl_types_json.h _libxl_types_private.h _libxl_types.c \
-	_libxl_types_internal.h _libxl_types_internal_json.h _libxl_types_internal_private.h _libxl_types_internal.c
-
-
-idl-gen: $(LIBXL_GEN_FILES) idl-external
-
-libxenlight.so: libxenlight.so.$(MAJOR)
-	$(SYMLINK_SHLIB) $< $@
-
-libxenlight.so.$(MAJOR): libxenlight.so.$(MAJOR).$(MINOR)
-	$(SYMLINK_SHLIB) $< $@
-
-libxenlight.so.$(MAJOR).$(MINOR): $(LIBXL_OBJS)
-	$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenlight.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LIBXL_LIBS) $(APPEND_LDFLAGS)
-
-libxenlight_test.so: $(LIBXL_OBJS) $(LIBXL_TEST_OBJS)
-	$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxenlight.so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $^ $(LIBXL_LIBS) $(APPEND_LDFLAGS)
-
-libxenlight.a: $(LIBXL_OBJS)
-	$(AR) rcs libxenlight.a $^
-
 libxlutil.so: libxlutil.so.$(XLUMAJOR)
 	$(SYMLINK_SHLIB) $< $@
 
 libxlutil.so.$(XLUMAJOR): libxlutil.so.$(XLUMAJOR).$(XLUMINOR)
 	$(SYMLINK_SHLIB) $< $@
 
-libxlutil.so.$(XLUMAJOR).$(XLUMINOR): $(LIBXLU_OBJS) libxenlight.so
+libxlutil.so.$(XLUMAJOR).$(XLUMINOR): $(LIBXLU_OBJS)
 	$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxlutil.so.$(XLUMAJOR) $(SHLIB_LDFLAGS) -o $@ $(LIBXLU_OBJS) $(LIBXLU_LIBS) $(APPEND_LDFLAGS)
 
 libxlutil.a: $(LIBXLU_OBJS)
 	$(AR) rcs libxlutil.a $^
 
-test_%: test_%.o test_common.o libxenlight_test.so
-	$(CC) $(LDFLAGS) -o $@ $^ $(filter-out %libxenlight.so, $(LDLIBS_libxenlight)) $(LDLIBS_libxentoollog) $(LDLIBS_libxentoolcore) -lyajl $(APPEND_LDFLAGS)
-
-libxl-save-helper: $(SAVE_HELPER_OBJS) libxenlight.so
-	$(CC) $(LDFLAGS) -o $@ $(SAVE_HELPER_OBJS) $(LDLIBS_libxentoollog) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxentoolcore) $(APPEND_LDFLAGS)
-
-testidl: testidl.o libxenlight.so
-	$(CC) $(LDFLAGS) -o $@ testidl.o $(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) $(LDLIBS_libxentoolcore) $(APPEND_LDFLAGS)
-
 .PHONY: install
 install: all
 	$(INSTALL_DIR) $(DESTDIR)$(libdir)
 	$(INSTALL_DIR) $(DESTDIR)$(includedir)
-	$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
-	$(INSTALL_PROG) libxl-save-helper $(DESTDIR)$(LIBEXEC_BIN)
-	$(INSTALL_SHLIB) libxenlight.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)
-	$(SYMLINK_SHLIB) libxenlight.so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxenlight.so.$(MAJOR)
-	$(SYMLINK_SHLIB) libxenlight.so.$(MAJOR) $(DESTDIR)$(libdir)/libxenlight.so
-	$(INSTALL_DATA) libxenlight.a $(DESTDIR)$(libdir)
 	$(INSTALL_SHLIB) libxlutil.so.$(XLUMAJOR).$(XLUMINOR) $(DESTDIR)$(libdir)
 	$(SYMLINK_SHLIB) libxlutil.so.$(XLUMAJOR).$(XLUMINOR) $(DESTDIR)$(libdir)/libxlutil.so.$(XLUMAJOR)
 	$(SYMLINK_SHLIB) libxlutil.so.$(XLUMAJOR) $(DESTDIR)$(libdir)/libxlutil.so
 	$(INSTALL_DATA) libxlutil.a $(DESTDIR)$(libdir)
-	$(INSTALL_DATA) libxl.h libxl_event.h libxl_json.h _libxl_types.h _libxl_types_json.h _libxl_list.h libxl_utils.h libxl_uuid.h libxlutil.h $(DESTDIR)$(includedir)
-	$(INSTALL_DATA) xenlight.pc $(DESTDIR)$(PKG_INSTALLDIR)
+	$(INSTALL_DATA) libxlutil.h $(DESTDIR)$(includedir)
 	$(INSTALL_DATA) xlutil.pc $(DESTDIR)$(PKG_INSTALLDIR)
 
 .PHONY: uninstall
 uninstall:
-	rm -f $(addprefix $(DESTDIR)$(PKG_INSTALLDIR)/,xlutil.pc xenlight.pc)
-	rm -f $(addprefix $(DESTDIR)$(includedir)/,libxl.h libxl_event.h libxl_json.h _libxl_types.h _libxl_types_json.h _libxl_list.h libxl_utils.h libxl_uuid.h libxlutil.h)
+	rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xlutil.pc
+	rm -f $(DESTDIR)$(includedir)/libxlutil.h
 	rm -f $(DESTDIR)$(libdir)/libxlutil.a
 	rm -f $(DESTDIR)$(libdir)/libxlutil.so
 	rm -f $(DESTDIR)$(libdir)/libxlutil.so.$(XLUMAJOR)
 	rm -f $(DESTDIR)$(libdir)/libxlutil.so.$(XLUMAJOR).$(XLUMINOR)
-	rm -f $(DESTDIR)$(libdir)/libxenlight.a
-	rm -f $(DESTDIR)$(libdir)/libxenlight.so
-	rm -f $(DESTDIR)$(libdir)/libxenlight.so.$(MAJOR)
-	rm -f $(DESTDIR)$(libdir)/libxenlight.so.$(MAJOR).$(MINOR)
-	rm -f $(DESTDIR)$(LIBEXEC_BIN)/libxl-save-helper
 
 .PHONY: clean
 clean:
-	$(RM) -f _*.h *.o *.so* *.a $(CLIENTS) $(DEPS_RM)
-	$(RM) -f _*.c *.pyc _paths.*.tmp _*.api-for-check
-	$(RM) -f testidl.c.new testidl.c *.api-ok
-	$(RM) -f $(TEST_PROGS)
-	$(RM) -f xenlight.pc
+	$(RM) -f _*.h *.o *.so* *.a $(DEPS_RM)
 	$(RM) -f xlutil.pc
-	$(RM) -rf __pycache__
-	$(MAKE) -C $(ACPI_PATH) ACPI_BUILD_DIR=$(CURDIR) clean
 
 distclean: clean
 
diff --git a/tools/ocaml/libs/xl/Makefile b/tools/ocaml/libs/xl/Makefile
index 0d1549dd3a..cbe1569cc5 100644
--- a/tools/ocaml/libs/xl/Makefile
+++ b/tools/ocaml/libs/xl/Makefile
@@ -50,10 +50,10 @@ xenlight.mli: xenlight.mli.in _libxl_types.mli.in
 	  < xenlight.mli.in > xenlight.mli.tmp
 	$(Q)mv xenlight.mli.tmp xenlight.mli
 
-_libxl_types.ml.in _libxl_types.mli.in _libxl_types.inc: genwrap.py $(XEN_ROOT)/tools/libxl/libxl_types.idl \
-                $(XEN_ROOT)/tools/libxl/idl.py
-	PYTHONPATH=$(XEN_ROOT)/tools/libxl $(PYTHON) genwrap.py \
-		$(XEN_ROOT)/tools/libxl/libxl_types.idl \
+_libxl_types.ml.in _libxl_types.mli.in _libxl_types.inc: genwrap.py $(XEN_ROOT)/tools/libs/light/libxl_types.idl \
+                $(XEN_ROOT)/tools/libs/light/idl.py
+	PYTHONPATH=$(XEN_ROOT)/tools/libs/light $(PYTHON) genwrap.py \
+		$(XEN_ROOT)/tools/libs/light/libxl_types.idl \
 		_libxl_types.mli.in _libxl_types.ml.in _libxl_types.inc
 
 libs: $(LIBS)
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 29/31] tools: rename global libxlutil make variables
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (27 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 28/31] tools/libxl: move libxenlight to tools/libs/light Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-09-07 15:55   ` Wei Liu
  2020-08-28 15:07 ` [PATCH v4 30/31] tools/libs: add option for library names not starting with libxen Juergen Gross
  2020-08-28 15:07 ` [PATCH v4 31/31] tools: move libxlutil to tools/libs/util Juergen Gross
  30 siblings, 1 reply; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu, Anthony PERARD

Rename *_libxlutil make variables to *_libxenutil in order to avoid
nasty indirections when moving libxlutil under the tools/libs
infrastructure.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 tools/Rules.mk       | 10 +++++-----
 tools/libxl/Makefile |  4 ++--
 tools/xl/Makefile    |  4 ++--
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/tools/Rules.mk b/tools/Rules.mk
index a80a633190..9b9db62fe5 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -15,7 +15,7 @@ XEN_INCLUDE        = $(XEN_ROOT)/tools/include
 
 include $(XEN_ROOT)/tools/libs/uselibs.mk
 
-XEN_libxlutil      = $(XEN_ROOT)/tools/libxl
+XEN_libxenutil     = $(XEN_ROOT)/tools/libxl
 
 CFLAGS_xeninclude = -I$(XEN_INCLUDE)
 
@@ -116,10 +116,10 @@ else
 CFLAGS += -O2 -fomit-frame-pointer
 endif
 
-CFLAGS_libxlutil = -I$(XEN_libxlutil)
-SHDEPS_libxlutil = $(SHLIB_libxenlight)
-LDLIBS_libxlutil = $(SHDEPS_libxlutil) $(XEN_libxlutil)/libxlutil$(libextension)
-SHLIB_libxlutil  = $(SHDEPS_libxlutil) -Wl,-rpath-link=$(XEN_libxlutil)
+CFLAGS_libxenutil = -I$(XEN_libxenutil)
+SHDEPS_libxenutil = $(SHLIB_libxenlight)
+LDLIBS_libxenutil = $(SHDEPS_libxenutil) $(XEN_libxenutil)/libxlutil$(libextension)
+SHLIB_libxenutil  = $(SHDEPS_libxenutil) -Wl,-rpath-link=$(XEN_libxenutil)
 
 CFLAGS += -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__
 
diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 8ab7c9d3f0..51da1d5be4 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -42,7 +42,7 @@ PKG_CONFIG_INST := $(PKG_CONFIG)
 xlutil.pc: PKG_CONFIG_NAME = Xlutil
 xlutil.pc: PKG_CONFIG_DESC = The xl utility library for Xen hypervisor
 xlutil.pc: PKG_CONFIG_VERSION = $(XLUMAJOR).$(XLUMINOR)
-xlutil.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxlutil)
+xlutil.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenutil)
 xlutil.pc: PKG_CONFIG_LIB = xlutil
 xlutil.pc: PKG_CONFIG_REQPRIV = xenlight
 $(PKG_CONFIG_INST): PKG_CONFIG_PREFIX = $(prefix)
@@ -55,7 +55,7 @@ PKG_CONFIG_LOCAL := $(foreach pc,$(PKG_CONFIG),$(PKG_CONFIG_DIR)/$(pc))
 $(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_NAME = Xlutil
 $(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_DESC = The xl utility library for Xen hypervisor
 $(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_VERSION = $(XLUMAJOR).$(XLUMINOR)
-$(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxlutil)
+$(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenutil)
 $(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_LIB = xlutil
 $(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_REQPRIV = xenlight
 $(PKG_CONFIG_LOCAL): PKG_CONFIG_PREFIX = $(XEN_ROOT)
diff --git a/tools/xl/Makefile b/tools/xl/Makefile
index 407dd7554c..bdf67c8464 100644
--- a/tools/xl/Makefile
+++ b/tools/xl/Makefile
@@ -13,7 +13,7 @@ CFLAGS += $(PTHREAD_CFLAGS)
 LDFLAGS += $(PTHREAD_LDFLAGS)
 
 CFLAGS_XL += $(CFLAGS_libxenlight)
-CFLAGS_XL += $(CFLAGS_libxlutil)
+CFLAGS_XL += $(CFLAGS_libxenutil)
 CFLAGS_XL += -Wshadow
 
 XL_OBJS-$(CONFIG_X86) = xl_psr.o
@@ -38,7 +38,7 @@ $(XL_OBJS): _paths.h
 all: xl
 
 xl: $(XL_OBJS)
-	$(CC) $(LDFLAGS) -o $@ $(XL_OBJS) $(LDLIBS_libxlutil) $(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) -lyajl $(APPEND_LDFLAGS)
+	$(CC) $(LDFLAGS) -o $@ $(XL_OBJS) $(LDLIBS_libxenutil) $(LDLIBS_libxenlight) $(LDLIBS_libxentoollog) -lyajl $(APPEND_LDFLAGS)
 
 .PHONY: install
 install: all
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 30/31] tools/libs: add option for library names not starting with libxen
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (28 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 29/31] tools: rename global libxlutil make variables Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-08-28 16:00   ` Wei Liu
  2020-08-28 15:07 ` [PATCH v4 31/31] tools: move libxlutil to tools/libs/util Juergen Gross
  30 siblings, 1 reply; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel; +Cc: Juergen Gross, Ian Jackson, Wei Liu

libxlutil doesn't follow the standard name pattern of all other Xen
libraries, so add another make variable which can be used to allow
other names.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 tools/Rules.mk     |  3 ++-
 tools/libs/libs.mk | 41 +++++++++++++++++++++--------------------
 2 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/tools/Rules.mk b/tools/Rules.mk
index 9b9db62fe5..5ad17b313b 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -87,10 +87,11 @@ endif
 # $(SHLIB_libfoo)
 
 define LIB_defs =
+ FILENAME_$(1) ?= xen$(1)
  XEN_libxen$(1) = $$(XEN_ROOT)/tools/libs/$(1)
  CFLAGS_libxen$(1) = -I$$(XEN_libxen$(1))/include $$(CFLAGS_xeninclude)
  SHDEPS_libxen$(1) = $$(foreach use,$$(USELIBS_$(1)),$$(SHLIB_libxen$$(use)))
- LDLIBS_libxen$(1) = $$(SHDEPS_libxen$(1)) $$(XEN_libxen$(1))/libxen$(1)$$(libextension)
+ LDLIBS_libxen$(1) = $$(SHDEPS_libxen$(1)) $$(XEN_libxen$(1))/lib$$(FILENAME_$(1))$$(libextension)
  SHLIB_libxen$(1) = $$(SHDEPS_libxen$(1)) -Wl,-rpath-link=$$(XEN_libxen$(1))
 endef
 
diff --git a/tools/libs/libs.mk b/tools/libs/libs.mk
index 9d0ed08846..325b7b7cea 100644
--- a/tools/libs/libs.mk
+++ b/tools/libs/libs.mk
@@ -20,20 +20,21 @@ LDUSELIBS = $(foreach lib, $(USELIBS_$(LIBNAME)), $(LDLIBS_libxen$(lib)))
 LIB_OBJS := $(SRCS-y:.c=.o)
 PIC_OBJS := $(SRCS-y:.c=.opic)
 
-LIB := libxen$(LIBNAME).a
+LIB_FILE_NAME = $(FILENAME_$(LIBNAME))
+LIB := lib$(LIB_FILE_NAME).a
 ifneq ($(nosharedlibs),y)
-LIB += libxen$(LIBNAME).so
+LIB += lib$(LIB_FILE_NAME).so
 endif
 
 comma:= ,
 empty:=
 space:= $(empty) $(empty)
-PKG_CONFIG ?= xen$(LIBNAME).pc
+PKG_CONFIG ?= $(LIB_FILE_NAME).pc
 PKG_CONFIG_NAME ?= Xen$(LIBNAME)
 PKG_CONFIG_DESC ?= The $(PKG_CONFIG_NAME) library for Xen hypervisor
 PKG_CONFIG_VERSION := $(MAJOR).$(MINOR)
 PKG_CONFIG_USELIBS := $(SHLIB_libxen$(LIBNAME))
-PKG_CONFIG_LIB := xen$(LIBNAME)
+PKG_CONFIG_LIB := $(LIB_FILE_NAME)
 PKG_CONFIG_REQPRIV := $(subst $(space),$(comma),$(strip $(foreach lib,$(patsubst ctrl,control,$(USELIBS_$(LIBNAME))),xen$(lib))))
 
 ifneq ($(CONFIG_LIBXC_MINIOS),y)
@@ -45,7 +46,7 @@ endif
 
 PKG_CONFIG_LOCAL := $(PKG_CONFIG_DIR)/$(PKG_CONFIG)
 
-LIBHEADER ?= xen$(LIBNAME).h
+LIBHEADER ?= $(LIB_FILE_NAME).h
 LIBHEADERS = $(foreach h, $(LIBHEADER), include/$(h))
 LIBHEADERSGLOB = $(foreach h, $(LIBHEADER), $(XEN_ROOT)/tools/include/$(h))
 
@@ -81,36 +82,36 @@ libxen$(LIBNAME).map:
 $(LIBHEADERSGLOB): $(LIBHEADERS)
 	for i in $(realpath $(LIBHEADERS)); do ln -sf $$i $(XEN_ROOT)/tools/include; done
 
-libxen$(LIBNAME).a: $(LIB_OBJS)
+lib$(LIB_FILE_NAME).a: $(LIB_OBJS)
 	$(AR) rc $@ $^
 
-libxen$(LIBNAME).so: libxen$(LIBNAME).so.$(MAJOR)
+lib$(LIB_FILE_NAME).so: lib$(LIB_FILE_NAME).so.$(MAJOR)
 	$(SYMLINK_SHLIB) $< $@
-libxen$(LIBNAME).so.$(MAJOR): libxen$(LIBNAME).so.$(MAJOR).$(MINOR)
+lib$(LIB_FILE_NAME).so.$(MAJOR): lib$(LIB_FILE_NAME).so.$(MAJOR).$(MINOR)
 	$(SYMLINK_SHLIB) $< $@
 
-libxen$(LIBNAME).so.$(MAJOR).$(MINOR): $(PIC_OBJS) libxen$(LIBNAME).map
-	$(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxen$(LIBNAME).so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $(PIC_OBJS) $(LDUSELIBS) $(APPEND_LDFLAGS)
+lib$(LIB_FILE_NAME).so.$(MAJOR).$(MINOR): $(PIC_OBJS) libxen$(LIBNAME).map
+	$(CC) $(LDFLAGS) $(PTHREAD_LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,lib$(LIB_FILE_NAME).so.$(MAJOR) $(SHLIB_LDFLAGS) -o $@ $(PIC_OBJS) $(LDUSELIBS) $(APPEND_LDFLAGS)
 
 .PHONY: install
 install: build
 	$(INSTALL_DIR) $(DESTDIR)$(libdir)
 	$(INSTALL_DIR) $(DESTDIR)$(includedir)
-	$(INSTALL_SHLIB) libxen$(LIBNAME).so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)
-	$(INSTALL_DATA) libxen$(LIBNAME).a $(DESTDIR)$(libdir)
-	$(SYMLINK_SHLIB) libxen$(LIBNAME).so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/libxen$(LIBNAME).so.$(MAJOR)
-	$(SYMLINK_SHLIB) libxen$(LIBNAME).so.$(MAJOR) $(DESTDIR)$(libdir)/libxen$(LIBNAME).so
+	$(INSTALL_SHLIB) lib$(LIB_FILE_NAME).so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)
+	$(INSTALL_DATA) lib$(LIB_FILE_NAME).a $(DESTDIR)$(libdir)
+	$(SYMLINK_SHLIB) lib$(LIB_FILE_NAME).so.$(MAJOR).$(MINOR) $(DESTDIR)$(libdir)/lib$(LIB_FILE_NAME).so.$(MAJOR)
+	$(SYMLINK_SHLIB) lib$(LIB_FILE_NAME).so.$(MAJOR) $(DESTDIR)$(libdir)/lib$(LIB_FILE_NAME).so
 	for i in $(LIBHEADERS); do $(INSTALL_DATA) $$i $(DESTDIR)$(includedir); done
 	$(INSTALL_DATA) $(PKG_CONFIG) $(DESTDIR)$(PKG_INSTALLDIR)
 
 .PHONY: uninstall
 uninstall:
-	rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xen$(LIBNAME).pc
+	rm -f $(DESTDIR)$(PKG_INSTALLDIR)/$(LIB_FILE_NAME).pc
 	for i in $(LIBHEADER); do rm -f $(DESTDIR)$(includedir)/$(LIBHEADER); done
-	rm -f $(DESTDIR)$(libdir)/libxen$(LIBNAME).so
-	rm -f $(DESTDIR)$(libdir)/libxen$(LIBNAME).so.$(MAJOR)
-	rm -f $(DESTDIR)$(libdir)/libxen$(LIBNAME).so.$(MAJOR).$(MINOR)
-	rm -f $(DESTDIR)$(libdir)/libxen$(LIBNAME).a
+	rm -f $(DESTDIR)$(libdir)/lib$(LIB_FILE_NAME).so
+	rm -f $(DESTDIR)$(libdir)/lib$(LIB_FILE_NAME).so.$(MAJOR)
+	rm -f $(DESTDIR)$(libdir)/lib$(LIB_FILE_NAME).so.$(MAJOR).$(MINOR)
+	rm -f $(DESTDIR)$(libdir)/lib$(LIB_FILE_NAME).a
 
 .PHONY: TAGS
 TAGS:
@@ -119,7 +120,7 @@ TAGS:
 .PHONY: clean
 clean:
 	rm -rf *.rpm $(LIB) *~ $(DEPS_RM) $(LIB_OBJS) $(PIC_OBJS)
-	rm -f libxen$(LIBNAME).so.$(MAJOR).$(MINOR) libxen$(LIBNAME).so.$(MAJOR)
+	rm -f lib$(LIB_FILE_NAME).so.$(MAJOR).$(MINOR) lib$(LIB_FILE_NAME).so.$(MAJOR)
 	rm -f headers.chk
 	rm -f $(PKG_CONFIG)
 	rm -f $(LIBHEADERSGLOB)
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* [PATCH v4 31/31] tools: move libxlutil to tools/libs/util
  2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
                   ` (29 preceding siblings ...)
  2020-08-28 15:07 ` [PATCH v4 30/31] tools/libs: add option for library names not starting with libxen Juergen Gross
@ 2020-08-28 15:07 ` Juergen Gross
  2020-10-01 10:46   ` Wei Liu
  30 siblings, 1 reply; 48+ messages in thread
From: Juergen Gross @ 2020-08-28 15:07 UTC (permalink / raw)
  To: xen-devel
  Cc: Juergen Gross, Andrew Cooper, George Dunlap, Ian Jackson,
	Jan Beulich, Julien Grall, Stefano Stabellini, Wei Liu,
	Anthony PERARD

Move the libxlutil source to tools/libs/util and delete tools/libxl.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 .gitignore                                    |   6 +-
 tools/Makefile                                |   1 -
 tools/Rules.mk                                |   7 -
 tools/libs/Makefile                           |   1 +
 tools/libs/uselibs.mk                         |   3 +
 tools/{libxl => libs/util}/CODING_STYLE       |   0
 tools/libs/util/Makefile                      |  63 +++++++++
 .../{libxl => libs/util/include}/libxlutil.h  |   0
 tools/{libxl => libs/util}/libxlu_cfg.c       |   0
 tools/{libxl => libs/util}/libxlu_cfg_i.h     |   0
 tools/{libxl => libs/util}/libxlu_cfg_l.c     |   0
 tools/{libxl => libs/util}/libxlu_cfg_l.h     |   0
 tools/{libxl => libs/util}/libxlu_cfg_l.l     |   0
 tools/{libxl => libs/util}/libxlu_cfg_y.c     |   0
 tools/{libxl => libs/util}/libxlu_cfg_y.h     |   0
 tools/{libxl => libs/util}/libxlu_cfg_y.y     |   0
 tools/{libxl => libs/util}/libxlu_disk.c      |   0
 tools/{libxl => libs/util}/libxlu_disk_i.h    |   0
 tools/{libxl => libs/util}/libxlu_disk_l.c    |   0
 tools/{libxl => libs/util}/libxlu_disk_l.h    |   0
 tools/{libxl => libs/util}/libxlu_disk_l.l    |   0
 tools/{libxl => libs/util}/libxlu_internal.h  |   0
 tools/{libxl => libs/util}/libxlu_pci.c       |   0
 tools/{libxl => libs/util}/libxlu_vif.c       |   0
 tools/libxl/Makefile                          | 124 ------------------
 25 files changed, 71 insertions(+), 134 deletions(-)
 rename tools/{libxl => libs/util}/CODING_STYLE (100%)
 create mode 100644 tools/libs/util/Makefile
 rename tools/{libxl => libs/util/include}/libxlutil.h (100%)
 rename tools/{libxl => libs/util}/libxlu_cfg.c (100%)
 rename tools/{libxl => libs/util}/libxlu_cfg_i.h (100%)
 rename tools/{libxl => libs/util}/libxlu_cfg_l.c (100%)
 rename tools/{libxl => libs/util}/libxlu_cfg_l.h (100%)
 rename tools/{libxl => libs/util}/libxlu_cfg_l.l (100%)
 rename tools/{libxl => libs/util}/libxlu_cfg_y.c (100%)
 rename tools/{libxl => libs/util}/libxlu_cfg_y.h (100%)
 rename tools/{libxl => libs/util}/libxlu_cfg_y.y (100%)
 rename tools/{libxl => libs/util}/libxlu_disk.c (100%)
 rename tools/{libxl => libs/util}/libxlu_disk_i.h (100%)
 rename tools/{libxl => libs/util}/libxlu_disk_l.c (100%)
 rename tools/{libxl => libs/util}/libxlu_disk_l.h (100%)
 rename tools/{libxl => libs/util}/libxlu_disk_l.l (100%)
 rename tools/{libxl => libs/util}/libxlu_internal.h (100%)
 rename tools/{libxl => libs/util}/libxlu_pci.c (100%)
 rename tools/{libxl => libs/util}/libxlu_vif.c (100%)
 delete mode 100644 tools/libxl/Makefile

diff --git a/.gitignore b/.gitignore
index f30550255f..188495783e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -154,6 +154,10 @@ tools/libs/store/utils.h
 tools/libs/store/xenstore.pc
 tools/libs/store/xs_lib.c
 tools/libs/store/include/xenstore_lib.h
+tools/libs/util/*.pc
+tools/libs/util/_paths.h
+tools/libs/util/libxlu_cfg_y.output
+tools/libs/util/libxenutil.map
 tools/libs/vchan/headers.chk
 tools/libs/vchan/libxenvchan.map
 tools/libs/vchan/xenvchan.pc
@@ -232,8 +236,6 @@ tools/include/xen/*
 tools/include/xen-xsm/*
 tools/include/xen-foreign/*.(c|h|size)
 tools/include/xen-foreign/checker
-tools/libxl/*.pc
-tools/libxl/libxlu_cfg_y.output
 tools/misc/cpuperf/cpuperf-perfcntr
 tools/misc/cpuperf/cpuperf-xen
 tools/misc/xc_shadow
diff --git a/tools/Makefile b/tools/Makefile
index ea69675cca..9c77ee6763 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -29,7 +29,6 @@ SUBDIRS-$(CONFIG_QEMU_XEN) += qemu-xen-dir
 endif
 
 SUBDIRS-y += xenpmd
-SUBDIRS-y += libxl
 SUBDIRS-$(CONFIG_GOLANG) += golang
 SUBDIRS-y += xl
 SUBDIRS-y += helpers
diff --git a/tools/Rules.mk b/tools/Rules.mk
index 5ad17b313b..842b9daf92 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -15,8 +15,6 @@ XEN_INCLUDE        = $(XEN_ROOT)/tools/include
 
 include $(XEN_ROOT)/tools/libs/uselibs.mk
 
-XEN_libxenutil     = $(XEN_ROOT)/tools/libxl
-
 CFLAGS_xeninclude = -I$(XEN_INCLUDE)
 
 XENSTORE_XENSTORED ?= y
@@ -117,11 +115,6 @@ else
 CFLAGS += -O2 -fomit-frame-pointer
 endif
 
-CFLAGS_libxenutil = -I$(XEN_libxenutil)
-SHDEPS_libxenutil = $(SHLIB_libxenlight)
-LDLIBS_libxenutil = $(SHDEPS_libxenutil) $(XEN_libxenutil)/libxlutil$(libextension)
-SHLIB_libxenutil  = $(SHDEPS_libxenutil) -Wl,-rpath-link=$(XEN_libxenutil)
-
 CFLAGS += -D__XEN_INTERFACE_VERSION__=__XEN_LATEST_INTERFACE_VERSION__
 
 # Get gcc to generate the dependencies for us.
diff --git a/tools/libs/Makefile b/tools/libs/Makefile
index c41455c604..1afcd12e2b 100644
--- a/tools/libs/Makefile
+++ b/tools/libs/Makefile
@@ -16,6 +16,7 @@ SUBDIRS-y += store
 SUBDIRS-y += stat
 SUBDIRS-$(CONFIG_Linux) += vchan
 SUBDIRS-y += light
+SUBDIRS-y += util
 
 ifeq ($(CONFIG_RUMP),y)
 SUBDIRS-y := toolcore
diff --git a/tools/libs/uselibs.mk b/tools/libs/uselibs.mk
index 685f368aed..efd7a475ba 100644
--- a/tools/libs/uselibs.mk
+++ b/tools/libs/uselibs.mk
@@ -28,3 +28,6 @@ LIBS_LIBS += stat
 USELIBS_stat := ctrl store
 LIBS_LIBS += light
 USELIBS_light := toollog evtchn toolcore ctrl store hypfs guest
+LIBS_LIBS += util
+USELIBS_util := light
+FILENAME_util := xlutil
diff --git a/tools/libxl/CODING_STYLE b/tools/libs/util/CODING_STYLE
similarity index 100%
rename from tools/libxl/CODING_STYLE
rename to tools/libs/util/CODING_STYLE
diff --git a/tools/libs/util/Makefile b/tools/libs/util/Makefile
new file mode 100644
index 0000000000..0c9db8027d
--- /dev/null
+++ b/tools/libs/util/Makefile
@@ -0,0 +1,63 @@
+XEN_ROOT = $(CURDIR)/../../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+SRCS-y += libxlu_cfg_y.c
+SRCS-y += libxlu_cfg_l.c
+SRCS-y += libxlu_cfg.c
+SRCS-y += libxlu_disk_l.c
+SRCS-y += libxlu_disk.c
+SRCS-y += libxlu_vif.c
+SRCS-y += libxlu_pci.c
+
+CFLAGS += -Wno-format-zero-length -Wmissing-declarations \
+	-Wno-declaration-after-statement -Wformat-nonliteral
+CFLAGS += -I. $(CFLAGS_libxenctrl)
+
+CFLAGS += $(PTHREAD_CFLAGS)
+LDFLAGS += $(PTHREAD_LDFLAGS)
+
+ifeq ($(FLEX),)
+%.c %.h:: %.l
+	$(warning Flex is needed to rebuild some libxl parsers and \
+		  scanners, please install it and rerun configure)
+endif
+
+ifeq ($(BISON),)
+%.c %.h:: %.y
+	$(warning Bison is needed to rebuild some libxl parsers and \
+		  scanners, please install it and rerun configure)
+endif
+
+AUTOINCS = libxlu_cfg_y.h libxlu_cfg_l.h libxlu_disk_l.h
+AUTOSRCS = libxlu_cfg_y.c libxlu_cfg_l.c
+
+LIBHEADER := libxlutil.h
+PKG_CONFIG_NAME := Xlutil
+PKG_CONFIG_DESC := The xl utility library for Xen hypervisor
+
+NO_HEADERS_CHK := y
+
+include $(XEN_ROOT)/tools/libs/libs.mk
+
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(XEN_libxenutil)/include
+$(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL = $(CFLAGS_xeninclude)
+
+$(LIB_OBJS) $(PIC_OBJS): $(AUTOINCS) _paths.h
+
+%.c %.h:: %.y
+	@rm -f $*.[ch]
+	$(BISON) --output=$*.c $<
+
+%.c %.h:: %.l
+	@rm -f $*.[ch]
+	$(FLEX) --header-file=$*.h --outfile=$*.c $<
+
+genpath-target = $(call buildmakevars2header,_paths.h)
+$(eval $(genpath-target))
+
+clean: cleanlocal
+
+.PHONY: cleanlocal
+cleanlocal:
+	$(RM) -f _*.h
+	$(RM) -f libxlutil.map
diff --git a/tools/libxl/libxlutil.h b/tools/libs/util/include/libxlutil.h
similarity index 100%
rename from tools/libxl/libxlutil.h
rename to tools/libs/util/include/libxlutil.h
diff --git a/tools/libxl/libxlu_cfg.c b/tools/libs/util/libxlu_cfg.c
similarity index 100%
rename from tools/libxl/libxlu_cfg.c
rename to tools/libs/util/libxlu_cfg.c
diff --git a/tools/libxl/libxlu_cfg_i.h b/tools/libs/util/libxlu_cfg_i.h
similarity index 100%
rename from tools/libxl/libxlu_cfg_i.h
rename to tools/libs/util/libxlu_cfg_i.h
diff --git a/tools/libxl/libxlu_cfg_l.c b/tools/libs/util/libxlu_cfg_l.c
similarity index 100%
rename from tools/libxl/libxlu_cfg_l.c
rename to tools/libs/util/libxlu_cfg_l.c
diff --git a/tools/libxl/libxlu_cfg_l.h b/tools/libs/util/libxlu_cfg_l.h
similarity index 100%
rename from tools/libxl/libxlu_cfg_l.h
rename to tools/libs/util/libxlu_cfg_l.h
diff --git a/tools/libxl/libxlu_cfg_l.l b/tools/libs/util/libxlu_cfg_l.l
similarity index 100%
rename from tools/libxl/libxlu_cfg_l.l
rename to tools/libs/util/libxlu_cfg_l.l
diff --git a/tools/libxl/libxlu_cfg_y.c b/tools/libs/util/libxlu_cfg_y.c
similarity index 100%
rename from tools/libxl/libxlu_cfg_y.c
rename to tools/libs/util/libxlu_cfg_y.c
diff --git a/tools/libxl/libxlu_cfg_y.h b/tools/libs/util/libxlu_cfg_y.h
similarity index 100%
rename from tools/libxl/libxlu_cfg_y.h
rename to tools/libs/util/libxlu_cfg_y.h
diff --git a/tools/libxl/libxlu_cfg_y.y b/tools/libs/util/libxlu_cfg_y.y
similarity index 100%
rename from tools/libxl/libxlu_cfg_y.y
rename to tools/libs/util/libxlu_cfg_y.y
diff --git a/tools/libxl/libxlu_disk.c b/tools/libs/util/libxlu_disk.c
similarity index 100%
rename from tools/libxl/libxlu_disk.c
rename to tools/libs/util/libxlu_disk.c
diff --git a/tools/libxl/libxlu_disk_i.h b/tools/libs/util/libxlu_disk_i.h
similarity index 100%
rename from tools/libxl/libxlu_disk_i.h
rename to tools/libs/util/libxlu_disk_i.h
diff --git a/tools/libxl/libxlu_disk_l.c b/tools/libs/util/libxlu_disk_l.c
similarity index 100%
rename from tools/libxl/libxlu_disk_l.c
rename to tools/libs/util/libxlu_disk_l.c
diff --git a/tools/libxl/libxlu_disk_l.h b/tools/libs/util/libxlu_disk_l.h
similarity index 100%
rename from tools/libxl/libxlu_disk_l.h
rename to tools/libs/util/libxlu_disk_l.h
diff --git a/tools/libxl/libxlu_disk_l.l b/tools/libs/util/libxlu_disk_l.l
similarity index 100%
rename from tools/libxl/libxlu_disk_l.l
rename to tools/libs/util/libxlu_disk_l.l
diff --git a/tools/libxl/libxlu_internal.h b/tools/libs/util/libxlu_internal.h
similarity index 100%
rename from tools/libxl/libxlu_internal.h
rename to tools/libs/util/libxlu_internal.h
diff --git a/tools/libxl/libxlu_pci.c b/tools/libs/util/libxlu_pci.c
similarity index 100%
rename from tools/libxl/libxlu_pci.c
rename to tools/libs/util/libxlu_pci.c
diff --git a/tools/libxl/libxlu_vif.c b/tools/libs/util/libxlu_vif.c
similarity index 100%
rename from tools/libxl/libxlu_vif.c
rename to tools/libs/util/libxlu_vif.c
diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
deleted file mode 100644
index 51da1d5be4..0000000000
--- a/tools/libxl/Makefile
+++ /dev/null
@@ -1,124 +0,0 @@
-#
-# tools/libxl/Makefile
-#
-
-XEN_ROOT = $(CURDIR)/../..
-include $(XEN_ROOT)/tools/Rules.mk
-
-XLUMAJOR = 4.15
-XLUMINOR = 0
-
-CFLAGS += -Werror -Wno-format-zero-length -Wmissing-declarations \
-	-Wno-declaration-after-statement -Wformat-nonliteral
-CFLAGS += -I. -fPIC
-
-CFLAGS += $(PTHREAD_CFLAGS)
-LDFLAGS += $(PTHREAD_LDFLAGS)
-
-LIBXLU_LIBS = $(LDLIBS_libxenlight)
-
-ifeq ($(FLEX),)
-%.c %.h:: %.l
-	$(warning Flex is needed to rebuild some libxl parsers and \
-		  scanners, please install it and rerun configure)
-endif
-
-ifeq ($(BISON),)
-%.c %.h:: %.y
-	$(warning Bison is needed to rebuild some libxl parsers and \
-		  scanners, please install it an rerun configure)
-endif
-
-AUTOINCS= libxlu_cfg_y.h libxlu_cfg_l.h libxlu_disk_l.h
-AUTOSRCS= libxlu_cfg_y.c libxlu_cfg_l.c
-LIBXLU_OBJS = libxlu_cfg_y.o libxlu_cfg_l.o libxlu_cfg.o \
-	libxlu_disk_l.o libxlu_disk.o libxlu_vif.o libxlu_pci.o
-$(LIBXLU_OBJS): CFLAGS += $(CFLAGS_libxenctrl) # For xentoollog.h
-
-PKG_CONFIG = xlutil.pc
-
-ifneq ($(CONFIG_LIBXC_MINIOS),y)
-PKG_CONFIG_INST := $(PKG_CONFIG)
-xlutil.pc: PKG_CONFIG_NAME = Xlutil
-xlutil.pc: PKG_CONFIG_DESC = The xl utility library for Xen hypervisor
-xlutil.pc: PKG_CONFIG_VERSION = $(XLUMAJOR).$(XLUMINOR)
-xlutil.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenutil)
-xlutil.pc: PKG_CONFIG_LIB = xlutil
-xlutil.pc: PKG_CONFIG_REQPRIV = xenlight
-$(PKG_CONFIG_INST): PKG_CONFIG_PREFIX = $(prefix)
-$(PKG_CONFIG_INST): PKG_CONFIG_INCDIR = $(includedir)
-$(PKG_CONFIG_INST): PKG_CONFIG_LIBDIR = $(libdir)
-endif
-
-PKG_CONFIG_LOCAL := $(foreach pc,$(PKG_CONFIG),$(PKG_CONFIG_DIR)/$(pc))
-
-$(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_NAME = Xlutil
-$(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_DESC = The xl utility library for Xen hypervisor
-$(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_VERSION = $(XLUMAJOR).$(XLUMINOR)
-$(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_USELIBS = $(SHLIB_libxenutil)
-$(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_LIB = xlutil
-$(PKG_CONFIG_DIR)/xlutil.pc: PKG_CONFIG_REQPRIV = xenlight
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_PREFIX = $(XEN_ROOT)
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_INCDIR = $(CURDIR)
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_LIBDIR = $(CURDIR)
-$(PKG_CONFIG_LOCAL): PKG_CONFIG_CFLAGS_LOCAL = $(CFLAGS_xeninclude)
-
-.PHONY: all
-all: libxlutil.so libxlutil.a $(AUTOSRCS) $(AUTOINCS) $(PKG_CONFIG) $(PKG_CONFIG_LOCAL)
-
-$(LIBXLU_OBJS): $(AUTOINCS)
-
-%.c %.h:: %.y
-	@rm -f $*.[ch]
-	$(BISON) --output=$*.c $<
-
-%.c %.h:: %.l
-	@rm -f $*.[ch]
-	$(FLEX) --header-file=$*.h --outfile=$*.c $<
-
-genpath-target = $(call buildmakevars2header,_paths.h)
-$(eval $(genpath-target))
-
-libxlutil.so: libxlutil.so.$(XLUMAJOR)
-	$(SYMLINK_SHLIB) $< $@
-
-libxlutil.so.$(XLUMAJOR): libxlutil.so.$(XLUMAJOR).$(XLUMINOR)
-	$(SYMLINK_SHLIB) $< $@
-
-libxlutil.so.$(XLUMAJOR).$(XLUMINOR): $(LIBXLU_OBJS)
-	$(CC) $(LDFLAGS) -Wl,$(SONAME_LDFLAG) -Wl,libxlutil.so.$(XLUMAJOR) $(SHLIB_LDFLAGS) -o $@ $(LIBXLU_OBJS) $(LIBXLU_LIBS) $(APPEND_LDFLAGS)
-
-libxlutil.a: $(LIBXLU_OBJS)
-	$(AR) rcs libxlutil.a $^
-
-.PHONY: install
-install: all
-	$(INSTALL_DIR) $(DESTDIR)$(libdir)
-	$(INSTALL_DIR) $(DESTDIR)$(includedir)
-	$(INSTALL_SHLIB) libxlutil.so.$(XLUMAJOR).$(XLUMINOR) $(DESTDIR)$(libdir)
-	$(SYMLINK_SHLIB) libxlutil.so.$(XLUMAJOR).$(XLUMINOR) $(DESTDIR)$(libdir)/libxlutil.so.$(XLUMAJOR)
-	$(SYMLINK_SHLIB) libxlutil.so.$(XLUMAJOR) $(DESTDIR)$(libdir)/libxlutil.so
-	$(INSTALL_DATA) libxlutil.a $(DESTDIR)$(libdir)
-	$(INSTALL_DATA) libxlutil.h $(DESTDIR)$(includedir)
-	$(INSTALL_DATA) xlutil.pc $(DESTDIR)$(PKG_INSTALLDIR)
-
-.PHONY: uninstall
-uninstall:
-	rm -f $(DESTDIR)$(PKG_INSTALLDIR)/xlutil.pc
-	rm -f $(DESTDIR)$(includedir)/libxlutil.h
-	rm -f $(DESTDIR)$(libdir)/libxlutil.a
-	rm -f $(DESTDIR)$(libdir)/libxlutil.so
-	rm -f $(DESTDIR)$(libdir)/libxlutil.so.$(XLUMAJOR)
-	rm -f $(DESTDIR)$(libdir)/libxlutil.so.$(XLUMAJOR).$(XLUMINOR)
-
-.PHONY: clean
-clean:
-	$(RM) -f _*.h *.o *.so* *.a $(DEPS_RM)
-	$(RM) -f xlutil.pc
-
-distclean: clean
-
-realclean: distclean
-	$(RM) -f $(AUTOSRCS) $(AUTOINCS)
-
--include $(DEPS_INCLUDE)
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 48+ messages in thread

* Re: [PATCH v4 30/31] tools/libs: add option for library names not starting with libxen
  2020-08-28 15:07 ` [PATCH v4 30/31] tools/libs: add option for library names not starting with libxen Juergen Gross
@ 2020-08-28 16:00   ` Wei Liu
  2020-08-29  4:38     ` Jürgen Groß
  0 siblings, 1 reply; 48+ messages in thread
From: Wei Liu @ 2020-08-28 16:00 UTC (permalink / raw)
  To: Juergen Gross; +Cc: xen-devel, Ian Jackson, Wei Liu

On Fri, Aug 28, 2020 at 05:07:46PM +0200, Juergen Gross wrote:
> libxlutil doesn't follow the standard name pattern of all other Xen
> libraries, so add another make variable which can be used to allow
> other names.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Is this still needed?

Wei.


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v4 28/31] tools/libxl: move libxenlight to tools/libs/light
  2020-08-28 15:07 ` [PATCH v4 28/31] tools/libxl: move libxenlight to tools/libs/light Juergen Gross
@ 2020-08-28 16:05   ` Wei Liu
  2020-08-31  5:50     ` Jürgen Groß
  0 siblings, 1 reply; 48+ messages in thread
From: Wei Liu @ 2020-08-28 16:05 UTC (permalink / raw)
  To: Juergen Gross
  Cc: xen-devel, Andrew Cooper, George Dunlap, Ian Jackson,
	Jan Beulich, Julien Grall, Stefano Stabellini, Wei Liu,
	Anthony PERARD, Shriram Rajagopalan, Yang Hongyang,
	Christian Lindig, David Scott

On Fri, Aug 28, 2020 at 05:07:44PM +0200, Juergen Gross wrote:
> Carve out all libxenlight related sources and move them to
> tools/libs/light in order to use the generic library build environment.
> 
> The closely related sources for libxl-save-helper and the libxl test
> environment are being moved, too.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>
> Acked-by: Wei Liu <wl@xen.org>

It occurs to me you may need to modify golang/xenlight/Makefile.

There is

    LIBXL_SRC_DIR = ../../libxl

in it.

I didn't hit any error perhaps due to I didn't have golang installed.

Wei.


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v4 30/31] tools/libs: add option for library names not starting with libxen
  2020-08-28 16:00   ` Wei Liu
@ 2020-08-29  4:38     ` Jürgen Groß
  2020-10-01 10:46       ` Wei Liu
  0 siblings, 1 reply; 48+ messages in thread
From: Jürgen Groß @ 2020-08-29  4:38 UTC (permalink / raw)
  To: Wei Liu; +Cc: xen-devel, Ian Jackson

On 28.08.20 18:00, Wei Liu wrote:
> On Fri, Aug 28, 2020 at 05:07:46PM +0200, Juergen Gross wrote:
>> libxlutil doesn't follow the standard name pattern of all other Xen
>> libraries, so add another make variable which can be used to allow
>> other names.
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
> 
> Is this still needed?

Yes. Its for the installed files, as those need to stay as they are
today.


Juergen


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v4 28/31] tools/libxl: move libxenlight to tools/libs/light
  2020-08-28 16:05   ` Wei Liu
@ 2020-08-31  5:50     ` Jürgen Groß
  2020-09-07 15:52       ` Wei Liu
  0 siblings, 1 reply; 48+ messages in thread
From: Jürgen Groß @ 2020-08-31  5:50 UTC (permalink / raw)
  To: Wei Liu
  Cc: xen-devel, Andrew Cooper, George Dunlap, Ian Jackson,
	Jan Beulich, Julien Grall, Stefano Stabellini, Anthony PERARD,
	Shriram Rajagopalan, Yang Hongyang, Christian Lindig,
	David Scott

On 28.08.20 18:05, Wei Liu wrote:
> On Fri, Aug 28, 2020 at 05:07:44PM +0200, Juergen Gross wrote:
>> Carve out all libxenlight related sources and move them to
>> tools/libs/light in order to use the generic library build environment.
>>
>> The closely related sources for libxl-save-helper and the libxl test
>> environment are being moved, too.
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>> Acked-by: Wei Liu <wl@xen.org>
> 
> It occurs to me you may need to modify golang/xenlight/Makefile.
> 
> There is
> 
>      LIBXL_SRC_DIR = ../../libxl
> 
> in it.
> 
> I didn't hit any error perhaps due to I didn't have golang installed.

Me neither.

Thanks for noticing that.


Juergen


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v4 01/31] tools: generate pkg-config files from make variables
  2020-08-28 15:07 ` [PATCH v4 01/31] tools: generate pkg-config files from make variables Juergen Gross
@ 2020-09-07 14:25   ` Wei Liu
  2020-09-07 14:44     ` Jürgen Groß
  0 siblings, 1 reply; 48+ messages in thread
From: Wei Liu @ 2020-09-07 14:25 UTC (permalink / raw)
  To: Juergen Gross
  Cc: xen-devel, Ian Jackson, Wei Liu, Samuel Thibault, Anthony PERARD

On Fri, Aug 28, 2020 at 05:07:17PM +0200, Juergen Gross wrote:
> For each library built two variants of pkg-config files are created
> from a per-library template: an "official" one for installation on
> the user's system, and one used for building internal tools, like e.g.
> qemu.
> 
> Instead of the template which is looking very similar for all libraries
> generate the pkg-config files directly from make variables.
> 
> This will reduce the need to specify some pkg-config file entries in
> the templates, as the contents can easily be generated from available
> data (e.g. "Version:" and "Requires.private:" entries).
> 
> Especially the variant used for building internal tools needs to gain
> additional runtime link parameters for the internally used libraries,
> as otherwise those won't be found by the users (e.g. qemu).
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Do you have the new generated files handy so that I can eyeball them a
bit?

If you don't already have them, I can find some time to apply this patch
to generate them myself.

Wei.


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v4 02/31] tools: drop explicit path specifications for qemu build
  2020-08-28 15:07 ` [PATCH v4 02/31] tools: drop explicit path specifications for qemu build Juergen Gross
@ 2020-09-07 14:25   ` Wei Liu
  0 siblings, 0 replies; 48+ messages in thread
From: Wei Liu @ 2020-09-07 14:25 UTC (permalink / raw)
  To: Juergen Gross; +Cc: xen-devel, Ian Jackson, Wei Liu

On Fri, Aug 28, 2020 at 05:07:18PM +0200, Juergen Gross wrote:
> Since more than three years now qemu is capable to set the needed
> include and library paths for the Xen libraries via pkg-config.
> 
> So drop the specification of those paths in tools/Makefile. This will
> enable to move libxenctrl away from tools/libxc, as qemu's configure
> script has special treatment of this path.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Acked-by: Wei Liu <wl@xen.org>


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v4 01/31] tools: generate pkg-config files from make variables
  2020-09-07 14:25   ` Wei Liu
@ 2020-09-07 14:44     ` Jürgen Groß
  2020-09-07 14:59       ` Wei Liu
  0 siblings, 1 reply; 48+ messages in thread
From: Jürgen Groß @ 2020-09-07 14:44 UTC (permalink / raw)
  To: Wei Liu; +Cc: xen-devel, Ian Jackson, Samuel Thibault, Anthony PERARD

[-- Attachment #1: Type: text/plain, Size: 1115 bytes --]

On 07.09.20 16:25, Wei Liu wrote:
> On Fri, Aug 28, 2020 at 05:07:17PM +0200, Juergen Gross wrote:
>> For each library built two variants of pkg-config files are created
>> from a per-library template: an "official" one for installation on
>> the user's system, and one used for building internal tools, like e.g.
>> qemu.
>>
>> Instead of the template which is looking very similar for all libraries
>> generate the pkg-config files directly from make variables.
>>
>> This will reduce the need to specify some pkg-config file entries in
>> the templates, as the contents can easily be generated from available
>> data (e.g. "Version:" and "Requires.private:" entries).
>>
>> Especially the variant used for building internal tools needs to gain
>> additional runtime link parameters for the internally used libraries,
>> as otherwise those won't be found by the users (e.g. qemu).
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
> 
> Do you have the new generated files handy so that I can eyeball them a
> bit?

Attached (both, the local and the installed ones, with the complete
series applied).


Juergen

[-- Attachment #2: pkgconfig.tar --]
[-- Type: application/x-tar, Size: 92160 bytes --]

^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v4 01/31] tools: generate pkg-config files from make variables
  2020-09-07 14:44     ` Jürgen Groß
@ 2020-09-07 14:59       ` Wei Liu
  0 siblings, 0 replies; 48+ messages in thread
From: Wei Liu @ 2020-09-07 14:59 UTC (permalink / raw)
  To: Jürgen Groß
  Cc: Wei Liu, xen-devel, Ian Jackson, Samuel Thibault, Anthony PERARD

On Mon, Sep 07, 2020 at 04:44:28PM +0200, Jürgen Groß wrote:
> On 07.09.20 16:25, Wei Liu wrote:
> > On Fri, Aug 28, 2020 at 05:07:17PM +0200, Juergen Gross wrote:
> > > For each library built two variants of pkg-config files are created
> > > from a per-library template: an "official" one for installation on
> > > the user's system, and one used for building internal tools, like e.g.
> > > qemu.
> > > 
> > > Instead of the template which is looking very similar for all libraries
> > > generate the pkg-config files directly from make variables.
> > > 
> > > This will reduce the need to specify some pkg-config file entries in
> > > the templates, as the contents can easily be generated from available
> > > data (e.g. "Version:" and "Requires.private:" entries).
> > > 
> > > Especially the variant used for building internal tools needs to gain
> > > additional runtime link parameters for the internally used libraries,
> > > as otherwise those won't be found by the users (e.g. qemu).
> > > 
> > > Signed-off-by: Juergen Gross <jgross@suse.com>
> > 
> > Do you have the new generated files handy so that I can eyeball them a
> > bit?
> 
> Attached (both, the local and the installed ones, with the complete
> series applied).

Thanks. They look correct to me.

Acked-by: Wei Liu <wl@xen.org>

Wei.


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v4 28/31] tools/libxl: move libxenlight to tools/libs/light
  2020-08-31  5:50     ` Jürgen Groß
@ 2020-09-07 15:52       ` Wei Liu
  2020-09-07 16:15         ` Jürgen Groß
  0 siblings, 1 reply; 48+ messages in thread
From: Wei Liu @ 2020-09-07 15:52 UTC (permalink / raw)
  To: Jürgen Groß
  Cc: Wei Liu, xen-devel, Andrew Cooper, George Dunlap, Ian Jackson,
	Jan Beulich, Julien Grall, Stefano Stabellini, Anthony PERARD,
	Shriram Rajagopalan, Yang Hongyang, Christian Lindig,
	David Scott

On Mon, Aug 31, 2020 at 07:50:42AM +0200, Jürgen Groß wrote:
> On 28.08.20 18:05, Wei Liu wrote:
> > On Fri, Aug 28, 2020 at 05:07:44PM +0200, Juergen Gross wrote:
> > > Carve out all libxenlight related sources and move them to
> > > tools/libs/light in order to use the generic library build environment.
> > > 
> > > The closely related sources for libxl-save-helper and the libxl test
> > > environment are being moved, too.
> > > 
> > > Signed-off-by: Juergen Gross <jgross@suse.com>
> > > Acked-by: Wei Liu <wl@xen.org>
> > 
> > It occurs to me you may need to modify golang/xenlight/Makefile.
> > 
> > There is
> > 
> >      LIBXL_SRC_DIR = ../../libxl
> > 
> > in it.
> > 
> > I didn't hit any error perhaps due to I didn't have golang installed.
> 
> Me neither.
> 
> Thanks for noticing that.

No need to resend just for this. I can fix it up for you.

Wei.


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v4 29/31] tools: rename global libxlutil make variables
  2020-08-28 15:07 ` [PATCH v4 29/31] tools: rename global libxlutil make variables Juergen Gross
@ 2020-09-07 15:55   ` Wei Liu
  2020-09-07 16:16     ` Jürgen Groß
  0 siblings, 1 reply; 48+ messages in thread
From: Wei Liu @ 2020-09-07 15:55 UTC (permalink / raw)
  To: Juergen Gross; +Cc: xen-devel, Ian Jackson, Wei Liu, Anthony PERARD

On Fri, Aug 28, 2020 at 05:07:45PM +0200, Juergen Gross wrote:
> Rename *_libxlutil make variables to *_libxenutil in order to avoid
> nasty indirections when moving libxlutil under the tools/libs
> infrastructure.

xl means xenlight.

So I think the name should be libxenlightutil here.

Wei.


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v4 28/31] tools/libxl: move libxenlight to tools/libs/light
  2020-09-07 15:52       ` Wei Liu
@ 2020-09-07 16:15         ` Jürgen Groß
  2020-09-07 16:27           ` Wei Liu
  0 siblings, 1 reply; 48+ messages in thread
From: Jürgen Groß @ 2020-09-07 16:15 UTC (permalink / raw)
  To: Wei Liu
  Cc: xen-devel, Andrew Cooper, George Dunlap, Ian Jackson,
	Jan Beulich, Julien Grall, Stefano Stabellini, Anthony PERARD,
	Shriram Rajagopalan, Yang Hongyang, Christian Lindig,
	David Scott

On 07.09.20 17:52, Wei Liu wrote:
> On Mon, Aug 31, 2020 at 07:50:42AM +0200, Jürgen Groß wrote:
>> On 28.08.20 18:05, Wei Liu wrote:
>>> On Fri, Aug 28, 2020 at 05:07:44PM +0200, Juergen Gross wrote:
>>>> Carve out all libxenlight related sources and move them to
>>>> tools/libs/light in order to use the generic library build environment.
>>>>
>>>> The closely related sources for libxl-save-helper and the libxl test
>>>> environment are being moved, too.
>>>>
>>>> Signed-off-by: Juergen Gross <jgross@suse.com>
>>>> Acked-by: Wei Liu <wl@xen.org>
>>>
>>> It occurs to me you may need to modify golang/xenlight/Makefile.
>>>
>>> There is
>>>
>>>       LIBXL_SRC_DIR = ../../libxl
>>>
>>> in it.
>>>
>>> I didn't hit any error perhaps due to I didn't have golang installed.
>>
>> Me neither.
>>
>> Thanks for noticing that.
> 
> No need to resend just for this. I can fix it up for you.

Sure? Did you consider ac7a21cf5c125810? I had to rebase in order
to have a successful build.


Juergen


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v4 29/31] tools: rename global libxlutil make variables
  2020-09-07 15:55   ` Wei Liu
@ 2020-09-07 16:16     ` Jürgen Groß
  2020-10-01 10:45       ` Wei Liu
  0 siblings, 1 reply; 48+ messages in thread
From: Jürgen Groß @ 2020-09-07 16:16 UTC (permalink / raw)
  To: Wei Liu; +Cc: xen-devel, Ian Jackson, Anthony PERARD

On 07.09.20 17:55, Wei Liu wrote:
> On Fri, Aug 28, 2020 at 05:07:45PM +0200, Juergen Gross wrote:
>> Rename *_libxlutil make variables to *_libxenutil in order to avoid
>> nasty indirections when moving libxlutil under the tools/libs
>> infrastructure.
> 
> xl means xenlight.
> 
> So I think the name should be libxenlightutil here.

I don't really mind, but given that the name is completely internal
to the build system I wonder whether the shorter name isn't more
pleasant.


Juergen


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v4 28/31] tools/libxl: move libxenlight to tools/libs/light
  2020-09-07 16:15         ` Jürgen Groß
@ 2020-09-07 16:27           ` Wei Liu
  0 siblings, 0 replies; 48+ messages in thread
From: Wei Liu @ 2020-09-07 16:27 UTC (permalink / raw)
  To: Jürgen Groß
  Cc: Wei Liu, xen-devel, Andrew Cooper, George Dunlap, Ian Jackson,
	Jan Beulich, Julien Grall, Stefano Stabellini, Anthony PERARD,
	Shriram Rajagopalan, Yang Hongyang, Christian Lindig,
	David Scott

On Mon, Sep 07, 2020 at 06:15:00PM +0200, Jürgen Groß wrote:
> On 07.09.20 17:52, Wei Liu wrote:
> > On Mon, Aug 31, 2020 at 07:50:42AM +0200, Jürgen Groß wrote:
> > > On 28.08.20 18:05, Wei Liu wrote:
> > > > On Fri, Aug 28, 2020 at 05:07:44PM +0200, Juergen Gross wrote:
> > > > > Carve out all libxenlight related sources and move them to
> > > > > tools/libs/light in order to use the generic library build environment.
> > > > > 
> > > > > The closely related sources for libxl-save-helper and the libxl test
> > > > > environment are being moved, too.
> > > > > 
> > > > > Signed-off-by: Juergen Gross <jgross@suse.com>
> > > > > Acked-by: Wei Liu <wl@xen.org>
> > > > 
> > > > It occurs to me you may need to modify golang/xenlight/Makefile.
> > > > 
> > > > There is
> > > > 
> > > >       LIBXL_SRC_DIR = ../../libxl
> > > > 
> > > > in it.
> > > > 
> > > > I didn't hit any error perhaps due to I didn't have golang installed.
> > > 
> > > Me neither.
> > > 
> > > Thanks for noticing that.
> > 
> > No need to resend just for this. I can fix it up for you.
> 
> Sure? Did you consider ac7a21cf5c125810? I had to rebase in order
> to have a successful build.

I have not tried to apply this series yet. I said "just for this" for a
reason. :-)

Wei.

> 
> 
> Juergen


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v4 29/31] tools: rename global libxlutil make variables
  2020-09-07 16:16     ` Jürgen Groß
@ 2020-10-01 10:45       ` Wei Liu
  0 siblings, 0 replies; 48+ messages in thread
From: Wei Liu @ 2020-10-01 10:45 UTC (permalink / raw)
  To: Jürgen Groß; +Cc: Wei Liu, xen-devel, Ian Jackson, Anthony PERARD

On Mon, Sep 07, 2020 at 06:16:32PM +0200, Jürgen Groß wrote:
> On 07.09.20 17:55, Wei Liu wrote:
> > On Fri, Aug 28, 2020 at 05:07:45PM +0200, Juergen Gross wrote:
> > > Rename *_libxlutil make variables to *_libxenutil in order to avoid
> > > nasty indirections when moving libxlutil under the tools/libs
> > > infrastructure.
> > 
> > xl means xenlight.
> > 
> > So I think the name should be libxenlightutil here.
> 
> I don't really mind, but given that the name is completely internal
> to the build system I wonder whether the shorter name isn't more
> pleasant.

Oh, yes. It is just an internal name. That's fine then. There is no
point in quibbling about this further.

Acked-by: Wei Liu <wl@xen.org>

> 
> 
> Juergen


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v4 30/31] tools/libs: add option for library names not starting with libxen
  2020-08-29  4:38     ` Jürgen Groß
@ 2020-10-01 10:46       ` Wei Liu
  0 siblings, 0 replies; 48+ messages in thread
From: Wei Liu @ 2020-10-01 10:46 UTC (permalink / raw)
  To: Jürgen Groß; +Cc: Wei Liu, xen-devel, Ian Jackson

On Sat, Aug 29, 2020 at 06:38:40AM +0200, Jürgen Groß wrote:
> On 28.08.20 18:00, Wei Liu wrote:
> > On Fri, Aug 28, 2020 at 05:07:46PM +0200, Juergen Gross wrote:
> > > libxlutil doesn't follow the standard name pattern of all other Xen
> > > libraries, so add another make variable which can be used to allow
> > > other names.
> > > 
> > > Signed-off-by: Juergen Gross <jgross@suse.com>
> > 
> > Is this still needed?
> 
> Yes. Its for the installed files, as those need to stay as they are
> today.

Acked-by: Wei Liu <wl@xen.org>


^ permalink raw reply	[flat|nested] 48+ messages in thread

* Re: [PATCH v4 31/31] tools: move libxlutil to tools/libs/util
  2020-08-28 15:07 ` [PATCH v4 31/31] tools: move libxlutil to tools/libs/util Juergen Gross
@ 2020-10-01 10:46   ` Wei Liu
  0 siblings, 0 replies; 48+ messages in thread
From: Wei Liu @ 2020-10-01 10:46 UTC (permalink / raw)
  To: Juergen Gross
  Cc: xen-devel, Andrew Cooper, George Dunlap, Ian Jackson,
	Jan Beulich, Julien Grall, Stefano Stabellini, Wei Liu,
	Anthony PERARD

On Fri, Aug 28, 2020 at 05:07:47PM +0200, Juergen Gross wrote:
> Move the libxlutil source to tools/libs/util and delete tools/libxl.
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Acked-by: Wei Liu <wl@xen.org>


^ permalink raw reply	[flat|nested] 48+ messages in thread

end of thread, other threads:[~2020-10-01 10:46 UTC | newest]

Thread overview: 48+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-28 15:07 [PATCH v4 00/31] tools: move most libraries into tools/libs Juergen Gross
2020-08-28 15:07 ` [PATCH v4 01/31] tools: generate pkg-config files from make variables Juergen Gross
2020-09-07 14:25   ` Wei Liu
2020-09-07 14:44     ` Jürgen Groß
2020-09-07 14:59       ` Wei Liu
2020-08-28 15:07 ` [PATCH v4 02/31] tools: drop explicit path specifications for qemu build Juergen Gross
2020-09-07 14:25   ` Wei Liu
2020-08-28 15:07 ` [PATCH v4 03/31] tools/python: drop libxenguest from setup.py Juergen Gross
2020-08-28 15:07 ` [PATCH v4 04/31] tools: fix pkg-config file for libxenguest Juergen Gross
2020-08-28 15:07 ` [PATCH v4 05/31] tools: don't assume libxenguest and libxenctrl to be in same directory Juergen Gross
2020-08-28 15:07 ` [PATCH v4 06/31] tools/misc: don't use libxenctrl internals from xen-hptool Juergen Gross
2020-08-28 15:07 ` [PATCH v4 07/31] tools/misc: don't include xg_save_restore.h from xen-mfndump.c Juergen Gross
2020-08-28 15:07 ` [PATCH v4 08/31] tools/misc: replace PAGE_SIZE with XC_PAGE_SIZE in xen-mfndump.c Juergen Gross
2020-08-28 15:07 ` [PATCH v4 09/31] tools/misc: drop all libxc internals from xen-mfndump.c Juergen Gross
2020-08-28 15:07 ` [PATCH v4 10/31] tools/libxc: remove unused headers xc_efi.h and xc_elf.h Juergen Gross
2020-08-28 15:07 ` [PATCH v4 11/31] tools/libxc: move xc_[un]map_domain_meminfo() into new source xg_domain.c Juergen Gross
2020-08-28 15:07 ` [PATCH v4 12/31] tools/libxc: rename all libxenguest sources to xg_* Juergen Gross
2020-08-28 15:07 ` [PATCH v4 13/31] tools/libxc: rename libxenguest internal headers Juergen Gross
2020-08-28 15:07 ` [PATCH v4 14/31] tools/misc: rename xc_dom.h do xenctrl_dom.h Juergen Gross
2020-08-28 15:07 ` [PATCH v4 15/31] tools/libxc: untangle libxenctrl from libxenguest Juergen Gross
2020-08-28 15:07 ` [PATCH v4 16/31] tools/xcutils: use official headers in readnotes Juergen Gross
2020-08-28 15:07 ` [PATCH v4 17/31] tools/xenpaging: remove libxc internals Juergen Gross
2020-08-28 15:07 ` [PATCH v4 18/31] tools: move libxenctrl below tools/libs Juergen Gross
2020-08-28 15:07 ` [PATCH v4 19/31] tools/libxc: move libxenguest to tools/libs/guest Juergen Gross
2020-08-28 15:07 ` [PATCH v4 20/31] tools: split libxenstore into new tools/libs/store directory Juergen Gross
2020-08-28 15:07 ` [PATCH v4 21/31] tools: split libxenvchan into new tools/libs/vchan directory Juergen Gross
2020-08-28 15:07 ` [PATCH v4 22/31] tools: split libxenstat into new tools/libs/stat directory Juergen Gross
2020-08-28 15:07 ` [PATCH v4 23/31] tools/libxl: fix dependencies of libxl tests Juergen Gross
2020-08-28 15:07 ` [PATCH v4 24/31] tools/libxl: don't include libxl_osdeps.h from libxlutil sources Juergen Gross
2020-08-28 15:07 ` [PATCH v4 25/31] tools/libxl: add missing items to clean target Juergen Gross
2020-08-28 15:07 ` [PATCH v4 26/31] tools/libxl: move xl parsing checks to tools/xl Juergen Gross
2020-08-28 15:07 ` [PATCH v4 27/31] tools/xl: don't assume libxl and libxlutil are in one directory Juergen Gross
2020-08-28 15:07 ` [PATCH v4 28/31] tools/libxl: move libxenlight to tools/libs/light Juergen Gross
2020-08-28 16:05   ` Wei Liu
2020-08-31  5:50     ` Jürgen Groß
2020-09-07 15:52       ` Wei Liu
2020-09-07 16:15         ` Jürgen Groß
2020-09-07 16:27           ` Wei Liu
2020-08-28 15:07 ` [PATCH v4 29/31] tools: rename global libxlutil make variables Juergen Gross
2020-09-07 15:55   ` Wei Liu
2020-09-07 16:16     ` Jürgen Groß
2020-10-01 10:45       ` Wei Liu
2020-08-28 15:07 ` [PATCH v4 30/31] tools/libs: add option for library names not starting with libxen Juergen Gross
2020-08-28 16:00   ` Wei Liu
2020-08-29  4:38     ` Jürgen Groß
2020-10-01 10:46       ` Wei Liu
2020-08-28 15:07 ` [PATCH v4 31/31] tools: move libxlutil to tools/libs/util Juergen Gross
2020-10-01 10:46   ` Wei Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.