qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 00/10] virtio fixes for 2.4
@ 2015-07-28  9:57 Michael S. Tsirkin
  2015-07-28  9:57 ` [Qemu-devel] [PULL 01/10] virtio: hide legacy features from modern guests Michael S. Tsirkin
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Michael S. Tsirkin @ 2015-07-28  9:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell

The following changes since commit b69b30532e0a80e25449244c01b0cbed000c99a3:

  Update version for v2.4.0-rc2 release (2015-07-22 18:17:19 +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 c147b5153e733a14fc65d2098e7036754c185ad1:

  virtio: minor cleanup (2015-07-27 23:55:27 +0300)

----------------------------------------------------------------
virtio fixes for 2.4

Mostly virtio 1 spec compliance fixes.
We are unlikely to make it perfectly compliant in
the first release, but it seems worth it to try.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

----------------------------------------------------------------
Gal Hammer (1):
      acpi: fix pvpanic device is not shown in ui

Jason Wang (3):
      virtio: get_features() can fail
      virtio-blk: fail get_features when both scsi and 1.0 were set
      virtio-blk: only clear VIRTIO_F_ANY_LAYOUT for legacy device

Michael S. Tsirkin (6):
      virtio: hide legacy features from modern guests
      virtio-serial: fix ANY_LAYOUT
      virtio-9p: fix any_layout
      virtio: set any_layout in virtio core
      virtio-pci: fix memory MR cleanup for modern
      virtio: minor cleanup

 include/hw/compat.h         | 22 +++++++++++++++++++++-
 include/hw/virtio/virtio.h  | 12 ++++++++++--
 hw/9pfs/virtio-9p-device.c  |  3 ++-
 hw/9pfs/virtio-9p.c         | 23 +++++++++++++++++------
 hw/block/virtio-blk.c       | 13 +++++++++++--
 hw/char/virtio-serial-bus.c |  6 ++++--
 hw/display/virtio-gpu.c     |  3 ++-
 hw/i386/acpi-build.c        |  4 ++--
 hw/input/virtio-input.c     |  3 ++-
 hw/net/virtio-net.c         |  5 ++---
 hw/scsi/vhost-scsi.c        |  3 ++-
 hw/scsi/virtio-scsi.c       |  5 ++---
 hw/virtio/virtio-balloon.c  |  3 ++-
 hw/virtio/virtio-bus.c      |  3 ++-
 hw/virtio/virtio-pci.c      | 18 +++++++++++++++++-
 hw/virtio/virtio-rng.c      |  2 +-
 16 files changed, 99 insertions(+), 29 deletions(-)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PULL 01/10] virtio: hide legacy features from modern guests
  2015-07-28  9:57 [Qemu-devel] [PULL 00/10] virtio fixes for 2.4 Michael S. Tsirkin
@ 2015-07-28  9:57 ` Michael S. Tsirkin
  2015-07-28  9:57 ` [Qemu-devel] [PULL 02/10] virtio-serial: fix ANY_LAYOUT Michael S. Tsirkin
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Michael S. Tsirkin @ 2015-07-28  9:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell

NOTIFY_ON_EMPTY, ANY_LAYOUT and BAD are only valid on the legacy
interface.

Hide them from modern guests.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 include/hw/virtio/virtio.h | 4 ++++
 hw/virtio/virtio-pci.c     | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 473fb75..0634c15 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -25,6 +25,10 @@
 /* A guest should never accept this.  It implies negotiation is broken. */
 #define VIRTIO_F_BAD_FEATURE		30
 
+#define VIRTIO_LEGACY_FEATURES ((0x1ULL << VIRTIO_F_BAD_FEATURE) | \
+                                (0x1ULL << VIRTIO_F_NOTIFY_ON_EMPTY) | \
+                                (0x1ULL << VIRTIO_F_ANY_LAYOUT))
+
 struct VirtQueue;
 
 static inline hwaddr vring_align(hwaddr addr,
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 283401a..db8f27c 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1095,7 +1095,8 @@ static uint64_t virtio_pci_common_read(void *opaque, hwaddr addr,
         break;
     case VIRTIO_PCI_COMMON_DF:
         if (proxy->dfselect <= 1) {
-            val = vdev->host_features >> (32 * proxy->dfselect);
+            val = (vdev->host_features & ~VIRTIO_LEGACY_FEATURES) >>
+                (32 * proxy->dfselect);
         }
         break;
     case VIRTIO_PCI_COMMON_GFSELECT:
-- 
MST

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PULL 02/10] virtio-serial: fix ANY_LAYOUT
  2015-07-28  9:57 [Qemu-devel] [PULL 00/10] virtio fixes for 2.4 Michael S. Tsirkin
  2015-07-28  9:57 ` [Qemu-devel] [PULL 01/10] virtio: hide legacy features from modern guests Michael S. Tsirkin
