master
c 48 lines 909 Bytes
Raw
1 /*
2 * Block activation tracking for migration purpose
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 *
6 * Copyright (C) 2024 Red Hat, Inc.
7 */
8 #include "qemu/osdep.h"
9 #include "block/block.h"
10 #include "qapi/error.h"
11 #include "migration/migration.h"
12 #include "qemu/error-report.h"
13 #include "trace.h"
14
15 bool migration_block_activate(Error **errp)
16 {
17 ERRP_GUARD();
18
19 assert(bql_locked());
20
21 trace_migration_block_activation("active");
22
23 bdrv_activate_all(errp);
24 if (*errp) {
25 error_report_err(error_copy(*errp));
26 return false;
27 }
28
29 return true;
30 }
31
32 bool migration_block_inactivate(void)
33 {
34 int ret;
35
36 assert(bql_locked());
37
38 trace_migration_block_activation("inactive");
39
40 ret = bdrv_inactivate_all();
41 if (ret) {
42 error_report("%s: bdrv_inactivate_all() failed: %d",
43 __func__, ret);
44 return false;
45 }
46
47 return true;
48 }