diff options
| author | Michael S. Tsirkin <mst@redhat.com> | 2015-04-14 20:47:43 -0400 |
|---|---|---|
| committer | Rusty Russell <rusty@rustcorp.com.au> | 2015-04-14 23:11:09 -0400 |
| commit | df81b29c7b81b9d70ee29b7a263dd5009daa0ce4 (patch) | |
| tree | a73a9ac6aa72aa32bd7e25a25148044025caa31f /include/uapi | |
| parent | 9e1a27ea42691429e31f158cce6fc61bc79bb2e9 (diff) | |
virtio_balloon: transitional interface
Virtio 1.0 doesn't include a modern balloon device.
But it's not a big change to support a transitional
balloon device: this has the advantage of supporting
existing drivers, transparently.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'include/uapi')
| -rw-r--r-- | include/uapi/linux/virtio_balloon.h | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/include/uapi/linux/virtio_balloon.h b/include/uapi/linux/virtio_balloon.h index 4b0488f20b2e..984169a819ee 100644 --- a/include/uapi/linux/virtio_balloon.h +++ b/include/uapi/linux/virtio_balloon.h | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 27 | * SUCH DAMAGE. */ | 27 | * SUCH DAMAGE. */ |
| 28 | #include <linux/types.h> | ||
| 28 | #include <linux/virtio_ids.h> | 29 | #include <linux/virtio_ids.h> |
| 29 | #include <linux/virtio_config.h> | 30 | #include <linux/virtio_config.h> |
| 30 | 31 | ||
| @@ -38,9 +39,9 @@ | |||
| 38 | 39 | ||
| 39 | struct virtio_balloon_config { | 40 | struct virtio_balloon_config { |
| 40 | /* Number of pages host wants Guest to give up. */ | 41 | /* Number of pages host wants Guest to give up. */ |
| 41 | __le32 num_pages; | 42 | __u32 num_pages; |
| 42 | /* Number of pages we've actually got in balloon. */ | 43 | /* Number of pages we've actually got in balloon. */ |
| 43 | __le32 actual; | 44 | __u32 actual; |
| 44 | }; | 45 | }; |
| 45 | 46 | ||
| 46 | #define VIRTIO_BALLOON_S_SWAP_IN 0 /* Amount of memory swapped in */ | 47 | #define VIRTIO_BALLOON_S_SWAP_IN 0 /* Amount of memory swapped in */ |
| @@ -51,9 +52,32 @@ struct virtio_balloon_config { | |||
| 51 | #define VIRTIO_BALLOON_S_MEMTOT 5 /* Total amount of memory */ | 52 | #define VIRTIO_BALLOON_S_MEMTOT 5 /* Total amount of memory */ |
| 52 | #define VIRTIO_BALLOON_S_NR 6 | 53 | #define VIRTIO_BALLOON_S_NR 6 |
| 53 | 54 | ||
| 55 | /* | ||
| 56 | * Memory statistics structure. | ||
| 57 | * Driver fills an array of these structures and passes to device. | ||
| 58 | * | ||
| 59 | * NOTE: fields are laid out in a way that would make compiler add padding | ||
| 60 | * between and after fields, so we have to use compiler-specific attributes to | ||
| 61 | * pack it, to disable this padding. This also often causes compiler to | ||
| 62 | * generate suboptimal code. | ||
| 63 | * | ||
| 64 | * We maintain this statistics structure format for backwards compatibility, | ||
| 65 | * but don't follow this example. | ||
| 66 | * | ||
| 67 | * If implementing a similar structure, do something like the below instead: | ||
| 68 | * struct virtio_balloon_stat { | ||
| 69 | * __virtio16 tag; | ||
| 70 | * __u8 reserved[6]; | ||
| 71 | * __virtio64 val; | ||
| 72 | * }; | ||
| 73 | * | ||
| 74 | * In other words, add explicit reserved fields to align field and | ||
| 75 | * structure boundaries at field size, avoiding compiler padding | ||
| 76 | * without the packed attribute. | ||
| 77 | */ | ||
| 54 | struct virtio_balloon_stat { | 78 | struct virtio_balloon_stat { |
| 55 | __u16 tag; | 79 | __virtio16 tag; |
| 56 | __u64 val; | 80 | __virtio64 val; |
| 57 | } __attribute__((packed)); | 81 | } __attribute__((packed)); |
| 58 | 82 | ||
| 59 | #endif /* _LINUX_VIRTIO_BALLOON_H */ | 83 | #endif /* _LINUX_VIRTIO_BALLOON_H */ |
