virtio, vhost: fixes for 2.5
The following changes since commit fd717e789010012c5f0537269df19ef19d469baf:
Merge remote-tracking branch 'remotes/mdroth/tags/qga-pull-2015-11-11-tag' into staging (2015-11-12 13:11:06 +0000)
are available in the git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.git tags/for_upstream
for you to fetch changes up to 4652f1640e029e1f2433fa77ba6af285c7cd923a:
virtio-9p: add savem handlers (2015-11-12 16:40:14 +0200)
----------------------------------------------------------------
virtio, vhost: fixes for 2.5
This fixes a performance regression with virtio 1, and makes device stop/start more robust for vhost-user. virtio devices on pcie bus now have pcie and pm capability, as required by the PCI Express spec. migration now works better with virtio 9p.
----------------------------------------------------------------
Greg Kurz (1):
virtio-9p: add savem handlers
Jason Wang (6):
virtio-pci: fix 1.0 virtqueue migration
memory: don't try to adjust endianness for zero length eventfd
KVM: add support for any length io eventfd
virtio-pci: use zero length mmio eventfd for 1.0 notification cap when possible
virtio-pci: introduce pio notification capability for modern device
virtio-pci: unbreak queue_enable read
Marcel Apfelbaum (1):
hw/virtio: Add PCIe capability to virtio devices
Victor Kaplansky (1):
vhost-user: modify SET_LOG_BASE to pass mmap size and offset
Yuanhan Liu (2):
vhost: rename RESET_DEVICE backto RESET_OWNER
vhost: send SET_VRING_ENABLE at start/stop
hw/virtio/virtio-pci.h | 30 ++++- include/hw/compat.h | 8 ++ include/hw/virtio/virtio-bus.h | 3 + include/sysemu/kvm.h | 8 ++ linux-headers/linux/vhost.h | 2 +- hw/9pfs/virtio-9p-device.c | 11 ++ hw/virtio/vhost-backend.c | 2 +- hw/virtio/vhost-user.c | 17 ++- hw/virtio/vhost.c | 9 ++ hw/virtio/virtio-pci.c | 299 ++++++++++++++++++++++++++++++++++++++--- hw/virtio/virtio.c | 58 ++++++++ kvm-all.c | 4 + kvm-stub.c | 1 + memory.c | 8 +- tests/vhost-user-bridge.c | 6 +- tests/vhost-user-test.c | 12 +- docs/specs/vhost-user.txt | 12 +- 17 files changed, 445 insertions(+), 45 deletions(-)
[PULL 03/11] KVM: add support for any length io eventfd
From: Jason Wang <[email protected]>
--- include/sysemu/kvm.h | 8 ++++++++ kvm-all.c | 4 ++++ kvm-stub.c | 1 + 3 files changed, 13 insertions(+)
include/sysemu/kvm.h +8 -0
@@ -53,6 +53,7 @@ extern bool kvm_gsi_routing_allowed;extern bool kvm_gsi_direct_mapping;extern bool kvm_readonly_mem_allowed;extern bool kvm_direct_msi_allowed; +extern bool kvm_ioeventfd_any_length_allowed;#if definedCONFIG_KVM || !definedNEED_CPU_H #define kvm_enabled () (kvm_allowed)
@@ -153,6 +154,12 @@ extern bool kvm_direct_msi_allowed;*/ #define kvm_direct_msi_enabled () (kvm_direct_msi_allowed) +/** +* kvm_ioeventfd_any_length_enabled: +* Returns: true if KVM allows any length io eventfd. +*/ +#define kvm_ioeventfd_any_length_enabled () (kvm_ioeventfd_any_length_allowed) +#else #define kvm_enabled () (0)#define kvm_irqchip_in_kernel () (false)
@@ -166,6 +173,7 @@ extern bool kvm_direct_msi_allowed;#define kvm_gsi_direct_mapping () (false)#define kvm_readonly_mem_enabled () (false)#define kvm_direct_msi_enabled () (false) +#define kvm_ioeventfd_any_length_enabled () (false)#endif struct kvm_run ;
kvm-all.c +4 -0
@@ -109,6 +109,7 @@ bool kvm_allowed;bool kvm_readonly_mem_allowed;bool kvm_vm_attributes_allowed;bool kvm_direct_msi_allowed; +bool kvm_ioeventfd_any_length_allowed;static const KVMCapabilityInfo kvm_required_capabilites[] = {KVM_CAP_INFO (USER_MEMORY ),
@@ -1611,6 +1612,9 @@ static int kvm_init(MachineState *ms) kvm_vm_attributes_allowed = (kvm_check_extension (s,KVM_CAP_VM_ATTRIBUTES ) >0 ); + kvm_ioeventfd_any_length_allowed = + (kvm_check_extension (s,KVM_CAP_IOEVENTFD_ANY_LENGTH ) >0 ); + ret =kvm_arch_init (ms, s);if (ret <0 ) { goto err;
kvm-stub.c +1 -0
@@ -30,6 +30,7 @@ bool kvm_gsi_routing_allowed;bool kvm_gsi_direct_mapping;bool kvm_allowed;bool kvm_readonly_mem_allowed; +bool kvm_ioeventfd_any_length_allowed;int kvm_init_vcpu (CPUState *cpu) {
Signature · 1 line
MST
[Qemu-devel] [PULL 01/11] virtio-pci: fix 1.0 virtqueue migration
In reply to Michael S. TsirkinFrom: Jason Wang <[email protected]>
We don't migrate the followings fields for virtio-pci:
uint32_t dfselect;uint32_t gfselect;uint32_t guest_features[2];
struct {
uint16_t num;
bool enabled;
uint32_t desc[2];
uint32_t avail[2];
uint32_t used[2];
} vqs[VIRTIO_QUEUE_MAX];This will confuse driver if migrating during initialization. Solves this issue by:
- introduce transport specific callbacks to load and store extra virtqueue states.
- add a new subsection for virtio to migrate transport specific modern device state.
- implement pci specific callbacks.
- add a new property for virtio-pci for whether or not to migrate extra state.
- compat the migration for 2.4 and elder machine types
--- hw/virtio/virtio-pci.h | 20 ++++--- include/hw/compat.h | 4 ++ include/hw/virtio/virtio-bus.h | 3 + hw/virtio/virtio-pci.c | 129 +++++++++++++++++++++++++++++++++++++++++ hw/virtio/virtio.c | 58 ++++++++++++++++++ 5 files changed, 207 insertions(+), 7 deletions(-)
hw/virtio/virtio-pci.h +13 -7
@@ -75,6 +75,10 @@ typedef struct VirtioBusClass VirtioPCIBusClass;#define VIRTIO_PCI_FLAG_DISABLE_LEGACY (1 << VIRTIO_PCI_FLAG_DISABLE_LEGACY_BIT)#define VIRTIO_PCI_FLAG_DISABLE_MODERN (1 << VIRTIO_PCI_FLAG_DISABLE_MODERN_BIT) +/* migrate extra state */ +#define VIRTIO_PCI_FLAG_MIGRATE_EXTRA_BIT 4 +#define VIRTIO_PCI_FLAG_MIGRATE_EXTRA (1 << VIRTIO_PCI_FLAG_MIGRATE_EXTRA_BIT) + typedef struct { MSIMessage msg; int virq;
@@ -104,6 +108,14 @@ typedef struct VirtIOPCIRegion {uint32_t type; } VirtIOPCIRegion; +typedef struct VirtIOPCIQueue { +uint16_t num; +bool enabled; +uint32_t desc[2 ]; +uint32_t avail[2 ]; +uint32_t used[2 ]; +}VirtIOPCIQueue ; +struct VirtIOPCIProxy {PCIDevice pci_dev;MemoryRegion bar;
@@ -124,13 +136,7 @@ struct VirtIOPCIProxy {uint32_t dfselect;uint32_t gfselect;uint32_t guest_features[2 ]; -struct { -uint16_t num; -bool enabled; -uint32_t desc[2 ]; -uint32_t avail[2 ]; -uint32_t used[2 ]; - } vqs[VIRTIO_QUEUE_MAX ]; +VirtIOPCIQueue vqs[VIRTIO_QUEUE_MAX ];bool ioeventfd_disabled;bool ioeventfd_started;
include/hw/compat.h +4 -0
@@ -6,6 +6,10 @@ .driver = "virtio-blk-device",\ .property = "scsi",\ .value = "true",\ + },{\ + .driver = "virtio-pci",\ + .property = "migrate-extra",\ + .value = "off",\ },#define HW_COMPAT_2_3 \
include/hw/virtio/virtio-bus.h +3 -0
@@ -44,9 +44,12 @@ typedef struct VirtioBusClass {void (*notify)(DeviceState *d,uint16_t vector);void (*save_config)(DeviceState *d,QEMUFile *f);void (*save_queue)(DeviceState *d,int n,QEMUFile *f); +void (*save_extra_state)(DeviceState *d,QEMUFile *f);int (*load_config)(DeviceState *d,QEMUFile *f);int (*load_queue)(DeviceState *d,int n,QEMUFile *f);int (*load_done)(DeviceState *d,QEMUFile *f); +int (*load_extra_state)(DeviceState *d,QEMUFile *f); +bool (*has_extra_state)(DeviceState *d);bool (*query_guest_notifiers)(DeviceState *d);int (*set_guest_notifiers)(DeviceState *d,int nvqs,bool assign);int (*set_host_notifier)(DeviceState *d,int n,bool assigned);
hw/virtio/virtio-pci.c +129 -0
153 lines not on this page · raw message
hw/virtio/virtio.c +58 -0
76 lines not on this page · raw message
Signature · 1 line
MST
[Qemu-devel] [PULL 02/11] memory: don't try to adjust endianness for zero length eventfd
In reply to Michael S. TsirkinFrom: Jason Wang <[email protected]>
There's no need to adjust endianness for zero length eventfd since the data wrote was actually ignored by kernel. So skip the adjust in this case to fix a possible crash when trying to use wildcard mmio eventfd in ppc.
--- memory.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
memory.c +6 -2
@@ -1688,7 +1688,9 @@ void memory_region_add_eventfd(MemoryRegion *mr, };unsigned i; -adjust_endianness (mr, &mrfd.data, size); +if (size) { +adjust_endianness (mr, &mrfd.data, size); + }memory_region_transaction_begin ();for (i =0 ; i < mr->ioeventfd_nb; ++i) {if (memory_region_ioeventfd_before (mrfd, mr->ioeventfds[i])) {
@@ -1721,7 +1723,9 @@ void memory_region_del_eventfd(MemoryRegion *mr, };unsigned i; -adjust_endianness (mr, &mrfd.data, size); +if (size) { +adjust_endianness (mr, &mrfd.data, size); + }memory_region_transaction_begin ();for (i =0 ; i < mr->ioeventfd_nb; ++i) {if (memory_region_ioeventfd_equal (mrfd, mr->ioeventfds[i])) {
Signature · 1 line
MST
[Qemu-devel] [PULL 04/11] virtio-pci: use zero length mmio eventfd for 1.0 notification cap when possible
In reply to Michael S. TsirkinFrom: Jason Wang <[email protected]>
We use data match eventfd for 1.0 notification currently. This could be slow since software decoding is needed for mmio exit. To speed this up, we can switch to use zero length mmio eventfd for 1.0 notification since we can examine the queue index directly from the writing address. KVM kernel module can utilize this by registering it to fast mmio bus which could be as fast as pio on ept capable machine when fast mmio is supported by host kernel.
Lots of improvements were seen on a ept capable machine:
Guest RX:(TCP)
size/session/+throughput%/+cpu%/-+per cpu%/
64/1/+1.6807%/[-16.2421%]/[+21.3984%]/
64/2/+0.6091%/[-11.0187%]/[+13.0678%]/
64/4/+0.0553%/[-5.9768%]/[+6.4155%]/
64/8/+0.1206%/[-4.0057%]/[+4.2984%]/
256/1/-0.0031%/[-10.1166%]/[+11.2517%]/
256/2/-0.5058%/[-6.1656%]/+6.0317%]/
...
Guest TX:(TCP)
size/session/+throughput%/+cpu%/-+per cpu%/
64/1/[+18.9183%]/-0.2823%/[+19.2550%]/
64/2/[+13.5714%]/[+2.2675%]/[+11.0533%]/
64/4/[+13.1070%]/[+2.1817%]/[+10.6920%]/
64/8/[+13.0426%]/[+2.0887%]/[+10.7299%]/
256/1/[+36.2761%]/+6.3434%/[+28.1471%]/
...
1024/1/[+44.8873%]/+2.0811%/[+41.9335%]/
...
1024/4/+0.0228%/[-2.2044%]/[+2.2774%]/
...
16384/2/+0.0127%/[-5.0346%]/[+5.3148%]/
...
65535/1/[+0.0062%]/[-4.1183%]/[+4.3017%]/
65535/2/+0.0004%/[-4.2311%]/[+4.4185%]/
65535/4/+0.0107%/[-4.6106%]/[+4.8446%]/
65535/8/-0.0090%/[-5.5178%]/[+5.8306%]/
Latency:(TCP_RR)
size/session/+transaction rate%/+cpu%/-+per cpu%/
64/1/[+6.5248%]/[-9.2882%]/[+17.4322%]/
64/25/[+11.0854%]/[+0.8000%]/[+10.2038%]/
64/50/[+12.1076%]/[+2.4627%]/[+9.4131%]/
256/1/[+5.3677%]/[+10.5669%]/-4.7024%/
256/25/[+5.6402%]/-0.8962%/[+6.5955%]/
256/50/[+5.9685%]/[+1.7766%]/[+4.1188%]/
4096/1/+0.2508%/[-10.4941%]/[+12.0047%]/
4096/25/[+1.8533%]/-0.0273%/+1.8812%/
4096/50/[+1.2156%]/-1.4134%/+2.6667%/
Notes: data with '[]' is the one whose significance is greater than 95%.
Thanks Wenli Quan <[email protected]> for the benchmarking.
--- hw/virtio/virtio-pci.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
hw/virtio/virtio-pci.c +15 -4
@@ -270,6 +270,7 @@ static int virtio_pci_set_host_notifier_internal(VirtIOPCIProxy *proxy,EventNotifier *notifier =virtio_queue_get_host_notifier (vq);bool legacy = !(proxy->flags &VIRTIO_PCI_FLAG_DISABLE_LEGACY );bool modern = !(proxy->flags &VIRTIO_PCI_FLAG_DISABLE_MODERN ); +bool fast_mmio =kvm_ioeventfd_any_length_enabled ();MemoryRegion *modern_mr = &proxy->notify.mr;MemoryRegion *legacy_mr = &proxy->bar; hwaddr modern_addr = QEMU_VIRTIO_PCI_QUEUE_MEM_MULT *
@@ -286,8 +287,13 @@ static int virtio_pci_set_host_notifier_internal(VirtIOPCIProxy *proxy, }virtio_queue_set_host_notifier_fd_handler (vq, true, set_handler);if (modern) { -memory_region_add_eventfd (modern_mr, modern_addr,2 , - true, n, notifier); +if (fast_mmio) { +memory_region_add_eventfd (modern_mr, modern_addr,0 , + false, n, notifier); + }else { +memory_region_add_eventfd (modern_mr, modern_addr,2 , + false, n, notifier); + } }if (legacy) { memory_region_add_eventfd(legacy_mr, legacy_addr, 2,
@@ -295,8 +301,13 @@ static int virtio_pci_set_host_notifier_internal(VirtIOPCIProxy *proxy, } }else {if (modern) { -memory_region_del_eventfd (modern_mr, modern_addr,2 , - true, n, notifier); +if (fast_mmio) { +memory_region_del_eventfd (modern_mr, modern_addr,0 , + false, n, notifier); + }else { +memory_region_del_eventfd (modern_mr, modern_addr,2 , + false, n, notifier); + } }if (legacy) { memory_region_del_eventfd(legacy_mr, legacy_addr, 2,
Signature · 1 line
MST
[Qemu-devel] [PULL 05/11] virtio-pci: introduce pio notification capability for modern device
In reply to Michael S. TsirkinFrom: Jason Wang <[email protected]>
We used to use mmio for notification. This could be slow on some arch (e.g on x86 without EPT). So this patch introduces pio bar and a pio notification cap for modern device. This ability is enabled through property "modern-pio-notify" for virtio pci devices and was disabled by default. Management can enable when it thinks it was needed.
Benchmarks shows almost no obvious difference compared to legacy device on machines without ept. Thanks Wenli Quan <[email protected]> for the benchmarking.
--- hw/virtio/virtio-pci.h | 8 ++++ hw/virtio/virtio-pci.c | 122 ++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 113 insertions(+), 17 deletions(-)
hw/virtio/virtio-pci.h +8 -0
@@ -79,6 +79,11 @@ typedef struct VirtioBusClass VirtioPCIBusClass;#define VIRTIO_PCI_FLAG_MIGRATE_EXTRA_BIT 4#define VIRTIO_PCI_FLAG_MIGRATE_EXTRA (1 << VIRTIO_PCI_FLAG_MIGRATE_EXTRA_BIT) +/* have pio notification for modern device ? */ +#define VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY_BIT 5 +#define VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY \ + (1 << VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY_BIT) + typedef struct { MSIMessage msg; int virq;
@@ -123,11 +128,14 @@ struct VirtIOPCIProxy {VirtIOPCIRegion isr;VirtIOPCIRegion device;VirtIOPCIRegion notify; +VirtIOPCIRegion notify_pio;MemoryRegion modern_bar; +MemoryRegion io_bar;MemoryRegion modern_cfg;AddressSpace modern_as;uint32_t legacy_io_bar;uint32_t msix_bar; +uint32_t modern_io_bar;uint32_t modern_mem_bar;int config_cap;uint32_t flags;
hw/virtio/virtio-pci.c +105 -17
220 lines not on this page · raw message
Signature · 1 line
MST
[Qemu-devel] [PULL 06/11] virtio-pci: unbreak queue_enable read
In reply to Michael S. TsirkinFrom: Jason Wang <[email protected]>
Guest always get zero when reading queue_enable. This violates spec. Fixing this by setting the queue_enable to true during any guest writing and setting it to zero during reset.
--- hw/virtio/virtio-pci.c | 7 +++++++ 1 file changed, 7 insertions(+)
hw/virtio/virtio-pci.c +7 -0
@@ -1384,6 +1384,7 @@ static void virtio_pci_common_write(void *opaque, hwaddr addr, proxy->vqs[vdev->queue_sel].avail[0 ], ((uint64_t )proxy->vqs[vdev->queue_sel].used[1 ]) <<32 | proxy->vqs[vdev->queue_sel].used[0]); + proxy->vqs[vdev->queue_sel].enabled =1 ;break ;case VIRTIO_PCI_COMMON_Q_DESCLO : proxy->vqs[vdev->queue_sel].desc[0 ] = val;
@@ -1831,9 +1832,15 @@ static void virtio_pci_reset(DeviceState *qdev) {VirtIOPCIProxy *proxy =VIRTIO_PCI (qdev);VirtioBusState *bus =VIRTIO_BUS (&proxy->bus); +int i; +virtio_pci_stop_ioeventfd (proxy);virtio_bus_reset (bus);msix_unuse_all_vectors (&proxy->pci_dev); + +for (i =0 ; i <VIRTIO_QUEUE_MAX ; i++) { + proxy->vqs[i].enabled =0 ; + } }static Property virtio_pci_properties[] = {
Signature · 1 line
MST
[Qemu-devel] [PULL 09/11] vhost: send SET_VRING_ENABLE at start/stop
In reply to Michael S. TsirkinFrom: Yuanhan Liu <[email protected]>
Send SET_VRING_ENABLE at start/stop, to give the backend an explicit sign of our state.
--- hw/virtio/vhost.c | 9 +++++++++ 1 file changed, 9 insertions(+)
hw/virtio/vhost.c +9 -0
@@ -1226,6 +1226,11 @@ int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev) } } +if (hdev->vhost_ops->vhost_set_vring_enable) { +/* only enable first vq pair by default */ + hdev->vhost_ops->vhost_set_vring_enable (hdev, hdev->vq_index ==0 ); + } +return 0 ; fail_log:vhost_log_put (hdev, false);
@@ -1256,6 +1261,10 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev) hdev->vq_index + i); } +if (hdev->vhost_ops->vhost_set_vring_enable) { + hdev->vhost_ops->vhost_set_vring_enable (hdev,0 ); + } +vhost_log_put (hdev, true); hdev->started = false; hdev->log =NULL ;
Signature · 1 line
MST
[Qemu-devel] [PULL 07/11] vhost-user: modify SET_LOG_BASE to pass mmap size and offset
In reply to Michael S. TsirkinFrom: Victor Kaplansky <[email protected]>
Unlike the kernel, vhost-user application accesses log table by mmaping it to its user space. This change adds two new fields to VhostUserMsg payload: mmap_size, and mmap_offset and make QEMU to pass the to vhost-user application in VHOST_USER_SET_LOG_BASE request.
--- hw/virtio/vhost-user.c | 11 +++++++++-- tests/vhost-user-test.c | 8 ++++++++ docs/specs/vhost-user.txt | 8 +++++++- 3 files changed, 24 insertions(+), 3 deletions(-)
hw/virtio/vhost-user.c +9 -2
@@ -75,6 +75,11 @@ typedef struct VhostUserMemory {VhostUserMemoryRegion regions[VHOST_MEMORY_MAX_NREGIONS ]; } VhostUserMemory; +typedef struct VhostUserLog { +uint64_t mmap_size; +uint64_t mmap_offset; +}VhostUserLog ; + typedef struct VhostUserMsg { VhostUserRequest request;
@@ -89,6 +94,7 @@ typedef struct VhostUserMsg {struct vhost_vring_state state;struct vhost_vring_addr addr;VhostUserMemory memory; +VhostUserLog log; } payload; }QEMU_PACKED VhostUserMsg;
@@ -200,8 +206,9 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base,VhostUserMsg msg = { .request =VHOST_USER_SET_LOG_BASE , .flags =VHOST_USER_VERSION , - .payload.u64 = base, - .size =sizeof (msg.payload.u64), + .payload.log.mmap_size = log->size, + .payload.log.mmap_offset =0 , + .size =sizeof (msg.payload.log), };if (shmfd && log->fd !=-1 ) {
tests/vhost-user-test.c +8 -0
@@ -86,6 +86,11 @@ typedef struct VhostUserMemory {VhostUserMemoryRegion regions[VHOST_MEMORY_MAX_NREGIONS ]; } VhostUserMemory; +typedef struct VhostUserLog { +uint64_t mmap_size; +uint64_t mmap_offset; +}VhostUserLog ; + typedef struct VhostUserMsg { VhostUserRequest request;
@@ -94,10 +99,13 @@ typedef struct VhostUserMsg {uint32_t flags;uint32_t size;/* the following payload size */ union { +#define VHOST_USER_VRING_IDX_MASK (0xff) +#define VHOST_USER_VRING_NOFD_MASK (0x1<<8)uint64_t u64;struct vhost_vring_state state;struct vhost_vring_addr addr;VhostUserMemory memory; +VhostUserLog log; } payload; }QEMU_PACKED VhostUserMsg;
docs/specs/vhost-user.txt +7 -1
@@ -98,6 +98,7 @@ typedef struct VhostUserMsg { struct vhost_vring_state state; struct vhost_vring_addr addr; VhostUserMemory memory; + VhostUserLog log; }; } QEMU_PACKED VhostUserMsg;
@@ -282,7 +283,12 @@ Message types Master payload: u64 Slave payload: N/A - Sets the logging base address. + Sets logging shared memory space. + When slave has VHOST_USER_PROTOCOL_F_LOG_SHMFD protocol + feature, the log memory fd is provided in the ancillary data of + VHOST_USER_SET_LOG_BASE message, the size and offset of shared + memory area provided in the message. + * VHOST_USER_SET_LOG_FD
Signature · 1 line
MST
[Qemu-devel] [PULL 08/11] vhost: rename RESET_DEVICE backto RESET_OWNER
In reply to Michael S. TsirkinFrom: Yuanhan Liu <[email protected]>
This patch basically reverts commit d1f8b30e.
It turned out that it breaks stuff, so revert it:
http://lists.nongnu.org/archive/html/qemu-devel/2015-10/msg00949.html
--- linux-headers/linux/vhost.h | 2 +- hw/virtio/vhost-backend.c | 2 +- hw/virtio/vhost-user.c | 6 +++--- tests/vhost-user-bridge.c | 6 +++--- tests/vhost-user-test.c | 4 ++-- docs/specs/vhost-user.txt | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-)
linux-headers/linux/vhost.h +1 -1
@@ -78,7 +78,7 @@ struct vhost_memory {#define VHOST_SET_OWNER _IO(VHOST_VIRTIO, 0x01)/* Give up ownership, and reset the device to default values. * Allows subsequent call to VHOST_OWNER_SET to succeed. */ -#define VHOST_RESET_DEVICE _IO(VHOST_VIRTIO, 0x02) +#define VHOST_RESET_OWNER _IO(VHOST_VIRTIO, 0x02)/* Set up/modify memory layout */ #define VHOST_SET_MEM_TABLE _IOW(VHOST_VIRTIO, 0x03, struct vhost_memory)
hw/virtio/vhost-backend.c +1 -1
@@ -156,7 +156,7 @@ static int vhost_kernel_set_owner(struct vhost_dev *dev)static int vhost_kernel_reset_device (struct vhost_dev *dev) { -return vhost_kernel_call (dev,VHOST_RESET_DEVICE ,NULL ); +return vhost_kernel_call (dev,VHOST_RESET_OWNER ,NULL ); }static int vhost_kernel_get_vq_index (struct vhost_dev *dev,int idx)
hw/virtio/vhost-user.c +3 -3
@@ -43,7 +43,7 @@ typedef enum VhostUserRequest {VHOST_USER_GET_FEATURES =1 ,VHOST_USER_SET_FEATURES =2 ,VHOST_USER_SET_OWNER =3 , -VHOST_USER_RESET_DEVICE =4 , +VHOST_USER_RESET_OWNER =4 ,VHOST_USER_SET_MEM_TABLE =5 ,VHOST_USER_SET_LOG_BASE =6 , VHOST_USER_SET_LOG_FD = 7,
@@ -163,7 +163,7 @@ static bool vhost_user_one_time_request(VhostUserRequest request) {switch (request) {case VHOST_USER_SET_OWNER : -case VHOST_USER_RESET_DEVICE : +case VHOST_USER_RESET_OWNER :case VHOST_USER_SET_MEM_TABLE :case VHOST_USER_GET_QUEUE_NUM :return true;
@@ -493,7 +493,7 @@ static int vhost_user_set_owner(struct vhost_dev *dev)static int vhost_user_reset_device (struct vhost_dev *dev) {VhostUserMsg msg = { - .request =VHOST_USER_RESET_DEVICE , + .request =VHOST_USER_RESET_OWNER , .flags =VHOST_USER_VERSION , };
tests/vhost-user-bridge.c +3 -3
@@ -188,7 +188,7 @@ typedef enum VhostUserRequest {VHOST_USER_GET_FEATURES =1 ,VHOST_USER_SET_FEATURES =2 ,VHOST_USER_SET_OWNER =3 , -VHOST_USER_RESET_DEVICE =4 , +VHOST_USER_RESET_OWNER =4 ,VHOST_USER_SET_MEM_TABLE =5 ,VHOST_USER_SET_LOG_BASE =6 , VHOST_USER_SET_LOG_FD = 7,
@@ -274,7 +274,7 @@ static const char *vubr_request_str[] = { [VHOST_USER_GET_FEATURES] = "VHOST_USER_GET_FEATURES", [VHOST_USER_SET_FEATURES] = "VHOST_USER_SET_FEATURES", [VHOST_USER_SET_OWNER] = "VHOST_USER_SET_OWNER", - [VHOST_USER_RESET_DEVICE] = "VHOST_USER_RESET_DEVICE", + [VHOST_USER_RESET_OWNER] = "VHOST_USER_RESET_OWNER", [VHOST_USER_SET_MEM_TABLE] = "VHOST_USER_SET_MEM_TABLE", [VHOST_USER_SET_LOG_BASE] = "VHOST_USER_SET_LOG_BASE", [VHOST_USER_SET_LOG_FD] = "VHOST_USER_SET_LOG_FD",
@@ -921,7 +921,7 @@ vubr_execute_request(VubrDev *dev, VhostUserMsg *vmsg)return vubr_set_features_exec (dev, vmsg);case VHOST_USER_SET_OWNER :return vubr_set_owner_exec (dev, vmsg); -case VHOST_USER_RESET_DEVICE : +case VHOST_USER_RESET_OWNER :return vubr_reset_device_exec (dev, vmsg);case VHOST_USER_SET_MEM_TABLE :return vubr_set_mem_table_exec (dev, vmsg);
tests/vhost-user-test.c +2 -2
@@ -57,7 +57,7 @@ typedef enum VhostUserRequest {VHOST_USER_GET_FEATURES =1 ,VHOST_USER_SET_FEATURES =2 ,VHOST_USER_SET_OWNER =3 , -VHOST_USER_RESET_DEVICE =4 , +VHOST_USER_RESET_OWNER =4 ,VHOST_USER_SET_MEM_TABLE =5 ,VHOST_USER_SET_LOG_BASE =6 , VHOST_USER_SET_LOG_FD = 7,
@@ -315,7 +315,7 @@ static void chr_read(void *opaque, const uint8_t *buf, int size)g_cond_signal (&s->data_cond);break ; -case VHOST_USER_RESET_DEVICE : +case VHOST_USER_RESET_OWNER : s->fds_num =0 ;break ;
docs/specs/vhost-user.txt +2 -2
@@ -256,10 +256,10 @@ Message types as an owner of the session. This can be used on the Slave as a "session start" flag. - * VHOST_USER_RESET_DEVICE + * VHOST_USER_RESET_OWNER Id: 4 - Equivalent ioctl: VHOST_RESET_DEVICE + Equivalent ioctl: VHOST_RESET_OWNER Master payload: N/A Issued when a new connection is about to be closed. The Master will no
Signature · 1 line
MST
[Qemu-devel] [PULL 10/11] hw/virtio: Add PCIe capability to virtio devices
In reply to Michael S. TsirkinFrom: Marcel Apfelbaum <[email protected]>
The virtio devices are converted to PCI-Express if they are plugged into a PCI-Express bus and the 'modern' protocol is enabled.
Devices plugged directly into the Root Complex as Integrated Endpoints remain PCI.
--- hw/virtio/virtio-pci.h | 2 ++ include/hw/compat.h | 4 ++++ hw/virtio/virtio-pci.c | 22 ++++++++++++++++++++++ 3 files changed, 28 insertions(+)
hw/virtio/virtio-pci.h +2 -0
@@ -72,8 +72,10 @@ typedef struct VirtioBusClass VirtioPCIBusClass;/* virtio version flags */ #define VIRTIO_PCI_FLAG_DISABLE_LEGACY_BIT 2#define VIRTIO_PCI_FLAG_DISABLE_MODERN_BIT 3 +#define VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT 4#define VIRTIO_PCI_FLAG_DISABLE_LEGACY (1 << VIRTIO_PCI_FLAG_DISABLE_LEGACY_BIT)#define VIRTIO_PCI_FLAG_DISABLE_MODERN (1 << VIRTIO_PCI_FLAG_DISABLE_MODERN_BIT) +#define VIRTIO_PCI_FLAG_DISABLE_PCIE (1 << VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT)/* migrate extra state */ #define VIRTIO_PCI_FLAG_MIGRATE_EXTRA_BIT 4
include/hw/compat.h +4 -0
@@ -8,6 +8,10 @@ .value = "true",\ },{\ .driver = "virtio-pci",\ + .property = "x-disable-pcie",\ + .value = "on",\ + },{\ + .driver = "virtio-pci",\ .property = "migrate-extra",\ .value = "off",\ },
hw/virtio/virtio-pci.c +22 -0
@@ -1814,6 +1814,26 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp)address_space_init (&proxy->modern_as, &proxy->modern_cfg,"virtio-pci-cfg-as" ); +if (!(proxy->flags &VIRTIO_PCI_FLAG_DISABLE_PCIE ) + && !(proxy->flags &VIRTIO_PCI_FLAG_DISABLE_MODERN ) + &&pci_bus_is_express (pci_dev->bus) + && !pci_bus_is_root (pci_dev->bus)) { +int pos; + + pci_dev->cap_present |=QEMU_PCI_CAP_EXPRESS ; + pos =pcie_endpoint_cap_init (pci_dev,0 ); +assert (pos >0 ); + + pos =pci_add_capability (pci_dev,PCI_CAP_ID_PM ,0 ,PCI_PM_SIZEOF ); +assert (pos >0 ); + +/* +* Indicates that this function complies with revision 1.2 of the +* PCI Power Management Interface Specification. +*/ +pci_set_word (pci_dev->config + pos +PCI_PM_PMC ,0x3 ); + } +virtio_pci_bus_new (&proxy->bus,sizeof (proxy->bus), proxy);if (k->realize) { k->realize (proxy, errp);
@@ -1854,6 +1874,8 @@ static Property virtio_pci_properties[] = { VIRTIO_PCI_FLAG_MIGRATE_EXTRA_BIT, true),DEFINE_PROP_BIT ("modern-pio-notify" , VirtIOPCIProxy, flags,VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY_BIT , false), +DEFINE_PROP_BIT ("x-disable-pcie" , VirtIOPCIProxy, flags, +VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT , false), DEFINE_PROP_END_OF_LIST(), };
Signature · 1 line
MST
[Qemu-devel] [PULL 11/11] virtio-9p: add savem handlers
In reply to Michael S. TsirkinFrom: Greg Kurz <[email protected]>
We don't support migration of mounted 9p shares. This is handled by a migration blocker.
One would expect, however, to be able to migrate if the share is unmounted. Unfortunately virtio-9p-device does not register savevm handlers at all ! Migration succeeds and leaves the guest with a dangling device...
This patch simply registers migration handlers for virtio-9p-device. Whether migration is possible or not still depends on the migration blocker.
--- hw/9pfs/virtio-9p-device.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
hw/9pfs/virtio-9p-device.c +11 -0
@@ -43,6 +43,16 @@ static void virtio_9p_get_config(VirtIODevice *vdev, uint8_t *config)g_free (cfg); } +static void virtio_9p_save (QEMUFile *f,void *opaque) +{ +virtio_save (VIRTIO_DEVICE (opaque), f); +} + +static int virtio_9p_load (QEMUFile *f,void *opaque,int version_id) +{ +return virtio_load (VIRTIO_DEVICE (opaque), f, version_id); +} +static void virtio_9p_device_realize (DeviceState *dev,Error **errp) {VirtIODevice *vdev =VIRTIO_DEVICE (dev);
@@ -130,6 +140,7 @@ static void virtio_9p_device_realize(DeviceState *dev, Error **errp) }v9fs_path_free (&path); +register_savevm (dev,"virtio-9p" ,-1 ,1 , virtio_9p_save, virtio_9p_load, s);return ; out:g_free (s->ctx.fs_root);
Signature · 1 line
MST
Peter Maydell
AppliedQuoted 38 lines · Michael S. Tsirkin
The following changes since commit
fd717e789010012c5f0537269df19ef19d469baf:Merge remote-tracking branch 'remotes/mdroth/tags/qga-pull-2015-11-11-tag' into staging (2015-11-12 13:11:06 +0000)
are available in the git repository at:
git://git.kernel.org/pub/scm/virt/kvm/mst/qemu.gittags/for_upstreamfor you to fetch changes up to
4652f1640e029e1f2433fa77ba6af285c7cd923a:virtio-9p: add savem handlers (2015-11-12 16:40:14 +0200)
----------------------------------------------------------------
virtio, vhost: fixes for 2.5This fixes a performance regression with virtio 1, and makes device stop/start more robust for vhost-user. virtio devices on pcie bus now have pcie and pm capability, as required by the PCI Express spec. migration now works better with virtio 9p.
Signed-off-by Michael S. Tsirkin <[email protected]>----------------------------------------------------------------
Greg Kurz (1):
virtio-9p: add savem handlersJason Wang (6):
virtio-pci: fix 1.0 virtqueue migration
memory: don't try to adjust endianness for zero length eventfd
KVM: add support for any length io eventfd
virtio-pci: use zero length mmio eventfd for 1.0 notification cap when possible
virtio-pci: introduce pio notification capability for modern device
virtio-pci: unbreakqueue_enablereadMarcel Apfelbaum (1):
hw/virtio: Add PCIe capability to virtio devices
Quoted 6 lines
Victor Kaplansky (1):
vhost-user: modifySET_LOG_BASEto pass mmap size and offsetYuanhan Liu (2):
vhost: renameRESET_DEVICEbacktoRESET_OWNER
vhost: sendSET_VRING_ENABLEat start/stop
Applied, thanks.
-- PMM