[Qemu-devel] [PATCH v3 1/2] hostmem: simplify ifdef-s in file_backend_memory_alloc()

Stefan Hajnoczi posted 2 patches 6 years, 12 months ago
Maintainers: Stefan Weil <sw@weilnetz.de>, Eduardo Habkost <ehabkost@redhat.com>, Igor Mammedov <imammedo@redhat.com>
[Qemu-devel] [PATCH v3 1/2] hostmem: simplify ifdef-s in file_backend_memory_alloc()
Posted by Stefan Hajnoczi 6 years, 12 months ago
From: Igor Mammedov <imammedo@redhat.com>

cleanup file_backend_memory_alloc() by using one CONFIG_POSIX ifdef
instead of several ones within the function to make it simpler to follow.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Suggested-by: Wei Yang <richardw.yang@linux.intel.com>
Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
Message-Id: <20190213123858.24620-1-imammedo@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 backends/hostmem-file.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c
index ba601ce940..ce54788048 100644
--- a/backends/hostmem-file.c
+++ b/backends/hostmem-file.c
@@ -41,10 +41,12 @@ struct HostMemoryBackendFile {
 static void
 file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
 {
+#ifndef CONFIG_POSIX
+    error_setg(errp, "backend '%s' not supported on this host",
+               object_get_typename(OBJECT(backend)));
+#else
     HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(backend);
-#ifdef CONFIG_POSIX
     gchar *name;
-#endif
 
     if (!backend->size) {
         error_setg(errp, "can't create backend with size 0");
@@ -54,9 +56,6 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
         error_setg(errp, "mem-path property not set");
         return;
     }
-#ifndef CONFIG_POSIX
-    error_setg(errp, "-mem-path not supported on this host");
-#else
     backend->force_prealloc = mem_prealloc;
     name = host_memory_backend_get_name(backend);
     memory_region_init_ram_from_file(&backend->mr, OBJECT(backend),
-- 
2.20.1


Re: [Qemu-devel] [PATCH v3 1/2] hostmem: simplify ifdef-s in file_backend_memory_alloc()
Posted by Wei Yang 6 years, 12 months ago
Maybe change the title 

   s/hotmem/hostmem-file/

would be more proper.

I missed this in previous review.

On Thu, Feb 14, 2019 at 11:10:03AM +0800, Stefan Hajnoczi wrote:
>From: Igor Mammedov <imammedo@redhat.com>
>
>cleanup file_backend_memory_alloc() by using one CONFIG_POSIX ifdef
>instead of several ones within the function to make it simpler to follow.
>
>Signed-off-by: Igor Mammedov <imammedo@redhat.com>
>Suggested-by: Wei Yang <richardw.yang@linux.intel.com>
>Reviewed-by: Wei Yang <richardw.yang@linux.intel.com>
>Message-Id: <20190213123858.24620-1-imammedo@redhat.com>
>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
>---
> backends/hostmem-file.c | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
>diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c
>index ba601ce940..ce54788048 100644
>--- a/backends/hostmem-file.c
>+++ b/backends/hostmem-file.c
>@@ -41,10 +41,12 @@ struct HostMemoryBackendFile {
> static void
> file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
> {
>+#ifndef CONFIG_POSIX
>+    error_setg(errp, "backend '%s' not supported on this host",
>+               object_get_typename(OBJECT(backend)));
>+#else
>     HostMemoryBackendFile *fb = MEMORY_BACKEND_FILE(backend);
>-#ifdef CONFIG_POSIX
>     gchar *name;
>-#endif
> 
>     if (!backend->size) {
>         error_setg(errp, "can't create backend with size 0");
>@@ -54,9 +56,6 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
>         error_setg(errp, "mem-path property not set");
>         return;
>     }
>-#ifndef CONFIG_POSIX
>-    error_setg(errp, "-mem-path not supported on this host");
>-#else
>     backend->force_prealloc = mem_prealloc;
>     name = host_memory_backend_get_name(backend);
>     memory_region_init_ram_from_file(&backend->mr, OBJECT(backend),
>-- 
>2.20.1

-- 
Wei Yang
Help you, Help me

Re: [Qemu-devel] [PATCH v3 1/2] hostmem: simplify ifdef-s in file_backend_memory_alloc()
Posted by Stefan Hajnoczi 6 years, 12 months ago
On Thu, Feb 14, 2019 at 03:26:29PM +0800, Wei Yang wrote:
> Maybe change the title 
> 
>    s/hotmem/hostmem-file/
> 
> would be more proper.
> 
> I missed this in previous review.

You're right.  This can be fixed when merging the patch.

Stefan
Re: [Qemu-devel] [PATCH v3 1/2] hostmem: simplify ifdef-s in file_backend_memory_alloc()
Posted by Igor Mammedov 6 years, 11 months ago
On Thu, 14 Feb 2019 16:16:19 +0800
Stefan Hajnoczi <stefanha@redhat.com> wrote:

> On Thu, Feb 14, 2019 at 03:26:29PM +0800, Wei Yang wrote:
> > Maybe change the title 
> > 
> >    s/hotmem/hostmem-file/
> > 
> > would be more proper.
> > 
> > I missed this in previous review.  
> 
> You're right.  This can be fixed when merging the patch.
> 
> Stefan

Did this patch fall through cracks?

Re: [Qemu-devel] [PATCH v3 1/2] hostmem: simplify ifdef-s in file_backend_memory_alloc()
Posted by Stefan Hajnoczi 6 years, 11 months ago
On Fri, Mar 01, 2019 at 11:40:06AM +0100, Igor Mammedov wrote:
> On Thu, 14 Feb 2019 16:16:19 +0800
> Stefan Hajnoczi <stefanha@redhat.com> wrote:
> 
> > On Thu, Feb 14, 2019 at 03:26:29PM +0800, Wei Yang wrote:
> > > Maybe change the title 
> > > 
> > >    s/hotmem/hostmem-file/
> > > 
> > > would be more proper.
> > > 
> > > I missed this in previous review.  
> > 
> > You're right.  This can be fixed when merging the patch.
> > 
> > Stefan
> 
> Did this patch fall through cracks?

Eduardo has been away.  It wasn't urgent but I'd be happy if either you
or Eduardo picks up these patches.

Thanks,
Stefan
Re: [Qemu-devel] [PATCH v3 1/2] hostmem: simplify ifdef-s in file_backend_memory_alloc()
Posted by Laurent Vivier 6 years, 11 months ago
On 01/03/2019 17:47, Stefan Hajnoczi wrote:
> On Fri, Mar 01, 2019 at 11:40:06AM +0100, Igor Mammedov wrote:
>> On Thu, 14 Feb 2019 16:16:19 +0800
>> Stefan Hajnoczi <stefanha@redhat.com> wrote:
>>
>>> On Thu, Feb 14, 2019 at 03:26:29PM +0800, Wei Yang wrote:
>>>> Maybe change the title 
>>>>
>>>>    s/hotmem/hostmem-file/
>>>>
>>>> would be more proper.
>>>>
>>>> I missed this in previous review.  
>>>
>>> You're right.  This can be fixed when merging the patch.
>>>
>>> Stefan
>>
>> Did this patch fall through cracks?
> 
> Eduardo has been away.  It wasn't urgent but I'd be happy if either you
> or Eduardo picks up these patches.
> 
> Thanks,
> Stefan
> 

On Igor request, applied to my trivial-patches branch.

Thanks,
Laurent