mirror of
git://git.proxmox.com/git/qemu-server.git
synced 2025-02-03 13:47:15 +03:00
property string update: watchdog
This commit is contained in:
parent
1f4f447b58
commit
ec3582b52a
@ -109,6 +109,24 @@ my $cpu_fmt = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
my $watchdog_fmt = {
|
||||||
|
model => {
|
||||||
|
default_key => 1,
|
||||||
|
type => 'string',
|
||||||
|
enum => [qw(i6300esb ib700)],
|
||||||
|
description => "Watchdog type to emulate.",
|
||||||
|
default => 'i6300esb',
|
||||||
|
optional => 1,
|
||||||
|
},
|
||||||
|
action => {
|
||||||
|
type => 'string',
|
||||||
|
enum => [qw(reset shutdown poweroff pause debug none)],
|
||||||
|
description => "The action to perform if after activation the guest fails to poll the watchdog in time.",
|
||||||
|
optional => 1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
PVE::JSONSchema::register_format('pve-qm-watchdog', $watchdog_fmt);
|
||||||
|
|
||||||
my $confdesc = {
|
my $confdesc = {
|
||||||
onboot => {
|
onboot => {
|
||||||
optional => 1,
|
optional => 1,
|
||||||
@ -322,7 +340,6 @@ EODESC
|
|||||||
watchdog => {
|
watchdog => {
|
||||||
optional => 1,
|
optional => 1,
|
||||||
type => 'string', format => 'pve-qm-watchdog',
|
type => 'string', format => 'pve-qm-watchdog',
|
||||||
typetext => '[[model=]i6300esb|ib700] [,[action=]reset|shutdown|poweroff|pause|debug|none]',
|
|
||||||
description => "Create a virtual hardware watchdog device. Once enabled" .
|
description => "Create a virtual hardware watchdog device. Once enabled" .
|
||||||
" (by a guest action), the watchdog must be periodically polled " .
|
" (by a guest action), the watchdog must be periodically polled " .
|
||||||
"by an agent inside the guest or else the watchdog will reset " .
|
"by an agent inside the guest or else the watchdog will reset " .
|
||||||
@ -1826,36 +1843,13 @@ sub verify_net {
|
|||||||
die "unable to parse network options\n";
|
die "unable to parse network options\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
PVE::JSONSchema::register_format('pve-qm-watchdog', \&verify_watchdog);
|
|
||||||
sub verify_watchdog {
|
|
||||||
my ($value, $noerr) = @_;
|
|
||||||
|
|
||||||
return $value if parse_watchdog($value);
|
|
||||||
|
|
||||||
return undef if $noerr;
|
|
||||||
|
|
||||||
die "unable to parse watchdog options\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
sub parse_watchdog {
|
sub parse_watchdog {
|
||||||
my ($value) = @_;
|
my ($value) = @_;
|
||||||
|
|
||||||
return undef if !$value;
|
return undef if !$value;
|
||||||
|
|
||||||
my $res = {};
|
my $res = eval { PVE::JSONSchema::parse_property_string($watchdog_fmt, $value) };
|
||||||
|
warn $@ if $@;
|
||||||
foreach my $p (split(/,/, $value)) {
|
|
||||||
next if $p =~ m/^\s*$/;
|
|
||||||
|
|
||||||
if ($p =~ m/^(model=)?(i6300esb|ib700)$/) {
|
|
||||||
$res->{model} = $2;
|
|
||||||
} elsif ($p =~ m/^(action=)?(reset|shutdown|poweroff|pause|debug|none)$/) {
|
|
||||||
$res->{action} = $2;
|
|
||||||
} else {
|
|
||||||
return undef;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user