Skip to content

Commit 0445409

Browse files
stefano-garzarellastefanhaRH
authored andcommitted
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 <[email protected]> Message-id: [email protected] Signed-off-by: Stefan Hajnoczi <[email protected]>
1 parent 801f3db commit 0445409

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

iothread.c

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ static PollParamInfo poll_shrink_info = {
213213
"poll-shrink", offsetof(IOThread, poll_shrink),
214214
};
215215

216-
static void iothread_get_poll_param(Object *obj, Visitor *v,
216+
static void iothread_get_param(Object *obj, Visitor *v,
217217
const char *name, void *opaque, Error **errp)
218218
{
219219
IOThread *iothread = IOTHREAD(obj);
@@ -223,7 +223,7 @@ static void iothread_get_poll_param(Object *obj, Visitor *v,
223223
visit_type_int64(v, name, field, errp);
224224
}
225225

226-
static void iothread_set_poll_param(Object *obj, Visitor *v,
226+
static bool iothread_set_param(Object *obj, Visitor *v,
227227
const char *name, void *opaque, Error **errp)
228228
{
229229
IOThread *iothread = IOTHREAD(obj);
@@ -232,17 +232,36 @@ static void iothread_set_poll_param(Object *obj, Visitor *v,
232232
int64_t value;
233233

234234
if (!visit_type_int64(v, name, &value, errp)) {
235-
return;
235+
return false;
236236
}
237237

238238
if (value < 0) {
239239
error_setg(errp, "%s value must be in range [0, %" PRId64 "]",
240240
info->name, INT64_MAX);
241-
return;
241+
return false;
242242
}
243243

244244
*field = value;
245245

246+
return true;
247+
}
248+
249+
static void iothread_get_poll_param(Object *obj, Visitor *v,
250+
const char *name, void *opaque, Error **errp)
251+
{
252+
253+
iothread_get_param(obj, v, name, opaque, errp);
254+
}
255+
256+
static void iothread_set_poll_param(Object *obj, Visitor *v,
257+
const char *name, void *opaque, Error **errp)
258+
{
259+
IOThread *iothread = IOTHREAD(obj);
260+
261+
if (!iothread_set_param(obj, v, name, opaque, errp)) {
262+
return;
263+
}
264+
246265
if (iothread->ctx) {
247266
aio_context_set_poll_params(iothread->ctx,
248267
iothread->poll_max_ns,

0 commit comments

Comments
 (0)