Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1842f23c authored by Rusty Russell's avatar Rusty Russell
Browse files

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: default avatarRusty Russell <rusty@rustcorp.com.au>
Cc: Ingo Molnar <mingo@redhat.com>
parent a91d74a3
Loading
Loading
Loading
Loading
+5 −16
Original line number Diff line number Diff line
@@ -93,8 +93,7 @@ static int lguest_fd;
static unsigned int __thread cpu_id;

/* This is our list of devices. */
struct device_list
{
struct device_list {
	/* Counter to assign interrupt numbers. */
	unsigned int next_irq;

@@ -114,8 +113,7 @@ struct device_list
static struct device_list devices;

/* The device structure describes a single device. */
struct device
{
struct device {
	/* The linked-list pointer. */
	struct device *next;

@@ -140,8 +138,7 @@ struct device
};

/* The virtqueue structure describes a queue attached to a device. */
struct virtqueue
{
struct virtqueue {
	struct virtqueue *next;

	/* Which device owns me. */
@@ -779,8 +776,7 @@ static void add_used_and_trigger(struct virtqueue *vq, unsigned head, int len)
 *
 * We associate some data with the console for our exit hack.
 */
struct console_abort
{
struct console_abort {
	/* How many times have they hit ^C? */
	int count;
	/* When did they start? */
@@ -1570,20 +1566,13 @@ static void setup_tun_net(char *arg)
/*:*/

/* This hangs off device->priv. */
struct vblk_info
{
struct vblk_info {
	/* The size of the file. */
	off64_t len;

	/* The file descriptor for the file. */
	int fd;

	/* IO thread listens on this file descriptor [0]. */
	int workpipe[2];

	/* IO thread writes to this file descriptor to mark it done, then
	 * Launcher triggers interrupt to Guest. */
	int done_fd;
};

/*L:210
+3 −6
Original line number Diff line number Diff line
@@ -16,15 +16,13 @@
void free_pagetables(void);
int init_pagetables(struct page **switcher_page, unsigned int pages);

struct pgdir
{
struct pgdir {
	unsigned long gpgdir;
	pgd_t *pgdir;
};

/* We have two pages shared with guests, per cpu.  */
struct lguest_pages
{
struct lguest_pages {
	/* This is the stack page mapped rw in guest */
	char spare[PAGE_SIZE - sizeof(struct lguest_regs)];
	struct lguest_regs regs;
@@ -89,8 +87,7 @@ struct lg_eventfd_map {
};

/* The private info the thread maintains about the guest. */
struct lguest
{
struct lguest {
	struct lguest_data __user *lguest_data;
	struct lg_cpu cpus[NR_CPUS];
	unsigned int nr_cpus;
+1 −2
Original line number Diff line number Diff line
@@ -207,8 +207,7 @@ static void lg_reset(struct virtio_device *vdev)
 */

/*D:140 This is the information we remember about each virtqueue. */
struct lguest_vq_info
{
struct lguest_vq_info {
	/* A copy of the information contained in the device config. */
	struct lguest_vqconfig config;

+1 −2
Original line number Diff line number Diff line
@@ -18,8 +18,7 @@
 * lguest_data".  Once the Guest's initialization hypercall tells the Host where
 * this is, the Guest and Host both publish information in it.
:*/
struct lguest_data
{
struct lguest_data {
	/*
	 * 512 == enabled (same as eflags in normal hardware).  The Guest
	 * changes interrupts so often that a hypercall is too slow.
+2 −4
Original line number Diff line number Diff line
@@ -20,8 +20,7 @@

#define VIRTIO_BLK_ID_BYTES	(sizeof(__u16[256]))	/* IDENTIFY DATA */

struct virtio_blk_config
{
struct virtio_blk_config {
	/* The capacity (in 512-byte sectors). */
	__u64 capacity;
	/* The maximum segment size (if VIRTIO_BLK_F_SIZE_MAX) */
@@ -50,8 +49,7 @@ struct virtio_blk_config
#define VIRTIO_BLK_T_BARRIER	0x80000000

/* This is the first element of the read scatter-gather list. */
struct virtio_blk_outhdr
{
struct virtio_blk_outhdr {
	/* VIRTIO_BLK_T* */
	__u32 type;
	/* io priority. */
Loading