@ 2015-07-28  9:57 ` Michael S. Tsirkin
  2015-07-28  9:57 ` [Qemu-devel] [PULL 03/10] virtio-9p: fix any_layout Michael S. Tsirkin
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Michael S. Tsirkin @ 2015-07-28  9:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah, Peter Maydell, Jason Wang

Don't assume a specific layout for control messages.
Required by virtio 1.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Jason Wang <jasowang@redhat.com>
---
 hw/char/virtio-serial-bus.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index 78c73e5..929e49c 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -195,7 +195,8 @@ static size_t send_control_msg(VirtIOSerial *vser, void *buf, size_t len)
         return 0;
     }
 
-    memcpy(elem.in_sg[0].iov_base, buf, len);
+    /* TODO: detect a buffer that's too short, set NEEDS_RESET */
+    iov_from_buf(elem.in_sg, elem.in_num, 0, buf, len);
 
     virtqueue_push(vq, &elem, len);
     virtio_notify(VIRTIO_DEVICE(vser), vq);
-- 
MST

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PULL 03/10] virtio-9p: fix any_layout
  2015-07-28  9:57 [Qemu-devel] [PULL 00/10] virtio fixes for 2.4 Michael S. Tsirkin
  2015-07-28  9:57 ` [Qemu-devel] [PULL 01/10] virtio: hide legacy features from modern guests Michael S. Tsirkin
  2015-07-28  9:57 ` [Qemu-devel] [PULL 02/10] virtio-serial: fix ANY_LAYOUT Michael S. Tsirkin
@ 2015-07-28  9:57 ` Michael S. Tsirkin
  2015-07-28  9:57 ` [Qemu-devel] [PULL 04/10] virtio: set any_layout in virtio core Michael S. Tsirkin
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Michael S. Tsirkin @ 2015-07-28  9:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Jason Wang, Aneesh Kumar K.V

virtio pci allows any device to have a modern interface,
this in turn requires ANY_LAYOUT support.
Fix up ANY_LAYOUT for virtio-9p.

Reported-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Jason Wang <jasowang@redhat.com>
---
 hw/9pfs/virtio-9p.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
index 6ef8af3..f972731 100644
--- a/hw/9pfs/virtio-9p.c
+++ b/hw/9pfs/virtio-9p.c
@@ -14,6 +14,7 @@
 #include "hw/virtio/virtio.h"
 #include "hw/i386/pc.h"
 #include "qemu/error-report.h"
+#include "qemu/iov.h"
 #include "qemu/sockets.h"
 #include "virtio-9p.h"
 #include "fsdev/qemu-fsdev.h"
@@ -3261,16 +3262,26 @@ void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq)
 
     while ((pdu = alloc_pdu(s)) &&
             (len = virtqueue_pop(vq, &pdu->elem)) != 0) {
-        uint8_t *ptr;
+        struct {
+            uint32_t size_le;
+            uint8_t id;
+            uint16_t tag_le;
+        } QEMU_PACKED out;
+        int len;
+
         pdu->s = s;
         BUG_ON(pdu->elem.out_num == 0 || pdu->elem.in_num == 0);
-        BUG_ON(pdu->elem.out_sg[0].iov_len < 7);
+        QEMU_BUILD_BUG_ON(sizeof out != 7);
+
+        len = iov_to_buf(pdu->elem.out_sg, pdu->elem.out_num, 0,
+                         &out, sizeof out);
+        BUG_ON(len != sizeof out);
+
+        pdu->size = le32_to_cpu(out.size_le);
 
-        ptr = pdu->elem.out_sg[0].iov_base;
+        pdu->id = out.id;
+        pdu->tag = le16_to_cpu(out.tag_le);
 
-        pdu->size = le32_to_cpu(*(uint32_t *)ptr);
-        pdu->id = ptr[4];
-        pdu->tag = le16_to_cpu(*(uint16_t *)(ptr + 5));
         qemu_co_queue_init(&pdu->complete);
         submit_pdu(s, pdu);
     }
