qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2 00/17] virtio: pull headers from linux


From: Michael S. Tsirkin
Subject: [Qemu-devel] [PATCH v2 00/17] virtio: pull headers from linux
Date: Sun, 15 Feb 2015 12:38:30 +0100

This reuses virtio headers from files exported by linux.
The current situation is quite messy: for example we
have multiple copies of the virtio net packet structure,
and the virtio ring structure.
We already use some of them for linux-specific code,
reusing more widely gets rid of code duplication.

One of the reasons we didn't do this previously
was portability considerations: this patchset addresses
this by fixing up headers in question - turns out to
be easy to do since they are already quite portable.

One of comments asked about support for functionality missing from linux
guests. This patchet addresses this simply by adding code in include/hw/virtio
like we did before.
One example of this is VIRTIO_NET_CTRL_GUEST_OFFLOADS command in
virtio-net, which is currently only used by windows guests.
The definition was therefore left in include/hw/virtio/virtio-net.h,
this approach makes it easy to find functionality that linux guests
are missing, which is important e.g. for testing.

Ability to synchronize headers in this way will bring long-term benefits in
case bugfixes need to apply to both host and guest.

In particular, this gives us known-good virtio 1.0 headers for free, right now.

This refactoring also better separates between guest ABI and internal
qemu functionality, which is a good thing as we need to be extra
careful about guest ABI changes.

This might also enable better static checking with sparse,
as linux tags virtio headers with correct endian-ness.
For now, sparse tags are automatically stripped, for
compatibility with existing code.

Some pieces are more widely applicable (outside virtio): e.g.
everyone will be able to pull ETH_ALEN from the
standard header.

The infrastructure also might be of use for other headers (pci_regs.h)?

Lightly tested on x86.
While I applied refactoring to s390 code as well, these patches
are untested, and aren't a mandatory part of the series.
Testing (even just build-test) reports would be very much appreciated.

Changes from v1:
    - add s390 headers (untested)
    - add code to check no unexpected linux-specific headers are pulled in
      by mistake
    - add if_ether.h to provide ETH_ALEN for virtio net
    - move headers from standard-headers/linux to standard-headers/sys
      and put them under include so they are on search path
    - fix up __leXX
    - fix up __attribute__((packed))


Michael S. Tsirkin (17):
  scripts/update-linux-headers.sh: pull virtio hdrs
  include: import virtio headers from linux 4.0
  virtio: use standard virtio_ring.h
  virtio: use standard-headers
  virtio-balloon: use standard headers
  virtio-9p: use standard headers
  virtio-blk: switch to standard-headers
  virtio-net,tap: use standard-headers
  virtio-rng: use standard-headers
  virtio-scsi: use standard-headers
  virtio-serial: switch to standard-headers
  update-linux-headers: use standard-headers
  linux-headers: use standard-headers
  virtio-pci: use standard headers
  scripts: add arch specific standard-headers
  standard-headers: add s390 virtio headers
  s390: use standard headers

 hw/9pfs/virtio-9p.h                                |  18 +-
 hw/s390x/s390-virtio-bus.h                         |  36 ++--
 hw/s390x/s390-virtio.h                             |   7 +-
 include/hw/virtio/dataplane/vring.h                |   2 +-
 include/hw/virtio/virtio-balloon.h                 |  35 +---
 include/hw/virtio/virtio-blk.h                     |  77 +------
 include/hw/virtio/virtio-net.h                     | 151 +------------
 include/hw/virtio/virtio-rng.h                     |   4 +-
 include/hw/virtio/virtio-scsi.h                    | 120 +----------
 include/hw/virtio/virtio-serial.h                  |  40 +---
 include/hw/virtio/virtio.h                         |  48 +----
 include/net/tap.h                                  |  24 +--
 include/standard-headers/asm-s390/kvm_virtio.h     |  64 ++++++
 include/standard-headers/asm-s390/virtio-ccw.h     |  21 ++
 include/standard-headers/sys/if_ether.h            |   1 +
 include/standard-headers/sys/types.h               |   2 +
 include/standard-headers/sys/virtio_9p.h           |  44 ++++
 include/standard-headers/sys/virtio_balloon.h      |  59 ++++++
 include/standard-headers/sys/virtio_blk.h          | 143 +++++++++++++
 include/standard-headers/sys/virtio_config.h       |  64 ++++++
 include/standard-headers/sys/virtio_console.h      |  78 +++++++
 include/standard-headers/sys/virtio_ids.h          |  43 ++++
 include/standard-headers/sys/virtio_net.h          | 233 +++++++++++++++++++++
 include/standard-headers/sys/virtio_pci.h          | 193 +++++++++++++++++
 .../virtio => standard-headers/sys}/virtio_ring.h  | 138 ++++++------
 include/standard-headers/sys/virtio_rng.h          |   8 +
 include/standard-headers/sys/virtio_scsi.h         | 164 +++++++++++++++
 include/standard-headers/sys/virtio_types.h        |  46 ++++
 linux-headers/linux/virtio_config.h                |  58 +----
 linux-headers/linux/virtio_ring.h                  | 164 +--------------
 hw/block/virtio-blk.c                              |   8 +-
 hw/char/virtio-serial-bus.c                        |   1 +
 hw/net/vhost_net.c                                 |   2 +-
 hw/scsi/virtio-scsi.c                              |   1 +
 hw/virtio/virtio-pci.c                             |  54 +----
 hw/virtio/virtio.c                                 |  23 +-
 scripts/update-linux-headers.sh                    |  51 ++++-
 37 files changed, 1345 insertions(+), 880 deletions(-)
 create mode 100644 include/standard-headers/asm-s390/kvm_virtio.h
 create mode 100644 include/standard-headers/asm-s390/virtio-ccw.h
 create mode 100644 include/standard-headers/sys/if_ether.h
 create mode 100644 include/standard-headers/sys/types.h
 create mode 100644 include/standard-headers/sys/virtio_9p.h
 create mode 100644 include/standard-headers/sys/virtio_balloon.h
 create mode 100644 include/standard-headers/sys/virtio_blk.h
 create mode 100644 include/standard-headers/sys/virtio_config.h
 create mode 100644 include/standard-headers/sys/virtio_console.h
 create mode 100644 include/standard-headers/sys/virtio_ids.h
 create mode 100644 include/standard-headers/sys/virtio_net.h
 create mode 100644 include/standard-headers/sys/virtio_pci.h
 rename include/{hw/virtio => standard-headers/sys}/virtio_ring.h (57%)
 create mode 100644 include/standard-headers/sys/virtio_rng.h
 create mode 100644 include/standard-headers/sys/virtio_scsi.h
 create mode 100644 include/standard-headers/sys/virtio_types.h

-- 
MST




reply via email to

[Prev in Thread] Current Thread [Next in Thread]