# using a computed version and only those can be used by the cfs_*_file methods
my $observed = {
'vzdump.cron' => 1,
+ 'vzdump.conf' => 1,
'jobs.cfg' => 1,
'storage.cfg' => 1,
'datacenter.cfg' => 1,
'replication.cfg' => 1,
'corosync.conf' => 1,
'corosync.conf.new' => 1,
+ 'firewall/cluster.fw' => 1,
'user.cfg' => 1,
'domains.cfg' => 1,
'priv/shadow.cfg' => 1,
my $res = -l "$basedir/local";
- die "pve configuration filesystem not mounted\n"
- if !$res && !$noerr;
+ die "pve configuration filesystem (pmxcfs) not mounted\n" if !$res && !$noerr;
return $res;
}
return $res;
}
+# properties: an array-ref of config properties you want to get, e.g., this
+# is perfect to get multiple properties of a guest _fast_
+# (>100 faster than manual parsing here)
+# vmid: optional, if a valid is passed we only check that one, else return all
+# NOTE: does *not* searches snapshot and PENDING entries sections!
+# NOTE: returns the guest config lines (excluding trailing whitespace) as is,
+# so for non-trivial properties, checking the validity must be done
+# NOTE: no permission check is done, that is the responsibilty of the caller
+sub get_guest_config_properties {
+ my ($properties, $vmid) = @_;
+
+ die "properties required" if !defined($properties);
+
+ my $num_props = scalar(@$properties);
+ die "only up to 255 properties supported" if $num_props > 255;
+ my $bindata = pack "VC", $vmid // 0, $num_props;
+ for my $property (@$properties) {
+ $bindata .= pack "Z*", $property;
+ }
+ my $res = $ipcc_send_rec_json->(CFS_IPC_GET_GUEST_CONFIG_PROPERTIES, $bindata);
+
+ return $res;
+}
+
# property: a config property you want to get, e.g., this is perfect to get
# the 'lock' entry of a guest _fast_ (>100 faster than manual parsing here)
-# vmid: optipnal, if a valid is passed we only check that one, else return all
+# vmid: optional, if a valid is passed we only check that one, else return all
# NOTE: does *not* searches snapshot and PENDING entries sections!
+# NOTE: returns the guest config lines (excluding trailing whitespace) as is,
+# so for non-trivial properties, checking the validity must be done
+# NOTE: no permission check is done, that is the responsibilty of the caller
sub get_guest_config_property {
my ($property, $vmid) = @_;
sub broadcast_tasklist {
my ($data) = @_;
- # the serialized list may not get bigger than 32kb (CFS_MAX_STATUS_SIZE
- # from pmxcfs) - drop older items until we satisfy this constraint
+ # the serialized list may not get bigger than 128 KiB (CFS_MAX_STATUS_SIZE from pmxcfs)
+ # drop older items until we satisfy this constraint
my $size = length(encode_json($data));
- while ($size >= (32 * 1024)) {
+ while ($size >= (32 * 1024)) { # TODO: update to 128 KiB in PVE 8.x
pop @$data;
$size = length(encode_json($data));
}
- eval {
- &$ipcc_update_status("tasklist", $data);
- };
-
+ eval { $ipcc_update_status->("tasklist", $data) };
warn $@ if $@;
}
foreach my $node (@$nodelist) {
next if $nodename && ($nodename ne $node);
eval {
- my $ver = $kvstore->{$node}->{tasklist} if $kvstore->{$node};
+ my $ver = exists $kvstore->{$node} ? $kvstore->{$node}->{tasklist} : undef;
my $cache = $tasklistcache->{$node};
if (!$cache || !$ver || !$cache->{version} || ($cache->{version} != $ver)) {
my $tasks = [];