It will be used as a replacement for macros code adding event params. Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx> --- src/conf/domain_conf.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ src/conf/domain_conf.h | 7 +++++++ src/libvirt_private.syms | 1 + 3 files changed, 61 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index aa6a2a8..7e91654 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -31773,6 +31773,59 @@ virDomainBlockIoTuneFromParams(virTypedParameterPtr params, } +static const char* virDomainBlockIoTuneFieldEventNames[] = { + VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_BYTES_SEC, + VIR_DOMAIN_TUNABLE_BLKDEV_READ_BYTES_SEC, + VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_BYTES_SEC, + VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_IOPS_SEC, + VIR_DOMAIN_TUNABLE_BLKDEV_READ_IOPS_SEC, + VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_IOPS_SEC, + VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_BYTES_SEC_MAX, + VIR_DOMAIN_TUNABLE_BLKDEV_READ_BYTES_SEC_MAX, + VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_BYTES_SEC_MAX, + VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_IOPS_SEC_MAX, + VIR_DOMAIN_TUNABLE_BLKDEV_READ_IOPS_SEC_MAX, + VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_IOPS_SEC_MAX, + VIR_DOMAIN_TUNABLE_BLKDEV_SIZE_IOPS_SEC, + VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_BYTES_SEC_MAX_LENGTH, + VIR_DOMAIN_TUNABLE_BLKDEV_READ_BYTES_SEC_MAX_LENGTH, + VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_BYTES_SEC_MAX_LENGTH, + VIR_DOMAIN_TUNABLE_BLKDEV_TOTAL_IOPS_SEC_MAX_LENGTH, + VIR_DOMAIN_TUNABLE_BLKDEV_READ_IOPS_SEC_MAX_LENGTH, + VIR_DOMAIN_TUNABLE_BLKDEV_WRITE_IOPS_SEC_MAX_LENGTH, +}; + + +int +virDomainBlockIoTuneToEventParams(virDomainBlockIoTuneInfoPtr iotune, + virDomainBlockIoTuneInfoPtr set, + virTypedParameterPtr *params, + int *nparams, + int *maxparams) +{ + g_autofree unsigned long long **fields = virDomainBlockIoTuneFields(iotune); + g_autofree unsigned long long **set_fields = virDomainBlockIoTuneFields(set); + size_t i; + + for (i = 0; i < G_N_ELEMENTS(virDomainBlockIoTuneFieldEventNames); i++) { + const char *name = virDomainBlockIoTuneFieldEventNames[i]; + + if (*set_fields[i] && + virTypedParamsAddULLong(params, nparams, maxparams, + name, *fields[i]) < 0) + return -1; + } + + if (iotune->group_name && + virTypedParamsAddString(params, nparams, maxparams, + VIR_DOMAIN_TUNABLE_BLKDEV_GROUP_NAME, + iotune->group_name) < 0) + return -1; + + return 0; +} + + /** * virHostdevIsSCSIDevice: * @hostdev: host device to check diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e511939..ea18720 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3955,6 +3955,13 @@ virDomainBlockIoTuneFromParams(virTypedParameterPtr params, virDomainBlockIoTuneInfoPtr iotune, virDomainBlockIoTuneInfoPtr set); +int +virDomainBlockIoTuneToEventParams(virDomainBlockIoTuneInfoPtr iotune, + virDomainBlockIoTuneInfoPtr set, + virTypedParameterPtr *params, + int *nparams, + int *maxparams); + bool virDomainDriveAddressIsUsedByDisk(const virDomainDef *def, virDomainDiskBus bus_type, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index bc42df0..e71b580 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -237,6 +237,7 @@ virDomainBlockIoTuneInfoHasAny; virDomainBlockIoTuneInfoHasBasic; virDomainBlockIoTuneInfoHasMax; virDomainBlockIoTuneInfoHasMaxLength; +virDomainBlockIoTuneToEventParams; virDomainBlockIoTuneValidate; virDomainBootTypeFromString; virDomainBootTypeToString; -- 1.8.3.1