/* THIS FILE IS AUTOMATICALLY GENERATED, DO NOT MODIFY */

/*
 * schema-defined QAPI visitor functions
 *
 * Copyright IBM, Corp. 2011
 *
 * Authors:
 *  Anthony Liguori   <aliguori@us.ibm.com>
 *
 * 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 "qga-qapi-visit.h"

void visit_type_GuestAgentCommandInfo(Visitor *m, GuestAgentCommandInfo ** obj, const char *name, Error **errp)
{
    if (!error_is_set(errp)) {
        Error *err = NULL;
        visit_start_struct(m, (void **)obj, "GuestAgentCommandInfo", name, sizeof(GuestAgentCommandInfo), &err);
        if (!err) {
            if (!obj || *obj) {
                visit_type_str(m, obj ? &(*obj)->name : NULL, "name", &err);
                visit_type_bool(m, obj ? &(*obj)->enabled : NULL, "enabled", &err);
            
                error_propagate(errp, err);
                err = NULL;
            }
            /* Always call end_struct if start_struct succeeded.  */
            visit_end_struct(m, &err);
        }
        error_propagate(errp, err);
    }
}

void visit_type_GuestAgentCommandInfoList(Visitor *m, GuestAgentCommandInfoList ** obj, const char *name, Error **errp)
{
    GenericList *i, **prev = (GenericList **)obj;
    Error *err = NULL;

    if (!error_is_set(errp)) {
        visit_start_list(m, name, &err);
        if (!err) {
            for (; (i = visit_next_list(m, prev, &err)) != NULL; prev = &i) {
                GuestAgentCommandInfoList *native_i = (GuestAgentCommandInfoList *)i;
                visit_type_GuestAgentCommandInfo(m, &native_i->value, NULL, &err);
            }
            error_propagate(errp, err);
            err = NULL;

            /* Always call end_list if start_list succeeded.  */
            visit_end_list(m, &err);
        }
        error_propagate(errp, err);
    }
}

void visit_type_GuestAgentInfo(Visitor *m, GuestAgentInfo ** obj, const char *name, Error **errp)
{
    if (!error_is_set(errp)) {
        Error *err = NULL;
        visit_start_struct(m, (void **)obj, "GuestAgentInfo", name, sizeof(GuestAgentInfo), &err);
        if (!err) {
            if (!obj || *obj) {
                visit_type_str(m, obj ? &(*obj)->version : NULL, "version", &err);
                visit_type_GuestAgentCommandInfoList(m, obj ? &(*obj)->supported_commands : NULL, "supported_commands", &err);
            
                error_propagate(errp, err);
                err = NULL;
            }
            /* Always call end_struct if start_struct succeeded.  */
            visit_end_struct(m, &err);
        }
        error_propagate(errp, err);
    }
}

void visit_type_GuestAgentInfoList(Visitor *m, GuestAgentInfoList ** obj, const char *name, Error **errp)
{
    GenericList *i, **prev = (GenericList **)obj;
    Error *err = NULL;

    if (!error_is_set(errp)) {
        visit_start_list(m, name, &err);
        if (!err) {
            for (; (i = visit_next_list(m, prev, &err)) != NULL; prev = &i) {
                GuestAgentInfoList *native_i = (GuestAgentInfoList *)i;
                visit_type_GuestAgentInfo(m, &native_i->value, NULL, &err);
            }
            error_propagate(errp, err);
            err = NULL;

            /* Always call end_list if start_list succeeded.  */
            visit_end_list(m, &err);
        }
        error_propagate(errp, err);
    }
}

void visit_type_GuestFileRead(Visitor *m, GuestFileRead ** obj, const char *name, Error **errp)
{
    if (!error_is_set(errp)) {
        Error *err = NULL;
        visit_start_struct(m, (void **)obj, "GuestFileRead", name, sizeof(GuestFileRead), &err);
        if (!err) {
            if (!obj || *obj) {
                visit_type_int(m, obj ? &(*obj)->count : NULL, "count", &err);
                visit_type_str(m, obj ? &(*obj)->buf_b64 : NULL, "buf-b64", &err);
                visit_type_bool(m, obj ? &(*obj)->eof : NULL, "eof", &err);
            
                error_propagate(errp, err);
                err = NULL;
            }
            /* Always call end_struct if start_struct succeeded.  */
            visit_end_struct(m, &err);
        }
        error_propagate(errp, err);
    }
}

void visit_type_GuestFileReadList(Visitor *m, GuestFileReadList ** obj, const char *name, Error **errp)
{
    GenericList *i, **prev = (GenericList **)obj;
    Error *err = NULL;

    if (!error_is_set(errp)) {
        visit_start_list(m, name, &err);
        if (!err) {
            for (; (i = visit_next_list(m, prev, &err)) != NULL; prev = &i) {
                GuestFileReadList *native_i = (GuestFileReadList *)i;
                visit_type_GuestFileRead(m, &native_i->value, NULL, &err);
            }
            error_propagate(errp, err);
            err = NULL;

            /* Always call end_list if start_list succeeded.  */
            visit_end_list(m, &err);
        }
        error_propagate(errp, err);
    }
}

