qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: Eduardo Habkost <ehabkost@redhat.com>, qemu-devel@nongnu.org
Cc: zhugh.fnst@cn.fujitsu.com, "Michael S. Tsirkin" <mst@redhat.com>,
	tangchen@cn.fujitsu.com, chen.fan.fnst@cn.fujitsu.com,
	isimatu.yasuaki@jp.fujitsu.com,
	Paolo Bonzini <pbonzini@redhat.com>,
	Gu Zheng <guz.fnst@cn.fujitsu.com>,
	Igor Mammedov <imammedo@redhat.com>,
	anshul.makkar@profitbricks.com
Subject: Re: [Qemu-devel] [PATCH v2 1/1] target-i386: Remove icc_bridge parameter from cpu_x86_create()
Date: Tue, 10 Mar 2015 23:43:41 +0100	[thread overview]
Message-ID: <54FF739D.9030102@suse.de> (raw)
In-Reply-To: <1426024655-17561-2-git-send-email-ehabkost@redhat.com>

Am 10.03.2015 um 22:57 schrieb Eduardo Habkost:
> Instead of passing icc_bridge from the PC initialization code to
> cpu_x86_create(), make the PC initialization code attach the CPU to
> icc_bridge.
> 
> The only difference here is that icc_bridge attachment will now be done
> after x86_cpu_parse_featurestr() is called. But this shouldn't make any
> difference, as property setters shouldn't depend on icc_bridge.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> Changes v1 -> v2:
>  * Keep existing check for NULL icc_bridge and error reporting, instead
>    of assing assert(icc_bridge)
> ---
>  hw/i386/pc.c      | 13 +++++++++++--
>  target-i386/cpu.c | 14 ++------------
>  target-i386/cpu.h |  3 +--
>  3 files changed, 14 insertions(+), 16 deletions(-)
> 
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index b5b2aad..a26e0ec 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -992,18 +992,27 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level)
>  static X86CPU *pc_new_cpu(const char *cpu_model, int64_t apic_id,
>                            DeviceState *icc_bridge, Error **errp)
>  {
> -    X86CPU *cpu;
> +    X86CPU *cpu = NULL;
>      Error *local_err = NULL;
>  
> -    cpu = cpu_x86_create(cpu_model, icc_bridge, &local_err);
> +    if (icc_bridge == NULL) {
> +        error_setg(&local_err, "Invalid icc-bridge value");
> +        goto out;
> +    }
> +
> +    cpu = cpu_x86_create(cpu_model, &local_err);

We had previously discussed reference counting. Here I would expect:

OBJECT(cpu)->ref == 1

>      if (local_err != NULL) {
>          error_propagate(errp, local_err);
>          return NULL;
>      }
>  
> +    qdev_set_parent_bus(DEVICE(cpu), qdev_get_child_bus(icc_bridge, "icc"));

OBJECT(cpu)->ref == 2

> +    object_unref(OBJECT(cpu));

OBJECT(cpu)->ref == 1

> +
>      object_property_set_int(OBJECT(cpu), apic_id, "apic-id", &local_err);
>      object_property_set_bool(OBJECT(cpu), true, "realized", &local_err);

OBJECT(cpu)->ref == 1 or 2 depending on DeviceClass::realize :)

>  
> +out:
>      if (local_err) {
>          error_propagate(errp, local_err);
>          object_unref(OBJECT(cpu));

object_unref(NULL) looks unusual but is valid.

Should we change the return NULL to jump here, too, then?

OBJECT(cpu)->ref == 0 or 1

I wonder whether we need another object_unref(OBJECT(cpu)) for the
non-error case, either here or in the callers? Out of scope for this
patch, of course.

Regards,
Andreas

[snip]

-- 
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu,
Graham Norton; HRB 21284 (AG Nürnberg)

  reply	other threads:[~2015-03-10 22:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-10 21:57 [Qemu-devel] [PATCH v2 0/1] target-i386: Move icc_bridge code to PC Eduardo Habkost
2015-03-10 21:57 ` [Qemu-devel] [PATCH v2 1/1] target-i386: Remove icc_bridge parameter from cpu_x86_create() Eduardo Habkost
2015-03-10 22:43   ` Andreas Färber [this message]
2015-03-11 11:11     ` Eduardo Habkost
2015-03-11 11:59       ` Andreas Färber
2015-03-11 13:20         ` Eduardo Habkost
2015-03-11 13:36   ` Igor Mammedov
2015-03-11 13:49     ` Eduardo Habkost
2015-03-11 14:34       ` Igor Mammedov
2015-03-17 16:46   ` [Qemu-devel] [PATCH for-next] pc: Ensure non-zero CPU ref count after attaching to ICC bus Andreas Färber
2015-03-17 17:04     ` Eduardo Habkost
2015-03-17 17:09       ` Andreas Färber
2015-04-27 19:03     ` Michael S. Tsirkin
2015-04-27 19:27     ` Eduardo Habkost
2015-04-27 19:35     ` Eduardo Habkost

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=54FF739D.9030102@suse.de \
    --to=afaerber@suse.de \
    --cc=anshul.makkar@profitbricks.com \
    --cc=chen.fan.fnst@cn.fujitsu.com \
    --cc=ehabkost@redhat.com \
    --cc=guz.fnst@cn.fujitsu.com \
    --cc=imammedo@redhat.com \
    --cc=isimatu.yasuaki@jp.fujitsu.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=tangchen@cn.fujitsu.com \
    --cc=zhugh.fnst@cn.fujitsu.com \
    /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).