virsh qemu-monitor-command 1 '{"execute":"object-add", "arguments":{"qom-= type":"throttle-group","id":"limit0","limits":{"iops-total":200,"iops-rea= d":0,"iops-total-max":200,"iops-total-max-length":1}}}' virsh qemu-monitor-command 1 '{"execute":"object-add", "arguments":{"qom-= type":"throttle-group","id":"limit1","limits":{"iops-total":250,"iops-rea= d":0,"iops-total-max":250,"iops-total-max-length":1}}}' virsh qemu-monitor-command 1 '{"execute":"object-add", "arguments":{"qom-= type":"throttle-group","id":"limit2","limits":{"iops-total":300,"iops-rea= d":0,"iops-total-max":300,"iops-total-max-length":1}}}' virsh qemu-monitor-command 1 '{"execute":"object-add", "arguments":{"qom-= type":"throttle-group","id":"limit012","limits":{"iops-total":400,"iops-r= ead":0,"iops-total-max":400,"iops-total-max-length":1}}}' - Chain up filters during attaching disk to apply two filters(limit0 and = limit012): virsh qemu-monitor-command 1 '{"execute":"blockdev-add", "arguments": {"= driver":"file","filename":"/virt/disks/vm1_disk_1.qcow2","node-name":"tes= t-3-storage","auto-read-only":true,"discard":"unmap"}}' =20 virsh qemu-monitor-command 1 '{"execute":"blockdev-add", "arguments":{"no= de-name":"test-4-format","read-only":false,"driver":"qcow2","file":"test-= 3-storage","backing":null}}' =20 virsh qemu-monitor-command 1 '{"execute":"blockdev-add", "arguments":{"dr= iver":"throttle","node-name":"libvirt-5-filter","throttle-group": "limit0= ","file":"test-4-format"}}' virsh qemu-monitor-command 1 '{"execute":"blockdev-add", "arguments": {"d= river":"throttle","node-name":"libvirt-6-filter","throttle-group":"limit0= 12","file":"libvirt-5-filter"}}' virsh qemu-monitor-command 1 '{"execute": "device_add", "arguments": {"dr= iver":"virtio-blk-pci","scsi":false,"bus":"pci.0","addr":"0x5","drive":"l= ibvirt-6-filter","id":"virtio-disk1"}}' This patchset includes: - Throttle group XML schema definition in patch 1 - Throttle filter XML schema definition in patch 2 - Throttle group struct definition, parsing and formating in patch 3 - Throttle filter struct definition, parsing and formating in patch 4 - New QMP processing to update and get throttle group in patch 5&6 - New API definition and implementation in patch 7 - QEMU driver implementation in patch 8 - Hotplug processing for throttle filters in patch 9 - Extract common iotune validation in patch 10 - qemuProcessLaunch flow implemenation for throttle group in patch 11 - qemuProcessLaunch flow implemenation for throttle filter in patch 12 - Domain XML test for processing throttle groups and filters in patch 13 - Test new implemented driver in patch 14 - New virsh cmd implementation for group in patch 15 - Update Virsh cmd "attach_disk" to include throttle filters in patch 16 v3 changes: - re-org commits by splitting changes containing throttle group and filte= rs - update commits msgs - move schema commits to be the first ones - refactor "diskIoTune" to extract common schema "iotune" - add new tests for throttle groups and filters in qemuxmlconftest - check flag "QEMU_CAPS_OBJECT_JSON" when preparing "-object"(qemu: comma= nd: Support throttle groups during qemuProcessLaunch ) or creating thrott= le group (qemu: Implement qemu driver for throttle API) - when creating throttle group through "object-add" (qemu: Implement qemu= driver for throttle API), reuse "qemuMonitorAddObject" to check if "obje= ctAddNoWrap"("props") is requried - remove "virObject parent;" in "_virDomainThrottleFilterDef" in domain_c= onf.h - remove "virDomainThrottleGroupIndexByName" in both domain_conf.h and do= main_conf.c - remove "virDomainThrottleFilterDefNew" in domain_conf.c - update "virDomainThrottleFilterDefFree" to use "g_free" rather than "VI= R_FREE" in domain_conf.c - update "virDomainDiskThrottleFilterDefParse" to remove "xmlXPathContext= Ptr ctx" parameter and check NULL against "filter->group_name" in domain_= conf.c - use "virBufferEscapeString" instead of "virBufferAsprintf" in "virDomai= nDiskDefFormatThrottleFilterChain" - use "group->val > 0" instead of "if (group->val)" in FORMAT_THROTTLE_GR= OUP - remove NULL check for "group->group_name" since virBufferEscapeString c= hecked NULL already in "virDomainThrottleGroupFormat" - I haven't added new conf module (src/conf/virdomainthrottle.c/h) becaus= e "virDomainThrottleGroupDef" is alias of "_virDomainBlockIoTuneInfo", tr= y to avoid circular dependency - remove "NULLSTR" in qemuMonitorUpdateThrottleGroup and qemuMonitorGetTh= rottleGroup in qemu_monitor.c - refactor "qemuMonitorMakeThrottleGroupLimits" to use virJSONValueObject= Add in qemu_monitor_json.c - use "g_strdup_printf" to avoid static buffers in "qemuMonitorJSONGetThr= ottleGroup" - remove virReportError after qemuMonitorJSONGetReply in "qemuMonitorJSON= GetThrottleGroup" to avoid overriding error - remove "VIR_DOMAIN_THROTTLE_GROUP" in libvirt/include/libvirt/libvirt-d= omain.h - update "virDomainGetThrottleGroup" to not first query the number of par= ameters,=20 - update "remote_domain_get_throttle_group_args" and "remote_domain_get_t= hrottle_group_ret" to remove "nparams" in src/remote_protocol-structs, al= so updated "remote_domain_get_throttle_group_args" and "remote_domain_get= _throttle_group_ret" in src/remote/remote_protocol.x - update parameter "virTypedParameterPtr params" to be "virTypedParameter= Ptr *params" in "virDrvDomainGetThrottleGroup" in driver-hypervisor.h - update "qemuDomainSetThrottleGroup" to not query number of parameters f= irst - remove wrapper "qemuDomainThrottleGroupByName" and "qemuDomainSetThrott= leGroupDefaults" - refactor "qemuDomainSetThrottleGroup" and "qemuDomainSetBlockIoTune" to= use common logic - update "qemuDomainDelThrottleGroup" to use VIR_JOB_MODIFY by referenci= ng "qemuDomainHotplugDelIOThread" - check if group is still being used by some filter(qemuDomainCheckThrott= leGroupRef) during deletion - replace "ThrottleFilterChain" with "ThrottleFilters" - update "qemuDomainDiskGetTopNodename" to take top throttle node name if= disk has throttles, and reuse "qemuDomainDiskGetBackendAlias" in "qemuBu= ildDiskDeviceProps" to get top node name as "drive" - after enabling throttlerfilter and if disk has throttlefilters, during = blockcommit, the top node name is not "libvirt-x-format" anymore, instead= , top node name referencies top filter like "libvirt-x-filter" - add check "cdrom device with throttle filters isn't supported" - delete "filternodenameindex" and reuse "nodenameindex" to generate inde= x for throttle nodes - refactor detaching filters by adding "qemuBuildThrottleFiltersDetachPre= pareBlockdev" to just build parameters for "blockdev-del" - refactor "testDomainSetBlockIoTune" and "testDomainSetThrottleGroup" to= use common logic Any comments/suggestions will be appriciated! Chun Feng Wu (16): schema: Add new domain elements to support multiple throttle groups schema: Add new domain elements to support multiple throttle filters config: Introduce ThrottleGroup and corresponding XML parsing config: Introduce ThrottleFilter and corresponding XML parsing qemu: monitor: Add support for ThrottleGroup operations tests: Test qemuMonitorJSONGetThrottleGroup and qemuMonitorJSONUpdateThrottleGroup remote: New APIs for ThrottleGroup lifecycle management qemu: Implement qemu driver for throttle API qemu: hotplug: Support hot attach and detach block disk along with throttle filters config: validate: Refactor disk iotune validation for reuse qemu: command: Support throttle groups during qemuProcessLaunch qemu: command: Support throttle filters during qemuProcessLaunch qemuxmlconftest: Add 'throttlefilter' tests test_driver: Test throttle group lifecycle APIs virsh: Add support for throttle group operations virsh: Add option "throttle-groups" to "attach_disk" docs/formatdomain.rst | 48 ++ include/libvirt/libvirt-domain.h | 21 + src/conf/domain_conf.c | 376 +++++++++++ src/conf/domain_conf.h | 51 ++ src/conf/domain_validate.c | 118 +++- src/conf/schemas/domaincommon.rng | 293 +++++---- src/conf/virconftypes.h | 4 + src/driver-hypervisor.h | 22 + src/libvirt-domain.c | 196 ++++++ src/libvirt_private.syms | 9 + src/libvirt_public.syms | 7 + src/qemu/qemu_block.c | 131 ++++ src/qemu/qemu_block.h | 53 ++ src/qemu/qemu_command.c | 182 ++++++ src/qemu/qemu_command.h | 12 + src/qemu/qemu_domain.c | 39 +- src/qemu/qemu_domain.h | 8 + src/qemu/qemu_driver.c | 617 +++++++++++++++--- src/qemu/qemu_hotplug.c | 33 + src/qemu/qemu_monitor.c | 34 + src/qemu/qemu_monitor.h | 14 + src/qemu/qemu_monitor_json.c | 150 +++++ src/qemu/qemu_monitor_json.h | 14 + src/remote/remote_daemon_dispatch.c | 44 ++ src/remote/remote_driver.c | 40 ++ src/remote/remote_protocol.x | 48 +- src/remote_protocol-structs | 28 + src/test/test_driver.c | 452 +++++++++---- tests/qemumonitorjsontest.c | 86 +++ .../throttlefilter.x86_64-latest.args | 43 ++ .../throttlefilter.x86_64-latest.xml | 65 ++ tests/qemuxmlconfdata/throttlefilter.xml | 55 ++ tests/qemuxmlconftest.c | 1 + tools/virsh-completer-domain.c | 64 ++ tools/virsh-completer-domain.h | 5 + tools/virsh-domain.c | 453 ++++++++++++- 36 files changed, 3447 insertions(+), 369 deletions(-) create mode 100644 tests/qemuxmlconfdata/throttlefilter.x86_64-latest.ar= gs create mode 100644 tests/qemuxmlconfdata/throttlefilter.x86_64-latest.xm= l create mode 100644 tests/qemuxmlconfdata/throttlefilter.xml --=20 2.34.1