[pve-devel] [PATCH v2 qemu-server 2/3] add error handling to vmconfig_apply_pending
Thomas Lamprecht
t.lamprecht at proxmox.com
Fri Dec 20 10:58:10 CET 2019
Am 12/13/19 um 12:41 PM schrieb Oguz Bektas:
> ---
> PVE/API2/Qemu.pm | 6 +++---
> PVE/QemuServer.pm | 9 ++++++++-
> 2 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
> index 3c7ef30..baa96f2 100644
> --- a/PVE/API2/Qemu.pm
> +++ b/PVE/API2/Qemu.pm
> @@ -1241,13 +1241,13 @@ my $update_vm_api = sub {
>
> $conf = PVE::QemuConfig->load_config($vmid); # update/reload
>
> + my $errors = {};
> if ($running) {
> - my $errors = {};
> PVE::QemuServer::vmconfig_hotplug_pending($vmid, $conf, $storecfg, $modified, $errors);
> - raise_param_exc($errors) if scalar(keys %$errors);
> } else {
> - PVE::QemuServer::vmconfig_apply_pending($vmid, $conf, $storecfg, $running);
> + PVE::QemuServer::vmconfig_apply_pending($vmid, $conf, $storecfg, $running, $errors);
> }
> + raise_param_exc($errors) if scalar(keys %$errors);
>
> return;
> };
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index 9c89be5..ed6b557 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -4977,7 +4977,14 @@ sub vmconfig_delete_or_detach_drive {
>
>
> sub vmconfig_apply_pending {
> - my ($vmid, $conf, $storecfg) = @_;
> + my ($vmid, $conf, $storecfg, $errors) = @_;
> +
> + my $add_apply_error = sub {
> + my ($opt, $msg) = @_;
> + my $err_msg = "unable to apply pending change $opt : $msg";
> + $errors->{$opt} = $err_msg;
> + warn $err_msg;
> + };
>
> # cold plug
>
>
... missing the actual error handling, which you squashed into 3/3, both
are now not patches who do one thing stand-alone.
Please do all the parts from 3/3 which do _not_ remove a write/load config
in this patch, i.e., the
> if (my $err = $@) {
> $add_apply_error->($opt, $err);
and "fixing" eval guard scopes parts..
More information about the pve-devel
mailing list