qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL v2 0/7] pc,vhost,test fixes
@ 2014-07-17 23:44 Michael S. Tsirkin
  2014-07-17 23:44 ` [Qemu-devel] [PULL v2 1/7] pc: fix qemu exiting with error when -m X < 128 with old machines types Michael S. Tsirkin
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2014-07-17 23:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Anthony Liguori

Resending.
v1 has exactly the same patches but had the wrong text in the tag.
Sorry about that.

The following changes since commit 3f0838ab8557c6071a5931183b2d7fed568cd35c:

  qemu-char: add chr_add_watch support in mux chardev (2014-07-06 09:13:54 +0300)

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 cd98639f673d92836b6b5fd60279b411748f2f1e:

  vhost-user: minor cleanups (2014-07-18 02:22:24 +0300)

----------------------------------------------------------------
pc,vhost,test fixes

Minor bugfixes all over the place.

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

----------------------------------------------------------------
Eduardo Habkost (1):
      pc_piix: Reuse pc_compat_1_2() for pc-0.1[0123]

Hu Tao (1):
      fix typo: apci -> acpi

Igor Mammedov (1):
      pc: fix qemu exiting with error when -m X < 128 with old machines types

Michael S. Tsirkin (1):
      vhost-user: minor cleanups

Nikolay Nikolaev (3):
      qtest: fix vhost-user-test compilation with old GLib
      vhost-user: Fix VHOST_SET_MEM_TABLE processing
      qtest: Adapt vhost-user-test to latest vhost-user changes

 hw/acpi/ich9.c          |  4 ++--
 hw/i386/pc_piix.c       | 13 ++-----------
 hw/virtio/vhost-user.c  |  6 +++++-
 tests/vhost-user-test.c | 15 +++++++++++++--
 vl.c                    |  1 +
 5 files changed, 23 insertions(+), 16 deletions(-)

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

* [Qemu-devel] [PULL v2 1/7] pc: fix qemu exiting with error when -m X < 128 with old machines types
  2014-07-17 23:44 [Qemu-devel] [PULL v2 0/7] pc,vhost,test fixes Michael S. Tsirkin
@ 2014-07-17 23:44 ` Michael S. Tsirkin
  2014-07-17 23:44 ` [Qemu-devel] [PULL v2 2/7] pc_piix: Reuse pc_compat_1_2() for pc-0.1[0123] Michael S. Tsirkin
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2014-07-17 23:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Bruce Rogers, Anthony Liguori, Igor Mammedov

From: Igor Mammedov <imammedo@redhat.com>

If machine doesn't support memory hotplug then staring QEMU
with initial memory less than default will make QEMU exit with
following error message:

$QEMU -m 16  -M isapc
qemu-system-i386: "-memory 'slots|maxmem'" is not supported by: isapc

Set maxram_size to initial memory value before parsing
'maxmem' option allows to keep maxmem in sync with initial
memory size if no maxmem option was specified.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
CC: Bruce Rogers <brogers@suse.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 vl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/vl.c b/vl.c
index 6e084c2..6abedcf 100644
--- a/vl.c
+++ b/vl.c
@@ -3315,6 +3315,7 @@ int main(int argc, char **argv, char **envp)
                     error_report("ram size too large");
                     exit(EXIT_FAILURE);
                 }
+                maxram_size = ram_size;
 
                 maxmem_str = qemu_opt_get(opts, "maxmem");
                 slots_str = qemu_opt_get(opts, "slots");
-- 
MST

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

* [Qemu-devel] [PULL v2 2/7] pc_piix: Reuse pc_compat_1_2() for pc-0.1[0123]
  2014-07-17 23:44 [Qemu-devel] [PULL v2 0/7] pc,vhost,test fixes Michael S. Tsirkin
  2014-07-17 23:44 ` [Qemu-devel] [PULL v2 1/7] pc: fix qemu exiting with error when -m X < 128 with old machines types Michael S. Tsirkin
@ 2014-07-17 23:44 ` Michael S. Tsirkin
  2014-07-17 23:44 ` [Qemu-devel] [PULL v2 3/7] fix typo: apci -> acpi Michael S. Tsirkin
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2014-07-17 23:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Eduardo Habkost, Anthony Liguori

From: Eduardo Habkost <ehabkost@redhat.com>

pc-0.13 and older were missing some compat code that was present on
newer machine-types:

* x86_cpu_compat_disable_kvm_features(FEAT_1_ECX, CPUID_EXT_X2APIC);
  (pc-i440fx-1.7 and older)
  (added by commit ef02ef5f4536dba090b12360a6c862ef0e57e3bc)