-- 
MST

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PULL 04/10] virtio: set any_layout in virtio core
  2015-07-28  9:57 [Qemu-devel] [PULL 00/10] virtio fixes for 2.4 Michael S. Tsirkin
                   ` (2 preceding siblings ...)
  2015-07-28  9:57 ` [Qemu-devel] [PULL 03/10] virtio-9p: fix any_layout Michael S. Tsirkin
@ 2015-07-28  9:57 ` Michael S. Tsirkin
  2015-07-28  9:57 ` [Qemu-devel] [PULL 05/10] virtio-pci: fix memory MR cleanup for modern Michael S. Tsirkin
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Michael S. Tsirkin @ 2015-07-28  9:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Peter Maydell, qemu-block, Stefan Hajnoczi,
	Paolo Bonzini

Exceptions:
    - virtio-blk
    - compat machine types

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 include/hw/compat.h        | 22 +++++++++++++++++++++-
 include/hw/virtio/virtio.h |  4 +++-
 hw/block/virtio-blk.c      |  1 +
 hw/net/virtio-net.c        |  2 --
 hw/scsi/virtio-scsi.c      |  2 --
 5 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/include/hw/compat.h b/include/hw/compat.h
index 4a43466..94c8097 100644
--- a/include/hw/compat.h
+++ b/include/hw/compat.h
@@ -2,7 +2,27 @@
 #define HW_COMPAT_H
 
 #define HW_COMPAT_2_3 \
-        /* empty */
+        {\
+            .driver   = "virtio-blk-pci",\
+            .property = "any_layout",\
+            .value    = "off",\
+        },{\
+            .driver   = "virtio-balloon-pci",\
+            .property = "any_layout",\
+            .value    = "off",\
+        },{\
+            .driver   = "virtio-serial-pci",\
+            .property = "any_layout",\
+            .value    = "off",\
+        },{\
+            .driver   = "virtio-9p-pci",\
+            .property = "any_layout",\
+            .value    = "off",\
+        },{\
+            .driver   = "virtio-rng-pci",\
+            .property = "any_layout",\
+            .value    = "off",\
+        },
 
 #define HW_COMPAT_2_2 \
         /* empty */
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 0634c15..ff91711 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -218,7 +218,9 @@ typedef struct VirtIORNGConf VirtIORNGConf;
     DEFINE_PROP_BIT64("event_idx", _state, _field,        \
                       VIRTIO_RING_F_EVENT_IDX, true),     \
     DEFINE_PROP_BIT64("notify_on_empty", _state, _field,  \
-                      VIRTIO_F_NOTIFY_ON_EMPTY, true)
+                      VIRTIO_F_NOTIFY_ON_EMPTY, true), \
+    DEFINE_PROP_BIT64("any_layout", _state, _field, \
+                      VIRTIO_F_ANY_LAYOUT, true)
 
 hwaddr virtio_queue_get_desc_addr(VirtIODevice *vdev, int n);
 hwaddr virtio_queue_get_avail_addr(VirtIODevice *vdev, int n);
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 6aefda4..015b9b5 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -731,6 +731,7 @@ static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features)
     virtio_add_feature(&features, VIRTIO_BLK_F_TOPOLOGY);
     virtio_add_feature(&features, VIRTIO_BLK_F_BLK_SIZE);
     virtio_add_feature(&features, VIRTIO_BLK_F_SCSI);
