Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L2qmD-0006XE-9y for qemu-devel@nongnu.org; Wed, 19 Nov 2008 12:23:41 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L2qmC-0006Wl-MK for qemu-devel@nongnu.org; Wed, 19 Nov 2008 12:23:40 -0500 Received: from [199.232.76.173] (port=38918 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L2qmC-0006Wc-Hv for qemu-devel@nongnu.org; Wed, 19 Nov 2008 12:23:40 -0500 Received: from mail-qy0-f20.google.com ([209.85.221.20]:60094) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1L2qmC-0001VN-1l for qemu-devel@nongnu.org; Wed, 19 Nov 2008 12:23:40 -0500 Received: by qyk13 with SMTP id 13so34013qyk.10 for ; Wed, 19 Nov 2008 09:23:36 -0800 (PST) Message-ID: <5d6222a80811190923o1e83d188kfb258a676811d9c5@mail.gmail.com> Date: Wed, 19 Nov 2008 15:23:36 -0200 From: "Glauber Costa" Subject: Re: [Qemu-devel] [PATCH 5/6] Introduce kvm logging interface. In-Reply-To: <49242E53.6000802@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1227108377-8442-1-git-send-email-glommer@redhat.com> <1227108377-8442-2-git-send-email-glommer@redhat.com> <1227108377-8442-3-git-send-email-glommer@redhat.com> <1227108377-8442-4-git-send-email-glommer@redhat.com> <1227108377-8442-5-git-send-email-glommer@redhat.com> <1227108377-8442-6-git-send-email-glommer@redhat.com> <49242E53.6000802@codemonkey.ws> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On Wed, Nov 19, 2008 at 1:18 PM, Anthony Liguori wrote: > Glauber Costa wrote: >> >> Introduce functions to stop and start logging of memory regions. >> We select region based on its start address. >> >> Signed-off-by: Glauber Costa >> --- >> kvm-all.c | 153 >> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ >> kvm.h | 5 ++ >> 2 files changed, 158 insertions(+), 0 deletions(-) >> >> diff --git a/kvm-all.c b/kvm-all.c >> index 9700e50..c522205 100644 >> --- a/kvm-all.c >> +++ b/kvm-all.c >> @@ -32,8 +32,13 @@ >> do { } while (0) >> #endif >> +#define warning(fmt, ...) \ >> + do { dprintf("%s:%d" fmt, __func__, __LINE__, ## __VA_ARGS__); } >> while (0) >> > > I don't think this macro really serves a purpose. You can just add "%s:%d: > " to the beginning of dprintf() if you want. Are you okay with all dprintfs having these info? This is very valuable info, so I'd like to have it. I can send a separate patch. >> > > Note that start and stop are identical except for a different printf(). The > call a common helper function. Why not fold everything into > kvm_dirty_pages_log_change() and make that the public interface > (kvm_set_log). I personally believe kvm_set_log is a very bad interface. It's nicer to read "start" and "stop" instead, but I can definitely do this internally. > >> +static inline int lookup_bitmap_phys(unsigned long *dirty, unsigned nr) >> +{ >> + unsigned word = nr / (sizeof(*dirty) * 8); >> + unsigned bit = nr % (sizeof(*dirty) * 8); >> + int ret; >> + >> + ret = (dirty[word] >> bit) & 1; >> + return ret; >> +} >> + >> +/** >> + * kvm_physical_sync_dirty_bitmap - Grab dirty bitmap from kernel space >> + * If a phys_offset parameter is given, this function updates qemu's >> dirty >> + * bitmap using cpu_physical_memory_set_dirty(). This means all bits are >> set >> + * to dirty. >> + * >> + * @start_add: start of logged region. This is what we use to search the >> memslot >> + * @end_addr: end of logged region. Only matters if we are updating qemu >> dirty bitmap. >> + * @phys_offset: the phys_offset we want to use for qemu dirty bitmap >> update. Passing >> + * NULL makes the update not happen. In this case, we only >> grab the bitmap >> + * from kernel. >> + */ >> +void kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr, >> target_phys_addr_t end_addr, >> + ram_addr_t phys_offset) >> > > This interface is weird and broken. If we wanted to use this for live > migration, we would end up passing phys_offset=0 but that has a special > meaning here. > > But why are we passing phys_offset at all? Why can't we do the lookup here? Because, if you remember, the last time I sent a patch _without_ it, you complained that we can't really trust any translation based on userspace_addr. Which is fine, because it is fundamentally broken long term. So, we need to be specific about what area are we writting the dirty bitmap too. If the zero is the problem, we can have the interface to always write to the given location, and disregard 0 as a special meaning field. -- Glauber Costa. "Free as in Freedom" http://glommer.net "The less confident you are, the more serious you have to act."