* x86_cpu_compat_set_features("n270", FEAT_1_ECX, 0, CPUID_EXT_MOVBE);
  (pc-i440fx-1.4 and older)
  (added by commit 4458c23672904fa131e69897007eeb7c953be7e5
* x86_cpu_compat_set_features("Westmere", FEAT_1_ECX, 0, CPUID_EXT_PCLMULQDQ);
  (pc-i440fx-1.4 and older)
  (added by commit 56383703c060777fd01aaf8d63d5f46d660e9fb9)

Instead of duplicating the code from the previous pc_compat_*()
functions, we can now reuse pc_compat_1_2() and fix those issues.

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 | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 2dccb34..ec8ccdb 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -386,19 +386,10 @@ static void pc_init_pci_1_2(MachineState *machine)
     pc_init_pci(machine);
 }
 
-/* PC init function for pc-0.10 to pc-0.13, and reused by xenfv */
+/* PC init function for pc-0.10 to pc-0.13 */
 static void pc_init_pci_no_kvmclock(MachineState *machine)
 {
-    has_pci_info = false;
-    has_acpi_build = false;
-    smbios_defaults = false;
-    gigabyte_align = false;
-    smbios_legacy_mode = true;
-    has_reserved_memory = false;
-    option_rom_has_mr = true;
-    rom_file_has_mr = false;
-    x86_cpu_compat_disable_kvm_features(FEAT_KVM, KVM_FEATURE_PV_EOI);
-    enable_compat_apic_id_mode();
+    pc_compat_1_2(machine);
     pc_init1(machine, 1, 0);
 }
 
-- 
MST

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

* [Qemu-devel] [PULL v2 3/7] fix typo: apci -> acpi
  2014-07-17 23:44 [Qemu-devel] [PULL v2 0/7] pc,vhost,test fixes Michael S. Tsirkin
  2014-07-17 23:44 ` [Qemu-devel] [PULL v2 1/7] pc: fix qemu exiting with error when -m X < 128 with old machines types Michael S. Tsirkin
  2014-07-17 23:44 ` [Qemu-devel] [PULL v2 2/7] pc_piix: Reuse pc_compat_1_2() for pc-0.1[0123] Michael S. Tsirkin
@ 2014-07-17 23:44 ` Michael S. Tsirkin
  2014-07-17 23:44 ` [Qemu-devel] [PULL v2 4/7] qtest: fix vhost-user-test compilation with old GLib Michael S. Tsirkin
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2014-07-17 23:44 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, =?UTF-8?q?Andreas=20F=C3=A4rber?=, Anthony Liguori,
	Hu Tao

From: Hu Tao <hutao@cn.fujitsu.com>

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

MST: rebase
---
 hw/acpi/ich9.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index e7d6c77..7b14bbb 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -232,11 +232,11 @@ void ich9_pm_init(PCIDevice *lpc_pci, ICH9LPCPMRegs *pm,
 
     acpi_gpe_init(&pm->acpi_regs, ICH9_PMIO_GPE0_LEN);
     memory_region_init_io(&pm->io_gpe, OBJECT(lpc_pci), &ich9_gpe_ops, pm,
-                          "apci-gpe0", ICH9_PMIO_GPE0_LEN);
+                          "acpi-gpe0", ICH9_PMIO_GPE0_LEN);
     memory_region_add_subregion(&pm->io, ICH9_PMIO_GPE0_STS, &pm->io_gpe);
 
     memory_region_init_io(&pm->io_smi, OBJECT(lpc_pci), &ich9_smi_ops, pm,
-                          "apci-smi", 8);
+                          "acpi-smi", 8);
     memory_region_add_subregion(&pm->io, ICH9_PMIO_SMI_EN, &pm->io_smi);
 
     pm->irq = sci_irq;
-- 
MST

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

* [Qemu-devel] [PULL v2 4/7] qtest: fix vhost-user-test compilation with old GLib
  2014-07-17 23:44 [Qemu-devel] [PULL v2 0/7] pc,vhost,test fixes Michael S. Tsirkin
                   ` (2 preceding siblings ...)
  2014-07-17 23:44 ` [Qemu-devel] [PULL v2 3/7] fix typo: apci -> acpi Michael S. Tsirkin
@ 2014-07-17 23:44 ` Michael S. Tsirkin
  2014-07-17 23:44 ` [Qemu-devel] [PULL v2 5/7] vhost-user: Fix VHOST_SET_MEM_TABLE processing Michael S. Tsirkin
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2014-07-17 23:44 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Peter Maydell, Nikolay Nikolaev, Anthony Liguori,
	Antonios Motakis

From: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>

