1ec22be5 added code that detects the maximum cpu count according to
domain capabilities. The code fell back to the old command only if the
API was not supported. If the API fails for other reasons the command
would fail. There's no point in not trying the old API in such case.
https://bugzilla.redhat.com/show_bug.cgi?id=1402690
Some arguments in vshErrorHandler, vshReadlineCompletion and
cmdSelfTest functions are not used. Mark them as such.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
If the 'nleases < 0' on return, then the subsequent call to
findLeaseInJSON will not produce the expected results (passed
in as a size_t, but nleases is a ssize_t). So check if the
returned value < 0 and if so, goto cleanup.
Found by Coverity as a NEGATIVE_RETURNS event
With current perf framework, this patch adds support and documentation
for the branch_instructions perf event.
Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
So far the NSS module looks up only hostnames as provided by
guests themselves. However, there are some cases where this is
not enough: e.g. when there's a fresh new guest being installed
(with some generic hostname) say from a live ISO image; or some
(older) systems don't advertise their hostname in DHCP
transactions at all.
In cases like that it would be helpful if we translate domain
name as seen by libvirt too so that users can:
# virsh start $dom && ssh $dom
In order to achieve that new libvirt-guest module is introduced,
while older libvirt module maintains its current behaviour (that
is translating guest provided names into IP addresses).
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
The part of the code that iterates over an array of JSON values
is going to be re-used. Instead of copying it over, move it to a
separate function.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
The part of the code that appends found IP address into a list is
going to be re-used. Instead of copying it over, move it to a
separate function.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
The name of the exported functions for an NSS module is quite
fixed, it is derived from the module name:
_nss_$module_$function
Since we will create another NSS module with very similar
implementation we might as well generate the function names at
the compile time.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
We have couple of functions that operate over NULL terminated
lits of strings. However, our naming sucks:
virStringJoin
virStringFreeList
virStringFreeListCount
virStringArrayHasString
virStringGetFirstWithPrefix
We can do better:
virStringListJoin
virStringListFree
virStringListFreeCount
virStringListHasString
virStringListGetFirstWithPrefix
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
It is already discussed in "[RFC] daemon: remove hardcode dep on libvirt-guests" [1].
Mgmt can use means to save/restore domains on system shutdown/boot other than
libvirt-guests.service. Thus we need to specify appropriate ordering dependency between
libvirtd, domains and save/restore service. This patch takes approach suggested
in RFC and introduces a systemd target, so that ordering can be built next way:
libvirtd -> domain -> virt-guest-shutdown.target -> save-restore.service.
This way domains are decoupled from specific shutdown service via intermediate
target.
[1] https://www.redhat.com/archives/libvir-list/2016-September/msg01353.html
Commit v1.3.3-181-gb028e9d7c implmented support for
VIR_MIGRATE_PARAM_PERSIST_XML migration parameter, but forgot to update
virsh.
https://bugzilla.redhat.com/show_bug.cgi?id=835300
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Although there already was an effort (b620bdee) to replace vshPrint occurrences
with vshPrintExtra due to '--quiet' flag, there were still some leftovers. So
this patch fixes them, hopefully for good.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1356881
Signed-off-by: Erik Skultety <eskultet@redhat.com>
There were a few places in our virsh* code where instead of calling vshError
on failure we called vshPrint.
Signed-off-by: Erik Skultety <eskultet@redhat.com>
First, since commit 834c5720 the error reporting within the vshErrorHandler
doesn't work because there was a lot of renaming going on (dull mechanical
renaming without much thinking about it, yep - shame on me) and so the original
env variable VIRSH_DEBUG got renamed to VSH_DEBUG which we don't support nor
document anywhere. Second, by specifying this env variable, the last libvirt
error gets reported twice despite the fact we say the error reporting should be
deferred until the command finishes, and last but not least the vintage code's
logic is a bit 'odd', since the error would get reported iff the env variable
is set, even if the value should be equal to our DEFAULT value in which case it
doesn't make sense that we behave differently when an env variable is set to
some value and when there's no env variable at all but we use the same value
automatically as default.
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Unlike the other error messages in vshInitDebug, this one relied on a hardcoded
name of a variable instead of using the prefix of the tool calling the init
routine.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1393854
Signed-off-by: Erik Skultety <eskultet@redhat.com>
After 06a7b1ff4 the @&opts_need_arg is not used anywhere. Well,
it is set but never read:
vsh.c: In function 'vshReadlineParse':
vsh.c:2658:14: warning: variable 'opts_need_arg' set but not used [-Wunused-but-set-variable]
uint64_t opts_need_arg, opts_seen;
^~~~~~~~~~~~~
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Commit id 'dcfdf341' passes 'opts_need_arg' and 'opts_seen' to
vshCmddefGetData, but that seems to be incorrect as those values
are not initialized properly (something at least one compiler found).
Instead the static 'const_opts_need_arg' and 'const_opts_seen' values
should be passed.
By passing unitialized values leads to not finding possible options
for simpler commands (domfsfreeze for example), where if you're in
a virsh shell using command line completion - you'll get a list of
files in your current directory instead of two options --domain and
--mountpoint (as would happen with this patch applied.
Correcting the error reporting method by using VSH_REQUIRE_OPTION
instead of virReportError
Signed-off-by: Kothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
The 'on_shutdown' was the name in Xen, there was never such option in
libvirt's domain XML.
Reported-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Since we're using autoconf to substitute the right value in
Makefile.am now, we can use a less generic name without running
into circular dependencies.
Adding $(prefix) in Makefile.am, as we were doing, means that
it would be prepended even when using --with-ws-plugindir,
which is something we don't want to happen.
Instead, we add it beforehand but take care that it doesn't
get expanded until make is called.
https://bugzilla.redhat.com/show_bug.cgi?id=1349898
Add the duration parameters to the virsh input/output for blkdeviotune
command and describe them in the pod file.
Signed-off-by: John Ferlan <jferlan@redhat.com>
Rework the repetitive lines to add iotune values into easier to read macros.
One to handle the SCALED values and one to handle the non scaled values.
Signed-off-by: John Ferlan <jferlan@redhat.com>
Added description for new vcpu.<num>.halted statistics value.
While there, also added a description for vcpu.<num>.wait and
clarified the units displayed for time and wait.
Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
It is stated in the manual already, so let's mention the same thing in
the description to avoid causing problems.
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
If the VM is offline virsh attempted to at least report the pinning
information for the VM. This would not work properly now that the vcpus
can be sparse. Fix it by getting the vcpu states from the XML.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1375920
The fallback code used if virDomainGetVcpusFlags is not supported used
wrong XPath queries and basically did not work at all. Fix them to point
to the <domain> <vcpu> element instead of <vcpus> which was not present
until lately.
The Requires relationship is very strong, in that it prevents
a unit from running unless all the units it Requires are
running as well.
This turns out to be a problem because we want to be able to
restart libvirtd at any time without having libvirt-guests
suspend or shutdown running guests.
Turn the Requires relationship into a Wants relationship:
this way starting libvirt-guests will cause systemd to (attempt
to) start libvirtd as well, but stopping or restarting libvirtd
will not alter libvirt-guests' running state.
1. Move the declaration of const vshCmdDef *help - it should be at the
top of the "if" rather than in the middle.
2. Change a comparison from && to || - without doing so we could crash
on commands like 'virsh list' which would allow completion of some
non -- option based on whatever was found in the current working
directory and then as soon as that was completed, the next <tab>
would crash since "opt" would be returned as NULL, but the check
was dereferencing "&& opt->type"
3. Before dereferencing opt->completer, be sure opt isn't NULL.
With newer versions of libvirt Domain-0 is again visible in the list of
running guests but it should not be considered as a guest for shutdown
or suspend.
Signed-off-by Stefan Bader <stefan.bader@canonical.com>
The list file expects all guest UUIDs on the same line as the URI
which the guests run on. This does not happen when the list is
echo'ed in quotes. When stripping the quotes, newlines get transformed
into spaces. Without this, only the first guest on the list is actually
handled.
Based on a fix by Omar Siam <simar@gmx.net>
Bug-Ubuntu: http://bugs.launchpad.net/bugs/1591695
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
For one VM, it could had more than one graphical display.
Such as we coud add both vnc and spice display to a VM.
This patch introduces '--all' for showing all
possible graphical display of a active VM.
Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
GCC complained that
vsh.c: In function 'vshReadlineOptionsGenerator':
vsh.c:2622:29: warning: unused variable 'opt' [-Wunused-variable]
const vshCmdOptDef *opt = &cmd->opts[list_index];
^
vsh.c: In function 'vshReadlineParse':
vsh.c:2830:44: warning: 'opt' may be used uninitialized in this function
[-Wmaybe-uninitialized]
completed_list = opt->completer(autoCompleteOpaque,
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
For compatibility reasons virDomainSetVcpus needs to add vcpus as non
hotpluggable which means that the users will not be able to unplug it
after the VM has started. Add a flag that will allow to tell the API
that the unpluggable vcpus are okay.
The NSS module shouldn't rely on custom leases database to not have
entries for leases which have expired.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=1379895
Introduced by commit id '834c5720'.
During the code motion and creation of vsh.c, the function 'vshDeinit()'
in the (new) vsh.c was altered from whence it came in virsh.c such that
calling 'vshReadlineDeinit(ctl)' was conditional on "ctl->imode".
This causes a problem for the interactive running if the "quit" and "exit"
commands are used because 'cmdQuit' will clear ctl->imode, thus when the
interactive loop in main() of virsh.c exits because ctl->mode is clear and
virshDeinit is called which calls vshDeinit, the history file is now not
written. Conversely, if one had exited the interactive loop via pressing
<ctrl>D the file would be created because loop control is broken on EOF
and ctl->imode is not set to false.
This patch will remove the conditional call to vshReadlineDeinit and
restore the former behaviour.