/* AUTOMATICALLY GENERATED by qapi-gen.py DO NOT MODIFY */

/*
 * Schema-defined QAPI/QMP commands
 *
 * Copyright IBM, Corp. 2011
 * Copyright (C) 2014-2018 Red Hat, Inc.
 *
 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
 * See the COPYING.LIB file in the top-level directory.
 */

#include "qemu/osdep.h"
#include "qapi/compat-policy.h"
#include "qapi/visitor.h"
#include "qobject/qdict.h"
#include "qapi/dealloc-visitor.h"
#include "qapi/error.h"
#include "qapi-visit-misc-i386.h"
#include "qapi-commands-misc-i386.h"
#include "qobject/qjson.h"
#include "trace/trace-qapi_commands_misc_i386_trace_events.h"

void qmp_marshal_rtc_reset_reinjection(QDict *args, QObject **ret, Error **errp)
{
    Error *err = NULL;
    bool ok = false;
    Visitor *v;

    v = qobject_input_visitor_new_qmp(QOBJECT(args));
    if (!visit_start_struct(v, NULL, NULL, 0, errp)) {
        goto out;
    }
    ok = visit_check_struct(v, errp);
    visit_end_struct(v, NULL);
    if (!ok) {
        goto out;
    }

    if (trace_event_get_state_backends(TRACE_QMP_ENTER_RTC_RESET_REINJECTION)) {
        g_autoptr(GString) req_json = qobject_to_json(QOBJECT(args));

        trace_qmp_enter_rtc_reset_reinjection(req_json->str);
    }

    qmp_rtc_reset_reinjection(&err);
    if (err) {
        trace_qmp_exit_rtc_reset_reinjection(error_get_pretty(err), false);
        error_propagate(errp, err);
        goto out;
    }

    trace_qmp_exit_rtc_reset_reinjection("{}", true);

out:
    visit_free(v);
    v = qapi_dealloc_visitor_new();
    visit_start_struct(v, NULL, NULL, 0, NULL);
    visit_end_struct(v, NULL);
    visit_free(v);
}

void qmp_marshal_query_sev(QDict *args, QObject **ret, Error **errp)
{
    Error *err = NULL;
    bool ok = false;
    Visitor *v;
    SevInfo *retval;
    Visitor *ov;

    v = qobject_input_visitor_new_qmp(QOBJECT(args));
    if (!visit_start_struct(v, NULL, NULL, 0, errp)) {
        goto out;
    }
    ok = visit_check_struct(v, errp);
    visit_end_struct(v, NULL);
    if (!ok) {
        goto out;
    }

    if (trace_event_get_state_backends(TRACE_QMP_ENTER_QUERY_SEV)) {
        g_autoptr(GString) req_json = qobject_to_json(QOBJECT(args));

        trace_qmp_enter_query_sev(req_json->str);
    }

    retval = qmp_query_sev(&err);
    if (err) {
        trace_qmp_exit_query_sev(error_get_pretty(err), false);
        error_propagate(errp, err);
        goto out;
    }

    ov = qobject_output_visitor_new_qmp(ret);
    if (visit_type_SevInfo(ov, "unused", &retval, errp)) {
        visit_complete(ov, ret);
    }
    visit_free(ov);
    ov = qapi_dealloc_visitor_new();
    visit_type_SevInfo(ov, "unused", &retval, NULL);
    visit_free(ov);

    if (trace_event_get_state_backends(TRACE_QMP_EXIT_QUERY_SEV)) {
        g_autoptr(GString) ret_json = qobject_to_json(*ret);

        trace_qmp_exit_query_sev(ret_json->str, true);
    }

out:
    visit_free(v);
    v = qapi_dealloc_visitor_new();
    visit_start_struct(v, NULL, NULL, 0, NULL);
    visit_end_struct(v, NULL);
    visit_free(v);
}

