aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2009-07-30 18:03:46 -0400
committerRusty Russell <rusty@rustcorp.com.au>2009-07-30 02:33:46 -0400
commit1842f23c05b6a866be831aa60bc8a8731c58ddd0 (patch)
tree8047f21d149b3958b5c4278c1a5601ddce9e0e4b
parenta91d74a3c4de8115295ee87350c13a329164aaaf (diff)
lguest and virtio: cleanup struct definitions to Linux style.
I've been doing this for years, and akpm picked me up on it about 12 months ago. lguest partly serves as example code, so let's do it Right. Also, remove two unused fields in struct vblk_info in the example launcher. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Cc: Ingo Molnar <mingo@redhat.com>
-rw-r--r--Documentation/lguest/lguest.c21
-rw-r--r--drivers/lguest/lg.h9
-rw-r--r--drivers/lguest/lguest_device.c3
-rw-r--r--include/linux/lguest.h3
-rw-r--r--include/linux/virtio_blk.h6
-rw-r--r--include/linux/virtio_config.h3
-rw-r--r--include/linux/virtio_net.h6
-rw-r--r--include/linux/virtio_ring.h12
8 files changed, 19 insertions, 44 deletions
diff --git a/Documentation/lguest/lguest.c b/Documentation/lguest/lguest.c
index 45163651b519..950cde6d6e58 100644
--- a/Documentation/lguest/lguest.c
+++ b/Documentation/lguest/lguest.c
@@ -93,8 +93,7 @@ static int lguest_fd;
93static unsigned int __thread cpu_id; 93static unsigned int __thread cpu_id;
94 94
95/* This is our list of devices. */ 95/* This is our list of devices. */
96struct device_list 96struct device_list {
97{
98 /* Counter to assign interrupt numbers. */ 97 /* Counter to assign interrupt numbers. */
99 unsigned int next_irq; 98 unsigned int next_irq;
100 99
@@ -114,8 +113,7 @@ struct device_list
114static struct device_list devices; 113static struct device_list devices;
115 114
116/* The device structure describes a single device. */ 115/* The device structure describes a single device. */
117struct device 116struct device {
118{
119 /* The linked-list pointer. */ 117 /* The linked-list pointer. */
120 struct device *next; 118 struct device *next;
121 119
@@ -140,8 +138,7 @@ struct device
140}; 138};
141 139
142/* The virtqueue structure describes a queue attached to a device. */ 140/* The virtqueue structure describes a queue attached to a device. */
143struct virtqueue 141struct virtqueue {
144{
145 struct virtqueue *next; 142 struct virtqueue *next;
146 143
147 /* Which device owns me. */ 144 /* Which device owns me. */
@@ -779,8 +776,7 @@ static void add_used_and_trigger(struct virtqueue *vq, unsigned head, int len)
779 * 776 *
780 * We associate some data with the console for our exit hack. 777 * We associate some data with the console for our exit hack.
781 */ 778 */
782struct console_abort 779struct console_abort {
783{
784 /* How many times have they hit ^C? */ 780 /* How many times have they hit ^C? */
785 int count; 781 int count;
786 /* When did they start? */ 782 /* When did they start? */
@@ -1570,20 +1566,13 @@ static void setup_tun_net(char *arg)
1570/*:*/ 1566/*:*/
1571 1567
1572/* This hangs off device->priv. */ 1568/* This hangs off device->priv. */
1573struct vblk_info 1569struct vblk_info {
1574{
1575 /* The size of the file. */ 1570 /* The size of the file. */
1576 off64_t len; 1571 off64_t len;
1577 1572
1578 /* The file descriptor for the file. */ 1573 /* The file descriptor for the file. */
1579 int fd; 1574 int fd;
1580 1575
1581 /* IO thread listens on this file descriptor [0]. */
1582 int workpipe[2];
1583
1584 /* IO thread writes to this file descriptor to mark it done, then
1585 * Launcher triggers interrupt to Guest. */
1586 int done_fd;
1587}; 1576};
1588 1577
1589/*L:210 1578/*L:210
diff --git a/drivers/lguest/lg.h b/drivers/lguest/lg.h
index 74c0db691b53..bc28745d05af 100644
--- a/drivers/lguest/lg.h
+++ b/drivers/lguest/lg.h
@@ -16,15 +16,13 @@
16void free_pagetables(void); 16void free_pagetables(void);
17int init_pagetables(struct page **switcher_page, unsigned int pages); 17int init_pagetables(struct page **switcher_page, unsigned int pages);
18 18
19struct pgdir 19struct pgdir {
20{
21 unsigned long gpgdir; 20 unsigned long gpgdir;
22 pgd_t *pgdir; 21 pgd_t *pgdir;
23}; 22};
24 23
25/* We have two pages shared with guests, per cpu. */ 24/* We have two pages shared with guests, per cpu. */
26struct lguest_pages 25struct lguest_pages {
27{
28 /* This is the stack page mapped rw in guest */ 26 /* This is the stack page mapped rw in guest */
29 char spare[PAGE_SIZE - sizeof(struct lguest_regs)]; 27 char spare[PAGE_SIZE - sizeof(struct lguest_regs)];
30 struct lguest_regs regs; 28 struct lguest_regs regs;
@@ -89,8 +87,7 @@ struct lg_eventfd_map {
89}; 87};
90 88
91/* The private info the thread maintains about the guest. */ 89/* The private info the thread maintains about the guest. */
92struct lguest 90struct lguest {
93{
94 struct lguest_data __user *lguest_data; 91 struct lguest_data __user *lguest_data;
95 struct lg_cpu cpus[NR_CPUS]; 92 struct lg_cpu cpus[NR_CPUS];
96 unsigned int nr_cpus; 93 unsigned int nr_cpus;
diff --git a/drivers/lguest/lguest_device.c b/drivers/lguest/lguest_device.c
index 1401c1ace1ec..b6200bc39b58 100644
--- a/drivers/lguest/lguest_device.c
+++ b/drivers/lguest/lguest_device.c
@@ -207,8 +207,7 @@ static void lg_reset(struct virtio_device *vdev)
207 */ 207 */
208 208
209/*D:140 This is the information we remember about each virtqueue. */ 209/*D:140 This is the information we remember about each virtqueue. */
210struct lguest_vq_info 210struct lguest_vq_info {
211{
212 /* A copy of the information contained in the device config. */ 211 /* A copy of the information contained in the device config. */
213 struct lguest_vqconfig config; 212 struct lguest_vqconfig config;
214 213
diff --git a/include/linux/lguest.h b/include/linux/lguest.h
index 0a3a11afd64b..2fb1dcbcb5aa 100644
--- a/include/linux/lguest.h
+++ b/include/linux/lguest.h
@@ -18,8 +18,7 @@
18 * lguest_data". Once the Guest's initialization hypercall tells the Host where 18 * lguest_data". Once the Guest's initialization hypercall tells the Host where
19 * this is, the Guest and Host both publish information in it. 19 * this is, the Guest and Host both publish information in it.
20:*/ 20:*/
21struct lguest_data 21struct lguest_data {
22{
23 /* 22 /*
24 * 512 == enabled (same as eflags in normal hardware). The Guest 23 * 512 == enabled (same as eflags in normal hardware). The Guest
25 * changes interrupts so often that a hypercall is too slow. 24 * changes interrupts so often that a hypercall is too slow.
diff --git a/include/linux/virtio_blk.h b/include/linux/virtio_blk.h
index be7d255fc7cf..8dab9f2b8832 100644
--- a/include/linux/virtio_blk.h
+++ b/include/linux/virtio_blk.h
@@ -20,8 +20,7 @@
20 20
21#define VIRTIO_BLK_ID_BYTES (sizeof(__u16[256])) /* IDENTIFY DATA */ 21#define VIRTIO_BLK_ID_BYTES (sizeof(__u16[256])) /* IDENTIFY DATA */
22 22
23struct virtio_blk_config 23struct virtio_blk_config {
24{
25 /* The capacity (in 512-byte sectors). */ 24 /* The capacity (in 512-byte sectors). */
26 __u64 capacity; 25 __u64 capacity;
27 /* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */ 26 /* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */
@@ -50,8 +49,7 @@ struct virtio_blk_config
50#define VIRTIO_BLK_T_BARRIER 0x80000000 49#define VIRTIO_BLK_T_BARRIER 0x80000000
51 50
52/* This is the first element of the read scatter-gather list. */ 51/* This is the first element of the read scatter-gather list. */
53struct virtio_blk_outhdr 52struct virtio_blk_outhdr {
54{
55 /* VIRTIO_BLK_T* */ 53 /* VIRTIO_BLK_T* */
56 __u32 type; 54 __u32 type;
57 /* io priority. */ 55 /* io priority. */
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index 99f514575f6a..e547e3c8ee9a 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -79,8 +79,7 @@
79 * the dev->feature bits if it wants. 79 * the dev->feature bits if it wants.
80 */ 80 */
81typedef void vq_callback_t(struct virtqueue *); 81typedef void vq_callback_t(struct virtqueue *);
82struct virtio_config_ops 82struct virtio_config_ops {
83{
84 void (*get)(struct virtio_device *vdev, unsigned offset, 83 void (*get)(struct virtio_device *vdev, unsigned offset,
85 void *buf, unsigned len); 84 void *buf, unsigned len);
86 void (*set)(struct virtio_device *vdev, unsigned offset, 85 void (*set)(struct virtio_device *vdev, unsigned offset,
diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
index 9c543d6ac535..d8dd539c9f48 100644
--- a/include/linux/virtio_net.h
+++ b/include/linux/virtio_net.h
@@ -31,8 +31,7 @@
31 31
32#define VIRTIO_NET_S_LINK_UP 1 /* Link is up */ 32#define VIRTIO_NET_S_LINK_UP 1 /* Link is up */
33 33
34struct virtio_net_config 34struct virtio_net_config {
35{
36 /* The config defining mac address (if VIRTIO_NET_F_MAC) */ 35 /* The config defining mac address (if VIRTIO_NET_F_MAC) */
37 __u8 mac[6]; 36 __u8 mac[6];
38 /* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */ 37 /* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */
@@ -41,8 +40,7 @@ struct virtio_net_config
41 40
42/* This is the first element of the scatter-gather list. If you don't 41/* This is the first element of the scatter-gather list. If you don't
43 * specify GSO or CSUM features, you can simply ignore the header. */ 42 * specify GSO or CSUM features, you can simply ignore the header. */
44struct virtio_net_hdr 43struct virtio_net_hdr {
45{
46#define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 // Use csum_start, csum_offset 44#define VIRTIO_NET_HDR_F_NEEDS_CSUM 1 // Use csum_start, csum_offset
47 __u8 flags; 45 __u8 flags;
48#define VIRTIO_NET_HDR_GSO_NONE 0 // Not a GSO frame 46#define VIRTIO_NET_HDR_GSO_NONE 0 // Not a GSO frame
diff --git a/include/linux/virtio_ring.h b/include/linux/virtio_ring.h
index 693e0ec5afa6..e4d144b132b5 100644
--- a/include/linux/virtio_ring.h
+++ b/include/linux/virtio_ring.h
@@ -30,8 +30,7 @@
30#define VIRTIO_RING_F_INDIRECT_DESC 28 30#define VIRTIO_RING_F_INDIRECT_DESC 28
31 31
32/* Virtio ring descriptors: 16 bytes. These can chain together via "next". */ 32/* Virtio ring descriptors: 16 bytes. These can chain together via "next". */
33struct vring_desc 33struct vring_desc {
34{
35 /* Address (guest-physical). */ 34 /* Address (guest-physical). */
36 __u64 addr; 35 __u64 addr;
37 /* Length. */ 36 /* Length. */
@@ -42,24 +41,21 @@ struct vring_desc
42 __u16 next; 41 __u16 next;
43}; 42};
44 43
45struct vring_avail 44struct vring_avail {
46{
47 __u16 flags; 45 __u16 flags;
48 __u16 idx; 46 __u16 idx;
49 __u16 ring[]; 47 __u16 ring[];
50}; 48};
51 49
52/* u32 is used here for ids for padding reasons. */ 50/* u32 is used here for ids for padding reasons. */
53struct vring_used_elem 51struct vring_used_elem {
54{
55 /* Index of start of used descriptor chain. */ 52 /* Index of start of used descriptor chain. */
56 __u32 id; 53 __u32 id;
57 /* Total length of the descriptor chain which was used (written to) */ 54 /* Total length of the descriptor chain which was used (written to) */
58 __u32 len; 55 __u32 len;
59}; 56};
60 57
61struct vring_used 58struct vring_used {
62{
63 __u16 flags; 59 __u16 flags;
64 __u16 idx; 60 __u16 idx;
65 struct vring_used_elem ring[]; 61 struct vring_used_elem ring[];