All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linhaifeng <haifeng.lin@huawei.com>
To: qemu-devel@nongnu.org
Cc: jerry.lilijun@huawei.com
Subject: [Qemu-devel] vhost-user:why region[0] always mmap failed ?
Date: Wed, 17 Sep 2014 10:33:23 +0800	[thread overview]
Message-ID: <5418F2F3.4000207@huawei.com> (raw)

Hi,

There is two memory regions when receive VHOST_SET_MEM_TABLE message:
region[0]
        gpa = 0x0
        size = 655360
        ua = 0x2aaaaac00000
        offset = 0
region[1]
        gpa = 0xC0000
        size = 2146697216
        ua = 0x2aaaaacc0000
        offset = 786432

region[0] always mmap failed.The user code is :

    for (idx = 0; idx < msg->msg.memory.nregions; idx++) {
        if (msg->fds[idx] > 0) {
            size_t size;
            uint64_t *guest_mem;
            Region *region = &vhost_server->memory.regions[i];

            region->guest_phys_addr = msg->msg.memory.regions[idx].guest_phys_addr;
            region->memory_size = msg->msg.memory.regions[idx].memory_size;
            region->userspace_addr = msg->msg.memory.regions[idx].userspace_addr;
            region->mmap_offset = msg->msg.memory.regions[idx].mmap_offset;
	
            assert(idx < msg->fd_num);
            assert(msg->fds[idx] > 0);

            size = region->memory_size + region->mmap_offset;
            guest_mem = mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, msg->fds[idx], 0);
            if (MAP_FAILED == guest_mem) {
                continue;
            }
            i++;
            guest_mem += (region->mmap_offset / sizeof(*guest_mem));
            region->mmap_addr = (uint64_t)guest_mem;
            vhost_server->memory.nregions++;
        }
    }

             reply	other threads:[~2014-09-17  2:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-17  2:33 Linhaifeng [this message]
2014-10-15 21:28 ` [Qemu-devel] vhost-user:why region[0] always mmap failed ? Anshul Makkar
2014-11-01  2:28   ` Linhaifeng

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=5418F2F3.4000207@huawei.com \
    --to=haifeng.lin@huawei.com \
    --cc=jerry.lilijun@huawei.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.