Mising G_TIME_SPAN_SECOND definition breaks the RHEL6 compilation as GLib
version before 2.26 does not have it. In such case just define it.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 tests/vhost-user-test.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tests/vhost-user-test.c b/tests/vhost-user-test.c
index 2af2381..406ba70 100644
--- a/tests/vhost-user-test.c
+++ b/tests/vhost-user-test.c
@@ -22,6 +22,10 @@
 #include <qemu/sockets.h>
 
 /* GLIB version compatibility flags */
+#if !GLIB_CHECK_VERSION(2, 26, 0)
+#define G_TIME_SPAN_SECOND              (G_GINT64_CONSTANT(1000000))
+#endif
+
 #if GLIB_CHECK_VERSION(2, 28, 0)
 #define HAVE_MONOTONIC_TIME
 #endif
-- 
MST

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

* [Qemu-devel] [PULL v2 5/7] vhost-user: Fix VHOST_SET_MEM_TABLE processing
  2014-07-17 23:44 [Qemu-devel] [PULL v2 0/7] pc,vhost,test fixes Michael S. Tsirkin
                   ` (3 preceding siblings ...)
  2014-07-17 23:44 ` [Qemu-devel] [PULL v2 4/7] qtest: fix vhost-user-test compilation with old GLib Michael S. Tsirkin
@ 2014-07-17 23:44 ` Michael S. Tsirkin
  2014-07-17 23:44 ` [Qemu-devel] [PULL v2 6/7] qtest: Adapt vhost-user-test to latest vhost-user changes Michael S. Tsirkin
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2014-07-17 23:44 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Nikolay Nikolaev, Anthony Liguori, Paolo Bonzini

From: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>

qemu_get_ram_fd doesn't accept a guest physical address. ram_addr_t are
opaque values that are assigned in qemu_ram_alloc.

Find the ram_addr_t corresponding to the userspace_addr using qemu_ram_addr_from_host,
and then call qemu_get_ram_fd on it.

Thanks to Paolo Bonzini <pbonzini@redhat.com>

