Revision 577c470f4326eae22e4e412946b167075f4440d2 authored by Singh, Brijesh on 01 October 2018, 19:44:37 UTC, committed by Michael S. Tsirkin on 05 November 2018, 18:24:02 UTC
Register the interrupt remapping callback and read/write ops for the
amd-iommu-ir memory region.

amd-iommu-ir is set to higher priority to ensure that this region won't
be masked out by other memory regions.

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Eduardo Habkost <ehabkost@redhat.com>
Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Cc: Tom Lendacky <Thomas.Lendacky@amd.com>
Cc: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
Reviewed-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent 5324438
Raw File
replication.c
/*
 * Replication filter
 *
 * Copyright (c) 2016 HUAWEI TECHNOLOGIES CO., LTD.
 * Copyright (c) 2016 Intel Corporation
 * Copyright (c) 2016 FUJITSU LIMITED
 *
 * Author:
 *   Changlong Xie <xiecl.fnst@cn.fujitsu.com>
 *
 * This work is licensed under the terms of the GNU GPL, version 2 or later.
 * See the COPYING file in the top-level directory.
 */

#include "qemu/osdep.h"
#include "qapi/error.h"
#include "replication.h"

static QLIST_HEAD(, ReplicationState) replication_states;

ReplicationState *replication_new(void *opaque, ReplicationOps *ops)
{
    ReplicationState *rs;

    assert(ops != NULL);
    rs = g_new0(ReplicationState, 1);
    rs->opaque = opaque;
    rs->ops = ops;
    QLIST_INSERT_HEAD(&replication_states, rs, node);

    return rs;
}

void replication_remove(ReplicationState *rs)
{
    if (rs) {
        QLIST_REMOVE(rs, node);
        g_free(rs);
    }
}

/*
 * The caller of the function MUST make sure vm stopped
 */
void replication_start_all(ReplicationMode mode, Error **errp)
{
    ReplicationState *rs, *next;
    Error *local_err = NULL;

    QLIST_FOREACH_SAFE(rs, &replication_states, node, next) {
        if (rs->ops && rs->ops->start) {
            rs->ops->start(rs, mode, &local_err);
        }
        if (local_err) {
            error_propagate(errp, local_err);
            return;
        }
    }
}

void replication_do_checkpoint_all(Error **errp)
{
    ReplicationState *rs, *next;
    Error *local_err = NULL;

    QLIST_FOREACH_SAFE(rs, &replication_states, node, next) {
        if (rs->ops && rs->ops->checkpoint) {
            rs->ops->checkpoint(rs, &local_err);
        }
        if (local_err) {
            error_propagate(errp, local_err);
            return;
        }
    }
}

void replication_get_error_all(Error **errp)
{
    ReplicationState *rs, *next;
    Error *local_err = NULL;

    QLIST_FOREACH_SAFE(rs, &replication_states, node, next) {
        if (rs->ops && rs->ops->get_error) {
            rs->ops->get_error(rs, &local_err);
        }
        if (local_err) {
            error_propagate(errp, local_err);
            return;
        }
    }
}

void replication_stop_all(bool failover, Error **errp)
{
    ReplicationState *rs, *next;
    Error *local_err = NULL;

    QLIST_FOREACH_SAFE(rs, &replication_states, node, next) {
        if (rs->ops && rs->ops->stop) {
            rs->ops->stop(rs, failover, &local_err);
        }
        if (local_err) {
            error_propagate(errp, local_err);
            return;
        }
    }
}
back to top