From: Matthew Rosato <mjrosato@linux.vnet.ibm.com>
To: David Hildenbrand <dahi@linux.vnet.ibm.com>
Cc: imammedo@redhat.com, qemu-devel@nongnu.org, agraf@suse.de,
borntraeger@de.ibm.com, bharata@linux.vnet.ibm.com,
cornelia.huck@de.ibm.com, pbonzini@redhat.com, afaerber@suse.de,
rth@twiddle.net
Subject: Re: [Qemu-devel] [PATCH v7 5/6] s390x/cpu: Add error handling to cpu creation
Date: Thu, 3 Mar 2016 12:52:17 -0500 [thread overview]
Message-ID: <56D879D1.7050509@linux.vnet.ibm.com> (raw)
In-Reply-To: <20160302085716.7874dd8d@thinkpad-w530>
>> +S390CPU *s390_new_cpu(MachineState *machine, int64_t id, Error **errp)
>> +{
>> + S390CPU *cpu = NULL;
>> + Error *local_err = NULL;
>
> Think the naming schema is "err" now.
>
>> +
>> + if (id >= max_cpus) {
>> + error_setg(errp, "Unable to add CPU: %" PRIi64
>> + ", max allowed: %d", id, max_cpus - 1);
>> + goto out;
>
> Could we also move this check to the realize function?
>
>> + }
>> +
>> + cpu = cpu_s390x_create(machine->cpu_model, &local_err);
>> + if (local_err != NULL) {
>> + goto out;
>> + }
>> +
>> + object_property_set_int(OBJECT(cpu), id, "id", &local_err);
>
> We should add a check in between
>
> if (err) {
> goto out;
> }
>
>> + object_property_set_bool(OBJECT(cpu), true, "realized", &local_err);
>> +
>> +out:
>> + if (cpu != NULL) {
>> + object_unref(OBJECT(cpu));
>
> Is the object_unref() here correct?
> I know that we have one reference from VCPU creation. Where does the second one
> come from (is it from the hotplug handler? then I'd prefer a comment here :D )
>
After some digging, I believe this unref is not necessary for s390
(bus-less) and I'm now questioning the i386 code that I used as a base...
@Igor/Andreas:
In i386, looks like the unrefs were due to the ref created when adding
the cpu to the icc bus. Andreas moved the checks outside of pc_new_cpu
and explains their purpose here:
0e3bd562 - pc: Ensure non-zero CPU ref count after attaching to ICC bus
But then a subsequent patch removed the bus and left the unrefs:
46232aaa - cpu/apic: drop icc bus/bridge
Should that patch not have also dropped the unrefs in pc_hot_add_cpu()
and pc_cpus_init()?
Matt
next prev parent reply other threads:[~2016-03-03 17:52 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-01 21:13 [Qemu-devel] [PATCH v7 0/6] Allow hotplug of s390 CPUs Matthew Rosato
2016-03-01 21:13 ` [Qemu-devel] [PATCH v7 1/6] s390x/cpu: Cleanup init in preparation for hotplug Matthew Rosato
2016-03-01 21:13 ` [Qemu-devel] [PATCH v7 2/6] s390x/cpu: Set initial CPU state in common routine Matthew Rosato
2016-03-01 21:13 ` [Qemu-devel] [PATCH v7 3/6] s390x/cpu: Move some CPU initialization into realize Matthew Rosato
2016-03-02 7:41 ` David Hildenbrand
2016-03-01 21:13 ` [Qemu-devel] [PATCH v7 4/6] s390x/cpu: Add CPU property links Matthew Rosato
2016-03-02 10:06 ` Igor Mammedov
2016-03-01 21:13 ` [Qemu-devel] [PATCH v7 5/6] s390x/cpu: Add error handling to cpu creation Matthew Rosato
2016-03-02 7:57 ` David Hildenbrand
2016-03-02 19:50 ` Matthew Rosato
2016-03-03 7:47 ` David Hildenbrand
2016-03-03 17:52 ` Matthew Rosato [this message]
2016-03-04 9:33 ` Igor Mammedov
2016-03-02 7:59 ` David Hildenbrand
2016-03-02 22:16 ` Matthew Rosato
2016-03-01 21:13 ` [Qemu-devel] [PATCH v7 6/6] s390x/cpu: Allow hotplug of CPUs Matthew Rosato
2016-03-02 8:00 ` 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=56D879D1.7050509@linux.vnet.ibm.com \
--to=mjrosato@linux.vnet.ibm.com \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=bharata@linux.vnet.ibm.com \
--cc=borntraeger@de.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=dahi@linux.vnet.ibm.com \
--cc=imammedo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@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).