* [Qemu-devel] [PULL 00/22] virtio,pc features, fixes
@ 2015-09-24 13:20 Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 01/22] virtio: right size for virtio_queue_get_avail_size Michael S. Tsirkin
` (23 more replies)
0 siblings, 24 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:20 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell
The following changes since commit fefa4b128de06cec6d513f00ee61e8208aed4a87:
Merge remote-tracking branch 'remotes/awilliam/tags/vfio-update-20150923.0' into staging (2015-09-23 21:39:46 +0100)
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 27fa11c68072398beb31af8828e25da5c2295814:
virtio-net: correctly drop truncated packets (2015-09-24 16:16:24 +0300)
----------------------------------------------------------------
virtio,pc features, fixes
New features:
vhost-user multiqueue support
virtio-ccw virtio 1 support
pci bridge support in iommu
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
----------------------------------------------------------------
Changchun Ouyang (2):
vhost-user: add multiple queue support
vhost-user: add a new message to disable/enable a specific virt queue.
Cornelia Huck (4):
virtio: ring sizes vs. reset
virtio-ccw: support ring size changes
virtio-ccw: feature bits > 31 handling
virtio-ccw: enable virtio-1
Eduardo Habkost (3):
q35: Move options common to all classes to pc_q35_machine_options()
q35: Move options common to all classes to pc_i440fx_machine_options()
pc: Introduce pc-*-2.5 machine classes
Jason Wang (4):
virtio-net: unbreak self announcement and guest offloads after migration
virtio: introduce virtqueue_unmap_sg()
virtio: introduce virtqueue_discard()
virtio-net: correctly drop truncated packets
Knut Omang (1):
intel_iommu: Add support for translation for devices behind bridges
Michael S. Tsirkin (1):
vhost-user: add protocol feature negotiation
Paolo Bonzini (2):
MAINTAINERS: add more devices to the PC section
MAINTAINERS: add more devices to the PCI section
Pierre Morel (1):
virtio: right size for virtio_queue_get_avail_size
Yuanhan Liu (4):
vhost-user: use VHOST_USER_XXX macro for switch statement
vhost: rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE
vhost-user: add VHOST_USER_GET_QUEUE_NUM message
vhost: introduce vhost_backend_get_vq_index method
qapi-schema.json | 6 +-
hw/s390x/virtio-ccw.h | 6 +-
include/hw/compat.h | 3 +
include/hw/i386/intel_iommu.h | 16 ++++-
include/hw/i386/pc.h | 4 ++
include/hw/virtio/vhost-backend.h | 4 ++
include/hw/virtio/vhost.h | 2 +
include/hw/virtio/virtio.h | 2 +
include/net/vhost_net.h | 3 +
linux-headers/linux/vhost.h | 2 +-
hw/i386/intel_iommu.c | 90 +++++++++++++++++++-----
hw/i386/pc_piix.c | 22 ++++--
hw/i386/pc_q35.c | 22 ++++--
hw/net/vhost_net.c | 44 ++++++++++--
hw/net/virtio-net.c | 56 ++++++++-------
hw/pci-host/q35.c | 25 +------
hw/s390x/s390-virtio-ccw.c | 20 ++++++
hw/s390x/virtio-ccw.c | 64 ++++++++++++-----
hw/virtio/vhost-backend.c | 10 ++-
hw/virtio/vhost-user.c | 139 +++++++++++++++++++++++++++++++------
hw/virtio/vhost.c | 20 +++---
hw/virtio/virtio.c | 88 ++++++++++++++++++++++--
net/vhost-user.c | 141 +++++++++++++++++++++++++-------------
tests/vhost-user-test.c | 2 +-
MAINTAINERS | 21 ++++++
docs/specs/vhost-user.txt | 77 ++++++++++++++++++++-
qemu-options.hx | 5 +-
27 files changed, 701 insertions(+), 193 deletions(-)
^ permalink raw reply [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 01/22] virtio: right size for virtio_queue_get_avail_size
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
@ 2015-09-24 13:20 ` Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 02/22] virtio-net: unbreak self announcement and guest offloads after migration Michael S. Tsirkin
` (22 subsequent siblings)
23 siblings, 0 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:20 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Pierre Morel
From: Pierre Morel <pmorel@linux.vnet.ibm.com>
Being working on dataplane I notice something strange:
virtio_queue_get_avail_size() used a 64bit size index
for the calculation of the available ring size.
It is quite strange but it did work with the old calculation
of the avail ring, at most with performance penalty,
and I wonder where I missed something.
This patch let use a 16bit size as defined in virtio_ring.h
Signed-off-by: Pierre Morel <pmorel@linux.vnet.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/virtio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 0832db9..730c7f0 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1460,7 +1460,7 @@ hwaddr virtio_queue_get_desc_size(VirtIODevice *vdev, int n)
hwaddr virtio_queue_get_avail_size(VirtIODevice *vdev, int n)
{
return offsetof(VRingAvail, ring) +
- sizeof(uint64_t) * vdev->vq[n].vring.num;
+ sizeof(uint16_t) * vdev->vq[n].vring.num;
}
hwaddr virtio_queue_get_used_size(VirtIODevice *vdev, int n)
--
MST
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 02/22] virtio-net: unbreak self announcement and guest offloads after migration
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 01/22] virtio: right size for virtio_queue_get_avail_size Michael S. Tsirkin
@ 2015-09-24 13:20 ` Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 03/22] q35: Move options common to all classes to pc_q35_machine_options() Michael S. Tsirkin
` (21 subsequent siblings)
23 siblings, 0 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:20 UTC (permalink / raw)
To: qemu-devel
Cc: Cornelia Huck, Peter Maydell, Jason Wang, qemu-stable,
Gerd Hoffmann
From: Jason Wang <jasowang@redhat.com>
After commit 019a3edbb25f1571e876f8af1ce4c55412939e5d ("virtio: make
features 64bit wide"). Device's guest_features was actually set after
vdc->load(). This breaks the assumption that device specific load()
function can check guest_features. For virtio-net, self announcement
and guest offloads won't work after migration.
Fixing this by defer them to virtio_net_load() where guest_features
were guaranteed to be set. Other virtio devices looks fine.
Fixes: 019a3edbb25f1571e876f8af1ce4c55412939e5d
("virtio: make features 64bit wide")
Cc: qemu-stable@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
hw/net/virtio-net.c | 40 +++++++++++++++++++++++-----------------
1 file changed, 23 insertions(+), 17 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index f72eebf..2775e6a 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1458,11 +1458,33 @@ static int virtio_net_load(QEMUFile *f, void *opaque, int version_id)
{
VirtIONet *n = opaque;
VirtIODevice *vdev = VIRTIO_DEVICE(n);
+ int ret;
if (version_id < 2 || version_id > VIRTIO_NET_VM_VERSION)
return -EINVAL;
- return virtio_load(vdev, f, version_id);
+ ret = virtio_load(vdev, f, version_id);
+ if (ret) {
+ return ret;
+ }
+
+ if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) {
+ n->curr_guest_offloads = qemu_get_be64(f);
+ } else {
+ n->curr_guest_offloads = virtio_net_supported_guest_offloads(n);
+ }
+
+ if (peer_has_vnet_hdr(n)) {
+ virtio_net_apply_guest_offloads(n);
+ }
+
+ if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_GUEST_ANNOUNCE) &&
+ virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) {
+ n->announce_counter = SELF_ANNOUNCE_ROUNDS;
+ timer_mod(n->announce_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL));
+ }
+
+ return 0;
}
static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f,
@@ -1559,16 +1581,6 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f,
}
}
- if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) {
- n->curr_guest_offloads = qemu_get_be64(f);
- } else {
- n->curr_guest_offloads = virtio_net_supported_guest_offloads(n);
- }
-
- if (peer_has_vnet_hdr(n)) {
- virtio_net_apply_guest_offloads(n);
- }
-
virtio_net_set_queues(n);
/* Find the first multicast entry in the saved MAC filter */
@@ -1586,12 +1598,6 @@ static int virtio_net_load_device(VirtIODevice *vdev, QEMUFile *f,
qemu_get_subqueue(n->nic, i)->link_down = link_down;
}
- if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_GUEST_ANNOUNCE) &&
- virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) {
- n->announce_counter = SELF_ANNOUNCE_ROUNDS;
- timer_mod(n->announce_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL));
- }
-
return 0;
}
--
MST
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 03/22] q35: Move options common to all classes to pc_q35_machine_options()
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 01/22] virtio: right size for virtio_queue_get_avail_size Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 02/22] virtio-net: unbreak self announcement and guest offloads after migration Michael S. Tsirkin
@ 2015-09-24 13:20 ` Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 04/22] q35: Move options common to all classes to pc_i440fx_machine_options() Michael S. Tsirkin
` (20 subsequent siblings)
23 siblings, 0 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:20 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Richard Henderson, Eduardo Habkost, Paolo Bonzini
From: Eduardo Habkost <ehabkost@redhat.com>
The existing default_machine_opts, default_display, no_floppy, and
no_tco settings will still apply to future machine classes. So it makes
sense to move them to pc_q35_machine_options() instead of keeping them
in a version-specific machine_options function.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/i386/pc_q35.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 11601ab..966eedb 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -364,6 +364,10 @@ static void pc_q35_machine_options(MachineClass *m)
m->desc = "Standard PC (Q35 + ICH9, 2009)";
m->hot_add_cpu = pc_hot_add_cpu;
m->units_per_default_bus = 1;
+ m->default_machine_opts = "firmware=bios-256k.bin";
+ m->default_display = "std";
+ m->no_floppy = 1;
+ m->no_tco = 0;
}
static void pc_q35_2_4_machine_options(MachineClass *m)
@@ -371,10 +375,6 @@ static void pc_q35_2_4_machine_options(MachineClass *m)
PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
pc_q35_machine_options(m);
pcmc->broken_reserved_end = true;
- m->default_machine_opts = "firmware=bios-256k.bin";
- m->default_display = "std";
- m->no_floppy = 1;
- m->no_tco = 0;
m->alias = "q35";
}
--
MST
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 04/22] q35: Move options common to all classes to pc_i440fx_machine_options()
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
` (2 preceding siblings ...)
2015-09-24 13:20 ` [Qemu-devel] [PULL 03/22] q35: Move options common to all classes to pc_q35_machine_options() Michael S. Tsirkin
@ 2015-09-24 13:20 ` Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 05/22] pc: Introduce pc-*-2.5 machine classes Michael S. Tsirkin
` (19 subsequent siblings)
23 siblings, 0 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:20 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Richard Henderson, Eduardo Habkost, Paolo Bonzini
From: Eduardo Habkost <ehabkost@redhat.com>
The existing default_machine_opts and default_display settings will
still apply to future machine classes. So it makes sense to move them to
pc_i440fx_machine_options() instead of keeping them in a
version-specific machine_options function.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/i386/pc_piix.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 3f925b2..2d9df7c 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -460,6 +460,8 @@ static void pc_i440fx_machine_options(MachineClass *m)
m->family = "pc_piix";
m->desc = "Standard PC (i440FX + PIIX, 1996)";
m->hot_add_cpu = pc_hot_add_cpu;
+ m->default_machine_opts = "firmware=bios-256k.bin";
+ m->default_display = "std";
}
static void pc_i440fx_2_4_machine_options(MachineClass *m)
@@ -467,8 +469,6 @@ static void pc_i440fx_2_4_machine_options(MachineClass *m)
PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
pc_i440fx_machine_options(m);
pcmc->broken_reserved_end = true;
- m->default_machine_opts = "firmware=bios-256k.bin";
- m->default_display = "std";
m->alias = "pc";
m->is_default = 1;
}
--
MST
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 05/22] pc: Introduce pc-*-2.5 machine classes
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
` (3 preceding siblings ...)
2015-09-24 13:20 ` [Qemu-devel] [PULL 04/22] q35: Move options common to all classes to pc_i440fx_machine_options() Michael S. Tsirkin
@ 2015-09-24 13:20 ` Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 06/22] virtio: ring sizes vs. reset Michael S. Tsirkin
` (18 subsequent siblings)
23 siblings, 0 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:20 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Richard Henderson, Eduardo Habkost, Paolo Bonzini
From: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/compat.h | 3 +++
include/hw/i386/pc.h | 4 ++++
hw/i386/pc_piix.c | 18 +++++++++++++++---
hw/i386/pc_q35.c | 14 ++++++++++++--
4 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/include/hw/compat.h b/include/hw/compat.h
index 94c8097..095de5d 100644
--- a/include/hw/compat.h
+++ b/include/hw/compat.h
@@ -1,6 +1,9 @@
#ifndef HW_COMPAT_H
#define HW_COMPAT_H
+#define HW_COMPAT_2_4 \
+ /* empty */
+
#define HW_COMPAT_2_3 \
{\
.driver = "virtio-blk-pci",\
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 3e002c9..6896328 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -291,7 +291,11 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
int e820_get_num_entries(void);
bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
+#define PC_COMPAT_2_4 \
+ HW_COMPAT_2_4
+
#define PC_COMPAT_2_3 \
+ PC_COMPAT_2_4 \
HW_COMPAT_2_3 \
{\
.driver = TYPE_X86_CPU,\
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 2d9df7c..3ffb05f 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -464,15 +464,27 @@ static void pc_i440fx_machine_options(MachineClass *m)
m->default_display = "std";
}
-static void pc_i440fx_2_4_machine_options(MachineClass *m)
+static void pc_i440fx_2_5_machine_options(MachineClass *m)
{
- PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
pc_i440fx_machine_options(m);
- pcmc->broken_reserved_end = true;
m->alias = "pc";
m->is_default = 1;
}
+DEFINE_I440FX_MACHINE(v2_5, "pc-i440fx-2.5", NULL,
+ pc_i440fx_2_5_machine_options);
+
+
+static void pc_i440fx_2_4_machine_options(MachineClass *m)
+{
+ PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
+ pc_i440fx_2_5_machine_options(m);
+ m->alias = NULL;
+ m->is_default = 0;
+ pcmc->broken_reserved_end = true;
+ SET_MACHINE_COMPAT(m, PC_COMPAT_2_4);
+}
+
DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL,
pc_i440fx_2_4_machine_options)
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 966eedb..1b7d3b6 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -370,12 +370,22 @@ static void pc_q35_machine_options(MachineClass *m)
m->no_tco = 0;
}
+static void pc_q35_2_5_machine_options(MachineClass *m)
+{
+ pc_q35_machine_options(m);
+ m->alias = "q35";
+}
+
+DEFINE_Q35_MACHINE(v2_5, "pc-q35-2.5", NULL,
+ pc_q35_2_5_machine_options);
+
static void pc_q35_2_4_machine_options(MachineClass *m)
{
PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
- pc_q35_machine_options(m);
+ pc_q35_2_5_machine_options(m);
+ m->alias = NULL;
pcmc->broken_reserved_end = true;
- m->alias = "q35";
+ SET_MACHINE_COMPAT(m, PC_COMPAT_2_4);
}
DEFINE_Q35_MACHINE(v2_4, "pc-q35-2.4", NULL,
--
MST
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 06/22] virtio: ring sizes vs. reset
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
` (4 preceding siblings ...)
2015-09-24 13:20 ` [Qemu-devel] [PULL 05/22] pc: Introduce pc-*-2.5 machine classes Michael S. Tsirkin
@ 2015-09-24 13:20 ` Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 07/22] virtio-ccw: support ring size changes Michael S. Tsirkin
` (17 subsequent siblings)
23 siblings, 0 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:20 UTC (permalink / raw)
To: qemu-devel; +Cc: Cornelia Huck, Peter Maydell, Jason Wang
From: Cornelia Huck <cornelia.huck@de.ibm.com>
We allow guests to change the size of the virtqueue rings by supplying
a number of buffers that is different from the number of buffers the
device was initialized with. Current code has some problems, however,
since reset does not reset the ringsizes to the default values (as this
is not saved anywhere).
Let's extend the core code to keep track of the default ringsizes and
migrate them once the guest changed them for any of the virtqueues
for a device.
Reviewed-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/virtio.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 730c7f0..7504f8b 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -60,6 +60,7 @@ typedef struct VRingUsed
typedef struct VRing
{
unsigned int num;
+ unsigned int num_default;
unsigned int align;
hwaddr desc;
hwaddr avail;
@@ -633,6 +634,7 @@ void virtio_reset(void *opaque)
vdev->vq[i].signalled_used = 0;
vdev->vq[i].signalled_used_valid = false;
vdev->vq[i].notification = true;
+ vdev->vq[i].vring.num = vdev->vq[i].vring.num_default;
}
}
@@ -964,6 +966,7 @@ VirtQueue *virtio_add_queue(VirtIODevice *vdev, int queue_size,
abort();
vdev->vq[i].vring.num = queue_size;
+ vdev->vq[i].vring.num_default = queue_size;
vdev->vq[i].vring.align = VIRTIO_PCI_VRING_ALIGN;
vdev->vq[i].handle_output = handle_output;
@@ -977,6 +980,7 @@ void virtio_del_queue(VirtIODevice *vdev, int n)
}
vdev->vq[n].vring.num = 0;
+ vdev->vq[n].vring.num_default = 0;
}
void virtio_irq(VirtQueue *vq)
@@ -1056,6 +1060,19 @@ static bool virtio_virtqueue_needed(void *opaque)
return virtio_host_has_feature(vdev, VIRTIO_F_VERSION_1);
}
+static bool virtio_ringsize_needed(void *opaque)
+{
+ VirtIODevice *vdev = opaque;
+ int i;
+
+ for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
+ if (vdev->vq[i].vring.num != vdev->vq[i].vring.num_default) {
+ return true;
+ }
+ }
+ return false;
+}
+
static void put_virtqueue_state(QEMUFile *f, void *pv, size_t size)
{
VirtIODevice *vdev = pv;
@@ -1104,6 +1121,52 @@ static const VMStateDescription vmstate_virtio_virtqueues = {
}
};
+static void put_ringsize_state(QEMUFile *f, void *pv, size_t size)
+{
+ VirtIODevice *vdev = pv;
+ int i;
+
+ for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
+ qemu_put_be32(f, vdev->vq[i].vring.num_default);
+ }
+}
+
+static int get_ringsize_state(QEMUFile *f, void *pv, size_t size)
+{
+ VirtIODevice *vdev = pv;
+ int i;
+
+ for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
+ vdev->vq[i].vring.num_default = qemu_get_be32(f);
+ }
+ return 0;
+}
+
+static VMStateInfo vmstate_info_ringsize = {
+ .name = "ringsize_state",
+ .get = get_ringsize_state,
+ .put = put_ringsize_state,
+};
+
+static const VMStateDescription vmstate_virtio_ringsize = {
+ .name = "virtio/ringsize",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .needed = &virtio_ringsize_needed,
+ .fields = (VMStateField[]) {
+ {
+ .name = "ringsize",
+ .version_id = 0,
+ .field_exists = NULL,
+ .size = 0,
+ .info = &vmstate_info_ringsize,
+ .flags = VMS_SINGLE,
+ .offset = 0,
+ },
+ VMSTATE_END_OF_LIST()
+ }
+};
+
static const VMStateDescription vmstate_virtio_device_endian = {
.name = "virtio/device_endian",
.version_id = 1,
@@ -1138,6 +1201,7 @@ static const VMStateDescription vmstate_virtio = {
&vmstate_virtio_device_endian,
&vmstate_virtio_64bit_features,
&vmstate_virtio_virtqueues,
+ &vmstate_virtio_ringsize,
NULL
}
};
--
MST
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 07/22] virtio-ccw: support ring size changes
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
` (5 preceding siblings ...)
2015-09-24 13:20 ` [Qemu-devel] [PULL 06/22] virtio: ring sizes vs. reset Michael S. Tsirkin
@ 2015-09-24 13:20 ` Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 08/22] virtio-ccw: feature bits > 31 handling Michael S. Tsirkin
` (16 subsequent siblings)
23 siblings, 0 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:20 UTC (permalink / raw)
To: qemu-devel
Cc: Cornelia Huck, Peter Maydell, Richard Henderson, Alexander Graf,
Christian Borntraeger
From: Cornelia Huck <cornelia.huck@de.ibm.com>
Wire up changing the ring size for virtio-1 devices.
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/s390x/virtio-ccw.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index d36373e..85e2a5d 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -307,11 +307,18 @@ static int virtio_ccw_set_vqs(SubchDev *sch, VqInfoBlock *info,
if (!desc) {
virtio_queue_set_vector(vdev, index, VIRTIO_NO_VECTOR);
} else {
- /* Fail if we don't have a big enough queue. */
- /* TODO: Add interface to handle vring.num changing */
- if (virtio_queue_get_num(vdev, index) > num) {
+ if (info) {
+ /* virtio-1 allows changing the ring size. */
+ if (virtio_queue_get_num(vdev, index) < num) {
+ /* Fail if we exceed the maximum number. */
+ return -EINVAL;
+ }
+ virtio_queue_set_num(vdev, index, num);
+ } else if (virtio_queue_get_num(vdev, index) > num) {
+ /* Fail if we don't have a big enough queue. */
return -EINVAL;
}
+ /* We ignore possible increased num for legacy for compatibility. */
virtio_queue_set_vector(vdev, index, index);
}
/* tell notify handler in case of config change */
--
MST
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 08/22] virtio-ccw: feature bits > 31 handling
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
` (6 preceding siblings ...)
2015-09-24 13:20 ` [Qemu-devel] [PULL 07/22] virtio-ccw: support ring size changes Michael S. Tsirkin
@ 2015-09-24 13:20 ` Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 09/22] virtio-ccw: enable virtio-1 Michael S. Tsirkin
` (15 subsequent siblings)
23 siblings, 0 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:20 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, David Hildenbrand, Alexander Graf,
Christian Borntraeger, Cornelia Huck, Richard Henderson
From: Cornelia Huck <cornelia.huck@de.ibm.com>
We currently switch off the VERSION_1 feature bit if the guest has
not negotiated at least revision 1. As no feature bits beyond 31 are
valid however unless VERSION_1 has been negotiated, make sure that
legacy guests never see a feature bit beyond 31.
Reviewed-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/s390x/virtio-ccw.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 85e2a5d..eed7b3e 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -468,15 +468,12 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
NULL);
if (features.index == 0) {
features.features = (uint32_t)vdev->host_features;
- } else if (features.index == 1) {
- features.features = (uint32_t)(vdev->host_features >> 32);
+ } else if ((features.index == 1) && (dev->revision >= 1)) {
/*
- * Don't offer version 1 to the guest if it did not
- * negotiate at least revision 1.
+ * Only offer feature bits beyond 31 if the guest has
+ * negotiated at least revision 1.
*/
- if (dev->revision <= 0) {
- features.features &= ~(1 << (VIRTIO_F_VERSION_1 - 32));
- }
+ features.features = (uint32_t)(vdev->host_features >> 32);
} else {
/* Return zeroes if the guest supports more feature bits. */
features.features = 0;
@@ -515,14 +512,12 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
virtio_set_features(vdev,
(vdev->guest_features & 0xffffffff00000000ULL) |
features.features);
- } else if (features.index == 1) {
+ } else if ((features.index == 1) && (dev->revision >= 1)) {
/*
- * The guest should not set version 1 if it didn't
- * negotiate a revision >= 1.
+ * If the guest did not negotiate at least revision 1,
+ * we did not offer it any feature bits beyond 31. Such a
+ * guest passing us any bit here is therefore buggy.
*/
- if (dev->revision <= 0) {
- features.features &= ~(1 << (VIRTIO_F_VERSION_1 - 32));
- }
virtio_set_features(vdev,
(vdev->guest_features & 0x00000000ffffffffULL) |
((uint64_t)features.features << 32));
--
MST
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 09/22] virtio-ccw: enable virtio-1
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
` (7 preceding siblings ...)
2015-09-24 13:20 ` [Qemu-devel] [PULL 08/22] virtio-ccw: feature bits > 31 handling Michael S. Tsirkin
@ 2015-09-24 13:20 ` Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 10/22] vhost-user: use VHOST_USER_XXX macro for switch statement Michael S. Tsirkin
` (14 subsequent siblings)
23 siblings, 0 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:20 UTC (permalink / raw)
To: qemu-devel
Cc: Cornelia Huck, Peter Maydell, Richard Henderson, Alexander Graf,
Christian Borntraeger
From: Cornelia Huck <cornelia.huck@de.ibm.com>
Let's enable revision 1 for virtio-ccw devices. We can always offer
VERSION_1 as drivers in legacy mode won't be able to see it anyway.
We have to introduce a way to set a lower maximum revision for a device
to accommodate the following cases:
- compat machines (to enforce legacy only)
- virtio-blk with scsi support (version 1 + scsi is fenced by common
code, with a user-configured max revision of 0 we can allow scsi
via not offering VERSION_1)
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/s390x/virtio-ccw.h | 6 ++++--
hw/s390x/s390-virtio-ccw.c | 20 ++++++++++++++++++++
hw/s390x/virtio-ccw.c | 30 ++++++++++++++++++++++++++++--
3 files changed, 52 insertions(+), 4 deletions(-)
diff --git a/hw/s390x/virtio-ccw.h b/hw/s390x/virtio-ccw.h
index 692ddd7..7ab8367 100644
--- a/hw/s390x/virtio-ccw.h
+++ b/hw/s390x/virtio-ccw.h
@@ -88,6 +88,7 @@ struct VirtioCcwDevice {
SubchDev *sch;
char *bus_id;
int revision;
+ uint32_t max_rev;
VirtioBusState bus;
bool ioeventfd_started;
bool ioeventfd_disabled;
@@ -102,9 +103,10 @@ struct VirtioCcwDevice {
};
/* The maximum virtio revision we support. */
-static inline int virtio_ccw_rev_max(VirtIODevice *vdev)
+#define VIRTIO_CCW_MAX_REV 1
+static inline int virtio_ccw_rev_max(VirtioCcwDevice *dev)
{
- return 0;
+ return dev->max_rev;
}
/* virtual css bus type */
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 36f78b4..c53ebc1 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -242,6 +242,26 @@ static const TypeInfo ccw_machine_info = {
.driver = TYPE_S390_SKEYS,\
.property = "migration-enabled",\
.value = "off",\
+ },{\
+ .driver = "virtio-blk-ccw",\
+ .property = "max_revision",\
+ .value = "0",\
+ },{\
+ .driver = "virtio-balloon-ccw",\
+ .property = "max_revision",\
+ .value = "0",\
+ },{\
+ .driver = "virtio-serial-ccw",\
+ .property = "max_revision",\
+ .value = "0",\
+ },{\
+ .driver = "virtio-9p-ccw",\
+ .property = "max_revision",\
+ .value = "0",\
+ },{\
+ .driver = "virtio-rng-ccw",\
+ .property = "max_revision",\
+ .value = "0",\
},
static void ccw_machine_2_4_class_init(ObjectClass *oc, void *data)
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index eed7b3e..fb103b7 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -467,7 +467,13 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
MEMTXATTRS_UNSPECIFIED,
NULL);
if (features.index == 0) {
- features.features = (uint32_t)vdev->host_features;
+ if (dev->revision >= 1) {
+ /* Don't offer legacy features for modern devices. */
+ features.features = (uint32_t)
+ (vdev->host_features & ~VIRTIO_LEGACY_FEATURES);
+ } else {
+ features.features = (uint32_t)vdev->host_features;
+ }
} else if ((features.index == 1) && (dev->revision >= 1)) {
/*
* Only offer feature bits beyond 31 if the guest has
@@ -768,7 +774,7 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw)
* need to fetch it here. Nothing to do for now, though.
*/
if (dev->revision >= 0 ||
- revinfo.revision > virtio_ccw_rev_max(vdev)) {
+ revinfo.revision > virtio_ccw_rev_max(dev)) {
ret = -ENOSYS;
break;
}
@@ -1541,6 +1547,10 @@ static void virtio_ccw_device_plugged(DeviceState *d, Error **errp)
sch->id.cu_model = virtio_bus_get_vdev_id(&dev->bus);
+ if (dev->max_rev >= 1) {
+ virtio_add_feature(&vdev->host_features, VIRTIO_F_VERSION_1);
+ }
+
css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid,
d->hotplugged, 1);
}
@@ -1557,6 +1567,8 @@ static Property virtio_ccw_net_properties[] = {
DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
+ DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
+ VIRTIO_CCW_MAX_REV),
DEFINE_PROP_END_OF_LIST(),
};
@@ -1584,6 +1596,8 @@ static Property virtio_ccw_blk_properties[] = {
DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
+ DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
+ VIRTIO_CCW_MAX_REV),
DEFINE_PROP_END_OF_LIST(),
};
@@ -1611,6 +1625,8 @@ static Property virtio_ccw_serial_properties[] = {
DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
+ DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
+ VIRTIO_CCW_MAX_REV),
DEFINE_PROP_END_OF_LIST(),
};
@@ -1638,6 +1654,8 @@ static Property virtio_ccw_balloon_properties[] = {
DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
+ DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
+ VIRTIO_CCW_MAX_REV),
DEFINE_PROP_END_OF_LIST(),
};
@@ -1665,6 +1683,8 @@ static Property virtio_ccw_scsi_properties[] = {
DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
+ DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
+ VIRTIO_CCW_MAX_REV),
DEFINE_PROP_END_OF_LIST(),
};
@@ -1691,6 +1711,8 @@ static const TypeInfo virtio_ccw_scsi = {
#ifdef CONFIG_VHOST_SCSI
static Property vhost_ccw_scsi_properties[] = {
DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
+ DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
+ VIRTIO_CCW_MAX_REV),
DEFINE_PROP_END_OF_LIST(),
};
@@ -1729,6 +1751,8 @@ static Property virtio_ccw_rng_properties[] = {
DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
+ DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
+ VIRTIO_CCW_MAX_REV),
DEFINE_PROP_END_OF_LIST(),
};
@@ -1882,6 +1906,8 @@ static Property virtio_ccw_9p_properties[] = {
DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
+ DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
+ VIRTIO_CCW_MAX_REV),
DEFINE_PROP_END_OF_LIST(),
};
--
MST
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 10/22] vhost-user: use VHOST_USER_XXX macro for switch statement
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
` (8 preceding siblings ...)
2015-09-24 13:20 ` [Qemu-devel] [PULL 09/22] virtio-ccw: enable virtio-1 Michael S. Tsirkin
@ 2015-09-24 13:20 ` Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 11/22] vhost-user: add protocol feature negotiation Michael S. Tsirkin
` (13 subsequent siblings)
23 siblings, 0 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:20 UTC (permalink / raw)
To: qemu-devel; +Cc: Marcel Apfelbaum, Peter Maydell, Yuanhan Liu
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
So that we could let vhost_user_call to handle extented requests,
such as VHOST_USER_GET/SET_PROTOCOL_FEATURES, instead of invoking
vhost_user_read/write and constructing the msg again by ourself.
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
---
hw/virtio/vhost-user.c | 38 ++++++++++++++++++++++----------------
1 file changed, 22 insertions(+), 16 deletions(-)
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index e7ab829..13677ac 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -193,27 +193,33 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER);
- msg_request = vhost_user_request_translate(request);
+ /* only translate vhost ioctl requests */
+ if (request > VHOST_USER_MAX) {
+ msg_request = vhost_user_request_translate(request);
+ } else {
+ msg_request = request;
+ }
+
msg.request = msg_request;
msg.flags = VHOST_USER_VERSION;
msg.size = 0;
- switch (request) {
- case VHOST_GET_FEATURES:
+ switch (msg_request) {
+ case VHOST_USER_GET_FEATURES:
need_reply = 1;
break;
- case VHOST_SET_FEATURES:
- case VHOST_SET_LOG_BASE:
+ case VHOST_USER_SET_FEATURES:
+ case VHOST_USER_SET_LOG_BASE:
msg.u64 = *((__u64 *) arg);
msg.size = sizeof(m.u64);
break;
- case VHOST_SET_OWNER:
- case VHOST_RESET_OWNER:
+ case VHOST_USER_SET_OWNER:
+ case VHOST_USER_RESET_OWNER:
break;
- case VHOST_SET_MEM_TABLE:
+ case VHOST_USER_SET_MEM_TABLE:
for (i = 0; i < dev->mem->nregions; ++i) {
struct vhost_memory_region *reg = dev->mem->regions + i;
ram_addr_t ram_addr;
@@ -246,30 +252,30 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
break;
- case VHOST_SET_LOG_FD:
+ case VHOST_USER_SET_LOG_FD:
fds[fd_num++] = *((int *) arg);
break;
- case VHOST_SET_VRING_NUM:
- case VHOST_SET_VRING_BASE:
+ case VHOST_USER_SET_VRING_NUM:
+ case VHOST_USER_SET_VRING_BASE:
memcpy(&msg.state, arg, sizeof(struct vhost_vring_state));
msg.size = sizeof(m.state);
break;
- case VHOST_GET_VRING_BASE:
+ case VHOST_USER_GET_VRING_BASE:
memcpy(&msg.state, arg, sizeof(struct vhost_vring_state));
msg.size = sizeof(m.state);
need_reply = 1;
break;
- case VHOST_SET_VRING_ADDR:
+ case VHOST_USER_SET_VRING_ADDR:
memcpy(&msg.addr, arg, sizeof(struct vhost_vring_addr));
msg.size = sizeof(m.addr);
break;
- case VHOST_SET_VRING_KICK:
- case VHOST_SET_VRING_CALL:
- case VHOST_SET_VRING_ERR:
+ case VHOST_USER_SET_VRING_KICK:
+ case VHOST_USER_SET_VRING_CALL:
+ case VHOST_USER_SET_VRING_ERR:
file = arg;
msg.u64 = file->index & VHOST_USER_VRING_IDX_MASK;
msg.size = sizeof(m.u64);
--
MST
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 11/22] vhost-user: add protocol feature negotiation
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
` (9 preceding siblings ...)
2015-09-24 13:20 ` [Qemu-devel] [PULL 10/22] vhost-user: use VHOST_USER_XXX macro for switch statement Michael S. Tsirkin
@ 2015-09-24 13:20 ` Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 12/22] vhost: rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE Michael S. Tsirkin
` (12 subsequent siblings)
23 siblings, 0 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:20 UTC (permalink / raw)
To: qemu-devel; +Cc: Marcel Apfelbaum, Peter Maydell, Yuanhan Liu, mst
Support a separate bitmask for vhost-user protocol features,
and messages to get/set protocol features.
Invoke them at init.
No features are defined yet.
[ leverage vhost_user_call for request handling -- Yuanhan Liu ]
Signed-off-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
---
include/hw/virtio/vhost.h | 1 +
hw/net/vhost_net.c | 2 ++
hw/virtio/vhost-user.c | 31 +++++++++++++++++++++++++++++++
docs/specs/vhost-user.txt | 37 +++++++++++++++++++++++++++++++++++++
4 files changed, 71 insertions(+)
diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
index dd51050..6467c73 100644
--- a/include/hw/virtio/vhost.h
+++ b/include/hw/virtio/vhost.h
@@ -47,6 +47,7 @@ struct vhost_dev {
unsigned long long features;
unsigned long long acked_features;
unsigned long long backend_features;
+ unsigned long long protocol_features;
bool started;
bool log_enabled;
unsigned long long log_size;
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 1d76b94..9d32d76 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -152,8 +152,10 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
net->dev.backend_features = qemu_has_vnet_hdr(options->net_backend)
? 0 : (1ULL << VHOST_NET_F_VIRTIO_NET_HDR);
net->backend = r;
+ net->dev.protocol_features = 0;
} else {
net->dev.backend_features = 0;
+ net->dev.protocol_features = 0;
net->backend = -1;
}
net->nc = options->net_backend;
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 13677ac..7fe35c6 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -24,6 +24,8 @@
#include <linux/vhost.h>
#define VHOST_MEMORY_MAX_NREGIONS 8
+#define VHOST_USER_F_PROTOCOL_FEATURES 30
+#define VHOST_USER_PROTOCOL_FEATURE_MASK 0x0ULL
typedef enum VhostUserRequest {
VHOST_USER_NONE = 0,
@@ -41,6 +43,8 @@ typedef enum VhostUserRequest {
VHOST_USER_SET_VRING_KICK = 12,
VHOST_USER_SET_VRING_CALL = 13,
VHOST_USER_SET_VRING_ERR = 14,
+ VHOST_USER_GET_PROTOCOL_FEATURES = 15,
+ VHOST_USER_SET_PROTOCOL_FEATURES = 16,
VHOST_USER_MAX
} VhostUserRequest;
@@ -206,11 +210,13 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
switch (msg_request) {
case VHOST_USER_GET_FEATURES:
+ case VHOST_USER_GET_PROTOCOL_FEATURES:
need_reply = 1;
break;
case VHOST_USER_SET_FEATURES:
case VHOST_USER_SET_LOG_BASE:
+ case VHOST_USER_SET_PROTOCOL_FEATURES:
msg.u64 = *((__u64 *) arg);
msg.size = sizeof(m.u64);
break;
@@ -308,6 +314,7 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
switch (msg_request) {
case VHOST_USER_GET_FEATURES:
+ case VHOST_USER_GET_PROTOCOL_FEATURES:
if (msg.size != sizeof(m.u64)) {
error_report("Received bad msg size.");
return -1;
@@ -333,10 +340,34 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
static int vhost_user_init(struct vhost_dev *dev, void *opaque)
{
+ unsigned long long features;
+ int err;
+
assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER);
dev->opaque = opaque;
+ err = vhost_user_call(dev, VHOST_USER_GET_FEATURES, &features);
+ if (err < 0) {
+ return err;
+ }
+
+ if (virtio_has_feature(features, VHOST_USER_F_PROTOCOL_FEATURES)) {
+ dev->backend_features |= 1ULL << VHOST_USER_F_PROTOCOL_FEATURES;
+
+ err = vhost_user_call(dev, VHOST_USER_GET_PROTOCOL_FEATURES, &features);
+ if (err < 0) {
+ return err;
+ }
+
+ dev->protocol_features = features & VHOST_USER_PROTOCOL_FEATURE_MASK;
+ err = vhost_user_call(dev, VHOST_USER_SET_PROTOCOL_FEATURES,
+ &dev->protocol_features);
+ if (err < 0) {
+ return err;
+ }
+ }
+
return 0;
}
diff --git a/docs/specs/vhost-user.txt b/docs/specs/vhost-user.txt
index 650bb18..70da3b1 100644
--- a/docs/specs/vhost-user.txt
+++ b/docs/specs/vhost-user.txt
@@ -113,6 +113,7 @@ message replies. Most of the requests don't require replies. Here is a list of
the ones that do:
* VHOST_GET_FEATURES
+ * VHOST_GET_PROTOCOL_FEATURES
* VHOST_GET_VRING_BASE
There are several messages that the master sends with file descriptors passed
@@ -127,6 +128,13 @@ in the ancillary data:
If Master is unable to send the full message or receives a wrong reply it will
close the connection. An optional reconnection mechanism can be implemented.
+Any protocol extensions are gated by protocol feature bits,
+which allows full backwards compatibility on both master
+and slave.
+As older slaves don't support negotiating protocol features,
+a feature bit was dedicated for this purpose:
+#define VHOST_USER_F_PROTOCOL_FEATURES 30
+
Message types
-------------
@@ -138,6 +146,8 @@ Message types
Slave payload: u64
Get from the underlying vhost implementation the features bitmask.
+ Feature bit VHOST_USER_F_PROTOCOL_FEATURES signals slave support for
+ VHOST_USER_GET_PROTOCOL_FEATURES and VHOST_USER_SET_PROTOCOL_FEATURES.
* VHOST_USER_SET_FEATURES
@@ -146,6 +156,33 @@ Message types
Master payload: u64
Enable features in the underlying vhost implementation using a bitmask.
+ Feature bit VHOST_USER_F_PROTOCOL_FEATURES signals slave support for
+ VHOST_USER_GET_PROTOCOL_FEATURES and VHOST_USER_SET_PROTOCOL_FEATURES.
+
+ * VHOST_USER_GET_PROTOCOL_FEATURES
+
+ Id: 15
+ Equivalent ioctl: VHOST_GET_FEATURES
+ Master payload: N/A
+ Slave payload: u64
+
+ Get the protocol feature bitmask from the underlying vhost implementation.
+ Only legal if feature bit VHOST_USER_F_PROTOCOL_FEATURES is present in
+ VHOST_USER_GET_FEATURES.
+ Note: slave that reported VHOST_USER_F_PROTOCOL_FEATURES must support
+ this message even before VHOST_USER_SET_FEATURES was called.
+
+ * VHOST_USER_SET_PROTOCOL_FEATURES
+
+ Id: 16
+ Ioctl: VHOST_SET_FEATURES
+ Master payload: u64
+
+ Enable protocol features in the underlying vhost implementation.
+ Only legal if feature bit VHOST_USER_F_PROTOCOL_FEATURES is present in
+ VHOST_USER_GET_FEATURES.
+ Note: slave that reported VHOST_USER_F_PROTOCOL_FEATURES must support
+ this message even before VHOST_USER_SET_FEATURES was called.
* VHOST_USER_SET_OWNER
--
MST
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 12/22] vhost: rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
` (10 preceding siblings ...)
2015-09-24 13:20 ` [Qemu-devel] [PULL 11/22] vhost-user: add protocol feature negotiation Michael S. Tsirkin
@ 2015-09-24 13:20 ` Michael S. Tsirkin
2015-10-02 16:18 ` Paolo Bonzini
2015-09-24 13:20 ` [Qemu-devel] [PULL 13/22] vhost-user: add VHOST_USER_GET_QUEUE_NUM message Michael S. Tsirkin
` (11 subsequent siblings)
23 siblings, 1 reply; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:20 UTC (permalink / raw)
To: qemu-devel; +Cc: Marcel Apfelbaum, Peter Maydell, Yuanhan Liu
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Quote from Michael:
We really should rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE.
Suggested-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
---
| 2 +-
hw/net/vhost_net.c | 2 +-
hw/virtio/vhost-user.c | 6 +++---
tests/vhost-user-test.c | 2 +-
docs/specs/vhost-user.txt | 4 ++--
5 files changed, 8 insertions(+), 8 deletions(-)
--git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h
index ead86db..14a0160 100644
--- a/linux-headers/linux/vhost.h
+++ b/linux-headers/linux/vhost.h
@@ -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_OWNER _IO(VHOST_VIRTIO, 0x02)
+#define VHOST_RESET_DEVICE _IO(VHOST_VIRTIO, 0x02)
/* Set up/modify memory layout */
#define VHOST_SET_MEM_TABLE _IOW(VHOST_VIRTIO, 0x03, struct vhost_memory)
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 9d32d76..b7d29b7 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -287,7 +287,7 @@ static void vhost_net_stop_one(struct vhost_net *net,
} else if (net->nc->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER) {
for (file.index = 0; file.index < net->dev.nvqs; ++file.index) {
const VhostOps *vhost_ops = net->dev.vhost_ops;
- int r = vhost_ops->vhost_call(&net->dev, VHOST_RESET_OWNER,
+ int r = vhost_ops->vhost_call(&net->dev, VHOST_RESET_DEVICE,
NULL);
assert(r >= 0);
}
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 7fe35c6..9cb2f52 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -32,7 +32,7 @@ typedef enum VhostUserRequest {
VHOST_USER_GET_FEATURES = 1,
VHOST_USER_SET_FEATURES = 2,
VHOST_USER_SET_OWNER = 3,
- VHOST_USER_RESET_OWNER = 4,
+ VHOST_USER_RESET_DEVICE = 4,
VHOST_USER_SET_MEM_TABLE = 5,
VHOST_USER_SET_LOG_BASE = 6,
VHOST_USER_SET_LOG_FD = 7,
@@ -98,7 +98,7 @@ static unsigned long int ioctl_to_vhost_user_request[VHOST_USER_MAX] = {
VHOST_GET_FEATURES, /* VHOST_USER_GET_FEATURES */
VHOST_SET_FEATURES, /* VHOST_USER_SET_FEATURES */
VHOST_SET_OWNER, /* VHOST_USER_SET_OWNER */
- VHOST_RESET_OWNER, /* VHOST_USER_RESET_OWNER */
+ VHOST_RESET_DEVICE, /* VHOST_USER_RESET_DEVICE */
VHOST_SET_MEM_TABLE, /* VHOST_USER_SET_MEM_TABLE */
VHOST_SET_LOG_BASE, /* VHOST_USER_SET_LOG_BASE */
VHOST_SET_LOG_FD, /* VHOST_USER_SET_LOG_FD */
@@ -222,7 +222,7 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
break;
case VHOST_USER_SET_OWNER:
- case VHOST_USER_RESET_OWNER:
+ case VHOST_USER_RESET_DEVICE:
break;
case VHOST_USER_SET_MEM_TABLE:
diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 75fedf0..e301db7 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -58,7 +58,7 @@ typedef enum VhostUserRequest {
VHOST_USER_GET_FEATURES = 1,
VHOST_USER_SET_FEATURES = 2,
VHOST_USER_SET_OWNER = 3,
- VHOST_USER_RESET_OWNER = 4,
+ VHOST_USER_RESET_DEVICE = 4,
VHOST_USER_SET_MEM_TABLE = 5,
VHOST_USER_SET_LOG_BASE = 6,
VHOST_USER_SET_LOG_FD = 7,
diff --git a/docs/specs/vhost-user.txt b/docs/specs/vhost-user.txt
index 70da3b1..ccbbcbb 100644
--- a/docs/specs/vhost-user.txt
+++ b/docs/specs/vhost-user.txt
@@ -194,10 +194,10 @@ Message types
as an owner of the session. This can be used on the Slave as a
"session start" flag.
- * VHOST_USER_RESET_OWNER
+ * VHOST_USER_RESET_DEVICE
Id: 4
- Equivalent ioctl: VHOST_RESET_OWNER
+ Equivalent ioctl: VHOST_RESET_DEVICE
Master payload: N/A
Issued when a new connection is about to be closed. The Master will no
--
MST
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 13/22] vhost-user: add VHOST_USER_GET_QUEUE_NUM message
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
` (11 preceding siblings ...)
2015-09-24 13:20 ` [Qemu-devel] [PULL 12/22] vhost: rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE Michael S. Tsirkin
@ 2015-09-24 13:20 ` Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 14/22] vhost: introduce vhost_backend_get_vq_index method Michael S. Tsirkin
` (10 subsequent siblings)
23 siblings, 0 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:20 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Yuanhan Liu
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
This is for querying how many queues the backend supports if it has mq
support(when VHOST_USER_PROTOCOL_F_MQ flag is set from the quried
protocol features).
vhost_net_get_max_queues() is the interface to export that value, and
to tell if the backend supports # of queues user requested, which is
done in the following patch.
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
include/hw/virtio/vhost.h | 1 +
include/net/vhost_net.h | 1 +
hw/net/vhost_net.c | 12 ++++++++++++
hw/virtio/vhost-user.c | 15 ++++++++++++++-
docs/specs/vhost-user.txt | 11 +++++++++++
5 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h
index 6467c73..c3758f3 100644
--- a/include/hw/virtio/vhost.h
+++ b/include/hw/virtio/vhost.h
@@ -48,6 +48,7 @@ struct vhost_dev {
unsigned long long acked_features;
unsigned long long backend_features;
unsigned long long protocol_features;
+ unsigned long long max_queues;
bool started;
bool log_enabled;
unsigned long long log_size;
diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h
index 840d4b1..8db723e 100644
--- a/include/net/vhost_net.h
+++ b/include/net/vhost_net.h
@@ -13,6 +13,7 @@ typedef struct VhostNetOptions {
void *opaque;
} VhostNetOptions;
+uint64_t vhost_net_get_max_queues(VHostNetState *net);
struct vhost_net *vhost_net_init(VhostNetOptions *options);
int vhost_net_start(VirtIODevice *dev, NetClientState *ncs, int total_queues);
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index b7d29b7..f663e5a 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -122,6 +122,11 @@ void vhost_net_ack_features(struct vhost_net *net, uint64_t features)
vhost_ack_features(&net->dev, vhost_net_get_feature_bits(net), features);
}
+uint64_t vhost_net_get_max_queues(VHostNetState *net)
+{
+ return net->dev.max_queues;
+}
+
static int vhost_net_get_fd(NetClientState *backend)
{
switch (backend->info->type) {
@@ -144,6 +149,8 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
goto fail;
}
+ net->dev.max_queues = 1;
+
if (backend_kernel) {
r = vhost_net_get_fd(options->net_backend);
if (r < 0) {
@@ -414,6 +421,11 @@ VHostNetState *get_vhost_net(NetClientState *nc)
return vhost_net;
}
#else
+uint64_t vhost_net_get_max_queues(VHostNetState *net)
+{
+ return 1;
+}
+
struct vhost_net *vhost_net_init(VhostNetOptions *options)
{
error_report("vhost-net support is not compiled in");
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 9cb2f52..694fde5 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -25,7 +25,9 @@
#define VHOST_MEMORY_MAX_NREGIONS 8
#define VHOST_USER_F_PROTOCOL_FEATURES 30
-#define VHOST_USER_PROTOCOL_FEATURE_MASK 0x0ULL
+#define VHOST_USER_PROTOCOL_FEATURE_MASK 0x1ULL
+
+#define VHOST_USER_PROTOCOL_F_MQ 0
typedef enum VhostUserRequest {
VHOST_USER_NONE = 0,
@@ -45,6 +47,7 @@ typedef enum VhostUserRequest {
VHOST_USER_SET_VRING_ERR = 14,
VHOST_USER_GET_PROTOCOL_FEATURES = 15,
VHOST_USER_SET_PROTOCOL_FEATURES = 16,
+ VHOST_USER_GET_QUEUE_NUM = 17,
VHOST_USER_MAX
} VhostUserRequest;
@@ -211,6 +214,7 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
switch (msg_request) {
case VHOST_USER_GET_FEATURES:
case VHOST_USER_GET_PROTOCOL_FEATURES:
+ case VHOST_USER_GET_QUEUE_NUM:
need_reply = 1;
break;
@@ -315,6 +319,7 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
switch (msg_request) {
case VHOST_USER_GET_FEATURES:
case VHOST_USER_GET_PROTOCOL_FEATURES:
+ case VHOST_USER_GET_QUEUE_NUM:
if (msg.size != sizeof(m.u64)) {
error_report("Received bad msg size.");
return -1;
@@ -366,6 +371,14 @@ static int vhost_user_init(struct vhost_dev *dev, void *opaque)
if (err < 0) {
return err;
}
+
+ /* query the max queues we support if backend supports Multiple Queue */
+ if (dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_MQ)) {
+ err = vhost_user_call(dev, VHOST_USER_GET_QUEUE_NUM, &dev->max_queues);
+ if (err < 0) {
+ return err;
+ }
+ }
}
return 0;
diff --git a/docs/specs/vhost-user.txt b/docs/specs/vhost-user.txt
index ccbbcbb..43db9b4 100644
--- a/docs/specs/vhost-user.txt
+++ b/docs/specs/vhost-user.txt
@@ -301,3 +301,14 @@ Message types
Bits (0-7) of the payload contain the vring index. Bit 8 is the
invalid FD flag. This flag is set when there is no file descriptor
in the ancillary data.
+
+ * VHOST_USER_GET_QUEUE_NUM
+
+ Id: 17
+ Equivalent ioctl: N/A
+ Master payload: N/A
+ Slave payload: u64
+
+ Query how many queues the backend supports. This request should be
+ sent only when VHOST_USER_PROTOCOL_F_MQ is set in quried protocol
+ features by VHOST_USER_GET_PROTOCOL_FEATURES.
--
MST
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 14/22] vhost: introduce vhost_backend_get_vq_index method
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
` (12 preceding siblings ...)
2015-09-24 13:20 ` [Qemu-devel] [PULL 13/22] vhost-user: add VHOST_USER_GET_QUEUE_NUM message Michael S. Tsirkin
@ 2015-09-24 13:20 ` Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 15/22] vhost-user: add multiple queue support Michael S. Tsirkin
` (9 subsequent siblings)
23 siblings, 0 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:20 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Yuanhan Liu, Jason Wang
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Minusing the idx with the base(dev->vq_index) for vhost-kernel, and
then adding it back for vhost-user doesn't seem right. Here introduces
a new method vhost_backend_get_vq_index() for getting the right vq
index for following vhost messages calls.
Suggested-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
include/hw/virtio/vhost-backend.h | 2 ++
hw/virtio/vhost-backend.c | 10 +++++++++-
hw/virtio/vhost-user.c | 12 ++++++++++--
hw/virtio/vhost.c | 15 ++++++---------
4 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h
index e472f29..e1dfc6d 100644
--- a/include/hw/virtio/vhost-backend.h
+++ b/include/hw/virtio/vhost-backend.h
@@ -24,12 +24,14 @@ typedef int (*vhost_call)(struct vhost_dev *dev, unsigned long int request,
void *arg);
typedef int (*vhost_backend_init)(struct vhost_dev *dev, void *opaque);
typedef int (*vhost_backend_cleanup)(struct vhost_dev *dev);
+typedef int (*vhost_backend_get_vq_index)(struct vhost_dev *dev, int idx);
typedef struct VhostOps {
VhostBackendType backend_type;
vhost_call vhost_call;
vhost_backend_init vhost_backend_init;
vhost_backend_cleanup vhost_backend_cleanup;
+ vhost_backend_get_vq_index vhost_backend_get_vq_index;
} VhostOps;
extern const VhostOps user_ops;
diff --git a/hw/virtio/vhost-backend.c b/hw/virtio/vhost-backend.c
index 4d68a27..72d1392 100644
--- a/hw/virtio/vhost-backend.c
+++ b/hw/virtio/vhost-backend.c
@@ -42,11 +42,19 @@ static int vhost_kernel_cleanup(struct vhost_dev *dev)
return close(fd);
}
+static int vhost_kernel_get_vq_index(struct vhost_dev *dev, int idx)
+{
+ assert(idx >= dev->vq_index && idx < dev->vq_index + dev->nvqs);
+
+ return idx - dev->vq_index;
+}
+
static const VhostOps kernel_ops = {
.backend_type = VHOST_BACKEND_TYPE_KERNEL,
.vhost_call = vhost_kernel_call,
.vhost_backend_init = vhost_kernel_init,
- .vhost_backend_cleanup = vhost_kernel_cleanup
+ .vhost_backend_cleanup = vhost_kernel_cleanup,
+ .vhost_backend_get_vq_index = vhost_kernel_get_vq_index,
};
int vhost_set_backend_type(struct vhost_dev *dev, VhostBackendType backend_type)
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 694fde5..5018fd6 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -393,9 +393,17 @@ static int vhost_user_cleanup(struct vhost_dev *dev)
return 0;
}
+static int vhost_user_get_vq_index(struct vhost_dev *dev, int idx)
+{
+ assert(idx >= dev->vq_index && idx < dev->vq_index + dev->nvqs);
+
+ return idx;
+}
+
const VhostOps user_ops = {
.backend_type = VHOST_BACKEND_TYPE_USER,
.vhost_call = vhost_user_call,
.vhost_backend_init = vhost_user_init,
- .vhost_backend_cleanup = vhost_user_cleanup
- };
+ .vhost_backend_cleanup = vhost_user_cleanup,
+ .vhost_backend_get_vq_index = vhost_user_get_vq_index,
+};
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index a08c36b..7a7812d 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -719,7 +719,7 @@ static int vhost_virtqueue_start(struct vhost_dev *dev,
{
hwaddr s, l, a;
int r;
- int vhost_vq_index = idx - dev->vq_index;
+ int vhost_vq_index = dev->vhost_ops->vhost_backend_get_vq_index(dev, idx);
struct vhost_vring_file file = {
.index = vhost_vq_index
};
@@ -728,7 +728,6 @@ static int vhost_virtqueue_start(struct vhost_dev *dev,
};
struct VirtQueue *vvq = virtio_get_queue(vdev, idx);
- assert(idx >= dev->vq_index && idx < dev->vq_index + dev->nvqs);
vq->num = state.num = virtio_queue_get_num(vdev, idx);
r = dev->vhost_ops->vhost_call(dev, VHOST_SET_VRING_NUM, &state);
@@ -822,12 +821,12 @@ static void vhost_virtqueue_stop(struct vhost_dev *dev,
struct vhost_virtqueue *vq,
unsigned idx)
{
- int vhost_vq_index = idx - dev->vq_index;
+ int vhost_vq_index = dev->vhost_ops->vhost_backend_get_vq_index(dev, idx);
struct vhost_vring_state state = {
.index = vhost_vq_index,
};
int r;
- assert(idx >= dev->vq_index && idx < dev->vq_index + dev->nvqs);
+
r = dev->vhost_ops->vhost_call(dev, VHOST_GET_VRING_BASE, &state);
if (r < 0) {
fprintf(stderr, "vhost VQ %d ring restore failed: %d\n", idx, r);
@@ -1066,17 +1065,15 @@ void vhost_virtqueue_mask(struct vhost_dev *hdev, VirtIODevice *vdev, int n,
{
struct VirtQueue *vvq = virtio_get_queue(vdev, n);
int r, index = n - hdev->vq_index;
+ struct vhost_vring_file file;
- assert(n >= hdev->vq_index && n < hdev->vq_index + hdev->nvqs);
-
- struct vhost_vring_file file = {
- .index = index
- };
if (mask) {
file.fd = event_notifier_get_fd(&hdev->vqs[index].masked_notifier);
} else {
file.fd = event_notifier_get_fd(virtio_queue_get_guest_notifier(vvq));
}
+
+ file.index = hdev->vhost_ops->vhost_backend_get_vq_index(hdev, n);
r = hdev->vhost_ops->vhost_call(hdev, VHOST_SET_VRING_CALL, &file);
assert(r >= 0);
}
--
MST
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 15/22] vhost-user: add multiple queue support
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
` (13 preceding siblings ...)
2015-09-24 13:20 ` [Qemu-devel] [PULL 14/22] vhost: introduce vhost_backend_get_vq_index method Michael S. Tsirkin
@ 2015-09-24 13:20 ` Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 16/22] vhost-user: add a new message to disable/enable a specific virt queue Michael S. Tsirkin
` (8 subsequent siblings)
23 siblings, 0 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:20 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Yuanhan Liu, Jason Wang, Markus Armbruster,
Nikolay Nikolaev, Changchun Ouyang
From: Changchun Ouyang <changchun.ouyang@intel.com>
This patch is initially based a patch from Nikolay Nikolaev.
This patch adds vhost-user multiple queue support, by creating a nc
and vhost_net pair for each queue.
Qemu exits if find that the backend can't support the number of requested
queues (by providing queues=# option). The max number is queried by a
new message, VHOST_USER_GET_QUEUE_NUM, and is sent only when protocol
feature VHOST_USER_PROTOCOL_F_MQ is present first.
The max queue check is done at vhost-user initiation stage. We initiate
one queue first, which, in the meantime, also gets the max_queues the
backend supports.
In older version, it was reported that some messages are sent more times
than necessary. Here we came an agreement with Michael that we could
categorize vhost user messages to 2 types: non-vring specific messages,
which should be sent only once, and vring specific messages, which should
be sent per queue.
Here I introduced a helper function vhost_user_one_time_request(), which
lists following messages as non-vring specific messages:
VHOST_USER_SET_OWNER
VHOST_USER_RESET_DEVICE
VHOST_USER_SET_MEM_TABLE
VHOST_USER_GET_QUEUE_NUM
For above messages, we simply ignore them when they are not sent the first
time.
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Signed-off-by: Changchun Ouyang <changchun.ouyang@intel.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Jason Wang <jasowang@redhat.com>
---
qapi-schema.json | 6 +-
hw/net/vhost_net.c | 10 ++--
hw/virtio/vhost-user.c | 22 ++++++++
hw/virtio/vhost.c | 5 +-
net/vhost-user.c | 141 ++++++++++++++++++++++++++++++----------------
docs/specs/vhost-user.txt | 15 +++++
qemu-options.hx | 5 +-
7 files changed, 147 insertions(+), 57 deletions(-)
diff --git a/qapi-schema.json b/qapi-schema.json
index 527690d..582a817 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -2481,12 +2481,16 @@
#
# @vhostforce: #optional vhost on for non-MSIX virtio guests (default: false).
#
+# @queues: #optional number of queues to be created for multiqueue vhost-user
+# (default: 1) (Since 2.5)
+#
# Since 2.1
##
{ 'struct': 'NetdevVhostUserOptions',
'data': {
'chardev': 'str',
- '*vhostforce': 'bool' } }
+ '*vhostforce': 'bool',
+ '*queues': 'int' } }
##
# @NetClientOptions
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index f663e5a..ad82b5c 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -148,8 +148,11 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
fprintf(stderr, "vhost-net requires net backend to be setup\n");
goto fail;
}
+ net->nc = options->net_backend;
net->dev.max_queues = 1;
+ net->dev.nvqs = 2;
+ net->dev.vqs = net->vqs;
if (backend_kernel) {
r = vhost_net_get_fd(options->net_backend);
@@ -164,11 +167,10 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options)
net->dev.backend_features = 0;
net->dev.protocol_features = 0;
net->backend = -1;
- }
- net->nc = options->net_backend;
- net->dev.nvqs = 2;
- net->dev.vqs = net->vqs;
+ /* vhost-user needs vq_index to initiate a specific queue pair */
+ net->dev.vq_index = net->nc->queue_index * net->dev.nvqs;
+ }
r = vhost_dev_init(&net->dev, options->opaque,
options->backend_type);
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 5018fd6..e42fde6 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -187,6 +187,19 @@ static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg,
0 : -1;
}
+static bool vhost_user_one_time_request(VhostUserRequest request)
+{
+ switch (request) {
+ case VHOST_USER_SET_OWNER:
+ case VHOST_USER_RESET_DEVICE:
+ case VHOST_USER_SET_MEM_TABLE:
+ case VHOST_USER_GET_QUEUE_NUM:
+ return true;
+ default:
+ return false;
+ }
+}
+
static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
void *arg)
{
@@ -207,6 +220,15 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
msg_request = request;
}
+ /*
+ * For non-vring specific requests, like VHOST_USER_SET_MEM_TABLE,
+ * we just need send it once in the first time. For later such
+ * request, we just ignore it.
+ */
+ if (vhost_user_one_time_request(msg_request) && dev->vq_index != 0) {
+ return 0;
+ }
+
msg.request = msg_request;
msg.flags = VHOST_USER_VERSION;
msg.size = 0;
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 7a7812d..c0ed5b2 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -874,8 +874,9 @@ static void vhost_eventfd_del(MemoryListener *listener,
static int vhost_virtqueue_init(struct vhost_dev *dev,
struct vhost_virtqueue *vq, int n)
{
+ int vhost_vq_index = dev->vhost_ops->vhost_backend_get_vq_index(dev, n);
struct vhost_vring_file file = {
- .index = n,
+ .index = vhost_vq_index,
};
int r = event_notifier_init(&vq->masked_notifier, 0);
if (r < 0) {
@@ -926,7 +927,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque,
}
for (i = 0; i < hdev->nvqs; ++i) {
- r = vhost_virtqueue_init(hdev, hdev->vqs + i, i);
+ r = vhost_virtqueue_init(hdev, hdev->vqs + i, hdev->vq_index + i);
if (r < 0) {
goto fail_vq;
}
diff --git a/net/vhost-user.c b/net/vhost-user.c
index 93dcecd..8f354eb 100644
--- a/net/vhost-user.c
+++ b/net/vhost-user.c
@@ -14,6 +14,7 @@
#include "sysemu/char.h"
#include "qemu/config-file.h"
#include "qemu/error-report.h"
+#include "qmp-commands.h"
typedef struct VhostUserState {
NetClientState nc;
@@ -39,37 +40,77 @@ static int vhost_user_running(VhostUserState *s)
return (s->vhost_net) ? 1 : 0;
}
-static int vhost_user_start(VhostUserState *s)
+static void vhost_user_stop(int queues, NetClientState *ncs[])
{
- VhostNetOptions options;
-
- if (vhost_user_running(s)) {
- return 0;
- }
+ VhostUserState *s;
+ int i;
- options.backend_type = VHOST_BACKEND_TYPE_USER;
- options.net_backend = &s->nc;
- options.opaque = s->chr;
+ for (i = 0; i < queues; i++) {
+ assert (ncs[i]->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER);
- s->vhost_net = vhost_net_init(&options);
+ s = DO_UPCAST(VhostUserState, nc, ncs[i]);
+ if (!vhost_user_running(s)) {
+ continue;
+ }
- return vhost_user_running(s) ? 0 : -1;
+ if (s->vhost_net) {
+ vhost_net_cleanup(s->vhost_net);
+ s->vhost_net = NULL;
+ }
+ }
}
-static void vhost_user_stop(VhostUserState *s)
+static int vhost_user_start(int queues, NetClientState *ncs[])
{
- if (vhost_user_running(s)) {
- vhost_net_cleanup(s->vhost_net);
+ VhostNetOptions options;
+ VhostUserState *s;
+ int max_queues;
+ int i;
+
+ options.backend_type = VHOST_BACKEND_TYPE_USER;
+
+ for (i = 0; i < queues; i++) {
+ assert (ncs[i]->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER);
+
+ s = DO_UPCAST(VhostUserState, nc, ncs[i]);
+ if (vhost_user_running(s)) {
+ continue;
+ }
+
+ options.net_backend = ncs[i];
+ options.opaque = s->chr;
+ s->vhost_net = vhost_net_init(&options);
+ if (!s->vhost_net) {
+ error_report("failed to init vhost_net for queue %d\n", i);
+ goto err;
+ }
+
+ if (i == 0) {
+ max_queues = vhost_net_get_max_queues(s->vhost_net);
+ if (queues > max_queues) {
+ error_report("you are asking more queues than "
+ "supported: %d\n", max_queues);
+ goto err;
+ }
+ }
}
- s->vhost_net = 0;
+ return 0;
+
+err:
+ vhost_user_stop(i + 1, ncs);
+ return -1;
}
static void vhost_user_cleanup(NetClientState *nc)
{
VhostUserState *s = DO_UPCAST(VhostUserState, nc, nc);
- vhost_user_stop(s);
+ if (s->vhost_net) {
+ vhost_net_cleanup(s->vhost_net);
+ s->vhost_net = NULL;
+ }
+
qemu_purge_queued_packets(nc);
}
@@ -95,59 +136,61 @@ static NetClientInfo net_vhost_user_info = {
.has_ufo = vhost_user_has_ufo,
};
-static void net_vhost_link_down(VhostUserState *s, bool link_down)
-{
- s->nc.link_down = link_down;
-
- if (s->nc.peer) {
- s->nc.peer->link_down = link_down;
- }
-
- if (s->nc.info->link_status_changed) {
- s->nc.info->link_status_changed(&s->nc);
- }
-
- if (s->nc.peer && s->nc.peer->info->link_status_changed) {
- s->nc.peer->info->link_status_changed(s->nc.peer);
- }
-}
-
static void net_vhost_user_event(void *opaque, int event)
{
- VhostUserState *s = opaque;
+ const char *name = opaque;
+ NetClientState *ncs[MAX_QUEUE_NUM];
+ VhostUserState *s;
+ Error *err = NULL;
+ int queues;
+ queues = qemu_find_net_clients_except(name, ncs,
+ NET_CLIENT_OPTIONS_KIND_NIC,
+ MAX_QUEUE_NUM);
+ s = DO_UPCAST(VhostUserState, nc, ncs[0]);
switch (event) {
case CHR_EVENT_OPENED:
- vhost_user_start(s);
- net_vhost_link_down(s, false);
+ if (vhost_user_start(queues, ncs) < 0) {
+ exit(1);
+ }
+ qmp_set_link(name, true, &err);
error_report("chardev \"%s\" went up", s->chr->label);
break;
case CHR_EVENT_CLOSED:
- net_vhost_link_down(s, true);
- vhost_user_stop(s);
+ qmp_set_link(name, true, &err);
+ vhost_user_stop(queues, ncs);
error_report("chardev \"%s\" went down", s->chr->label);
break;
}
+
+ if (err) {
+ error_report_err(err);
+ }
}
static int net_vhost_user_init(NetClientState *peer, const char *device,
- const char *name, CharDriverState *chr)
+ const char *name, CharDriverState *chr,
+ int queues)
{
NetClientState *nc;
VhostUserState *s;
+ int i;
- nc = qemu_new_net_client(&net_vhost_user_info, peer, device, name);
+ for (i = 0; i < queues; i++) {
+ nc = qemu_new_net_client(&net_vhost_user_info, peer, device, name);
- snprintf(nc->info_str, sizeof(nc->info_str), "vhost-user to %s",
- chr->label);
+ snprintf(nc->info_str, sizeof(nc->info_str), "vhost-user%d to %s",
+ i, chr->label);
- s = DO_UPCAST(VhostUserState, nc, nc);
+ /* We don't provide a receive callback */
+ nc->receive_disabled = 1;
+ nc->queue_index = i;
- /* We don't provide a receive callback */
- s->nc.receive_disabled = 1;
- s->chr = chr;
+ s = DO_UPCAST(VhostUserState, nc, nc);
+ s->chr = chr;
+ }
- qemu_chr_add_handlers(s->chr, NULL, NULL, net_vhost_user_event, s);
+ qemu_chr_add_handlers(chr, NULL, NULL, net_vhost_user_event, (void*)name);
return 0;
}
@@ -226,6 +269,7 @@ static int net_vhost_check_net(void *opaque, QemuOpts *opts, Error **errp)
int net_init_vhost_user(const NetClientOptions *opts, const char *name,
NetClientState *peer, Error **errp)
{
+ int queues;
const NetdevVhostUserOptions *vhost_user_opts;
CharDriverState *chr;
@@ -243,6 +287,7 @@ int net_init_vhost_user(const NetClientOptions *opts, const char *name,
return -1;
}
+ queues = vhost_user_opts->has_queues ? vhost_user_opts->queues : 1;
- return net_vhost_user_init(peer, "vhost_user", name, chr);
+ return net_vhost_user_init(peer, "vhost_user", name, chr, queues);
}
diff --git a/docs/specs/vhost-user.txt b/docs/specs/vhost-user.txt
index 43db9b4..cfc9d41 100644
--- a/docs/specs/vhost-user.txt
+++ b/docs/specs/vhost-user.txt
@@ -135,6 +135,21 @@ As older slaves don't support negotiating protocol features,
a feature bit was dedicated for this purpose:
#define VHOST_USER_F_PROTOCOL_FEATURES 30
+Multiple queue support
+----------------------
+
+Multiple queue is treated as a protocol extension, hence the slave has to
+implement protocol features first. The multiple queues feature is supported
+only when the protocol feature VHOST_USER_PROTOCOL_F_MQ (bit 0) is set:
+#define VHOST_USER_PROTOCOL_F_MQ 0
+
+The max number of queues the slave supports can be queried with message
+VHOST_USER_GET_PROTOCOL_FEATURES. Master should stop when the number of
+requested queues is bigger than that.
+
+As all queues share one connection, the master uses a unique index for each
+queue in the sent message to identify a specified queue.
+
Message types
-------------
diff --git a/qemu-options.hx b/qemu-options.hx
index 7e147b8..328404c 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -1990,13 +1990,14 @@ The hubport netdev lets you connect a NIC to a QEMU "vlan" instead of a single
netdev. @code{-net} and @code{-device} with parameter @option{vlan} create the
required hub automatically.
-@item -netdev vhost-user,chardev=@var{id}[,vhostforce=on|off]
+@item -netdev vhost-user,chardev=@var{id}[,vhostforce=on|off][,queues=n]
Establish a vhost-user netdev, backed by a chardev @var{id}. The chardev should
be a unix domain socket backed one. The vhost-user uses a specifically defined
protocol to pass vhost ioctl replacement messages to an application on the other
end of the socket. On non-MSIX guests, the feature can be forced with
-@var{vhostforce}.
+@var{vhostforce}. Use 'queues=@var{n}' to specify the number of queues to
+be created for multiqueue vhost-user.
Example:
@example
--
MST
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 16/22] vhost-user: add a new message to disable/enable a specific virt queue.
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
` (14 preceding siblings ...)
2015-09-24 13:20 ` [Qemu-devel] [PULL 15/22] vhost-user: add multiple queue support Michael S. Tsirkin
@ 2015-09-24 13:20 ` Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 17/22] intel_iommu: Add support for translation for devices behind bridges Michael S. Tsirkin
` (7 subsequent siblings)
23 siblings, 0 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:20 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Yuanhan Liu, Jason Wang, Changchun Ouyang
From: Changchun Ouyang <changchun.ouyang@intel.com>
Add a new message, VHOST_USER_SET_VRING_ENABLE, to enable or disable
a specific virt queue, which is similar to attach/detach queue for
tap device.
virtio driver on guest doesn't have to use max virt queue pair, it
could enable any number of virt queue ranging from 1 to max virt
queue pair.
Signed-off-by: Changchun Ouyang <changchun.ouyang@intel.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Jason Wang <jasowang@redhat.com>
---
include/hw/virtio/vhost-backend.h | 2 ++
include/net/vhost_net.h | 2 ++
hw/net/vhost_net.c | 18 ++++++++++++++++++
hw/net/virtio-net.c | 8 ++++++++
hw/virtio/vhost-user.c | 19 +++++++++++++++++++
docs/specs/vhost-user.txt | 12 +++++++++++-
6 files changed, 60 insertions(+), 1 deletion(-)
diff --git a/include/hw/virtio/vhost-backend.h b/include/hw/virtio/vhost-backend.h
index e1dfc6d..3a0f6e2 100644
--- a/include/hw/virtio/vhost-backend.h
+++ b/include/hw/virtio/vhost-backend.h
@@ -25,6 +25,7 @@ typedef int (*vhost_call)(struct vhost_dev *dev, unsigned long int request,
typedef int (*vhost_backend_init)(struct vhost_dev *dev, void *opaque);
typedef int (*vhost_backend_cleanup)(struct vhost_dev *dev);
typedef int (*vhost_backend_get_vq_index)(struct vhost_dev *dev, int idx);
+typedef int (*vhost_backend_set_vring_enable)(struct vhost_dev *dev, int enable);
typedef struct VhostOps {
VhostBackendType backend_type;
@@ -32,6 +33,7 @@ typedef struct VhostOps {
vhost_backend_init vhost_backend_init;
vhost_backend_cleanup vhost_backend_cleanup;
vhost_backend_get_vq_index vhost_backend_get_vq_index;
+ vhost_backend_set_vring_enable vhost_backend_set_vring_enable;
} VhostOps;
extern const VhostOps user_ops;
diff --git a/include/net/vhost_net.h b/include/net/vhost_net.h
index 8db723e..0188c4d 100644
--- a/include/net/vhost_net.h
+++ b/include/net/vhost_net.h
@@ -28,4 +28,6 @@ bool vhost_net_virtqueue_pending(VHostNetState *net, int n);
void vhost_net_virtqueue_mask(VHostNetState *net, VirtIODevice *dev,
int idx, bool mask);
VHostNetState *get_vhost_net(NetClientState *nc);
+
+int vhost_set_vring_enable(NetClientState * nc, int enable);
#endif
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index ad82b5c..2bce891 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -422,6 +422,19 @@ VHostNetState *get_vhost_net(NetClientState *nc)
return vhost_net;
}
+
+int vhost_set_vring_enable(NetClientState *nc, int enable)
+{
+ VHostNetState *net = get_vhost_net(nc);
+ const VhostOps *vhost_ops = net->dev.vhost_ops;
+
+ if (vhost_ops->vhost_backend_set_vring_enable) {
+ return vhost_ops->vhost_backend_set_vring_enable(&net->dev, enable);
+ }
+
+ return 0;
+}
+
#else
uint64_t vhost_net_get_max_queues(VHostNetState *net)
{
@@ -472,4 +485,9 @@ VHostNetState *get_vhost_net(NetClientState *nc)
{
return 0;
}
+
+int vhost_set_vring_enable(NetClientState *nc, int enable)
+{
+ return 0;
+}
#endif
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 2775e6a..d388c55 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -406,6 +406,10 @@ static int peer_attach(VirtIONet *n, int index)
return 0;
}
+ if (nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER) {
+ vhost_set_vring_enable(nc->peer, 1);
+ }
+
if (nc->peer->info->type != NET_CLIENT_OPTIONS_KIND_TAP) {
return 0;
}
@@ -421,6 +425,10 @@ static int peer_detach(VirtIONet *n, int index)
return 0;
}
+ if (nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER) {
+ vhost_set_vring_enable(nc->peer, 0);
+ }
+
if (nc->peer->info->type != NET_CLIENT_OPTIONS_KIND_TAP) {
return 0;
}
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index e42fde6..b11c0d2 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -48,6 +48,7 @@ typedef enum VhostUserRequest {
VHOST_USER_GET_PROTOCOL_FEATURES = 15,
VHOST_USER_SET_PROTOCOL_FEATURES = 16,
VHOST_USER_GET_QUEUE_NUM = 17,
+ VHOST_USER_SET_VRING_ENABLE = 18,
VHOST_USER_MAX
} VhostUserRequest;
@@ -290,6 +291,7 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
case VHOST_USER_SET_VRING_NUM:
case VHOST_USER_SET_VRING_BASE:
+ case VHOST_USER_SET_VRING_ENABLE:
memcpy(&msg.state, arg, sizeof(struct vhost_vring_state));
msg.size = sizeof(m.state);
break;
@@ -406,6 +408,22 @@ static int vhost_user_init(struct vhost_dev *dev, void *opaque)
return 0;
}
+static int vhost_user_set_vring_enable(struct vhost_dev *dev, int enable)
+{
+ struct vhost_vring_state state = {
+ .index = dev->vq_index,
+ .num = enable,
+ };
+
+ assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER);
+
+ if (!(dev->protocol_features & (1ULL << VHOST_USER_PROTOCOL_F_MQ))) {
+ return -1;
+ }
+
+ return vhost_user_call(dev, VHOST_USER_SET_VRING_ENABLE, &state);
+}
+
static int vhost_user_cleanup(struct vhost_dev *dev)
{
assert(dev->vhost_ops->backend_type == VHOST_BACKEND_TYPE_USER);
@@ -428,4 +446,5 @@ const VhostOps user_ops = {
.vhost_backend_init = vhost_user_init,
.vhost_backend_cleanup = vhost_user_cleanup,
.vhost_backend_get_vq_index = vhost_user_get_vq_index,
+ .vhost_backend_set_vring_enable = vhost_user_set_vring_enable,
};
diff --git a/docs/specs/vhost-user.txt b/docs/specs/vhost-user.txt
index cfc9d41..4eadad1 100644
--- a/docs/specs/vhost-user.txt
+++ b/docs/specs/vhost-user.txt
@@ -148,7 +148,9 @@ VHOST_USER_GET_PROTOCOL_FEATURES. Master should stop when the number of
requested queues is bigger than that.
As all queues share one connection, the master uses a unique index for each
-queue in the sent message to identify a specified queue.
+queue in the sent message to identify a specified queue. One queue pair
+is enabled initially. More queues are enabled dynamically, by sending
+message VHOST_USER_SET_VRING_ENABLE.
Message types
-------------
@@ -327,3 +329,11 @@ Message types
Query how many queues the backend supports. This request should be
sent only when VHOST_USER_PROTOCOL_F_MQ is set in quried protocol
features by VHOST_USER_GET_PROTOCOL_FEATURES.
+
+ * VHOST_USER_SET_VRING_ENABLE
+
+ Id: 18
+ Equivalent ioctl: N/A
+ Master payload: vring state description
+
+ Signal slave to enable or disable corresponding vring.
--
MST
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 17/22] intel_iommu: Add support for translation for devices behind bridges
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
` (15 preceding siblings ...)
2015-09-24 13:20 ` [Qemu-devel] [PULL 16/22] vhost-user: add a new message to disable/enable a specific virt queue Michael S. Tsirkin
@ 2015-09-24 13:20 ` Michael S. Tsirkin
2015-09-25 6:43 ` Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 18/22] MAINTAINERS: add more devices to the PC section Michael S. Tsirkin
` (6 subsequent siblings)
23 siblings, 1 reply; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:20 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Richard Henderson, Knut Omang, Eduardo Habkost,
Paolo Bonzini
From: Knut Omang <knut.omang@oracle.com>
- Use a hash table indexed on bus pointers to store information about buses
instead of using the bus numbers.
Bus pointers are stored in a new VTDBus struct together with the vector
of device address space pointers indexed by devfn.
- The bus number is still used for lookup for selective SID based invalidate,
in which case the bus number is lazily resolved from the bus hash table and
cached in a separate index.
Signed-off-by: Knut Omang <knut.omang@oracle.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/i386/intel_iommu.h | 16 +++++++-
hw/i386/intel_iommu.c | 90 +++++++++++++++++++++++++++++++++++--------
hw/pci-host/q35.c | 25 ++----------
3 files changed, 91 insertions(+), 40 deletions(-)
diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h
index e321ee4..5dbadb7 100644
--- a/include/hw/i386/intel_iommu.h
+++ b/include/hw/i386/intel_iommu.h
@@ -49,6 +49,7 @@ typedef struct VTDContextCacheEntry VTDContextCacheEntry;
typedef struct IntelIOMMUState IntelIOMMUState;
typedef struct VTDAddressSpace VTDAddressSpace;
typedef struct VTDIOTLBEntry VTDIOTLBEntry;
+typedef struct VTDBus VTDBus;
/* Context-Entry */
struct VTDContextEntry {
@@ -65,7 +66,7 @@ struct VTDContextCacheEntry {
};
struct VTDAddressSpace {
- uint8_t bus_num;
+ PCIBus *bus;
uint8_t devfn;
AddressSpace as;
MemoryRegion iommu;
@@ -73,6 +74,11 @@ struct VTDAddressSpace {
VTDContextCacheEntry context_cache_entry;
};
+struct VTDBus {
+ PCIBus* bus; /* A reference to the bus to provide translation for */
+ VTDAddressSpace *dev_as[0]; /* A table of VTDAddressSpace objects indexed by devfn */
+};
+
struct VTDIOTLBEntry {
uint64_t gfn;
uint16_t domain_id;
@@ -114,7 +120,13 @@ struct IntelIOMMUState {
GHashTable *iotlb; /* IOTLB */
MemoryRegionIOMMUOps iommu_ops;
- VTDAddressSpace **address_spaces[VTD_PCI_BUS_MAX];
+ GHashTable *vtd_as_by_busptr; /* VTDBus objects indexed by PCIBus* reference */
+ VTDBus *vtd_as_by_bus_num[VTD_PCI_BUS_MAX]; /* VTDBus objects indexed by bus number */
};
+/* Find the VTD Address space associated with the given bus pointer,
+ * create a new one if none exists
+ */
+VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn);
+
#endif
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 08055a8..da67c36 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -22,6 +22,7 @@
#include "hw/sysbus.h"
#include "exec/address-spaces.h"
#include "intel_iommu_internal.h"
+#include "hw/pci/pci.h"
/*#define DEBUG_INTEL_IOMMU*/
#ifdef DEBUG_INTEL_IOMMU
@@ -166,19 +167,17 @@ static gboolean vtd_hash_remove_by_page(gpointer key, gpointer value,
*/
static void vtd_reset_context_cache(IntelIOMMUState *s)
{
- VTDAddressSpace **pvtd_as;
VTDAddressSpace *vtd_as;
- uint32_t bus_it;
+ VTDBus *vtd_bus;
+ GHashTableIter bus_it;
uint32_t devfn_it;
+ g_hash_table_iter_init(&bus_it, s->vtd_as_by_busptr);
+
VTD_DPRINTF(CACHE, "global context_cache_gen=1");
- for (bus_it = 0; bus_it < VTD_PCI_BUS_MAX; ++bus_it) {
- pvtd_as = s->address_spaces[bus_it];
- if (!pvtd_as) {
- continue;
- }
+ while (g_hash_table_iter_next (&bus_it, NULL, (void**)&vtd_bus)) {
for (devfn_it = 0; devfn_it < VTD_PCI_DEVFN_MAX; ++devfn_it) {
- vtd_as = pvtd_as[devfn_it];
+ vtd_as = vtd_bus->dev_as[devfn_it];
if (!vtd_as) {
continue;
}
@@ -754,12 +753,13 @@ static inline bool vtd_is_interrupt_addr(hwaddr addr)
* @is_write: The access is a write operation
* @entry: IOMMUTLBEntry that contain the addr to be translated and result
*/
-static void vtd_do_iommu_translate(VTDAddressSpace *vtd_as, uint8_t bus_num,
+static void vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus *bus,
uint8_t devfn, hwaddr addr, bool is_write,
IOMMUTLBEntry *entry)
{
IntelIOMMUState *s = vtd_as->iommu_state;
VTDContextEntry ce;
+ uint8_t bus_num = pci_bus_num(bus);
VTDContextCacheEntry *cc_entry = &vtd_as->context_cache_entry;
uint64_t slpte;
uint32_t level;
@@ -874,6 +874,30 @@ static void vtd_context_global_invalidate(IntelIOMMUState *s)
}
}
+
+/* Find the VTD address space currently associated with a given bus number,
+ */
+static VTDBus *vtd_find_as_from_bus_num(IntelIOMMUState *s, uint8_t bus_num)
+{
+ VTDBus *vtd_bus = s->vtd_as_by_bus_num[bus_num];
+ if (!vtd_bus) {
+ /* Iterate over the registered buses to find the one
+ * which currently hold this bus number, and update the bus_num lookup table:
+ */
+ GHashTableIter iter;
+ uint64_t key;
+
+ g_hash_table_iter_init(&iter, s->vtd_as_by_busptr);
+ while (g_hash_table_iter_next (&iter, (void**)&key, (void**)&vtd_bus)) {
+ if (pci_bus_num(vtd_bus->bus) == bus_num) {
+ s->vtd_as_by_bus_num[bus_num] = vtd_bus;
+ return vtd_bus;
+ }
+ }
+ }
+ return vtd_bus;
+}
+
/* Do a context-cache device-selective invalidation.
* @func_mask: FM field after shifting
*/
@@ -882,7 +906,7 @@ static void vtd_context_device_invalidate(IntelIOMMUState *s,
uint16_t func_mask)
{
uint16_t mask;
- VTDAddressSpace **pvtd_as;
+ VTDBus *vtd_bus;
VTDAddressSpace *vtd_as;
uint16_t devfn;
uint16_t devfn_it;
@@ -903,11 +927,11 @@ static void vtd_context_device_invalidate(IntelIOMMUState *s,
}
VTD_DPRINTF(INV, "device-selective invalidation source 0x%"PRIx16
" mask %"PRIu16, source_id, mask);
- pvtd_as = s->address_spaces[VTD_SID_TO_BUS(source_id)];
- if (pvtd_as) {
+ vtd_bus = vtd_find_as_from_bus_num(s, VTD_SID_TO_BUS(source_id));
+ if (vtd_bus) {
devfn = VTD_SID_TO_DEVFN(source_id);
for (devfn_it = 0; devfn_it < VTD_PCI_DEVFN_MAX; ++devfn_it) {
- vtd_as = pvtd_as[devfn_it];
+ vtd_as = vtd_bus->dev_as[devfn_it];
if (vtd_as && ((devfn_it & mask) == (devfn & mask))) {
VTD_DPRINTF(INV, "invalidate context-cahce of devfn 0x%"PRIx16,
devfn_it);
@@ -1805,11 +1829,11 @@ static IOMMUTLBEntry vtd_iommu_translate(MemoryRegion *iommu, hwaddr addr,
return ret;
}
- vtd_do_iommu_translate(vtd_as, vtd_as->bus_num, vtd_as->devfn, addr,
+ vtd_do_iommu_translate(vtd_as, vtd_as->bus, vtd_as->devfn, addr,
is_write, &ret);
VTD_DPRINTF(MMU,
"bus %"PRIu8 " slot %"PRIu8 " func %"PRIu8 " devfn %"PRIu8
- " gpa 0x%"PRIx64 " hpa 0x%"PRIx64, vtd_as->bus_num,
+ " gpa 0x%"PRIx64 " hpa 0x%"PRIx64, pci_bus_num(vtd_as->bus),
VTD_PCI_SLOT(vtd_as->devfn), VTD_PCI_FUNC(vtd_as->devfn),
vtd_as->devfn, addr, ret.translated_addr);
return ret;
@@ -1839,6 +1863,38 @@ static Property vtd_properties[] = {
DEFINE_PROP_END_OF_LIST(),
};
+
+VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn)
+{
+ uint64_t key = (uint64_t)bus;
+ VTDBus *vtd_bus = g_hash_table_lookup(s->vtd_as_by_busptr, &key);
+ VTDAddressSpace *vtd_dev_as;
+
+ if (!vtd_bus) {
+ /* No corresponding free() */
+ vtd_bus = g_malloc0(sizeof(VTDBus) + sizeof(VTDAddressSpace *) * VTD_PCI_DEVFN_MAX);
+ vtd_bus->bus = bus;
+ key = (uint64_t)bus;
+ g_hash_table_add(s->vtd_as_by_busptr, vtd_bus);
+ }
+
+ vtd_dev_as = vtd_bus->dev_as[devfn];
+
+ if (!vtd_dev_as) {
+ vtd_bus->dev_as[devfn] = vtd_dev_as = g_malloc0(sizeof(VTDAddressSpace));
+
+ vtd_dev_as->bus = bus;
+ vtd_dev_as->devfn = (uint8_t)devfn;
+ vtd_dev_as->iommu_state = s;
+ vtd_dev_as->context_cache_entry.context_cache_gen = 0;
+ memory_region_init_iommu(&vtd_dev_as->iommu, OBJECT(s),
+ &s->iommu_ops, "intel_iommu", UINT64_MAX);
+ address_space_init(&vtd_dev_as->as,
+ &vtd_dev_as->iommu, "intel_iommu");
+ }
+ return vtd_dev_as;
+}
+
/* Do the initialization. It will also be called when reset, so pay
* attention when adding new initialization stuff.
*/
@@ -1931,13 +1987,15 @@ static void vtd_realize(DeviceState *dev, Error **errp)
IntelIOMMUState *s = INTEL_IOMMU_DEVICE(dev);
VTD_DPRINTF(GENERAL, "");
- memset(s->address_spaces, 0, sizeof(s->address_spaces));
+ memset(s->vtd_as_by_bus_num, 0, sizeof(s->vtd_as_by_bus_num));
memory_region_init_io(&s->csrmem, OBJECT(s), &vtd_mem_ops, s,
"intel_iommu", DMAR_REG_SIZE);
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->csrmem);
/* No corresponding destroy */
s->iotlb = g_hash_table_new_full(vtd_uint64_hash, vtd_uint64_equal,
g_free, g_free);
+ s->vtd_as_by_busptr = g_hash_table_new_full(vtd_uint64_hash, vtd_uint64_equal,
+ g_free, g_free);
vtd_init(s);
}
diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index bd74094..c81507d 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -426,31 +426,12 @@ static void mch_reset(DeviceState *qdev)
static AddressSpace *q35_host_dma_iommu(PCIBus *bus, void *opaque, int devfn)
{
IntelIOMMUState *s = opaque;
- VTDAddressSpace **pvtd_as;
- int bus_num = pci_bus_num(bus);
+ VTDAddressSpace *vtd_as;
- assert(0 <= bus_num && bus_num <= VTD_PCI_BUS_MAX);
assert(0 <= devfn && devfn <= VTD_PCI_DEVFN_MAX);
- pvtd_as = s->address_spaces[bus_num];
- if (!pvtd_as) {
- /* No corresponding free() */
- pvtd_as = g_malloc0(sizeof(VTDAddressSpace *) * VTD_PCI_DEVFN_MAX);
- s->address_spaces[bus_num] = pvtd_as;
- }
- if (!pvtd_as[devfn]) {
- pvtd_as[devfn] = g_malloc0(sizeof(VTDAddressSpace));
-
- pvtd_as[devfn]->bus_num = (uint8_t)bus_num;
- pvtd_as[devfn]->devfn = (uint8_t)devfn;
- pvtd_as[devfn]->iommu_state = s;
- pvtd_as[devfn]->context_cache_entry.context_cache_gen = 0;
- memory_region_init_iommu(&pvtd_as[devfn]->iommu, OBJECT(s),
- &s->iommu_ops, "intel_iommu", UINT64_MAX);
- address_space_init(&pvtd_as[devfn]->as,
- &pvtd_as[devfn]->iommu, "intel_iommu");
- }
- return &pvtd_as[devfn]->as;
+ vtd_as = vtd_find_add_as(s, bus, devfn);
+ return &vtd_as->as;
}
static void mch_init_dmar(MCHPCIState *mch)
--
MST
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 18/22] MAINTAINERS: add more devices to the PC section
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
` (16 preceding siblings ...)
2015-09-24 13:20 ` [Qemu-devel] [PULL 17/22] intel_iommu: Add support for translation for devices behind bridges Michael S. Tsirkin
@ 2015-09-24 13:20 ` Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 19/22] MAINTAINERS: add more devices to the PCI section Michael S. Tsirkin
` (5 subsequent siblings)
23 siblings, 0 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:20 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Peter Maydell, Amit Shah, Stefan Hajnoczi,
Paolo Bonzini
From: Paolo Bonzini <pbonzini@redhat.com>
For chipset devices, I can co-maintain it with Michael.
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
MAINTAINERS | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 71c652b..583d4af 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -601,6 +601,25 @@ F: hw/acpi/piix4.c
F: hw/acpi/ich9.c
F: include/hw/acpi/ich9.h
F: include/hw/acpi/piix.h
+F: hw/misc/sga.c
+
+PC Chipset
+M: Michael S. Tsirkin <mst@redhat.com>
+M: Paolo Bonzini <pbonzini@redhat.com>
+S: Support
+F: hw/char/debugcon.c
+F: hw/char/parallel.c
+F: hw/char/serial*
+F: hw/dma/i8257*
+F: hw/i2c/pm_smbus.c
+F: hw/intc/apic*
+F: hw/intc/ioapic*
+F: hw/intc/i8259*
+F: hw/misc/debugexit.c
+F: hw/misc/pc-testdev.c
+F: hw/timer/hpet*
+F: hw/timer/i8254*
+F: hw/timer/mc146818rtc*
Xtensa Machines
--
MST
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 19/22] MAINTAINERS: add more devices to the PCI section
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
` (17 preceding siblings ...)
2015-09-24 13:20 ` [Qemu-devel] [PULL 18/22] MAINTAINERS: add more devices to the PC section Michael S. Tsirkin
@ 2015-09-24 13:20 ` Michael S. Tsirkin
2015-09-24 13:21 ` [Qemu-devel] [PULL 20/22] virtio: introduce virtqueue_unmap_sg() Michael S. Tsirkin
` (4 subsequent siblings)
23 siblings, 0 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:20 UTC (permalink / raw)
To: qemu-devel
Cc: Kevin Wolf, Peter Maydell, Markus Armbruster, Stefan Hajnoczi,
Amit Shah, Paolo Bonzini
From: Paolo Bonzini <pbonzini@redhat.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
MAINTAINERS | 2 ++
1 file changed, 2 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 583d4af..b2e5fbd 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -672,7 +672,9 @@ PCI
M: Michael S. Tsirkin <mst@redhat.com>
S: Supported
F: include/hw/pci/*
+F: hw/misc/pci-testdev.c
F: hw/pci/*
+F: hw/pci-bridge/*
ACPI/SMBIOS
M: Michael S. Tsirkin <mst@redhat.com>
--
MST
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 20/22] virtio: introduce virtqueue_unmap_sg()
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
` (18 preceding siblings ...)
2015-09-24 13:20 ` [Qemu-devel] [PULL 19/22] MAINTAINERS: add more devices to the PCI section Michael S. Tsirkin
@ 2015-09-24 13:21 ` Michael S. Tsirkin
2015-09-24 18:58 ` Michael S. Tsirkin
2015-09-24 13:21 ` [Qemu-devel] [PULL 21/22] virtio: introduce virtqueue_discard() Michael S. Tsirkin
` (3 subsequent siblings)
23 siblings, 1 reply; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:21 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Jason Wang
From: Jason Wang <jasowang@redhat.com>
Factor out sg unmapping logic. This will be reused by the patch that
can discard descriptor.
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/virtio/virtio.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 7504f8b..d6a2bca 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -244,15 +244,12 @@ int virtio_queue_empty(VirtQueue *vq)
return vring_avail_idx(vq) == vq->last_avail_idx;
}
-void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
- unsigned int len, unsigned int idx)
+static void virtqueue_unmap_sg(VirtQueue *vq, const VirtQueueElement *elem,
+ unsigned int len)
{
unsigned int offset;
int i;
- trace_virtqueue_fill(vq, elem, len, idx);
-
- offset = 0;
for (i = 0; i < elem->in_num; i++) {
size_t size = MIN(len - offset, elem->in_sg[i].iov_len);
@@ -267,6 +264,14 @@ void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
cpu_physical_memory_unmap(elem->out_sg[i].iov_base,
elem->out_sg[i].iov_len,
0, elem->out_sg[i].iov_len);
+}
+
+void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
+ unsigned int len, unsigned int idx)
+{
+ trace_virtqueue_fill(vq, elem, len, idx);
+
+ virtqueue_unmap_sg(vq, elem, len);
idx = (idx + vring_used_idx(vq)) % vq->vring.num;
--
MST
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 21/22] virtio: introduce virtqueue_discard()
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
` (19 preceding siblings ...)
2015-09-24 13:21 ` [Qemu-devel] [PULL 20/22] virtio: introduce virtqueue_unmap_sg() Michael S. Tsirkin
@ 2015-09-24 13:21 ` Michael S. Tsirkin
2015-09-24 13:21 ` [Qemu-devel] [PULL 22/22] virtio-net: correctly drop truncated packets Michael S. Tsirkin
` (2 subsequent siblings)
23 siblings, 0 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:21 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Jason Wang
From: Jason Wang <jasowang@redhat.com>
This patch introduces virtqueue_discard() to discard a descriptor and
unmap the sgs. This will be used by the patch that will discard
descriptor when packet is truncated.
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/hw/virtio/virtio.h | 2 ++
hw/virtio/virtio.c | 7 +++++++
2 files changed, 9 insertions(+)
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 6201ee8..9d09115 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -146,6 +146,8 @@ void virtio_del_queue(VirtIODevice *vdev, int n);
void virtqueue_push(VirtQueue *vq, const VirtQueueElement *elem,
unsigned int len);
void virtqueue_flush(VirtQueue *vq, unsigned int count);
+void virtqueue_discard(VirtQueue *vq, const VirtQueueElement *elem,
+ unsigned int len);
void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
unsigned int len, unsigned int idx);
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index d6a2bca..c9bf10c 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -266,6 +266,13 @@ static void virtqueue_unmap_sg(VirtQueue *vq, const VirtQueueElement *elem,
0, elem->out_sg[i].iov_len);
}
+void virtqueue_discard(VirtQueue *vq, const VirtQueueElement *elem,
+ unsigned int len)
+{
+ vq->last_avail_idx--;
+ virtqueue_unmap_sg(vq, elem, len);
+}
+
void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
unsigned int len, unsigned int idx)
{
--
MST
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 22/22] virtio-net: correctly drop truncated packets
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
` (20 preceding siblings ...)
2015-09-24 13:21 ` [Qemu-devel] [PULL 21/22] virtio: introduce virtqueue_discard() Michael S. Tsirkin
@ 2015-09-24 13:21 ` Michael S. Tsirkin
2015-09-24 13:30 ` [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
2015-09-24 18:36 ` Peter Maydell
23 siblings, 0 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:21 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Jason Wang
From: Jason Wang <jasowang@redhat.com>
When packet is truncated during receiving, we drop the packets but
neither discard the descriptor nor add and signal used
descriptor. This will lead several issues:
- sg mappings are leaked
- rx will be stalled if a lots of packets were truncated
In order to be consistent with vhost, fix by discarding the descriptor
in this case.
Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/net/virtio-net.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index d388c55..a877614 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1094,13 +1094,7 @@ static ssize_t virtio_net_receive(NetClientState *nc, const uint8_t *buf, size_t
* must have consumed the complete packet.
* Otherwise, drop it. */
if (!n->mergeable_rx_bufs && offset < size) {
-#if 0
- error_report("virtio-net truncated non-mergeable packet: "
- "i %zd mergeable %d offset %zd, size %zd, "
- "guest hdr len %zd, host hdr len %zd",
- i, n->mergeable_rx_bufs,
- offset, size, n->guest_hdr_len, n->host_hdr_len);
-#endif
+ virtqueue_discard(q->rx_vq, &elem, total);
return size;
}
--
MST
^ permalink raw reply related [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 00/22] virtio,pc features, fixes
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
` (21 preceding siblings ...)
2015-09-24 13:21 ` [Qemu-devel] [PULL 22/22] virtio-net: correctly drop truncated packets Michael S. Tsirkin
@ 2015-09-24 13:30 ` Michael S. Tsirkin
2015-09-24 18:36 ` Peter Maydell
23 siblings, 0 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 13:30 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell
On Thu, Sep 24, 2015 at 04:20:03PM +0300, Michael S. Tsirkin wrote:
> The following changes since commit fefa4b128de06cec6d513f00ee61e8208aed4a87:
>
> Merge remote-tracking branch 'remotes/awilliam/tags/vfio-update-20150923.0' into staging (2015-09-23 21:39:46 +0100)
>
> 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 27fa11c68072398beb31af8828e25da5c2295814:
>
> virtio-net: correctly drop truncated packets (2015-09-24 16:16:24 +0300)
I tweaked a commit log for a couple of the patches by adding
Marcel's Tested-by tag.
No other changes. The new tip is 56204f322bcafefb8a0afb637f350a68cadc5c98
> ----------------------------------------------------------------
> virtio,pc features, fixes
>
> New features:
> vhost-user multiqueue support
> virtio-ccw virtio 1 support
> pci bridge support in iommu
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>
> ----------------------------------------------------------------
> Changchun Ouyang (2):
> vhost-user: add multiple queue support
> vhost-user: add a new message to disable/enable a specific virt queue.
>
> Cornelia Huck (4):
> virtio: ring sizes vs. reset
> virtio-ccw: support ring size changes
> virtio-ccw: feature bits > 31 handling
> virtio-ccw: enable virtio-1
>
> Eduardo Habkost (3):
> q35: Move options common to all classes to pc_q35_machine_options()
> q35: Move options common to all classes to pc_i440fx_machine_options()
> pc: Introduce pc-*-2.5 machine classes
>
> Jason Wang (4):
> virtio-net: unbreak self announcement and guest offloads after migration
> virtio: introduce virtqueue_unmap_sg()
> virtio: introduce virtqueue_discard()
> virtio-net: correctly drop truncated packets
>
> Knut Omang (1):
> intel_iommu: Add support for translation for devices behind bridges
>
> Michael S. Tsirkin (1):
> vhost-user: add protocol feature negotiation
>
> Paolo Bonzini (2):
> MAINTAINERS: add more devices to the PC section
> MAINTAINERS: add more devices to the PCI section
>
> Pierre Morel (1):
> virtio: right size for virtio_queue_get_avail_size
>
> Yuanhan Liu (4):
> vhost-user: use VHOST_USER_XXX macro for switch statement
> vhost: rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE
> vhost-user: add VHOST_USER_GET_QUEUE_NUM message
> vhost: introduce vhost_backend_get_vq_index method
>
> qapi-schema.json | 6 +-
> hw/s390x/virtio-ccw.h | 6 +-
> include/hw/compat.h | 3 +
> include/hw/i386/intel_iommu.h | 16 ++++-
> include/hw/i386/pc.h | 4 ++
> include/hw/virtio/vhost-backend.h | 4 ++
> include/hw/virtio/vhost.h | 2 +
> include/hw/virtio/virtio.h | 2 +
> include/net/vhost_net.h | 3 +
> linux-headers/linux/vhost.h | 2 +-
> hw/i386/intel_iommu.c | 90 +++++++++++++++++++-----
> hw/i386/pc_piix.c | 22 ++++--
> hw/i386/pc_q35.c | 22 ++++--
> hw/net/vhost_net.c | 44 ++++++++++--
> hw/net/virtio-net.c | 56 ++++++++-------
> hw/pci-host/q35.c | 25 +------
> hw/s390x/s390-virtio-ccw.c | 20 ++++++
> hw/s390x/virtio-ccw.c | 64 ++++++++++++-----
> hw/virtio/vhost-backend.c | 10 ++-
> hw/virtio/vhost-user.c | 139 +++++++++++++++++++++++++++++++------
> hw/virtio/vhost.c | 20 +++---
> hw/virtio/virtio.c | 88 ++++++++++++++++++++++--
> net/vhost-user.c | 141 +++++++++++++++++++++++++-------------
> tests/vhost-user-test.c | 2 +-
> MAINTAINERS | 21 ++++++
> docs/specs/vhost-user.txt | 77 ++++++++++++++++++++-
> qemu-options.hx | 5 +-
> 27 files changed, 701 insertions(+), 193 deletions(-)
>
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 00/22] virtio,pc features, fixes
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
` (22 preceding siblings ...)
2015-09-24 13:30 ` [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
@ 2015-09-24 18:36 ` Peter Maydell
2015-09-24 18:57 ` Michael S. Tsirkin
23 siblings, 1 reply; 37+ messages in thread
From: Peter Maydell @ 2015-09-24 18:36 UTC (permalink / raw)
To: Michael S. Tsirkin; +Cc: QEMU Developers
On 24 September 2015 at 06:20, Michael S. Tsirkin <mst@redhat.com> wrote:
> The following changes since commit fefa4b128de06cec6d513f00ee61e8208aed4a87:
>
> Merge remote-tracking branch 'remotes/awilliam/tags/vfio-update-20150923.0' into staging (2015-09-23 21:39:46 +0100)
>
> 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 27fa11c68072398beb31af8828e25da5c2295814:
>
> virtio-net: correctly drop truncated packets (2015-09-24 16:16:24 +0300)
>
> ----------------------------------------------------------------
> virtio,pc features, fixes
>
> New features:
> vhost-user multiqueue support
> virtio-ccw virtio 1 support
> pci bridge support in iommu
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Fails to build:
/home/petmay01/linaro/qemu-for-merges/hw/virtio/virtio.c: In function
‘virtqueue_unmap_sg.isra.21’:
/home/petmay01/linaro/qemu-for-merges/hw/virtio/virtio.c:260:16:
error: ‘offset’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
offset += size;
^
(both gcc and clang complain about this).
thanks
-- PMM
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 00/22] virtio,pc features, fixes
2015-09-24 18:36 ` Peter Maydell
@ 2015-09-24 18:57 ` Michael S. Tsirkin
0 siblings, 0 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 18:57 UTC (permalink / raw)
To: Peter Maydell; +Cc: QEMU Developers
On Thu, Sep 24, 2015 at 11:36:35AM -0700, Peter Maydell wrote:
> On 24 September 2015 at 06:20, Michael S. Tsirkin <mst@redhat.com> wrote:
> > The following changes since commit fefa4b128de06cec6d513f00ee61e8208aed4a87:
> >
> > Merge remote-tracking branch 'remotes/awilliam/tags/vfio-update-20150923.0' into staging (2015-09-23 21:39:46 +0100)
> >
> > 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 27fa11c68072398beb31af8828e25da5c2295814:
> >
> > virtio-net: correctly drop truncated packets (2015-09-24 16:16:24 +0300)
> >
> > ----------------------------------------------------------------
> > virtio,pc features, fixes
> >
> > New features:
> > vhost-user multiqueue support
> > virtio-ccw virtio 1 support
> > pci bridge support in iommu
> >
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>
> Fails to build:
>
> /home/petmay01/linaro/qemu-for-merges/hw/virtio/virtio.c: In function
> ‘virtqueue_unmap_sg.isra.21’:
> /home/petmay01/linaro/qemu-for-merges/hw/virtio/virtio.c:260:16:
> error: ‘offset’ may be used uninitialized in this function
> [-Werror=maybe-uninitialized]
> offset += size;
> ^
>
> (both gcc and clang complain about this).
>
> thanks
> -- PMM
Sorry about that, I will investiage.
I dropped this patch for now, since these are the last
to patches, it was easy with no need to rebase.
Could you please fetch from same tag?
--
MST
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 20/22] virtio: introduce virtqueue_unmap_sg()
2015-09-24 13:21 ` [Qemu-devel] [PULL 20/22] virtio: introduce virtqueue_unmap_sg() Michael S. Tsirkin
@ 2015-09-24 18:58 ` Michael S. Tsirkin
2015-09-25 3:26 ` Jason Wang
0 siblings, 1 reply; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-24 18:58 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Jason Wang
On Thu, Sep 24, 2015 at 04:21:02PM +0300, Michael S. Tsirkin wrote:
> From: Jason Wang <jasowang@redhat.com>
>
> Factor out sg unmapping logic. This will be reused by the patch that
> can discard descriptor.
>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> hw/virtio/virtio.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index 7504f8b..d6a2bca 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -244,15 +244,12 @@ int virtio_queue_empty(VirtQueue *vq)
> return vring_avail_idx(vq) == vq->last_avail_idx;
> }
>
> -void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
> - unsigned int len, unsigned int idx)
> +static void virtqueue_unmap_sg(VirtQueue *vq, const VirtQueueElement *elem,
> + unsigned int len)
> {
> unsigned int offset;
> int i;
>
> - trace_virtqueue_fill(vq, elem, len, idx);
> -
> - offset = 0;
> for (i = 0; i < elem->in_num; i++) {
> size_t size = MIN(len - offset, elem->in_sg[i].iov_len);
>
This part causes an unitialized variable warning to appear.
I dropped this from the pull request.
Jason, could you look into this please?
> @@ -267,6 +264,14 @@ void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
> cpu_physical_memory_unmap(elem->out_sg[i].iov_base,
> elem->out_sg[i].iov_len,
> 0, elem->out_sg[i].iov_len);
> +}
> +
> +void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
> + unsigned int len, unsigned int idx)
> +{
> + trace_virtqueue_fill(vq, elem, len, idx);
> +
> + virtqueue_unmap_sg(vq, elem, len);
>
> idx = (idx + vring_used_idx(vq)) % vq->vring.num;
>
> --
> MST
>
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 20/22] virtio: introduce virtqueue_unmap_sg()
2015-09-24 18:58 ` Michael S. Tsirkin
@ 2015-09-25 3:26 ` Jason Wang
0 siblings, 0 replies; 37+ messages in thread
From: Jason Wang @ 2015-09-25 3:26 UTC (permalink / raw)
To: Michael S. Tsirkin, qemu-devel; +Cc: Peter Maydell
On 09/25/2015 02:58 AM, Michael S. Tsirkin wrote:
> On Thu, Sep 24, 2015 at 04:21:02PM +0300, Michael S. Tsirkin wrote:
>> From: Jason Wang <jasowang@redhat.com>
>>
>> Factor out sg unmapping logic. This will be reused by the patch that
>> can discard descriptor.
>>
>> Cc: Michael S. Tsirkin <mst@redhat.com>
>> Signed-off-by: Jason Wang <jasowang@redhat.com>
>> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>> ---
>> hw/virtio/virtio.c | 15 ++++++++++-----
>> 1 file changed, 10 insertions(+), 5 deletions(-)
>>
>> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
>> index 7504f8b..d6a2bca 100644
>> --- a/hw/virtio/virtio.c
>> +++ b/hw/virtio/virtio.c
>> @@ -244,15 +244,12 @@ int virtio_queue_empty(VirtQueue *vq)
>> return vring_avail_idx(vq) == vq->last_avail_idx;
>> }
>>
>> -void virtqueue_fill(VirtQueue *vq, const VirtQueueElement *elem,
>> - unsigned int len, unsigned int idx)
>> +static void virtqueue_unmap_sg(VirtQueue *vq, const VirtQueueElement *elem,
>> + unsigned int len)
>> {
>> unsigned int offset;
>> int i;
>>
>> - trace_virtqueue_fill(vq, elem, len, idx);
>> -
>> - offset = 0;
>> for (i = 0; i < elem->in_num; i++) {
>> size_t size = MIN(len - offset, elem->in_sg[i].iov_len);
>>
> This part causes an unitialized variable warning to appear.
> I dropped this from the pull request.
> Jason, could you look into this please?
>
Will fix this in V2.
Thanks
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 17/22] intel_iommu: Add support for translation for devices behind bridges
2015-09-24 13:20 ` [Qemu-devel] [PULL 17/22] intel_iommu: Add support for translation for devices behind bridges Michael S. Tsirkin
@ 2015-09-25 6:43 ` Michael S. Tsirkin
2015-09-25 7:33 ` Knut Omang
0 siblings, 1 reply; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-09-25 6:43 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Richard Henderson, Knut Omang, Eduardo Habkost,
Paolo Bonzini
On Thu, Sep 24, 2015 at 04:20:53PM +0300, Michael S. Tsirkin wrote:
> From: Knut Omang <knut.omang@oracle.com>
>
> - Use a hash table indexed on bus pointers to store information about buses
> instead of using the bus numbers.
> Bus pointers are stored in a new VTDBus struct together with the vector
> of device address space pointers indexed by devfn.
> - The bus number is still used for lookup for selective SID based invalidate,
> in which case the bus number is lazily resolved from the bus hash table and
> cached in a separate index.
>
> Signed-off-by: Knut Omang <knut.omang@oracle.com>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This fails to build with our minimal glib version:
Undefined symbols for architecture x86_64:
"_g_hash_table_add", referenced from:
_vtd_find_add_as in intel_iommu.o
SETFILE lm32-softmmu/qemu-system-lm32
g_hash_table_add only appeared in glib 2.32; our minimum
is 2.22.
Dropped this patch for now, please fix and repost.
> ---
> include/hw/i386/intel_iommu.h | 16 +++++++-
> hw/i386/intel_iommu.c | 90 +++++++++++++++++++++++++++++++++++--------
> hw/pci-host/q35.c | 25 ++----------
> 3 files changed, 91 insertions(+), 40 deletions(-)
>
> diff --git a/include/hw/i386/intel_iommu.h b/include/hw/i386/intel_iommu.h
> index e321ee4..5dbadb7 100644
> --- a/include/hw/i386/intel_iommu.h
> +++ b/include/hw/i386/intel_iommu.h
> @@ -49,6 +49,7 @@ typedef struct VTDContextCacheEntry VTDContextCacheEntry;
> typedef struct IntelIOMMUState IntelIOMMUState;
> typedef struct VTDAddressSpace VTDAddressSpace;
> typedef struct VTDIOTLBEntry VTDIOTLBEntry;
> +typedef struct VTDBus VTDBus;
>
> /* Context-Entry */
> struct VTDContextEntry {
> @@ -65,7 +66,7 @@ struct VTDContextCacheEntry {
> };
>
> struct VTDAddressSpace {
> - uint8_t bus_num;
> + PCIBus *bus;
> uint8_t devfn;
> AddressSpace as;
> MemoryRegion iommu;
> @@ -73,6 +74,11 @@ struct VTDAddressSpace {
> VTDContextCacheEntry context_cache_entry;
> };
>
> +struct VTDBus {
> + PCIBus* bus; /* A reference to the bus to provide translation for */
> + VTDAddressSpace *dev_as[0]; /* A table of VTDAddressSpace objects indexed by devfn */
> +};
> +
> struct VTDIOTLBEntry {
> uint64_t gfn;
> uint16_t domain_id;
> @@ -114,7 +120,13 @@ struct IntelIOMMUState {
> GHashTable *iotlb; /* IOTLB */
>
> MemoryRegionIOMMUOps iommu_ops;
> - VTDAddressSpace **address_spaces[VTD_PCI_BUS_MAX];
> + GHashTable *vtd_as_by_busptr; /* VTDBus objects indexed by PCIBus* reference */
> + VTDBus *vtd_as_by_bus_num[VTD_PCI_BUS_MAX]; /* VTDBus objects indexed by bus number */
> };
>
> +/* Find the VTD Address space associated with the given bus pointer,
> + * create a new one if none exists
> + */
> +VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn);
> +
> #endif
> diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
> index 08055a8..da67c36 100644
> --- a/hw/i386/intel_iommu.c
> +++ b/hw/i386/intel_iommu.c
> @@ -22,6 +22,7 @@
> #include "hw/sysbus.h"
> #include "exec/address-spaces.h"
> #include "intel_iommu_internal.h"
> +#include "hw/pci/pci.h"
>
> /*#define DEBUG_INTEL_IOMMU*/
> #ifdef DEBUG_INTEL_IOMMU
> @@ -166,19 +167,17 @@ static gboolean vtd_hash_remove_by_page(gpointer key, gpointer value,
> */
> static void vtd_reset_context_cache(IntelIOMMUState *s)
> {
> - VTDAddressSpace **pvtd_as;
> VTDAddressSpace *vtd_as;
> - uint32_t bus_it;
> + VTDBus *vtd_bus;
> + GHashTableIter bus_it;
> uint32_t devfn_it;
>
> + g_hash_table_iter_init(&bus_it, s->vtd_as_by_busptr);
> +
> VTD_DPRINTF(CACHE, "global context_cache_gen=1");
> - for (bus_it = 0; bus_it < VTD_PCI_BUS_MAX; ++bus_it) {
> - pvtd_as = s->address_spaces[bus_it];
> - if (!pvtd_as) {
> - continue;
> - }
> + while (g_hash_table_iter_next (&bus_it, NULL, (void**)&vtd_bus)) {
> for (devfn_it = 0; devfn_it < VTD_PCI_DEVFN_MAX; ++devfn_it) {
> - vtd_as = pvtd_as[devfn_it];
> + vtd_as = vtd_bus->dev_as[devfn_it];
> if (!vtd_as) {
> continue;
> }
> @@ -754,12 +753,13 @@ static inline bool vtd_is_interrupt_addr(hwaddr addr)
> * @is_write: The access is a write operation
> * @entry: IOMMUTLBEntry that contain the addr to be translated and result
> */
> -static void vtd_do_iommu_translate(VTDAddressSpace *vtd_as, uint8_t bus_num,
> +static void vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus *bus,
> uint8_t devfn, hwaddr addr, bool is_write,
> IOMMUTLBEntry *entry)
> {
> IntelIOMMUState *s = vtd_as->iommu_state;
> VTDContextEntry ce;
> + uint8_t bus_num = pci_bus_num(bus);
> VTDContextCacheEntry *cc_entry = &vtd_as->context_cache_entry;
> uint64_t slpte;
> uint32_t level;
> @@ -874,6 +874,30 @@ static void vtd_context_global_invalidate(IntelIOMMUState *s)
> }
> }
>
> +
> +/* Find the VTD address space currently associated with a given bus number,
> + */
> +static VTDBus *vtd_find_as_from_bus_num(IntelIOMMUState *s, uint8_t bus_num)
> +{
> + VTDBus *vtd_bus = s->vtd_as_by_bus_num[bus_num];
> + if (!vtd_bus) {
> + /* Iterate over the registered buses to find the one
> + * which currently hold this bus number, and update the bus_num lookup table:
> + */
> + GHashTableIter iter;
> + uint64_t key;
> +
> + g_hash_table_iter_init(&iter, s->vtd_as_by_busptr);
> + while (g_hash_table_iter_next (&iter, (void**)&key, (void**)&vtd_bus)) {
> + if (pci_bus_num(vtd_bus->bus) == bus_num) {
> + s->vtd_as_by_bus_num[bus_num] = vtd_bus;
> + return vtd_bus;
> + }
> + }
> + }
> + return vtd_bus;
> +}
> +
> /* Do a context-cache device-selective invalidation.
> * @func_mask: FM field after shifting
> */
> @@ -882,7 +906,7 @@ static void vtd_context_device_invalidate(IntelIOMMUState *s,
> uint16_t func_mask)
> {
> uint16_t mask;
> - VTDAddressSpace **pvtd_as;
> + VTDBus *vtd_bus;
> VTDAddressSpace *vtd_as;
> uint16_t devfn;
> uint16_t devfn_it;
> @@ -903,11 +927,11 @@ static void vtd_context_device_invalidate(IntelIOMMUState *s,
> }
> VTD_DPRINTF(INV, "device-selective invalidation source 0x%"PRIx16
> " mask %"PRIu16, source_id, mask);
> - pvtd_as = s->address_spaces[VTD_SID_TO_BUS(source_id)];
> - if (pvtd_as) {
> + vtd_bus = vtd_find_as_from_bus_num(s, VTD_SID_TO_BUS(source_id));
> + if (vtd_bus) {
> devfn = VTD_SID_TO_DEVFN(source_id);
> for (devfn_it = 0; devfn_it < VTD_PCI_DEVFN_MAX; ++devfn_it) {
> - vtd_as = pvtd_as[devfn_it];
> + vtd_as = vtd_bus->dev_as[devfn_it];
> if (vtd_as && ((devfn_it & mask) == (devfn & mask))) {
> VTD_DPRINTF(INV, "invalidate context-cahce of devfn 0x%"PRIx16,
> devfn_it);
> @@ -1805,11 +1829,11 @@ static IOMMUTLBEntry vtd_iommu_translate(MemoryRegion *iommu, hwaddr addr,
> return ret;
> }
>
> - vtd_do_iommu_translate(vtd_as, vtd_as->bus_num, vtd_as->devfn, addr,
> + vtd_do_iommu_translate(vtd_as, vtd_as->bus, vtd_as->devfn, addr,
> is_write, &ret);
> VTD_DPRINTF(MMU,
> "bus %"PRIu8 " slot %"PRIu8 " func %"PRIu8 " devfn %"PRIu8
> - " gpa 0x%"PRIx64 " hpa 0x%"PRIx64, vtd_as->bus_num,
> + " gpa 0x%"PRIx64 " hpa 0x%"PRIx64, pci_bus_num(vtd_as->bus),
> VTD_PCI_SLOT(vtd_as->devfn), VTD_PCI_FUNC(vtd_as->devfn),
> vtd_as->devfn, addr, ret.translated_addr);
> return ret;
> @@ -1839,6 +1863,38 @@ static Property vtd_properties[] = {
> DEFINE_PROP_END_OF_LIST(),
> };
>
> +
> +VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus, int devfn)
> +{
> + uint64_t key = (uint64_t)bus;
> + VTDBus *vtd_bus = g_hash_table_lookup(s->vtd_as_by_busptr, &key);
> + VTDAddressSpace *vtd_dev_as;
> +
> + if (!vtd_bus) {
> + /* No corresponding free() */
> + vtd_bus = g_malloc0(sizeof(VTDBus) + sizeof(VTDAddressSpace *) * VTD_PCI_DEVFN_MAX);
> + vtd_bus->bus = bus;
> + key = (uint64_t)bus;
> + g_hash_table_add(s->vtd_as_by_busptr, vtd_bus);
> + }
> +
> + vtd_dev_as = vtd_bus->dev_as[devfn];
> +
> + if (!vtd_dev_as) {
> + vtd_bus->dev_as[devfn] = vtd_dev_as = g_malloc0(sizeof(VTDAddressSpace));
> +
> + vtd_dev_as->bus = bus;
> + vtd_dev_as->devfn = (uint8_t)devfn;
> + vtd_dev_as->iommu_state = s;
> + vtd_dev_as->context_cache_entry.context_cache_gen = 0;
> + memory_region_init_iommu(&vtd_dev_as->iommu, OBJECT(s),
> + &s->iommu_ops, "intel_iommu", UINT64_MAX);
> + address_space_init(&vtd_dev_as->as,
> + &vtd_dev_as->iommu, "intel_iommu");
> + }
> + return vtd_dev_as;
> +}
> +
> /* Do the initialization. It will also be called when reset, so pay
> * attention when adding new initialization stuff.
> */
> @@ -1931,13 +1987,15 @@ static void vtd_realize(DeviceState *dev, Error **errp)
> IntelIOMMUState *s = INTEL_IOMMU_DEVICE(dev);
>
> VTD_DPRINTF(GENERAL, "");
> - memset(s->address_spaces, 0, sizeof(s->address_spaces));
> + memset(s->vtd_as_by_bus_num, 0, sizeof(s->vtd_as_by_bus_num));
> memory_region_init_io(&s->csrmem, OBJECT(s), &vtd_mem_ops, s,
> "intel_iommu", DMAR_REG_SIZE);
> sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->csrmem);
> /* No corresponding destroy */
> s->iotlb = g_hash_table_new_full(vtd_uint64_hash, vtd_uint64_equal,
> g_free, g_free);
> + s->vtd_as_by_busptr = g_hash_table_new_full(vtd_uint64_hash, vtd_uint64_equal,
> + g_free, g_free);
> vtd_init(s);
> }
>
> diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
> index bd74094..c81507d 100644
> --- a/hw/pci-host/q35.c
> +++ b/hw/pci-host/q35.c
> @@ -426,31 +426,12 @@ static void mch_reset(DeviceState *qdev)
> static AddressSpace *q35_host_dma_iommu(PCIBus *bus, void *opaque, int devfn)
> {
> IntelIOMMUState *s = opaque;
> - VTDAddressSpace **pvtd_as;
> - int bus_num = pci_bus_num(bus);
> + VTDAddressSpace *vtd_as;
>
> - assert(0 <= bus_num && bus_num <= VTD_PCI_BUS_MAX);
> assert(0 <= devfn && devfn <= VTD_PCI_DEVFN_MAX);
>
> - pvtd_as = s->address_spaces[bus_num];
> - if (!pvtd_as) {
> - /* No corresponding free() */
> - pvtd_as = g_malloc0(sizeof(VTDAddressSpace *) * VTD_PCI_DEVFN_MAX);
> - s->address_spaces[bus_num] = pvtd_as;
> - }
> - if (!pvtd_as[devfn]) {
> - pvtd_as[devfn] = g_malloc0(sizeof(VTDAddressSpace));
> -
> - pvtd_as[devfn]->bus_num = (uint8_t)bus_num;
> - pvtd_as[devfn]->devfn = (uint8_t)devfn;
> - pvtd_as[devfn]->iommu_state = s;
> - pvtd_as[devfn]->context_cache_entry.context_cache_gen = 0;
> - memory_region_init_iommu(&pvtd_as[devfn]->iommu, OBJECT(s),
> - &s->iommu_ops, "intel_iommu", UINT64_MAX);
> - address_space_init(&pvtd_as[devfn]->as,
> - &pvtd_as[devfn]->iommu, "intel_iommu");
> - }
> - return &pvtd_as[devfn]->as;
> + vtd_as = vtd_find_add_as(s, bus, devfn);
> + return &vtd_as->as;
> }
>
> static void mch_init_dmar(MCHPCIState *mch)
> --
> MST
>
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 17/22] intel_iommu: Add support for translation for devices behind bridges
2015-09-25 6:43 ` Michael S. Tsirkin
@ 2015-09-25 7:33 ` Knut Omang
0 siblings, 0 replies; 37+ messages in thread
From: Knut Omang @ 2015-09-25 7:33 UTC (permalink / raw)
To: Michael S. Tsirkin, qemu-devel
Cc: Peter Maydell, Richard Henderson, Eduardo Habkost, Paolo Bonzini
On Fri, 2015-09-25 at 09:43 +0300, Michael S. Tsirkin wrote:
> On Thu, Sep 24, 2015 at 04:20:53PM +0300, Michael S. Tsirkin wrote:
> > From: Knut Omang <knut.omang@oracle.com>
> >
> > - Use a hash table indexed on bus pointers to store information
> > about buses
> > instead of using the bus numbers.
> > Bus pointers are stored in a new VTDBus struct together with the
> > vector
> > of device address space pointers indexed by devfn.
> > - The bus number is still used for lookup for selective SID based
> > invalidate,
> > in which case the bus number is lazily resolved from the bus hash
> > table and
> > cached in a separate index.
> >
> > Signed-off-by: Knut Omang <knut.omang@oracle.com>
> > Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>
> This fails to build with our minimal glib version:
> Undefined symbols for architecture x86_64:
> "_g_hash_table_add", referenced from:
> _vtd_find_add_as in intel_iommu.o
> SETFILE lm32-softmmu/qemu-system-lm32
>
> g_hash_table_add only appeared in glib 2.32; our minimum
> is 2.22.
>
> Dropped this patch for now, please fix and repost.
Ouch, will look at it and repost, sorry - was not aware of that
requirement.
Knut
> > ---
> > include/hw/i386/intel_iommu.h | 16 +++++++-
> > hw/i386/intel_iommu.c | 90
> > +++++++++++++++++++++++++++++++++++--------
> > hw/pci-host/q35.c | 25 ++----------
> > 3 files changed, 91 insertions(+), 40 deletions(-)
> >
> > diff --git a/include/hw/i386/intel_iommu.h
> > b/include/hw/i386/intel_iommu.h
> > index e321ee4..5dbadb7 100644
> > --- a/include/hw/i386/intel_iommu.h
> > +++ b/include/hw/i386/intel_iommu.h
> > @@ -49,6 +49,7 @@ typedef struct VTDContextCacheEntry
> > VTDContextCacheEntry;
> > typedef struct IntelIOMMUState IntelIOMMUState;
> > typedef struct VTDAddressSpace VTDAddressSpace;
> > typedef struct VTDIOTLBEntry VTDIOTLBEntry;
> > +typedef struct VTDBus VTDBus;
> >
> > /* Context-Entry */
> > struct VTDContextEntry {
> > @@ -65,7 +66,7 @@ struct VTDContextCacheEntry {
> > };
> >
> > struct VTDAddressSpace {
> > - uint8_t bus_num;
> > + PCIBus *bus;
> > uint8_t devfn;
> > AddressSpace as;
> > MemoryRegion iommu;
> > @@ -73,6 +74,11 @@ struct VTDAddressSpace {
> > VTDContextCacheEntry context_cache_entry;
> > };
> >
> > +struct VTDBus {
> > + PCIBus* bus; /* A reference to the bus to
> > provide translation for */
> > + VTDAddressSpace *dev_as[0]; /* A table of
> > VTDAddressSpace objects indexed by devfn */
> > +};
> > +
> > struct VTDIOTLBEntry {
> > uint64_t gfn;
> > uint16_t domain_id;
> > @@ -114,7 +120,13 @@ struct IntelIOMMUState {
> > GHashTable *iotlb; /* IOTLB */
> >
> > MemoryRegionIOMMUOps iommu_ops;
> > - VTDAddressSpace **address_spaces[VTD_PCI_BUS_MAX];
> > + GHashTable *vtd_as_by_busptr; /* VTDBus objects indexed by
> > PCIBus* reference */
> > + VTDBus *vtd_as_by_bus_num[VTD_PCI_BUS_MAX]; /* VTDBus objects
> > indexed by bus number */
> > };
> >
> > +/* Find the VTD Address space associated with the given bus
> > pointer,
> > + * create a new one if none exists
> > + */
> > +VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus,
> > int devfn);
> > +
> > #endif
> > diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
> > index 08055a8..da67c36 100644
> > --- a/hw/i386/intel_iommu.c
> > +++ b/hw/i386/intel_iommu.c
> > @@ -22,6 +22,7 @@
> > #include "hw/sysbus.h"
> > #include "exec/address-spaces.h"
> > #include "intel_iommu_internal.h"
> > +#include "hw/pci/pci.h"
> >
> > /*#define DEBUG_INTEL_IOMMU*/
> > #ifdef DEBUG_INTEL_IOMMU
> > @@ -166,19 +167,17 @@ static gboolean
> > vtd_hash_remove_by_page(gpointer key, gpointer value,
> > */
> > static void vtd_reset_context_cache(IntelIOMMUState *s)
> > {
> > - VTDAddressSpace **pvtd_as;
> > VTDAddressSpace *vtd_as;
> > - uint32_t bus_it;
> > + VTDBus *vtd_bus;
> > + GHashTableIter bus_it;
> > uint32_t devfn_it;
> >
> > + g_hash_table_iter_init(&bus_it, s->vtd_as_by_busptr);
> > +
> > VTD_DPRINTF(CACHE, "global context_cache_gen=1");
> > - for (bus_it = 0; bus_it < VTD_PCI_BUS_MAX; ++bus_it) {
> > - pvtd_as = s->address_spaces[bus_it];
> > - if (!pvtd_as) {
> > - continue;
> > - }
> > + while (g_hash_table_iter_next (&bus_it, NULL,
> > (void**)&vtd_bus)) {
> > for (devfn_it = 0; devfn_it < VTD_PCI_DEVFN_MAX;
> > ++devfn_it) {
> > - vtd_as = pvtd_as[devfn_it];
> > + vtd_as = vtd_bus->dev_as[devfn_it];
> > if (!vtd_as) {
> > continue;
> > }
> > @@ -754,12 +753,13 @@ static inline bool
> > vtd_is_interrupt_addr(hwaddr addr)
> > * @is_write: The access is a write operation
> > * @entry: IOMMUTLBEntry that contain the addr to be translated
> > and result
> > */
> > -static void vtd_do_iommu_translate(VTDAddressSpace *vtd_as,
> > uint8_t bus_num,
> > +static void vtd_do_iommu_translate(VTDAddressSpace *vtd_as, PCIBus
> > *bus,
> > uint8_t devfn, hwaddr addr,
> > bool is_write,
> > IOMMUTLBEntry *entry)
> > {
> > IntelIOMMUState *s = vtd_as->iommu_state;
> > VTDContextEntry ce;
> > + uint8_t bus_num = pci_bus_num(bus);
> > VTDContextCacheEntry *cc_entry = &vtd_as->context_cache_entry;
> > uint64_t slpte;
> > uint32_t level;
> > @@ -874,6 +874,30 @@ static void
> > vtd_context_global_invalidate(IntelIOMMUState *s)
> > }
> > }
> >
> > +
> > +/* Find the VTD address space currently associated with a given
> > bus number,
> > + */
> > +static VTDBus *vtd_find_as_from_bus_num(IntelIOMMUState *s,
> > uint8_t bus_num)
> > +{
> > + VTDBus *vtd_bus = s->vtd_as_by_bus_num[bus_num];
> > + if (!vtd_bus) {
> > + /* Iterate over the registered buses to find the one
> > + * which currently hold this bus number, and update the
> > bus_num lookup table:
> > + */
> > + GHashTableIter iter;
> > + uint64_t key;
> > +
> > + g_hash_table_iter_init(&iter, s->vtd_as_by_busptr);
> > + while (g_hash_table_iter_next (&iter, (void**)&key,
> > (void**)&vtd_bus)) {
> > + if (pci_bus_num(vtd_bus->bus) == bus_num) {
> > + s->vtd_as_by_bus_num[bus_num] = vtd_bus;
> > + return vtd_bus;
> > + }
> > + }
> > + }
> > + return vtd_bus;
> > +}
> > +
> > /* Do a context-cache device-selective invalidation.
> > * @func_mask: FM field after shifting
> > */
> > @@ -882,7 +906,7 @@ static void
> > vtd_context_device_invalidate(IntelIOMMUState *s,
> > uint16_t func_mask)
> > {
> > uint16_t mask;
> > - VTDAddressSpace **pvtd_as;
> > + VTDBus *vtd_bus;
> > VTDAddressSpace *vtd_as;
> > uint16_t devfn;
> > uint16_t devfn_it;
> > @@ -903,11 +927,11 @@ static void
> > vtd_context_device_invalidate(IntelIOMMUState *s,
> > }
> > VTD_DPRINTF(INV, "device-selective invalidation source
> > 0x%"PRIx16
> > " mask %"PRIu16, source_id, mask);
> > - pvtd_as = s->address_spaces[VTD_SID_TO_BUS(source_id)];
> > - if (pvtd_as) {
> > + vtd_bus = vtd_find_as_from_bus_num(s,
> > VTD_SID_TO_BUS(source_id));
> > + if (vtd_bus) {
> > devfn = VTD_SID_TO_DEVFN(source_id);
> > for (devfn_it = 0; devfn_it < VTD_PCI_DEVFN_MAX;
> > ++devfn_it) {
> > - vtd_as = pvtd_as[devfn_it];
> > + vtd_as = vtd_bus->dev_as[devfn_it];
> > if (vtd_as && ((devfn_it & mask) == (devfn & mask))) {
> > VTD_DPRINTF(INV, "invalidate context-cahce of
> > devfn 0x%"PRIx16,
> > devfn_it);
> > @@ -1805,11 +1829,11 @@ static IOMMUTLBEntry
> > vtd_iommu_translate(MemoryRegion *iommu, hwaddr addr,
> > return ret;
> > }
> >
> > - vtd_do_iommu_translate(vtd_as, vtd_as->bus_num, vtd_as->devfn,
> > addr,
> > + vtd_do_iommu_translate(vtd_as, vtd_as->bus, vtd_as->devfn,
> > addr,
> > is_write, &ret);
> > VTD_DPRINTF(MMU,
> > "bus %"PRIu8 " slot %"PRIu8 " func %"PRIu8 " devfn
> > %"PRIu8
> > - " gpa 0x%"PRIx64 " hpa 0x%"PRIx64, vtd_as
> > ->bus_num,
> > + " gpa 0x%"PRIx64 " hpa 0x%"PRIx64,
> > pci_bus_num(vtd_as->bus),
> > VTD_PCI_SLOT(vtd_as->devfn), VTD_PCI_FUNC(vtd_as
> > ->devfn),
> > vtd_as->devfn, addr, ret.translated_addr);
> > return ret;
> > @@ -1839,6 +1863,38 @@ static Property vtd_properties[] = {
> > DEFINE_PROP_END_OF_LIST(),
> > };
> >
> > +
> > +VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, PCIBus *bus,
> > int devfn)
> > +{
> > + uint64_t key = (uint64_t)bus;
> > + VTDBus *vtd_bus = g_hash_table_lookup(s->vtd_as_by_busptr,
> > &key);
> > + VTDAddressSpace *vtd_dev_as;
> > +
> > + if (!vtd_bus) {
> > + /* No corresponding free() */
> > + vtd_bus = g_malloc0(sizeof(VTDBus) +
> > sizeof(VTDAddressSpace *) * VTD_PCI_DEVFN_MAX);
> > + vtd_bus->bus = bus;
> > + key = (uint64_t)bus;
> > + g_hash_table_add(s->vtd_as_by_busptr, vtd_bus);
> > + }
> > +
> > + vtd_dev_as = vtd_bus->dev_as[devfn];
> > +
> > + if (!vtd_dev_as) {
> > + vtd_bus->dev_as[devfn] = vtd_dev_as =
> > g_malloc0(sizeof(VTDAddressSpace));
> > +
> > + vtd_dev_as->bus = bus;
> > + vtd_dev_as->devfn = (uint8_t)devfn;
> > + vtd_dev_as->iommu_state = s;
> > + vtd_dev_as->context_cache_entry.context_cache_gen = 0;
> > + memory_region_init_iommu(&vtd_dev_as->iommu, OBJECT(s),
> > + &s->iommu_ops, "intel_iommu",
> > UINT64_MAX);
> > + address_space_init(&vtd_dev_as->as,
> > + &vtd_dev_as->iommu, "intel_iommu");
> > + }
> > + return vtd_dev_as;
> > +}
> > +
> > /* Do the initialization. It will also be called when reset, so
> > pay
> > * attention when adding new initialization stuff.
> > */
> > @@ -1931,13 +1987,15 @@ static void vtd_realize(DeviceState *dev,
> > Error **errp)
> > IntelIOMMUState *s = INTEL_IOMMU_DEVICE(dev);
> >
> > VTD_DPRINTF(GENERAL, "");
> > - memset(s->address_spaces, 0, sizeof(s->address_spaces));
> > + memset(s->vtd_as_by_bus_num, 0, sizeof(s->vtd_as_by_bus_num));
> > memory_region_init_io(&s->csrmem, OBJECT(s), &vtd_mem_ops, s,
> > "intel_iommu", DMAR_REG_SIZE);
> > sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->csrmem);
> > /* No corresponding destroy */
> > s->iotlb = g_hash_table_new_full(vtd_uint64_hash,
> > vtd_uint64_equal,
> > g_free, g_free);
> > + s->vtd_as_by_busptr = g_hash_table_new_full(vtd_uint64_hash,
> > vtd_uint64_equal,
> > + g_free, g_free);
> > vtd_init(s);
> > }
> >
> > diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
> > index bd74094..c81507d 100644
> > --- a/hw/pci-host/q35.c
> > +++ b/hw/pci-host/q35.c
> > @@ -426,31 +426,12 @@ static void mch_reset(DeviceState *qdev)
> > static AddressSpace *q35_host_dma_iommu(PCIBus *bus, void *opaque,
> > int devfn)
> > {
> > IntelIOMMUState *s = opaque;
> > - VTDAddressSpace **pvtd_as;
> > - int bus_num = pci_bus_num(bus);
> > + VTDAddressSpace *vtd_as;
> >
> > - assert(0 <= bus_num && bus_num <= VTD_PCI_BUS_MAX);
> > assert(0 <= devfn && devfn <= VTD_PCI_DEVFN_MAX);
> >
> > - pvtd_as = s->address_spaces[bus_num];
> > - if (!pvtd_as) {
> > - /* No corresponding free() */
> > - pvtd_as = g_malloc0(sizeof(VTDAddressSpace *) *
> > VTD_PCI_DEVFN_MAX);
> > - s->address_spaces[bus_num] = pvtd_as;
> > - }
> > - if (!pvtd_as[devfn]) {
> > - pvtd_as[devfn] = g_malloc0(sizeof(VTDAddressSpace));
> > -
> > - pvtd_as[devfn]->bus_num = (uint8_t)bus_num;
> > - pvtd_as[devfn]->devfn = (uint8_t)devfn;
> > - pvtd_as[devfn]->iommu_state = s;
> > - pvtd_as[devfn]->context_cache_entry.context_cache_gen = 0;
> > - memory_region_init_iommu(&pvtd_as[devfn]->iommu,
> > OBJECT(s),
> > - &s->iommu_ops, "intel_iommu",
> > UINT64_MAX);
> > - address_space_init(&pvtd_as[devfn]->as,
> > - &pvtd_as[devfn]->iommu, "intel_iommu");
> > - }
> > - return &pvtd_as[devfn]->as;
> > + vtd_as = vtd_find_add_as(s, bus, devfn);
> > + return &vtd_as->as;
> > }
> >
> > static void mch_init_dmar(MCHPCIState *mch)
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 12/22] vhost: rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE
2015-09-24 13:20 ` [Qemu-devel] [PULL 12/22] vhost: rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE Michael S. Tsirkin
@ 2015-10-02 16:18 ` Paolo Bonzini
2015-10-03 16:33 ` Michael S. Tsirkin
0 siblings, 1 reply; 37+ messages in thread
From: Paolo Bonzini @ 2015-10-02 16:18 UTC (permalink / raw)
To: Michael S. Tsirkin, qemu-devel
Cc: Marcel Apfelbaum, Peter Maydell, Yuanhan Liu
On 24/09/2015 15:20, Michael S. Tsirkin wrote:
> From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
>
> Quote from Michael:
>
> We really should rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE.
Where is the corresponding Linux patch for this?
I would like to fetch the updated headers for KVM, and this is breaking
it. In fact, a patch that just renames the #define (without providing
the old name for backwards compatibility) would be NACKed in upstream Linux.
Paolo
> Suggested-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
> ---
> linux-headers/linux/vhost.h | 2 +-
> hw/net/vhost_net.c | 2 +-
> hw/virtio/vhost-user.c | 6 +++---
> tests/vhost-user-test.c | 2 +-
> docs/specs/vhost-user.txt | 4 ++--
> 5 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h
> index ead86db..14a0160 100644
> --- a/linux-headers/linux/vhost.h
> +++ b/linux-headers/linux/vhost.h
> @@ -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_OWNER _IO(VHOST_VIRTIO, 0x02)
> +#define VHOST_RESET_DEVICE _IO(VHOST_VIRTIO, 0x02)
>
> /* Set up/modify memory layout */
> #define VHOST_SET_MEM_TABLE _IOW(VHOST_VIRTIO, 0x03, struct vhost_memory)
> diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> index 9d32d76..b7d29b7 100644
> --- a/hw/net/vhost_net.c
> +++ b/hw/net/vhost_net.c
> @@ -287,7 +287,7 @@ static void vhost_net_stop_one(struct vhost_net *net,
> } else if (net->nc->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER) {
> for (file.index = 0; file.index < net->dev.nvqs; ++file.index) {
> const VhostOps *vhost_ops = net->dev.vhost_ops;
> - int r = vhost_ops->vhost_call(&net->dev, VHOST_RESET_OWNER,
> + int r = vhost_ops->vhost_call(&net->dev, VHOST_RESET_DEVICE,
> NULL);
> assert(r >= 0);
> }
> diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
> index 7fe35c6..9cb2f52 100644
> --- a/hw/virtio/vhost-user.c
> +++ b/hw/virtio/vhost-user.c
> @@ -32,7 +32,7 @@ typedef enum VhostUserRequest {
> VHOST_USER_GET_FEATURES = 1,
> VHOST_USER_SET_FEATURES = 2,
> VHOST_USER_SET_OWNER = 3,
> - VHOST_USER_RESET_OWNER = 4,
> + VHOST_USER_RESET_DEVICE = 4,
> VHOST_USER_SET_MEM_TABLE = 5,
> VHOST_USER_SET_LOG_BASE = 6,
> VHOST_USER_SET_LOG_FD = 7,
> @@ -98,7 +98,7 @@ static unsigned long int ioctl_to_vhost_user_request[VHOST_USER_MAX] = {
> VHOST_GET_FEATURES, /* VHOST_USER_GET_FEATURES */
> VHOST_SET_FEATURES, /* VHOST_USER_SET_FEATURES */
> VHOST_SET_OWNER, /* VHOST_USER_SET_OWNER */
> - VHOST_RESET_OWNER, /* VHOST_USER_RESET_OWNER */
> + VHOST_RESET_DEVICE, /* VHOST_USER_RESET_DEVICE */
> VHOST_SET_MEM_TABLE, /* VHOST_USER_SET_MEM_TABLE */
> VHOST_SET_LOG_BASE, /* VHOST_USER_SET_LOG_BASE */
> VHOST_SET_LOG_FD, /* VHOST_USER_SET_LOG_FD */
> @@ -222,7 +222,7 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
> break;
>
> case VHOST_USER_SET_OWNER:
> - case VHOST_USER_RESET_OWNER:
> + case VHOST_USER_RESET_DEVICE:
> break;
>
> case VHOST_USER_SET_MEM_TABLE:
> diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
> index 75fedf0..e301db7 100644
> --- a/tests/vhost-user-test.c
> +++ b/tests/vhost-user-test.c
> @@ -58,7 +58,7 @@ typedef enum VhostUserRequest {
> VHOST_USER_GET_FEATURES = 1,
> VHOST_USER_SET_FEATURES = 2,
> VHOST_USER_SET_OWNER = 3,
> - VHOST_USER_RESET_OWNER = 4,
> + VHOST_USER_RESET_DEVICE = 4,
> VHOST_USER_SET_MEM_TABLE = 5,
> VHOST_USER_SET_LOG_BASE = 6,
> VHOST_USER_SET_LOG_FD = 7,
> diff --git a/docs/specs/vhost-user.txt b/docs/specs/vhost-user.txt
> index 70da3b1..ccbbcbb 100644
> --- a/docs/specs/vhost-user.txt
> +++ b/docs/specs/vhost-user.txt
> @@ -194,10 +194,10 @@ Message types
> as an owner of the session. This can be used on the Slave as a
> "session start" flag.
>
> - * VHOST_USER_RESET_OWNER
> + * VHOST_USER_RESET_DEVICE
>
> Id: 4
> - Equivalent ioctl: VHOST_RESET_OWNER
> + Equivalent ioctl: VHOST_RESET_DEVICE
> Master payload: N/A
>
> Issued when a new connection is about to be closed. The Master will no
>
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 12/22] vhost: rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE
2015-10-02 16:18 ` Paolo Bonzini
@ 2015-10-03 16:33 ` Michael S. Tsirkin
2015-10-08 5:24 ` Yuanhan Liu
2015-11-05 11:42 ` Peter Maydell
0 siblings, 2 replies; 37+ messages in thread
From: Michael S. Tsirkin @ 2015-10-03 16:33 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: Marcel Apfelbaum, Peter Maydell, Yuanhan Liu, qemu-devel
On Fri, Oct 02, 2015 at 06:18:51PM +0200, Paolo Bonzini wrote:
>
>
> On 24/09/2015 15:20, Michael S. Tsirkin wrote:
> > From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> >
> > Quote from Michael:
> >
> > We really should rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE.
>
> Where is the corresponding Linux patch for this?
>
> I would like to fetch the updated headers for KVM, and this is breaking
> it. In fact, a patch that just renames the #define (without providing
> the old name for backwards compatibility) would be NACKed in upstream Linux.
>
> Paolo
Right. And it turns out this whole approach is wrong. I intend to
revert this patch, and also drop the patch sending VHOST_RESET_OWNER on
device stop.
> > Suggested-by: Michael S. Tsirkin <mst@redhat.com>
> > Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> > Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> > Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
> > ---
> > linux-headers/linux/vhost.h | 2 +-
> > hw/net/vhost_net.c | 2 +-
> > hw/virtio/vhost-user.c | 6 +++---
> > tests/vhost-user-test.c | 2 +-
> > docs/specs/vhost-user.txt | 4 ++--
> > 5 files changed, 8 insertions(+), 8 deletions(-)
> >
> > diff --git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h
> > index ead86db..14a0160 100644
> > --- a/linux-headers/linux/vhost.h
> > +++ b/linux-headers/linux/vhost.h
> > @@ -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_OWNER _IO(VHOST_VIRTIO, 0x02)
> > +#define VHOST_RESET_DEVICE _IO(VHOST_VIRTIO, 0x02)
> >
> > /* Set up/modify memory layout */
> > #define VHOST_SET_MEM_TABLE _IOW(VHOST_VIRTIO, 0x03, struct vhost_memory)
> > diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> > index 9d32d76..b7d29b7 100644
> > --- a/hw/net/vhost_net.c
> > +++ b/hw/net/vhost_net.c
> > @@ -287,7 +287,7 @@ static void vhost_net_stop_one(struct vhost_net *net,
> > } else if (net->nc->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER) {
> > for (file.index = 0; file.index < net->dev.nvqs; ++file.index) {
> > const VhostOps *vhost_ops = net->dev.vhost_ops;
> > - int r = vhost_ops->vhost_call(&net->dev, VHOST_RESET_OWNER,
> > + int r = vhost_ops->vhost_call(&net->dev, VHOST_RESET_DEVICE,
> > NULL);
> > assert(r >= 0);
> > }
> > diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
> > index 7fe35c6..9cb2f52 100644
> > --- a/hw/virtio/vhost-user.c
> > +++ b/hw/virtio/vhost-user.c
> > @@ -32,7 +32,7 @@ typedef enum VhostUserRequest {
> > VHOST_USER_GET_FEATURES = 1,
> > VHOST_USER_SET_FEATURES = 2,
> > VHOST_USER_SET_OWNER = 3,
> > - VHOST_USER_RESET_OWNER = 4,
> > + VHOST_USER_RESET_DEVICE = 4,
> > VHOST_USER_SET_MEM_TABLE = 5,
> > VHOST_USER_SET_LOG_BASE = 6,
> > VHOST_USER_SET_LOG_FD = 7,
> > @@ -98,7 +98,7 @@ static unsigned long int ioctl_to_vhost_user_request[VHOST_USER_MAX] = {
> > VHOST_GET_FEATURES, /* VHOST_USER_GET_FEATURES */
> > VHOST_SET_FEATURES, /* VHOST_USER_SET_FEATURES */
> > VHOST_SET_OWNER, /* VHOST_USER_SET_OWNER */
> > - VHOST_RESET_OWNER, /* VHOST_USER_RESET_OWNER */
> > + VHOST_RESET_DEVICE, /* VHOST_USER_RESET_DEVICE */
> > VHOST_SET_MEM_TABLE, /* VHOST_USER_SET_MEM_TABLE */
> > VHOST_SET_LOG_BASE, /* VHOST_USER_SET_LOG_BASE */
> > VHOST_SET_LOG_FD, /* VHOST_USER_SET_LOG_FD */
> > @@ -222,7 +222,7 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
> > break;
> >
> > case VHOST_USER_SET_OWNER:
> > - case VHOST_USER_RESET_OWNER:
> > + case VHOST_USER_RESET_DEVICE:
> > break;
> >
> > case VHOST_USER_SET_MEM_TABLE:
> > diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
> > index 75fedf0..e301db7 100644
> > --- a/tests/vhost-user-test.c
> > +++ b/tests/vhost-user-test.c
> > @@ -58,7 +58,7 @@ typedef enum VhostUserRequest {
> > VHOST_USER_GET_FEATURES = 1,
> > VHOST_USER_SET_FEATURES = 2,
> > VHOST_USER_SET_OWNER = 3,
> > - VHOST_USER_RESET_OWNER = 4,
> > + VHOST_USER_RESET_DEVICE = 4,
> > VHOST_USER_SET_MEM_TABLE = 5,
> > VHOST_USER_SET_LOG_BASE = 6,
> > VHOST_USER_SET_LOG_FD = 7,
> > diff --git a/docs/specs/vhost-user.txt b/docs/specs/vhost-user.txt
> > index 70da3b1..ccbbcbb 100644
> > --- a/docs/specs/vhost-user.txt
> > +++ b/docs/specs/vhost-user.txt
> > @@ -194,10 +194,10 @@ Message types
> > as an owner of the session. This can be used on the Slave as a
> > "session start" flag.
> >
> > - * VHOST_USER_RESET_OWNER
> > + * VHOST_USER_RESET_DEVICE
> >
> > Id: 4
> > - Equivalent ioctl: VHOST_RESET_OWNER
> > + Equivalent ioctl: VHOST_RESET_DEVICE
> > Master payload: N/A
> >
> > Issued when a new connection is about to be closed. The Master will no
> >
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 12/22] vhost: rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE
2015-10-03 16:33 ` Michael S. Tsirkin
@ 2015-10-08 5:24 ` Yuanhan Liu
2015-11-05 11:42 ` Peter Maydell
1 sibling, 0 replies; 37+ messages in thread
From: Yuanhan Liu @ 2015-10-08 5:24 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Marcel Apfelbaum, Paolo Bonzini, qemu-devel, Peter Maydell
On Sat, Oct 03, 2015 at 07:33:16PM +0300, Michael S. Tsirkin wrote:
> On Fri, Oct 02, 2015 at 06:18:51PM +0200, Paolo Bonzini wrote:
> >
> >
> > On 24/09/2015 15:20, Michael S. Tsirkin wrote:
> > > From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> > >
> > > Quote from Michael:
> > >
> > > We really should rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE.
> >
> > Where is the corresponding Linux patch for this?
> >
> > I would like to fetch the updated headers for KVM, and this is breaking
> > it. In fact, a patch that just renames the #define (without providing
> > the old name for backwards compatibility) would be NACKed in upstream Linux.
> >
> > Paolo
>
> Right. And it turns out this whole approach is wrong. I intend to
> revert this patch,
I was considering to put this patch as the last one in this set, so that
we could drop (or revert) it if it's turned out to be wrong (I had vague
feeling that it was wrong).
Luckily, this patch could be reverted successfully (I firstly thought
there might be conflicts). Besides that, we need one extra manual fix:
[yliu@yliu-dev ~/qemu]$ gg 'VHOST.*RESET_DEVICE'
hw/virtio/vhost-user.c:195: case VHOST_USER_RESET_DEVICE:
Michael, shall I send the revert request, or you will do that?
> and also drop the patch sending VHOST_RESET_OWNER on
> device stop.
Something wrong there?
--yliu
>
> > > Suggested-by: Michael S. Tsirkin <mst@redhat.com>
> > > Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> > > Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> > > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > > Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> > > Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
> > > ---
> > > linux-headers/linux/vhost.h | 2 +-
> > > hw/net/vhost_net.c | 2 +-
> > > hw/virtio/vhost-user.c | 6 +++---
> > > tests/vhost-user-test.c | 2 +-
> > > docs/specs/vhost-user.txt | 4 ++--
> > > 5 files changed, 8 insertions(+), 8 deletions(-)
> > >
> > > diff --git a/linux-headers/linux/vhost.h b/linux-headers/linux/vhost.h
> > > index ead86db..14a0160 100644
> > > --- a/linux-headers/linux/vhost.h
> > > +++ b/linux-headers/linux/vhost.h
> > > @@ -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_OWNER _IO(VHOST_VIRTIO, 0x02)
> > > +#define VHOST_RESET_DEVICE _IO(VHOST_VIRTIO, 0x02)
> > >
> > > /* Set up/modify memory layout */
> > > #define VHOST_SET_MEM_TABLE _IOW(VHOST_VIRTIO, 0x03, struct vhost_memory)
> > > diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
> > > index 9d32d76..b7d29b7 100644
> > > --- a/hw/net/vhost_net.c
> > > +++ b/hw/net/vhost_net.c
> > > @@ -287,7 +287,7 @@ static void vhost_net_stop_one(struct vhost_net *net,
> > > } else if (net->nc->info->type == NET_CLIENT_OPTIONS_KIND_VHOST_USER) {
> > > for (file.index = 0; file.index < net->dev.nvqs; ++file.index) {
> > > const VhostOps *vhost_ops = net->dev.vhost_ops;
> > > - int r = vhost_ops->vhost_call(&net->dev, VHOST_RESET_OWNER,
> > > + int r = vhost_ops->vhost_call(&net->dev, VHOST_RESET_DEVICE,
> > > NULL);
> > > assert(r >= 0);
> > > }
> > > diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
> > > index 7fe35c6..9cb2f52 100644
> > > --- a/hw/virtio/vhost-user.c
> > > +++ b/hw/virtio/vhost-user.c
> > > @@ -32,7 +32,7 @@ typedef enum VhostUserRequest {
> > > VHOST_USER_GET_FEATURES = 1,
> > > VHOST_USER_SET_FEATURES = 2,
> > > VHOST_USER_SET_OWNER = 3,
> > > - VHOST_USER_RESET_OWNER = 4,
> > > + VHOST_USER_RESET_DEVICE = 4,
> > > VHOST_USER_SET_MEM_TABLE = 5,
> > > VHOST_USER_SET_LOG_BASE = 6,
> > > VHOST_USER_SET_LOG_FD = 7,
> > > @@ -98,7 +98,7 @@ static unsigned long int ioctl_to_vhost_user_request[VHOST_USER_MAX] = {
> > > VHOST_GET_FEATURES, /* VHOST_USER_GET_FEATURES */
> > > VHOST_SET_FEATURES, /* VHOST_USER_SET_FEATURES */
> > > VHOST_SET_OWNER, /* VHOST_USER_SET_OWNER */
> > > - VHOST_RESET_OWNER, /* VHOST_USER_RESET_OWNER */
> > > + VHOST_RESET_DEVICE, /* VHOST_USER_RESET_DEVICE */
> > > VHOST_SET_MEM_TABLE, /* VHOST_USER_SET_MEM_TABLE */
> > > VHOST_SET_LOG_BASE, /* VHOST_USER_SET_LOG_BASE */
> > > VHOST_SET_LOG_FD, /* VHOST_USER_SET_LOG_FD */
> > > @@ -222,7 +222,7 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
> > > break;
> > >
> > > case VHOST_USER_SET_OWNER:
> > > - case VHOST_USER_RESET_OWNER:
> > > + case VHOST_USER_RESET_DEVICE:
> > > break;
> > >
> > > case VHOST_USER_SET_MEM_TABLE:
> > > diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
> > > index 75fedf0..e301db7 100644
> > > --- a/tests/vhost-user-test.c
> > > +++ b/tests/vhost-user-test.c
> > > @@ -58,7 +58,7 @@ typedef enum VhostUserRequest {
> > > VHOST_USER_GET_FEATURES = 1,
> > > VHOST_USER_SET_FEATURES = 2,
> > > VHOST_USER_SET_OWNER = 3,
> > > - VHOST_USER_RESET_OWNER = 4,
> > > + VHOST_USER_RESET_DEVICE = 4,
> > > VHOST_USER_SET_MEM_TABLE = 5,
> > > VHOST_USER_SET_LOG_BASE = 6,
> > > VHOST_USER_SET_LOG_FD = 7,
> > > diff --git a/docs/specs/vhost-user.txt b/docs/specs/vhost-user.txt
> > > index 70da3b1..ccbbcbb 100644
> > > --- a/docs/specs/vhost-user.txt
> > > +++ b/docs/specs/vhost-user.txt
> > > @@ -194,10 +194,10 @@ Message types
> > > as an owner of the session. This can be used on the Slave as a
> > > "session start" flag.
> > >
> > > - * VHOST_USER_RESET_OWNER
> > > + * VHOST_USER_RESET_DEVICE
> > >
> > > Id: 4
> > > - Equivalent ioctl: VHOST_RESET_OWNER
> > > + Equivalent ioctl: VHOST_RESET_DEVICE
> > > Master payload: N/A
> > >
> > > Issued when a new connection is about to be closed. The Master will no
> > >
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 12/22] vhost: rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE
2015-10-03 16:33 ` Michael S. Tsirkin
2015-10-08 5:24 ` Yuanhan Liu
@ 2015-11-05 11:42 ` Peter Maydell
2015-11-06 1:34 ` Yuanhan Liu
1 sibling, 1 reply; 37+ messages in thread
From: Peter Maydell @ 2015-11-05 11:42 UTC (permalink / raw)
To: Michael S. Tsirkin
Cc: Marcel Apfelbaum, Paolo Bonzini, Yuanhan Liu, QEMU Developers
On 3 October 2015 at 17:33, Michael S. Tsirkin <mst@redhat.com> wrote:
> On Fri, Oct 02, 2015 at 06:18:51PM +0200, Paolo Bonzini wrote:
>>
>>
>> On 24/09/2015 15:20, Michael S. Tsirkin wrote:
>> > From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
>> >
>> > Quote from Michael:
>> >
>> > We really should rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE.
>>
>> Where is the corresponding Linux patch for this?
>>
>> I would like to fetch the updated headers for KVM, and this is breaking
>> it. In fact, a patch that just renames the #define (without providing
>> the old name for backwards compatibility) would be NACKed in upstream Linux.
>>
>> Paolo
>
> Right. And it turns out this whole approach is wrong. I intend to
> revert this patch, and also drop the patch sending VHOST_RESET_OWNER on
> device stop.
This revert doesn't seem to have happened, I think, which means
that this is one of the things which prevents a clean header-update
against kvm/next. Could we get this fixed for rc0, please?
thanks
-- PMM
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 12/22] vhost: rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE
2015-11-05 11:42 ` Peter Maydell
@ 2015-11-06 1:34 ` Yuanhan Liu
2015-11-06 10:01 ` Peter Maydell
0 siblings, 1 reply; 37+ messages in thread
From: Yuanhan Liu @ 2015-11-06 1:34 UTC (permalink / raw)
To: Peter Maydell
Cc: Marcel Apfelbaum, Paolo Bonzini, QEMU Developers,
Michael S. Tsirkin
On Thu, Nov 05, 2015 at 11:42:15AM +0000, Peter Maydell wrote:
> On 3 October 2015 at 17:33, Michael S. Tsirkin <mst@redhat.com> wrote:
> > On Fri, Oct 02, 2015 at 06:18:51PM +0200, Paolo Bonzini wrote:
> >>
> >>
> >> On 24/09/2015 15:20, Michael S. Tsirkin wrote:
> >> > From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> >> >
> >> > Quote from Michael:
> >> >
> >> > We really should rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE.
> >>
> >> Where is the corresponding Linux patch for this?
> >>
> >> I would like to fetch the updated headers for KVM, and this is breaking
> >> it. In fact, a patch that just renames the #define (without providing
> >> the old name for backwards compatibility) would be NACKed in upstream Linux.
> >>
> >> Paolo
> >
> > Right. And it turns out this whole approach is wrong. I intend to
> > revert this patch, and also drop the patch sending VHOST_RESET_OWNER on
> > device stop.
>
> This revert doesn't seem to have happened, I think, which means
> that this is one of the things which prevents a clean header-update
> against kvm/next. Could we get this fixed for rc0, please?
My bad. I will fix it next week. What's the deadline for rc0 then?
BTW, as Michael stated, a simple revert is not enough.
--yliu
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 12/22] vhost: rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE
2015-11-06 1:34 ` Yuanhan Liu
@ 2015-11-06 10:01 ` Peter Maydell
2015-11-09 3:56 ` Yuanhan Liu
0 siblings, 1 reply; 37+ messages in thread
From: Peter Maydell @ 2015-11-06 10:01 UTC (permalink / raw)
To: Yuanhan Liu
Cc: Marcel Apfelbaum, Paolo Bonzini, QEMU Developers,
Michael S. Tsirkin
On 6 November 2015 at 01:34, Yuanhan Liu <yuanhan.liu@linux.intel.com> wrote:
> On Thu, Nov 05, 2015 at 11:42:15AM +0000, Peter Maydell wrote:
>> On 3 October 2015 at 17:33, Michael S. Tsirkin <mst@redhat.com> wrote:
>> > On Fri, Oct 02, 2015 at 06:18:51PM +0200, Paolo Bonzini wrote:
>> >>
>> >>
>> >> On 24/09/2015 15:20, Michael S. Tsirkin wrote:
>> >> > From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
>> >> >
>> >> > Quote from Michael:
>> >> >
>> >> > We really should rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE.
>> >>
>> >> Where is the corresponding Linux patch for this?
>> >>
>> >> I would like to fetch the updated headers for KVM, and this is breaking
>> >> it. In fact, a patch that just renames the #define (without providing
>> >> the old name for backwards compatibility) would be NACKed in upstream Linux.
>> >>
>> >> Paolo
>> >
>> > Right. And it turns out this whole approach is wrong. I intend to
>> > revert this patch, and also drop the patch sending VHOST_RESET_OWNER on
>> > device stop.
>>
>> This revert doesn't seem to have happened, I think, which means
>> that this is one of the things which prevents a clean header-update
>> against kvm/next. Could we get this fixed for rc0, please?
>
> My bad. I will fix it next week. What's the deadline for rc0 then?
rc0 is 12th November (http://wiki.qemu.org/Planning/2.5). You need
to also allow time for the patch to be reviewed and possibly taken
via somebody's tree.
thanks
-- PMM
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 12/22] vhost: rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE
2015-11-06 10:01 ` Peter Maydell
@ 2015-11-09 3:56 ` Yuanhan Liu
0 siblings, 0 replies; 37+ messages in thread
From: Yuanhan Liu @ 2015-11-09 3:56 UTC (permalink / raw)
To: Peter Maydell
Cc: Marcel Apfelbaum, Paolo Bonzini, QEMU Developers,
Michael S. Tsirkin
On Fri, Nov 06, 2015 at 10:01:58AM +0000, Peter Maydell wrote:
> On 6 November 2015 at 01:34, Yuanhan Liu <yuanhan.liu@linux.intel.com> wrote:
> > On Thu, Nov 05, 2015 at 11:42:15AM +0000, Peter Maydell wrote:
> >> On 3 October 2015 at 17:33, Michael S. Tsirkin <mst@redhat.com> wrote:
> >> > On Fri, Oct 02, 2015 at 06:18:51PM +0200, Paolo Bonzini wrote:
> >> >>
> >> >>
> >> >> On 24/09/2015 15:20, Michael S. Tsirkin wrote:
> >> >> > From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> >> >> >
> >> >> > Quote from Michael:
> >> >> >
> >> >> > We really should rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE.
> >> >>
> >> >> Where is the corresponding Linux patch for this?
> >> >>
> >> >> I would like to fetch the updated headers for KVM, and this is breaking
> >> >> it. In fact, a patch that just renames the #define (without providing
> >> >> the old name for backwards compatibility) would be NACKed in upstream Linux.
> >> >>
> >> >> Paolo
> >> >
> >> > Right. And it turns out this whole approach is wrong. I intend to
> >> > revert this patch, and also drop the patch sending VHOST_RESET_OWNER on
> >> > device stop.
> >>
> >> This revert doesn't seem to have happened, I think, which means
> >> that this is one of the things which prevents a clean header-update
> >> against kvm/next. Could we get this fixed for rc0, please?
> >
> > My bad. I will fix it next week. What's the deadline for rc0 then?
>
> rc0 is 12th November (http://wiki.qemu.org/Planning/2.5). You need
> to also allow time for the patch to be reviewed and possibly taken
> via somebody's tree.
Got it and thanks for the remind.
--yliu
^ permalink raw reply [flat|nested] 37+ messages in thread
end of thread, other threads:[~2015-11-09 3:53 UTC | newest]
Thread overview: 37+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-24 13:20 [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 01/22] virtio: right size for virtio_queue_get_avail_size Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 02/22] virtio-net: unbreak self announcement and guest offloads after migration Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 03/22] q35: Move options common to all classes to pc_q35_machine_options() Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 04/22] q35: Move options common to all classes to pc_i440fx_machine_options() Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 05/22] pc: Introduce pc-*-2.5 machine classes Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 06/22] virtio: ring sizes vs. reset Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 07/22] virtio-ccw: support ring size changes Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 08/22] virtio-ccw: feature bits > 31 handling Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 09/22] virtio-ccw: enable virtio-1 Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 10/22] vhost-user: use VHOST_USER_XXX macro for switch statement Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 11/22] vhost-user: add protocol feature negotiation Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 12/22] vhost: rename VHOST_RESET_OWNER to VHOST_RESET_DEVICE Michael S. Tsirkin
2015-10-02 16:18 ` Paolo Bonzini
2015-10-03 16:33 ` Michael S. Tsirkin
2015-10-08 5:24 ` Yuanhan Liu
2015-11-05 11:42 ` Peter Maydell
2015-11-06 1:34 ` Yuanhan Liu
2015-11-06 10:01 ` Peter Maydell
2015-11-09 3:56 ` Yuanhan Liu
2015-09-24 13:20 ` [Qemu-devel] [PULL 13/22] vhost-user: add VHOST_USER_GET_QUEUE_NUM message Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 14/22] vhost: introduce vhost_backend_get_vq_index method Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 15/22] vhost-user: add multiple queue support Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 16/22] vhost-user: add a new message to disable/enable a specific virt queue Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 17/22] intel_iommu: Add support for translation for devices behind bridges Michael S. Tsirkin
2015-09-25 6:43 ` Michael S. Tsirkin
2015-09-25 7:33 ` Knut Omang
2015-09-24 13:20 ` [Qemu-devel] [PULL 18/22] MAINTAINERS: add more devices to the PC section Michael S. Tsirkin
2015-09-24 13:20 ` [Qemu-devel] [PULL 19/22] MAINTAINERS: add more devices to the PCI section Michael S. Tsirkin
2015-09-24 13:21 ` [Qemu-devel] [PULL 20/22] virtio: introduce virtqueue_unmap_sg() Michael S. Tsirkin
2015-09-24 18:58 ` Michael S. Tsirkin
2015-09-25 3:26 ` Jason Wang
2015-09-24 13:21 ` [Qemu-devel] [PULL 21/22] virtio: introduce virtqueue_discard() Michael S. Tsirkin
2015-09-24 13:21 ` [Qemu-devel] [PULL 22/22] virtio-net: correctly drop truncated packets Michael S. Tsirkin
2015-09-24 13:30 ` [Qemu-devel] [PULL 00/22] virtio,pc features, fixes Michael S. Tsirkin
2015-09-24 18:36 ` Peter Maydell
2015-09-24 18:57 ` 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).