From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40417) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZsB4m-0005gU-3F for qemu-devel@nongnu.org; Fri, 30 Oct 2015 10:54:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZsB4i-0008HH-T8 for qemu-devel@nongnu.org; Fri, 30 Oct 2015 10:54:44 -0400 Received: from relay.parallels.com ([195.214.232.42]:54944) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZsB4i-0008Gk-LR for qemu-devel@nongnu.org; Fri, 30 Oct 2015 10:54:40 -0400 Message-ID: <56338497.3050800@virtuozzo.com> Date: Fri, 30 Oct 2015 17:54:15 +0300 From: Vladimir Sementsov-Ogievskiy MIME-Version: 1.0 References: <1446184587-142784-1-git-send-email-guangrong.xiao@linux.intel.com> <1446184587-142784-11-git-send-email-guangrong.xiao@linux.intel.com> In-Reply-To: <1446184587-142784-11-git-send-email-guangrong.xiao@linux.intel.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v6 10/33] hostmem-file: clean up memory allocation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Xiao Guangrong , pbonzini@redhat.com, imammedo@redhat.com Cc: ehabkost@redhat.com, kvm@vger.kernel.org, mst@redhat.com, gleb@kernel.org, mtosatti@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, dan.j.williams@intel.com, rth@twiddle.net On 30.10.2015 08:56, Xiao Guangrong wrote: > - hostmem-file.c is compiled only if CONFIG_LINUX is enabled so that is > unnecessary to do the same check in the source file > > - the interface, HostMemoryBackendClass->alloc(), is not called many > times, do not need to check if the memory-region is initialized > > Signed-off-by: Xiao Guangrong > --- > backends/hostmem-file.c | 11 +++-------- > 1 file changed, 3 insertions(+), 8 deletions(-) > > diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c > index e9b6d21..9097a57 100644 > --- a/backends/hostmem-file.c > +++ b/backends/hostmem-file.c > @@ -46,17 +46,12 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) > error_setg(errp, "mem-path property not set"); > return; > } > -#ifndef CONFIG_LINUX > - error_setg(errp, "-mem-path not supported on this host"); > -#else > - if (!memory_region_size(&backend->mr)) { > - backend->force_prealloc = mem_prealloc; > - memory_region_init_ram_from_file(&backend->mr, OBJECT(backend), > + > + backend->force_prealloc = mem_prealloc; > + memory_region_init_ram_from_file(&backend->mr, OBJECT(backend), > object_get_canonical_path(OBJECT(backend)), > backend->size, fb->share, > fb->mem_path, errp); > - } > -#endif > } > > static void Similar function for memory backend (the only other HostMemoryBackendClass) - ram_backend_memory_alloc - has not such check too. It's ok.. Reviewed-by: Vladimir Sementsov-Ogievskiy -- Best regards, Vladimir * now, @virtuozzo.com instead of @parallels.com. Sorry for this inconvenience.