void qmp_marshal_query_sev_launch_measure(QDict *args, QObject **ret, Error **errp)
{
    Error *err = NULL;
    bool ok = false;
    Visitor *v;
    SevLaunchMeasureInfo *retval;
    Visitor *ov;

    v = qobject_input_visitor_new_qmp(QOBJECT(args));
    if (!visit_start_struct(v, NULL, NULL, 0, errp)) {
        goto out;
    }
    ok = visit_check_struct(v, errp);
    visit_end_struct(v, NULL);
    if (!ok) {
        goto out;
    }

    if (trace_event_get_state_backends(TRACE_QMP_ENTER_QUERY_SEV_LAUNCH_MEASURE)) {
        g_autoptr(GString) req_json = qobject_to_json(QOBJECT(args));

        trace_qmp_enter_query_sev_launch_measure(req_json->str);
    }

    retval = qmp_query_sev_launch_measure(&err);
    if (err) {
        trace_qmp_exit_query_sev_launch_measure(error_get_pretty(err), false);
        error_propagate(errp, err);
        goto out;
    }

    ov = qobject_output_visitor_new_qmp(ret);
    if (visit_type_SevLaunchMeasureInfo(ov, "unused", &retval, errp)) {
        visit_complete(ov, ret);
    }
    visit_free(ov);
    ov = qapi_dealloc_visitor_new();
    visit_type_SevLaunchMeasureInfo(ov, "unused", &retval, NULL);
    visit_free(ov);

    if (trace_event_get_state_backends(TRACE_QMP_EXIT_QUERY_SEV_LAUNCH_MEASURE)) {
        g_autoptr(GString) ret_json = qobject_to_json(*ret);

        trace_qmp_exit_query_sev_launch_measure(ret_json->str, true);
    }

out:
    visit_free(v);
    v = qapi_dealloc_visitor_new();
    visit_start_struct(v, NULL, NULL, 0, NULL);
    visit_end_struct(v, NULL);
    visit_free(v);
}

void qmp_marshal_query_sev_capabilities(QDict *args, QObject **ret, Error **errp)
{
    Error *err = NULL;
    bool ok = false;
    Visitor *v;
    SevCapability *retval;
    Visitor *ov;

    v = qobject_input_visitor_new_qmp(QOBJECT(args));
    if (!visit_start_struct(v, NULL, NULL, 0, errp)) {
        goto out;
    }
    ok = visit_check_struct(v, errp);
    visit_end_struct(v, NULL);
    if (!ok) {
        goto out;
    }

    if (trace_event_get_state_backends(TRACE_QMP_ENTER_QUERY_SEV_CAPABILITIES)) {
        g_autoptr(GString) req_json = qobject_to_json(QOBJECT(args));

        trace_qmp_enter_query_sev_capabilities(req_json->str);
    }

    retval = qmp_query_sev_capabilities(&err);
    if (err) {
        trace_qmp_exit_query_sev_capabilities(error_get_pretty(err), false);
        error_propagate(errp, err);
        goto out;
    }

    ov = qobject_output_visitor_new_qmp(ret);
    if (visit_type_SevCapability(ov, "unused", &retval, errp)) {
        visit_complete(ov, ret);
    }
    visit_free(ov);
    ov = qapi_dealloc_visitor_new();
    visit_type_SevCapability(ov, "unused", &retval, NULL);
    visit_free(ov);

    if (trace_event_get_state_backends(TRACE_QMP_EXIT_QUERY_SEV_CAPABILITIES)) {
        g_autoptr(GString) ret_json = qobject_to_json(*ret);

        trace_qmp_exit_query_sev_capabilities(ret_json->str, true);
    }

out:
    visit_free(v);
    v = qapi_dealloc_visitor_new();
    visit_start_struct(v, NULL, NULL, 0, NULL);
    visit_end_struct(v, NULL);
    visit_free(v);
}

void qmp_marshal_sev_inject_launch_secret(QDict *args, QObject **ret, Error **errp)
{
    Error *err = NULL;
    bool ok = false;
    Visitor *v;
    q_obj_sev_inject_launch_secret_arg arg = {0};

    v = qobject_input_visitor_new_qmp(QOBJECT(args));
    if (!visit_start_struct(v, NULL, NULL, 0, errp)) {
        goto out;
    }
    if (visit_type_q_obj_sev_inject_launch_secret_arg_members(v, &arg, errp)) {
        ok = visit_check_struct(v, errp);
    }
    visit_end_struct(v, NULL);
    if (!ok) {
        goto out;
    }

    if (trace_event_get_state_backends(TRACE_QMP_ENTER_SEV_INJECT_LAUNCH_SECRET)) {
        g_autoptr(GString) req_json = qobject_to_json(QOBJECT(args));

        trace_qmp_enter_sev_inject_launch_secret(req_json->str);
    }

    qmp_sev_inject_launch_secret(arg.packet_header, arg.secret, arg.has_gpa, arg.gpa, &err);
    if (err) {
        trace_qmp_exit_sev_inject_launch_secret(error_get_pretty(err), false);
        error_propagate(errp, err);
        goto out;
    }

    trace_qmp_exit_sev_inject_launch_secret("{}", true);

out:
    visit_free(v);
    v = qapi_dealloc_visitor_new();
    visit_start_struct(v, NULL, NULL, 0, NULL);
    visit_type_q_obj_sev_inject_launch_secret_arg_members(v, &arg, NULL);
    visit_end_struct(v, NULL);
    visit_free(v);
}

