Vladimir Sementsov-Ogievskiy <[email protected]> writes:

> We are going to implement backend-transfer feature: some devices
> will be able to transfer their backend through migration stream
> for local migration through UNIX domain socket. For example,
> virtio-net will migrate its attached TAP netdev, with all its
> connected file descriptors.
>
> In this commit we introduce a migration parameter, which pick
> devices for backend-transfer migration in context of next
> outgoing or incoming migration. Of course, user is responsible
> to pick same set of devices on source and target.
>
> QMP command query-backend-transfer-support command may help
> to prepare such set as intersection of
> query-backend-transfer-support results on source and target.
>
> With this commit, no device yet support backend-transfer,
> so passing something other then empty list to backend-transfer
> migration parameter will fail.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]>

[...]

>  void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp)
> diff --git a/qapi/migration.json b/qapi/migration.json
> index be0f3fcc12..9478c4ddab 100644
> --- a/qapi/migration.json
> +++ b/qapi/migration.json
> @@ -951,9 +951,15 @@
>  #     is @cpr-exec.  The first list element is the program's filename,
>  #     the remainder its arguments.  (Since 10.2)
>  #
> +# @backend-transfer: List of devices (IDs or QOM paths) for
> +#     backend-transfer migration.  When enabled, device backends
> +#     including opened fds will be passed to the destination in the
> +#     migration channel (which must be a UNIX domain socket).  Default
> +#     is no backend-transfer migration. (Since 10.2)

Two spaces after '.', please.

> +#
>  # Features:
>  #
> -# @unstable: Members @x-checkpoint-delay and
> +# @unstable: Members @backend-transfer, @x-checkpoint-delay and
>  #     @x-vcpu-dirty-limit-period are experimental.
>  #
>  # Since: 2.4
> @@ -978,7 +984,8 @@
>             'mode',
>             'zero-page-detection',
>             'direct-io',
> -           'cpr-exec-command'] }
> +           'cpr-exec-command',
> +           { 'name': 'backend-transfer', 'features': ['unstable'] } ] }
>  
>  ##
>  # @MigrateSetParameters:
> @@ -1137,9 +1144,15 @@
>  #     is @cpr-exec.  The first list element is the program's filename,
>  #     the remainder its arguments.  (Since 10.2)
>  #
> +# @backend-transfer: List of devices (IDs or QOM paths) for
> +#     backend-transfer migration.  When enabled, device backends
> +#     including opened fds will be passed to the destination in the
> +#     migration channel (which must be a UNIX domain socket).  Default
> +#     is no backend-transfer migration. (Since 10.2)

Likewise.

> +#
>  # Features:
>  #
> -# @unstable: Members @x-checkpoint-delay and
> +# @unstable: Members @backend-transfer, @x-checkpoint-delay and
>  #     @x-vcpu-dirty-limit-period are experimental.
>  #
>  # TODO: either fuse back into `MigrationParameters`, or make
> @@ -1179,7 +1192,9 @@
>              '*mode': 'MigMode',
>              '*zero-page-detection': 'ZeroPageDetection',
>              '*direct-io': 'bool',
> -            '*cpr-exec-command': [ 'str' ]} }
> +            '*cpr-exec-command': [ 'str' ],
> +            '*backend-transfer': { 'type': [ 'str' ],
> +                                   'features': [ 'unstable' ] } } }
>  
>  ##
>  # @migrate-set-parameters:
> @@ -1352,9 +1367,15 @@
>  #     is @cpr-exec.  The first list element is the program's filename,
>  #     the remainder its arguments.  (Since 10.2)
>  #
> +# @backend-transfer: List of devices (IDs or QOM paths) for
> +#     backend-transfer migration.  When enabled, device backends
> +#     including opened fds will be passed to the destination in the
> +#     migration channel (which must be a UNIX domain socket).  Default
> +#     is no backend-transfer migration. (Since 10.2)

Two spaces after '.', please.

> +#
>  # Features:
>  #
> -# @unstable: Members @x-checkpoint-delay and
> +# @unstable: Members @backend-transfer, @x-checkpoint-delay and
>  #     @x-vcpu-dirty-limit-period are experimental.
>  #
>  # Since: 2.4
> @@ -1391,7 +1412,9 @@
>              '*mode': 'MigMode',
>              '*zero-page-detection': 'ZeroPageDetection',
>              '*direct-io': 'bool',
> -            '*cpr-exec-command': [ 'str' ]} }
> +            '*cpr-exec-command': [ 'str' ],
> +            '*backend-transfer': { 'type': [ 'str' ],
> +                                   'features': [ 'unstable' ] } } }
>  
>  ##
>  # @query-migrate-parameters:
> diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c
> index 9d3d961c15..549c77b2f0 100644
> --- a/system/qdev-monitor.c
> +++ b/system/qdev-monitor.c
> @@ -939,6 +939,19 @@ void qmp_device_del(const char *id, Error **errp)
>      }
>  }
>  
> +bool migrate_backend_transfer(DeviceState *dev)
> +{
> +    const strList *el = migrate_backend_transfer_list();
> +
> +    for ( ; el; el = el->next) {

Please use

       const strList *el;

       for (el = migrate_backend_transfer_list(); el; el = el->next) {

> +        if (find_device_state(el->value, false, NULL) == dev) {
> +            return true;
> +        }
> +    }
> +
> +    return false;
> +}
> +
>  static bool qdev_backend_transfer_support(DeviceState *dev, Error **errp)
>  {
>      DeviceClass *dc = DEVICE_GET_CLASS(dev);
> @@ -952,6 +965,24 @@ static bool qdev_backend_transfer_support(DeviceState 
> *dev, Error **errp)
>      return dc->backend_transfer_support(dev, errp);
>  }
>  
> +bool migrate_backend_transfer_check_list(const strList *list, Error **errp)
> +{
> +    const strList *el = list;
> +
> +    for ( ; el; el = el->next) {

Likewise.

> +        DeviceState *dev = find_device_state(el->value, true, errp);
> +        if (!dev) {
> +            return false;
> +        }
> +
> +        if (!qdev_backend_transfer_support(dev, errp)) {
> +            return false;
> +        }
> +    }
> +
> +    return true;
> +}
> +
>  static int qdev_add_if_backend_transfer_supported(Object *obj, void *opaque)
>  {
>      DevPathList **list = opaque;


Reply via email to