All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: Igor Mammedov <imammedo@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	qemu-devel@nongnu.org, anthony@codemonkey.ws,
	ehabkost@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2] qdev: Don't assume existence of parent bus on unparenting
Date: Mon, 07 Jan 2013 15:02:35 +0100	[thread overview]
Message-ID: <50EAD57B.8040905@suse.de> (raw)
In-Reply-To: <20130107144700.1cc540d4@thinkpad.mammed.net>

Am 07.01.2013 14:47, schrieb Igor Mammedov:
> On Fri,  4 Jan 2013 18:34:40 +0100
> Andreas Färber <afaerber@suse.de> wrote:
> 
>> Commit 667d22d1ae59da46b4c1fbd094ca61145f19b8c3 (qdev: move bus removal
>> to object_unparent) made the assumption that at unparenting time
>> parent_bus is not NULL. This assumption is unjustified since
>> object_unparent() may well be called directly after object_initialize(),
>> without any qdev_set_parent_bus().
>>
>> This did not cause any issues yet because qdev_[try_]create() does call
>> qdev_set_parent_bus(), falling back to SysBus if unsupplied.
>>
>> While at it, ensure that this new function uses the device_ prefix and
>> make the name more neutral in light of this semantic change.
>>
>> Reported-by: Eduardo Habkost <ehabkost@redhat.com>
>> Signed-off-by: Andreas Färber <afaerber@suse.de>
>> Cc: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>  Planning to insert this before the final CPU-as-a-device patch on qom-cpu,
>>  to avoid a regression for, e.g., -cpu Haswell,enforce if unsupported by host.
>>
>>  This supersedes my cosmetic patch in the "QOM realize, device-only" series:
>>
>>  v1 -> v2:
>>  * Make bus removal conditional on parent bus
>>  * Rename function further
>>
>>  hw/qdev.c |    8 +++++---
>>  1 Datei geändert, 5 Zeilen hinzugefügt(+), 3 Zeilen entfernt(-)
>>
>> diff --git a/hw/qdev.c b/hw/qdev.c
>> index f2c2484..e2a5c57 100644
>> --- a/hw/qdev.c
>> +++ b/hw/qdev.c
>> @@ -698,16 +698,18 @@ static void device_class_base_init(ObjectClass *class, void *data)
>>      klass->props = NULL;
>>  }
>>  
>> -static void qdev_remove_from_bus(Object *obj)
>> +static void device_unparent(Object *obj)
>>  {
>>      DeviceState *dev = DEVICE(obj);
>>  
>> -    bus_remove_child(dev->parent_bus, dev);
>> +    if (dev->parent_bus != NULL) {
>> +        bus_remove_child(dev->parent_bus, dev);
>> +    }
>>  }
>>  
>>  static void device_class_init(ObjectClass *class, void *data)
>>  {
>> -    class->unparent = qdev_remove_from_bus;
>> +    class->unparent = device_unparent;
>>  }
>>  
>>  void device_reset(DeviceState *dev)
>> -- 
>> 1.7.10.4
>>
>>
> Works for me,
> 
> Tested-By: Igor Mammedov <imammedo@redhat.com>

Thanks, inserted into qom-cpu queue:
https://github.com/afaerber/qemu-cpu/commits/qom-cpu

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

      reply	other threads:[~2013-01-07 14:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-04 17:34 [Qemu-devel] [PATCH v2] qdev: Don't assume existence of parent bus on unparenting Andreas Färber
2013-01-07 13:47 ` Igor Mammedov
2013-01-07 14:02   ` Andreas Färber [this message]

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=50EAD57B.8040905@suse.de \
    --to=afaerber@suse.de \
    --cc=anthony@codemonkey.ws \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.com \
    --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.