mirror of
https://github.com/mii443/qemu.git
synced 2025-12-07 04:58:25 +00:00
util/main-loop: Introduce the main loop into QOM
'event-loop-base' provides basic property handling for all 'AioContext'
based event loops. So let's define a new 'MainLoopClass' that inherits
from it. This will permit tweaking the main loop's properties through
qapi as well as through the command line using the '-object' keyword[1].
Only one instance of 'MainLoopClass' might be created at any time.
'EventLoopBaseClass' learns a new callback, 'can_be_deleted()' so as to
mark 'MainLoop' as non-deletable.
[1] For example:
-object main-loop,id=main-loop,aio-max-batch=<value>
Signed-off-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Acked-by: Markus Armbruster <armbru@redhat.com>
Message-id: 20220425075723.20019-3-nsaenzju@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
committed by
Stefan Hajnoczi
parent
7d5983e3c8
commit
70ac26b9e5
@@ -73,10 +73,23 @@ static void event_loop_base_complete(UserCreatable *uc, Error **errp)
|
||||
}
|
||||
}
|
||||
|
||||
static bool event_loop_base_can_be_deleted(UserCreatable *uc)
|
||||
{
|
||||
EventLoopBaseClass *bc = EVENT_LOOP_BASE_GET_CLASS(uc);
|
||||
EventLoopBase *backend = EVENT_LOOP_BASE(uc);
|
||||
|
||||
if (bc->can_be_deleted) {
|
||||
return bc->can_be_deleted(backend);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void event_loop_base_class_init(ObjectClass *klass, void *class_data)
|
||||
{
|
||||
UserCreatableClass *ucc = USER_CREATABLE_CLASS(klass);
|
||||
ucc->complete = event_loop_base_complete;
|
||||
ucc->can_be_deleted = event_loop_base_can_be_deleted;
|
||||
|
||||
object_class_property_add(klass, "aio-max-batch", "int",
|
||||
event_loop_base_get_param,
|
||||
|
||||
Reference in New Issue
Block a user