+    virtio_clear_feature(&features, VIRTIO_F_ANY_LAYOUT);
 
     if (s->conf.config_wce) {
         virtio_add_feature(&features, VIRTIO_BLK_F_CONFIG_WCE);
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 304d3dd..e203058 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1777,8 +1777,6 @@ static void virtio_net_instance_init(Object *obj)
 }
 
 static Property virtio_net_properties[] = {
-    DEFINE_PROP_BIT("any_layout", VirtIONet, host_features,
-                    VIRTIO_F_ANY_LAYOUT, true),
     DEFINE_PROP_BIT("csum", VirtIONet, host_features, VIRTIO_NET_F_CSUM, true),
     DEFINE_PROP_BIT("guest_csum", VirtIONet, host_features,
                     VIRTIO_NET_F_GUEST_CSUM, true),
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index f7d3c7c..d17698d 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -953,8 +953,6 @@ static Property virtio_scsi_properties[] = {
                                                   0xFFFF),
     DEFINE_PROP_UINT32("cmd_per_lun", VirtIOSCSI, parent_obj.conf.cmd_per_lun,
                                                   128),
-    DEFINE_PROP_BIT("any_layout", VirtIOSCSI, host_features,
-                                              VIRTIO_F_ANY_LAYOUT, true),
     DEFINE_PROP_BIT("hotplug", VirtIOSCSI, host_features,
                                            VIRTIO_SCSI_F_HOTPLUG, true),
     DEFINE_PROP_BIT("param_change", VirtIOSCSI, host_features,
-- 
MST

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PULL 05/10] virtio-pci: fix memory MR cleanup for modern
  2015-07-28  9:57 [Qemu-devel] [PULL 00/10] virtio fixes for 2.4 Michael S. Tsirkin
                   ` (3 preceding siblings ...)
  2015-07-28  9:57 ` [Qemu-devel] [PULL 04/10] virtio: set any_layout in virtio core Michael S. Tsirkin
@ 2015-07-28  9:57 ` Michael S. Tsirkin
  2015-07-28  9:57 ` [Qemu-devel] [PULL 06/10] virtio: get_features() can fail Michael S. Tsirkin
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Michael S. Tsirkin @ 2015-07-28  9:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Paolo Bonzini

Each memory_region_add_subregion must be paired with
memory_region_del_subregion.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/virtio/virtio-pci.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index db8f27c..c024161 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -1414,6 +1414,13 @@ static void virtio_pci_modern_region_map(VirtIOPCIProxy *proxy,
     virtio_pci_add_mem_cap(proxy, cap);
 }
 
+static void virtio_pci_modern_region_unmap(VirtIOPCIProxy *proxy,
+                                           VirtIOPCIRegion *region)
+{
+    memory_region_del_subregion(&proxy->modern_bar,
+                                &region->mr);
+}
+
 /* This is called by virtio-bus just after the device is plugged. */
 static void virtio_pci_device_plugged(DeviceState *d, Error **errp)
 {
@@ -1520,8 +1527,16 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp)
 static void virtio_pci_device_unplugged(DeviceState *d)
 {
     VirtIOPCIProxy *proxy = VIRTIO_PCI(d);
+    bool modern = !(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_MODERN);
 
     virtio_pci_stop_ioeventfd(proxy);
+
+    if (modern) {
+        virtio_pci_modern_region_unmap(proxy, &proxy->common);
+        virtio_pci_modern_region_unmap(proxy, &proxy->isr);
+        virtio_pci_modern_region_unmap(proxy, &proxy->device);
+        virtio_pci_modern_region_unmap(proxy, &proxy->notify);
+    }
 }
 
 static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp)
-- 
MST

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PULL 06/10] virtio: get_features() can fail
  2015-07-28  9:57 [Qemu-devel] [PULL 00/10] virtio fixes for 2.4 Michael S. Tsirkin
                   ` (4 preceding siblings ...)
  2015-07-28  9:57 ` [Qemu-devel] [PULL 05/10] virtio-pci: fix memory MR cleanup for modern Michael S. Tsirkin
@ 2015-07-28  9:57 ` Michael S. Tsirkin
  2015-07-28  9:57 ` [Qemu-devel] [PULL 07/10] virtio-blk: fail get_features when both scsi and 1.0 were set Michael S. Tsirkin
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Michael S. Tsirkin @ 2015-07-28  9:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Peter Maydell, qemu-block, Jason Wang,
	Aneesh Kumar K.V, Stefan Hajnoczi, Amit Shah, Paolo Bonzini,
	Gerd Hoffmann

