]> git.proxmox.com Git - mirror_qemu.git/blame - include/hw/virtio/virtio-balloon.h
Use DECLARE_*CHECKER* macros
[mirror_qemu.git] / include / hw / virtio / virtio-balloon.h
CommitLineData
bd322087
AL
1/*
2 * Virtio Support
3 *
4 * Copyright IBM, Corp. 2007-2008
5 *
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
8 * Rusty Russell <rusty@rustcorp.com.au>
9 *
10 * This work is licensed under the terms of the GNU GPL, version 2. See
11 * the COPYING file in the top-level directory.
12 *
13 */
14
2a6a4076
MA
15#ifndef QEMU_VIRTIO_BALLOON_H
16#define QEMU_VIRTIO_BALLOON_H
bd322087 17
73706bd1 18#include "standard-headers/linux/virtio_balloon.h"
0d09e41a 19#include "hw/virtio/virtio.h"
c13c4153 20#include "sysemu/iothread.h"
db1015e9 21#include "qom/object.h"
bd322087 22
f574fa8b 23#define TYPE_VIRTIO_BALLOON "virtio-balloon-device"
db1015e9 24typedef struct VirtIOBalloon VirtIOBalloon;
8110fa1d
EH
25DECLARE_INSTANCE_CHECKER(VirtIOBalloon, VIRTIO_BALLOON,
26 TYPE_VIRTIO_BALLOON)
1ab461b5 27
3219b42f 28#define VIRTIO_BALLOON_FREE_PAGE_HINT_CMD_ID_MIN 0x80000000
c13c4153 29
73706bd1 30typedef struct virtio_balloon_stat VirtIOBalloonStat;
625a5bef 31
fbdc6892
MT
32typedef struct virtio_balloon_stat_modern {
33 uint16_t tag;
34 uint8_t reserved[6];
35 uint64_t val;
36} VirtIOBalloonStatModern;
37
3219b42f
AD
38enum virtio_balloon_free_page_hint_status {
39 FREE_PAGE_HINT_S_STOP = 0,
40 FREE_PAGE_HINT_S_REQUESTED = 1,
41 FREE_PAGE_HINT_S_START = 2,
42 FREE_PAGE_HINT_S_DONE = 3,
c13c4153
WW
43};
44
db1015e9 45struct VirtIOBalloon {
c96caced 46 VirtIODevice parent_obj;
91b86719 47 VirtQueue *ivq, *dvq, *svq, *free_page_vq, *reporting_vq;
3219b42f 48 uint32_t free_page_hint_status;
f1b24e84
FK
49 uint32_t num_pages;
50 uint32_t actual;
3219b42f 51 uint32_t free_page_hint_cmd_id;
f1b24e84 52 uint64_t stats[VIRTIO_BALLOON_S_NR];
51b19ebe 53 VirtQueueElement *stats_vq_elem;
f1b24e84
FK
54 size_t stats_vq_offset;
55 QEMUTimer *stats_timer;
c13c4153
WW
56 IOThread *iothread;
57 QEMUBH *free_page_bh;
58 /*
59 * Lock to synchronize threads to access the free page reporting related
3219b42f 60 * fields (e.g. free_page_hint_status).
c13c4153
WW
61 */
62 QemuMutex free_page_lock;
63 QemuCond free_page_cond;
64 /*
65 * Set to block iothread to continue reading free page hints as the VM is
66 * stopped.
67 */
68 bool block_iothread;
3219b42f 69 NotifierWithReturn free_page_hint_notify;
f1b24e84
FK
70 int64_t stats_last_update;
71 int64_t stats_poll_interval;
e3816255 72 uint32_t host_features;
2bbadb08
SH
73
74 bool qemu_4_0_config_size;
7483cbba 75 uint32_t poison_val;
db1015e9 76};
f1b24e84 77
bd322087 78#endif