Tizen 2.1 base
[sdk/emulator/qemu.git] / hw / virtio-balloon.h
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
15 #ifndef _QEMU_VIRTIO_BALLOON_H
16 #define _QEMU_VIRTIO_BALLOON_H
17
18 #include "sysbus.h"
19 #include "virtio.h"
20 #include "pci.h"
21 #include "virtio-transport.h"
22
23 /* from Linux's linux/virtio_balloon.h */
24
25 /* The ID for virtio_balloon */
26 #define VIRTIO_ID_BALLOON 5
27
28 /* The feature bitmap for virtio balloon */
29 #define VIRTIO_BALLOON_F_MUST_TELL_HOST 0 /* Tell before reclaiming pages */
30 #define VIRTIO_BALLOON_F_STATS_VQ 1       /* Memory stats virtqueue */
31
32 /* Size of a PFN in the balloon interface. */
33 #define VIRTIO_BALLOON_PFN_SHIFT 12
34
35 struct virtio_balloon_config
36 {
37     /* Number of pages host wants Guest to give up. */
38     uint32_t num_pages;
39     /* Number of pages we've actually got in balloon. */
40     uint32_t actual;
41 };
42
43 /* Memory Statistics */
44 #define VIRTIO_BALLOON_S_SWAP_IN  0   /* Amount of memory swapped in */
45 #define VIRTIO_BALLOON_S_SWAP_OUT 1   /* Amount of memory swapped out */
46 #define VIRTIO_BALLOON_S_MAJFLT   2   /* Number of major faults */
47 #define VIRTIO_BALLOON_S_MINFLT   3   /* Number of minor faults */
48 #define VIRTIO_BALLOON_S_MEMFREE  4   /* Total amount of free memory */
49 #define VIRTIO_BALLOON_S_MEMTOT   5   /* Total amount of memory */
50 #define VIRTIO_BALLOON_S_NR       6
51
52 typedef struct VirtIOBalloonStat {
53     uint16_t tag;
54     uint64_t val;
55 } QEMU_PACKED VirtIOBalloonStat;
56
57 typedef struct {
58     DeviceState qdev;
59     VirtIOTransportLink *trl;
60 } VirtIOBaloonState;
61
62 #define VIRTIO_BALLOON_FROM_QDEV(dev) DO_UPCAST(VirtIOBaloonState, qdev, dev)
63
64 #endif