[PATCH 06/24] virtio-net: mac property is mandatory
by Michael S. Tsirkin
Mac feature bit isn't going to work as all network cards already have a
'mac' property to set the mac address. Remove it from mask and add in
get_features.
Reported-by: Gerd Hoffmann <kraxel(a)redhat.com>
Signed-off-by: Michael S. Tsirkin <mst(a)redhat.com>
Signed-off-by: Anthony Liguori <aliguori(a)us.ibm.com>
(cherry picked from commit c9f79a3f79a48de28b4575cb5644bcf45d3754d0)
---
hw/virtio-net.c | 2 ++
hw/virtio-net.h | 1 -
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index c2a389f..02d9180 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -151,6 +151,8 @@ static uint32_t virtio_net_get_features(VirtIODevice *vdev, uint32_t features)
{
VirtIONet *n = to_virtio_net(vdev);
+ features |= (1 << VIRTIO_NET_F_MAC);
+
if (peer_has_vnet_hdr(n)) {
tap_using_vnet_hdr(n->nic->nc.peer, 1);
} else {
diff --git a/hw/virtio-net.h b/hw/virtio-net.h
index 9130d75..e55119b 100644
--- a/hw/virtio-net.h
+++ b/hw/virtio-net.h
@@ -157,7 +157,6 @@ struct virtio_net_ctrl_mac {
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("mac", _state, _field, VIRTIO_NET_F_MAC, 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), \
--
1.6.6.144.g5c3af
14 years, 2 months
[PATCH 05/24] virtio: add features as qdev properties
by Michael S. Tsirkin
Add feature bits as properties to virtio. This makes it possible to e.g. define
machine without indirect buffer support, which is required for 0.10
compatibility, or without hardware checksum support, which is required for 0.11
compatibility. Since default values for optional features are now set by qdev,
get_features callback has been modified: it sets non-optional bits, and clears
bits not supported by host.
Signed-off-by: Michael S. Tsirkin <mst(a)redhat.com>
Acked-by: Gerd Hoffmann <kraxel(a)redhat.com>
Signed-off-by: Anthony Liguori <aliguori(a)us.ibm.com>
(cherry picked from commit 8172539d21a03e982aa7f139ddc1607dc1422045)
---
hw/s390-virtio-bus.c | 12 +++++++++---
hw/s390-virtio-bus.h | 1 +
hw/syborg_virtio.c | 13 ++++++++-----
hw/virtio-balloon.c | 4 ++--
hw/virtio-blk.c | 6 +-----
hw/virtio-blk.h | 8 ++++++++
hw/virtio-console.c | 4 ++--
hw/virtio-net.c | 39 ++++++++++++++++-----------------------
hw/virtio-net.h | 20 ++++++++++++++++++++
hw/virtio-pci.c | 25 +++++++++++++++++--------
hw/virtio.c | 2 +-
hw/virtio.h | 7 ++++++-
12 files changed, 91 insertions(+), 50 deletions(-)
diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index 6c0da11..980e7eb 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -101,6 +101,7 @@ static int s390_virtio_device_init(VirtIOS390Device *dev, VirtIODevice *vdev)
bus->dev_offs += dev_len;
virtio_bind_device(vdev, &virtio_s390_bindings, dev);
+ dev->host_features = vdev->get_features(vdev, dev->host_features);
s390_virtio_device_sync(dev);
return 0;
@@ -222,9 +223,7 @@ static void s390_virtio_device_sync(VirtIOS390Device *dev)
cur_offs += num_vq * VIRTIO_VQCONFIG_LEN;
/* Sync feature bitmap */
- if (dev->vdev->get_features) {
- stl_phys(cur_offs, dev->vdev->get_features(dev->vdev));
- }
+ stl_phys(cur_offs, dev->host_features);
dev->feat_offs = cur_offs + dev->feat_len;
cur_offs += dev->feat_len * 2;
@@ -310,10 +309,17 @@ static void virtio_s390_notify(void *opaque, uint16_t vector)
kvm_s390_virtio_irq(s390_cpu_addr2state(0), 0, token);
}
+static unsigned virtio_s390_get_features(void *opaque)
+{
+ VirtIOS390Device *dev = (VirtIOS390Device*)opaque;
+ return dev->host_features;
+}
+
/**************** S390 Virtio Bus Device Descriptions *******************/
static const VirtIOBindings virtio_s390_bindings = {
.notify = virtio_s390_notify,
+ .get_features = virtio_s390_get_features,
};
static VirtIOS390DeviceInfo s390_virtio_net = {
diff --git a/hw/s390-virtio-bus.h b/hw/s390-virtio-bus.h
index ef36714..8ae2065 100644
--- a/hw/s390-virtio-bus.h
+++ b/hw/s390-virtio-bus.h
@@ -40,6 +40,7 @@ typedef struct VirtIOS390Device {
VirtIODevice *vdev;
DriveInfo *dinfo;
NICConf nic;
+ uint32_t host_features;
} VirtIOS390Device;
typedef struct VirtIOS390Bus {
diff --git a/hw/syborg_virtio.c b/hw/syborg_virtio.c
index fe6fc23..65239a0 100644
--- a/hw/syborg_virtio.c
+++ b/hw/syborg_virtio.c
@@ -25,6 +25,7 @@
#include "syborg.h"
#include "sysbus.h"
#include "virtio.h"
+#include "virtio-net.h"
#include "sysemu.h"
//#define DEBUG_SYBORG_VIRTIO
@@ -66,6 +67,7 @@ typedef struct {
uint32_t int_enable;
uint32_t id;
NICConf nic;
+ uint32_t host_features;
} SyborgVirtIOProxy;
static uint32_t syborg_virtio_readl(void *opaque, target_phys_addr_t offset)
@@ -86,8 +88,7 @@ static uint32_t syborg_virtio_readl(void *opaque, target_phys_addr_t offset)
ret = s->id;
break;
case SYBORG_VIRTIO_HOST_FEATURES:
- ret = vdev->get_features(vdev);
- ret |= vdev->binding->get_features(s);
+ ret = s->host_features;
break;
case SYBORG_VIRTIO_GUEST_FEATURES:
ret = vdev->guest_features;
@@ -244,9 +245,8 @@ static void syborg_virtio_update_irq(void *opaque, uint16_t vector)
static unsigned syborg_virtio_get_features(void *opaque)
{
- unsigned ret = 0;
- ret |= (1 << VIRTIO_F_NOTIFY_ON_EMPTY);
- return ret;
+ SyborgVirtIOProxy *proxy = opaque;
+ return proxy->host_features;
}
static VirtIOBindings syborg_virtio_bindings = {
@@ -272,6 +272,8 @@ static int syborg_virtio_init(SyborgVirtIOProxy *proxy, VirtIODevice *vdev)
qemu_register_reset(virtio_reset, vdev);
virtio_bind_device(vdev, &syborg_virtio_bindings, proxy);
+ proxy->host_features |= (0x1 << VIRTIO_F_NOTIFY_ON_EMPTY);
+ proxy->host_features = vdev->get_features(vdev, proxy->host_features);
return 0;
}
@@ -292,6 +294,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_END_OF_LIST(),
}
};
diff --git a/hw/virtio-balloon.c b/hw/virtio-balloon.c
index 7ca783e..242c6c8 100644
--- a/hw/virtio-balloon.c
+++ b/hw/virtio-balloon.c
@@ -125,9 +125,9 @@ static void virtio_balloon_set_config(VirtIODevice *vdev,
dev->actual = config.actual;
}
-static uint32_t virtio_balloon_get_features(VirtIODevice *vdev)
+static uint32_t virtio_balloon_get_features(VirtIODevice *vdev, uint32_t f)
{
- return 0;
+ return f;
}
static ram_addr_t virtio_balloon_to_target(void *opaque, ram_addr_t target)
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index a2f0639..cb1ae1f 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -432,19 +432,15 @@ static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config)
memcpy(config, &blkcfg, s->config_size);
}
-static uint32_t virtio_blk_get_features(VirtIODevice *vdev)
+static uint32_t virtio_blk_get_features(VirtIODevice *vdev, uint32_t features)
{
VirtIOBlock *s = to_virtio_blk(vdev);
- uint32_t features = 0;
features |= (1 << VIRTIO_BLK_F_SEG_MAX);
features |= (1 << VIRTIO_BLK_F_GEOMETRY);
if (bdrv_enable_write_cache(s->bs))
features |= (1 << VIRTIO_BLK_F_WCACHE);
-#ifdef __linux__
- features |= (1 << VIRTIO_BLK_F_SCSI);
-#endif
if (strcmp(s->serial_str, "0"))
features |= 1 << VIRTIO_BLK_F_IDENTIFY;
diff --git a/hw/virtio-blk.h b/hw/virtio-blk.h
index 23ad74c..c28f776 100644
--- a/hw/virtio-blk.h
+++ b/hw/virtio-blk.h
@@ -92,4 +92,12 @@ struct virtio_scsi_inhdr
uint32_t residual;
};
+#ifdef __linux__
+#define DEFINE_VIRTIO_BLK_FEATURES(_state, _field) \
+ DEFINE_VIRTIO_COMMON_FEATURES(_state, _field), \
+ DEFINE_PROP_BIT("scsi", _state, _field, VIRTIO_BLK_F_SCSI, true)
+#else
+#define DEFINE_VIRTIO_BLK_FEATURES(_state, _field) \
+ DEFINE_VIRTIO_COMMON_FEATURES(_state, _field)
+#endif
#endif
diff --git a/hw/virtio-console.c b/hw/virtio-console.c
index 92c953c..ff9c306 100644
--- a/hw/virtio-console.c
+++ b/hw/virtio-console.c
@@ -51,9 +51,9 @@ static void virtio_console_handle_input(VirtIODevice *vdev, VirtQueue *vq)
{
}
-static uint32_t virtio_console_get_features(VirtIODevice *vdev)
+static uint32_t virtio_console_get_features(VirtIODevice *vdev, uint32_t f)
{
- return 0;
+ return f;
}
static int vcon_can_read(void *opaque)
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index ab20a33..c2a389f 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -147,34 +147,27 @@ static int peer_has_ufo(VirtIONet *n)
return n->has_ufo;
}
-static uint32_t virtio_net_get_features(VirtIODevice *vdev)
+static uint32_t virtio_net_get_features(VirtIODevice *vdev, uint32_t features)
{
VirtIONet *n = to_virtio_net(vdev);
- uint32_t features = (1 << VIRTIO_NET_F_MAC) |
- (1 << VIRTIO_NET_F_MRG_RXBUF) |
- (1 << VIRTIO_NET_F_STATUS) |
- (1 << VIRTIO_NET_F_CTRL_VQ) |
- (1 << VIRTIO_NET_F_CTRL_RX) |
- (1 << VIRTIO_NET_F_CTRL_VLAN) |
- (1 << VIRTIO_NET_F_CTRL_RX_EXTRA);
if (peer_has_vnet_hdr(n)) {
tap_using_vnet_hdr(n->nic->nc.peer, 1);
+ } else {
+ features &= ~(0x1 << VIRTIO_NET_F_CSUM);
+ features &= ~(0x1 << VIRTIO_NET_F_HOST_TSO4);
+ features &= ~(0x1 << VIRTIO_NET_F_HOST_TSO6);
+ features &= ~(0x1 << VIRTIO_NET_F_HOST_ECN);
+
+ features &= ~(0x1 << VIRTIO_NET_F_GUEST_CSUM);
+ features &= ~(0x1 << VIRTIO_NET_F_GUEST_TSO4);
+ features &= ~(0x1 << VIRTIO_NET_F_GUEST_TSO6);
+ features &= ~(0x1 << VIRTIO_NET_F_GUEST_ECN);
+ }
- features |= (1 << VIRTIO_NET_F_CSUM);
- features |= (1 << VIRTIO_NET_F_HOST_TSO4);
- features |= (1 << VIRTIO_NET_F_HOST_TSO6);
- features |= (1 << VIRTIO_NET_F_HOST_ECN);
-
- features |= (1 << VIRTIO_NET_F_GUEST_CSUM);
- features |= (1 << VIRTIO_NET_F_GUEST_TSO4);
- features |= (1 << VIRTIO_NET_F_GUEST_TSO6);
- features |= (1 << VIRTIO_NET_F_GUEST_ECN);
-
- if (peer_has_ufo(n)) {
- features |= (1 << VIRTIO_NET_F_GUEST_UFO);
- features |= (1 << VIRTIO_NET_F_HOST_UFO);
- }
+ if (!peer_has_vnet_hdr(n) || !peer_has_ufo(n)) {
+ features &= ~(0x1 << VIRTIO_NET_F_GUEST_UFO);
+ features &= ~(0x1 << VIRTIO_NET_F_HOST_UFO);
}
return features;
@@ -192,7 +185,7 @@ static uint32_t virtio_net_bad_features(VirtIODevice *vdev)
features |= (1 << VIRTIO_NET_F_HOST_TSO6);
features |= (1 << VIRTIO_NET_F_HOST_ECN);
- return features & virtio_net_get_features(vdev);
+ return features;
}
static void virtio_net_set_features(VirtIODevice *vdev, uint32_t features)
diff --git a/hw/virtio-net.h b/hw/virtio-net.h
index 2085181..9130d75 100644
--- a/hw/virtio-net.h
+++ b/hw/virtio-net.h
@@ -153,4 +153,24 @@ 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("mac", _state, _field, VIRTIO_NET_F_MAC, 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)
#endif
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index c23dbc0..573c98a 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -16,6 +16,8 @@
#include <inttypes.h>
#include "virtio.h"
+#include "virtio-blk.h"
+#include "virtio-net.h"
#include "pci.h"
#include "sysemu.h"
#include "msix.h"
@@ -92,6 +94,7 @@ typedef struct {
uint32_t nvectors;
DriveInfo *dinfo;
NICConf nic;
+ uint32_t host_features;
} VirtIOPCIProxy;
/* virtio device */
@@ -175,7 +178,7 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
/* Guest does not negotiate properly? We have to assume nothing. */
if (val & (1 << VIRTIO_F_BAD_FEATURE)) {
if (vdev->bad_features)
- val = vdev->bad_features(vdev);
+ val = proxy->host_features & vdev->bad_features(vdev);
else
val = 0;
}
@@ -235,8 +238,7 @@ static uint32_t virtio_ioport_read(VirtIOPCIProxy *proxy, uint32_t addr)
switch (addr) {
case VIRTIO_PCI_HOST_FEATURES:
- ret = vdev->get_features(vdev);
- ret |= vdev->binding->get_features(proxy);
+ ret = proxy->host_features;
break;
case VIRTIO_PCI_GUEST_FEATURES:
ret = vdev->guest_features;
@@ -382,11 +384,8 @@ static void virtio_write_config(PCIDevice *pci_dev, uint32_t address,
static unsigned virtio_pci_get_features(void *opaque)
{
- unsigned ret = 0;
- ret |= (1 << VIRTIO_F_NOTIFY_ON_EMPTY);
- ret |= (1 << VIRTIO_RING_F_INDIRECT_DESC);
- ret |= (1 << VIRTIO_F_BAD_FEATURE);
- return ret;
+ VirtIOPCIProxy *proxy = opaque;
+ return proxy->host_features;
}
static const VirtIOBindings virtio_pci_bindings = {
@@ -442,6 +441,9 @@ static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev,
virtio_map);
virtio_bind_device(vdev, &virtio_pci_bindings, proxy);
+ proxy->host_features |= 0x1 << VIRTIO_F_NOTIFY_ON_EMPTY;
+ proxy->host_features |= 0x1 << VIRTIO_F_BAD_FEATURE;
+ proxy->host_features = vdev->get_features(vdev, proxy->host_features);
}
static int virtio_blk_init_pci(PCIDevice *pci_dev)
@@ -553,6 +555,7 @@ static PCIDeviceInfo virtio_info[] = {
DEFINE_PROP_HEX32("class", VirtIOPCIProxy, class_code, 0),
DEFINE_PROP_DRIVE("drive", VirtIOPCIProxy, dinfo),
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 2),
+ DEFINE_VIRTIO_BLK_FEATURES(VirtIOPCIProxy, host_features),
DEFINE_PROP_END_OF_LIST(),
},
.qdev.reset = virtio_pci_reset,
@@ -564,6 +567,7 @@ static PCIDeviceInfo virtio_info[] = {
.romfile = "pxe-virtio.bin",
.qdev.props = (Property[]) {
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 3),
+ DEFINE_VIRTIO_NET_FEATURES(VirtIOPCIProxy, host_features),
DEFINE_NIC_PROPERTIES(VirtIOPCIProxy, nic),
DEFINE_PROP_END_OF_LIST(),
},
@@ -575,6 +579,7 @@ static PCIDeviceInfo virtio_info[] = {
.exit = virtio_exit_pci,
.qdev.props = (Property[]) {
DEFINE_PROP_HEX32("class", VirtIOPCIProxy, class_code, 0),
+ DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),
DEFINE_PROP_END_OF_LIST(),
},
.qdev.reset = virtio_pci_reset,
@@ -583,6 +588,10 @@ static PCIDeviceInfo virtio_info[] = {
.qdev.size = sizeof(VirtIOPCIProxy),
.init = virtio_balloon_init_pci,
.exit = virtio_exit_pci,
+ .qdev.props = (Property[]) {
+ DEFINE_VIRTIO_COMMON_FEATURES(VirtIOPCIProxy, host_features),
+ DEFINE_PROP_END_OF_LIST(),
+ },
.qdev.reset = virtio_pci_reset,
},{
/* end of list */
diff --git a/hw/virtio.c b/hw/virtio.c
index c25a5f1..fa7184a 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -652,7 +652,7 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
{
int num, i, ret;
uint32_t features;
- uint32_t supported_features = vdev->get_features(vdev) |
+ uint32_t supported_features =
vdev->binding->get_features(vdev->binding_opaque);
if (vdev->binding->load_config) {
diff --git a/hw/virtio.h b/hw/virtio.h
index 85ef171..3994cc9 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -105,7 +105,7 @@ struct VirtIODevice
void *config;
uint16_t config_vector;
int nvectors;
- uint32_t (*get_features)(VirtIODevice *vdev);
+ uint32_t (*get_features)(VirtIODevice *vdev, uint32_t requested_features);
uint32_t (*bad_features)(VirtIODevice *vdev);
void (*set_features)(VirtIODevice *vdev, uint32_t val);
void (*get_config)(VirtIODevice *vdev, uint8_t *config);
@@ -176,4 +176,9 @@ VirtIODevice *virtio_balloon_init(DeviceState *dev);
void virtio_net_exit(VirtIODevice *vdev);
+#define DEFINE_VIRTIO_COMMON_FEATURES(_state, _field) \
+ DEFINE_PROP_BIT("indirect_desc", _state, _field, \
+ VIRTIO_RING_F_INDIRECT_DESC, true)
+
+
#endif
--
1.6.6.144.g5c3af
14 years, 2 months
[PATCH 04/24] qdev: fix thinko leading to guest crashes
by Michael S. Tsirkin
Without this fix, guest crashes with drive=virtio.
Signed-off-by: Michael S. Tsirkin <mst(a)redhat.com>
Signed-off-by: Anthony Liguori <aliguori(a)us.ibm.com>
(cherry picked from commit dbd483242c2e6dfaacb9fd3d20c333bbdad87243)
---
hw/qdev-properties.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 9e123ae..277ff9e 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -20,7 +20,7 @@ static void bit_prop_set(DeviceState *dev, Property *props, bool val)
uint32_t *p = qdev_get_prop_ptr(dev, props);
uint32_t mask = qdev_get_prop_mask(props);
if (val)
- *p |= ~mask;
+ *p |= mask;
else
*p &= ~mask;
}
--
1.6.6.144.g5c3af
14 years, 2 months
[PATCH 03/24] qdev: add bit property type
by Michael S. Tsirkin
This adds "bit" property type, which is a boolean stored in a 32 bit
integer field, with legal values on and off. Will be used by virtio for
feature bits.
Signed-off-by: Michael S. Tsirkin <mst(a)redhat.com>
Acked-by: Gerd Hoffmann <kraxel(a)redhat.com>
Signed-off-by: Anthony Liguori <aliguori(a)us.ibm.com>
(cherry picked from commit d2364ee424ebf9180afaf21128a71da55321ad00)
---
hw/qdev-properties.c | 62 ++++++++++++++++++++++++++++++++++++++++++++-----
hw/qdev.h | 11 +++++++++
2 files changed, 66 insertions(+), 7 deletions(-)
diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c
index 217ddc0..9e123ae 100644
--- a/hw/qdev-properties.c
+++ b/hw/qdev-properties.c
@@ -9,6 +9,59 @@ void *qdev_get_prop_ptr(DeviceState *dev, Property *prop)
return ptr;
}
+static uint32_t qdev_get_prop_mask(Property *prop)
+{
+ assert(prop->info->type == PROP_TYPE_BIT);
+ return 0x1 << prop->bitnr;
+}
+
+static void bit_prop_set(DeviceState *dev, Property *props, bool val)
+{
+ uint32_t *p = qdev_get_prop_ptr(dev, props);
+ uint32_t mask = qdev_get_prop_mask(props);
+ if (val)
+ *p |= ~mask;
+ else
+ *p &= ~mask;
+}
+
+static void qdev_prop_cpy(DeviceState *dev, Property *props, void *src)
+{
+ if (props->info->type == PROP_TYPE_BIT) {
+ bool *defval = src;
+ bit_prop_set(dev, props, *defval);
+ } else {
+ char *dst = qdev_get_prop_ptr(dev, props);
+ memcpy(dst, src, props->info->size);
+ }
+}
+
+/* Bit */
+static int parse_bit(DeviceState *dev, Property *prop, const char *str)
+{
+ if (!strncasecmp(str, "on", 2))
+ bit_prop_set(dev, prop, true);
+ else if (!strncasecmp(str, "off", 3))
+ bit_prop_set(dev, prop, false);
+ else
+ return -1;
+ return 0;
+}
+
+static int print_bit(DeviceState *dev, Property *prop, char *dest, size_t len)
+{
+ uint8_t *p = qdev_get_prop_ptr(dev, prop);
+ return snprintf(dest, len, (*p & qdev_get_prop_mask(prop)) ? "on" : "off");
+}
+
+PropertyInfo qdev_prop_bit = {
+ .name = "on/off",
+ .type = PROP_TYPE_BIT,
+ .size = sizeof(uint32_t),
+ .parse = parse_bit,
+ .print = print_bit,
+};
+
/* --- 8bit integer --- */
static int parse_uint8(DeviceState *dev, Property *prop, const char *str)
@@ -511,7 +564,6 @@ int qdev_prop_parse(DeviceState *dev, const char *name, const char *value)
void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyType type)
{
Property *prop;
- void *dst;
prop = qdev_prop_find(dev, name);
if (!prop) {
@@ -524,8 +576,7 @@ void qdev_prop_set(DeviceState *dev, const char *name, void *src, enum PropertyT
__FUNCTION__, dev->info->name, name);
abort();
}
- dst = qdev_get_prop_ptr(dev, prop);
- memcpy(dst, src, prop->info->size);
+ qdev_prop_cpy(dev, prop, src);
}
void qdev_prop_set_uint8(DeviceState *dev, const char *name, uint8_t value)
@@ -585,14 +636,11 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)
void qdev_prop_set_defaults(DeviceState *dev, Property *props)
{
- char *dst;
-
if (!props)
return;
while (props->name) {
if (props->defval) {
- dst = qdev_get_prop_ptr(dev, props);
- memcpy(dst, props->defval, props->info->size);
+ qdev_prop_cpy(dev, props, props->defval);
}
props++;
}
diff --git a/hw/qdev.h b/hw/qdev.h
index bbcdba1..07b9603 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -64,6 +64,7 @@ struct Property {
const char *name;
PropertyInfo *info;
int offset;
+ int bitnr;
void *defval;
};
@@ -82,6 +83,7 @@ enum PropertyType {
PROP_TYPE_NETDEV,
PROP_TYPE_VLAN,
PROP_TYPE_PTR,
+ PROP_TYPE_BIT,
};
struct PropertyInfo {
@@ -173,6 +175,7 @@ void do_device_del(Monitor *mon, const QDict *qdict);
/*** qdev-properties.c ***/
+extern PropertyInfo qdev_prop_bit;
extern PropertyInfo qdev_prop_uint8;
extern PropertyInfo qdev_prop_uint16;
extern PropertyInfo qdev_prop_uint32;
@@ -202,6 +205,14 @@ extern PropertyInfo qdev_prop_pci_devfn;
+ type_check(_type,typeof_field(_state, _field)), \
.defval = (_type[]) { _defval }, \
}
+#define DEFINE_PROP_BIT(_name, _state, _field, _bit, _defval) { \
+ .name = (_name), \
+ .info = &(qdev_prop_bit), \
+ .bitnr = (_bit), \
+ .offset = offsetof(_state, _field) \
+ + type_check(uint32_t,typeof_field(_state, _field)), \
+ .defval = (bool[]) { (_defval) }, \
+ }
#define DEFINE_PROP_UINT8(_n, _s, _f, _d) \
DEFINE_PROP_DEFAULT(_n, _s, _f, _d, qdev_prop_uint8, uint8_t)
--
1.6.6.144.g5c3af
14 years, 2 months
[PATCH 02/24] virtio: rename features -> guest_features
by Michael S. Tsirkin
Rename features->guest_features. This is
what they are, avoid confusion with
host features which we also need to keep around.
Signed-off-by: Michael S. Tsirkin <mst(a)redhat.com>
Signed-off-by: Anthony Liguori <aliguori(a)us.ibm.com>
(cherry picked from commit 704a76fcd24372a683652651b4597f6654084975)
---
hw/s390-virtio-bus.c | 2 +-
hw/syborg_virtio.c | 4 ++--
hw/virtio-net.c | 10 +++++-----
hw/virtio-pci.c | 4 ++--
hw/virtio.c | 8 ++++----
hw/virtio.h | 2 +-
6 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index dc154ed..6c0da11 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -251,7 +251,7 @@ void s390_virtio_device_update_status(VirtIOS390Device *dev)
if (vdev->set_features) {
vdev->set_features(vdev, features);
}
- vdev->features = features;
+ vdev->guest_features = features;
}
VirtIOS390Device *s390_virtio_bus_console(VirtIOS390Bus *bus)
diff --git a/hw/syborg_virtio.c b/hw/syborg_virtio.c
index a84206a..fe6fc23 100644
--- a/hw/syborg_virtio.c
+++ b/hw/syborg_virtio.c
@@ -90,7 +90,7 @@ static uint32_t syborg_virtio_readl(void *opaque, target_phys_addr_t offset)
ret |= vdev->binding->get_features(s);
break;
case SYBORG_VIRTIO_GUEST_FEATURES:
- ret = vdev->features;
+ ret = vdev->guest_features;
break;
case SYBORG_VIRTIO_QUEUE_BASE:
ret = virtio_queue_get_addr(vdev, vdev->queue_sel);
@@ -132,7 +132,7 @@ static void syborg_virtio_writel(void *opaque, target_phys_addr_t offset,
case SYBORG_VIRTIO_GUEST_FEATURES:
if (vdev->set_features)
vdev->set_features(vdev, value);
- vdev->features = value;
+ vdev->guest_features = value;
break;
case SYBORG_VIRTIO_QUEUE_BASE:
if (value == 0)
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 2f201ff..ab20a33 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -768,11 +768,11 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
if (n->has_vnet_hdr) {
tap_using_vnet_hdr(n->nic->nc.peer, 1);
tap_set_offload(n->nic->nc.peer,
- (n->vdev.features >> VIRTIO_NET_F_GUEST_CSUM) & 1,
- (n->vdev.features >> VIRTIO_NET_F_GUEST_TSO4) & 1,
- (n->vdev.features >> VIRTIO_NET_F_GUEST_TSO6) & 1,
- (n->vdev.features >> VIRTIO_NET_F_GUEST_ECN) & 1,
- (n->vdev.features >> VIRTIO_NET_F_GUEST_UFO) & 1);
+ (n->vdev.guest_features >> VIRTIO_NET_F_GUEST_CSUM) & 1,
+ (n->vdev.guest_features >> VIRTIO_NET_F_GUEST_TSO4) & 1,
+ (n->vdev.guest_features >> VIRTIO_NET_F_GUEST_TSO6) & 1,
+ (n->vdev.guest_features >> VIRTIO_NET_F_GUEST_ECN) & 1,
+ (n->vdev.guest_features >> VIRTIO_NET_F_GUEST_UFO) & 1);
}
}
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 3594152..c23dbc0 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -181,7 +181,7 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
}
if (vdev->set_features)
vdev->set_features(vdev, val);
- vdev->features = val;
+ vdev->guest_features = val;
break;
case VIRTIO_PCI_QUEUE_PFN:
pa = (target_phys_addr_t)val << VIRTIO_PCI_QUEUE_ADDR_SHIFT;
@@ -239,7 +239,7 @@ static uint32_t virtio_ioport_read(VirtIOPCIProxy *proxy, uint32_t addr)
ret |= vdev->binding->get_features(proxy);
break;
case VIRTIO_PCI_GUEST_FEATURES:
- ret = vdev->features;
+ ret = vdev->guest_features;
break;
case VIRTIO_PCI_QUEUE_PFN:
ret = virtio_queue_get_addr(vdev, vdev->queue_sel)
diff --git a/hw/virtio.c b/hw/virtio.c
index cecd0dc..c25a5f1 100644
--- a/hw/virtio.c
+++ b/hw/virtio.c
@@ -445,7 +445,7 @@ void virtio_reset(void *opaque)
if (vdev->reset)
vdev->reset(vdev);
- vdev->features = 0;
+ vdev->guest_features = 0;
vdev->queue_sel = 0;
vdev->status = 0;
vdev->isr = 0;
@@ -598,7 +598,7 @@ void virtio_notify(VirtIODevice *vdev, VirtQueue *vq)
{
/* Always notify when queue is empty (when feature acknowledge) */
if ((vring_avail_flags(vq) & VRING_AVAIL_F_NO_INTERRUPT) &&
- (!(vdev->features & (1 << VIRTIO_F_NOTIFY_ON_EMPTY)) ||
+ (!(vdev->guest_features & (1 << VIRTIO_F_NOTIFY_ON_EMPTY)) ||
(vq->inuse || vring_avail_idx(vq) != vq->last_avail_idx)))
return;
@@ -625,7 +625,7 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
qemu_put_8s(f, &vdev->status);
qemu_put_8s(f, &vdev->isr);
qemu_put_be16s(f, &vdev->queue_sel);
- qemu_put_be32s(f, &vdev->features);
+ qemu_put_be32s(f, &vdev->guest_features);
qemu_put_be32(f, vdev->config_len);
qemu_put_buffer(f, vdev->config, vdev->config_len);
@@ -670,7 +670,7 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f)
features, supported_features);
return -1;
}
- vdev->features = features;
+ vdev->guest_features = features;
vdev->config_len = qemu_get_be32(f);
qemu_get_buffer(f, vdev->config, vdev->config_len);
diff --git a/hw/virtio.h b/hw/virtio.h
index 35532a6..85ef171 100644
--- a/hw/virtio.h
+++ b/hw/virtio.h
@@ -100,7 +100,7 @@ struct VirtIODevice
uint8_t status;
uint8_t isr;
uint16_t queue_sel;
- uint32_t features;
+ uint32_t guest_features;
size_t config_len;
void *config;
uint16_t config_vector;
--
1.6.6.144.g5c3af
14 years, 2 months
[PATCH 01/24] net: add API to disable/enable polling
by Michael S. Tsirkin
When vhost is bound to a backend device, we need to stop polling it when
vhost is started, and restart polling when vhost is stopped.
Add an API for that for use by vhost, and implement in tap backend.
Signed-off-by: Michael S. Tsirkin <mst(a)redhat.com>
Signed-off-by: Anthony Liguori <aliguori(a)us.ibm.com>
(cherry picked from commit ceb696159d569db5b2a7659ce38752398c236742)
---
net.h | 3 +++
net/tap.c | 8 ++++++++
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/net.h b/net.h
index 4971fcb..116bb80 100644
--- a/net.h
+++ b/net.h
@@ -1,6 +1,7 @@
#ifndef QEMU_NET_H
#define QEMU_NET_H
+#include <stdbool.h>
#include "qemu-queue.h"
#include "qemu-common.h"
#include "qdict.h"
@@ -36,6 +37,7 @@ typedef enum {
NET_CLIENT_TYPE_DUMP
} net_client_type;
+typedef void (NetPoll)(VLANClientState *, bool enable);
typedef int (NetCanReceive)(VLANClientState *);
typedef ssize_t (NetReceive)(VLANClientState *, const uint8_t *, size_t);
typedef ssize_t (NetReceiveIOV)(VLANClientState *, const struct iovec *, int);
@@ -51,6 +53,7 @@ typedef struct NetClientInfo {
NetCanReceive *can_receive;
NetCleanup *cleanup;
LinkStatusChanged *link_status_changed;
+ NetPoll *poll;
} NetClientInfo;
struct VLANClientState {
diff --git a/net/tap.c b/net/tap.c
index 0d8b424..d3492de 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -262,6 +262,13 @@ static void tap_cleanup(VLANClientState *nc)
close(s->fd);
}
+static void tap_poll(VLANClientState *nc, bool enable)
+{
+ TAPState *s = DO_UPCAST(TAPState, nc, nc);
+ tap_read_poll(s, enable);
+ tap_write_poll(s, enable);
+}
+
/* fd support */
static NetClientInfo net_tap_info = {
@@ -270,6 +277,7 @@ static NetClientInfo net_tap_info = {
.receive = tap_receive,
.receive_raw = tap_receive_raw,
.receive_iov = tap_receive_iov,
+ .poll = tap_poll,
.cleanup = tap_cleanup,
};
--
1.6.6.144.g5c3af
14 years, 2 months
[PATCH 00/24] qemu-kvm: backport vhost net from upstream
by Michael S. Tsirkin
The following patchset backports vhost net support
from qemu-kvm master to F13. I'd like the patches to
be added to fedora before feature freeze.
These patches are required for vhost net feature. Feature page here:
https://fedoraproject.org/wiki/Features/VHostNet
The patches have been posted upstream, and apply without changes. Most
infrastructure is upstream already, and has been backported by simple
cherry-pick.
Thanks!
Michael S. Tsirkin (24):
net: add API to disable/enable polling
virtio: rename features -> guest_features
qdev: add bit property type
qdev: fix thinko leading to guest crashes
virtio: add features as qdev properties
virtio-net: mac property is mandatory
exec: memory notifiers
kvm: add API to set ioeventfd
notifier: event notifier implementation
virtio: add notifier support
virtio: add APIs for queue fields
virtio: add status change callback
virtio: move typedef to qemu-common
virtio-pci: fill in notifier support
tap: add interface to get device fd
vhost: vhost net support
tap: add vhost/vhostfd options
tap: add API to retrieve vhost net header
virtio-net: vhost net support
qemu-kvm: add vhost.h header
kvm: irqfd support
msix: add mask/unmask notifiers
virtio-pci: irqfd support
virtio: avoid crash with non-tap backends
Makefile.target | 2 +
cpu-common.h | 19 ++
exec.c | 114 +++++++++-
hw/msix.c | 36 +++-
hw/msix.h | 1 +
hw/notifier.c | 50 ++++
hw/notifier.h | 16 ++
hw/pci.h | 6 +
hw/qdev-properties.c | 62 ++++-
hw/qdev.h | 11 +
hw/s390-virtio-bus.c | 17 +-
hw/s390-virtio-bus.h | 1 +
hw/syborg_virtio.c | 19 +-
hw/vhost.c | 603 +++++++++++++++++++++++++++++++++++++++++++++
hw/vhost.h | 44 ++++
hw/vhost_net.c | 147 +++++++++++
hw/vhost_net.h | 20 ++
hw/virtio-balloon.c | 4 +-
hw/virtio-blk.c | 6 +-
hw/virtio-blk.h | 8 +
hw/virtio-console.c | 4 +-
hw/virtio-net.c | 122 +++++++---
hw/virtio-net.h | 19 ++
hw/virtio-pci.c | 124 +++++++++-
hw/virtio.c | 62 +++++-
hw/virtio.h | 22 ++-
kvm-all.c | 39 +++
kvm.h | 26 ++
kvm/include/linux/vhost.h | 130 ++++++++++
net.c | 8 +
net.h | 3 +
net/tap.c | 51 ++++
net/tap.h | 5 +
qemu-common.h | 2 +
qemu-options.hx | 4 +-
35 files changed, 1726 insertions(+), 81 deletions(-)
create mode 100644 hw/notifier.c
create mode 100644 hw/notifier.h
create mode 100644 hw/vhost.c
create mode 100644 hw/vhost.h
create mode 100644 hw/vhost_net.c
create mode 100644 hw/vhost_net.h
create mode 100644 kvm/include/linux/vhost.h
14 years, 2 months
Fedora virt status
by Justin Forbes
Fedora 13
=========
Feature Submission deadline for F-13 was earlier this week, we have some
exciting new features submitted. As we move towards F-13, we are getting
really close to the Feature Freeze deadline.
F-13 schedule:
2010-02-09 Feature Freeze (4 days)
2010-02-16 Alpha Freeze (11 days)
2010-03-23 Beta (Final Development) Freeze (46 days)
2010-04-29 Compose Release Candidate (83 days)
Fedora Cloud SIG
================
A new Fedora Cloud SIG has been created focused to make Fedora
successful on all major cloud platforms, public and private. More
details can be found at https://fedoraproject.org/wiki/Cloud_SIG
F12 Virt Preview
================
As was announced before, the virt-preview repository for F12 users wishing
to test out the latest virtualization bits is available. Instructions for
using this repository can be found at:
https://fedoraproject.org/wiki/Virtualization_Preview_Repository
Recent updates in this repository include:
gpxe-1.0.0-1:
- bugfix release, also adds wireless card support
- bnx2 builds again
- drop our one patch
libvirt-0.7.6-1:
- upstream release of 0.7.6
- Use QEmu new device adressing when possible
- Implement CPU topology support for QEMU driver
- Implement SCSI controller hotplug/unplug for QEMU
- Implement support for multi IQN
- a lot of fixes and improvements
libvirt-java-0.4.2-1:
- Changed Scheduled Parameters to be a Union instead of a Struct.
- Better Pointer mappings in the error callback
qemu-0.12.2-5:
- Avoid creating too large iovecs in multiwrite merge (#559717)
- Don't try to set max_kernel_pages during ksm init on newer kernels (#558281)
- Add logfile options for ksmtuned debug.
Bugs
====
DOOM-O-METER: 230 bugs open 1 week ago, up to 238 now.
Many of these are duplicates from abrt auto filing, but We still have a
lot of work to do!
= Important =
== kernel ==
https://bugzilla.redhat.com/show_bug.cgi?id=545851
KVM/networking-related crash
A patch has been submitted upstream, and this should be fixed with
the next kernel update.
== kvm ==
https://bugzilla.redhat.com/show_bug.cgi?id=559717
KVM/Qemu 0.12.2 guest: WARNING: at block/blk-core.c:336
This has been fixed in the most recent rawhide and virt-preview builds.
https://bugzilla.redhat.com/show_bug.cgi?id=555788
SIGTRAP leakage between separate virtual machines
Patches have been posted for this, and a resolution is coming soon.
https://bugzilla.redhat.com/show_bug.cgi?id=478317
almost 9 thousand syscalls per second while idle
This is believed to be a result of the USB Tablet device, but several
users have noticed high host CPU usage while guests were idle.
https://bugzilla.redhat.com/show_bug.cgi?id=544339
Segfaults logged from kvm (qemu-kvm) resulting in guest sudden crash
and data loss
A number of users complaining of guests crashing and sometimes taking
the host with them. This appears to be related to sound emulation.
https://bugzilla.redhat.com/show_bug.cgi?id=544940
reattach virtio to rhel{5,6} guests will cause qemu-kvm crash
== libvirt ==
https://bugzilla.redhat.com/show_bug.cgi?id=547045
libvirt can generate bogus node device XML
libvirt has a function for escaping XML strings that we clearly forgot to
use here. In addition though we probably need to check where this garbage
is coming from, because in this particular case we probably shouldn't be
including the element at all.
14 years, 2 months
wiki or comparable documentation for dom0 kernel under FC12
by Martin Bach
Dear list members,
I was wondering if anyone has documented the necessary steps to end up
with a dom0 kernel under FC12 and ideally X11. I am not afraid of
building xen/libvirt/kernel from source (did so with ubuntu and gentoo
patches) but somehow I must be missing a step somewhere.
Thanks for any input!
Martin
14 years, 2 months
uniquely identifying drives in virt configurations
by Bill McGonigle
Hi, all,
I'm wondering what folks are doing for uniquely identifying plain disks
in their virtual machine configs.
For instance, I'm trying out the new Xen version and stuck a couple SATA
drives in a box. I'd like to use them as physical devices, but not
break my vm config if I re-cable the drives (or move them to another
machine).
I could create a degraded RAID mirror, and then reference them by mdX
and let md worry about the UUID's, but that's ugly. If I were using
luks on the drives they'd get tagged and could be referenced uniquely.
Same with iscsi, those are available uniquely under /sys.
Maybe something with device mapper? But I'm actually interested in
benchmarking ZFS through Xen with this, so I'd hate to add another layer
just for this purpose, since it's only needed at setup time. I could
script some ugly hacks but I'd rather not.
I was hoping to find a /sys/block/scsi/model/serialnumber type of thing
symlinked back to the ../../devices/pci... , but I didn't. So, I hope
I'm missing something obvious and folks here have this solved.
Thanks,
-Bill
--
Bill McGonigle, Owner
BFC Computing, LLC
http://bfccomputing.com/
Telephone: +1.603.448.4440
Email, IM, VOIP: bill(a)bfccomputing.com
VCard: http://bfccomputing.com/vcard/bill.vcf
Social networks: bill_mcgonigle/bill.mcgonigle
14 years, 2 months