From: Jason Wang <jasowang@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>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
---
 include/hw/virtio/virtio.h  | 4 +++-
 hw/9pfs/virtio-9p-device.c  | 3 ++-
 hw/block/virtio-blk.c       | 3 ++-
 hw/char/virtio-serial-bus.c | 3 ++-
 hw/display/virtio-gpu.c     | 3 ++-
 hw/input/virtio-input.c     | 3 ++-
 hw/net/virtio-net.c         | 3 ++-
 hw/scsi/vhost-scsi.c        | 3 ++-
 hw/scsi/virtio-scsi.c       | 3 ++-
 hw/virtio/virtio-balloon.c  | 3 ++-
 hw/virtio/virtio-bus.c      | 3 ++-
 hw/virtio/virtio-rng.c      | 2 +-
 12 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index ff91711..59f0763 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -101,7 +101,9 @@ typedef struct VirtioDeviceClass {
     /* This is what a VirtioDevice must implement */
     DeviceRealize realize;
     DeviceUnrealize unrealize;
-    uint64_t (*get_features)(VirtIODevice *vdev, uint64_t requested_features);
+    uint64_t (*get_features)(VirtIODevice *vdev,
+                             uint64_t requested_features,
+                             Error **errp);
     uint64_t (*bad_features)(VirtIODevice *vdev);
     void (*set_features)(VirtIODevice *vdev, uint64_t val);
     int (*validate_features)(VirtIODevice *vdev);
diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c
index 3f4c9e7..93a407c 100644
--- a/hw/9pfs/virtio-9p-device.c
+++ b/hw/9pfs/virtio-9p-device.c
@@ -21,7 +21,8 @@
 #include "virtio-9p-coth.h"
 #include "hw/virtio/virtio-access.h"
 
-static uint64_t virtio_9p_get_features(VirtIODevice *vdev, uint64_t features)
+static uint64_t virtio_9p_get_features(VirtIODevice *vdev, uint64_t features,
+                                       Error **errp)
 {
     virtio_add_feature(&features, VIRTIO_9P_MOUNT_TAG);
     return features;
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 015b9b5..a6cf008 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -722,7 +722,8 @@ static void virtio_blk_set_config(VirtIODevice *vdev, const uint8_t *config)
     aio_context_release(blk_get_aio_context(s->blk));
 }
 
-static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features)
+static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features,
+                                        Error **errp)
 {
     VirtIOBlock *s = VIRTIO_BLK(vdev);
 
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index 929e49c..bc56f5d 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -500,7 +500,8 @@ static void handle_input(VirtIODevice *vdev, VirtQueue *vq)
     }
 }
 
-static uint64_t get_features(VirtIODevice *vdev, uint64_t features)
+static uint64_t get_features(VirtIODevice *vdev, uint64_t features,
+                             Error **errp)
 {
     VirtIOSerial *vser;
 
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 990a26b..a67d927 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -89,7 +89,8 @@ static void virtio_gpu_set_config(VirtIODevice *vdev, const uint8_t *config)
     }
 }
 
-static uint64_t virtio_gpu_get_features(VirtIODevice *vdev, uint64_t features)
+static uint64_t virtio_gpu_get_features(VirtIODevice *vdev, uint64_t features,
+                                        Error **errp)
 {
     return features;
 }
diff --git a/hw/input/virtio-input.c b/hw/input/virtio-input.c
index 7f5b8d6..7b25d27 100644
--- a/hw/input/virtio-input.c
+++ b/hw/input/virtio-input.c
@@ -166,7 +166,8 @@ static void virtio_input_set_config(VirtIODevice *vdev,
     virtio_notify_config(vdev);
 }
 
-static uint64_t virtio_input_get_features(VirtIODevice *vdev, uint64_t f)
+static uint64_t virtio_input_get_features(VirtIODevice *vdev, uint64_t f,
+                                          Error **errp)
 {
     return f;
 }
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index e203058..1510839 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -446,7 +446,8 @@ static void virtio_net_set_queues(VirtIONet *n)
 
 static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue);
 
-static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features)
+static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features,
+                                        Error **errp)
 {
     VirtIONet *n = VIRTIO_NET(vdev);
     NetClientState *nc = qemu_get_queue(n->nic);
diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
index 52549f8..a69918b 100644
--- a/hw/scsi/vhost-scsi.c
+++ b/hw/scsi/vhost-scsi.c
@@ -153,7 +153,8 @@ static void vhost_scsi_stop(VHostSCSI *s)
 }
 
 static uint64_t vhost_scsi_get_features(VirtIODevice *vdev,
-                                        uint64_t features)
+                                        uint64_t features,
+                                        Error **errp)
 {
     VHostSCSI *s = VHOST_SCSI(vdev);
 
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index d17698d..811c3da 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -629,7 +629,8 @@ static void virtio_scsi_set_config(VirtIODevice *vdev,
 }
 
 static uint64_t virtio_scsi_get_features(VirtIODevice *vdev,
-                                         uint64_t requested_features)
+                                         uint64_t requested_features,
+                                         Error **errp)
 {
     VirtIOSCSI *s = VIRTIO_SCSI(vdev);
 
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 2990f8d..3577b7a 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -310,7 +310,8 @@ static void virtio_balloon_set_config(VirtIODevice *vdev,
     trace_virtio_balloon_set_config(dev->actual, oldactual);
 }
 
-static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f)
+static uint64_t virtio_balloon_get_features(VirtIODevice *vdev, uint64_t f,
+                                            Error **errp)
 {
     VirtIOBalloon *dev = VIRTIO_BALLOON(vdev);
     f |= dev->host_features;
diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c
index 3926f7e..febda76 100644
--- a/hw/virtio/virtio-bus.c
+++ b/hw/virtio/virtio-bus.c
@@ -54,7 +54,8 @@ void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp)
 
     /* Get the features of the plugged device. */
     assert(vdc->get_features != NULL);
