qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
To: snabb-devel@googlegroups.com, qemu-devel@nongnu.org, mst@redhat.com
Cc: tech@virtualopensystems.com, n.nikolaev@virtualopensystems.com
Subject: [Qemu-devel] [PATCH v2 2/2 for-2.1] qtest: Adapt vhost-user-test to latehs vhost-user changes
Date: Sat, 12 Jul 2014 04:43:19 +0300	[thread overview]
Message-ID: <20140712014254.10636.31208.stgit@3820> (raw)
In-Reply-To: <20140712014119.10636.81503.stgit@3820>

A new field mmap_offset was added in the vhost-user message, we need to reflect
this change in the test too.

Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
---
 tests/vhost-user-test.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 406ba70..75fedf0 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -76,6 +76,7 @@ typedef struct VhostUserMemoryRegion {
     uint64_t guest_phys_addr;
     uint64_t memory_size;
     uint64_t userspace_addr;
+    uint64_t mmap_offset;
 } VhostUserMemoryRegion;
 
 typedef struct VhostUserMemory {
@@ -205,6 +206,7 @@ static void read_guest_mem(void)
     uint32_t *guest_mem;
     gint64 end_time;
     int i, j;
+    size_t size;
 
     g_mutex_lock(data_mutex);
 
@@ -231,8 +233,13 @@ static void read_guest_mem(void)
 
         g_assert_cmpint(memory.regions[i].memory_size, >, 1024);
 
-        guest_mem = mmap(0, memory.regions[i].memory_size,
-        PROT_READ | PROT_WRITE, MAP_SHARED, fds[i], 0);
+        size =  memory.regions[i].memory_size + memory.regions[i].mmap_offset;
+
+        guest_mem = mmap(0, size, PROT_READ | PROT_WRITE,
+                         MAP_SHARED, fds[i], 0);
+
+        g_assert(guest_mem != MAP_FAILED);
+        guest_mem += (memory.regions[i].mmap_offset / sizeof(*guest_mem));
 
         for (j = 0; j < 256; j++) {
             uint32_t a = readl(memory.regions[i].guest_phys_addr + j*4);

      parent reply	other threads:[~2014-07-12  1:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-12  1:42 [Qemu-devel] [PATCH v2 0/2 for-2.1] vhost-user fixes Nikolay Nikolaev
2014-07-12  1:42 ` [Qemu-devel] [PATCH v2 1/2 for-2.1] vhost-user: Fix VHOST_SET_MEM_TABLE processing Nikolay Nikolaev
2014-07-12  5:07   ` Paolo Bonzini
2014-07-12  9:04   ` Nikolay Nikolaev
2014-07-12  1:43 ` Nikolay Nikolaev [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140712014254.10636.31208.stgit@3820 \
    --to=n.nikolaev@virtualopensystems.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=snabb-devel@googlegroups.com \
    --cc=tech@virtualopensystems.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).