Any action we take in tap_plug() when using OVS will undo
our rate limiting, which means any hotplug change must
restore the previous rate setting.
Since this means tap_plug() would always be followed by a
tap_rate_limit() call anyway we just include the rate
parameter here and let the caller decide whether the full
tap_plug() is required or the simple tap_rate_limit()
suffices.
This hook runs before and after creating volume snapshots,
as well as after unfreezing. Only needed for Qemu right now,
so the base case in PVE::AbstractConfig is a noop.
This class contains common code formerly duplicated in
PVE::LXC and PVE::QemuServer, as well as abstract methods
that must be implemented for LXC and Qemu seperately.
Currently implemented in PVE::LXC::Config, Qemu refactoring
will follow.
Dominik Csapak [Fri, 12 Feb 2016 10:43:23 +0000 (11:43 +0100)]
limit vmid with JSON format
if we do not do this, vmids < 100 (not really bad) and
vmids > 999999999 are possible, which can lead to vms which you can
only get rid of, if you delete the config files manually
also this makes the api consistent with the webgui for vmids
Fix #882: active state of interfaces depends on ipv6
read_etc_network_interfaces used the content of
/proc/net/if_inet6 to decide whether an interface's state is
"active", which means an interface is only active when it
has an ipv6 address, thus using net.ipv6.conf.*.disable_ipv6
on an interface will cause it to show as inactive in the web
interface.
We now filter the interfaces found in /proc/dev/net by their
IFF_UP flag read via an SIOCGIFFLAGS ioctl().
This was already implemented in PVE::LXC::lock_aquire() and
lock_release(). Enabling refcounting in the general
PVE::Tools::lock_file() and lock_file_full() methods allows
us to use one code base for flocking.
Furthermore, we could get rid of various xx_no_lock methods
that were required because the old non-refcounting version
did not support nested flocks (the inner most flock would
close the file handle and thus release the flock).
Thomas Lamprecht [Wed, 16 Dec 2015 09:38:20 +0000 (10:38 +0100)]
Output also lockname if it cannot be acquired
If we can't acquire the lock in lock_file_full and get interrupted
by a signal inqeual to EINTR (e.g. SIGTERM), output also it's name
in the error message to allow better debugging.
Also fix a typo.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Thomas Lamprecht [Wed, 16 Dec 2015 09:38:19 +0000 (10:38 +0100)]
allow fall back to default completion
This allows a fall back to the default completion, which completes
possible paths/files, if nothing can be generated from the PVE
completion handler ($print_bash_completion) or if the user starts
to entry a path.
This is especially useful for restore or create commands which can
take an archive file as argument.
The bash-completions get generated at each package build through the
respective Makefile, so to let this change come in effect the package
needs to be rebuild and installed (and the respective file from
/usr/share/bash-completion/completions/<pve cli tool> needs to be
sourced again (or simply open a new terminal))
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
They were leaking into processes blocking full restarts of
the daemons.
Note that perl's fcntl doesn't work on numeric
filedescriptors (neither does POSIX::fcntl, which even stays
silent about it and returns EBADF without ever trying to
actually perform the fcntl syscall), so the socket handles
need to be stored ($daemon_sockets).
The flag is added back when the socket gets reopened.
Thomas Lamprecht [Mon, 30 Nov 2015 08:25:20 +0000 (09:25 +0100)]
run_command: return exit code and add noerr
Allow to return the exit code of the executed command.
And as we do not reach the return of the exit code if it was not 0,
a noerr parameter is also needed so we can suppress the 'command
failed' die in case of an exit code unequal to 0.
This is required as some programs return another value than 0 when
they succeed, For example `systemctl list-jobs` returns a value
>= 0 on a successful execution, normally 1.
Without this patch a run_command call to `systemctl list-jobs` gets
marked as failed although it was successful.
This does not break current behaviour in any way as setting the
noerr parameter is required to return something other than 0 or
undef, which are equal in a boolean comparison.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Keys in the skip-list don't need to be valid schema keys.
This was overly strict before which makes it harder to
include temporary internal keys in a such an object.
There are a few places where we grep over /proc/mounts
without taking the encoding into acount.
ProcFSTools::parse_mounts parses mount data and decodes all
the special character the kernel might encode into it.
Shortcut: parse_proc_mounts to do
parse_mounts(read_proc_mounts()).
is_mounted() updated to parse mounts correctly.
Tools: make unshare behave like other perl syscalls
Most syscall wrappers in perl return 1 on success and our
current use of Tools::unshare isn't using the return value
(yet), so let's fix this while we can.
Also it seems to make sense to use prototyping on syscalls
to add some compile-time argument checking.
- read_v6addr used the wrong $_
- All values in the file are hex and possibly prefixed with
zeroes so we need to make sure they don't get interpreted as
octal.
In qemu the 'volume' key maps to 'file', both can be used,
so to support this case in the comma-separated property
list parser we need a way to alias keys to one another.
This allows declaring a key like:
volume => {
alias => 'file'
}
file => {
type => 'string',
format => 'pve-volume-id',
default_key => 1,
format_description => 'volume'
}
With this the following property strings are equivalent and
result in the same datastructure being returned from
parse_property_string:
Giving unknown interfaces an order-id of 0 caused them to
always be on top of the interfaces file. This is often
undesired. Instead we now only take type-ordering into
account when both interfaces which are being compared have a
known type, and otherwise only use the priority attribute.
This should result in a more stable modification of
interfaces.
In an alternation /a|b|c/ the first match matches, so while
'1.1.1.121' matches /^$IPV4RE$/ (note the ^ and $ anchors),
parsing a line like /nameserver ($IPV4RE)/ would only
extract '1.1.1.12', ignoring the last '1' due to the /[1-9]/
alternative matching before the /1[0-9]/ one.
Dietmar Maurer [Fri, 2 Oct 2015 08:37:50 +0000 (10:37 +0200)]
CLIHandler: make read_password an optional class method
And correctly hide password option when generation man pages.
I also define a new method run_cli_handler() meant to replace
the old run_cli() code, using named parameters.
It's a special case in some output functions as it needs
to use format_size(), so it'll be its own type and handled
in the upcoming print_property_string() function.
Now that generate_typetext doesn't need to be accessed
anymore it made sense to move it to PodParser.pm as this is
the only place that uses it now.
PodParser now needs access to JSONSchema's $format_list, so
a JSONSchema::get_format was added.