void visit_type_GuestFileWrite(Visitor *m, GuestFileWrite ** obj, const char *name, Error **errp)
{
    if (!error_is_set(errp)) {
        Error *err = NULL;
        visit_start_struct(m, (void **)obj, "GuestFileWrite", name, sizeof(GuestFileWrite), &err);
        if (!err) {
            if (!obj || *obj) {
                visit_type_int(m, obj ? &(*obj)->count : NULL, "count", &err);
                visit_type_bool(m, obj ? &(*obj)->eof : NULL, "eof", &err);
            
                error_propagate(errp, err);
                err = NULL;
            }
            /* Always call end_struct if start_struct succeeded.  */
            visit_end_struct(m, &err);
        }
        error_propagate(errp, err);
    }
}

void visit_type_GuestFileWriteList(Visitor *m, GuestFileWriteList ** obj, const char *name, Error **errp)
{
    GenericList *i, **prev = (GenericList **)obj;
    Error *err = NULL;

    if (!error_is_set(errp)) {
        visit_start_list(m, name, &err);
        if (!err) {
            for (; (i = visit_next_list(m, prev, &err)) != NULL; prev = &i) {
                GuestFileWriteList *native_i = (GuestFileWriteList *)i;
                visit_type_GuestFileWrite(m, &native_i->value, NULL, &err);
            }
            error_propagate(errp, err);
            err = NULL;

            /* Always call end_list if start_list succeeded.  */
            visit_end_list(m, &err);
        }
        error_propagate(errp, err);
    }
}

void visit_type_GuestFileSeek(Visitor *m, GuestFileSeek ** obj, const char *name, Error **errp)
{
    if (!error_is_set(errp)) {
        Error *err = NULL;
        visit_start_struct(m, (void **)obj, "GuestFileSeek", name, sizeof(GuestFileSeek), &err);
        if (!err) {
            if (!obj || *obj) {
                visit_type_int(m, obj ? &(*obj)->position : NULL, "position", &err);
                visit_type_bool(m, obj ? &(*obj)->eof : NULL, "eof", &err);
            
                error_propagate(errp, err);
                err = NULL;
            }
            /* Always call end_struct if start_struct succeeded.  */
            visit_end_struct(m, &err);
        }
        error_propagate(errp, err);
    }
}

void visit_type_GuestFileSeekList(Visitor *m, GuestFileSeekList ** obj, const char *name, Error **errp)
{
    GenericList *i, **prev = (GenericList **)obj;
    Error *err = NULL;

    if (!error_is_set(errp)) {
        visit_start_list(m, name, &err);
        if (!err) {
            for (; (i = visit_next_list(m, prev, &err)) != NULL; prev = &i) {
                GuestFileSeekList *native_i = (GuestFileSeekList *)i;
                visit_type_GuestFileSeek(m, &native_i->value, NULL, &err);
            }
            error_propagate(errp, err);
            err = NULL;

            /* Always call end_list if start_list succeeded.  */
            visit_end_list(m, &err);
        }
        error_propagate(errp, err);
    }
}

void visit_type_GuestFsfreezeStatus(Visitor *m, GuestFsfreezeStatus * obj, const char *name, Error **errp)
{
    visit_type_enum(m, (int *)obj, GuestFsfreezeStatus_lookup, "GuestFsfreezeStatus", name, errp);
}

void visit_type_GuestIpAddressType(Visitor *m, GuestIpAddressType * obj, const char *name, Error **errp)
{
    visit_type_enum(m, (int *)obj, GuestIpAddressType_lookup, "GuestIpAddressType", name, errp);
}

void visit_type_GuestIpAddress(Visitor *m, GuestIpAddress ** obj, const char *name, Error **errp)
{
    if (!error_is_set(errp)) {
        Error *err = NULL;
        visit_start_struct(m, (void **)obj, "GuestIpAddress", name, sizeof(GuestIpAddress), &err);
        if (!err) {
            if (!obj || *obj) {
                visit_type_str(m, obj ? &(*obj)->ip_address : NULL, "ip-address", &err);
                visit_type_GuestIpAddressType(m, obj ? &(*obj)->ip_address_type : NULL, "ip-address-type", &err);
                visit_type_int(m, obj ? &(*obj)->prefix : NULL, "prefix", &err);
            
                error_propagate(errp, err);
                err = NULL;
            }
            /* Always call end_struct if start_struct succeeded.  */
            visit_end_struct(m, &err);
        }
        error_propagate(errp, err);
    }
}

