qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH RFC 2/3] virtio: misc fixes, include linux header


From: Michael S. Tsirkin
Subject: [Qemu-devel] [PATCH RFC 2/3] virtio: misc fixes, include linux header
Date: Tue, 30 Dec 2014 18:28:34 +0200

Tweak virtio core so we can use linux virtio pci header
directly without duplicating code.

Signed-off-by: Michael S. Tsirkin <address@hidden>
---
 hw/net/virtio-net.c    |  2 +-
 hw/virtio/virtio-pci.c |  3 +++
 hw/virtio/virtio.c     | 13 +++++++++----
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index b5dd356..5fff769 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1046,7 +1046,7 @@ static ssize_t virtio_net_receive(NetClientState *nc, 
const uint8_t *buf, size_t
                 return -1;
             error_report("virtio-net unexpected empty queue: "
                     "i %zd mergeable %d offset %zd, size %zd, "
-                    "guest hdr len %zd, host hdr len %zd guest features 0x%lx",
+                    "guest hdr len %zd, host hdr len %zd guest features 
0x%"PRIx64,
                     i, n->mergeable_rx_bufs, offset, size,
                     n->guest_hdr_len, n->host_hdr_len, vdev->guest_features);
             exit(1);
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
index 7382705..bc11d3d 100644
--- a/hw/virtio/virtio-pci.c
+++ b/hw/virtio/virtio-pci.c
@@ -17,6 +17,7 @@
 
 #include <inttypes.h>
 
+#include "linux-headers/linux/virtio_pci.h"
 #include "hw/virtio/virtio.h"
 #include "hw/virtio/virtio-blk.h"
 #include "hw/virtio/virtio-net.h"
@@ -76,6 +77,8 @@
                                          VIRTIO_PCI_CONFIG_MSI : \
                                          VIRTIO_PCI_CONFIG_NOMSI)
 
+#undef VIRTIO_PCI_CONFIG
+
 /* The remaining space is defined by each driver as the per-driver
  * configuration space */
 #define VIRTIO_PCI_CONFIG(dev)          (msix_enabled(dev) ? \
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 90eedd3..301b83f 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1033,7 +1033,8 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int 
version_id)
     int i, ret;
     int32_t config_len;
     uint32_t num;
-    uint32_t features;
+    uint32_t features_lo, features_hi;
+    uint64_t features;
     uint64_t supported_features;
     BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
     VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
@@ -1057,12 +1058,16 @@ int virtio_load(VirtIODevice *vdev, QEMUFile *f, int 
version_id)
     if (vdev->queue_sel >= VIRTIO_PCI_QUEUE_MAX) {
         return -1;
     }
-    qemu_get_be32s(f, &features);
+    qemu_get_be32s(f, &features_lo);
+
+    //if (features_lo & (1UL << VIRTIO_F_VERSION_1)) {
+        qemu_get_be32s(f, &features_hi);
+    //}
+    features = (((uint64_t)features_hi) << 32) | features_lo;
 
-    /* XXX features >= 32 */
     if (__virtio_set_features(vdev, features) < 0) {
         supported_features = k->get_features(qbus->parent);
-        error_report("Features 0x%x unsupported. Allowed features: 0x%lx",
+        error_report("Features 0x%"PRIx64" unsupported. Allowed features: 
0x%"PRIx64,
                      features, supported_features);
         return -1;
     }
-- 
MST




reply via email to

[Prev in Thread] Current Thread [Next in Thread]