mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00

Block devices have an individual active state, a single global flag can't cover this correctly. This becomes more important as we allow users to manually manage which nodes are active or inactive. Now that it's allowed to call bdrv_inactivate_all() even when some nodes are already inactive, we can remove the flag and just unconditionally call bdrv_inactivate_all() and, more importantly, bdrv_activate_all() before we make use of the nodes. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Acked-by: Fabiano Rosas <farosas@suse.de> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-ID: <20250204211407.381505-5-kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
48 lines
909 B
C
48 lines
909 B
C
/*
|
|
* Block activation tracking for migration purpose
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
*
|
|
* Copyright (C) 2024 Red Hat, Inc.
|
|
*/
|
|
#include "qemu/osdep.h"
|
|
#include "block/block.h"
|
|
#include "qapi/error.h"
|
|
#include "migration/migration.h"
|
|
#include "qemu/error-report.h"
|
|
#include "trace.h"
|
|
|
|
bool migration_block_activate(Error **errp)
|
|
{
|
|
ERRP_GUARD();
|
|
|
|
assert(bql_locked());
|
|
|
|
trace_migration_block_activation("active");
|
|
|
|
bdrv_activate_all(errp);
|
|
if (*errp) {
|
|
error_report_err(error_copy(*errp));
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
bool migration_block_inactivate(void)
|
|
{
|
|
int ret;
|
|
|
|
assert(bql_locked());
|
|
|
|
trace_migration_block_activation("inactive");
|
|
|
|
ret = bdrv_inactivate_all();
|
|
if (ret) {
|
|
error_report("%s: bdrv_inactivate_all() failed: %d",
|
|
__func__, ret);
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|