Signed-off-by: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/virtio/vhost-user.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 38e5806..3d23218 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -216,7 +216,9 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
     case VHOST_SET_MEM_TABLE:
         for (i = 0; i < dev->mem->nregions; ++i) {
             struct vhost_memory_region *reg = dev->mem->regions + i;
-            fd = qemu_get_ram_fd(reg->guest_phys_addr);
+            ram_addr_t ram_addr;
+            qemu_ram_addr_from_host((void *)reg->userspace_addr, &ram_addr);
+            fd = qemu_get_ram_fd(ram_addr);
             if (fd > 0) {
                 msg.memory.regions[fd_num].userspace_addr = reg->userspace_addr;
                 msg.memory.regions[fd_num].memory_size  = reg->memory_size;
-- 
MST

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

* [Qemu-devel] [PULL v2 6/7] qtest: Adapt vhost-user-test to latest vhost-user changes
  2014-07-17 23:44 [Qemu-devel] [PULL v2 0/7] pc,vhost,test fixes Michael S. Tsirkin
                   ` (4 preceding siblings ...)
  2014-07-17 23:44 ` [Qemu-devel] [PULL v2 5/7] vhost-user: Fix VHOST_SET_MEM_TABLE processing Michael S. Tsirkin
@ 2014-07-17 23:44 ` Michael S. Tsirkin
  2014-09-13  9:48   ` Linhaifeng
  2014-07-17 23:44 ` [Qemu-devel] [PULL v2 7/7] vhost-user: minor cleanups Michael S. Tsirkin
  2014-07-18 12:24 ` [Qemu-devel] [PULL v2 0/7] pc,vhost,test fixes Peter Maydell
  7 siblings, 1 reply; 10+ messages in thread
From: Michael S. Tsirkin @ 2014-07-17 23:44 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Nikolay Nikolaev, Anthony Liguori,
	Antonios Motakis

From: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>

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>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.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);
-- 
MST

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

* [Qemu-devel] [PULL v2 7/7] vhost-user: minor cleanups
  2014-07-17 23:44 [Qemu-devel] [PULL v2 0/7] pc,vhost,test fixes Michael S. Tsirkin
                   ` (5 preceding siblings ...)
  2014-07-17 23:44 ` [Qemu-devel] [PULL v2 6/7] qtest: Adapt vhost-user-test to latest vhost-user changes Michael S. Tsirkin
@ 2014-07-17 23:44 ` Michael S. Tsirkin
  2014-07-18 12:24 ` [Qemu-devel] [PULL v2 0/7] pc,vhost,test fixes Peter Maydell
  7 siblings, 0 replies; 10+ messages in thread
From: Michael S. Tsirkin @ 2014-07-17 23:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Anthony Liguori

assert to verify cast does not discard information
minor style fixup.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/virtio/vhost-user.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 3d23218..4e88d9c 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -217,7 +217,9 @@ static int vhost_user_call(struct vhost_dev *dev, unsigned long int request,
         for (i = 0; i < dev->mem->nregions; ++i) {
             struct vhost_memory_region *reg = dev->mem->regions + i;
             ram_addr_t ram_addr;
-            qemu_ram_addr_from_host((void *)reg->userspace_addr, &ram_addr);
+
+            assert((uintptr_t)reg->userspace_addr == reg->userspace_addr);
+            qemu_ram_addr_from_host((void *)(uintptr_t)reg->userspace_addr, &ram_addr);
             fd = qemu_get_ram_fd(ram_addr);
             if (fd > 0) {
                 msg.memory.regions[fd_num].userspace_addr = reg->userspace_addr;
-- 
MST

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

* Re: [Qemu-devel] [PULL v2 0/7] pc,vhost,test fixes
  2014-07-17 23:44 [Qemu-devel] [PULL v2 0/7] pc,vhost,test fixes Michael S. Tsirkin
                   ` (6 preceding siblings ...)
  2014-07-17 23:44 ` [Qemu-devel] [PULL v2 7/7] vhost-user: minor cleanups Michael S. Tsirkin
@ 2014-07-18 12:24 ` Peter Maydell
  7 siblings, 0 replies; 10+ messages in thread
From: Peter Maydell @ 2014-07-18 12:24 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: QEMU Developers, Anthony Liguori

On 18 July 2014 00:44, Michael S. Tsirkin <mst@redhat.com> wrote:
> Resending.
> v1 has exactly the same patches but had the wrong text in the tag.
> Sorry about that.
>
> The following changes since commit 3f0838ab8557c6071a5931183b2d7fed568cd35c:
>
>   qemu-char: add chr_add_watch support in mux chardev (2014-07-06 09:13:54 +0300)
>
> 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 cd98639f673d92836b6b5fd60279b411748f2f1e:
>
>   vhost-user: minor cleanups (2014-07-18 02:22:24 +0300)
>
> ----------------------------------------------------------------
> pc,vhost,test fixes
>
> Minor bugfixes all over the place.
>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

Applied, thanks.

-- PMM

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

* Re: [Qemu-devel] [PULL v2 6/7] qtest: Adapt vhost-user-test to latest vhost-user changes
  2014-07-17 23:44 ` [Qemu-devel] [PULL v2 6/7] qtest: Adapt vhost-user-test to latest vhost-user changes Michael S. Tsirkin
@ 2014-09-13  9:48   ` Linhaifeng
  0 siblings, 0 replies; 10+ messages in thread
From: Linhaifeng @ 2014-09-13  9:48 UTC (permalink / raw)
  To: Michael S. Tsirkin, qemu-devel
  Cc: jerry.lilijun, Peter Maydell, Anthony Liguori, Nikolay Nikolaev,
	Antonios Motakis

How to test send data to VM?

On 2014/7/18 7:44, Michael S. Tsirkin wrote:
> From: Nikolay Nikolaev <n.nikolaev@virtualopensystems.com>
> 
> 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>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Michael S. Tsirkin <mst@redhat.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);
> 

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

end of thread, other threads:[~2014-09-13  9:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-17 23:44 [Qemu-devel] [PULL v2 0/7] pc,vhost,test fixes Michael S. Tsirkin
2014-07-17 23:44 ` [Qemu-devel] [PULL v2 1/7] pc: fix qemu exiting with error when -m X < 128 with old machines types Michael S. Tsirkin
2014-07-17 23:44 ` [Qemu-devel] [PULL v2 2/7] pc_piix: Reuse pc_compat_1_2() for pc-0.1[0123] Michael S. Tsirkin
2014-07-17 23:44 ` [Qemu-devel] [PULL v2 3/7] fix typo: apci -> acpi Michael S. Tsirkin
2014-07-17 23:44 ` [Qemu-devel] [PULL v2 4/7] qtest: fix vhost-user-test compilation with old GLib Michael S. Tsirkin
2014-07-17 23:44 ` [Qemu-devel] [PULL v2 5/7] vhost-user: Fix VHOST_SET_MEM_TABLE processing Michael S. Tsirkin
2014-07-17 23:44 ` [Qemu-devel] [PULL v2 6/7] qtest: Adapt vhost-user-test to latest vhost-user changes Michael S. Tsirkin
2014-09-13  9:48   ` Linhaifeng
2014-07-17 23:44 ` [Qemu-devel] [PULL v2 7/7] vhost-user: minor cleanups Michael S. Tsirkin
2014-07-18 12:24 ` [Qemu-devel] [PULL v2 0/7] pc,vhost,test fixes 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).