void visit_type_GuestIpAddressList(Visitor *m, GuestIpAddressList ** obj, const char *name, Error **errp)
{
    GenericList *i, **prev = (GenericList **)obj;
    Error *err = NULL;

    if (!error_is_set(errp)) {
        visit_start_list(m, name, &err);
        if (!err) {
            for (; (i = visit_next_list(m, prev, &err)) != NULL; prev = &i) {
                GuestIpAddressList *native_i = (GuestIpAddressList *)i;
                visit_type_GuestIpAddress(m, &native_i->value, NULL, &err);
            }
            error_propagate(errp, err);
            err = NULL;

            /* Always call end_list if start_list succeeded.  */
            visit_end_list(m, &err);
        }
        error_propagate(errp, err);
    }
}

void visit_type_GuestNetworkInterface(Visitor *m, GuestNetworkInterface ** obj, const char *name, Error **errp)
{
    if (!error_is_set(errp)) {
        Error *err = NULL;
        visit_start_struct(m, (void **)obj, "GuestNetworkInterface", name, sizeof(GuestNetworkInterface), &err);
        if (!err) {
            if (!obj || *obj) {
                visit_type_str(m, obj ? &(*obj)->name : NULL, "name", &err);
                visit_start_optional(m, obj ? &(*obj)->has_hardware_address : NULL, "hardware-address", &err);
                if (obj && (*obj)->has_hardware_address) {
                    visit_type_str(m, obj ? &(*obj)->hardware_address : NULL, "hardware-address", &err);
                }
                visit_end_optional(m, &err);
                visit_start_optional(m, obj ? &(*obj)->has_ip_addresses : NULL, "ip-addresses", &err);
                if (obj && (*obj)->has_ip_addresses) {
                    visit_type_GuestIpAddressList(m, obj ? &(*obj)->ip_addresses : NULL, "ip-addresses", &err);
                }
                visit_end_optional(m, &err);
            
                error_propagate(errp, err);
                err = NULL;
            }
            /* Always call end_struct if start_struct succeeded.  */
            visit_end_struct(m, &err);
        }
        error_propagate(errp, err);
    }
}

void visit_type_GuestNetworkInterfaceList(Visitor *m, GuestNetworkInterfaceList ** obj, const char *name, Error **errp)
{
    GenericList *i, **prev = (GenericList **)obj;
    Error *err = NULL;

    if (!error_is_set(errp)) {
        visit_start_list(m, name, &err);
        if (!err) {
            for (; (i = visit_next_list(m, prev, &err)) != NULL; prev = &i) {
                GuestNetworkInterfaceList *native_i = (GuestNetworkInterfaceList *)i;
                visit_type_GuestNetworkInterface(m, &native_i->value, NULL, &err);
            }
            error_propagate(errp, err);
            err = NULL;

            /* Always call end_list if start_list succeeded.  */
            visit_end_list(m, &err);
        }
        error_propagate(errp, err);
    }
}

void visit_type_GuestLogicalProcessor(Visitor *m, GuestLogicalProcessor ** obj, const char *name, Error **errp)
{
    if (!error_is_set(errp)) {
        Error *err = NULL;
        visit_start_struct(m, (void **)obj, "GuestLogicalProcessor", name, sizeof(GuestLogicalProcessor), &err);
        if (!err) {
            if (!obj || *obj) {
                visit_type_int(m, obj ? &(*obj)->logical_id : NULL, "logical-id", &err);
                visit_type_bool(m, obj ? &(*obj)->online : NULL, "online", &err);
                visit_start_optional(m, obj ? &(*obj)->has_can_offline : NULL, "can-offline", &err);
                if (obj && (*obj)->has_can_offline) {
                    visit_type_bool(m, obj ? &(*obj)->can_offline : NULL, "can-offline", &err);
                }
                visit_end_optional(m, &err);
            
                error_propagate(errp, err);
                err = NULL;
            }
            /* Always call end_struct if start_struct succeeded.  */
            visit_end_struct(m, &err);
        }
        error_propagate(errp, err);
    }
}

void visit_type_GuestLogicalProcessorList(Visitor *m, GuestLogicalProcessorList ** obj, const char *name, Error **errp)
{
    GenericList *i, **prev = (GenericList **)obj;
    Error *err = NULL;

    if (!error_is_set(errp)) {
        visit_start_list(m, name, &err);
        if (!err) {
            for (; (i = visit_next_list(m, prev, &err)) != NULL; prev = &i) {
                GuestLogicalProcessorList *native_i = (GuestLogicalProcessorList *)i;
                visit_type_GuestLogicalProcessor(m, &native_i->value, NULL, &err);
            }
            error_propagate(errp, err);
            err = NULL;

            /* Always call end_list if start_list succeeded.  */
            visit_end_list(m, &err);
        }
        error_propagate(errp, err);
    }
}