-    vdev->host_features = vdc->get_features(vdev, vdev->host_features);
+    vdev->host_features = vdc->get_features(vdev, vdev->host_features,
+                                            errp);
 }
 
 /* Reset the virtio_bus */
diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
index 6e5f022..97d1541 100644
--- a/hw/virtio/virtio-rng.c
+++ b/hw/virtio/virtio-rng.c
@@ -104,7 +104,7 @@ static void handle_input(VirtIODevice *vdev, VirtQueue *vq)
     virtio_rng_process(vrng);
 }
 
-static uint64_t get_features(VirtIODevice *vdev, uint64_t f)
+static uint64_t get_features(VirtIODevice *vdev, uint64_t f, Error **errp)
 {
     return f;
 }
-- 
MST

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PULL 07/10] virtio-blk: fail get_features when both scsi and 1.0 were set
  2015-07-28  9:57 [Qemu-devel] [PULL 00/10] virtio fixes for 2.4 Michael S. Tsirkin
                   ` (5 preceding siblings ...)
  2015-07-28  9:57 ` [Qemu-devel] [PULL 06/10] virtio: get_features() can fail Michael S. Tsirkin
@ 2015-07-28  9:57 ` Michael S. Tsirkin
  2015-07-28  9:57 ` [Qemu-devel] [PULL 08/10] virtio-blk: only clear VIRTIO_F_ANY_LAYOUT for legacy device Michael S. Tsirkin
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Michael S. Tsirkin @ 2015-07-28  9:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Peter Maydell, qemu-block, Jason Wang,
	Stefan Hajnoczi, Paolo Bonzini

From: Jason Wang <jasowang@redhat.com>

SCSI passthrough was no longer supported in virtio 1.0, so this patch
fail the get_features() when both 1.0 and scsi is set. And also only
advertise VIRTIO_BLK_F_SCSI for legacy virtio-blk device.

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>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/block/virtio-blk.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index a6cf008..ebd9d84 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -731,8 +731,16 @@ static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features,
     virtio_add_feature(&features, VIRTIO_BLK_F_GEOMETRY);
     virtio_add_feature(&features, VIRTIO_BLK_F_TOPOLOGY);
     virtio_add_feature(&features, VIRTIO_BLK_F_BLK_SIZE);
-    virtio_add_feature(&features, VIRTIO_BLK_F_SCSI);
     virtio_clear_feature(&features, VIRTIO_F_ANY_LAYOUT);
+    if (__virtio_has_feature(features, VIRTIO_F_VERSION_1)) {
+        if (s->conf.scsi) {
+            error_setg(errp, "Please set scsi=off for virtio-blk devices in order to use virtio 1.0");
+            return 0;
+        }
+        virtio_add_feature(&features, VIRTIO_F_ANY_LAYOUT);
+    } else {
+        virtio_add_feature(&features, VIRTIO_BLK_F_SCSI);
+    }
 
     if (s->conf.config_wce) {
         virtio_add_feature(&features, VIRTIO_BLK_F_CONFIG_WCE);
-- 
MST

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PULL 08/10] virtio-blk: only clear VIRTIO_F_ANY_LAYOUT for legacy device
  2015-07-28  9:57 [Qemu-devel] [PULL 00/10] virtio fixes for 2.4 Michael S. Tsirkin
                   ` (6 preceding siblings ...)
  2015-07-28  9:57 ` [Qemu-devel] [PULL 07/10] virtio-blk: fail get_features when both scsi and 1.0 were set Michael S. Tsirkin
@ 2015-07-28  9:57 ` Michael S. Tsirkin
  2015-07-28  9:57 ` [Qemu-devel] [PULL 09/10] acpi: fix pvpanic device is not shown in ui Michael S. Tsirkin
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Michael S. Tsirkin @ 2015-07-28  9:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Peter Maydell, qemu-block, Jason Wang,
	Stefan Hajnoczi, Paolo Bonzini

From: Jason Wang <jasowang@redhat.com>

Chapter 6.3 of spec said

"
Transitional devices MUST offer, and if offered by the device
transitional drivers MUST accept the following:

