aboutsummaryrefslogtreecommitdiff
path: root/migration/block-active.c
blob: 40e986aadea407436138911625ca35d71af369e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
 * 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;
}