qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Liu Ping Fan <qemulist@gmail.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Anthony Liguori <aliguori@us.ibm.com>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>,
	Stefan Hajnoczi <stefanha@gmail.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: [Qemu-devel] [PATCH 1/5] memory: add ref/unref interface for MemroyRegionOps
Date: Mon,  1 Apr 2013 16:20:30 +0800	[thread overview]
Message-ID: <1364804434-7980-2-git-send-email-qemulist@gmail.com> (raw)
In-Reply-To: <1364804434-7980-1-git-send-email-qemulist@gmail.com>

From: Liu Ping Fan <pingfank@linux.vnet.ibm.com>

This pair of interface are optinal, except for those device which is
used outside the biglock's protection for hot unplug. Currently,
HostMem used by virtio-blk dataplane is outside biglock, so the RAM
device should implement this.

Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
---
 include/exec/memory.h |   10 ++++++++++
 memory.c              |   18 ++++++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/include/exec/memory.h b/include/exec/memory.h
index 2322732..4289e62 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -55,6 +55,12 @@ struct MemoryRegionIORange {
  * Memory region callbacks
  */
 struct MemoryRegionOps {
+
+    /* ref/unref pair is optional;  ref.
+     * inc refcnt of object who store MemoryRegion
+     */
+    void (*ref)(void);
+    void (*unref)(void);
     /* Read from the memory region. @addr is relative to @mr; @size is
      * in bytes. */
     uint64_t (*read)(void *opaque,
@@ -228,6 +234,10 @@ struct MemoryListener {
     QTAILQ_ENTRY(MemoryListener) link;
 };
 
+/**/
+bool memory_region_ref(MemoryRegion *mr);
+bool memory_region_unref(MemoryRegion *mr);
+
 /**
  * memory_region_init: Initialize a memory region
  *
diff --git a/memory.c b/memory.c
index 75ca281..c29998d 100644
--- a/memory.c
+++ b/memory.c
@@ -786,6 +786,24 @@ static bool memory_region_wrong_endianness(MemoryRegion *mr)
 #endif
 }
 
+bool memory_region_ref(MemoryRegion *mr)
+{
+    if (mr->ops && mr->ops->ref) {
+        mr->ops->ref();
+        return true;
+    }
+    return false;
+}
+
+bool memory_region_unref(MemoryRegion *mr)
+{
+    if (mr->ops && mr->ops->unref) {
+        mr->ops->unref();
+        return true;
+    }
+    return false;
+}
+
 void memory_region_init(MemoryRegion *mr,
                         const char *name,
                         uint64_t size)
-- 
1.7.4.4

  reply	other threads:[~2013-04-01  8:21 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-01  8:20 [Qemu-devel] [PATCH 0/5] proposal to make hostmem listener RAM unplug safe Liu Ping Fan
2013-04-01  8:20 ` Liu Ping Fan [this message]
2013-04-11  9:49   ` [Qemu-devel] [PATCH 1/5] memory: add ref/unref interface for MemroyRegionOps Stefan Hajnoczi
2013-04-12  4:12     ` liu ping fan
2013-04-01  8:20 ` [Qemu-devel] [PATCH 2/5] hostmem: make hostmem global and RAM hotunplg safe Liu Ping Fan
2013-04-02  6:11   ` li guang
2013-04-11 10:09   ` Paolo Bonzini
2013-04-12  6:46     ` liu ping fan
2013-04-12  8:21       ` Stefan Hajnoczi
2013-04-11 10:11   ` Stefan Hajnoczi
2013-04-11 10:26     ` Paolo Bonzini
2013-04-12  3:55     ` liu ping fan
2013-04-12  8:38       ` Stefan Hajnoczi
2013-04-12 10:03         ` Paolo Bonzini
2013-04-15  1:42           ` liu ping fan
2013-04-15  6:38             ` Paolo Bonzini
2013-04-01  8:20 ` [Qemu-devel] [PATCH 3/5] vring: use hostmem's RAM safe api Liu Ping Fan
2013-04-11 10:15   ` Stefan Hajnoczi
2013-04-12  4:49     ` liu ping fan
2013-04-12  8:41       ` Stefan Hajnoczi
2013-04-01  8:20 ` [Qemu-devel] [PATCH 4/5] virtio-blk: release reference to RAM's memoryRegion Liu Ping Fan
2013-04-02  5:58   ` li guang
2013-04-12  4:44     ` liu ping fan
2013-04-11 10:20   ` Stefan Hajnoczi
2013-04-12  4:48     ` liu ping fan
2013-04-12  8:45       ` Stefan Hajnoczi
2013-04-12  9:05         ` liu ping fan
2013-04-16  7:57           ` Stefan Hajnoczi
2013-04-16  8:12             ` Paolo Bonzini
2013-04-01  8:20 ` [Qemu-devel] [PATCH 5/5] hostmem: init/finalize hostmem listener Liu Ping Fan
2013-04-11 10:02   ` Paolo Bonzini
2013-04-11 12:08     ` liu ping fan
2013-04-11 13:14       ` Paolo Bonzini
2013-06-13  4:38   ` [Qemu-devel] about atexit() (was: [PATCH 5/5] hostmem: init/finalize hostmem listener) Amos Kong
2013-06-13  8:51     ` liu ping fan

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=1364804434-7980-2-git-send-email-qemulist@gmail.com \
    --to=qemulist@gmail.com \
    --cc=aliguori@us.ibm.com \
    --cc=jan.kiszka@siemens.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=vasilis.liaskovitis@profitbricks.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).