qemu: Store all iothread's 'poll*' attributes as unsigned long long

Convert the internal types to unsigned long long. Luckily we can also
covert the external types too:

 - 'qemuDomainSetIOThreadParams' can accept both _UINT and _ULLONG by
   converting to 'virTypedParamsGetUnsigned'

 - querying is handled via the bulk stats API which is flexible:
    - we use virTypedParamListAddUnsigned to use the bigger type only if
      necessary
    - most users don't even notice because the bindings abstract the
      data types

Apart from the code modifications we also improve the documentation
which was missing for the setters.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2023-04-19 12:38:45 +02:00
parent 6d8dcc644c
commit 6f9d66c828
5 changed files with 56 additions and 39 deletions

View File

@ -2482,7 +2482,7 @@ int virDomainDelIOThread(virDomainPtr domain,
* poll_grow and poll_shrink parameters provided. A value set too large
* will cause more CPU time to be allocated the guest. A value set too
* small will not provide enough cycles for the guest to process data.
* The polling interval is not available for statistical purposes.
* Accepted type is VIR_TYPED_PARAM_ULLONG.
*
* Since: 4.10.0
*/
@ -2495,6 +2495,7 @@ int virDomainDelIOThread(virDomainPtr domain,
* use to grow its polling interval up to the poll_max_ns value. A value
* of 0 (zero) allows the hypervisor to choose its own value. The algorithm
* to use for adjustment is hypervisor specific.
* Accepted type is VIR_TYPED_PARAM_UINT or since 9.3.0 VIR_TYPED_PARAM_ULLONG.
*
* Since: 4.10.0
*/
@ -2508,6 +2509,7 @@ int virDomainDelIOThread(virDomainPtr domain,
* the poll_max_ns value. A value of 0 (zero) allows the hypervisor to
* choose its own value. The algorithm to use for adjustment is hypervisor
* specific.
* Accepted type is VIR_TYPED_PARAM_UINT or since 9.3.0 VIR_TYPED_PARAM_ULLONG.
*
* Since: 4.10.0
*/

View File

@ -12449,14 +12449,18 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
* "iothread.<id>.poll-max-ns" - maximum polling time in ns as an unsigned
* long long. A 0 (zero) means polling is
* disabled.
* "iothread.<id>.poll-grow" - polling time factor as an unsigned int.
* "iothread.<id>.poll-grow" - polling time factor as an unsigned int or
* unsigned long long if exceeding range of
* unsigned int.
* A 0 (zero) indicates to allow the underlying
* hypervisor to choose how to grow the
* polling time.
* "iothread.<id>.poll-shrink" - polling time divisor as an unsigned int.
* A 0 (zero) indicates to allow the underlying
* hypervisor to choose how to shrink the
* polling time.
* "iothread.<id>.poll-shrink" - polling time divisor as an unsigned int or
* unsigned long long if exceeding range of
* unsigned int.
* A 0 (zero) indicates to allow the underlying
* hypervisor to choose how to shrink the
* polling time.
*
* VIR_DOMAIN_STATS_MEMORY:
* Return memory bandwidth statistics and the usage information. The typed

View File

@ -5189,9 +5189,9 @@ qemuDomainIOThreadParseParams(virTypedParameterPtr params,
VIR_DOMAIN_IOTHREAD_POLL_MAX_NS,
VIR_TYPED_PARAM_ULLONG,
VIR_DOMAIN_IOTHREAD_POLL_GROW,
VIR_TYPED_PARAM_UINT,
VIR_TYPED_PARAM_UNSIGNED,
VIR_DOMAIN_IOTHREAD_POLL_SHRINK,
VIR_TYPED_PARAM_UINT,
VIR_TYPED_PARAM_UNSIGNED,
VIR_DOMAIN_IOTHREAD_THREAD_POOL_MIN,
VIR_TYPED_PARAM_INT,
VIR_DOMAIN_IOTHREAD_THREAD_POOL_MAX,
@ -5206,16 +5206,16 @@ qemuDomainIOThreadParseParams(virTypedParameterPtr params,
if (rc == 1)
iothread->set_poll_max_ns = true;
if ((rc = virTypedParamsGetUInt(params, nparams,
VIR_DOMAIN_IOTHREAD_POLL_GROW,
&iothread->poll_grow)) < 0)
if ((rc = virTypedParamsGetUnsigned(params, nparams,
VIR_DOMAIN_IOTHREAD_POLL_GROW,
&iothread->poll_grow)) < 0)
return -1;
if (rc == 1)
iothread->set_poll_grow = true;
if ((rc = virTypedParamsGetUInt(params, nparams,
VIR_DOMAIN_IOTHREAD_POLL_SHRINK,
&iothread->poll_shrink)) < 0)
if ((rc = virTypedParamsGetUnsigned(params, nparams,
VIR_DOMAIN_IOTHREAD_POLL_SHRINK,
&iothread->poll_shrink)) < 0)
return -1;
if (rc == 1)
iothread->set_poll_shrink = true;
@ -17535,12 +17535,12 @@ qemuDomainGetStatsIOThread(virQEMUDriver *driver G_GNUC_UNUSED,
virTypedParamListAddULLong(params, iothreads[i]->poll_max_ns,
"iothread.%u.poll-max-ns",
iothreads[i]->iothread_id);
virTypedParamListAddUInt(params, iothreads[i]->poll_grow,
"iothread.%u.poll-grow",
iothreads[i]->iothread_id);
virTypedParamListAddUInt(params, iothreads[i]->poll_shrink,
"iothread.%u.poll-shrink",
iothreads[i]->iothread_id);
virTypedParamListAddUnsigned(params, iothreads[i]->poll_grow,
"iothread.%u.poll-grow",
iothreads[i]->iothread_id);
virTypedParamListAddUnsigned(params, iothreads[i]->poll_shrink,
"iothread.%u.poll-shrink",
iothreads[i]->iothread_id);
}
}

View File

@ -1254,8 +1254,8 @@ struct _qemuMonitorIOThreadInfo {
int thread_id;
bool poll_valid;
unsigned long long poll_max_ns;
unsigned int poll_grow;
unsigned int poll_shrink;
unsigned long long poll_grow;
unsigned long long poll_shrink;
int thread_pool_min;
int thread_pool_max;
bool set_poll_max_ns;

View File

@ -7130,10 +7130,10 @@ qemuMonitorJSONGetIOThreads(qemuMonitor *mon,
if (virJSONValueObjectGetNumberUlong(child, "poll-max-ns",
&info->poll_max_ns) == 0 &&
virJSONValueObjectGetNumberUint(child, "poll-grow",
&info->poll_grow) == 0 &&
virJSONValueObjectGetNumberUint(child, "poll-shrink",
&info->poll_shrink) == 0)
virJSONValueObjectGetNumberUlong(child, "poll-grow",
&info->poll_grow) == 0 &&
virJSONValueObjectGetNumberUlong(child, "poll-shrink",
&info->poll_shrink) == 0)
info->poll_valid = true;
}
@ -7161,18 +7161,20 @@ qemuMonitorJSONSetIOThread(qemuMonitor *mon,
path = g_strdup_printf("/objects/iothread%u", iothreadInfo->iothread_id);
#define VIR_IOTHREAD_SET_PROP(propName, propVal) \
#define VIR_IOTHREAD_SET_PROP_UL(propName, propVal) \
if (iothreadInfo->set_##propVal) { \
memset(&prop, 0, sizeof(qemuMonitorJSONObjectProperty)); \
prop.type = QEMU_MONITOR_OBJECT_PROPERTY_INT; \
prop.val.iv = iothreadInfo->propVal; \
prop.type = QEMU_MONITOR_OBJECT_PROPERTY_ULONG; \
prop.val.ul = iothreadInfo->propVal; \
if (qemuMonitorJSONSetObjectProperty(mon, path, propName, &prop) < 0) \
return -1; \
}
VIR_IOTHREAD_SET_PROP("poll-max-ns", poll_max_ns);
VIR_IOTHREAD_SET_PROP("poll-grow", poll_grow);
VIR_IOTHREAD_SET_PROP("poll-shrink", poll_shrink);
VIR_IOTHREAD_SET_PROP_UL("poll-max-ns", poll_max_ns);
VIR_IOTHREAD_SET_PROP_UL("poll-grow", poll_grow);
VIR_IOTHREAD_SET_PROP_UL("poll-shrink", poll_shrink);
#undef VIR_IOTHREAD_SET_PROP_UL
if (iothreadInfo->set_thread_pool_min &&
iothreadInfo->set_thread_pool_max) {
@ -7192,15 +7194,24 @@ qemuMonitorJSONSetIOThread(qemuMonitor *mon,
setMaxFirst = true;
}
if (setMaxFirst) {
VIR_IOTHREAD_SET_PROP("thread-pool-max", thread_pool_max);
VIR_IOTHREAD_SET_PROP("thread-pool-min", thread_pool_min);
} else {
VIR_IOTHREAD_SET_PROP("thread-pool-min", thread_pool_min);
VIR_IOTHREAD_SET_PROP("thread-pool-max", thread_pool_max);
#define VIR_IOTHREAD_SET_PROP_INT(propName, propVal) \
if (iothreadInfo->set_##propVal) { \
memset(&prop, 0, sizeof(qemuMonitorJSONObjectProperty)); \
prop.type = QEMU_MONITOR_OBJECT_PROPERTY_INT; \
prop.val.iv = iothreadInfo->propVal; \
if (qemuMonitorJSONSetObjectProperty(mon, path, propName, &prop) < 0) \
return -1; \
}
#undef VIR_IOTHREAD_SET_PROP
if (setMaxFirst) {
VIR_IOTHREAD_SET_PROP_INT("thread-pool-max", thread_pool_max);
VIR_IOTHREAD_SET_PROP_INT("thread-pool-min", thread_pool_min);
} else {
VIR_IOTHREAD_SET_PROP_INT("thread-pool-min", thread_pool_min);
VIR_IOTHREAD_SET_PROP_INT("thread-pool-max", thread_pool_max);
}
#undef VIR_IOTHREAD_SET_PROP_INT
return 0;
}