kvm tools: Add is_pio flag to ioeventfd__add_event

Add is_pio flag to set KVM_IOEVENTFD_FLAG_PIO. This is useful for
attaching an ioeventfd to MMIO address as well as PIO address.
virtio-mmio needs an ioeventfd to MMIO address.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: Rework on virtio transport abstraction.

This patch reworks on virtio transport abstraction.

* Move virtio transport operations to virtio operations and drop
  virtio/trans.c This makes the abstraction much cleaner.

* Rename struct virtio_trans to struct virtio_device

  struct virtio_trans {
       void                    *virtio;
       enum virtio_trans_type  type;
       struct virtio_trans_ops *trans_ops;
       struct virtio_ops       *virtio_ops;
  };

  struct virtio_device {
       void                    *virtio;
       struct virtio_ops       *ops;
  };

  The virtio_trans struct is bit confusing since it also includes virtio
  operations.

* Introduce virtio_init()
  To init device, e.g.
  Before:
	virtio_trans_init()
	ndev->vtrans.trans_ops->init()
	ndev->vtrans.virtio_ops = &net_dev_virtio_ops
  After:
	virtio_init()

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: Rename callback_mmio_table

Reanme callback_mmio_table to virtio_pci__mmio_callback

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: Introduce KVM_VIRTIO_MMIO_AREA

This area is used for virtio-mmio.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: Add virtio-mmio support

This patch is based on Sasha's 'kvm tools: Add support for virtio-mmio'
patch. ioeventfds support is added which was missing in the previous one.
VQ size/align is still not supported.

It adds support for the new virtio-mmio transport layer added in
3.2-rc1. The purpose of this new layer is to allow virtio to work on
systems which don't necessarily support PCI, such as embedded systems.

To apply the patch on top of the KVM tools tree, you must first pull
Linus' tree on top. Also, CONFIG_VIRTIO_MMIO=y should be set in the
guest kernel.

To easily test it it's recommended to apply Pawel Moll's patch named
'virtio-mmio: Devices parameter parsing' on top, and define the
virtio-mmio device using kernel command line.

LKVM will print a message to help user to figure out how to add kernel
command line to support virtio-mmio.

To instantiate guest virtio-mmio devices using kernel command line (or
module) parameter, e.g.

   virtio_mmio.devices=0x200@0xd2000000:5,0x200@0xd2000200:6

Cc: Pawel Moll <pawel.moll@arm.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: virtualization@lists.linux-foundation.org
Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: Support virtio-mmio in virtio_init

This patch adds virtio-mmio support in virtio_init.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: Introduce trans=mmio parameter for virtio-net

To select virtio-mmio instead of virito-pci transport:

   lkvm run --network trans=mmio

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: Increase virtio-blk and virtio-net queue size

Increase virtio-blk and virtio-net queue size to 256.
This makes virtio-mmio work.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: Add set_size_vq for virtio-net

set_size_vq does not do the actual work, we can implement this later.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: Add set_size_vq for virtio-blk

set_size_vq does not do the actual work, we can implement this later.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: Rename VIRTIO_P9 to VIRTIO_9P

This makes the naming more consistent.

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: Use enum for NET_MODE_{USER, TAP}

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: Small indentation fix

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
kvm tools: Drop unnecessary headers in barrier.h

Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>