void qmp_marshal_query_sev_attestation_report(QDict *args, QObject **ret, Error **errp)
{
    Error *err = NULL;
    bool ok = false;
    Visitor *v;
    SevAttestationReport *retval;
    Visitor *ov;
    q_obj_query_sev_attestation_report_arg arg = {0};

    v = qobject_input_visitor_new_qmp(QOBJECT(args));
    if (!visit_start_struct(v, NULL, NULL, 0, errp)) {
        goto out;
    }
    if (visit_type_q_obj_query_sev_attestation_report_arg_members(v, &arg, errp)) {
        ok = visit_check_struct(v, errp);
    }
    visit_end_struct(v, NULL);
    if (!ok) {
        goto out;
    }

    if (trace_event_get_state_backends(TRACE_QMP_ENTER_QUERY_SEV_ATTESTATION_REPORT)) {
        g_autoptr(GString) req_json = qobject_to_json(QOBJECT(args));

        trace_qmp_enter_query_sev_attestation_report(req_json->str);
    }

    retval = qmp_query_sev_attestation_report(arg.mnonce, &err);
    if (err) {
        trace_qmp_exit_query_sev_attestation_report(error_get_pretty(err), false);
        error_propagate(errp, err);
        goto out;
    }

    ov = qobject_output_visitor_new_qmp(ret);
    if (visit_type_SevAttestationReport(ov, "unused", &retval, errp)) {
        visit_complete(ov, ret);
    }
    visit_free(ov);
    ov = qapi_dealloc_visitor_new();
    visit_type_SevAttestationReport(ov, "unused", &retval, NULL);
    visit_free(ov);

    if (trace_event_get_state_backends(TRACE_QMP_EXIT_QUERY_SEV_ATTESTATION_REPORT)) {
        g_autoptr(GString) ret_json = qobject_to_json(*ret);

        trace_qmp_exit_query_sev_attestation_report(ret_json->str, true);
    }

out:
    visit_free(v);
    v = qapi_dealloc_visitor_new();
    visit_start_struct(v, NULL, NULL, 0, NULL);
    visit_type_q_obj_query_sev_attestation_report_arg_members(v, &arg, NULL);
    visit_end_struct(v, NULL);
    visit_free(v);
}

void qmp_marshal_query_sgx(QDict *args, QObject **ret, Error **errp)
{
    Error *err = NULL;
    bool ok = false;
    Visitor *v;
    SgxInfo *retval;
    Visitor *ov;

    v = qobject_input_visitor_new_qmp(QOBJECT(args));
    if (!visit_start_struct(v, NULL, NULL, 0, errp)) {
        goto out;
    }
    ok = visit_check_struct(v, errp);
    visit_end_struct(v, NULL);
    if (!ok) {
        goto out;
    }

    if (trace_event_get_state_backends(TRACE_QMP_ENTER_QUERY_SGX)) {
        g_autoptr(GString) req_json = qobject_to_json(QOBJECT(args));

        trace_qmp_enter_query_sgx(req_json->str);
    }

    retval = qmp_query_sgx(&err);
    if (err) {
        trace_qmp_exit_query_sgx(error_get_pretty(err), false);
        error_propagate(errp, err);
        goto out;
    }

    ov = qobject_output_visitor_new_qmp(ret);
    if (visit_type_SgxInfo(ov, "unused", &retval, errp)) {
        visit_complete(ov, ret);
    }
    visit_free(ov);
    ov = qapi_dealloc_visitor_new();
    visit_type_SgxInfo(ov, "unused", &retval, NULL);
    visit_free(ov);

    if (trace_event_get_state_backends(TRACE_QMP_EXIT_QUERY_SGX)) {
        g_autoptr(GString) ret_json = qobject_to_json(*ret);

        trace_qmp_exit_query_sgx(ret_json->str, true);
    }

out:
    visit_free(v);
    v = qapi_dealloc_visitor_new();
    visit_start_struct(v, NULL, NULL, 0, NULL);
    visit_end_struct(v, NULL);
    visit_free(v);
}

