diff mbox series

[v6,08/10] migration/yank: Use channel features

Message ID 20230911171320.24372-9-farosas@suse.de
State New
Headers show
Series Fix segfault on migration return path | expand

Commit Message

Fabiano Rosas Sept. 11, 2023, 5:13 p.m. UTC
Stop using outside knowledge about the io channels when registering
yank functions. Query for features instead.

The yank method for all channels used with migration code currently is
to call the qio_channel_shutdown() function, so query for
QIO_CHANNEL_FEATURE_SHUTDOWN. We could add a separate feature in the
future for indicating whether a channel supports yanking, but that
seems overkill at the moment.

Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
 migration/yank_functions.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

Philippe Mathieu-Daudé Sept. 11, 2023, 8:46 p.m. UTC | #1
On 11/9/23 19:13, Fabiano Rosas wrote:
> Stop using outside knowledge about the io channels when registering
> yank functions. Query for features instead.
> 
> The yank method for all channels used with migration code currently is
> to call the qio_channel_shutdown() function, so query for
> QIO_CHANNEL_FEATURE_SHUTDOWN. We could add a separate feature in the
> future for indicating whether a channel supports yanking, but that
> seems overkill at the moment.
> 
> Signed-off-by: Fabiano Rosas <farosas@suse.de>
> ---
>   migration/yank_functions.c | 6 +-----
>   1 file changed, 1 insertion(+), 5 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Peter Xu Sept. 13, 2023, 8:05 p.m. UTC | #2
On Mon, Sep 11, 2023 at 02:13:18PM -0300, Fabiano Rosas wrote:
> Stop using outside knowledge about the io channels when registering
> yank functions. Query for features instead.
> 
> The yank method for all channels used with migration code currently is
> to call the qio_channel_shutdown() function, so query for
> QIO_CHANNEL_FEATURE_SHUTDOWN. We could add a separate feature in the
> future for indicating whether a channel supports yanking, but that
> seems overkill at the moment.
> 
> Signed-off-by: Fabiano Rosas <farosas@suse.de>

Reviewed-by: Peter Xu <peterx@redhat.com>
Fabiano Rosas Jan. 22, 2024, 8:08 p.m. UTC | #3
Peter Xu <peterx@redhat.com> writes:

> On Mon, Sep 11, 2023 at 02:13:18PM -0300, Fabiano Rosas wrote:
>> Stop using outside knowledge about the io channels when registering
>> yank functions. Query for features instead.
>> 
>> The yank method for all channels used with migration code currently is
>> to call the qio_channel_shutdown() function, so query for
>> QIO_CHANNEL_FEATURE_SHUTDOWN. We could add a separate feature in the
>> future for indicating whether a channel supports yanking, but that
>> seems overkill at the moment.
>> 
>> Signed-off-by: Fabiano Rosas <farosas@suse.de>
>
> Reviewed-by: Peter Xu <peterx@redhat.com>

Hi Peter, this one has fell through the cracks, think we could merge it?
Peter Xu Jan. 23, 2024, 1:27 a.m. UTC | #4
On Mon, Jan 22, 2024 at 05:08:09PM -0300, Fabiano Rosas wrote:
> Peter Xu <peterx@redhat.com> writes:
> 
> > On Mon, Sep 11, 2023 at 02:13:18PM -0300, Fabiano Rosas wrote:
> >> Stop using outside knowledge about the io channels when registering
> >> yank functions. Query for features instead.
> >> 
> >> The yank method for all channels used with migration code currently is
> >> to call the qio_channel_shutdown() function, so query for
> >> QIO_CHANNEL_FEATURE_SHUTDOWN. We could add a separate feature in the
> >> future for indicating whether a channel supports yanking, but that
> >> seems overkill at the moment.
> >> 
> >> Signed-off-by: Fabiano Rosas <farosas@suse.de>
> >
> > Reviewed-by: Peter Xu <peterx@redhat.com>
> 
> Hi Peter, this one has fell through the cracks, think we could merge it?

Yep, queued.
diff mbox series

Patch

diff --git a/migration/yank_functions.c b/migration/yank_functions.c
index d5a710a3f2..979e60c762 100644
--- a/migration/yank_functions.c
+++ b/migration/yank_functions.c
@@ -8,12 +8,9 @@ 
  */
 
 #include "qemu/osdep.h"
-#include "qapi/error.h"
 #include "io/channel.h"
 #include "yank_functions.h"
 #include "qemu/yank.h"
-#include "io/channel-socket.h"
-#include "io/channel-tls.h"
 #include "qemu-file.h"
 
 void migration_yank_iochannel(void *opaque)
@@ -26,8 +23,7 @@  void migration_yank_iochannel(void *opaque)
 /* Return whether yank is supported on this ioc */
 static bool migration_ioc_yank_supported(QIOChannel *ioc)
 {
-    return object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_SOCKET) ||
-        object_dynamic_cast(OBJECT(ioc), TYPE_QIO_CHANNEL_TLS);
+    return qio_channel_has_feature(ioc, QIO_CHANNEL_FEATURE_SHUTDOWN);
 }
 
 void migration_ioc_register_yank(QIOChannel *ioc)