qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>,
	Cornelia Huck <cohuck@redhat.com>,
	Eduardo Habkost <ehabkost@redhat.com>,
	Peter Crosthwaite <crosthwaite.peter@gmail.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	qemu-devel@nongnu.org, Alexander Graf <agraf@suse.de>,
	qemu-s390x@nongnu.org, qemu-ppc@nongnu.org,
	Paolo Bonzini <pbonzini@redhat.com>, Greg Kurz <groug@kaod.org>,
	David Gibson <david@gibson.dropbear.id.au>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH v1 8/8] s390x: local error handling in hotplug handler functions
Date: Fri, 8 Jun 2018 11:19:37 +0200	[thread overview]
Message-ID: <766df31f-96e6-eb2f-0b7f-2182476b540e@redhat.com> (raw)
In-Reply-To: <20180608110350.13fbcd77@redhat.com>

On 08.06.2018 11:03, Igor Mammedov wrote:
> On Fri, 8 Jun 2018 09:40:04 +0200
> David Hildenbrand <david@redhat.com> wrote:
> 
>> On 08.06.2018 09:27, Christian Borntraeger wrote:
>>>
>>>
>>> On 06/08/2018 09:25 AM, Cornelia Huck wrote:  
>>>> On Thu,  7 Jun 2018 18:52:18 +0200
>>>> David Hildenbrand <david@redhat.com> wrote:
>>>>  
>>>>> Let's introduce and use local error variables in the hotplug handler
>>>>> functions.
>>>>>
>>>>> Signed-off-by: David Hildenbrand <david@redhat.com>
>>>>> ---
>>>>>  hw/s390x/s390-virtio-ccw.c | 11 ++++++++---
>>>>>  1 file changed, 8 insertions(+), 3 deletions(-)
>>>>>
>>>>> diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
>>>>> index 7ae5fb38dd..29ea50a177 100644
>>>>> --- a/hw/s390x/s390-virtio-ccw.c
>>>>> +++ b/hw/s390x/s390-virtio-ccw.c
>>>>> @@ -434,18 +434,23 @@ static void s390_machine_reset(void)
>>>>>  static void s390_machine_device_plug(HotplugHandler *hotplug_dev,
>>>>>                                       DeviceState *dev, Error **errp)
>>>>>  {
>>>>> +    Error *local_err = NULL;
>>>>> +
>>>>>      if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
>>>>> -        s390_cpu_plug(hotplug_dev, dev, errp);
>>>>> +        s390_cpu_plug(hotplug_dev, dev, &local_err);
>>>>>      }
>>>>> +    error_propagate(errp, local_err);
>>>>>  }
>>>>>  
>>>>>  static void s390_machine_device_unplug_request(HotplugHandler *hotplug_dev,
>>>>>                                                 DeviceState *dev, Error **errp)
>>>>>  {
>>>>> +    Error *local_err = NULL;
>>>>> +
>>>>>      if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
>>>>> -        error_setg(errp, "CPU hot unplug not supported on this machine");
>>>>> -        return;
>>>>> +        error_setg(&local_err, "CPU hot unplug not supported on this machine");
>>>>>      }
>>>>> +    error_propagate(errp, local_err);
>>>>>  }
>>>>>  
>>>>>  static CpuInstanceProperties s390_cpu_index_to_props(MachineState *ms,  
>>>>
>>>> Just seeing this patch by itself, it does not really make much sense.
>>>> Even if this is a split out clean-up series, I'd prefer this to go
>>>> together with a patch that actually adds something more to the
>>>> plug/unplug functions.  
>>>
>>> +1. It is hard to see the "why". Maybe a better patch description could help here?
>>>   
>>
>> When checking for an error (*errp) we should make sure that we don't
>> dereference the NULL pointer. I will be doing that in the future (memory
>> devices), but as you both don't seem to like this patch, I'll drop it
>> for now.
> hotplug handlers aren't called with NULL errp, so it not really necessary.
> To be on the safe side we can ensure that errp is not NULL doing something
> like:

They are, but not on s390x :) But we should never life with such
assumptions - calling code may change. Passing NULL results right now
not in a crash, but the "return" value in case of a failure cannot be
indicated.

Maybe we should even change all users of NULL for errp to use &error_abort.

For now I dropped these "local_err" patches and kept only the spapr
cleanups.

