[pve-devel] [PATCH qemu-server 1/3] hotplug_pending: remove redundant write/load config calls
Thomas Lamprecht
t.lamprecht at proxmox.com
Thu Dec 12 14:49:45 CET 2019
On 11/26/19 6:59 PM, Oguz Bektas wrote:
> instead of writing the config after every change, we can do it once for
> all the changes in the end to avoid redundant i/o.
>
Why is this OK?? The most important part is completely missing from
the commit message, namely that we can only do this because all errors
are caught and recorded gracefully, so any change which was done is
actually written out to the config even if another failed.
> we also don't need to load_config after writing fastplug changes.
>
> Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
> ---
> PVE/QemuServer.pm | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index 75e4f67..9749917 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -4773,7 +4773,6 @@ sub vmconfig_hotplug_pending {
>
> if ($changes) {
> PVE::QemuConfig->write_config($vmid, $conf);
> - $conf = PVE::QemuConfig->load_config($vmid); # update/reload
> }
>
> my $hotplug_features = parse_hotplug_features(defined($conf->{hotplug}) ? $conf->{hotplug} : '1');
> @@ -4833,11 +4832,8 @@ sub vmconfig_hotplug_pending {
> if (my $err = $@) {
> &$add_error($opt, $err) if $err ne "skip\n";
> } else {
> - # save new config if hotplug was successful
> delete $conf->{$opt};
> PVE::QemuConfig->remove_from_pending_delete($conf, $opt);
> - PVE::QemuConfig->write_config($vmid, $conf);
> - $conf = PVE::QemuConfig->load_config($vmid); # update/reload
> }
> }
>
> @@ -4925,13 +4921,12 @@ sub vmconfig_hotplug_pending {
> if (my $err = $@) {
> &$add_error($opt, $err) if $err ne "skip\n";
> } else {
> - # save new config if hotplug was successful
> $conf->{$opt} = $value;
> delete $conf->{pending}->{$opt};
> - PVE::QemuConfig->write_config($vmid, $conf);
> - $conf = PVE::QemuConfig->load_config($vmid); # update/reload
> }
> }
> +
> + PVE::QemuConfig->write_config($vmid, $conf);
> }
>
> sub try_deallocate_drive {
>
More information about the pve-devel
mailing list