VIRTIO_F_ANY_LAYOUT (27)
"

So this patch only clear VIRTIO_F_LAYOUT for legacy device.

Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-block@nongnu.org
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>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/block/virtio-blk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index ebd9d84..44f9b8e 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -731,7 +731,6 @@ static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features,
     virtio_add_feature(&features, VIRTIO_BLK_F_GEOMETRY);
     virtio_add_feature(&features, VIRTIO_BLK_F_TOPOLOGY);
     virtio_add_feature(&features, VIRTIO_BLK_F_BLK_SIZE);
-    virtio_clear_feature(&features, VIRTIO_F_ANY_LAYOUT);
     if (__virtio_has_feature(features, VIRTIO_F_VERSION_1)) {
         if (s->conf.scsi) {
             error_setg(errp, "Please set scsi=off for virtio-blk devices in order to use virtio 1.0");
@@ -739,6 +738,7 @@ static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features,
         }
         virtio_add_feature(&features, VIRTIO_F_ANY_LAYOUT);
     } else {
+        virtio_clear_feature(&features, VIRTIO_F_ANY_LAYOUT);
         virtio_add_feature(&features, VIRTIO_BLK_F_SCSI);
     }
 
-- 
MST

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PULL 09/10] acpi: fix pvpanic device is not shown in ui
  2015-07-28  9:57 [Qemu-devel] [PULL 00/10] virtio fixes for 2.4 Michael S. Tsirkin
                   ` (7 preceding siblings ...)
  2015-07-28  9:57 ` [Qemu-devel] [PULL 08/10] virtio-blk: only clear VIRTIO_F_ANY_LAYOUT for legacy device Michael S. Tsirkin
@ 2015-07-28  9:57 ` Michael S. Tsirkin
  2015-07-28  9:58 ` [Qemu-devel] [PULL 10/10] virtio: minor cleanup Michael S. Tsirkin
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Michael S. Tsirkin @ 2015-07-28  9:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Eduardo Habkost, Gal Hammer, Igor Mammedov,
	Paolo Bonzini, Richard Henderson

From: Gal Hammer <ghammer@redhat.com>

Commit 2332333c added a _STA method that hides the device. The fact
that the device is not shown in the gui make it harder to install its
Windows' device.

https://bugzilla.redhat.com/show_bug.cgi?id=1238141

