On 12/4/19 3:20 PM, Daniel P. Berrangé wrote:
> The virCapsPtr object is a serious source of performance problems for
> the QEMU driver, because populating it means probing every QEMU system
> emulator binary installed on the host.
>
> This is is crazy because parsing any single XML document only ever needs
> information about a single QEMU binary.
>
> We've already done a great job of untangling stuff with the post-parse
> and validation functions, but the job was never quite finished. This
> series tackles the last pieces so that parsing & formatting XML will
> never use the virCapsPtr object directly. Some of the virt drivers will
> still use virCapsPtr in their private callbacks, but the QEMU driver
> will instead use the QEMU emulator capabilities cache directly.
>
> The first ten patches are the key bits of work to remove use of the
> virCapsPtr parameter from domain XML APIs.
>
> The next thirteen patches remove the (now unused) virCapsPtr parameter
> from the domain XML APIs & their callers.
>
> The final six patches help various QEMU driver APIs stop relying
> on the virCapsPtr, so that it is no longer even created at startup.
>
> This has a nice benefit on libvirtd startup tie when all 30 QEMU
> emulators are installed, reducing it from 4 seconds down to a
> fraction of a second.
>
> More work is still needed to follow on from this...
>
> A couple of places in the QEMU driver still use virCapsPtr
>
> - The virConnectGetVersion API.
> - The virNodeGetSecurityModel API.
> - virDomainGetResctrlMonData API.
>
> In all cases we just need to move to store the relevant data directly
> in virQEMUDriverPtr, and not use the virCaps.
>
>
> next, apps can use virDomainGetCapabilities to fetch info about a
> specific QEMU binary they care about to avoid the cost of the
> virConnectGetCapabilities API.
>
> There are still times when apps need info in virConnectGetCapabilities
> and this will annoyingly probe all QEMU binaries, even though the app
> doesn't want the guest info.
>
> virConnectGetCapabilities is one of our very early APIs which now flags
> parameter, so this problem is unfixable in that API.
>
> I'm thus included to introduce a new virNodeGetCapabilities that is
> specifically only returning information about the host hypervisor.
> Essentially the <capabilities> schema, but only the <host> sub-tree.
>
> I do, however, wonder if even this is overkill & we should aim for a
> much more fine grained way for reporting host capabilities.
>
> eg if an app wants the host CPU, do they really want to pay the
> penality to probe host cache nformation, or NUMA topology and
> vica-verca.
>
> I'm not sure what the right kind of tradeoff here is, whether we should
> try individual APIs, or have one API and a set of flags to control what
> info is filled in.
>
> Daniel P. Berrangé (30):
> qemu: cache host arch separately from virCapsPtr
> qemu: add machines & arch to fake test capabilities cache
> conf: sanitize virDomainSaveStatus & virDomainSaveConfig APIs
> conf: sanitize virDomainObjFormat & virDomainDefFormat* APIs
> conf: pass in default architecture via domain XML options
> conf: move virt type / os type / arch validation to post-parse
> conf: don't use passed in caps in post parse method
> conf: pass netprefix in the domain parser config struct
> conf: move seclabel validation into post-parse phase
> conf: pass default sec model in parser config
> conf: drop virCapsPtr param from assign addresses callback
> conf: drop virCapsPtr param from basic post parse callback
> conf: drop virCapsPtr param from post parse data alloc callback
> conf: drop virCapsPtr param from post parse callback
> conf: drop virCapsPtr param from device post parse callback
> conf: drop virCapsPtr param from domain validate callback
> conf: drop virCapsPtr param from domain formatting APIs
> conf: drop virCapsPtr param from domain post parse & validate APIs
> conf: drop virCapsPtr param from domain parse APIs
> conf: drop virCapsPtr param from domain APIs for copying config
> conf: drop virCapsPtr param from APIs for saving domains
> conf: drop virCapsPtr param from domain obj list APIs
> conf: drop virCapsPtr param from snapshot & checkpoint APIs
> qemu: drop virCapsPtr param & vars from many APIs
> conf: move NUMA capabilities into self contained object
> qemu: use NUMA capabilities object directly
> conf: make virCPUDef into a ref counted struct
> qemu: use host CPU object directly
> qemu: directly create virResctrlInfo ignoring capabilities
> qemu: stop creating capabilities at driver startup
>
> docs/formatdomain.html.in | 6 +-
> src/bhyve/bhyve_domain.c | 16 +-
> src/bhyve/bhyve_driver.c | 46 +-
> src/bhyve/bhyve_process.c | 22 +-
> src/conf/capabilities.c | 217 +++++---
> src/conf/capabilities.h | 34 +-
> src/conf/checkpoint_conf.c | 21 +-
> src/conf/checkpoint_conf.h | 2 -
> src/conf/cpu_conf.c | 29 +-
> src/conf/cpu_conf.h | 4 +
> src/conf/domain_conf.c | 404 ++++++--------
> src/conf/domain_conf.h | 84 ++-
> src/conf/snapshot_conf.c | 28 +-
> src/conf/snapshot_conf.h | 3 -
> src/conf/virconftypes.h | 3 +
> src/conf/virdomainobjlist.c | 9 +-
> src/conf/virdomainobjlist.h | 1 -
> src/cpu/cpu.c | 3 +-
> src/cpu/cpu_arm.c | 5 +-
> src/cpu/cpu_ppc64.c | 3 +-
> src/cpu/cpu_x86.c | 6 +-
> src/esx/esx_driver.c | 14 +-
> src/hyperv/hyperv_driver.c | 1 +
> src/libvirt_private.syms | 18 +-
> src/libxl/libxl_capabilities.c | 23 +-
> src/libxl/libxl_conf.c | 3 +-
> src/libxl/libxl_conf.h | 2 +-
> src/libxl/libxl_domain.c | 37 +-
> src/libxl/libxl_driver.c | 83 ++-
> src/libxl/libxl_migration.c | 20 +-
> src/libxl/xen_xl.c | 13 +-
> src/libxl/xen_xm.c | 2 +-
> src/lxc/lxc_conf.c | 9 +-
> src/lxc/lxc_conf.h | 2 +-
> src/lxc/lxc_controller.c | 44 +-
> src/lxc/lxc_domain.c | 13 +-
> src/lxc/lxc_driver.c | 98 ++--
> src/lxc/lxc_native.c | 4 +-
> src/lxc/lxc_process.c | 20 +-
> src/openvz/openvz_conf.c | 62 ++-
> src/openvz/openvz_conf.h | 1 +
> src/openvz/openvz_driver.c | 64 +--
> src/phyp/phyp_driver.c | 26 +-
> src/qemu/qemu_capabilities.c | 176 ++++---
> src/qemu/qemu_capabilities.h | 12 +-
> src/qemu/qemu_capspriv.h | 10 +
> src/qemu/qemu_checkpoint.c | 32 +-
> src/qemu/qemu_checkpoint.h | 1 -
> src/qemu/qemu_command.c | 6 +-
> src/qemu/qemu_conf.c | 57 +-
> src/qemu/qemu_conf.h | 18 +-
> src/qemu/qemu_domain.c | 108 ++--
> src/qemu/qemu_domain.h | 1 -
> src/qemu/qemu_driver.c | 293 ++++-------
> src/qemu/qemu_hotplug.c | 8 +-
> src/qemu/qemu_migration.c | 36 +-
> src/qemu/qemu_migration_cookie.c | 8 +-
> src/qemu/qemu_process.c | 196 +++----
> src/security/virt-aa-helper.c | 2 +-
> src/test/test_driver.c | 45 +-
> src/util/virresctrl.h | 2 +
> src/vbox/vbox_common.c | 16 +-
> src/vmware/vmware_conf.c | 2 +-
> src/vmware/vmware_driver.c | 25 +-
> src/vmx/vmx.c | 23 +-
> src/vmx/vmx.h | 2 +-
> src/vz/vz_driver.c | 29 +-
> tests/Makefile.am | 17 +-
> tests/bhyveargv2xmltest.c | 2 +-
> tests/bhyvexml2argvtest.c | 2 +-
> tests/cputest.c | 11 +-
> tests/domaincapstest.c | 14 +-
> tests/domainconftest.c | 2 +-
> tests/libxlxml2domconfigtest.c | 22 +-
> tests/lxcconf2xmltest.c | 17 +-
> tests/lxcxml2xmltest.c | 13 +-
> tests/openvzutilstest.c | 8 +-
> tests/qemuagenttest.c | 2 +-
> tests/qemublocktest.c | 2 +-
> tests/qemucapabilitiestest.c | 9 +-
> tests/qemudomaincheckpointxml2xmltest.c | 4 +-
> tests/qemudomainsnapshotxml2xmltest.c | 4 +-
> tests/qemuhotplugtest.c | 11 +-
> tests/qemumemlocktest.c | 6 +-
> tests/qemusecuritytest.c | 1 -
> tests/qemuxml2argvtest.c | 35 +-
> tests/qemuxml2xmltest.c | 4 +-
> tests/securityselinuxlabeltest.c | 2 +-
> tests/testutils.c | 39 +-
> tests/testutils.h | 5 +-
> tests/testutilslxc.c | 34 +-
> tests/testutilslxc.h | 4 +
> tests/testutilsqemu.c | 670 +++++++-----------------
> tests/testutilsqemu.h | 9 +-
> tests/testutilsxen.c | 34 +-
> tests/testutilsxen.h | 9 +-
> tests/vircaps2xmltest.c | 6 +-
> tests/vircapstest.c | 11 +-
> tests/vmx2xmltest.c | 4 +-
> tests/xlconfigtest.c | 27 +-
> tests/xmconfigtest.c | 23 +-
> tests/xml2vmxtest.c | 4 +-
> 102 files changed, 1687 insertions(+), 1993 deletions(-)
>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Michal
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list