99c147e2 | 17-Jun-2024 |
Fabiano Rosas <farosas@suse.de> |
monitor: fdset: Match against O_DIRECT
We're about to enable the use of O_DIRECT in the migration code and due to the alignment restrictions imposed by filesystems we need to make sure the flag is o
monitor: fdset: Match against O_DIRECT
We're about to enable the use of O_DIRECT in the migration code and due to the alignment restrictions imposed by filesystems we need to make sure the flag is only used when doing aligned IO.
The migration will do parallel IO to different regions of a file, so we need to use more than one file descriptor. Those cannot be obtained by duplicating (dup()) since duplicated file descriptors share the file status flags, including O_DIRECT. If one migration channel does unaligned IO while another sets O_DIRECT to do aligned IO, the filesystem would fail the unaligned operation.
The add-fd QMP command along with the fdset code are specifically designed to allow the user to pass a set of file descriptors with different access flags into QEMU to be later fetched by code that needs to alternate between those flags when doing IO.
Extend the fdset matching to behave the same with the O_DIRECT flag.
Reviewed-by: Peter Xu <peterx@redhat.com> Signed-off-by: Fabiano Rosas <farosas@suse.de>
show more ...
|
881172f3 | 17-Jun-2024 |
Fabiano Rosas <farosas@suse.de> |
monitor: Simplify fdset and fd removal
Remove fds right away instead of setting the ->removed flag. We don't need the extra complexity of having a cleanup function reap the removed entries at a late
monitor: Simplify fdset and fd removal
Remove fds right away instead of setting the ->removed flag. We don't need the extra complexity of having a cleanup function reap the removed entries at a later time.
Reviewed-by: Peter Xu <peterx@redhat.com> Signed-off-by: Fabiano Rosas <farosas@suse.de>
show more ...
|
87d67fad | 17-Jun-2024 |
Fabiano Rosas <farosas@suse.de> |
monitor: Stop removing non-duplicated fds
monitor_fdsets_cleanup() currently has three responsibilities:
1- Remove the fds that have been marked for removal(->removed=true) by qmp_remove_fd(). T
monitor: Stop removing non-duplicated fds
monitor_fdsets_cleanup() currently has three responsibilities:
1- Remove the fds that have been marked for removal(->removed=true) by qmp_remove_fd(). This is overly complicated, but ok.
2- Remove any file descriptors that have been passed into QEMU and never duplicated[1,2]. A file descriptor without duplicates indicates that no part of QEMU has made use of it. This is problematic because the current implementation does it only if the guest is not running and the monitor is closed.
3- Remove/free fdsets that have become empty due to the above removals. This is ok.
The scenario described in (2) is starting to show some cracks now that we're trying to consume fds from the migration code:
- Doing cleanup every time the last monitor connection closes works to reap unused fds, but also has the side effect of forcing the management layer to pass the file descriptors again in case of a disconnect/re-connect, if that happened to be the only monitor connection.
Another side effect is that removing an fd with qmp_remove_fd() is effectively delayed until the last monitor connection closes.
The usage of mon_refcount is also problematic because it's racy.
- Checking runstate_is_running() skips the cleanup unless the VM is running and avoids premature cleanup of the fds, but also has the side effect of blocking the legitimate removal of an fd via qmp_remove_fd() if the VM happens to be in another state.
This affects qmp_remove_fd() and qmp_query_fdsets() in particular because requesting a removal at a bad time (guest stopped) might cause an fd to never be removed, or to be removed at a much later point in time, causing the query command to continue showing the supposedly removed fd/fdset.
Note that file descriptors that *have* been duplicated are owned by the code that uses them and will be removed after qemu_close() is called. Therefore we've decided that the best course of action to avoid the undesired side-effects is to stop managing non-duplicated file descriptors.
1- efb87c1697 ("monitor: Clean up fd sets on monitor disconnect") 2- ebe52b592d ("monitor: Prevent removing fd from set during init")
Reviewed-by: Peter Xu <peterx@redhat.com> [fix logic mistake: s/fdset_free/fdset_free_if_empty] Signed-off-by: Fabiano Rosas <farosas@suse.de>
show more ...
|
a93ad560 | 17-Jun-2024 |
Fabiano Rosas <farosas@suse.de> |
monitor: Introduce monitor_fdset_*free
Introduce new functions to remove and free no longer used fds and fdsets.
We need those to decouple the remove/free routines from monitor_fdset_cleanup() whic
monitor: Introduce monitor_fdset_*free
Introduce new functions to remove and free no longer used fds and fdsets.
We need those to decouple the remove/free routines from monitor_fdset_cleanup() which will go away in the next patches.
The new functions:
- monitor_fdset_free/_if_empty() will be used when a monitor connection closes and when an fd is removed to cleanup any fdset that is now empty.
- monitor_fdset_fd_free() will be used to remove one or more fds that have been explicitly targeted by qmp_remove_fd().
Reviewed-by: Peter Xu <peterx@redhat.com> Signed-off-by: Fabiano Rosas <farosas@suse.de>
show more ...
|
795eaa62 | 07-Jun-2024 |
Philippe Mathieu-Daudé <philmd@linaro.org> |
hw/intc: Introduce x-query-interrupt-controllers QMP command
This is a counterpart to the HMP "info pic" command. It is being added with an "x-" prefix because this QMP command is intended as an adh
hw/intc: Introduce x-query-interrupt-controllers QMP command
This is a counterpart to the HMP "info pic" command. It is being added with an "x-" prefix because this QMP command is intended as an adhoc debugging tool and will thus not be modelled in QAPI as fully structured data, nor will it have long term guaranteed stability. The existing HMP command is rewritten to call the QMP command.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20240610063518.50680-3-philmd@linaro.org>
show more ...
|
eea7cd3f | 15-Mar-2023 |
Paolo Bonzini <pbonzini@redhat.com> |
monitor: do not use mb_read/mb_set
Instead of relying on magic memory barriers, document the pattern that is being used. It is the one based on Dekker's algorithm, and in this case it is embodied a
monitor: do not use mb_read/mb_set
Instead of relying on magic memory barriers, document the pattern that is being used. It is the one based on Dekker's algorithm, and in this case it is embodied as follows:
enqueue request; sleeping = true; smp_mb(); smp_mb(); if (sleeping) kick(); if (!have a request) yield();
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|