static int nbd_receive_option_reply(QIOChannel *ioc, uint32_t opt,

                                    nbd_opt_reply *reply, Error **errp)

{

    QEMU_BUILD_BUG_ON(sizeof(*reply) != 20);

    if (nbd_read(ioc, reply, sizeof(*reply), errp) < 0) {

        error_prepend(errp, "failed to read option reply");

        nbd_send_opt_abort(ioc);

        return -1;

    }

    be64_to_cpus(&reply->magic);

    be32_to_cpus(&reply->option);

    be32_to_cpus(&reply->type);

    be32_to_cpus(&reply->length);



    trace_nbd_receive_option_reply(reply->option, reply->type, reply->length);



    if (reply->magic != NBD_REP_MAGIC) {

        error_setg(errp, "Unexpected option reply magic");

        nbd_send_opt_abort(ioc);

        return -1;

    }

    if (reply->option != opt) {

        error_setg(errp, "Unexpected option type %x expected %x",

                   reply->option, opt);

        nbd_send_opt_abort(ioc);

        return -1;

    }

    return 0;

}

static int nbd_receive_option_reply(QIOChannel *ioc, uint32_t opt,

                                    nbd_opt_reply *reply, Error **errp)

{

    QEMU_BUILD_BUG_ON(sizeof(*reply) != 20);

    if (nbd_read(ioc, reply, sizeof(*reply), errp) < 0) {

        error_prepend(errp, "failed to read option reply");

        nbd_send_opt_abort(ioc);

        return -1;

    }

    be64_to_cpus(&reply->magic);

    be32_to_cpus(&reply->option);

    be32_to_cpus(&reply->type);

    be32_to_cpus(&reply->length);



    trace_nbd_receive_option_reply(reply->option, reply->type, reply->length);



    if (reply->magic != NBD_REP_MAGIC) {

        error_setg(errp, "Unexpected option reply magic");

        nbd_send_opt_abort(ioc);

        return -1;

    }

    if (reply->option != opt) {

        error_setg(errp, "Unexpected option type %x expected %x",

                   reply->option, opt);

        nbd_send_opt_abort(ioc);

        return -1;

    }

    return 0;

}

static int FUNC_0(QIOChannel *VAR_0, uint32_t VAR_1,

                                    nbd_opt_reply *VAR_2, Error **VAR_3)

{

    QEMU_BUILD_BUG_ON(sizeof(*VAR_2) != 20);

    if (nbd_read(VAR_0, VAR_2, sizeof(*VAR_2), VAR_3) < 0) {

        error_prepend(VAR_3, "failed to read option VAR_2");

        nbd_send_opt_abort(VAR_0);

        return -1;

    }

    be64_to_cpus(&VAR_2->magic);

    be32_to_cpus(&VAR_2->option);

    be32_to_cpus(&VAR_2->type);

    be32_to_cpus(&VAR_2->length);



    trace_nbd_receive_option_reply(VAR_2->option, VAR_2->type, VAR_2->length);



    if (VAR_2->magic != NBD_REP_MAGIC) {

        error_setg(VAR_3, "Unexpected option VAR_2 magic");

        nbd_send_opt_abort(VAR_0);

        return -1;

    }

    if (VAR_2->option != VAR_1) {

        error_setg(VAR_3, "Unexpected option type %x expected %x",

                   VAR_2->option, VAR_1);

        nbd_send_opt_abort(VAR_0);

        return -1;

    }

    return 0;

}

static int FUNC_0(QIOChannel *VAR_0, uint32_t VAR_1,
nbd_opt_reply *VAR_2, Error **VAR_3)
{ QEMU_BUILD_BUG_ON(sizeof(*VAR_2) != 20); if (nbd_read(VAR_0, VAR_2, sizeof(*VAR_2), VAR_3) < 0) { error_prepend(VAR_3, "failed to read option VAR_2"); nbd_send_opt_abort(VAR_0); return -1; } be64_to_cpus(&VAR_2->magic); be32_to_cpus(&VAR_2->option); be32_to_cpus(&VAR_2->type); be32_to_cpus(&VAR_2->length); trace_nbd_receive_option_reply(VAR_2->option, VAR_2->type, VAR_2->length); if (VAR_2->magic != NBD_REP_MAGIC) { error_setg(VAR_3, "Unexpected option VAR_2 magic"); nbd_send_opt_abort(VAR_0); return -1; } if (VAR_2->option != VAR_1) { error_setg(VAR_3, "Unexpected option type %x expected %x",
VAR_2->option, VAR_1); nbd_send_opt_abort(VAR_0); return -1; } return 0; }