qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 08/31] pc: Fix machine property nvdimm-persisten


From: Marc-André Lureau
Subject: Re: [Qemu-devel] [PATCH 08/31] pc: Fix machine property nvdimm-persistence error handling
Date: Tue, 9 Oct 2018 13:15:05 +0400

Hi
On Mon, Oct 8, 2018 at 9:38 PM Markus Armbruster <address@hidden> wrote:
>
> Calling error_report() in a function that takes an Error ** argument
> is suspicious.  pc.c's pc_machine_set_nvdimm_persistence() does that,
> and then exit()s.  Wrong.  Attempting to set machine property
> nvdimm-persistence to a bad value instantly kills the VM:
>
>     $ qemu-system-x86_64 -nodefaults -S -display none -qmp stdio
>     {"QMP": {"version": {"qemu": {"micro": 50, "minor": 0, "major": 3}, 
> "package": "v3.0.0-837-gc5e4e49258"}, "capabilities": []}}
>     {"execute": "qmp_capabilities"}
>     {"return": {}}
>     {"execute": "qom-set", "arguments": {"path": "/machine", "property": 
> "nvdimm-persistence", "value": "instadeath"}}
>     -machine nvdimm-persistence=instadeath: unsupported option
>     $ echo $?
>     1
>
> Broken when commit 11c39b5cd96 (v3.0.0) replaced error_propagate();
> return by error_report(); exit() instead of error_setg(); return.  Fix
> that.
>
> Fixes: 11c39b5cd966ddc067a1ca0c5392ec9b666c45b7
> Cc: "Michael S. Tsirkin" <address@hidden>
> Signed-off-by: Markus Armbruster <address@hidden>

Reviewed-by: Marc-André Lureau <address@hidden>

> ---
>  hw/i386/pc.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index cd5029c149..eab8572f2a 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -2209,8 +2209,9 @@ static void pc_machine_set_nvdimm_persistence(Object 
> *obj, const char *value,
>      else if (strcmp(value, "mem-ctrl") == 0)
>          nvdimm_state->persistence = 2;
>      else {
> -        error_report("-machine nvdimm-persistence=%s: unsupported option", 
> value);
> -        exit(EXIT_FAILURE);
> +        error_setg(errp, "-machine nvdimm-persistence=%s: unsupported 
> option",
> +                   value);
> +        return;
>      }
>
>      g_free(nvdimm_state->persistence_string);
> --
> 2.17.1
>
>


-- 
Marc-André Lureau



reply via email to

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