* [Qemu-devel] [PATCH 0/9] virtio: device configuration cleanup
@ 2011-11-24 12:38 Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 1/9] virtio-net: move property declarations to header file Paolo Bonzini
` (9 more replies)
0 siblings, 10 replies; 16+ messages in thread
From: Paolo Bonzini @ 2011-11-24 12:38 UTC (permalink / raw)
To: qemu-devel; +Cc: mst
This series cleans up device configuration in virtio:
1) all properties (features and not) are moved to a single macro
DEFINE_VIRTIO_XYZ_PROPERTIES. This makes the definitions
uniform across all three virtio backends.
2) all configuration is moved to a single struct, which embeds
the NICConf/BlockConf for respectively virtio-nic/virtio-blk.
This lets the DEFINE_VIRTIO_XYZ_PROPERTIES include these
pieces as well.
3) virtio-9p had some knowledge of PCI, but there should be
no reason why s390 or mmio backends cannot use it. These bits
are removed and moved back to virtio-pci.[ch].
Tested x86_64, compiled arm+s390x.
Paolo Bonzini (9):
virtio-net: move property declarations to header file
virtio-net: move NICConf into virtio_net_conf
virtio-serial: move property declarations to header file
virtio-9p: remove PCI dependencies from hw/9pfs/
virtio-9p: move property declarations to header file
virtio-blk: define VirtIOBlkConf
virtio-blk: move property declarations to header file
virtio-blk: move BlockConf into VirtIOBlkConf
virtio: move conf fields into an anonymous union
hw/9pfs/virtio-9p-device.c | 35 +---------------------
hw/{9p.h => 9pfs/virtio-9p-device.h} | 9 ++++-
hw/9pfs/virtio-9p.c | 1 -
hw/s390-virtio-bus.c | 18 +++--------
hw/s390-virtio-bus.h | 11 ++++---
hw/syborg_virtio.c | 15 +++------
hw/virtio-blk.c | 28 ++++++++--------
hw/virtio-blk.h | 12 +++++++
hw/virtio-net.c | 13 ++++----
hw/virtio-net.h | 43 +++++++++++++++------------
hw/virtio-pci.c | 55 +++++++++++++++++++++++----------
hw/virtio-pci.h | 14 +++++----
hw/virtio-serial.h | 5 +++
hw/virtio.h | 9 ++---
14 files changed, 135 insertions(+), 133 deletions(-)
rename hw/{9p.h => 9pfs/virtio-9p-device.h} (50%)
--
1.7.7.1
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH 1/9] virtio-net: move property declarations to header file
2011-11-24 12:38 [Qemu-devel] [PATCH 0/9] virtio: device configuration cleanup Paolo Bonzini
@ 2011-11-24 12:38 ` Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 2/9] virtio-net: move NICConf into virtio_net_conf Paolo Bonzini
` (8 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Paolo Bonzini @ 2011-11-24 12:38 UTC (permalink / raw)
To: qemu-devel; +Cc: mst
Include also other properties than features. NIC properties are
tackled in the next patch.
There is one semantic change: this adds the virtio-net and common feature
bits to s390.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/s390-virtio-bus.c | 6 +-----
hw/syborg_virtio.c | 7 +------
hw/virtio-net.h | 41 ++++++++++++++++++++++-------------------
hw/virtio-pci.c | 7 +------
4 files changed, 25 insertions(+), 36 deletions(-)
diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index c4b9a99..0326cfc 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -337,11 +337,7 @@ static VirtIOS390DeviceInfo s390_virtio_net = {
.qdev.size = sizeof(VirtIOS390Device),
.qdev.props = (Property[]) {
DEFINE_NIC_PROPERTIES(VirtIOS390Device, nic),
- DEFINE_PROP_UINT32("x-txtimer", VirtIOS390Device,
- net.txtimer, TX_TIMER_INTERVAL),
- DEFINE_PROP_INT32("x-txburst", VirtIOS390Device,
- net.txburst, TX_BURST),
- DEFINE_PROP_STRING("tx", VirtIOS390Device, net.tx),
+ DEFINE_VIRTIO_NET_PROPERTIES(VirtIOS390Device, host_features, net),
DEFINE_PROP_END_OF_LIST(),
},
};
diff --git a/hw/syborg_virtio.c b/hw/syborg_virtio.c
index 6de952c..98fd47b 100644
--- a/hw/syborg_virtio.c
+++ b/hw/syborg_virtio.c
@@ -295,12 +295,7 @@ static SysBusDeviceInfo syborg_virtio_net_info = {
.qdev.size = sizeof(SyborgVirtIOProxy),
.qdev.props = (Property[]) {
DEFINE_NIC_PROPERTIES(SyborgVirtIOProxy, nic),
- DEFINE_VIRTIO_NET_FEATURES(SyborgVirtIOProxy, host_features),
- DEFINE_PROP_UINT32("x-txtimer", SyborgVirtIOProxy,
- net.txtimer, TX_TIMER_INTERVAL),
- DEFINE_PROP_INT32("x-txburst", SyborgVirtIOProxy,
- net.txburst, TX_BURST),
- DEFINE_PROP_STRING("tx", SyborgVirtIOProxy, net.tx),
+ DEFINE_VIRTIO_NET_PROPERTIES(SyborgVirtIOProxy, host_features, net),
DEFINE_PROP_END_OF_LIST(),
}
};
diff --git a/hw/virtio-net.h b/hw/virtio-net.h
index 4468741..f6faea9 100644
--- a/hw/virtio-net.h
+++ b/hw/virtio-net.h
@@ -167,23 +167,26 @@ struct virtio_net_ctrl_mac {
#define VIRTIO_NET_CTRL_VLAN_ADD 0
#define VIRTIO_NET_CTRL_VLAN_DEL 1
-#define DEFINE_VIRTIO_NET_FEATURES(_state, _field) \
- DEFINE_VIRTIO_COMMON_FEATURES(_state, _field), \
- DEFINE_PROP_BIT("csum", _state, _field, VIRTIO_NET_F_CSUM, true), \
- DEFINE_PROP_BIT("guest_csum", _state, _field, VIRTIO_NET_F_GUEST_CSUM, true), \
- DEFINE_PROP_BIT("gso", _state, _field, VIRTIO_NET_F_GSO, true), \
- DEFINE_PROP_BIT("guest_tso4", _state, _field, VIRTIO_NET_F_GUEST_TSO4, true), \
- DEFINE_PROP_BIT("guest_tso6", _state, _field, VIRTIO_NET_F_GUEST_TSO6, true), \
- DEFINE_PROP_BIT("guest_ecn", _state, _field, VIRTIO_NET_F_GUEST_ECN, true), \
- DEFINE_PROP_BIT("guest_ufo", _state, _field, VIRTIO_NET_F_GUEST_UFO, true), \
- DEFINE_PROP_BIT("host_tso4", _state, _field, VIRTIO_NET_F_HOST_TSO4, true), \
- DEFINE_PROP_BIT("host_tso6", _state, _field, VIRTIO_NET_F_HOST_TSO6, true), \
- DEFINE_PROP_BIT("host_ecn", _state, _field, VIRTIO_NET_F_HOST_ECN, true), \
- DEFINE_PROP_BIT("host_ufo", _state, _field, VIRTIO_NET_F_HOST_UFO, true), \
- DEFINE_PROP_BIT("mrg_rxbuf", _state, _field, VIRTIO_NET_F_MRG_RXBUF, true), \
- DEFINE_PROP_BIT("status", _state, _field, VIRTIO_NET_F_STATUS, true), \
- DEFINE_PROP_BIT("ctrl_vq", _state, _field, VIRTIO_NET_F_CTRL_VQ, true), \
- DEFINE_PROP_BIT("ctrl_rx", _state, _field, VIRTIO_NET_F_CTRL_RX, true), \
- DEFINE_PROP_BIT("ctrl_vlan", _state, _field, VIRTIO_NET_F_CTRL_VLAN, true), \
- DEFINE_PROP_BIT("ctrl_rx_extra", _state, _field, VIRTIO_NET_F_CTRL_RX_EXTRA, true)
+#define DEFINE_VIRTIO_NET_PROPERTIES(_state, _features_field, _conf_field) \
+ DEFINE_VIRTIO_COMMON_FEATURES(_state, _features_field), \
+ DEFINE_PROP_BIT("csum", _state, _features_field, VIRTIO_NET_F_CSUM, true), \
+ DEFINE_PROP_BIT("guest_csum", _state, _features_field, VIRTIO_NET_F_GUEST_CSUM, true), \
+ DEFINE_PROP_BIT("gso", _state, _features_field, VIRTIO_NET_F_GSO, true), \
+ DEFINE_PROP_BIT("guest_tso4", _state, _features_field, VIRTIO_NET_F_GUEST_TSO4, true), \
+ DEFINE_PROP_BIT("guest_tso6", _state, _features_field, VIRTIO_NET_F_GUEST_TSO6, true), \
+ DEFINE_PROP_BIT("guest_ecn", _state, _features_field, VIRTIO_NET_F_GUEST_ECN, true), \
+ DEFINE_PROP_BIT("guest_ufo", _state, _features_field, VIRTIO_NET_F_GUEST_UFO, true), \
+ DEFINE_PROP_BIT("host_tso4", _state, _features_field, VIRTIO_NET_F_HOST_TSO4, true), \
+ DEFINE_PROP_BIT("host_tso6", _state, _features_field, VIRTIO_NET_F_HOST_TSO6, true), \
+ DEFINE_PROP_BIT("host_ecn", _state, _features_field, VIRTIO_NET_F_HOST_ECN, true), \
+ DEFINE_PROP_BIT("host_ufo", _state, _features_field, VIRTIO_NET_F_HOST_UFO, true), \
+ DEFINE_PROP_BIT("mrg_rxbuf", _state, _features_field, VIRTIO_NET_F_MRG_RXBUF, true), \
+ DEFINE_PROP_BIT("status", _state, _features_field, VIRTIO_NET_F_STATUS, true), \
+ DEFINE_PROP_BIT("ctrl_vq", _state, _features_field, VIRTIO_NET_F_CTRL_VQ, true), \
+ DEFINE_PROP_BIT("ctrl_rx", _state, _features_field, VIRTIO_NET_F_CTRL_RX, true), \
+ DEFINE_PROP_BIT("ctrl_vlan", _state, _features_field, VIRTIO_NET_F_CTRL_VLAN, true), \
+ DEFINE_PROP_BIT("ctrl_rx_extra", _state, _features_field, VIRTIO_NET_F_CTRL_RX_EXTRA, true), \
+ DEFINE_PROP_UINT32("x-txtimer", _state, _conf_field.txtimer, TX_TIMER_INTERVAL), \
+ DEFINE_PROP_INT32("x-txburst", _state, _conf_field.txburst, TX_BURST), \
+ DEFINE_PROP_STRING("tx", _state, _conf_field.tx)
#endif
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 64c6a94..a909e5f 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -816,13 +816,8 @@ static PCIDeviceInfo virtio_info[] = {
DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, false),
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 3),
- DEFINE_VIRTIO_NET_FEATURES(VirtIOPCIProxy, host_features),
+ DEFINE_VIRTIO_NET_PROPERTIES(VirtIOPCIProxy, host_features, net),
DEFINE_NIC_PROPERTIES(VirtIOPCIProxy, nic),
- DEFINE_PROP_UINT32("x-txtimer", VirtIOPCIProxy,
- net.txtimer, TX_TIMER_INTERVAL),
- DEFINE_PROP_INT32("x-txburst", VirtIOPCIProxy,
- net.txburst, TX_BURST),
- DEFINE_PROP_STRING("tx", VirtIOPCIProxy, net.tx),
DEFINE_PROP_END_OF_LIST(),
},
.qdev.reset = virtio_pci_reset,
--
1.7.7.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH 2/9] virtio-net: move NICConf into virtio_net_conf
2011-11-24 12:38 [Qemu-devel] [PATCH 0/9] virtio: device configuration cleanup Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 1/9] virtio-net: move property declarations to header file Paolo Bonzini
@ 2011-11-24 12:38 ` Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 3/9] virtio-serial: move property declarations to header file Paolo Bonzini
` (7 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Paolo Bonzini @ 2011-11-24 12:38 UTC (permalink / raw)
To: qemu-devel; +Cc: mst
This part pushes the NIC properties down into virtio_net_conf and
DEFINE_VIRTIO_NET_PROPERTIES. No semantic change.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/s390-virtio-bus.c | 3 +--
hw/s390-virtio-bus.h | 1 -
hw/syborg_virtio.c | 4 +---
hw/virtio-net.c | 13 ++++++-------
hw/virtio-net.h | 2 ++
hw/virtio-pci.c | 3 +--
hw/virtio-pci.h | 1 -
hw/virtio.h | 3 +--
8 files changed, 12 insertions(+), 18 deletions(-)
diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index 0326cfc..80b11e5 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -116,7 +116,7 @@ static int s390_virtio_net_init(VirtIOS390Device *dev)
{
VirtIODevice *vdev;
- vdev = virtio_net_init((DeviceState *)dev, &dev->nic, &dev->net);
+ vdev = virtio_net_init((DeviceState *)dev, &dev->net);
if (!vdev) {
return -1;
}
@@ -336,7 +336,6 @@ static VirtIOS390DeviceInfo s390_virtio_net = {
.qdev.alias = "virtio-net",
.qdev.size = sizeof(VirtIOS390Device),
.qdev.props = (Property[]) {
- DEFINE_NIC_PROPERTIES(VirtIOS390Device, nic),
DEFINE_VIRTIO_NET_PROPERTIES(VirtIOS390Device, host_features, net),
DEFINE_PROP_END_OF_LIST(),
},
diff --git a/hw/s390-virtio-bus.h b/hw/s390-virtio-bus.h
index f1bece7..b10c78b 100644
--- a/hw/s390-virtio-bus.h
+++ b/hw/s390-virtio-bus.h
@@ -43,7 +43,6 @@ typedef struct VirtIOS390Device {
VirtIODevice *vdev;
BlockConf block;
char *block_serial;
- NICConf nic;
uint32_t host_features;
virtio_serial_conf serial;
virtio_net_conf net;
diff --git a/hw/syborg_virtio.c b/hw/syborg_virtio.c
index 98fd47b..a1dc5ff 100644
--- a/hw/syborg_virtio.c
+++ b/hw/syborg_virtio.c
@@ -65,7 +65,6 @@ typedef struct {
qemu_irq irq;
uint32_t int_enable;
uint32_t id;
- NICConf nic;
uint32_t host_features;
virtio_net_conf net;
} SyborgVirtIOProxy;
@@ -285,7 +284,7 @@ static int syborg_virtio_net_init(SysBusDevice *dev)
VirtIODevice *vdev;
SyborgVirtIOProxy *proxy = FROM_SYSBUS(SyborgVirtIOProxy, dev);
- vdev = virtio_net_init(&dev->qdev, &proxy->nic, &proxy->net);
+ vdev = virtio_net_init(&dev->qdev, &proxy->net);
return syborg_virtio_init(proxy, vdev);
}
@@ -294,7 +293,6 @@ static SysBusDeviceInfo syborg_virtio_net_info = {
.qdev.name = "syborg,virtio-net",
.qdev.size = sizeof(SyborgVirtIOProxy),
.qdev.props = (Property[]) {
- DEFINE_NIC_PROPERTIES(SyborgVirtIOProxy, nic),
DEFINE_VIRTIO_NET_PROPERTIES(SyborgVirtIOProxy, host_features, net),
DEFINE_PROP_END_OF_LIST(),
}
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 8c2f460..163b6c0 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -992,8 +992,7 @@ static NetClientInfo net_virtio_info = {
.link_status_changed = virtio_net_set_link_status,
};
-VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf,
- virtio_net_conf *net)
+VirtIODevice *virtio_net_init(DeviceState *dev, virtio_net_conf *net)
{
VirtIONet *n;
@@ -1026,13 +1025,13 @@ VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf,
n->tx_bh = qemu_bh_new(virtio_net_tx_bh, n);
}
n->ctrl_vq = virtio_add_queue(&n->vdev, 64, virtio_net_handle_ctrl);
- qemu_macaddr_default_if_unset(&conf->macaddr);
- memcpy(&n->mac[0], &conf->macaddr, sizeof(n->mac));
+ qemu_macaddr_default_if_unset(&net->nic.macaddr);
+ memcpy(&n->mac[0], &net->nic.macaddr, sizeof(n->mac));
n->status = VIRTIO_NET_S_LINK_UP;
- n->nic = qemu_new_nic(&net_virtio_info, conf, dev->info->name, dev->id, n);
+ n->nic = qemu_new_nic(&net_virtio_info, &net->nic, dev->info->name, dev->id, n);
- qemu_format_nic_info_str(&n->nic->nc, conf->macaddr.a);
+ qemu_format_nic_info_str(&n->nic->nc, net->nic.macaddr.a);
n->tx_waiting = 0;
n->tx_burst = net->txburst;
@@ -1047,7 +1046,7 @@ VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf,
register_savevm(dev, "virtio-net", -1, VIRTIO_NET_VM_VERSION,
virtio_net_save, virtio_net_load, n);
- add_boot_device_path(conf->bootindex, dev, "/ethernet-phy@0");
+ add_boot_device_path(net->nic.bootindex, dev, "/ethernet-phy@0");
return &n->vdev;
}
diff --git a/hw/virtio-net.h b/hw/virtio-net.h
index f6faea9..ee55a85 100644
--- a/hw/virtio-net.h
+++ b/hw/virtio-net.h
@@ -58,6 +58,7 @@
typedef struct virtio_net_conf
{
+ NICConf nic;
uint32_t txtimer;
int32_t txburst;
char *tx;
@@ -168,6 +169,7 @@ struct virtio_net_ctrl_mac {
#define VIRTIO_NET_CTRL_VLAN_DEL 1
#define DEFINE_VIRTIO_NET_PROPERTIES(_state, _features_field, _conf_field) \
+ DEFINE_NIC_PROPERTIES(_state, _conf_field.nic), \
DEFINE_VIRTIO_COMMON_FEATURES(_state, _features_field), \
DEFINE_PROP_BIT("csum", _state, _features_field, VIRTIO_NET_F_CSUM, true), \
DEFINE_PROP_BIT("guest_csum", _state, _features_field, VIRTIO_NET_F_GUEST_CSUM, true), \
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index a909e5f..b93477b 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -738,7 +738,7 @@ static int virtio_net_init_pci(PCIDevice *pci_dev)
VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
VirtIODevice *vdev;
- vdev = virtio_net_init(&pci_dev->qdev, &proxy->nic, &proxy->net);
+ vdev = virtio_net_init(&pci_dev->qdev, &proxy->net);
vdev->nvectors = proxy->nvectors;
virtio_init_pci(proxy, vdev);
@@ -817,7 +817,6 @@ static PCIDeviceInfo virtio_info[] = {
VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, false),
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 3),
DEFINE_VIRTIO_NET_PROPERTIES(VirtIOPCIProxy, host_features, net),
- DEFINE_NIC_PROPERTIES(VirtIOPCIProxy, nic),
DEFINE_PROP_END_OF_LIST(),
},
.qdev.reset = virtio_pci_reset,
diff --git a/hw/virtio-pci.h b/hw/virtio-pci.h
index f8404de..4126705 100644
--- a/hw/virtio-pci.h
+++ b/hw/virtio-pci.h
@@ -33,7 +33,6 @@ typedef struct {
uint32_t nvectors;
BlockConf block;
char *block_serial;
- NICConf nic;
uint32_t host_features;
#ifdef CONFIG_LINUX
V9fsConf fsconf;
diff --git a/hw/virtio.h b/hw/virtio.h
index 25f5564..7303b6c 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -194,8 +194,7 @@ void virtio_bind_device(VirtIODevice *vdev, const VirtIOBindings *binding,
VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf,
char **serial);
struct virtio_net_conf;
-VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf,
- struct virtio_net_conf *net);
+VirtIODevice *virtio_net_init(DeviceState *dev, struct virtio_net_conf *net);
typedef struct virtio_serial_conf virtio_serial_conf;
VirtIODevice *virtio_serial_init(DeviceState *dev, virtio_serial_conf *serial);
VirtIODevice *virtio_balloon_init(DeviceState *dev);
--
1.7.7.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH 3/9] virtio-serial: move property declarations to header file
2011-11-24 12:38 [Qemu-devel] [PATCH 0/9] virtio: device configuration cleanup Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 1/9] virtio-net: move property declarations to header file Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 2/9] virtio-net: move NICConf into virtio_net_conf Paolo Bonzini
@ 2011-11-24 12:38 ` Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 4/9] virtio-9p: remove PCI dependencies from hw/9pfs/ Paolo Bonzini
` (6 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Paolo Bonzini @ 2011-11-24 12:38 UTC (permalink / raw)
To: qemu-devel; +Cc: mst
Include also other properties than features. This adds the common virtio
features to s390.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/s390-virtio-bus.c | 3 +--
hw/virtio-pci.c | 4 +---
hw/virtio-serial.h | 5 +++++
3 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index 80b11e5..282688a 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -359,8 +359,7 @@ static VirtIOS390DeviceInfo s390_virtio_serial = {
.qdev.alias = "virtio-serial",
.qdev.size = sizeof(VirtIOS390Device),
.qdev.props = (Property[]) {
- DEFINE_PROP_UINT32("max_ports", VirtIOS390Device,
- serial.max_virtserial_ports, 31),
+ DEFINE_VIRTIO_SERIAL_PROPERTIES(VirtIOS390Device, host_features, serial),
DEFINE_PROP_END_OF_LIST(),
},
};
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index b93477b..d5cdc04 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -836,9 +836,7 @@ static PCIDeviceInfo virtio_info[] = {
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,
DEV_NVECTORS_UNSPECIFIED),
DEFINE_PROP_HEX32("class", VirtIOPCIProxy, class_code, 0),
- DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),
- DEFINE_PROP_UINT32("max_ports", VirtIOPCIProxy,
- serial.max_virtserial_ports, 31),
+ DEFINE_VIRTIO_SERIAL_PROPERTIES(VirtIOPCIProxy, host_features, serial),
DEFINE_PROP_END_OF_LIST(),
},
.qdev.reset = virtio_pci_reset,
diff --git a/hw/virtio-serial.h b/hw/virtio-serial.h
index ab13803..2e1a428 100644
--- a/hw/virtio-serial.h
+++ b/hw/virtio-serial.h
@@ -204,4 +204,9 @@ size_t virtio_serial_guest_ready(VirtIOSerialPort *port);
*/
void virtio_serial_throttle_port(VirtIOSerialPort *port, bool throttle);
+#define DEFINE_VIRTIO_SERIAL_PROPERTIES(_state, _feature_field, _conf_field) \
+ DEFINE_VIRTIO_COMMON_FEATURES(_state, _feature_field), \
+ DEFINE_PROP_UINT32("max_ports", _state, \
+ _conf_field.max_virtserial_ports, 31)
+
#endif
--
1.7.7.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH 4/9] virtio-9p: remove PCI dependencies from hw/9pfs/
2011-11-24 12:38 [Qemu-devel] [PATCH 0/9] virtio: device configuration cleanup Paolo Bonzini
` (2 preceding siblings ...)
2011-11-24 12:38 ` [Qemu-devel] [PATCH 3/9] virtio-serial: move property declarations to header file Paolo Bonzini
@ 2011-11-24 12:38 ` Paolo Bonzini
2011-11-28 17:18 ` Aneesh Kumar K.V
2011-11-28 18:46 ` Michael S. Tsirkin
2011-11-24 12:38 ` [Qemu-devel] [PATCH 5/9] virtio-9p: move property declarations to header file Paolo Bonzini
` (5 subsequent siblings)
9 siblings, 2 replies; 16+ messages in thread
From: Paolo Bonzini @ 2011-11-24 12:38 UTC (permalink / raw)
To: qemu-devel; +Cc: mst
Also move the 9p.h file to 9pfs/virtio-9p-device.h, for consistency
with the corresponding .c file.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/9pfs/virtio-9p-device.c | 35 +---------------------------------
hw/{9p.h => 9pfs/virtio-9p-device.h} | 4 +-
hw/9pfs/virtio-9p.c | 1 -
hw/virtio-pci.c | 35 ++++++++++++++++++++++++++++++++++
hw/virtio-pci.h | 1 +
hw/virtio.h | 2 +-
6 files changed, 40 insertions(+), 38 deletions(-)
rename hw/{9p.h => 9pfs/virtio-9p-device.h} (85%)
diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index bba4c54..509faa8 100644
--- a/hw/9pfs/virtio-9p-device.c
+++ b/hw/9pfs/virtio-9p-device.c
@@ -14,9 +14,9 @@
#include "hw/virtio.h"
#include "hw/pc.h"
#include "qemu_socket.h"
-#include "hw/virtio-pci.h"
#include "virtio-9p.h"
#include "fsdev/qemu-fsdev.h"
+#include "virtio-9p-device.h"
#include "virtio-9p-xattr.h"
#include "virtio-9p-coth.h"
@@ -147,41 +147,8 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
return &s->vdev;
}
-static int virtio_9p_init_pci(PCIDevice *pci_dev)
-{
- VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
- VirtIODevice *vdev;
-
- vdev = virtio_9p_init(&pci_dev->qdev, &proxy->fsconf);
- vdev->nvectors = proxy->nvectors;
- virtio_init_pci(proxy, vdev);
- /* make the actual value visible */
- proxy->nvectors = vdev->nvectors;
- return 0;
-}
-
-static PCIDeviceInfo virtio_9p_info = {
- .qdev.name = "virtio-9p-pci",
- .qdev.size = sizeof(VirtIOPCIProxy),
- .init = virtio_9p_init_pci,
- .vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET,
- .device_id = 0x1009,
- .revision = VIRTIO_PCI_ABI_VERSION,
- .class_id = 0x2,
- .qdev.props = (Property[]) {
- DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
- VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
- DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
- DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),
- DEFINE_PROP_STRING("mount_tag", VirtIOPCIProxy, fsconf.tag),
- DEFINE_PROP_STRING("fsdev", VirtIOPCIProxy, fsconf.fsdev_id),
- DEFINE_PROP_END_OF_LIST(),
- }
-};
-
static void virtio_9p_register_devices(void)
{
- pci_qdev_register(&virtio_9p_info);
virtio_9p_set_fd_limit();
}
diff --git a/hw/9p.h b/hw/9pfs/virtio-9p-device.h
similarity index 85%
rename from hw/9p.h
rename to hw/9pfs/virtio-9p-device.h
index d9951d6..65789db 100644
--- a/hw/9p.h
+++ b/hw/9pfs/virtio-9p-device.h
@@ -11,8 +11,8 @@
*
*/
-#ifndef QEMU_9P_H
-#define QEMU_9P_H
+#ifndef QEMU_VIRTIO_9P_DEVICE_H
+#define QEMU_VIRTIO_9P_DEVICE_H
typedef struct V9fsConf
{
diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
index 1b2fc5d..7b786e5 100644
--- a/hw/9pfs/virtio-9p.c
+++ b/hw/9pfs/virtio-9p.c
@@ -17,7 +17,6 @@
#include "hw/virtio.h"
#include "hw/pc.h"
#include "qemu_socket.h"
-#include "hw/virtio-pci.h"
#include "virtio-9p.h"
#include "fsdev/qemu-fsdev.h"
#include "virtio-9p-xattr.h"
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index d5cdc04..78c1790 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -779,6 +779,21 @@ static int virtio_balloon_exit_pci(PCIDevice *pci_dev)
return virtio_exit_pci(pci_dev);
}
+#ifdef CONFIG_LINUX
+static int virtio_9p_init_pci(PCIDevice *pci_dev)
+{
+ VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
+ VirtIODevice *vdev;
+
+ vdev = virtio_9p_init(&pci_dev->qdev, &proxy->fsconf);
+ vdev->nvectors = proxy->nvectors;
+ virtio_init_pci(proxy, vdev);
+ /* make the actual value visible */
+ proxy->nvectors = vdev->nvectors;
+ return 0;
+}
+#endif
+
static PCIDeviceInfo virtio_info[] = {
{
.qdev.name = "virtio-blk-pci",
@@ -855,6 +870,26 @@ static PCIDeviceInfo virtio_info[] = {
DEFINE_PROP_END_OF_LIST(),
},
.qdev.reset = virtio_pci_reset,
+#ifdef CONFIG_LINUX
+ }, {
+ .qdev.name = "virtio-9p-pci",
+ .qdev.size = sizeof(VirtIOPCIProxy),
+ .init = virtio_9p_init_pci,
+ .vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET,
+ .device_id = 0x1009,
+ .revision = VIRTIO_PCI_ABI_VERSION,
+ .class_id = 0x2,
+ .qdev.props = (Property[]) {
+ DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
+ VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
+ DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
+ DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),
+ DEFINE_PROP_STRING("mount_tag", VirtIOPCIProxy, fsconf.tag),
+ DEFINE_PROP_STRING("fsdev", VirtIOPCIProxy, fsconf.fsdev_id),
+ DEFINE_PROP_END_OF_LIST(),
+ },
+ .qdev.reset = virtio_pci_reset,
+#endif
},{
/* end of list */
}
diff --git a/hw/virtio-pci.h b/hw/virtio-pci.h
index 4126705..7654c84 100644
--- a/hw/virtio-pci.h
+++ b/hw/virtio-pci.h
@@ -17,6 +17,7 @@
#include "virtio-net.h"
#include "virtio-serial.h"
+#include "9pfs/virtio-9p-device.h"
/* Performance improves when virtqueue kick processing is decoupled from the
* vcpu thread using ioeventfd for some devices. */
diff --git a/hw/virtio.h b/hw/virtio.h
index 7303b6c..9ed8dfc 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -21,7 +21,7 @@
#include "block.h"
#include "event_notifier.h"
#ifdef CONFIG_LINUX
-#include "9p.h"
+#include "9pfs/virtio-9p-device.h"
#endif
/* from Linux's linux/virtio_config.h */
--
1.7.7.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH 5/9] virtio-9p: move property declarations to header file
2011-11-24 12:38 [Qemu-devel] [PATCH 0/9] virtio: device configuration cleanup Paolo Bonzini
` (3 preceding siblings ...)
2011-11-24 12:38 ` [Qemu-devel] [PATCH 4/9] virtio-9p: remove PCI dependencies from hw/9pfs/ Paolo Bonzini
@ 2011-11-24 12:38 ` Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 6/9] virtio-blk: define VirtIOBlkConf Paolo Bonzini
` (4 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Paolo Bonzini @ 2011-11-24 12:38 UTC (permalink / raw)
To: qemu-devel; +Cc: mst
No s390 change here, since s390 does not (yet?) support virtio-9p.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/9pfs/virtio-9p-device.h | 5 +++++
hw/virtio-pci.c | 4 +---
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/hw/9pfs/virtio-9p-device.h b/hw/9pfs/virtio-9p-device.h
index 65789db..7f2a4eb 100644
--- a/hw/9pfs/virtio-9p-device.h
+++ b/hw/9pfs/virtio-9p-device.h
@@ -21,4 +21,9 @@ typedef struct V9fsConf
char *fsdev_id;
} V9fsConf;
+#define DEFINE_VIRTIO_9P_PROPERTIES(_state, _features_field, _conf_field) \
+ DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, _features_field), \
+ DEFINE_PROP_STRING("mount_tag", VirtIOPCIProxy, _conf_field.tag), \
+ DEFINE_PROP_STRING("fsdev", VirtIOPCIProxy, _conf_field.fsdev_id)
+
#endif
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 78c1790..f522156 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -883,9 +883,7 @@ static PCIDeviceInfo virtio_info[] = {
DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
- DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),
- DEFINE_PROP_STRING("mount_tag", VirtIOPCIProxy, fsconf.tag),
- DEFINE_PROP_STRING("fsdev", VirtIOPCIProxy, fsconf.fsdev_id),
+ DEFINE_VIRTIO_9P_PROPERTIES(VirtIOPCIProxy, host_features, fsconf),
DEFINE_PROP_END_OF_LIST(),
},
.qdev.reset = virtio_pci_reset,
--
1.7.7.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH 6/9] virtio-blk: define VirtIOBlkConf
2011-11-24 12:38 [Qemu-devel] [PATCH 0/9] virtio: device configuration cleanup Paolo Bonzini
` (4 preceding siblings ...)
2011-11-24 12:38 ` [Qemu-devel] [PATCH 5/9] virtio-9p: move property declarations to header file Paolo Bonzini
@ 2011-11-24 12:38 ` Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 7/9] virtio-blk: move property declarations to header file Paolo Bonzini
` (3 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Paolo Bonzini @ 2011-11-24 12:38 UTC (permalink / raw)
To: qemu-devel; +Cc: mst
It has only one field for now, but this will change soon...
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/s390-virtio-bus.c | 4 ++--
hw/s390-virtio-bus.h | 3 ++-
hw/virtio-blk.c | 13 ++++++-------
hw/virtio-blk.h | 5 +++++
hw/virtio-pci.c | 4 ++--
hw/virtio-pci.h | 3 ++-
hw/virtio.h | 3 ++-
7 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index 282688a..cf7cfef 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -129,7 +129,7 @@ static int s390_virtio_blk_init(VirtIOS390Device *dev)
VirtIODevice *vdev;
vdev = virtio_blk_init((DeviceState *)dev, &dev->block,
- &dev->block_serial);
+ &dev->blk);
if (!vdev) {
return -1;
}
@@ -348,7 +348,7 @@ static VirtIOS390DeviceInfo s390_virtio_blk = {
.qdev.size = sizeof(VirtIOS390Device),
.qdev.props = (Property[]) {
DEFINE_BLOCK_PROPERTIES(VirtIOS390Device, block),
- DEFINE_PROP_STRING("serial", VirtIOS390Device, block_serial),
+ DEFINE_PROP_STRING("serial", VirtIOS390Device, blk.serial),
DEFINE_PROP_END_OF_LIST(),
},
};
diff --git a/hw/s390-virtio-bus.h b/hw/s390-virtio-bus.h
index b10c78b..1f47e4d 100644
--- a/hw/s390-virtio-bus.h
+++ b/hw/s390-virtio-bus.h
@@ -17,6 +17,7 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
+#include "virtio-blk.h"
#include "virtio-net.h"
#include "virtio-serial.h"
@@ -42,7 +43,7 @@ typedef struct VirtIOS390Device {
uint8_t feat_len;
VirtIODevice *vdev;
BlockConf block;
- char *block_serial;
+ VirtIOBlkConf blk;
uint32_t host_features;
virtio_serial_conf serial;
virtio_net_conf net;
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index 19e89e7..e34140e 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -29,7 +29,7 @@ typedef struct VirtIOBlock
void *rq;
QEMUBH *bh;
BlockConf *conf;
- char *serial;
+ VirtIOBlkConf *blk;
unsigned short sector_mask;
DeviceState *qdev;
} VirtIOBlock;
@@ -397,7 +397,7 @@ static void virtio_blk_handle_request(VirtIOBlockReq *req,
* terminated by '\0' only when shorter than buffer.
*/
strncpy(req->elem.in_sg[0].iov_base,
- s->serial ? s->serial : "",
+ s->blk->serial ? s->blk->serial : "",
MIN(req->elem.in_sg[0].iov_len, VIRTIO_BLK_ID_BYTES));
virtio_blk_req_complete(req, VIRTIO_BLK_S_OK);
g_free(req);
@@ -570,8 +570,7 @@ static const BlockDevOps virtio_block_ops = {
.resize_cb = virtio_blk_resize,
};
-VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf,
- char **serial)
+VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf, VirtIOBlkConf *blk)
{
VirtIOBlock *s;
int cylinders, heads, secs;
@@ -587,11 +586,11 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf,
return NULL;
}
- if (!*serial) {
+ if (!blk->serial) {
/* try to fall back to value set with legacy -drive serial=... */
dinfo = drive_get_by_blockdev(conf->bs);
if (*dinfo->serial) {
- *serial = strdup(dinfo->serial);
+ blk->serial = strdup(dinfo->serial);
}
}
@@ -604,7 +603,7 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf,
s->vdev.reset = virtio_blk_reset;
s->bs = conf->bs;
s->conf = conf;
- s->serial = *serial;
+ s->blk = blk;
s->rq = NULL;
s->sector_mask = (s->conf->logical_block_size / BDRV_SECTOR_SIZE) - 1;
bdrv_guess_geometry(s->bs, &cylinders, &heads, &secs);
diff --git a/hw/virtio-blk.h b/hw/virtio-blk.h
index 244dce4..5f150f8 100644
--- a/hw/virtio-blk.h
+++ b/hw/virtio-blk.h
@@ -97,6 +97,11 @@ struct virtio_scsi_inhdr
uint32_t residual;
};
+struct VirtIOBlkConf
+{
+ char *serial;
+};
+
#ifdef __linux__
#define DEFINE_VIRTIO_BLK_FEATURES(_state, _field) \
DEFINE_VIRTIO_COMMON_FEATURES(_state, _field), \
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index f522156..bd111d0 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -670,7 +670,7 @@ static int virtio_blk_init_pci(PCIDevice *pci_dev)
proxy->class_code = PCI_CLASS_STORAGE_SCSI;
vdev = virtio_blk_init(&pci_dev->qdev, &proxy->block,
- &proxy->block_serial);
+ &proxy->blk);
if (!vdev) {
return -1;
}
@@ -808,7 +808,7 @@ static PCIDeviceInfo virtio_info[] = {
.qdev.props = (Property[]) {
DEFINE_PROP_HEX32("class", VirtIOPCIProxy, class_code, 0),
DEFINE_BLOCK_PROPERTIES(VirtIOPCIProxy, block),
- DEFINE_PROP_STRING("serial", VirtIOPCIProxy, block_serial),
+ DEFINE_PROP_STRING("serial", VirtIOPCIProxy, blk.serial),
DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
diff --git a/hw/virtio-pci.h b/hw/virtio-pci.h
index 7654c84..195e852 100644
--- a/hw/virtio-pci.h
+++ b/hw/virtio-pci.h
@@ -15,6 +15,7 @@
#ifndef QEMU_VIRTIO_PCI_H
#define QEMU_VIRTIO_PCI_H
+#include "virtio-blk.h"
#include "virtio-net.h"
#include "virtio-serial.h"
#include "9pfs/virtio-9p-device.h"
@@ -33,7 +34,7 @@ typedef struct {
uint32_t class_code;
uint32_t nvectors;
BlockConf block;
- char *block_serial;
+ VirtIOBlkConf blk;
uint32_t host_features;
#ifdef CONFIG_LINUX
V9fsConf fsconf;
diff --git a/hw/virtio.h b/hw/virtio.h
index 9ed8dfc..da2941e 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -191,8 +191,9 @@ void virtio_bind_device(VirtIODevice *vdev, const VirtIOBindings *binding,
void *opaque);
/* Base devices. */
+typedef struct VirtIOBlkConf VirtIOBlkConf;
VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf,
- char **serial);
+ VirtIOBlkConf *blk);
struct virtio_net_conf;
VirtIODevice *virtio_net_init(DeviceState *dev, struct virtio_net_conf *net);
typedef struct virtio_serial_conf virtio_serial_conf;
--
1.7.7.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH 7/9] virtio-blk: move property declarations to header file
2011-11-24 12:38 [Qemu-devel] [PATCH 0/9] virtio: device configuration cleanup Paolo Bonzini
` (5 preceding siblings ...)
2011-11-24 12:38 ` [Qemu-devel] [PATCH 6/9] virtio-blk: define VirtIOBlkConf Paolo Bonzini
@ 2011-11-24 12:38 ` Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 8/9] virtio-blk: move BlockConf into VirtIOBlkConf Paolo Bonzini
` (2 subsequent siblings)
9 siblings, 0 replies; 16+ messages in thread
From: Paolo Bonzini @ 2011-11-24 12:38 UTC (permalink / raw)
To: qemu-devel; +Cc: mst
Include also other properties than features. This adds the common virtio
features to s390.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/s390-virtio-bus.c | 2 +-
hw/virtio-blk.h | 5 +++++
hw/virtio-pci.c | 3 +--
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index cf7cfef..71720b9 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -348,7 +348,7 @@ static VirtIOS390DeviceInfo s390_virtio_blk = {
.qdev.size = sizeof(VirtIOS390Device),
.qdev.props = (Property[]) {
DEFINE_BLOCK_PROPERTIES(VirtIOS390Device, block),
- DEFINE_PROP_STRING("serial", VirtIOS390Device, blk.serial),
+ DEFINE_VIRTIO_BLK_PROPERTIES(VirtIOS390Device, host_features, blk),
DEFINE_PROP_END_OF_LIST(),
},
};
diff --git a/hw/virtio-blk.h b/hw/virtio-blk.h
index 5f150f8..dd26ae7 100644
--- a/hw/virtio-blk.h
+++ b/hw/virtio-blk.h
@@ -110,4 +110,9 @@ struct VirtIOBlkConf
#define DEFINE_VIRTIO_BLK_FEATURES(_state, _field) \
DEFINE_VIRTIO_COMMON_FEATURES(_state, _field)
#endif
+
+#define DEFINE_VIRTIO_BLK_PROPERTIES(_state, _features_field, _conf_field) \
+ DEFINE_VIRTIO_BLK_FEATURES(_state, _features_field), \
+ DEFINE_PROP_STRING("serial", _state, _conf_field.serial)
+
#endif
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index bd111d0..d64058e 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -808,11 +808,10 @@ static PCIDeviceInfo virtio_info[] = {
.qdev.props = (Property[]) {
DEFINE_PROP_HEX32("class", VirtIOPCIProxy, class_code, 0),
DEFINE_BLOCK_PROPERTIES(VirtIOPCIProxy, block),
- DEFINE_PROP_STRING("serial", VirtIOPCIProxy, blk.serial),
DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
- DEFINE_VIRTIO_BLK_FEATURES(VirtIOPCIProxy, host_features),
+ DEFINE_VIRTIO_BLK_PROPERTIES(VirtIOPCIProxy, host_features, blk),
DEFINE_PROP_END_OF_LIST(),
},
.qdev.reset = virtio_pci_reset,
--
1.7.7.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH 8/9] virtio-blk: move BlockConf into VirtIOBlkConf
2011-11-24 12:38 [Qemu-devel] [PATCH 0/9] virtio: device configuration cleanup Paolo Bonzini
` (6 preceding siblings ...)
2011-11-24 12:38 ` [Qemu-devel] [PATCH 7/9] virtio-blk: move property declarations to header file Paolo Bonzini
@ 2011-11-24 12:38 ` Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 9/9] virtio: move conf fields into an anonymous union Paolo Bonzini
2011-11-28 18:51 ` [Qemu-devel] [PATCH 0/9] virtio: device configuration cleanup Michael S. Tsirkin
9 siblings, 0 replies; 16+ messages in thread
From: Paolo Bonzini @ 2011-11-24 12:38 UTC (permalink / raw)
To: qemu-devel; +Cc: mst
This part pushes the block device properties down into VirtIOBlkConf and
DEFINE_VIRTIO_BLK_PROPERTIES. No semantic change.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/s390-virtio-bus.c | 4 +---
hw/s390-virtio-bus.h | 1 -
hw/virtio-blk.c | 17 +++++++++--------
hw/virtio-blk.h | 2 ++
hw/virtio-pci.c | 5 +----
hw/virtio-pci.h | 1 -
hw/virtio.h | 3 +--
7 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index 71720b9..a3810f2 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -128,8 +128,7 @@ static int s390_virtio_blk_init(VirtIOS390Device *dev)
{
VirtIODevice *vdev;
- vdev = virtio_blk_init((DeviceState *)dev, &dev->block,
- &dev->blk);
+ vdev = virtio_blk_init((DeviceState *)dev, &dev->blk);
if (!vdev) {
return -1;
}
@@ -347,7 +346,6 @@ static VirtIOS390DeviceInfo s390_virtio_blk = {
.qdev.alias = "virtio-blk",
.qdev.size = sizeof(VirtIOS390Device),
.qdev.props = (Property[]) {
- DEFINE_BLOCK_PROPERTIES(VirtIOS390Device, block),
DEFINE_VIRTIO_BLK_PROPERTIES(VirtIOS390Device, host_features, blk),
DEFINE_PROP_END_OF_LIST(),
},
diff --git a/hw/s390-virtio-bus.h b/hw/s390-virtio-bus.h
index 1f47e4d..414fd22 100644
--- a/hw/s390-virtio-bus.h
+++ b/hw/s390-virtio-bus.h
@@ -42,7 +42,6 @@ typedef struct VirtIOS390Device {
ram_addr_t feat_offs;
uint8_t feat_len;
VirtIODevice *vdev;
- BlockConf block;
VirtIOBlkConf blk;
uint32_t host_features;
virtio_serial_conf serial;
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index e34140e..7713fd1 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -570,25 +570,25 @@ static const BlockDevOps virtio_block_ops = {
.resize_cb = virtio_blk_resize,
};
-VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf, VirtIOBlkConf *blk)
+VirtIODevice *virtio_blk_init(DeviceState *dev, VirtIOBlkConf *blk)
{
VirtIOBlock *s;
int cylinders, heads, secs;
static int virtio_blk_id;
DriveInfo *dinfo;
- if (!conf->bs) {
+ if (!blk->conf.bs) {
error_report("virtio-blk-pci: drive property not set");
return NULL;
}
- if (!bdrv_is_inserted(conf->bs)) {
+ if (!bdrv_is_inserted(blk->conf.bs)) {
error_report("Device needs media, but drive is empty");
return NULL;
}
if (!blk->serial) {
/* try to fall back to value set with legacy -drive serial=... */
- dinfo = drive_get_by_blockdev(conf->bs);
+ dinfo = drive_get_by_blockdev(blk->conf.bs);
if (*dinfo->serial) {
blk->serial = strdup(dinfo->serial);
}
@@ -601,8 +601,8 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf, VirtIOBlkConf *
s->vdev.get_config = virtio_blk_update_config;
s->vdev.get_features = virtio_blk_get_features;
s->vdev.reset = virtio_blk_reset;
- s->bs = conf->bs;
- s->conf = conf;
+ s->bs = blk->conf.bs;
+ s->conf = &blk->conf;
s->blk = blk;
s->rq = NULL;
s->sector_mask = (s->conf->logical_block_size / BDRV_SECTOR_SIZE) - 1;
@@ -615,10 +615,10 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf, VirtIOBlkConf *
register_savevm(dev, "virtio-blk", virtio_blk_id++, 2,
virtio_blk_save, virtio_blk_load, s);
bdrv_set_dev_ops(s->bs, &virtio_block_ops, s);
- bdrv_set_buffer_alignment(s->bs, conf->logical_block_size);
+ bdrv_set_buffer_alignment(s->bs, s->conf->logical_block_size);
bdrv_iostatus_enable(s->bs);
- add_boot_device_path(conf->bootindex, dev, "/disk@0,0");
+ add_boot_device_path(s->conf->bootindex, dev, "/disk@0,0");
return &s->vdev;
}
@@ -627,5 +627,6 @@ void virtio_blk_exit(VirtIODevice *vdev)
{
VirtIOBlock *s = to_virtio_blk(vdev);
unregister_savevm(s->qdev, "virtio-blk", s);
+ blockdev_mark_auto_del(s->bs);
virtio_cleanup(vdev);
}
diff --git a/hw/virtio-blk.h b/hw/virtio-blk.h
index dd26ae7..518e1cc 100644
--- a/hw/virtio-blk.h
+++ b/hw/virtio-blk.h
@@ -99,6 +99,7 @@ struct virtio_scsi_inhdr
struct VirtIOBlkConf
{
+ BlockConf conf;
char *serial;
};
@@ -113,6 +114,7 @@ struct VirtIOBlkConf
#define DEFINE_VIRTIO_BLK_PROPERTIES(_state, _features_field, _conf_field) \
DEFINE_VIRTIO_BLK_FEATURES(_state, _features_field), \
+ DEFINE_BLOCK_PROPERTIES(_state, _conf_field.conf), \
DEFINE_PROP_STRING("serial", _state, _conf_field.serial)
#endif
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index d64058e..0048dc1 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -669,8 +669,7 @@ static int virtio_blk_init_pci(PCIDevice *pci_dev)
proxy->class_code != PCI_CLASS_STORAGE_OTHER)
proxy->class_code = PCI_CLASS_STORAGE_SCSI;
- vdev = virtio_blk_init(&pci_dev->qdev, &proxy->block,
- &proxy->blk);
+ vdev = virtio_blk_init(&pci_dev->qdev, &proxy->blk);
if (!vdev) {
return -1;
}
@@ -698,7 +697,6 @@ static int virtio_blk_exit_pci(PCIDevice *pci_dev)
virtio_pci_stop_ioeventfd(proxy);
virtio_blk_exit(proxy->vdev);
- blockdev_mark_auto_del(proxy->block.bs);
return virtio_exit_pci(pci_dev);
}
@@ -807,7 +805,6 @@ static PCIDeviceInfo virtio_info[] = {
.class_id = PCI_CLASS_STORAGE_SCSI,
.qdev.props = (Property[]) {
DEFINE_PROP_HEX32("class", VirtIOPCIProxy, class_code, 0),
- DEFINE_BLOCK_PROPERTIES(VirtIOPCIProxy, block),
DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
diff --git a/hw/virtio-pci.h b/hw/virtio-pci.h
index 195e852..63d83ae 100644
--- a/hw/virtio-pci.h
+++ b/hw/virtio-pci.h
@@ -33,7 +33,6 @@ typedef struct {
uint32_t flags;
uint32_t class_code;
uint32_t nvectors;
- BlockConf block;
VirtIOBlkConf blk;
uint32_t host_features;
#ifdef CONFIG_LINUX
diff --git a/hw/virtio.h b/hw/virtio.h
index da2941e..94963fe 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -192,8 +192,7 @@ void virtio_bind_device(VirtIODevice *vdev, const VirtIOBindings *binding,
/* Base devices. */
typedef struct VirtIOBlkConf VirtIOBlkConf;
-VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf,
- VirtIOBlkConf *blk);
+VirtIODevice *virtio_blk_init(DeviceState *dev, VirtIOBlkConf *blk);
struct virtio_net_conf;
VirtIODevice *virtio_net_init(DeviceState *dev, struct virtio_net_conf *net);
typedef struct virtio_serial_conf virtio_serial_conf;
--
1.7.7.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH 9/9] virtio: move conf fields into an anonymous union
2011-11-24 12:38 [Qemu-devel] [PATCH 0/9] virtio: device configuration cleanup Paolo Bonzini
` (7 preceding siblings ...)
2011-11-24 12:38 ` [Qemu-devel] [PATCH 8/9] virtio-blk: move BlockConf into VirtIOBlkConf Paolo Bonzini
@ 2011-11-24 12:38 ` Paolo Bonzini
2011-11-28 18:51 ` [Qemu-devel] [PATCH 0/9] virtio: device configuration cleanup Michael S. Tsirkin
9 siblings, 0 replies; 16+ messages in thread
From: Paolo Bonzini @ 2011-11-24 12:38 UTC (permalink / raw)
To: qemu-devel; +Cc: mst
The devices should not need to share any space from the conf fields
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/s390-virtio-bus.h | 8 +++++---
hw/syborg_virtio.c | 4 +++-
hw/virtio-pci.h | 10 ++++++----
3 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/hw/s390-virtio-bus.h b/hw/s390-virtio-bus.h
index 414fd22..b9f711d 100644
--- a/hw/s390-virtio-bus.h
+++ b/hw/s390-virtio-bus.h
@@ -42,10 +42,12 @@ typedef struct VirtIOS390Device {
ram_addr_t feat_offs;
uint8_t feat_len;
VirtIODevice *vdev;
- VirtIOBlkConf blk;
uint32_t host_features;
- virtio_serial_conf serial;
- virtio_net_conf net;
+ union {
+ VirtIOBlkConf blk;
+ virtio_serial_conf serial;
+ virtio_net_conf net;
+ };
} VirtIOS390Device;
typedef struct VirtIOS390Bus {
diff --git a/hw/syborg_virtio.c b/hw/syborg_virtio.c
index a1dc5ff..0971a85 100644
--- a/hw/syborg_virtio.c
+++ b/hw/syborg_virtio.c
@@ -66,7 +66,9 @@ typedef struct {
uint32_t int_enable;
uint32_t id;
uint32_t host_features;
- virtio_net_conf net;
+ union {
+ virtio_net_conf net;
+ };
} SyborgVirtIOProxy;
static uint32_t syborg_virtio_readl(void *opaque, target_phys_addr_t offset)
diff --git a/hw/virtio-pci.h b/hw/virtio-pci.h
index 63d83ae..e05af31 100644
--- a/hw/virtio-pci.h
+++ b/hw/virtio-pci.h
@@ -33,13 +33,15 @@ typedef struct {
uint32_t flags;
uint32_t class_code;
uint32_t nvectors;
- VirtIOBlkConf blk;
uint32_t host_features;
+ union {
+ VirtIOBlkConf blk;
#ifdef CONFIG_LINUX
- V9fsConf fsconf;
+ V9fsConf fsconf;
#endif
- virtio_serial_conf serial;
- virtio_net_conf net;
+ virtio_serial_conf serial;
+ virtio_net_conf net;
+ };
bool ioeventfd_disabled;
bool ioeventfd_started;
} VirtIOPCIProxy;
--
1.7.7.1
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 4/9] virtio-9p: remove PCI dependencies from hw/9pfs/
2011-11-24 12:38 ` [Qemu-devel] [PATCH 4/9] virtio-9p: remove PCI dependencies from hw/9pfs/ Paolo Bonzini
@ 2011-11-28 17:18 ` Aneesh Kumar K.V
2011-11-28 18:46 ` Michael S. Tsirkin
1 sibling, 0 replies; 16+ messages in thread
From: Aneesh Kumar K.V @ 2011-11-28 17:18 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: mst
On Thu, 24 Nov 2011 13:38:23 +0100, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Also move the 9p.h file to 9pfs/virtio-9p-device.h, for consistency
> with the corresponding .c file.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> hw/9pfs/virtio-9p-device.c | 35 +---------------------------------
> hw/{9p.h => 9pfs/virtio-9p-device.h} | 4 +-
> hw/9pfs/virtio-9p.c | 1 -
> hw/virtio-pci.c | 35 ++++++++++++++++++++++++++++++++++
> hw/virtio-pci.h | 1 +
> hw/virtio.h | 2 +-
> 6 files changed, 40 insertions(+), 38 deletions(-)
> rename hw/{9p.h => 9pfs/virtio-9p-device.h} (85%)
>
> diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
> index bba4c54..509faa8 100644
> --- a/hw/9pfs/virtio-9p-device.c
> +++ b/hw/9pfs/virtio-9p-device.c
> @@ -14,9 +14,9 @@
> #include "hw/virtio.h"
> #include "hw/pc.h"
> #include "qemu_socket.h"
> -#include "hw/virtio-pci.h"
> #include "virtio-9p.h"
> #include "fsdev/qemu-fsdev.h"
> +#include "virtio-9p-device.h"
> #include "virtio-9p-xattr.h"
> #include "virtio-9p-coth.h"
>
> @@ -147,41 +147,8 @@ VirtIODevice *virtio_9p_init(DeviceState *dev, V9fsConf *conf)
> return &s->vdev;
> }
>
> -static int virtio_9p_init_pci(PCIDevice *pci_dev)
> -{
> - VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
> - VirtIODevice *vdev;
> -
> - vdev = virtio_9p_init(&pci_dev->qdev, &proxy->fsconf);
> - vdev->nvectors = proxy->nvectors;
> - virtio_init_pci(proxy, vdev);
> - /* make the actual value visible */
> - proxy->nvectors = vdev->nvectors;
> - return 0;
> -}
> -
> -static PCIDeviceInfo virtio_9p_info = {
> - .qdev.name = "virtio-9p-pci",
> - .qdev.size = sizeof(VirtIOPCIProxy),
> - .init = virtio_9p_init_pci,
> - .vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET,
> - .device_id = 0x1009,
> - .revision = VIRTIO_PCI_ABI_VERSION,
> - .class_id = 0x2,
> - .qdev.props = (Property[]) {
> - DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
> - VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
> - DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
> - DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),
> - DEFINE_PROP_STRING("mount_tag", VirtIOPCIProxy, fsconf.tag),
> - DEFINE_PROP_STRING("fsdev", VirtIOPCIProxy, fsconf.fsdev_id),
> - DEFINE_PROP_END_OF_LIST(),
> - }
> -};
> -
> static void virtio_9p_register_devices(void)
> {
> - pci_qdev_register(&virtio_9p_info);
> virtio_9p_set_fd_limit();
> }
>
> diff --git a/hw/9p.h b/hw/9pfs/virtio-9p-device.h
> similarity index 85%
> rename from hw/9p.h
> rename to hw/9pfs/virtio-9p-device.h
> index d9951d6..65789db 100644
> --- a/hw/9p.h
> +++ b/hw/9pfs/virtio-9p-device.h
> @@ -11,8 +11,8 @@
> *
> */
>
> -#ifndef QEMU_9P_H
> -#define QEMU_9P_H
> +#ifndef QEMU_VIRTIO_9P_DEVICE_H
> +#define QEMU_VIRTIO_9P_DEVICE_H
>
> typedef struct V9fsConf
> {
> diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
> index 1b2fc5d..7b786e5 100644
> --- a/hw/9pfs/virtio-9p.c
> +++ b/hw/9pfs/virtio-9p.c
> @@ -17,7 +17,6 @@
> #include "hw/virtio.h"
> #include "hw/pc.h"
> #include "qemu_socket.h"
> -#include "hw/virtio-pci.h"
> #include "virtio-9p.h"
> #include "fsdev/qemu-fsdev.h"
> #include "virtio-9p-xattr.h"
> diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
> index d5cdc04..78c1790 100644
> --- a/hw/virtio-pci.c
> +++ b/hw/virtio-pci.c
> @@ -779,6 +779,21 @@ static int virtio_balloon_exit_pci(PCIDevice *pci_dev)
> return virtio_exit_pci(pci_dev);
> }
>
> +#ifdef CONFIG_LINUX
> +static int virtio_9p_init_pci(PCIDevice *pci_dev)
> +{
> + VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
> + VirtIODevice *vdev;
> +
> + vdev = virtio_9p_init(&pci_dev->qdev, &proxy->fsconf);
> + vdev->nvectors = proxy->nvectors;
> + virtio_init_pci(proxy, vdev);
> + /* make the actual value visible */
> + proxy->nvectors = vdev->nvectors;
> + return 0;
> +}
> +#endif
> +
> static PCIDeviceInfo virtio_info[] = {
> {
> .qdev.name = "virtio-blk-pci",
> @@ -855,6 +870,26 @@ static PCIDeviceInfo virtio_info[] = {
> DEFINE_PROP_END_OF_LIST(),
> },
> .qdev.reset = virtio_pci_reset,
> +#ifdef CONFIG_LINUX
> + }, {
> + .qdev.name = "virtio-9p-pci",
> + .qdev.size = sizeof(VirtIOPCIProxy),
> + .init = virtio_9p_init_pci,
> + .vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET,
> + .device_id = 0x1009,
> + .revision = VIRTIO_PCI_ABI_VERSION,
> + .class_id = 0x2,
> + .qdev.props = (Property[]) {
> + DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags,
> + VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true),
> + DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
> + DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),
> + DEFINE_PROP_STRING("mount_tag", VirtIOPCIProxy, fsconf.tag),
> + DEFINE_PROP_STRING("fsdev", VirtIOPCIProxy, fsconf.fsdev_id),
> + DEFINE_PROP_END_OF_LIST(),
> + },
> + .qdev.reset = virtio_pci_reset,
> +#endif
> },{
> /* end of list */
> }
> diff --git a/hw/virtio-pci.h b/hw/virtio-pci.h
> index 4126705..7654c84 100644
> --- a/hw/virtio-pci.h
> +++ b/hw/virtio-pci.h
> @@ -17,6 +17,7 @@
>
> #include "virtio-net.h"
> #include "virtio-serial.h"
> +#include "9pfs/virtio-9p-device.h"
>
> /* Performance improves when virtqueue kick processing is decoupled from the
> * vcpu thread using ioeventfd for some devices. */
> diff --git a/hw/virtio.h b/hw/virtio.h
> index 7303b6c..9ed8dfc 100644
> --- a/hw/virtio.h
> +++ b/hw/virtio.h
> @@ -21,7 +21,7 @@
> #include "block.h"
> #include "event_notifier.h"
> #ifdef CONFIG_LINUX
> -#include "9p.h"
> +#include "9pfs/virtio-9p-device.h"
> #endif
>
> /* from Linux's linux/virtio_config.h */
That adds few #ifdef to virtio-pci.c. Is that ok ? I actually moved
that code from virtio-pci.c as a part of
9fe1ebebd0c427fd9b3d1ffffa77a9969d873d93 . Regarding PCI dependency,
I was thinking it would be better for 9p to explicitly state that
dependency. When virtio can support other than pci devices, we would
list then using #ifdef in virtio-9p-device.c That way all 9p device
related details can be found at one place. That is one of the reason
i did 9fe1ebebd0c427fd9b3d1ffffa77a9969d873d93
Part of the above patch would still be needed if we don't want to
apply the full patch above. I have inlined it below.
commit 2cb7289031b2646d6a107610967e90d2320791fa
Author: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Date: Mon Nov 28 12:23:49 2011 +0530
hw/9pfs: Add qdev.reset callback for virtio-9p-pci device
Add the device reset callback
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index bba4c54..57dc77c 100644
--- a/hw/9pfs/virtio-9p-device.c
+++ b/hw/9pfs/virtio-9p-device.c
@@ -176,7 +176,8 @@ static PCIDeviceInfo virtio_9p_info = {
DEFINE_PROP_STRING("mount_tag", VirtIOPCIProxy, fsconf.tag),
DEFINE_PROP_STRING("fsdev", VirtIOPCIProxy, fsconf.fsdev_id),
DEFINE_PROP_END_OF_LIST(),
- }
+ },
+ .qdev.reset = virtio_pci_reset,
};
static void virtio_9p_register_devices(void)
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index ca5923c..07f5861 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -266,7 +266,7 @@ static void virtio_pci_stop_ioeventfd(VirtIOPCIProxy *proxy)
proxy->ioeventfd_started = false;
}
-static void virtio_pci_reset(DeviceState *d)
+void virtio_pci_reset(DeviceState *d)
{
VirtIOPCIProxy *proxy = container_of(d, VirtIOPCIProxy, pci_dev.qdev);
virtio_pci_stop_ioeventfd(proxy);
diff --git a/hw/virtio-pci.h b/hw/virtio-pci.h
index f8404de..344c22b 100644
--- a/hw/virtio-pci.h
+++ b/hw/virtio-pci.h
@@ -45,6 +45,7 @@ typedef struct {
} VirtIOPCIProxy;
void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev);
+void virtio_pci_reset(DeviceState *d);
/* Virtio ABI version, if we increment this, we break the guest driver. */
#define VIRTIO_PCI_ABI_VERSION 0
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 4/9] virtio-9p: remove PCI dependencies from hw/9pfs/
2011-11-24 12:38 ` [Qemu-devel] [PATCH 4/9] virtio-9p: remove PCI dependencies from hw/9pfs/ Paolo Bonzini
2011-11-28 17:18 ` Aneesh Kumar K.V
@ 2011-11-28 18:46 ` Michael S. Tsirkin
2011-11-29 8:38 ` Paolo Bonzini
1 sibling, 1 reply; 16+ messages in thread
From: Michael S. Tsirkin @ 2011-11-28 18:46 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
On Thu, Nov 24, 2011 at 01:38:23PM +0100, Paolo Bonzini wrote:
> Also move the 9p.h file to 9pfs/virtio-9p-device.h, for consistency
> with the corresponding .c file.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
...
> diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
> index d5cdc04..78c1790 100644
> --- a/hw/virtio-pci.c
> +++ b/hw/virtio-pci.c
> @@ -779,6 +779,21 @@ static int virtio_balloon_exit_pci(PCIDevice *pci_dev)
> return virtio_exit_pci(pci_dev);
> }
>
> +#ifdef CONFIG_LINUX
> +static int virtio_9p_init_pci(PCIDevice *pci_dev)
> +{
> + VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
> + VirtIODevice *vdev;
> +
> + vdev = virtio_9p_init(&pci_dev->qdev, &proxy->fsconf);
> + vdev->nvectors = proxy->nvectors;
> + virtio_init_pci(proxy, vdev);
> + /* make the actual value visible */
> + proxy->nvectors = vdev->nvectors;
> + return 0;
> +}
> +#endif
> +
This ifdef looks wrong to me - is there no way 9p can thinkably
work on non-linux hosts? If yes, we should have a separate config
entry for 9p, configure script can make it
conditional on linux host.
--
MST
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 0/9] virtio: device configuration cleanup
2011-11-24 12:38 [Qemu-devel] [PATCH 0/9] virtio: device configuration cleanup Paolo Bonzini
` (8 preceding siblings ...)
2011-11-24 12:38 ` [Qemu-devel] [PATCH 9/9] virtio: move conf fields into an anonymous union Paolo Bonzini
@ 2011-11-28 18:51 ` Michael S. Tsirkin
9 siblings, 0 replies; 16+ messages in thread
From: Michael S. Tsirkin @ 2011-11-28 18:51 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
On Thu, Nov 24, 2011 at 01:38:19PM +0100, Paolo Bonzini wrote:
> This series cleans up device configuration in virtio:
>
> 1) all properties (features and not) are moved to a single macro
> DEFINE_VIRTIO_XYZ_PROPERTIES. This makes the definitions
> uniform across all three virtio backends.
>
> 2) all configuration is moved to a single struct, which embeds
> the NICConf/BlockConf for respectively virtio-nic/virtio-blk.
> This lets the DEFINE_VIRTIO_XYZ_PROPERTIES include these
> pieces as well.
>
> 3) virtio-9p had some knowledge of PCI, but there should be
> no reason why s390 or mmio backends cannot use it. These bits
> are removed and moved back to virtio-pci.[ch].
>
> Tested x86_64, compiled arm+s390x.
Looks good except the 9p part, commented on that.
> Paolo Bonzini (9):
> virtio-net: move property declarations to header file
> virtio-net: move NICConf into virtio_net_conf
> virtio-serial: move property declarations to header file
> virtio-9p: remove PCI dependencies from hw/9pfs/
> virtio-9p: move property declarations to header file
> virtio-blk: define VirtIOBlkConf
> virtio-blk: move property declarations to header file
> virtio-blk: move BlockConf into VirtIOBlkConf
> virtio: move conf fields into an anonymous union
>
> hw/9pfs/virtio-9p-device.c | 35 +---------------------
> hw/{9p.h => 9pfs/virtio-9p-device.h} | 9 ++++-
> hw/9pfs/virtio-9p.c | 1 -
> hw/s390-virtio-bus.c | 18 +++--------
> hw/s390-virtio-bus.h | 11 ++++---
> hw/syborg_virtio.c | 15 +++------
> hw/virtio-blk.c | 28 ++++++++--------
> hw/virtio-blk.h | 12 +++++++
> hw/virtio-net.c | 13 ++++----
> hw/virtio-net.h | 43 +++++++++++++++------------
> hw/virtio-pci.c | 55 +++++++++++++++++++++++----------
> hw/virtio-pci.h | 14 +++++----
> hw/virtio-serial.h | 5 +++
> hw/virtio.h | 9 ++---
> 14 files changed, 135 insertions(+), 133 deletions(-)
> rename hw/{9p.h => 9pfs/virtio-9p-device.h} (50%)
>
> --
> 1.7.7.1
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 4/9] virtio-9p: remove PCI dependencies from hw/9pfs/
2011-11-28 18:46 ` Michael S. Tsirkin
@ 2011-11-29 8:38 ` Paolo Bonzini
2011-11-29 13:12 ` Michael S. Tsirkin
0 siblings, 1 reply; 16+ messages in thread
From: Paolo Bonzini @ 2011-11-29 8:38 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
On 11/28/2011 07:46 PM, Michael S. Tsirkin wrote:
>> > +#ifdef CONFIG_LINUX
>> > +static int virtio_9p_init_pci(PCIDevice *pci_dev)
>> > +{
>> > + VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
>> > + VirtIODevice *vdev;
>> > +
>> > + vdev = virtio_9p_init(&pci_dev->qdev,&proxy->fsconf);
>> > + vdev->nvectors = proxy->nvectors;
>> > + virtio_init_pci(proxy, vdev);
>> > + /* make the actual value visible */
>> > + proxy->nvectors = vdev->nvectors;
>> > + return 0;
>> > +}
>> > +#endif
>> > +
> This ifdef looks wrong to me - is there no way 9p can thinkably
> work on non-linux hosts? If yes, we should have a separate config
> entry for 9p, configure script can make it
> conditional on linux host.
I think it was true in the beginning, but more recent versions should
only depend on CONFIG_POSIX. I will set up FreeBSD and come back.
Paolo
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 4/9] virtio-9p: remove PCI dependencies from hw/9pfs/
2011-11-29 8:38 ` Paolo Bonzini
@ 2011-11-29 13:12 ` Michael S. Tsirkin
2012-01-01 21:45 ` Paolo Bonzini
0 siblings, 1 reply; 16+ messages in thread
From: Michael S. Tsirkin @ 2011-11-29 13:12 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel
On Tue, Nov 29, 2011 at 09:38:43AM +0100, Paolo Bonzini wrote:
> On 11/28/2011 07:46 PM, Michael S. Tsirkin wrote:
> >>> +#ifdef CONFIG_LINUX
> >>> +static int virtio_9p_init_pci(PCIDevice *pci_dev)
> >>> +{
> >>> + VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
> >>> + VirtIODevice *vdev;
> >>> +
> >>> + vdev = virtio_9p_init(&pci_dev->qdev,&proxy->fsconf);
> >>> + vdev->nvectors = proxy->nvectors;
> >>> + virtio_init_pci(proxy, vdev);
> >>> + /* make the actual value visible */
> >>> + proxy->nvectors = vdev->nvectors;
> >>> + return 0;
> >>> +}
> >>> +#endif
> >>> +
> >This ifdef looks wrong to me - is there no way 9p can thinkably
> >work on non-linux hosts? If yes, we should have a separate config
> >entry for 9p, configure script can make it
> >conditional on linux host.
>
> I think it was true in the beginning, but more recent versions
> should only depend on CONFIG_POSIX. I will set up FreeBSD and come
> back.
>
> Paolo
It might be easier to add CONFIG_VIRTIO_9P. That won't hurt in any case.
--
MST
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 4/9] virtio-9p: remove PCI dependencies from hw/9pfs/
2011-11-29 13:12 ` Michael S. Tsirkin
@ 2012-01-01 21:45 ` Paolo Bonzini
0 siblings, 0 replies; 16+ messages in thread
From: Paolo Bonzini @ 2012-01-01 21:45 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: qemu-devel
On 11/29/2011 02:12 PM, Michael S. Tsirkin wrote:
> On Tue, Nov 29, 2011 at 09:38:43AM +0100, Paolo Bonzini wrote:
>> On 11/28/2011 07:46 PM, Michael S. Tsirkin wrote:
>>>>> +#ifdef CONFIG_LINUX
>>>>> +static int virtio_9p_init_pci(PCIDevice *pci_dev)
>>>>> +{
>>>>> + VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
>>>>> + VirtIODevice *vdev;
>>>>> +
>>>>> + vdev = virtio_9p_init(&pci_dev->qdev,&proxy->fsconf);
>>>>> + vdev->nvectors = proxy->nvectors;
>>>>> + virtio_init_pci(proxy, vdev);
>>>>> + /* make the actual value visible */
>>>>> + proxy->nvectors = vdev->nvectors;
>>>>> + return 0;
>>>>> +}
>>>>> +#endif
>>>>> +
>>> This ifdef looks wrong to me - is there no way 9p can thinkably
>>> work on non-linux hosts? If yes, we should have a separate config
>>> entry for 9p, configure script can make it
>>> conditional on linux host.
>>
>> I think it was true in the beginning, but more recent versions
>> should only depend on CONFIG_POSIX. I will set up FreeBSD and come
>> back.
>>
>> Paolo
>
> It might be easier to add CONFIG_VIRTIO_9P. That won't hurt in any case.
Actually CONFIG_VIRTFS exists already (Linux dependencies are mostly
statfs and d_off in struct dirent, plus extended attributes which are
checked separately).
Will resend.
Paolo
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2012-01-01 21:45 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-24 12:38 [Qemu-devel] [PATCH 0/9] virtio: device configuration cleanup Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 1/9] virtio-net: move property declarations to header file Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 2/9] virtio-net: move NICConf into virtio_net_conf Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 3/9] virtio-serial: move property declarations to header file Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 4/9] virtio-9p: remove PCI dependencies from hw/9pfs/ Paolo Bonzini
2011-11-28 17:18 ` Aneesh Kumar K.V
2011-11-28 18:46 ` Michael S. Tsirkin
2011-11-29 8:38 ` Paolo Bonzini
2011-11-29 13:12 ` Michael S. Tsirkin
2012-01-01 21:45 ` Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 5/9] virtio-9p: move property declarations to header file Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 6/9] virtio-blk: define VirtIOBlkConf Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 7/9] virtio-blk: move property declarations to header file Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 8/9] virtio-blk: move BlockConf into VirtIOBlkConf Paolo Bonzini
2011-11-24 12:38 ` [Qemu-devel] [PATCH 9/9] virtio: move conf fields into an anonymous union Paolo Bonzini
2011-11-28 18:51 ` [Qemu-devel] [PATCH 0/9] virtio: device configuration cleanup Michael S. Tsirkin
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).