]>
Commit | Line | Data |
---|---|---|
bd322087 AL |
1 | /* |
2 | * Virtio Support | |
3 | * | |
4 | * Copyright IBM, Corp. 2007-2008 | |
5 | * | |
6 | * Authors: | |
7 | * Anthony Liguori <[email protected]> | |
8 | * Rusty Russell <[email protected]> | |
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 | ||
15 | #ifndef _QEMU_VIRTIO_BALLOON_H | |
16 | #define _QEMU_VIRTIO_BALLOON_H | |
17 | ||
83c9f4ca PB |
18 | #include "hw/virtio.h" |
19 | #include "hw/pci/pci.h" | |
bd322087 | 20 | |
1ab461b5 FK |
21 | #define TYPE_VIRTIO_BALLOON "virtio-balloon" |
22 | #define VIRTIO_BALLOON(obj) \ | |
23 | OBJECT_CHECK(VirtIOBalloon, (obj), TYPE_VIRTIO_BALLOON) | |
24 | ||
bd322087 AL |
25 | /* from Linux's linux/virtio_balloon.h */ |
26 | ||
27 | /* The ID for virtio_balloon */ | |
28 | #define VIRTIO_ID_BALLOON 5 | |
29 | ||
30 | /* The feature bitmap for virtio balloon */ | |
31 | #define VIRTIO_BALLOON_F_MUST_TELL_HOST 0 /* Tell before reclaiming pages */ | |
625a5bef | 32 | #define VIRTIO_BALLOON_F_STATS_VQ 1 /* Memory stats virtqueue */ |
bd322087 AL |
33 | |
34 | /* Size of a PFN in the balloon interface. */ | |
35 | #define VIRTIO_BALLOON_PFN_SHIFT 12 | |
36 | ||
37 | struct virtio_balloon_config | |
38 | { | |
39 | /* Number of pages host wants Guest to give up. */ | |
40 | uint32_t num_pages; | |
41 | /* Number of pages we've actually got in balloon. */ | |
42 | uint32_t actual; | |
43 | }; | |
44 | ||
625a5bef AL |
45 | /* Memory Statistics */ |
46 | #define VIRTIO_BALLOON_S_SWAP_IN 0 /* Amount of memory swapped in */ | |
47 | #define VIRTIO_BALLOON_S_SWAP_OUT 1 /* Amount of memory swapped out */ | |
48 | #define VIRTIO_BALLOON_S_MAJFLT 2 /* Number of major faults */ | |
49 | #define VIRTIO_BALLOON_S_MINFLT 3 /* Number of minor faults */ | |
50 | #define VIRTIO_BALLOON_S_MEMFREE 4 /* Total amount of free memory */ | |
51 | #define VIRTIO_BALLOON_S_MEMTOT 5 /* Total amount of memory */ | |
52 | #define VIRTIO_BALLOON_S_NR 6 | |
53 | ||
54 | typedef struct VirtIOBalloonStat { | |
55 | uint16_t tag; | |
56 | uint64_t val; | |
541dc0d4 | 57 | } QEMU_PACKED VirtIOBalloonStat; |
625a5bef | 58 | |
f1b24e84 | 59 | typedef struct VirtIOBalloon { |
c96caced | 60 | VirtIODevice parent_obj; |
f1b24e84 FK |
61 | VirtQueue *ivq, *dvq, *svq; |
62 | uint32_t num_pages; | |
63 | uint32_t actual; | |
64 | uint64_t stats[VIRTIO_BALLOON_S_NR]; | |
65 | VirtQueueElement stats_vq_elem; | |
66 | size_t stats_vq_offset; | |
67 | QEMUTimer *stats_timer; | |
68 | int64_t stats_last_update; | |
69 | int64_t stats_poll_interval; | |
f1b24e84 FK |
70 | } VirtIOBalloon; |
71 | ||
bd322087 | 72 | #endif |