migration: per-mode blockers

Extend the blocker interface so that a blocker can be registered for
one or more migration modes.  The existing interfaces register a
blocker for all modes, and the new interfaces take a varargs list
of modes.

Internally, maintain a separate blocker list per mode.  The same Error
object may be added to multiple lists.  When a block is deleted, it is
removed from every list, and the Error is freed.

No functional change until a new mode is added.

Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <1698263069-406971-3-git-send-email-steven.sistare@oracle.com>
This commit is contained in:
Steve Sistare 2023-10-25 12:44:25 -07:00 committed by Juan Quintela
parent eea1e5c9d6
commit fa3673e497
3 changed files with 135 additions and 20 deletions

View file

@ -14,8 +14,12 @@
#ifndef MIGRATION_BLOCKER_H
#define MIGRATION_BLOCKER_H
#include "qapi/qapi-types-migration.h"
#define MIG_MODE_ALL MIG_MODE__MAX
/**
* @migrate_add_blocker - prevent migration from proceeding
* @migrate_add_blocker - prevent all modes of migration from proceeding
*
* @reasonp - address of an error to be returned whenever migration is attempted
*
@ -30,8 +34,8 @@
int migrate_add_blocker(Error **reasonp, Error **errp);
/**
* @migrate_add_blocker_internal - prevent migration from proceeding without
* only-migrate implications
* @migrate_add_blocker_internal - prevent all modes of migration from
* proceeding, but ignore -only-migratable
*
* @reasonp - address of an error to be returned whenever migration is attempted
*
@ -50,7 +54,7 @@ int migrate_add_blocker(Error **reasonp, Error **errp);
int migrate_add_blocker_internal(Error **reasonp, Error **errp);
/**
* @migrate_del_blocker - remove a blocking error from migration and free it.
* @migrate_del_blocker - remove a migration blocker from all modes and free it.
*
* @reasonp - address of the error blocking migration
*
@ -58,4 +62,36 @@ int migrate_add_blocker_internal(Error **reasonp, Error **errp);
*/
void migrate_del_blocker(Error **reasonp);
/**
* @migrate_add_blocker_normal - prevent normal migration mode from proceeding
*
* @reasonp - address of an error to be returned whenever migration is attempted
*
* @errp - [out] The reason (if any) we cannot block migration right now.
*
* @returns - 0 on success, -EBUSY/-EACCES on failure, with errp set.
*
* *@reasonp is freed and set to NULL if failure is returned.
* On success, the caller must not free @reasonp, except by
* calling migrate_del_blocker.
*/
int migrate_add_blocker_normal(Error **reasonp, Error **errp);
/**
* @migrate_add_blocker_modes - prevent some modes of migration from proceeding
*
* @reasonp - address of an error to be returned whenever migration is attempted
*
* @errp - [out] The reason (if any) we cannot block migration right now.
*
* @mode - one or more migration modes to be blocked. The list is terminated
* by -1 or MIG_MODE_ALL. For the latter, all modes are blocked.
*
* @returns - 0 on success, -EBUSY/-EACCES on failure, with errp set.
*
* *@reasonp is freed and set to NULL if failure is returned.
* On success, the caller must not free *@reasonp before the blocker is removed.
*/
int migrate_add_blocker_modes(Error **reasonp, Error **errp, MigMode mode, ...);
#endif