All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Marcelo Tosatti" <mtosatti@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Like Xu" <like.xu@linux.intel.com>,
	"David Hildenbrand" <david@redhat.com>,
	"Cornelia Huck" <cohuck@redhat.com>,
	qemu-devel@nongnu.org, qemu-s390x@nongnu.org,
	qemu-arm@nongnu.org, qemu-ppc@nongnu.org,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"David Gibson" <david@gibson.dropbear.id.au>,
	"Richard Henderson" <rth@twiddle.net>
Subject: Re: [PATCH v2 07/10] qdev: Abort if the root machine container is missing
Date: Tue, 21 Jan 2020 13:45:06 +0100	[thread overview]
Message-ID: <87k15ldlm5.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20200121110349.25842-8-philmd@redhat.com> ("Philippe Mathieu-Daudé"'s message of "Tue, 21 Jan 2020 12:03:46 +0100")

Philippe Mathieu-Daudé <philmd@redhat.com> writes:

> The QEMU device API (qdev) relies on having the '/machine'
> container always available.
>
> If it is missing, QEMU will later crash dereferencing a NULL
> pointer, we will get a SEGV, open a debugger, look at the
> backtrace, and figure out we messed with QOM.
> Or we can use g_assert() which abort, displaying the filename
> and line number, so we can quickly open our favorite IDE.
> Prefer the later, to save time to developers.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> v2: New patch
> ---
>  hw/core/qdev.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 58e87d336d..d30cf6320b 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -1143,6 +1143,7 @@ Object *qdev_get_machine(void)
>  
>      if (dev == NULL) {
>          dev = container_get(object_get_root(), "/machine");
> +        g_assert(dev != NULL);
>      }
>  
>      return dev;

container_get()'s contract promises it won't return null.  I think the
assertion belongs there instead.


  reply	other threads:[~2020-01-21 13:54 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-21 11:03 [PATCH v2 00/10] Cleanups around the 'current_machine' global variable Philippe Mathieu-Daudé
2020-01-21 11:03 ` [PATCH v2 01/10] hw/ppc/spapr_rtas: Use local MachineState variable Philippe Mathieu-Daudé
2020-01-21 11:03 ` [PATCH v2 02/10] hw/ppc/spapr_rtas: Access MachineState via SpaprMachineState argument Philippe Mathieu-Daudé
2020-01-21 11:03 ` [PATCH v2 03/10] hw/ppc/spapr_rtas: Remove local variable Philippe Mathieu-Daudé
2020-01-22  3:27   ` David Gibson
2020-01-21 11:03 ` [PATCH v2 04/10] target/arm/kvm: Use CPUState::kvm_state in kvm_arm_pmu_supported() Philippe Mathieu-Daudé
2020-01-21 11:03 ` [PATCH v2 05/10] target/s390x: Remove duplicated ifdef macro Philippe Mathieu-Daudé
2020-01-21 13:52   ` Cornelia Huck
2020-01-21 16:45   ` Cornelia Huck
2020-01-21 11:03 ` [PATCH v2 06/10] qom/object: Display more helpful message when a parent is missing Philippe Mathieu-Daudé
2020-01-21 13:54   ` Cornelia Huck
2020-01-21 11:03 ` [PATCH v2 07/10] qdev: Abort if the root machine container " Philippe Mathieu-Daudé
2020-01-21 12:45   ` Markus Armbruster [this message]
2020-01-21 11:03 ` [PATCH v2 08/10] accel: Introduce the current_accel() wrapper Philippe Mathieu-Daudé
2020-01-21 13:56   ` Cornelia Huck
2020-01-21 11:03 ` [PATCH v2 09/10] accel: Replace current_machine->accelerator by " Philippe Mathieu-Daudé
2020-01-21 11:03   ` Philippe Mathieu-Daudé
2020-01-21 14:03   ` Cornelia Huck
2020-01-21 14:03     ` Cornelia Huck
2020-01-22  3:28   ` David Gibson
2020-01-22  3:28     ` David Gibson
2020-01-21 11:03 ` [PATCH v2 10/10] accel/tcg: Sanitize include path Philippe Mathieu-Daudé
2020-01-21 14:06   ` Cornelia Huck
2020-01-21 12:47 ` [PATCH v2 00/10] Cleanups around the 'current_machine' global variable Markus Armbruster
2020-01-21 12:49   ` Philippe Mathieu-Daudé
2020-01-21 16:27 ` Paolo Bonzini
2020-01-21 16:44   ` Cornelia Huck

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=87k15ldlm5.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=david@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=like.xu@linux.intel.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=rth@twiddle.net \
    /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.