Am 17.03.2015 um 18:04 schrieb Eduardo Habkost:
> On Tue, Mar 17, 2015 at 05:46:36PM +0100, Andreas Färber wrote:
> [...]
>> @@ -1054,7 +1055,12 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)
>>  
>>      icc_bridge = DEVICE(object_resolve_path_type("icc-bridge",
>>                                                   TYPE_ICC_BRIDGE, NULL));
>> -    pc_new_cpu(current_cpu_model, apic_id, icc_bridge, errp);
>> +    cpu = pc_new_cpu(current_cpu_model, apic_id, icc_bridge, &local_err);
>> +    if (local_err) {
>> +        error_propagate(errp, local_err);
>> +        return;
>> +    }
>> +    object_unref(OBJECT(cpu));
> 
> Calling object_unref(NULL) is valid, so you can still keep it simple and
> do this:
> 
> -    pc_new_cpu(current_cpu_model, apic_id, icc_bridge, errp);
> +    cpu = pc_new_cpu(current_cpu_model, apic_id, icc_bridge, errp);
> +    object_unref(OBJECT(cpu));

Valid yes, but I have a follow-up doing:

         error_propagate(errp, local_err);
         return;
     }
+    object_property_set_bool(OBJECT(cpu), true, "realized", errp);
     object_unref(OBJECT(cpu));
 }


So it's handier to keep it last.

Regards,
Andreas

-- 
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 via email to