mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
iothread: generalize iothread_set_param/iothread_get_param
Changes in preparation for next patches where we add a new parameter not related to the poll mechanism. Let's add two new generic functions (iothread_set_param and iothread_get_param) that we use to set and get IOThread parameters. Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Message-id: 20210721094211.69853-2-sgarzare@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
801f3db756
commit
0445409d74
1 changed files with 23 additions and 4 deletions
27
iothread.c
27
iothread.c
|
@ -213,7 +213,7 @@ static PollParamInfo poll_shrink_info = {
|
|||
"poll-shrink", offsetof(IOThread, poll_shrink),
|
||||
};
|
||||
|
||||
static void iothread_get_poll_param(Object *obj, Visitor *v,
|
||||
static void iothread_get_param(Object *obj, Visitor *v,
|
||||
const char *name, void *opaque, Error **errp)
|
||||
{
|
||||
IOThread *iothread = IOTHREAD(obj);
|
||||
|
@ -223,7 +223,7 @@ static void iothread_get_poll_param(Object *obj, Visitor *v,
|
|||
visit_type_int64(v, name, field, errp);
|
||||
}
|
||||
|
||||
static void iothread_set_poll_param(Object *obj, Visitor *v,
|
||||
static bool iothread_set_param(Object *obj, Visitor *v,
|
||||
const char *name, void *opaque, Error **errp)
|
||||
{
|
||||
IOThread *iothread = IOTHREAD(obj);
|
||||
|
@ -232,17 +232,36 @@ static void iothread_set_poll_param(Object *obj, Visitor *v,
|
|||
int64_t value;
|
||||
|
||||
if (!visit_type_int64(v, name, &value, errp)) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value < 0) {
|
||||
error_setg(errp, "%s value must be in range [0, %" PRId64 "]",
|
||||
info->name, INT64_MAX);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
*field = value;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void iothread_get_poll_param(Object *obj, Visitor *v,
|
||||
const char *name, void *opaque, Error **errp)
|
||||
{
|
||||
|
||||
iothread_get_param(obj, v, name, opaque, errp);
|
||||
}
|
||||
|
||||
static void iothread_set_poll_param(Object *obj, Visitor *v,
|
||||
const char *name, void *opaque, Error **errp)
|
||||
{
|
||||
IOThread *iothread = IOTHREAD(obj);
|
||||
|
||||
if (!iothread_set_param(obj, v, name, opaque, errp)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (iothread->ctx) {
|
||||
aio_context_set_poll_params(iothread->ctx,
|
||||
iothread->poll_max_ns,
|
||||
|
|
Loading…
Reference in a new issue