Signed-off-by: Gal Hammer <ghammer@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
---
 hw/i386/acpi-build.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index aed811a..46eddb8 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1108,8 +1108,8 @@ build_ssdt(GArray *table_data, GArray *linker,
         aml_append(field, aml_named_field("PEPT", 8));
         aml_append(dev, field);
 
-        /* device present, functioning, decoding, not shown in UI */
-        aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
+        /* device present, functioning, decoding, shown in UI */
+        aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
 
         method = aml_method("RDPT", 0);
         aml_append(method, aml_store(aml_name("PEPT"), aml_local(0)));
-- 
MST

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [Qemu-devel] [PULL 10/10] virtio: minor cleanup
  2015-07-28  9:57 [Qemu-devel] [PULL 00/10] virtio fixes for 2.4 Michael S. Tsirkin
                   ` (8 preceding siblings ...)
  2015-07-28  9:57 ` [Qemu-devel] [PULL 09/10] acpi: fix pvpanic device is not shown in ui Michael S. Tsirkin
@ 2015-07-28  9:58 ` Michael S. Tsirkin
  2015-07-28 10:39 ` [Qemu-devel] [PULL 00/10] virtio fixes for 2.4 Cornelia Huck
  2015-07-28 18:01 ` Peter Maydell
  11 siblings, 0 replies; 13+ messages in thread
From: Michael S. Tsirkin @ 2015-07-28  9:58 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, Peter Maydell, qemu-block, Stefan Hajnoczi

There's no need for blk to set ANY_LAYOUT, it's
done by virtio core as necessary.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/block/virtio-blk.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 44f9b8e..1556c9c 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -736,7 +736,6 @@ static uint64_t virtio_blk_get_features(VirtIODevice *vdev, uint64_t features,
             error_setg(errp, "Please set scsi=off for virtio-blk devices in order to use virtio 1.0");
             return 0;
         }
-        virtio_add_feature(&features, VIRTIO_F_ANY_LAYOUT);
     } else {
         virtio_clear_feature(&features, VIRTIO_F_ANY_LAYOUT);
         virtio_add_feature(&features, VIRTIO_BLK_F_SCSI);
-- 
MST

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PULL 00/10] virtio fixes for 2.4
  2015-07-28  9:57 [Qemu-devel] [PULL 00/10] virtio fixes for 2.4 Michael S. Tsirkin
                   ` (9 preceding siblings ...)
  2015-07-28  9:58 ` [Qemu-devel] [PULL 10/10] virtio: minor cleanup Michael S. Tsirkin
@ 2015-07-28 10:39 ` Cornelia Huck
  2015-07-28 18:01 ` Peter Maydell
  11 siblings, 0 replies; 13+ messages in thread
From: Cornelia Huck @ 2015-07-28 10:39 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: Peter Maydell, qemu-devel

On Tue, 28 Jul 2015 12:57:29 +0300
"Michael S. Tsirkin" <mst@redhat.com> wrote:

> ----------------------------------------------------------------
> virtio fixes for 2.4
> 
> Mostly virtio 1 spec compliance fixes.
> We are unlikely to make it perfectly compliant in
> the first release, but it seems worth it to try.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> 
> ----------------------------------------------------------------

FWIW, I think the feature bit tango in the various virtio-blk patches
is a bit confusing, but the end result looks sane. A bit wary of doing
these changes that late in the release cycle, but it survives some
light testing and seems fine for virtio-ccw revision 1 enablement as
well.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Qemu-devel] [PULL 00/10] virtio fixes for 2.4
  2015-07-28  9:57 [Qemu-devel] [PULL 00/10] virtio fixes for 2.4 Michael S. Tsirkin
                   ` (10 preceding siblings ...)
  2015-07-28 10:39 ` [Qemu-devel] [PULL 00/10] virtio fixes for 2.4 Cornelia Huck
@ 2015-07-28 18:01 ` Peter Maydell
  11 siblings, 0 replies; 13+ messages in thread
From: Peter Maydell @ 2015-07-28 18:01 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: QEMU Developers

On 28 July 2015 at 10:57, Michael S. Tsirkin <mst@redhat.com> wrote:
> The following changes since commit b69b30532e0a80e25449244c01b0cbed000c99a3:
>
>   Update version for v2.4.0-rc2 release (2015-07-22 18:17:19 +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 c147b5153e733a14fc65d2098e7036754c185ad1:
>
>   virtio: minor cleanup (2015-07-27 23:55:27 +0300)
>
> ----------------------------------------------------------------
> virtio fixes for 2.4
>
> Mostly virtio 1 spec compliance fixes.
> We are unlikely to make it perfectly compliant in
> the first release, but it seems worth it to try.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-07-28 18:02 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-28  9:57 [Qemu-devel] [PULL 00/10] virtio fixes for 2.4 Michael S. Tsirkin
2015-07-28  9:57 ` [Qemu-devel] [PULL 01/10] virtio: hide legacy features from modern guests Michael S. Tsirkin
2015-07-28  9:57 ` [Qemu-devel] [PULL 02/10] virtio-serial: fix ANY_LAYOUT Michael S. Tsirkin
2015-07-28  9:57 ` [Qemu-devel] [PULL 03/10] virtio-9p: fix any_layout Michael S. Tsirkin
2015-07-28  9:57 ` [Qemu-devel] [PULL 04/10] virtio: set any_layout in virtio core Michael S. Tsirkin
2015-07-28  9:57 ` [Qemu-devel] [PULL 05/10] virtio-pci: fix memory MR cleanup for modern Michael S. Tsirkin
2015-07-28  9:57 ` [Qemu-devel] [PULL 06/10] virtio: get_features() can fail Michael S. Tsirkin
2015-07-28  9:57 ` [Qemu-devel] [PULL 07/10] virtio-blk: fail get_features when both scsi and 1.0 were set Michael S. Tsirkin
2015-07-28  9:57 ` [Qemu-devel] [PULL 08/10] virtio-blk: only clear VIRTIO_F_ANY_LAYOUT for legacy device Michael S. Tsirkin
2015-07-28  9:57 ` [Qemu-devel] [PULL 09/10] acpi: fix pvpanic device is not shown in ui Michael S. Tsirkin
2015-07-28  9:58 ` [Qemu-devel] [PULL 10/10] virtio: minor cleanup Michael S. Tsirkin
2015-07-28 10:39 ` [Qemu-devel] [PULL 00/10] virtio fixes for 2.4 Cornelia Huck
2015-07-28 18:01 ` Peter Maydell

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).