void qmp_marshal_query_sgx_capabilities(QDict *args, QObject **ret, Error **errp)
{
    Error *err = NULL;
    bool ok = false;
    Visitor *v;
    SgxInfo *retval;
    Visitor *ov;

    v = qobject_input_visitor_new_qmp(QOBJECT(args));
    if (!visit_start_struct(v, NULL, NULL, 0, errp)) {
        goto out;
    }
    ok = visit_check_struct(v, errp);
    visit_end_struct(v, NULL);
    if (!ok) {
        goto out;
    }

    if (trace_event_get_state_backends(TRACE_QMP_ENTER_QUERY_SGX_CAPABILITIES)) {
        g_autoptr(GString) req_json = qobject_to_json(QOBJECT(args));

        trace_qmp_enter_query_sgx_capabilities(req_json->str);
    }

    retval = qmp_query_sgx_capabilities(&err);
    if (err) {
        trace_qmp_exit_query_sgx_capabilities(error_get_pretty(err), false);
        error_propagate(errp, err);
        goto out;
    }

    ov = qobject_output_visitor_new_qmp(ret);
    if (visit_type_SgxInfo(ov, "unused", &retval, errp)) {
        visit_complete(ov, ret);
    }
    visit_free(ov);
    ov = qapi_dealloc_visitor_new();
    visit_type_SgxInfo(ov, "unused", &retval, NULL);
    visit_free(ov);

    if (trace_event_get_state_backends(TRACE_QMP_EXIT_QUERY_SGX_CAPABILITIES)) {
        g_autoptr(GString) ret_json = qobject_to_json(*ret);

        trace_qmp_exit_query_sgx_capabilities(ret_json->str, true);
    }

out:
    visit_free(v);
    v = qapi_dealloc_visitor_new();
    visit_start_struct(v, NULL, NULL, 0, NULL);
    visit_end_struct(v, NULL);
    visit_free(v);
}

void qmp_marshal_xen_event_list(QDict *args, QObject **ret, Error **errp)
{
    Error *err = NULL;
    bool ok = false;
    Visitor *v;
    EvtchnInfoList *retval;
    Visitor *ov;

    v = qobject_input_visitor_new_qmp(QOBJECT(args));
    if (!visit_start_struct(v, NULL, NULL, 0, errp)) {
        goto out;
    }
    ok = visit_check_struct(v, errp);
    visit_end_struct(v, NULL);
    if (!ok) {
        goto out;
    }

    if (trace_event_get_state_backends(TRACE_QMP_ENTER_XEN_EVENT_LIST)) {
        g_autoptr(GString) req_json = qobject_to_json(QOBJECT(args));

        trace_qmp_enter_xen_event_list(req_json->str);
    }

    retval = qmp_xen_event_list(&err);
    if (err) {
        trace_qmp_exit_xen_event_list(error_get_pretty(err), false);
        error_propagate(errp, err);
        goto out;
    }

    ov = qobject_output_visitor_new_qmp(ret);
    if (visit_type_EvtchnInfoList(ov, "unused", &retval, errp)) {
        visit_complete(ov, ret);
    }
    visit_free(ov);
    ov = qapi_dealloc_visitor_new();
    visit_type_EvtchnInfoList(ov, "unused", &retval, NULL);
    visit_free(ov);

    if (trace_event_get_state_backends(TRACE_QMP_EXIT_XEN_EVENT_LIST)) {
        g_autoptr(GString) ret_json = qobject_to_json(*ret);

        trace_qmp_exit_xen_event_list(ret_json->str, true);
    }

out:
    visit_free(v);
    v = qapi_dealloc_visitor_new();
    visit_start_struct(v, NULL, NULL, 0, NULL);
    visit_end_struct(v, NULL);
    visit_free(v);
}

void qmp_marshal_xen_event_inject(QDict *args, QObject **ret, Error **errp)
{
    Error *err = NULL;
    bool ok = false;
    Visitor *v;
    q_obj_xen_event_inject_arg arg = {0};

    v = qobject_input_visitor_new_qmp(QOBJECT(args));
    if (!visit_start_struct(v, NULL, NULL, 0, errp)) {
        goto out;
    }
    if (visit_type_q_obj_xen_event_inject_arg_members(v, &arg, errp)) {
        ok = visit_check_struct(v, errp);
    }
    visit_end_struct(v, NULL);
    if (!ok) {
        goto out;
    }

    if (trace_event_get_state_backends(TRACE_QMP_ENTER_XEN_EVENT_INJECT)) {
        g_autoptr(GString) req_json = qobject_to_json(QOBJECT(args));

        trace_qmp_enter_xen_event_inject(req_json->str);
    }

    qmp_xen_event_inject(arg.port, &err);
    if (err) {
        trace_qmp_exit_xen_event_inject(error_get_pretty(err), false);
        error_propagate(errp, err);
        goto out;
    }

    trace_qmp_exit_xen_event_inject("{}", true);

out:
    visit_free(v);
    v = qapi_dealloc_visitor_new();
    visit_start_struct(v, NULL, NULL, 0, NULL);
    visit_type_q_obj_xen_event_inject_arg_members(v, &arg, NULL);
    visit_end_struct(v, NULL);
    visit_free(v);
}

/* Dummy declaration to prevent empty .o file */
char qapi_dummy_qapi_commands_misc_i386_c;
