From: fred.konrad@greensocs.com
To: qemu-devel@nongnu.org, aliguori@us.ibm.com
Cc: kwolf@redhat.com, peter.maydell@linaro.org,
e.voevodin@samsung.com, mst@redhat.com,
mark.burton@greensocs.com, agraf@suse.de, amit.shah@redhat.com,
aneesh.kumar@linux.vnet.ibm.com, stefanha@redhat.com,
deepakcs@linux.vnet.ibm.com, cornelia.huck@de.ibm.com,
pbonzini@redhat.com, afaerber@suse.de, fred.konrad@greensocs.com
Subject: [Qemu-devel] [PATCH V3 01/44] virtio: make virtio device's structures public.
Date: Tue, 15 Jan 2013 15:09:15 +0100 [thread overview]
Message-ID: <1358258998-6504-2-git-send-email-fred.konrad@greensocs.com> (raw)
In-Reply-To: <1358258998-6504-1-git-send-email-fred.konrad@greensocs.com>
From: KONRAD Frederic <fred.konrad@greensocs.com>
These structures must be made public to avoid two memory allocations for
virtio-*-*.
Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com>
---
hw/virtio-balloon.c | 12 ------------
hw/virtio-balloon.h | 11 +++++++++++
hw/virtio-blk.c | 16 ----------------
hw/virtio-blk.h | 15 +++++++++++++++
hw/virtio-net.c | 41 -----------------------------------------
hw/virtio-net.h | 41 +++++++++++++++++++++++++++++++++++++++++
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, 143 insertions(+), 144 deletions(-)
diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c
index 3040bc6..3ea1790 100644
--- a/hw/virtio-balloon.c
+++ b/hw/virtio-balloon.c
@@ -27,18 +27,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;
- DeviceState *qdev;
-} VirtIOBalloon;
-
static VirtIOBalloon *to_virtio_balloon(VirtIODevice *vdev)
{
return (VirtIOBalloon *)vdev;
diff --git a/hw/virtio-balloon.h b/hw/virtio-balloon.h
index b1828f4..0cd211e 100644
--- a/hw/virtio-balloon.h
+++ b/hw/virtio-balloon.h
@@ -52,4 +52,15 @@ 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;
+ DeviceState *qdev;
+} VirtIOBalloon;
+
#endif
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index df57b35..38a53e9 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -25,22 +25,6 @@
# 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;
-#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
- VirtIOBlockDataPlane *dataplane;
-#endif
-} VirtIOBlock;
-
static VirtIOBlock *to_virtio_blk(VirtIODevice *vdev)
{
return (VirtIOBlock *)vdev;
diff --git a/hw/virtio-blk.h b/hw/virtio-blk.h
index 43ca492..2a7aef2 100644
--- a/hw/virtio-blk.h
+++ b/hw/virtio-blk.h
@@ -108,6 +108,21 @@ 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;
+#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
+ VirtIOBlockDataPlane *dataplane;
+#endif
+} VirtIOBlock;
+
#define DEFINE_VIRTIO_BLK_FEATURES(_state, _field) \
DEFINE_VIRTIO_COMMON_FEATURES(_state, _field)
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 3bb01b1..a012318 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -26,47 +26,6 @@
#define MAC_TABLE_ENTRIES 64
#define MAX_VLAN (1 << 12) /* Per 802.1Q definition */
-typedef struct VirtIONet
-{
- VirtIODevice vdev;
- uint8_t mac[ETH_ALEN];
- uint16_t status;
- VirtQueue *rx_vq;
- VirtQueue *tx_vq;
- VirtQueue *ctrl_vq;
- NICState *nic;
- QEMUTimer *tx_timer;
- QEMUBH *tx_bh;
- uint32_t tx_timeout;
- int32_t tx_burst;
- int tx_waiting;
- uint32_t has_vnet_hdr;
- size_t host_hdr_len;
- size_t guest_hdr_len;
- uint8_t has_ufo;
- struct {
- VirtQueueElement elem;
- ssize_t len;
- } async_tx;
- 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;
-} VirtIONet;
-
/* TODO
* - we could suppress RX interrupt if we were so inclined.
*/
diff --git a/hw/virtio-net.h b/hw/virtio-net.h
index d46fb98..f6ff85d 100644
--- a/hw/virtio-net.h
+++ b/hw/virtio-net.h
@@ -124,6 +124,47 @@ struct virtio_net_ctrl_mac {
uint32_t entries;
uint8_t macs[][ETH_ALEN];
};
+
+typedef struct VirtIONet {
+ VirtIODevice vdev;
+ uint8_t mac[ETH_ALEN];
+ uint16_t status;
+ VirtQueue *rx_vq;
+ VirtQueue *tx_vq;
+ VirtQueue *ctrl_vq;
+ NICState *nic;
+ QEMUTimer *tx_timer;
+ QEMUBH *tx_bh;
+ uint32_t tx_timeout;
+ int32_t tx_burst;
+ int tx_waiting;
+ uint32_t has_vnet_hdr;
+ size_t host_hdr_len;
+ size_t guest_hdr_len;
+ uint8_t has_ufo;
+ struct {
+ VirtQueueElement elem;
+ ssize_t len;
+ } async_tx;
+ 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;
+} VirtIONet;
+
#define VIRTIO_NET_CTRL_MAC 1
#define VIRTIO_NET_CTRL_MAC_TABLE_SET 0
diff --git a/hw/virtio-rng.c b/hw/virtio-rng.c
index e063127..d79aa46 100644
--- a/hw/virtio-rng.c
+++ b/hw/virtio-rng.c
@@ -15,25 +15,6 @@
#include "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)
diff --git a/hw/virtio-rng.h b/hw/virtio-rng.h
index f42d748..3711c97 100644
--- a/hw/virtio-rng.h
+++ b/hw/virtio-rng.h
@@ -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
diff --git a/hw/virtio-scsi.c b/hw/virtio-scsi.c
index 0715865..3645423 100644
--- a/hw/virtio-scsi.c
+++ b/hw/virtio-scsi.c
@@ -129,21 +129,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;
diff --git a/hw/virtio-scsi.h b/hw/virtio-scsi.h
index 8d9d15f..613deb5 100644
--- a/hw/virtio-scsi.h
+++ b/hw/virtio-scsi.h
@@ -16,6 +16,7 @@
#include "virtio.h"
#include "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), \
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index aa7d0d7..a4ce7e0 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -25,47 +25,6 @@
#include "trace.h"
#include "virtio-serial.h"
-/* The virtio-serial bus on top of which the ports will ride as devices */
-struct VirtIOSerialBus {
- BusState qbus;
-
- /* This is the parent device that provides the bus for ports. */
- VirtIOSerial *vser;
-
- /* The maximum number of ports that can ride on top of this bus */
- uint32_t max_nr_ports;
-};
-
-typedef struct VirtIOSerialPostLoad {
- QEMUTimer *timer;
- uint32_t nr_active_ports;
- struct {
- VirtIOSerialPort *port;
- uint8_t host_connected;
- } *connected;
-} VirtIOSerialPostLoad;
-
-struct VirtIOSerial {
- VirtIODevice vdev;
-
- VirtQueue *c_ivq, *c_ovq;
- /* Arrays of ivqs and ovqs: one per port */
- VirtQueue **ivqs, **ovqs;
-
- VirtIOSerialBus bus;
-
- DeviceState *qdev;
-
- QTAILQ_HEAD(, VirtIOSerialPort) ports;
-
- /* bitmap for identifying active ports */
- uint32_t *ports_map;
-
- struct virtio_console_config config;
-
- struct VirtIOSerialPostLoad *post_load;
-};
-
static VirtIOSerialPort *find_port_by_id(VirtIOSerial *vser, uint32_t id)
{
VirtIOSerialPort *port;
diff --git a/hw/virtio-serial.h b/hw/virtio-serial.h
index 16e3982..722d01b 100644
--- a/hw/virtio-serial.h
+++ b/hw/virtio-serial.h
@@ -173,6 +173,47 @@ struct VirtIOSerialPort {
bool throttled;
};
+/* The virtio-serial bus on top of which the ports will ride as devices */
+struct VirtIOSerialBus {
+ BusState qbus;
+
+ /* This is the parent device that provides the bus for ports. */
+ VirtIOSerial *vser;
+
+ /* The maximum number of ports that can ride on top of this bus */
+ uint32_t max_nr_ports;
+};
+
+typedef struct VirtIOSerialPostLoad {
+ QEMUTimer *timer;
+ uint32_t nr_active_ports;
+ struct {
+ VirtIOSerialPort *port;
+ uint8_t host_connected;
+ } *connected;
+} VirtIOSerialPostLoad;
+
+struct VirtIOSerial {
+ VirtIODevice vdev;
+
+ VirtQueue *c_ivq, *c_ovq;
+ /* Arrays of ivqs and ovqs: one per port */
+ VirtQueue **ivqs, **ovqs;
+
+ VirtIOSerialBus bus;
+
+ DeviceState *qdev;
+
+ QTAILQ_HEAD(, VirtIOSerialPort) ports;
+
+ /* bitmap for identifying active ports */
+ uint32_t *ports_map;
+
+ struct virtio_console_config config;
+
+ struct VirtIOSerialPostLoad *post_load;
+};
+
/* Interface to the virtio-serial bus */
/*
--
1.7.11.7
next prev parent reply other threads:[~2013-01-15 14:10 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-15 14:09 [Qemu-devel] [PATCH V3 00/44] Virtio-refactoring part2 fred.konrad
2013-01-15 14:09 ` fred.konrad [this message]
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 02/44] virtio-blk: don't use pointer for configuration fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 03/44] virtio-blk: add the virtio-blk device fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 04/44] virtio-blk-pci: switch to new API fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 05/44] virtio-blk-s390: switch to the " fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 06/44] virtio-blk: cleanup: use QOM cast fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 07/44] virtio-blk: cleanup: remove qdev field fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 08/44] virtio-net: add the virtio-net device fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 09/44] virtio-net-pci: switch to the new API fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 10/44] virtio-net-s390: " fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 11/44] virtio-net: cleanup: use QOM cast fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 12/44] virtio-net: cleanup: init and exit function fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 13/44] virtio-net: cleanup: remove qdev field fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 14/44] virtio-scsi: don't use pointer for configuration fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 15/44] virtio-scsi: allocate cmd_vqs array separately fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 16/44] virtio-scsi: moving host_features from properties to transport properties fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 17/44] virtio-scsi: add the virtio-scsi device fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 18/44] virtio-scsi-pci: switch to new API fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 19/44] virtio-scsi-s390: switch to the " fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 20/44] virtio-scsi: cleanup: use QOM casts fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 21/44] virtio-scsi: cleanup: init and exit functions fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 22/44] virtio-scsi: cleanup: remove qdev field fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 23/44] virtio-balloon: add the virtio-balloon device fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 24/44] virtio-balloon-pci: switch to the new API fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 25/44] virtio-balloon: cleanup: init and exit function fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 26/44] virtio-balloon: cleanup: QOM casts fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 27/44] virtio-balloon: cleanup: remove qdev field fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 28/44] virtio-rng: don't use pointer for configuration fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 29/44] virtio-rng: add virtio-rng device fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 30/44] virtio-rng-s390: switch to the new API fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 31/44] virtio-rng-pci: " fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 32/44] virtio-rng.c: cleanup: init and exit functions fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 33/44] virtio-rng.c: cleanup: remove qdev field fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 34/44] virtio-rng.c: cleanup: use QOM casts fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 35/44] virtio-serial: add the virtio-serial device fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 36/44] virtio-serial-pci: switch to the new API fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 37/44] virtio-serial-s390: " fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 38/44] virtio-serial: cleanup: init and exit functions fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 39/44] virtio-serial: cleanup: use QOM casts fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 40/44] virtio-serial: cleanup: remove qdev field fred.konrad
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 41/44] virtio-9p: add the virtio-9p device fred.konrad
2013-01-18 8:04 ` Deepak C Shetty
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 42/44] virtio-9p-pci: switch to the new API fred.konrad
2013-01-18 8:04 ` Deepak C Shetty
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 43/44] virtio-9p: cleanup: init function fred.konrad
2013-01-18 8:04 ` Deepak C Shetty
2013-01-15 14:09 ` [Qemu-devel] [PATCH V3 44/44] virtio-9p: cleanup: QOM casts fred.konrad
2013-01-18 8:05 ` Deepak C Shetty
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1358258998-6504-2-git-send-email-fred.konrad@greensocs.com \
--to=fred.konrad@greensocs.com \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=aliguori@us.ibm.com \
--cc=amit.shah@redhat.com \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=deepakcs@linux.vnet.ibm.com \
--cc=e.voevodin@samsung.com \
--cc=kwolf@redhat.com \
--cc=mark.burton@greensocs.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).