[pve-devel] [PATCH 1/6] vm_deviceplug|unplug : implement pending change
Dietmar Maurer
dietmar at proxmox.com
Tue Nov 18 11:19:21 CET 2014
> Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
> ---
> PVE/QemuServer.pm | 127 ++++++++++++++++++++++++++++++++++++---------
> --------
> 1 file changed, 86 insertions(+), 41 deletions(-)
>
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index e43a228..141a21c
> 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -2994,63 +2994,81 @@ sub vm_devices_list { }
>
> sub vm_deviceplug {
> - my ($storecfg, $conf, $vmid, $deviceid, $device) = @_;
> + my ($storecfg, $conf, $vmid, $deviceid, $device, $optvalue) = @_;
>
> - return 1 if !check_running($vmid);
> + if (!check_running($vmid)){
> + if($conf->{pending}->{$deviceid}){
> + $conf->{$deviceid} = $optvalue;
> + delete $conf->{pending}->{$deviceid};
> + PVE::QemuServer::update_config_nolock($vmid, $conf, 1);
> + }
> + }
Why do you want to modify configuration here? I am a bit afraid of side effect, because
we call this function from several places? Maybe better to make the explicit, like:
if (vm_deviceplug(...)) {
$conf->{$deviceid} = $optvalue;
delete $conf->{pending}->{$deviceid};
PVE::QemuServer::update_config_nolock($vmid, $conf, 1);
}
(we can also make an extra sub for that)
More information about the pve-devel
mailing list