mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
migration: Introduce migration_ioc_[un]register_yank()
There're plenty of places in migration/* that checks against either socket or tls typed ioc for yank operations. Provide two helpers to hide all these information. Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Peter Xu <peterx@redhat.com> Message-Id: <20210722175841.938739-4-peterx@redhat.com> Reviewed-by: Lukas Straub <lukasstraub2@web.de> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
This commit is contained in:
parent
43044ac0ee
commit
18711405b5
5 changed files with 36 additions and 25 deletions
|
@ -11,6 +11,9 @@
|
|||
#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"
|
||||
|
||||
void migration_yank_iochannel(void *opaque)
|
||||
{
|
||||
|
@ -18,3 +21,28 @@ void migration_yank_iochannel(void *opaque)
|
|||
|
||||
qio_channel_shutdown(ioc, QIO_CHANNEL_SHUTDOWN_BOTH, NULL);
|
||||
}
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
void migration_ioc_register_yank(QIOChannel *ioc)
|
||||
{
|
||||
if (migration_ioc_yank_supported(ioc)) {
|
||||
yank_register_function(MIGRATION_YANK_INSTANCE,
|
||||
migration_yank_iochannel,
|
||||
QIO_CHANNEL(ioc));
|
||||
}
|
||||
}
|
||||
|
||||
void migration_ioc_unregister_yank(QIOChannel *ioc)
|
||||
{
|
||||
if (migration_ioc_yank_supported(ioc)) {
|
||||
yank_unregister_function(MIGRATION_YANK_INSTANCE,
|
||||
migration_yank_iochannel,
|
||||
QIO_CHANNEL(ioc));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue