iothread: use IOThreadParamInfo in iothread_[set|get]_param()

Commit 0445409d74 ("iothread: generalize
iothread_set_param/iothread_get_param") moved common code to set and
get IOThread parameters in two new functions.

These functions are called inside callbacks, so we don't need to use an
opaque pointer. Let's replace `void *opaque` parameter with
`IOThreadParamInfo *info`.

Suggested-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20210727145936.147032-3-sgarzare@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Stefano Garzarella 2021-07-27 16:59:36 +02:00 committed by Stefan Hajnoczi
parent f0ed36a64f
commit 1cc7eada97

View File

@ -231,20 +231,18 @@ static IOThreadParamInfo aio_max_batch_info = {
}; };
static void iothread_get_param(Object *obj, Visitor *v, static void iothread_get_param(Object *obj, Visitor *v,
const char *name, void *opaque, Error **errp) const char *name, IOThreadParamInfo *info, Error **errp)
{ {
IOThread *iothread = IOTHREAD(obj); IOThread *iothread = IOTHREAD(obj);
IOThreadParamInfo *info = opaque;
int64_t *field = (void *)iothread + info->offset; int64_t *field = (void *)iothread + info->offset;
visit_type_int64(v, name, field, errp); visit_type_int64(v, name, field, errp);
} }
static bool iothread_set_param(Object *obj, Visitor *v, static bool iothread_set_param(Object *obj, Visitor *v,
const char *name, void *opaque, Error **errp) const char *name, IOThreadParamInfo *info, Error **errp)
{ {
IOThread *iothread = IOTHREAD(obj); IOThread *iothread = IOTHREAD(obj);
IOThreadParamInfo *info = opaque;
int64_t *field = (void *)iothread + info->offset; int64_t *field = (void *)iothread + info->offset;
int64_t value; int64_t value;
@ -266,16 +264,18 @@ static bool iothread_set_param(Object *obj, Visitor *v,
static void iothread_get_poll_param(Object *obj, Visitor *v, static void iothread_get_poll_param(Object *obj, Visitor *v,
const char *name, void *opaque, Error **errp) const char *name, void *opaque, Error **errp)
{ {
IOThreadParamInfo *info = opaque;
iothread_get_param(obj, v, name, opaque, errp); iothread_get_param(obj, v, name, info, errp);
} }
static void iothread_set_poll_param(Object *obj, Visitor *v, static void iothread_set_poll_param(Object *obj, Visitor *v,
const char *name, void *opaque, Error **errp) const char *name, void *opaque, Error **errp)
{ {
IOThread *iothread = IOTHREAD(obj); IOThread *iothread = IOTHREAD(obj);
IOThreadParamInfo *info = opaque;
if (!iothread_set_param(obj, v, name, opaque, errp)) { if (!iothread_set_param(obj, v, name, info, errp)) {
return; return;
} }
@ -291,16 +291,18 @@ static void iothread_set_poll_param(Object *obj, Visitor *v,
static void iothread_get_aio_param(Object *obj, Visitor *v, static void iothread_get_aio_param(Object *obj, Visitor *v,
const char *name, void *opaque, Error **errp) const char *name, void *opaque, Error **errp)
{ {
IOThreadParamInfo *info = opaque;
iothread_get_param(obj, v, name, opaque, errp); iothread_get_param(obj, v, name, info, errp);
} }
static void iothread_set_aio_param(Object *obj, Visitor *v, static void iothread_set_aio_param(Object *obj, Visitor *v,
const char *name, void *opaque, Error **errp) const char *name, void *opaque, Error **errp)
{ {
IOThread *iothread = IOTHREAD(obj); IOThread *iothread = IOTHREAD(obj);
IOThreadParamInfo *info = opaque;
if (!iothread_set_param(obj, v, name, opaque, errp)) { if (!iothread_set_param(obj, v, name, info, errp)) {
return; return;
} }