> 
> diff --git a/hw/core/hotplug.c b/hw/core/hotplug.c
> index 17ac986..dc9e4bf 100644
> --- a/hw/core/hotplug.c
> +++ b/hw/core/hotplug.c
> @@ -52,6 +52,7 @@ void hotplug_handler_unplug(HotplugHandler *plug_handler,
>  {
>      HotplugHandlerClass *hdc = HOTPLUG_HANDLER_GET_CLASS(plug_handler);
>  
> +    g_assert(errp);
>      if (hdc->unplug) {
>          hdc->unplug(plug_handler, plugged_dev, errp);
>      }
> 
> and do it for all similar wrappers in this file
> 
> 


-- 

Thanks,

David / dhildenb

  reply	other threads:[~2018-06-08  9:19 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-07 16:52 [Qemu-devel] [PATCH v1 0/8] pc/spapr/s390x: machine hotplug handler cleanups David Hildenbrand
2018-06-07 16:52 ` [Qemu-devel] [PATCH v1 1/8] pc: local error handling in hotplug handler functions David Hildenbrand
2018-06-08  8:04   ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2018-06-08  8:05     ` David Hildenbrand
2018-06-07 16:52 ` [Qemu-devel] [PATCH v1 2/8] spapr: no need to verify the node David Hildenbrand
2018-06-08  3:28   ` David Gibson
2018-06-08  7:34   ` Greg Kurz
2018-06-08  7:42     ` David Hildenbrand
2018-06-08  7:46       ` Greg Kurz
2018-06-08  7:48         ` David Hildenbrand
2018-06-08  8:07           ` [Qemu-devel] [qemu-s390x] " Thomas Huth
2018-06-08  8:39             ` Igor Mammedov
2018-06-08  8:41               ` David Hildenbrand
2018-06-08  9:06                 ` Igor Mammedov
2018-06-08  9:24                   ` David Hildenbrand
2018-06-08 10:52                     ` Greg Kurz
2018-06-08 11:28                       ` David Hildenbrand
2018-06-08 11:31                         ` Cornelia Huck
2018-06-08 11:53                         ` Greg Kurz
2018-06-08  8:20         ` [Qemu-devel] " David Gibson
2018-06-08  8:24           ` David Hildenbrand
2018-06-07 16:52 ` [Qemu-devel] [PATCH v1 3/8] spapr: move all DIMM checks into spapr_memory_plug David Hildenbrand
2018-06-08  3:28   ` David Gibson
2018-06-08  8:05   ` Greg Kurz
2018-06-08  8:07     ` David Hildenbrand
2018-06-08  8:41       ` Igor Mammedov
2018-06-07 16:52 ` [Qemu-devel] [PATCH v1 4/8] spapr: local error handling in hotplug handler functions David Hildenbrand
2018-06-08  3:29   ` David Gibson
2018-06-08  8:40   ` Greg Kurz
2018-06-07 16:52 ` [Qemu-devel] [PATCH v1 5/8] spapr: introduce machine unplug handler David Hildenbrand
2018-06-08  3:29   ` David Gibson
2018-06-08  8:44   ` Igor Mammedov
2018-06-08  8:56   ` Greg Kurz
2018-06-07 16:52 ` [Qemu-devel] [PATCH v1 6/8] spapr: handle pc-dimm unplug via hotplug handler chain David Hildenbrand
2018-06-08  3:30   ` David Gibson
2018-06-08  8:56   ` Igor Mammedov
2018-06-08  9:02     ` David Hildenbrand
2018-06-08  9:35       ` Igor Mammedov
2018-06-08  9:36         ` David Hildenbrand
2018-06-08  8:59   ` Greg Kurz
2018-06-07 16:52 ` [Qemu-devel] [PATCH v1 7/8] spapr: handle cpu core " David Hildenbrand
2018-06-08  3:31   ` David Gibson
2018-06-08  8:57   ` Igor Mammedov
2018-06-08  9:00   ` Greg Kurz
2018-06-07 16:52 ` [Qemu-devel] [PATCH v1 8/8] s390x: local error handling in hotplug handler functions David Hildenbrand
2018-06-08  7:25   ` Cornelia Huck
2018-06-08  7:27     ` Christian Borntraeger
2018-06-08  7:40       ` David Hildenbrand
2018-06-08  7:50         ` Christian Borntraeger
2018-06-08  9:03         ` Igor Mammedov
2018-06-08  9:19           ` David Hildenbrand [this message]
2018-06-08  7:58 ` [Qemu-devel] [PATCH v1 0/8] pc/spapr/s390x: machine hotplug handler cleanups David Hildenbrand

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=766df31f-96e6-eb2f-0b7f-2182476b540e@redhat.com \
    --to=david@redhat.com \
    --cc=agraf@suse.de \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=crosthwaite.peter@gmail.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=ehabkost@redhat.com \
    --cc=groug@kaod.org \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).