From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YbvwB-00031n-RC for qemu-devel@nongnu.org; Sat, 28 Mar 2015 14:58:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ybvw6-0008PY-KW for qemu-devel@nongnu.org; Sat, 28 Mar 2015 14:58:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49555) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ybvw6-0008PN-DU for qemu-devel@nongnu.org; Sat, 28 Mar 2015 14:58:22 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t2SIwLkE022361 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Sat, 28 Mar 2015 14:58:21 -0400 Date: Sat, 28 Mar 2015 19:58:18 +0100 From: "Michael S. Tsirkin" Message-ID: <20150328195615-mutt-send-email-mst@redhat.com> References: <1427391520-29497-1-git-send-email-pbonzini@redhat.com> <1427391520-29497-2-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1427391520-29497-2-git-send-email-pbonzini@redhat.com> Subject: Re: [Qemu-devel] [PATCH 01/22] memory: add memory_region_ram_resize List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org On Thu, Mar 26, 2015 at 06:38:19PM +0100, Paolo Bonzini wrote: > This is a simple MemoryRegion wrapper for qemu_ram_resize. > > Cc: Michael S. Tsirkin > Signed-off-by: Paolo Bonzini > --- > include/exec/memory.h | 12 ++++++++++++ > memory.c | 7 +++++++ > 2 files changed, 19 insertions(+) > > diff --git a/include/exec/memory.h b/include/exec/memory.h > index 06ffa1d..a2ea587 100644 > --- a/include/exec/memory.h > +++ b/include/exec/memory.h > @@ -605,6 +605,18 @@ int memory_region_get_fd(MemoryRegion *mr); > */ > void *memory_region_get_ram_ptr(MemoryRegion *mr); > > +/* memory_region_ram_resize: Resize a RAM region. > + * > + * Only legal before guest might have detected the memory size: e.g. on > + * incoming migration, or right after reset. > + * > + * @mr: a memory region created with @memory_region_init_resizeable_ram. > + * @newsize: the new size the region > + * @errp: pointer to Error*, to store an error if it happens. > + */ > +void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize, > + Error **errp); > + > /** > * memory_region_set_log: Turn dirty logging on or off for a region. > * > diff --git a/memory.c b/memory.c > index ee3f2a8..a11e9bf 100644 > --- a/memory.c > +++ b/memory.c > @@ -1452,6 +1452,13 @@ void *memory_region_get_ram_ptr(MemoryRegion *mr) > return qemu_get_ram_ptr(mr->ram_addr & TARGET_PAGE_MASK); > } > > +void memory_region_ram_resize(MemoryRegion *mr, ram_addr_t newsize, Error **errp) > +{ > + assert(mr->terminates); Why? Does "terminates" guarantee that ram_addr is valid? In any case, I think this needs a comment. > + > + qemu_ram_resize(mr->ram_addr, newsize, errp); > +} > + > static void memory_region_update_coalesced_range_as(MemoryRegion *mr, AddressSpace *as) > { > FlatView *view; > -- > 2.3.3 >