From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Fei Li <fli@suse.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 3/5] qemu_init_vcpu: add a new Error paramater to propagate
Date: Tue, 4 Sep 2018 12:22:46 +0100 [thread overview]
Message-ID: <20180904112246.GF22349@redhat.com> (raw)
In-Reply-To: <20180904110822.12863-4-fli@suse.com>
On Tue, Sep 04, 2018 at 07:08:20PM +0800, Fei Li wrote:
> The caller of qemu_init_vcpu() already passed the **errp to handle
> errors. In view of this, add a new Error parameter to the following
> call trace to propagate the error and let the final caller check it.
>
> Signed-off-by: Fei Li <fli@suse.com>
> ---
> cpus.c | 32 +++++++++++++++++++-------------
> include/qom/cpu.h | 2 +-
> target/alpha/cpu.c | 6 +++++-
> target/arm/cpu.c | 6 +++++-
> target/cris/cpu.c | 6 +++++-
> target/hppa/cpu.c | 6 +++++-
> target/i386/cpu.c | 6 +++++-
> target/lm32/cpu.c | 6 +++++-
> target/m68k/cpu.c | 6 +++++-
> target/microblaze/cpu.c | 6 +++++-
> target/mips/cpu.c | 6 +++++-
> target/moxie/cpu.c | 6 +++++-
> target/nios2/cpu.c | 6 +++++-
> target/openrisc/cpu.c | 6 +++++-
> target/ppc/translate_init.inc.c | 6 +++++-
> target/riscv/cpu.c | 6 +++++-
> target/s390x/cpu.c | 5 ++++-
> target/sh4/cpu.c | 6 +++++-
> target/sparc/cpu.c | 6 +++++-
> target/tilegx/cpu.c | 6 +++++-
> target/tricore/cpu.c | 6 +++++-
> target/unicore32/cpu.c | 6 +++++-
> target/xtensa/cpu.c | 6 +++++-
> 23 files changed, 124 insertions(+), 35 deletions(-)
>
> diff --git a/cpus.c b/cpus.c
> index 8ee6e5db93..41efddc218 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -1898,7 +1898,7 @@ void cpu_remove_sync(CPUState *cpu)
> /* For temporary buffers for forming a name */
> #define VCPU_THREAD_NAME_SIZE 16
>
> -static void qemu_tcg_init_vcpu(CPUState *cpu)
> +static void qemu_tcg_init_vcpu(CPUState *cpu, Error **errp)
> {
> char thread_name[VCPU_THREAD_NAME_SIZE];
> static QemuCond *single_tcg_halt_cond;
> @@ -1954,7 +1954,7 @@ static void qemu_tcg_init_vcpu(CPUState *cpu)
> }
> }
>
> -static void qemu_hax_start_vcpu(CPUState *cpu)
> +static void qemu_hax_start_vcpu(CPUState *cpu, Error **errp)
> {
> char thread_name[VCPU_THREAD_NAME_SIZE];
>
> @@ -1971,7 +1971,7 @@ static void qemu_hax_start_vcpu(CPUState *cpu)
> #endif
> }
>
> -static void qemu_kvm_start_vcpu(CPUState *cpu)
> +static void qemu_kvm_start_vcpu(CPUState *cpu, Error **errp)
> {
> char thread_name[VCPU_THREAD_NAME_SIZE];
>
> @@ -1984,7 +1984,7 @@ static void qemu_kvm_start_vcpu(CPUState *cpu)
> cpu, QEMU_THREAD_JOINABLE);
> }
>
> -static void qemu_hvf_start_vcpu(CPUState *cpu)
> +static void qemu_hvf_start_vcpu(CPUState *cpu, Error **errp)
> {
> char thread_name[VCPU_THREAD_NAME_SIZE];
>
> @@ -2002,7 +2002,7 @@ static void qemu_hvf_start_vcpu(CPUState *cpu)
> cpu, QEMU_THREAD_JOINABLE);
> }
>
> -static void qemu_whpx_start_vcpu(CPUState *cpu)
> +static void qemu_whpx_start_vcpu(CPUState *cpu, Error **errp)
> {
> char thread_name[VCPU_THREAD_NAME_SIZE];
>
> @@ -2018,7 +2018,7 @@ static void qemu_whpx_start_vcpu(CPUState *cpu)
> #endif
> }
>
> -static void qemu_dummy_start_vcpu(CPUState *cpu)
> +static void qemu_dummy_start_vcpu(CPUState *cpu, Error **errp)
> {
> char thread_name[VCPU_THREAD_NAME_SIZE];
>
> @@ -2031,11 +2031,12 @@ static void qemu_dummy_start_vcpu(CPUState *cpu)
> QEMU_THREAD_JOINABLE);
> }
>
> -void qemu_init_vcpu(CPUState *cpu)
> +void qemu_init_vcpu(CPUState *cpu, Error **errp)
> {
> cpu->nr_cores = smp_cores;
> cpu->nr_threads = smp_threads;
> cpu->stopped = true;
> + Error *local_err = NULL;
>
> if (!cpu->as) {
> /* If the target cpu hasn't set up any address spaces itself,
> @@ -2046,17 +2047,22 @@ void qemu_init_vcpu(CPUState *cpu)
> }
>
> if (kvm_enabled()) {
> - qemu_kvm_start_vcpu(cpu);
> + qemu_kvm_start_vcpu(cpu, &local_err);
> } else if (hax_enabled()) {
> - qemu_hax_start_vcpu(cpu);
> + qemu_hax_start_vcpu(cpu, &local_err);
> } else if (hvf_enabled()) {
> - qemu_hvf_start_vcpu(cpu);
> + qemu_hvf_start_vcpu(cpu, &local_err);
> } else if (tcg_enabled()) {
> - qemu_tcg_init_vcpu(cpu);
> + qemu_tcg_init_vcpu(cpu, &local_err);
> } else if (whpx_enabled()) {
> - qemu_whpx_start_vcpu(cpu);
> + qemu_whpx_start_vcpu(cpu, &local_err);
> } else {
> - qemu_dummy_start_vcpu(cpu);
> + qemu_dummy_start_vcpu(cpu, &local_err);
> + }
> +
> + if (local_err) {
> + error_propagate(errp, local_err);
> + return;
> }
I'd be inclined to make this method return a boolean, so....
> diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c
> index b08078e7fc..5b0b4892f2 100644
> --- a/target/alpha/cpu.c
> +++ b/target/alpha/cpu.c
> @@ -66,7 +66,11 @@ static void alpha_cpu_realizefn(DeviceState *dev, Error **errp)
> return;
> }
>
> - qemu_init_vcpu(cs);
> + qemu_init_vcpu(cs, &local_err);
> + if (local_err) {
> + error_propagate(errp, local_err);
> + return;
> + }
...this can be simplified to get rid of the local error object
if (!qemu_init_vcpu(cs, errp)) {
return;
}
likewise for the rest of the patch below...
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2018-09-04 11:22 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-04 11:08 [Qemu-devel] [PATCH 0/5] qemu_thread_create: propagate errors to callers to check Fei Li
2018-09-04 11:08 ` [Qemu-devel] [PATCH 1/5] Fix segmentation fault when qemu_signal_init fails Fei Li
2018-09-04 11:26 ` Daniel P. Berrangé
2018-09-05 4:17 ` Fei Li
2018-09-05 8:36 ` Daniel P. Berrangé
2018-09-05 11:20 ` Fei Li
2018-09-05 14:38 ` Fam Zheng
2018-09-06 6:31 ` Fei Li
2018-09-04 11:08 ` [Qemu-devel] [PATCH 2/5] ui/vnc.c: polish vnc_init_func Fei Li
2018-09-04 11:08 ` [Qemu-devel] [PATCH 3/5] qemu_init_vcpu: add a new Error paramater to propagate Fei Li
2018-09-04 11:22 ` Daniel P. Berrangé [this message]
2018-09-05 4:36 ` Fei Li
2018-09-05 17:15 ` Eric Blake
2018-09-06 6:52 ` Fei Li
2018-09-04 11:08 ` [Qemu-devel] [PATCH 4/5] qemu_thread_create: propagate the error to callers to check Fei Li
2018-09-04 11:18 ` Daniel P. Berrangé
2018-09-05 4:20 ` Fei Li
2018-09-04 11:08 ` [Qemu-devel] [PATCH 5/5] Propagate qemu_thread_create's error to all callers to handle Fei Li
2018-09-04 11:20 ` Daniel P. Berrangé
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=20180904112246.GF22349@redhat.com \
--to=berrange@redhat.com \
--cc=fli@suse.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 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).