Commit f1b24e84 authored by KONRAD Frederic's avatar KONRAD Frederic Committed by Anthony Liguori
Browse files

virtio: make virtio device's structures public.



These structures must be made public to avoid two memory allocations for
refactored virtio devices.

Signed-off-by: default avatarKONRAD Frederic <fred.konrad@greensocs.com>
Reviewed-by: default avatarAndreas Färber <afaerber@suse.de>
Reviewed-by: default avatarPeter Maydell <peter.maydell@linaro.org>
Reviewed-by: default avatarAndreas Färber <afaerber@suse.de>
Message-id: 1363624648-16906-2-git-send-email-fred.konrad@greensocs.com

Changes V4 <- V3:
   * Rebased on current git.

Changes V3 <- V2:
    * Style correction spotted by Andreas (virtio-scsi.h).
    * Style correction for virtio-net.h.

Changes V2 <- V1:
    * Move the dataplane include into the header (virtio-blk).
Signed-off-by: default avatarAnthony Liguori <aliguori@us.ibm.com>
parent e531761d
Loading
Loading
Loading
Loading
+0 −15
Original line number Diff line number Diff line
@@ -29,21 +29,6 @@
#include <sys/mman.h>
#endif

typedef struct VirtIOBalloon
{
    VirtIODevice vdev;
    VirtQueue *ivq, *dvq, *svq;
    uint32_t num_pages;
    uint32_t actual;
    uint64_t stats[VIRTIO_BALLOON_S_NR];
    VirtQueueElement stats_vq_elem;
    size_t stats_vq_offset;
    QEMUTimer *stats_timer;
    int64_t stats_last_update;
    int64_t stats_poll_interval;
    DeviceState *qdev;
} VirtIOBalloon;

static VirtIOBalloon *to_virtio_balloon(VirtIODevice *vdev)
{
    return (VirtIOBalloon *)vdev;
+14 −0
Original line number Diff line number Diff line
@@ -52,4 +52,18 @@ typedef struct VirtIOBalloonStat {
    uint64_t val;
} QEMU_PACKED VirtIOBalloonStat;

typedef struct VirtIOBalloon {
    VirtIODevice vdev;
    VirtQueue *ivq, *dvq, *svq;
    uint32_t num_pages;
    uint32_t actual;
    uint64_t stats[VIRTIO_BALLOON_S_NR];
    VirtQueueElement stats_vq_elem;
    size_t stats_vq_offset;
    QEMUTimer *stats_timer;
    int64_t stats_last_update;
    int64_t stats_poll_interval;
    DeviceState *qdev;
} VirtIOBalloon;

#endif
+0 −20
Original line number Diff line number Diff line
@@ -17,31 +17,11 @@
#include "hw/block-common.h"
#include "sysemu/blockdev.h"
#include "hw/virtio-blk.h"
#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
#include "dataplane/virtio-blk.h"
#endif
#include "hw/scsi-defs.h"
#ifdef __linux__
# include <scsi/sg.h>
#endif

typedef struct VirtIOBlock
{
    VirtIODevice vdev;
    BlockDriverState *bs;
    VirtQueue *vq;
    void *rq;
    QEMUBH *bh;
    BlockConf *conf;
    VirtIOBlkConf *blk;
    unsigned short sector_mask;
    DeviceState *qdev;
    VMChangeStateEntry *change;
#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
    VirtIOBlockDataPlane *dataplane;
#endif
} VirtIOBlock;

static VirtIOBlock *to_virtio_blk(VirtIODevice *vdev)
{
    return (VirtIOBlock *)vdev;
+19 −0
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

#include "hw/virtio.h"
#include "hw/block-common.h"
#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
#include "dataplane/virtio-blk.h"
#endif

/* from Linux's linux/virtio_blk.h */

@@ -108,6 +111,22 @@ struct VirtIOBlkConf
    uint32_t data_plane;
};

typedef struct VirtIOBlock {
    VirtIODevice vdev;
    BlockDriverState *bs;
    VirtQueue *vq;
    void *rq;
    QEMUBH *bh;
    BlockConf *conf;
    VirtIOBlkConf *blk;
    unsigned short sector_mask;
    DeviceState *qdev;
    VMChangeStateEntry *change;
#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
    VirtIOBlockDataPlane *dataplane;
#endif
} VirtIOBlock;

#define DEFINE_VIRTIO_BLK_FEATURES(_state, _field) \
        DEFINE_VIRTIO_COMMON_FEATURES(_state, _field)

+0 −50
Original line number Diff line number Diff line
@@ -26,56 +26,6 @@
#define MAC_TABLE_ENTRIES    64
#define MAX_VLAN    (1 << 12)   /* Per 802.1Q definition */

typedef struct VirtIONetQueue {
    VirtQueue *rx_vq;
    VirtQueue *tx_vq;
    QEMUTimer *tx_timer;
    QEMUBH *tx_bh;
    int tx_waiting;
    struct {
        VirtQueueElement elem;
        ssize_t len;
    } async_tx;
    struct VirtIONet *n;
} VirtIONetQueue;

typedef struct VirtIONet
{
    VirtIODevice vdev;
    uint8_t mac[ETH_ALEN];
    uint16_t status;
    VirtIONetQueue *vqs;
    VirtQueue *ctrl_vq;
    NICState *nic;
    uint32_t tx_timeout;
    int32_t tx_burst;
    uint32_t has_vnet_hdr;
    size_t host_hdr_len;
    size_t guest_hdr_len;
    uint8_t has_ufo;
    int mergeable_rx_bufs;
    uint8_t promisc;
    uint8_t allmulti;
    uint8_t alluni;
    uint8_t nomulti;
    uint8_t nouni;
    uint8_t nobcast;
    uint8_t vhost_started;
    struct {
        int in_use;
        int first_multi;
        uint8_t multi_overflow;
        uint8_t uni_overflow;
        uint8_t *macs;
    } mac_table;
    uint32_t *vlans;
    DeviceState *qdev;
    int multiqueue;
    uint16_t max_queues;
    uint16_t curr_queues;
    size_t config_size;
} VirtIONet;

/*
 * Calculate the number of bytes up to and including the given 'field' of
 * 'container'.
Loading