virtio: make virtio device's structures public.
PATCH v4 1/1 virtio: make virtio device's structures public.
From: KONRAD Frederic <[email protected]>
These structures must be made public to avoid two memory allocations for refactored virtio devices.
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).
--- hw/virtio-balloon.c | 15 --------------- hw/virtio-balloon.h | 14 ++++++++++++++ hw/virtio-blk.c | 20 -------------------- hw/virtio-blk.h | 19 +++++++++++++++++++ hw/virtio-net.c | 50 -------------------------------------------------- hw/virtio-net.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ hw/virtio-rng.c | 19 ------------------- hw/virtio-rng.h | 19 +++++++++++++++++++ hw/virtio-scsi.c | 15 --------------- hw/virtio-scsi.h | 16 ++++++++++++++++ hw/virtio-serial-bus.c | 41 ----------------------------------------- hw/virtio-serial.h | 41 +++++++++++++++++++++++++++++++++++++++++ 12 files changed, 159 insertions(+), 160 deletions(-)
hw/virtio-balloon.c +0 -15
@@ -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;
hw/virtio-balloon.h +14 -0
@@ -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
hw/virtio-blk.c +0 -20
@@ -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;
hw/virtio-blk.h +19 -0
@@ -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 VirtIOBlkConfuint32_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)
hw/virtio-net.c +0 -50
56 lines not on this page · raw message
hw/virtio-net.h +50 -0
56 lines not on this page · raw message
hw/virtio-rng.c +0 -19
@@ -16,25 +16,6 @@#include "hw/virtio-rng.h" #include "qemu/rng.h" -typedef struct VirtIORNG { -VirtIODevice vdev; - -DeviceState *qdev; - -/* Only one vq - guest puts buffer(s) on it when it needs entropy */ -VirtQueue *vq; - -VirtIORNGConf *conf; - -RngBackend *rng; - -/* We purposefully don't migrate this state. The quota will reset on the -* destination as a result. Rate limiting is host state, not guest state. -*/ -QEMUTimer *rate_limit_timer; -int64_t quota_remaining; -}VirtIORNG ; -static bool is_guest_ready (VirtIORNG *vrng) { if (virtio_queue_ready(vrng->vq)
hw/virtio-rng.h +19 -0
@@ -25,4 +25,23 @@ struct VirtIORNGConf { RndRandom *default_backend; }; +typedef struct VirtIORNG { +VirtIODevice vdev; + +DeviceState *qdev; + +/* Only one vq - guest puts buffer(s) on it when it needs entropy */ +VirtQueue *vq; + +VirtIORNGConf *conf; + +RngBackend *rng; + +/* We purposefully don't migrate this state. The quota will reset on the +* destination as a result. Rate limiting is host state, not guest state. +*/ +QEMUTimer *rate_limit_timer; +int64_t quota_remaining; +}VirtIORNG ; +#endif
hw/virtio-scsi.c +0 -15
@@ -130,21 +130,6 @@ typedef struct {uint32_t max_lun; }QEMU_PACKED VirtIOSCSIConfig; -typedef struct { -VirtIODevice vdev; -DeviceState *qdev; -VirtIOSCSIConf *conf; - -SCSIBus bus; -uint32_t sense_size; -uint32_t cdb_size; -int resetting; -bool events_dropped; -VirtQueue *ctrl_vq; -VirtQueue *event_vq; -VirtQueue *cmd_vqs[0 ]; -}VirtIOSCSI ; - typedef struct VirtIOSCSIReq { VirtIOSCSI *dev; VirtQueue *vq;
hw/virtio-scsi.h +16 -0
@@ -16,6 +16,7 @@#include "hw/virtio.h" #include "hw/pci/pci.h" +#include "hw/scsi.h" /* The ID for virtio_scsi */ #define VIRTIO_ID_SCSI 8
@@ -31,6 +32,21 @@ struct VirtIOSCSIConf {uint32_t cmd_per_lun; }; +typedef struct VirtIOSCSI { +VirtIODevice vdev; +DeviceState *qdev; +VirtIOSCSIConf *conf; + +SCSIBus bus; +uint32_t sense_size; +uint32_t cdb_size; +int resetting; +bool events_dropped; +VirtQueue *ctrl_vq; +VirtQueue *event_vq; +VirtQueue *cmd_vqs[0 ]; +}VirtIOSCSI ; +#define DEFINE_VIRTIO_SCSI_PROPERTIES (_state, _features_field, _conf_field) \ DEFINE_VIRTIO_COMMON_FEATURES(_state, _features_field), \ DEFINE_PROP_UINT32("num_queues", _state, _conf_field.num_queues, 1), \
hw/virtio-serial-bus.c +0 -41
47 lines not on this page · raw message
hw/virtio-serial.h +41 -0
47 lines not on this page · raw message
Signature · 1 line
1.7.11.7
Quoted 7 lines · On 12 March 2013 08:37, <[email protected]> wrote:
From: KONRAD Frederic <[email protected]>
These structures must be made public to avoid two memory allocations for refactored virtio devices.
Signed-off-by KONRAD Frederic <[email protected]>Reviewed-by Andreas Färber <[email protected]>
-- PMM
Anthony Liguori
AppliedApplied. Thanks.
Regards,
Anthony Liguori