master
c 40 lines 870 Bytes
Raw
1 /*
2 * CPER payload parser for error injection
3 *
4 * Copyright(C) 2024-2025 Huawei LTD.
5 *
6 * This code is licensed under the GPL version 2 or later. See the
7 * COPYING file in the top-level directory.
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 */
11
12 #include "qemu/osdep.h"
13
14 #include "qemu/base64.h"
15 #include "qemu/error-report.h"
16 #include "qemu/uuid.h"
17 #include "qapi/qapi-commands-acpi-hest.h"
18 #include "hw/acpi/ghes.h"
19
20 void qmp_inject_ghes_v2_error(const char *qmp_cper, Error **errp)
21 {
22 AcpiGhesState *ags;
23 uint8_t *cper;
24 size_t len;
25
26 ags = acpi_ghes_get_state();
27 if (!ags) {
28 return;
29 }
30
31 cper = qbase64_decode(qmp_cper, -1, &len, errp);
32 if (!cper) {
33 error_setg(errp, "missing GHES CPER payload");
34 return;
35 }
36
37 ghes_record_cper_errors(ags, cper, len, ACPI_HEST_SRC_ID_QMP, errp);
38
39 g_free(cper);
40 }