pci,net,pc enhancements
From: Michael S. Tsirkin <[email protected]>
The following changes since commit 7588e2b0559ae72d3c2952c7807fc05c03099970:
pci: Fold host_buses list into PCIHostState functionality (2013-07-07 23:10:57 +0300)
are available in the git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_anthony
for you to fetch changes up to d26d9e14c15837eba2b7447e8d15230bab8e0940:
pc: don't access fw cfg if NULL (2013-07-15 21:26:32 +0300)
----------------------------------------------------------------
pci,net,pc enhancements
This includes some fixes and enhancements that accumulated in my tree:
pci fixes by dkoch, virtio-net enhancements by akong and mst, and a fix for xen pc by mst.
----------------------------------------------------------------
Amos Kong (1):
net: add support of mac-programming over macvtap in QEMU side
Don Koch (2):
pci-bridge: update mappings for migration/restore
pci: fix BRDIGE typo
Michael S. Tsirkin (2):
virtio-net: add feature bit for any header s/g
pc: don't access fw cfg if NULL
QMP/qmp-events.txt | 17 ++++++ hw/i386/pc.c | 2 +- hw/net/virtio-net.c | 133 +++++++++++++++++++++++++++++++++++++++-- hw/pci-bridge/i82801b11.c | 2 +- hw/pci/pci.c | 5 ++ hw/pci/pci_bridge.c | 2 +- include/hw/i386/pc.h | 4 ++ include/hw/pci/pci_bridge.h | 1 + include/hw/pci/pci_ids.h | 2 +- include/hw/virtio/virtio-net.h | 1 + include/hw/virtio/virtio.h | 2 + include/monitor/monitor.h | 1 + include/net/net.h | 3 + monitor.c | 1 + net/net.c | 48 +++++++++++++++ qapi-schema.json | 76 +++++++++++++++++++++++ qmp-commands.hx | 63 +++++++++++++++++++ 17 files changed, 353 insertions(+), 10 deletions(-)
[Qemu-devel] [PULL 1/5] pci-bridge: update mappings for migration/restore
From: Don Koch <[email protected]>
Fix for LP#1187529: Devices on PCI bridge stop working when live-migrated. Update bridge mappings for all PCI bridge devices in get_pci_config_device().
--- hw/pci/pci.c | 5 +++++ hw/pci/pci_bridge.c | 2 +- include/hw/pci/pci_bridge.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-)
hw/pci/pci.c +5 -0
@@ -378,6 +378,7 @@ int pci_bus_num(PCIBus *s)static int get_pci_config_device (QEMUFile *f,void *pv,size_t size) {PCIDevice *s =container_of (pv, PCIDevice, config); +PCIDeviceClass *pc =PCI_DEVICE_GET_CLASS (s);uint8_t *config;int i;
@@ -395,6 +396,10 @@ static int get_pci_config_device(QEMUFile *f, void *pv, size_t size)memcpy (s->config, config, size);pci_update_mappings (s); +if (pc->is_bridge) { +PCIBridge *b =container_of (s, PCIBridge, dev); +pci_bridge_update_mappings (b); + }memory_region_set_enabled (&s->bus_master_enable_region, pci_get_word(s->config + PCI_COMMAND)
hw/pci/pci_bridge.c +1 -1
@@ -224,7 +224,7 @@ static void pci_bridge_region_cleanup(PCIBridge *br, PCIBridgeWindows *w)g_free (w); } -static void pci_bridge_update_mappings (PCIBridge *br) +void pci_bridge_update_mappings (PCIBridge *br) {PCIBridgeWindows *w = br->windows;
include/hw/pci/pci_bridge.h +1 -0
@@ -37,6 +37,7 @@ PCIBus *pci_bridge_get_sec_bus(PCIBridge *br);pcibus_t pci_bridge_get_base (const PCIDevice *bridge,uint8_t type);pcibus_t pci_bridge_get_limit (const PCIDevice *bridge,uint8_t type); +void pci_bridge_update_mappings (PCIBridge *br);void pci_bridge_write_config (PCIDevice *d,uint32_t address,uint32_t val,int len);void pci_bridge_disable_base_limit (PCIDevice *dev);
Signature · 1 line
MST
[Qemu-devel] [PULL 2/5] pci: fix BRDIGE typo
In reply to Michael S. TsirkinFrom: Don Koch <[email protected]>
Fix typo in macro name: PCI_CLASS_BRDIGE_PCI_INF_SUB.
--- hw/pci-bridge/i82801b11.c | 2 +- include/hw/pci/pci_ids.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
hw/pci-bridge/i82801b11.c +1 -1
@@ -69,7 +69,7 @@ static int i82801b11_bridge_initfn(PCIDevice *d)if (rc <0 ) { goto err_bridge; } -pci_config_set_prog_interface (d->config,PCI_CLASS_BRDIGE_PCI_INF_SUB ); +pci_config_set_prog_interface (d->config,PCI_CLASS_BRIDGE_PCI_INF_SUB );return 0 ; err_bridge:
include/hw/pci/pci_ids.h +1 -1
@@ -39,7 +39,7 @@#define PCI_CLASS_BRIDGE_HOST 0x0600#define PCI_CLASS_BRIDGE_ISA 0x0601#define PCI_CLASS_BRIDGE_PCI 0x0604 -#define PCI_CLASS_BRDIGE_PCI_INF_SUB 0x01 +#define PCI_CLASS_BRIDGE_PCI_INF_SUB 0x01#define PCI_CLASS_BRIDGE_OTHER 0x0680#define PCI_CLASS_COMMUNICATION_SERIAL 0x0700
Signature · 1 line
MST
[Qemu-devel] [PULL 4/5] virtio-net: add feature bit for any header s/g
In reply to Michael S. TsirkinOld qemu versions required that 1st s/g entry is the header.
Since QEMU 1.5, patchset titled "virtio-net: iovec handling cleanup" removed this limitation but a feature bit is needed so guests know it's safe to lay out header differently.
This patch applies on top and adds such a feature bit to QEMU. It is set by default for virtio-net.
virtio net header inline with the data is beneficial for latency and small packet bandwidth - guest driver code utilizing this feature has been acked but missed 3.11 by a narrow margin, it's pending for 3.12.
This feature bit is cleared by default when compatibility with old machine types is requested.
Other performance-sensitive devices (blk and scsi) don't yet support arbitrary s/g layouts, so we only set this bit for virtio-net for now. There are plans to allow arbitrary layouts there, but no code has been posted yet.
--- include/hw/i386/pc.h | 4 ++++ include/hw/virtio/virtio-net.h | 1 + include/hw/virtio/virtio.h | 2 ++ 3 files changed, 7 insertions(+)
include/hw/i386/pc.h +4 -0
@@ -229,6 +229,10 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t); .driver = "Nehalem-" TYPE_X86_CPU,\ .property = "level",\ .value = stringify(2),\ + },{\ + .driver = "virtio-net-pci",\ + .property = "any_layout",\ + .value = "off",\ }#define PC_COMPAT_1_4 \
include/hw/virtio/virtio-net.h +1 -0
@@ -243,6 +243,7 @@ struct virtio_net_ctrl_mq {#define DEFINE_VIRTIO_NET_FEATURES (_state, _field) \ DEFINE_VIRTIO_COMMON_FEATURES(_state, _field), \ + DEFINE_PROP_BIT("any_layout", _state, _field, VIRTIO_F_ANY_LAYOUT, true), \ 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), \
include/hw/virtio/virtio.h +2 -0
@@ -43,6 +43,8 @@/* We notify when the ring is completely used, even if the guest is suppressing * callbacks */ #define VIRTIO_F_NOTIFY_ON_EMPTY 24 +/* Can the device handle any descriptor layout? */ +#define VIRTIO_F_ANY_LAYOUT 27/* We support indirect buffer descriptors */ #define VIRTIO_RING_F_INDIRECT_DESC 28/* The Guest publishes the used index for which it expects an interrupt
Signature · 1 line
MST
[Qemu-devel] [PULL 3/5] net: add support of mac-programming over macvtap in QEMU side
In reply to Michael S. TsirkinFrom: Amos Kong <[email protected]>
Currently macvtap based macvlan device is working in promiscuous mode, we want to implement mac-programming over macvtap through Libvirt for better performance.
Design:
QEMU notifies Libvirt when rx-filter config is changed in guest, then Libvirt query the rx-filter information by a monitor command, and sync the change to macvtap device. Related rx-filter config of the nic contains main mac, rx-mode items and vlan table.
This patch adds a QMP event to notify management of rx-filter change, and adds a monitor command for management to query rx-filter information.
Test:
If we repeatedly add/remove vlan, and change macaddr of vlan interfaces in guest by a loop script.
Result:
The events will flood the QMP client(management), management takes too much resource to process the events.
Event_throttle API (set rate to 1 ms) can avoid the events to flood QMP client, but it could cause an unexpected delay (~1ms), guests guests normally expect rx-filter updates immediately.
So we use a flag for each nic to avoid events flooding, the event is emitted once until the query command is executed. The flag implementation could not introduce unexpected delay.
There maybe exist an uncontrollable delay if we let Libvirt do the real change, guests normally expect rx-filter updates immediately. But it's another separate issue, we can investigate it when the work in Libvirt side is done.
Michael S. Tsirkin: tweaked to enable events on start Michael S. Tsirkin: fixed not to crash when no id
Michael S. Tsirkin: fold in patch:
"additional fixes for mac-programming feature"
Amos Kong: always notify QMP client if mactable is changed Amos Kong: return NULL list if no net client supports rx-filter query
--- QMP/qmp-events.txt | 17 ++++++ hw/net/virtio-net.c | 133 +++++++++++++++++++++++++++++++++++++++++++--- include/monitor/monitor.h | 1 + include/net/net.h | 3 ++ monitor.c | 1 + net/net.c | 48 +++++++++++++++++ qapi-schema.json | 76 ++++++++++++++++++++++++++ qmp-commands.hx | 63 ++++++++++++++++++++++ 8 files changed, 336 insertions(+), 6 deletions(-)
QMP/qmp-events.txt +17 -0
@@ -172,6 +172,23 @@ Data: }, "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } +NIC_RX_FILTER_CHANGED +----------------- + +The event is emitted once until the query command is executed, +the first event will always be emitted. + +Data: + +- "name": net client name (json-string) +- "path": device path (json-string) + +{ "event": "NIC_RX_FILTER_CHANGED", + "data": { "name": "vnet0", + "path": "/machine/peripheral/vnet0/virtio-backend" }, + "timestamp": { "seconds": 1368697518, "microseconds": 326866 } } +} + RESET -----
hw/net/virtio-net.c +127 -6
239 lines not on this page · raw message
include/monitor/monitor.h +1 -0
@@ -41,6 +41,7 @@ typedef enum MonitorEvent {QEVENT_BLOCK_JOB_READY ,QEVENT_DEVICE_DELETED ,QEVENT_DEVICE_TRAY_MOVED , +QEVENT_NIC_RX_FILTER_CHANGED ,QEVENT_SUSPEND ,QEVENT_SUSPEND_DISK , QEVENT_WAKEUP,
include/net/net.h +3 -0
@@ -49,6 +49,7 @@ typedef ssize_t (NetReceiveIOV)(NetClientState *, const struct iovec *, int);typedef void (NetCleanup ) (NetClientState *);typedef void (LinkStatusChanged )(NetClientState *);typedef void (NetClientDestructor )(NetClientState *); +typedef RxFilterInfo *(QueryRxFilter )(NetClientState *); typedef struct NetClientInfo { NetClientOptionsKind type;
@@ -59,6 +60,7 @@ typedef struct NetClientInfo {NetCanReceive *can_receive;NetCleanup *cleanup;LinkStatusChanged *link_status_changed; +QueryRxFilter *query_rx_filter;NetPoll *poll; } NetClientInfo;
@@ -74,6 +76,7 @@ struct NetClientState { unsigned receive_disabled : 1;NetClientDestructor *destructor;unsigned int queue_index; + unsigned rxfilter_notify_enabled:1; }; typedef struct NICState {
monitor.c +1 -0
@@ -490,6 +490,7 @@ static const char *monitor_event_names[] = { [QEVENT_BLOCK_JOB_READY] = "BLOCK_JOB_READY", [QEVENT_DEVICE_DELETED] = "DEVICE_DELETED", [QEVENT_DEVICE_TRAY_MOVED] = "DEVICE_TRAY_MOVED", + [QEVENT_NIC_RX_FILTER_CHANGED] = "NIC_RX_FILTER_CHANGED", [QEVENT_SUSPEND] = "SUSPEND", [QEVENT_SUSPEND_DISK] = "SUSPEND_DISK", [QEVENT_WAKEUP] = "WAKEUP",
net/net.c +48 -0
54 lines not on this page · raw message
qapi-schema.json +76 -0
79 lines not on this page · raw message
qmp-commands.hx +63 -0
66 lines not on this page · raw message
Signature · 1 line
MST
[Qemu-devel] [PULL 5/5] pc: don't access fw cfg if NULL
In reply to Michael S. Tsirkincommit f8c457b88d72a48989f190bc3d7b79f4f3b7d11c
"pc: pass PCI hole ranges to Guests"
broke Xen as it has no fw_cfg.
Check for this configuration and boil out.
--- hw/i386/pc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/pc.c +1 -1
@@ -1000,7 +1000,7 @@ typedef struct PcRomPciInfo {static void pc_fw_cfg_guest_info (PcGuestInfo *guest_info) {PcRomPciInfo *info; -if (!guest_info->has_pci_info) { +if (!guest_info->has_pci_info || !guest_info->fw_cfg) {return ; }
Signature · 1 line
MST