summaryrefslogtreecommitdiffstats
path: root/include/qemu/timed-average.h
blob: 08245e7a10990aa93e1526c0b13c04beb5ee51d8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 * QEMU timed average computation
 *
 * Copyright (C) Nodalink, EURL. 2014
 * Copyright (C) Igalia, S.L. 2015
 *
 * Authors:
 *   Benoît Canet <benoit.canet@nodalink.com>
 *   Alberto Garcia <berto@igalia.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) version 3 or any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef TIMED_AVERAGE_H
#define TIMED_AVERAGE_H


#include "qemu/timer.h"

typedef struct TimedAverageWindow TimedAverageWindow;
typedef struct T
 *
 * Copyright (c) 2014 Red Hat, Inc.
 *
 * 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 "libqtest.h"
#include "qemu/timer.h"

static void qmp_check_no_event(void)
{
    QDict *resp = qmp("{'execute':'query-status'}");
    g_assert(qdict_haskey(resp, "return"));
    QDECREF(resp);
}

static QDict *qmp_get_event(const char *name)
{
    QDict *event = qmp("");
    QDict *data;
    g_assert(qdict_haskey(event, "event"));
    g_assert(!strcmp(qdict_get_str(event, "event"), name));

    if (qdict_haskey(event, "data")) {
        data = qdict_get_qdict(event, "data");
        QINCREF(data);
    } else {
        data = NULL;
    }

    QDECREF(event);
    return data;
}