qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Error handling in cpu_x86_create


From: Igor Mammedov
Subject: Re: [Qemu-devel] Error handling in cpu_x86_create
Date: Tue, 30 Jul 2013 14:21:43 +0200

On Tue, 30 Jul 2013 13:00:40 +0200
Jan Kiszka <address@hidden> wrote:

> Hi Igor,
> 
> just noticed by chance that error handling in cpu_x86_create is likely
> broken after your changes. Any error after cpu = ...object_new() will
> not properly release the CPU object again nor report NULL to the caller.
> That means errors should slip through, no? And cpu_x86_init looks similar.
Failure of object_new() in cpu_x86_create() is not checked since it should
never fail.

As for following error handling caller of cpu_x86_create(..., errp) should
use errp to check for errors and release failed cpu.

cpu_x86_init() that calls it has:
===
out:
    if (error) {
        fprintf(stderr, "%s\n", error_get_pretty(error));
        error_free(error);
        if (cpu != NULL) {
            object_unref(OBJECT(cpu));
===
similar code-path exists in pc_new_cpu()

end goal is to replace cpu_x86_create() with just object_new(FOO_CPU),
but that needs to x86 CPU subclasses and properties in place so
we could remove/isolate legacy stuff to legacy hook.

Did you hit any particular problem with current code?

> 
> Jan
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]