All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org, david@kernel.org, imammedo@redhat.com,
	peter.maydell@linaro.org
Subject: Re: [PATCH 1/7] backends/hostmem: Drop redundant validation of property "size"
Date: Thu, 12 Nov 2026 08:12:40 +0000	[thread overview]
Message-ID: <avV0-C7TSKV4lQWP@redhat.com> (raw)
In-Reply-To: <87fqx6sdcz.fsf@pond.sub.org>

On Thu, Nov 12, 2026 at 08:44:28AM +0100, Markus Armbruster wrote:
> Daniel P. Berrangé <berrange@redhat.com> writes:
> 
> > On Wed, Nov 11, 2026 at 01:23:36PM +0100, Markus Armbruster wrote:
> >> Property "size" is mandatory, and its setter
> >> host_memory_backend_set_size() rejects value zero.  Delete the
> >> redundant checks for zero in the .alloc() callbacks.
> >> 
> >> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> >> ---
> >>  backends/hostmem-epc.c   | 5 -----
> >>  backends/hostmem-file.c  | 4 ----
> >>  backends/hostmem-memfd.c | 5 -----
> >>  backends/hostmem-ram.c   | 5 -----
> >>  backends/hostmem-shm.c   | 5 -----
> >>  5 files changed, 24 deletions(-)
> >
> > Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
> >
> > ...it is a shame this was/is dead code, since the actual error message
> > from host_memory_backend_set_size() is (IMHO) worse than that from the
> > unreachable code you're deleting
> >
> >   $ ./build/qemu-system-x86_64 -object memory-backend-ram,size=0,id=foo
> >   qemu-system-x86_64: property 'size' of memory-backend-ram doesn't take value '0'
> 
> Fair point.
> 
> > as a separate patch I might suggest
> >
> >     diff --git a/backends/hostmem.c b/backends/hostmem.c
> >     index 173d042be35..f523dce6eb0 100644
> >     --- a/backends/hostmem.c
> >     +++ b/backends/hostmem.c
> >     @@ -77,8 +77,8 @@ host_memory_backend_set_size(Object *obj, Visitor *v, const char *name,
>            if (host_memory_backend_mr_inited(backend)) {
>                error_setg(errp, "cannot change property %s of %s ", name,
>                           object_get_typename(obj));
>                return;
>            }
> 
>            if (!visit_type_size(v, name, &value, errp)) {
>                return;
> >          }
> >          if (!value) {
> >              error_setg(errp,
> >     -                   "property '%s' of %s doesn't take value '%" PRIu64 "'",
> >     -                   name, object_get_typename(obj), value);
> >     +                   "cannot create '%s' with a size of 0",
> >     +                   object_get_typename(obj));
> >              return;
> >          }
> >          backend->size = value;
> >
> > so that we get the nicer message:
> >
> >     $ ./build/qemu-system-x86_64 -object memory-backend-ram,size=0,id=foo
> >     qemu-system-x86_64: cannot create 'memory-backend-ram' with a size of 0
> 
> Your message assumes that the property is only ever set on behalf of an
> object creation request.  Not true in general, qom-set exists.  I
> believe it's true here due to the host_memory_backend_mr_inited() guard.
> But that's not entirely obvious, isn't it?
> 
> Possible phrasings that don't assume this:
> 
>    property 'size' of 'memory-backend-ram' cannot be zero
>    cannot set property 'size' of 'memory-backend-ram' to zero
> 
> Is one of them good enough?  I doubt this error is common.

I'm fine with either of those, perhaps mildly leaning towards
the second.

> There are enough "doesn't take value" error messages elsewhere to
> justify a small series of its own.


With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|



  reply	other threads:[~2026-11-12  8:13 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11 12:23 [PATCH 0/7] backends/hostmem: Make QOM types and properties unconditional Markus Armbruster
2026-11-11 12:23 ` [PATCH 1/7] backends/hostmem: Drop redundant validation of property "size" Markus Armbruster
2026-11-11 12:45   ` Daniel P. Berrangé
2026-11-12  7:44     ` Markus Armbruster
2026-11-12  8:12       ` Daniel P. Berrangé [this message]
2026-11-12 11:49         ` Markus Armbruster
2026-11-11 16:42   ` Mark Cave-Ayland
2026-11-11 12:23 ` [PATCH 2/7] backends/hostmem-file: Drop useless validation of property "mem-path" Markus Armbruster
2026-11-11 12:50   ` Daniel P. Berrangé
2026-11-11 16:48   ` Mark Cave-Ayland
2026-11-11 12:23 ` [PATCH 3/7] backends/hostmem: Improve error reporting when method alloc() fails Markus Armbruster
2026-11-11 12:51   ` Daniel P. Berrangé
2026-11-11 16:49   ` Mark Cave-Ayland
2026-11-11 12:23 ` [PATCH 4/7] backends/hostmem-epc: Register QOM type unconditionally Markus Armbruster
2026-11-11 12:53   ` Daniel P. Berrangé
2026-11-11 16:50   ` Mark Cave-Ayland
2026-11-11 12:23 ` [PATCH 5/7] backends/hostmem-memfd: " Markus Armbruster
2026-11-11 12:54   ` Daniel P. Berrangé
2026-11-11 16:51   ` Mark Cave-Ayland
2026-11-11 12:23 ` [PATCH 6/7] util/memfd: Improve error message when memfd_create() fails Markus Armbruster
2026-11-11 12:56   ` Daniel P. Berrangé
2026-11-11 16:53   ` Mark Cave-Ayland
2026-11-11 12:23 ` [PATCH 7/7] backends/hostmem-memfd: Add huge TLB properties unconditionally Markus Armbruster
2026-11-11 12:56   ` Daniel P. Berrangé
2026-11-11 16:54   ` Mark Cave-Ayland
2026-11-11 12:36 ` Use of qemu_memfd_check() in system/physmem.c (was: [PATCH 0/7] backends/hostmem: Make QOM types and properties unconditional) Markus Armbruster

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=avV0-C7TSKV4lQWP@redhat.com \
    --to=berrange@redhat.com \
    --cc=armbru@redhat.com \
    --cc=david@kernel.org \
    --cc=imammedo@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.