[pve-devel] [PATCH pve-ha-manager 3/4] Sim/Hardware: allow recursive locking in queue_crm_commands
Thomas Lamprecht
t.lamprecht at proxmox.com
Mon Dec 21 12:52:55 CET 2015
To allow regression testing for service migrate/relocate actions
we need to avoid a deadlock as we queue commands from the already
locked sim_hardware_cmd method.
This isn't real recursive locking (obviously) but a easy hack to let
queue_crm_commands know that it's called from a locked context.
We _cannot_ remove the locking in queue_crm_commands as the
simulator runs threaded and thus needs atomicity here, else we could
loose crm commands.
Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
src/PVE/HA/Sim/Hardware.pm | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/PVE/HA/Sim/Hardware.pm b/src/PVE/HA/Sim/Hardware.pm
index 24ef68b..7a27924 100644
--- a/src/PVE/HA/Sim/Hardware.pm
+++ b/src/PVE/HA/Sim/Hardware.pm
@@ -129,8 +129,10 @@ sub change_service_location {
$self->write_service_config($conf);
}
+# $is_locked is a hack to avoid a deadlock when we migrate/relocate
+# in the regression test
sub queue_crm_commands {
- my ($self, $cmd) = @_;
+ my ($self, $cmd, $is_locked) = @_;
chomp $cmd;
@@ -143,9 +145,12 @@ sub queue_crm_commands {
$data .= "$cmd\n";
PVE::Tools::file_set_contents($filename, $data);
};
-
- $self->global_lock($code);
+ if ($is_locked) {
+ &$code();
+ } else {
+ $self->global_lock($code);
+ }
return undef;
}
--
2.1.4
More information about the pve-devel
mailing list