]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
8 years agoqemu: agent: skip outdated sync replies
Nikolay Shirokovskiy [Fri, 16 Sep 2016 10:35:34 +0000 (13:35 +0300)]
qemu: agent: skip outdated sync replies

When we wait for sync reply we can receive delayed
reply to syncs or commands that were sent erlier. We can
safely skip them until we receive sync reply with correct id.
There is no much sense report this situation to client.
Actually with a bit of "luck" if we involve client into
this the play can go on forever: send sync 0, receive
sync reply -1, send sync 1, receive reply 0 ...

8 years agoqemu: agent: ignore garbage while waiting for sync reply
Nikolay Shirokovskiy [Fri, 16 Sep 2016 10:35:33 +0000 (13:35 +0300)]
qemu: agent: ignore garbage while waiting for sync reply

After sync is sent we can receive garbare and this is not error.
Consider next regular case:

1. libvirtd sends sync
2. qga sends partial sync reply and die
3. libvirtd sends sync
4. qga sends sync reply
5. libvirtd receives garbage
  (half of first reply and second reply together)

We should handle this situation as it is recoverable.
Next sync can succeed. Let's report reply is NULL,
it will be converted to the VIR_ERR_AGENT_UNSYNCED
which signals client to retry.

8 years agoqemu: agent: ignore delayed reply when unsynced
Nikolay Shirokovskiy [Fri, 16 Sep 2016 10:35:32 +0000 (13:35 +0300)]
qemu: agent: ignore delayed reply when unsynced

Errors in qemuAgentIOProcessLine stop agent IO processing just
like any regular IO error, however some of current errors
that this functions spawns are false positives. Consider
next case for example:

1. send sync (unsynced state)
2. receive sync reply (sync established)
3. command send, but timeout occured (unsynced state)
4. receive command reply

Last IO triggers error because current code ignores
only delayed syncs when unsynced

We should not treat any delayed reply as error in unsynced
state. Until client and qga are not in sync delayed reply to any
command is possible. msg == NULL is the exact criterion
that we are not in sync.

8 years agoconf: Add some shmem helpers for future use
Martin Kletzander [Mon, 12 Sep 2016 11:41:07 +0000 (13:41 +0200)]
conf: Add some shmem helpers for future use

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: Add qemuAssignDeviceShmemAlias and use it
Martin Kletzander [Mon, 12 Sep 2016 13:48:41 +0000 (15:48 +0200)]
qemu: Add qemuAssignDeviceShmemAlias and use it

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: Rename qemuBuildShmemBackendStr to qemuBuildShmemBackendChrStr
Martin Kletzander [Tue, 13 Sep 2016 12:12:29 +0000 (14:12 +0200)]
qemu: Rename qemuBuildShmemBackendStr to qemuBuildShmemBackendChrStr

There will be more backends in the future so let's not complicate it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: Abstract shmem socket path preparation
Martin Kletzander [Tue, 13 Sep 2016 11:40:50 +0000 (13:40 +0200)]
qemu: Abstract shmem socket path preparation

Put it into qemuDomainPrepareShmemChardev() so it can be used later.
Also don't fill in the path unless the server option is enabled.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: Reorder shmem params nicely
Martin Kletzander [Wed, 10 Aug 2016 07:34:45 +0000 (09:34 +0200)]
qemu: Reorder shmem params nicely

Always format id first so that we don't need to do that twice in
different code paths.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: Move common checks outside qemuBuildShmemDevLegacyStr
Martin Kletzander [Mon, 8 Aug 2016 11:44:38 +0000 (13:44 +0200)]
qemu: Move common checks outside qemuBuildShmemDevLegacyStr

Some checks will need to be performed for newer device types as well, so
let's not duplicate them.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: Rename qemuBuildShmemDevStr to qemuBuildShmemDevLegacyStr
Martin Kletzander [Mon, 8 Aug 2016 11:44:28 +0000 (13:44 +0200)]
qemu: Rename qemuBuildShmemDevStr to qemuBuildShmemDevLegacyStr

This will make sense after adding support for newer device types.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: Make qemuBuildShmemDevStr static
Martin Kletzander [Mon, 8 Aug 2016 14:45:37 +0000 (16:45 +0200)]
qemu: Make qemuBuildShmemDevStr static

It isn't used anywhere else.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agovirtlogd: Don't stop or restart along with libvirtd
Andrea Bolognani [Tue, 20 Sep 2016 13:22:04 +0000 (15:22 +0200)]
virtlogd: Don't stop or restart along with libvirtd

Commit 839a060 tied the lifecycle of virtlogd more
closely to that of libvirtd. Unfortunately, while starting
virtlogd when libvirtd is started is definitely a good idea,
restarting virtlogd or shutting it down at any time outside
of system poweroff is not.

Revert part of that commit by removing the PartOf= lines,
meaning that only startup requests will be propagated from
libvirtd to virtlogd.

Resolves: https://bugzilla.redhat.com/1372576

8 years agovirt-admin: Add some command aliases to provide syntax sugar over ugly commands
Erik Skultety [Wed, 7 Sep 2016 15:27:52 +0000 (17:27 +0200)]
virt-admin: Add some command aliases to provide syntax sugar over ugly commands

Make use of the new recently introduced alias handling for virt-admin srv-*
commands.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovirt-admin: Tweak command parsing logic so that aliases point to new commands
Erik Skultety [Wed, 7 Sep 2016 15:30:48 +0000 (17:30 +0200)]
virt-admin: Tweak command parsing logic so that aliases point to new commands

Change the logic in a way, so that VSH_CMD_FLAG_ALIAS behaves similarly to
how VSH_OT_ALIAS for command options, i.e. there is no need for code duplication
for the alias and the aliased command structures. Along with that change,
switch any existing VSH_CMD_FLAG_ALIAS occurrences to this new format. Also,
since this patch introduces a new command structure element, adjust the
virsh-self-test test to make sure we won't ever miss to specify the '.alias'
member for an aliased command because doing that would lead to an internal
error.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovirsh: man: Do not document our old deprecated nodedev-dettach command
Erik Skultety [Fri, 16 Sep 2016 14:06:47 +0000 (16:06 +0200)]
virsh: man: Do not document our old deprecated nodedev-dettach command

The command is deprecated due to being grammatically incorrect, but for
backwards compatibility reasons cannot be removed. However, we should not
document such commands.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovsh: discard vshCmddefOptFill and move its body to vshCmddefOptParse
Erik Skultety [Fri, 16 Sep 2016 08:17:46 +0000 (10:17 +0200)]
vsh: discard vshCmddefOptFill and move its body to vshCmddefOptParse

Recent changes extracted the command internals validation routine from
vshCmddefOptParse method which now just calls vshCmddefOptFill. Therefore, make
vshCmddefOptFill the new vshCmddefOptParse and drop the unnecessary name.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovsh: Extract vshCmddefCheckInternals from vshCmddefOptParse
Erik Skultety [Fri, 16 Sep 2016 07:58:24 +0000 (09:58 +0200)]
vsh: Extract vshCmddefCheckInternals from vshCmddefOptParse

Originally introduced by commit 2432521e which correctly split
vshCmddefOptParse into command's options validation and options parsing.
However, command's 'internals' are not tied solely to .options, rather it
should be about the overall structure, therefore the validation should be
extracted from vshCmddefOptParse and performed only within our test suite, i.e.
in vshSelfTest.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovsh: vshCmddefHelp: Drop the unnecessary 'else' branch
Erik Skultety [Thu, 15 Sep 2016 15:52:11 +0000 (17:52 +0200)]
vsh: vshCmddefHelp: Drop the unnecessary 'else' branch

If the initial check is true the function immediately returns so there's no
need to enclose the code following the check within an 'else' block.
Also, by removing the 'else' block, the declarations need to be moved to
beginning of the function block to conform with our guidelines.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovsh: vshCmddefHelp: Drop unnecessary variable 'help'
Erik Skultety [Fri, 16 Sep 2016 12:32:01 +0000 (14:32 +0200)]
vsh: vshCmddefHelp: Drop unnecessary variable 'help'

Since it's used on a single place only, it can easily be replaced by the right
side of the original assignment.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovsh: Enforce checking for missing help string
Erik Skultety [Mon, 19 Sep 2016 11:10:38 +0000 (13:10 +0200)]
vsh: Enforce checking for missing help string

The intention is to move vshCmddefCheckInternals out of vshCmddefOptParse to
our test suite. First step to do that is to enforce checking for an existing
help string (that also means it's non-empty) in a command because a command
without a help is not much of a use.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoAdd missing 'extern' for VIR_EXPORT_VAR macro
Daniel P. Berrange [Tue, 20 Sep 2016 11:51:07 +0000 (12:51 +0100)]
Add missing 'extern' for VIR_EXPORT_VAR macro

The recent update to gnulib

  commit 9d7a37ecb2ab516c19164a57b8aeb32016a99d2c
  Author: Eric Blake <eblake@redhat.com>
  Date:   Thu Sep 15 15:12:52 2016 -0500

    build: update to latest gnulib

Pulled in a change that adds -fno-common to the default compiler
flags

  commit bf8e658ffadb95d444f56d222d04c9af955af765
  Author: Jim Meyering <meyering@fb.com>
  Date:   Fri Sep 2 09:16:16 2016 -0700

    manywarnings: add -fno-common

This caused libvirt Mingw build to break with the compiler
reporting 100's of definitions of virConnectAuthPtrDefault

./.libs/libvirt_util.a(libvirt_util_la-virarch.o):virarch.c:(.bss+0x0): multiple definition of `virConnectAuthPtrDefault'
./.libs/libvirt_util.a(libvirt_util_la-viralloc.o):viralloc.c:(.bss+0x0): first defined here
./.libs/libvirt_util.a(libvirt_util_la-viratomic.o):viratomic.c:(.bss+0x0): multiple definition of `virConnectAuthPtrDefault'
./.libs/libvirt_util.a(libvirt_util_la-viralloc.o):/home/berrange/src/virt/libvirt/src/util/viralloc.c:87: first defined here
./.libs/libvirt_util.a(libvirt_util_la-viraudit.o):viraudit.c:(.bss+0x0): multiple definition of `virConnectAuthPtrDefault'
./.libs/libvirt_util.a(libvirt_util_la-viralloc.o):/home/berrange/src/virt/libvirt/src/util/viralloc.c:87: first defined here
./.libs/libvirt_util.a(libvirt_util_la-virauth.o):virauth.c:(.bss+0x0): multiple definition of `virConnectAuthPtrDefault'
./.libs/libvirt_util.a(libvirt_util_la-viralloc.o):/home/berrange/src/virt/libvirt/src/util/viralloc.c:87: first defined here
./.libs/libvirt_util.a(libvirt_util_la-virauthconfig.o):virauthconfig.c:(.bss+0x0): multiple definition of `virConnectAuthPtrDefault'
...snip...

The cause is our VIR_EXPORT_VAR macro which has some
magic on win to add dllexport/dllimport to the variable
declaration. Unfortunately the dllexport branch missed
off the 'extern' keyword, so the header file was in
fact declaring an instance of the variable in every
source file.

Previously the linker would merge all these definitions
into one, but that no longer happens due to -fno-common

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agotest: update capability replies for qemu-2.7.0
Pavel Hrdina [Tue, 20 Sep 2016 08:42:18 +0000 (10:42 +0200)]
test: update capability replies for qemu-2.7.0

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agoqemu_process: fix a typo
Chen Hanxiao [Tue, 20 Sep 2016 07:37:21 +0000 (15:37 +0800)]
qemu_process: fix a typo

s/unitl/until

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
8 years agotests: fix use of fixedcontent variable
Laine Stump [Mon, 19 Sep 2016 17:44:21 +0000 (13:44 -0400)]
tests: fix use of fixedcontent variable

Commit 8563560026d192c2cf047b550ffd468692245ed6 switched from
hardcoded use of strcontent to hardcoded use of fixedcontent
(fixedcontent is *sometimes* a copy of strcontent with a \n
appended). This was a problem because sometimes fixedcontent is *not*
a copy of strcontent, but is instead NULL, leading to the regenerated
test case output being a 0 length file.

This patch creates a new const char *cmpcontent initialized to
strcontent, but changed to fixedcontent if/when fixedcontent is
created, then always uses cmpcontent instead of (str|fixed)content.

8 years agoRevert "configure: Check for major() more strictly"
Eric Blake [Thu, 15 Sep 2016 20:13:27 +0000 (15:13 -0500)]
Revert "configure: Check for major() more strictly"

This reverts commit d53fa838e18d8c192296487ff40c3a37420b6d06,
which is no longer needed now that gnulib does the job.

Signed-off-by: Eric Blake <eblake@redhat.com>
8 years agobuild: update to latest gnulib
Eric Blake [Thu, 15 Sep 2016 20:12:52 +0000 (15:12 -0500)]
build: update to latest gnulib

In particular, pull in gnulib's fix for the broken AC_HEADER_MAJOR
macro in autoconf.

Signed-off-by: Eric Blake <eblake@redhat.com>
8 years agoqemu: Introduce qemuGetHupageMemPath
Michal Privoznik [Mon, 19 Sep 2016 05:45:12 +0000 (07:45 +0200)]
qemu: Introduce qemuGetHupageMemPath

Now that we have two same implementations for getting path for
huge pages backed guest memory, lets merge them into one function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuBuildMemoryBackendStr: Don't crash if no hugetlbfs is mounted
Michal Privoznik [Sat, 17 Sep 2016 07:29:11 +0000 (09:29 +0200)]
qemuBuildMemoryBackendStr: Don't crash if no hugetlbfs is mounted

When trying to migrate a huge page enabled guest, I've noticed
the following crash. Apparently, if no specific hugepages are
requested:

  <memoryBacking>
    <hugepages/>
  </memoryBacking>

and there are no hugepages configured on the destination, we try
to dereference a NULL pointer.

Program received signal SIGSEGV, Segmentation fault.
0x00007fcc907fb20e in qemuGetHugepagePath (hugepage=0x0) at qemu/qemu_conf.c:1447
1447        if (virAsprintf(&ret, "%s/libvirt/qemu", hugepage->mnt_dir) < 0)
(gdb) bt
#0  0x00007fcc907fb20e in qemuGetHugepagePath (hugepage=0x0) at qemu/qemu_conf.c:1447
#1  0x00007fcc907fb2f5 in qemuGetDefaultHugepath (hugetlbfs=0x0, nhugetlbfs=0) at qemu/qemu_conf.c:1466
#2  0x00007fcc907b4afa in qemuBuildMemoryBackendStr (size=4194304, pagesize=0, guestNode=0, userNodeset=0x0, autoNodeset=0x0, def=0x7fcc70019070, qemuCaps=0x7fcc70004000, cfg=0x7fcc5c011800, backendType=0x7fcc95087228, backendProps=0x7fcc95087218,
    force=false) at qemu/qemu_command.c:3297
#3  0x00007fcc907b4f91 in qemuBuildMemoryCellBackendStr (def=0x7fcc70019070, qemuCaps=0x7fcc70004000, cfg=0x7fcc5c011800, cell=0, auto_nodeset=0x0, backendStr=0x7fcc70020360) at qemu/qemu_command.c:3413
#4  0x00007fcc907c0406 in qemuBuildNumaArgStr (cfg=0x7fcc5c011800, def=0x7fcc70019070, cmd=0x7fcc700040c0, qemuCaps=0x7fcc70004000, auto_nodeset=0x0) at qemu/qemu_command.c:7470
#5  0x00007fcc907c5fdf in qemuBuildCommandLine (driver=0x7fcc5c07b8a0, logManager=0x7fcc70003c00, def=0x7fcc70019070, monitor_chr=0x7fcc70004bb0, monitor_json=true, qemuCaps=0x7fcc70004000, migrateURI=0x7fcc700199c0 "defer", snapshot=0x0,
    vmop=VIR_NETDEV_VPORT_PROFILE_OP_MIGRATE_IN_START, standalone=false, enableFips=false, nodeset=0x0, nnicindexes=0x7fcc95087498, nicindexes=0x7fcc950874a0, domainLibDir=0x7fcc700047c0 "/var/lib/libvirt/qemu/domain-1-fedora") at qemu/qemu_command.c:9547

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu_agent|monitor: use different log on hangup event
Chen Hanxiao [Mon, 19 Sep 2016 06:24:50 +0000 (14:24 +0800)]
qemu_agent|monitor: use different log on hangup event

Both qemu monitor and agent print the same
log on HUANGUP event, which would be confusing
when reading libvirtd log.

This patch will give a different log message to them.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
8 years agodocs: expand docs on user x509 cert locations
Daniel P. Berrange [Thu, 15 Sep 2016 13:47:59 +0000 (14:47 +0100)]
docs: expand docs on user x509 cert locations

The layout in $HOME/.pki is different from that in /etc/pki
but we never tell anyone about this trap. Add docs showing
the required $HOME/.pki layout.

8 years agoconf: Allow copying of shmem defs
Martin Kletzander [Thu, 15 Sep 2016 15:14:31 +0000 (17:14 +0200)]
conf: Allow copying of shmem defs

This way we'll be able to hotplug with both --live and --config in one
API call.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoschema: Allow shmem to have alias
Martin Kletzander [Thu, 15 Sep 2016 08:33:06 +0000 (10:33 +0200)]
schema: Allow shmem to have alias

It already is used and tests will be automatically added in later patches.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemuhotplugtest: Only read result_filename if used
Martin Kletzander [Thu, 15 Sep 2016 08:58:17 +0000 (10:58 +0200)]
qemuhotplugtest: Only read result_filename if used

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: map "virtio" video model to "virt" machtype correctly (arm/aarch64)
Laszlo Ersek [Fri, 16 Sep 2016 07:30:23 +0000 (09:30 +0200)]
qemu: map "virtio" video model to "virt" machtype correctly (arm/aarch64)

Most of QEMU's PCI display device models, such as:

  libvirt video/model/@type  QEMU -device
  -------------------------  ------------
  cirrus                     cirrus-vga
  vga                        VGA
  qxl                        qxl-vga
  virtio                     virtio-vga

come with a linear framebuffer (sometimes called "VGA compatibility
framebuffer"). This linear framebuffer lives in one of the PCI device's
MMIO BARs, and allows guest code (primarily: firmware drivers, and
non-accelerated OS drivers) to display graphics with direct memory access.

Due to architectural reasons on aarch64/KVM hosts, this kind of
framebuffer doesn't / can't work in

  qemu-system-(arm|aarch64) -M virt

machines. Cache coherency issues guarantee a corrupted / unusable display.
The problem has been researched by several people, including kvm-arm
maintainers, and it's been decided that the best way (practically the only
way) to have boot time graphics for such guests is to consolidate on
QEMU's "virtio-gpu-pci" device.

>From <https://bugzilla.redhat.com/show_bug.cgi?id=1195176>, libvirt
supports

  <devices>
    <video>
      <model type='virtio'/>
    </video>
  </devices>

but libvirt unconditionally maps @type='virtio' to QEMU's "virtio-vga"
device model. (See the qemuBuildDeviceVideoStr() function and the
"qemuDeviceVideo" enum impl.)

According to the above, this is not right for the "virt" machine type; the
qemu-system-(arm|aarch64) binaries don't even recognize the "virtio-vga"
device model (justifiedly). Whereas "virtio-gpu-pci", which is a pure
virtio device without a compatibility framebuffer, is available, and works
fine.

(The ArmVirtQemu ("AAVMF") platform of edk2 -- that is, the UEFI firmware
for "virt" -- supports "virtio-gpu-pci", as of upstream commit
3ef3209d3028. See
<https://tianocore.acgmultimedia.com/show_bug.cgi?id=66>.)

Override the default mapping of "virtio", from "virtio-vga" to
"virtio-gpu-pci", if qemuDomainMachineIsVirt() evaluates to true.

Cc: Andrea Bolognani <abologna@redhat.com>
Cc: Drew Jones <drjones@redhat.com>
Cc: Marc-André Lureau <marcandre.lureau@redhat.com>
Cc: Martin Kletzander <mkletzan@redhat.com>
Suggested-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1372901
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoutil: Expose virHostCPUStatsAssign on non-Linux
Martin Kletzander [Fri, 16 Sep 2016 06:33:47 +0000 (08:33 +0200)]
util: Expose virHostCPUStatsAssign on non-Linux

There is nothing Linux-specific in that function.  Also since commit
8c3b5bf48123783b812b97360db7ac51f1889e17 mingw build is broken due to
the fact that this function is not compiled in the library.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agotest driver: Implement testNodeGetFreePages.
Tomáš Ryšavý [Thu, 15 Sep 2016 08:27:09 +0000 (10:27 +0200)]
test driver: Implement testNodeGetFreePages.

Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
8 years agotest driver: added pages sizes into XML into test driver.
Tomáš Ryšavý [Thu, 15 Sep 2016 08:27:08 +0000 (10:27 +0200)]
test driver: added pages sizes into XML into test driver.

Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
8 years agotest driver: Implement testNodeGetFreeMemory
Tomáš Ryšavý [Thu, 15 Sep 2016 08:27:07 +0000 (10:27 +0200)]
test driver: Implement testNodeGetFreeMemory

Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agotest driver: Implement testNodeGetCPUStats
Tomáš Ryšavý [Thu, 15 Sep 2016 08:27:06 +0000 (10:27 +0200)]
test driver: Implement testNodeGetCPUStats

Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agotest driver: Implement virConnectGetType.
Tomáš Ryšavý [Thu, 15 Sep 2016 08:27:05 +0000 (10:27 +0200)]
test driver: Implement virConnectGetType.

Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agotest driver: Implement virConnectGetSysinfo.
Tomáš Ryšavý [Thu, 15 Sep 2016 08:27:04 +0000 (10:27 +0200)]
test driver: Implement virConnectGetSysinfo.

Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agotest_driver: Replace magic constant
Tomáš Ryšavý [Thu, 15 Sep 2016 08:27:03 +0000 (10:27 +0200)]
test_driver: Replace magic constant

In testOpenDefault we create a virtual computer that is later
presented to user. We also pretend to have NUMA cells and
initialize them somehow. But whilst doing so a magical constant
is used. Drop it.

Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirhostcpu: Expose virHostCPUStatsAssign
Tomáš Ryšavý [Thu, 15 Sep 2016 08:27:02 +0000 (10:27 +0200)]
virhostcpu: Expose virHostCPUStatsAssign

We will need this function shortly when implementing
nodeGetCPUStats in the test driver.

Signed-off-by: Tomáš Ryšavý <tom.rysavy.0@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirsh: use virConnectGetDomainCapabilities with maxvcpus
Shivaprasad G Bhat [Wed, 7 Sep 2016 08:55:42 +0000 (14:25 +0530)]
virsh: use virConnectGetDomainCapabilities with maxvcpus

virsh maxvcpus --type kvm output is useless on PPC. Also, in
commit e6806d79 we documented not rely on virConnectGetMaxVcpus
output. Fix the  maxvcpus to use virConnectGetDomainCapabilities
now to make it useful. The call is made to use the default emulator
binary and to check for the host machine and arch which is what the
command intends to show anyway.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
8 years agotests: Use fixedcontent variable
Martin Kletzander [Tue, 13 Sep 2016 10:49:56 +0000 (12:49 +0200)]
tests: Use fixedcontent variable

Commit ca32929908bbc94116493ad8915e7cd7ae0f57d5 added function
virTestCompareToFile(), but forgot to use a fixedcontent value for the
actual comparison.  That lead to VIR_TEST_DEBUG=1 showing (for some
tests) all the actual output from the first error to the end of the
string due to the difference being an endline in the end.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agohyperv: additional server 2008 wmi classes
Jason Miesionczek [Tue, 9 Aug 2016 12:39:09 +0000 (12:39 +0000)]
hyperv: additional server 2008 wmi classes

8 years agotests: Self test virt-admin
Michal Privoznik [Wed, 14 Sep 2016 08:08:48 +0000 (10:08 +0200)]
tests: Self test virt-admin

Just like we are running 'virsh self-test' from within our test
suite, we should run 'virt-admin self-test' too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirsh: Move cmdSelfTest to vsh
Michal Privoznik [Wed, 14 Sep 2016 07:50:22 +0000 (09:50 +0200)]
virsh: Move cmdSelfTest to vsh

This command should be exposed to other shells of ours.
They are gonna need it as soon as we want to test them too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: domain: Don't infer vcpu state
Peter Krempa [Tue, 13 Sep 2016 15:56:08 +0000 (17:56 +0200)]
qemu: domain: Don't infer vcpu state

Use the state information (online, hotpluggable) provided by the monitor
code rather than trying to infer it. This fixes an issue where on
architectures that require hotplug of multiple threads at once the
sub-cores would get updated as offline on daemon restart thus creating
an invalid configuration.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1375783

8 years agoqemu: monitor: Add vcpu state information to monitor data
Peter Krempa [Tue, 13 Sep 2016 15:52:38 +0000 (17:52 +0200)]
qemu: monitor: Add vcpu state information to monitor data

Return whether a vcpu entry is hotpluggable or online so that upper
layers don't have to infer the information from other data.

Advantage is that this code can be tested by unit tests.

8 years agoqemu: monitor: qemuMonitorGetCPUInfoHotplug: Add iterator 'anycpu'
Peter Krempa [Tue, 13 Sep 2016 15:38:08 +0000 (17:38 +0200)]
qemu: monitor: qemuMonitorGetCPUInfoHotplug: Add iterator 'anycpu'

Add separate iterator for iterating all the entries

8 years agoqemu: monitor: Use a more obvious iterator name
Peter Krempa [Tue, 13 Sep 2016 15:28:02 +0000 (17:28 +0200)]
qemu: monitor: Use a more obvious iterator name

The algorithm that matches data from query-cpus and
query-hotpluggable-cpus is quite complex. Start using descriptive
iterator names to avoid confusion.

8 years agovirDomainGetBlockJobInfo: Fix corner case when qemu reports no info
Michal Privoznik [Fri, 2 Sep 2016 07:45:44 +0000 (09:45 +0200)]
virDomainGetBlockJobInfo: Fix corner case when qemu reports no info

https://bugzilla.redhat.com/show_bug.cgi?id=1372613

Apparently, some management applications use the following code
pattern when waiting for a block job to finish:

  while (1) {
    virDomainGetBlockJobInfo(dom, disk, info, flags);

    if (info.cur == info.end)
        break;

    sleep(1);
  }

Problem with this approach is in its corner cases. In case of
QEMU, libvirt merely pass what has been reported on the monitor.
However, if the block job hasn't started yet, qemu reports cur ==
end == 0 which tricks mgmt apps into thinking job is complete.

The solution is to mangle cur/end values as described here [1].

1: https://www.redhat.com/archives/libvir-list/2016-September/msg00017.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuDomainGetBlockJobInfo: Move info translation into separate func
Michal Privoznik [Fri, 2 Sep 2016 06:38:19 +0000 (08:38 +0200)]
qemuDomainGetBlockJobInfo: Move info translation into separate func

Even though we merely just pass to users whatever qemu provided
on the monitor, we still do some translation. For instance we
turn bytes into mebibytes, or fix job type if needed. However, in
the future there is more fixing to be done so this code deserves
its own function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agotests: use a fixed chardev TLS path
Daniel P. Berrange [Wed, 14 Sep 2016 09:44:44 +0000 (10:44 +0100)]
tests: use a fixed chardev TLS path

The test qemuxml2argv-serial-tcp-tlsx509-chardev.args
will fail if libvirt is built with a --sysconfdir
arg that is not /etc.  Fix this by setting a hardcoded
path in the test code.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agonuma: Rename virNumaGetHostNodeset and make it return only nodes with memory
Peter Krempa [Tue, 13 Sep 2016 13:55:06 +0000 (15:55 +0200)]
numa: Rename virNumaGetHostNodeset and make it return only nodes with memory

Name it virNumaGetHostMemoryNodeset and return only NUMA nodes which
have memory installed. This is necessary as the kernel is not very happy
to set the memory cgroup setting for nodes which do not have any memory.

This would break vcpu hotplug with following message on such
configruation:

  Invalid value '0,8' for 'cpuset.mems': Invalid argument

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1375268

8 years agoutil: numa: Remove impossible error handling
Peter Krempa [Tue, 13 Sep 2016 12:28:33 +0000 (14:28 +0200)]
util: numa: Remove impossible error handling

The code guarantees that virBitmapSetBit won't be called with out of
range values. Just ignore the return value and remove dead error
handling.

8 years agoconfigure: Check for major() more strictly
Michal Privoznik [Tue, 13 Sep 2016 14:23:05 +0000 (16:23 +0200)]
configure: Check for major() more strictly

Thing is, in f3f15cc24 I'm trying to adapt libvirt to the newest
glibc where major()/minor()/makedev() are moved from sys/types.h
to sys/sysmacros.h. However, my commit back then expect autoconf
to be fixed too as we already use AC_HEADER_MAJOR to determine
which header file the functions are in, but because the header
files just trigger a warning and not a compile error, the
autoconf macro detects the bad header file.

This is just a workaround until autoconf macro is fixed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agotests: fix incorrect status handling by virsh-self-test
Erik Skultety [Thu, 8 Sep 2016 13:28:07 +0000 (15:28 +0200)]
tests: fix incorrect status handling by virsh-self-test

The virsh-self-test script compared the test's return code with 1 and only if
the return code matched this value then the test was marked as failed. Problem
is that SIGSEGV returns 139 (or 11 to be precise, since shell reserves the MSB
for abnormal exit signaling) which passes the check just fine and test then
appears as successful which it most certainly wasn't.
Therefore, flip the logic to compare against 0 instead and every other result
will be treated as a failed test case.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoqemu: Add missing 'p' to qemuCgrouEmulatorAllNodesRestore
Peter Krempa [Tue, 13 Sep 2016 10:24:02 +0000 (12:24 +0200)]
qemu: Add missing 'p' to qemuCgrouEmulatorAllNodesRestore

8 years agovirsh: add --keep-nvram option to undefine command
Nikolay Shirokovskiy [Fri, 27 May 2016 08:05:16 +0000 (11:05 +0300)]
virsh: add --keep-nvram option to undefine command

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agoqemu: add VIR_DOMAIN_UNDEFINE_KEEP_NVRAM support
Nikolay Shirokovskiy [Fri, 27 May 2016 08:05:15 +0000 (11:05 +0300)]
qemu: add VIR_DOMAIN_UNDEFINE_KEEP_NVRAM support

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agoapi: add VIR_DOMAIN_UNDEFINE_KEEP_NVRAM flag
Nikolay Shirokovskiy [Fri, 27 May 2016 08:05:14 +0000 (11:05 +0300)]
api: add VIR_DOMAIN_UNDEFINE_KEEP_NVRAM flag

This flags specifies to keep nvram file if it is existed for inactive
domains.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agoconf: allow hotplugging "legacy PCI" device to manually addressed PCIe slot
Laine Stump [Fri, 9 Sep 2016 19:26:34 +0000 (15:26 -0400)]
conf: allow hotplugging "legacy PCI" device to manually addressed PCIe slot

In a full domain config, libvirt allows overriding the normal PCI
vs. PCI Express rules when a device address is explicitly provided
(so, e.g., you can force a legacy PCI device to plug into a PCIe port,
although libvirt would never do that on its own). However, due to a
bug libvirt doesn't give this same leeway when hotplugging devices. On
top of that, current libvirt assumes that *all* devices are legacy
PCI. The result of all this is that it's impossible to hotplug a
device into a PCIe port, even if you manually add the PCI address.

This can all be traced to the function
virDomainPCIAddressEnsureAddr(), and the fact that it calls
virDomainPCIaddressReserveSlot() for manually set addresses, and that
function hardcodes the argument "fromConfig" to false (meaning "this
address was auto-assigned, so it should be subject to stricter
validation").

Since virDomainPCIAddressReserveSlot() is just a one line simple
wrapper around virDomainPCIAddressReserveAddr() (adding in a hardcoded
reserveEntireSlot = true and fromConfig = false), all that's needed to
solve the problem with no unwanted side effects is to replace that
call for virDomainPCIAddressReserveSlot() with a direct call to
virDomainPCIAddressReserveAddr(), but with reserveEntireSlot = true,
fromConfig = true. That's what this patch does.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1337490

8 years agoqemu: fix improper initialization of cgroupControllers bitmap
Laine Stump [Mon, 12 Sep 2016 17:21:10 +0000 (13:21 -0400)]
qemu: fix improper initialization of cgroupControllers bitmap

virQEMUDriverConfigNew() always initializes the bitmap in its
cgroupControllers member to -1 (i.e. all 1's).

Prior to commit a9331394, if qemu.conf had a line with
"cgroup_controllers", cgroupControllers would get reset to 0 before
going through a loop setting a bit for each named cgroup controller.
commit a9331394 left out the "reset to 0" part, so cgroupControllers
would always be -1; if you didn't want a controller included, there
was no longer a way to make that happen.

This was discovered by users who were using qemu commandline
passthrough to use the "input-linux" method of directing
keyboard/mouse input to a virtual machine:

 https://www.redhat.com/archives/vfio-users/2016-April/msg00105.html

Here's the first report I found of the problem encountered after
upgrading libvirt beyond v2.0.0:

 https://www.redhat.com/archives/vfio-users/2016-August/msg00053.html

Thanks to sL1pKn07 SpinFlo <sl1pkn07@gmail.com> for bringing the
problem up in IRC, and then taking the time to do a git bisect and
find the patch that started the problem.

8 years agoaudit: Audit information about shmem devices
Martin Kletzander [Thu, 11 Aug 2016 09:40:18 +0000 (11:40 +0200)]
audit: Audit information about shmem devices

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1218603

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoqemu: avoid parameter named 'listen'
Daniel P. Berrange [Mon, 12 Sep 2016 14:49:28 +0000 (15:49 +0100)]
qemu: avoid parameter named 'listen'

previous commit:

  commit 2c3223785c121eafbdd503f11549d7964461934f
  Author: John Ferlan <jferlan@redhat.com>
  Date:   Mon Jun 13 12:30:34 2016 -0400

    qemu: Add the ability to hotplug the TLS X.509 environment

added a parameter "bool listen" in some methods. This
unfortunately clashes with the listen() method, causing
compile failures on certain platforms (RHEL-6 for example)

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agostorage: Need to properly read the crypt offset value
John Ferlan [Tue, 6 Sep 2016 21:00:30 +0000 (17:00 -0400)]
storage: Need to properly read the crypt offset value

Commit id 'a48c7141' altered how to determine if a volume was encrypted
by adding a peek at an offset into the file at a specific buffer location.
Unfortunately, all that was compared was the first "char" of the buffer
against the expect "int" value.

Restore the virReadBufInt32BE to get the complete field in order to
compare against the expected value from the qcow2EncryptionInfo or
qcow1EncryptionInfo "modeValue" field.

This restores the capability to create a volume with encryption, then
refresh the pool, and still find the encryption for the volume.

8 years agostorage: Need to refresh secret for luks volume after volume refresh
John Ferlan [Tue, 6 Sep 2016 20:52:36 +0000 (16:52 -0400)]
storage: Need to refresh secret for luks volume after volume refresh

A LUKS volume uses the volume secret type just like the QCOW2 secret, so
adjust the loading of the default secrets to handle any volume that the
virStorageFileGetMetadataFromBuf code has deemed to be an encrypted volume
to search for the volume's secret. This lookup is done by volume usage
where the usage is expected to be the path to volume.

8 years agolog: Fix reporting OOM error incorrectly when defining a logging filter
Nikolay Shirokovskiy [Mon, 12 Sep 2016 10:56:29 +0000 (13:56 +0300)]
log: Fix reporting OOM error incorrectly when defining a logging filter

When a new filter is being defined, the return code is not handled properly,
thus triggering OOM error reporting routine (bug introduced by 51b2606f).

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoqemu: Don't use query-migrate on destination
Jiri Denemark [Mon, 12 Sep 2016 08:24:21 +0000 (10:24 +0200)]
qemu: Don't use query-migrate on destination

When migration fails, we need to poke QEMU monitor to check for a reason
of the failure. We did this using query-migrate QMP command, which is
not supposed to return any meaningful result on the destination side.
Thus if the monitor was still functional when we detected the migration
failure, parsing the answer from query-migrate always failed with the
following error message:

    "info migration reply was missing return status"

This irrelevant message was then used as the reason for the migration
failure replacing any message we might have had.

Let's use harmless query-status for poking the monitor to make sure we
only get an error if the monitor connection is broken.

https://bugzilla.redhat.com/show_bug.cgi?id=1374613

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoutil: Quiet the logging if perf file doesn't exist
John Ferlan [Tue, 6 Sep 2016 21:20:30 +0000 (17:20 -0400)]
util: Quiet the logging if perf file doesn't exist

Commit id 'b00d7f29' shifted the opening of the /sys/devices/intel_cqm/type
file from event enable to perf event initialization. If the file did not
exist, then an error would be written to the domain log:

2016-09-06 20:51:21.677+0000: 7310: error : virFileReadAll:1360 : Failed to open file '/sys/devices/intel_cqm/type': No such file or directory

Since the error is now handled in virPerfEventEnable by checking if the
event_attr->attrType == 0 for CMT, MBML, and MBMT events - we can just
use the Quiet API in order to not log the error we're going to throw away.

Additionally, rather than using virReportSystemError, use virReportError
and VIR_ERR_ARGUMENT_UNSUPPORTED in order to signify that support isn't there
for that type of perf event - adjust the error message as well.

8 years agolibxl: implement virConnectBaselineCPU
Joao Martins [Wed, 20 Jul 2016 19:08:49 +0000 (20:08 +0100)]
libxl: implement virConnectBaselineCPU

Akin to previous commit but for "virsh cpu-baseline" which
computes a baseline CPU for a set of host cpu elements.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agolibxl: implement virConnectCompareCPU
Joao Martins [Wed, 20 Jul 2016 19:08:48 +0000 (20:08 +0100)]
libxl: implement virConnectCompareCPU

Implement support for "virsh cpu-compare" so that we can calculate
common cpu element between a pool of hosts, which had a requirement
of providing host cpu description.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agolibxl: describe host cpu features based on hwcaps
Joao Martins [Wed, 20 Jul 2016 19:08:47 +0000 (20:08 +0100)]
libxl: describe host cpu features based on hwcaps

Parse libxl_hwcap accounting for versions since Xen 4.4 - Xen 4.7.
libxl_hwcaps is a set of cpuid leaves output that is described in [0] or
[1] in Xen 4.7. This is a collection of CPUID leaves that we version
in libvirt whenever feature words are reordered or added. Thus we keep the
common ones in one struct and others for each version. Since
libxl_hwcaps doesn't appear to have a stable format across all supported
versions thus we need to keep track of changes as a compromise until it's
exported in xen libxl API. We don't fail in initializing the driver in case
parsing of hwcaps failed for that reason. In addition, change the notation
on PAE feature such that is easier to read which bit it corresponds.

[0] xen/include/asm-x86/cpufeature.h
[1] xen/include/public/arch-x86/cpufeatureset.h

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
8 years agolibxl: describe host topology in capabilities
Joao Martins [Wed, 20 Jul 2016 19:08:46 +0000 (20:08 +0100)]
libxl: describe host topology in capabilities

Add support for describing cpu topology in host cpu element.  In doing
so, refactor hwcaps part to its own helper namely libxlCapsInitCPU to
handle all host cpu related operations, including topology.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
8 years agoqemu: hotplug: Don't wait if cdrom tray is opened forcibly
Peter Krempa [Mon, 5 Sep 2016 16:12:00 +0000 (18:12 +0200)]
qemu: hotplug: Don't wait if cdrom tray is opened forcibly

Qemu always opens the tray if forced to. Skip the waiting step in such
case.

This also helps if qemu does not report the tray change event when
opening the cdrom forcibly (the documentation says that the event will
not be sent although qemu in fact does trigger it even if @force is
selceted).

This is a workaround for a qemu issue where qemu does not send the tray
change event in some cases (after migration with empty closed locked
drive) and thus renders the cdrom useless from libvirt's point of view.

Partially resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1368368

8 years agoqemu: domain: Clear startup policy for dropped removable media
Peter Krempa [Mon, 5 Sep 2016 13:50:18 +0000 (15:50 +0200)]
qemu: domain: Clear startup policy for dropped removable media

When a source image is dropped when missing due to startup policy the
policy needs to be cleared since it was relevant only for the given
storage source. New sources need to update it if needed.

8 years agoqemu: Implement virtio-net rx_queue_size
Michal Privoznik [Fri, 19 Aug 2016 07:50:31 +0000 (09:50 +0200)]
qemu: Implement virtio-net rx_queue_size

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu_capabilities: Introduce virtio-net-*.rx_queue_size
Michal Privoznik [Fri, 19 Aug 2016 06:39:08 +0000 (08:39 +0200)]
qemu_capabilities: Introduce virtio-net-*.rx_queue_size

Just like in the previous commit, teach qemu driver to detect
whether qemu supports this configuration knob or not.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoconf: Add support for virtio-net.rx_queue_size
Michal Privoznik [Thu, 18 Aug 2016 16:19:13 +0000 (18:19 +0200)]
conf: Add support for virtio-net.rx_queue_size

https://bugzilla.redhat.com/show_bug.cgi?id=1366989

QEMU added another virtio-net tunable [1]. It basically allows
users to set the size of RX virtio ring. But because virtio-net
uses two separate ring buffers to pass data from/to guest they
named it explicitly rx_queue_size. We should expose it in our XML
too.

1: http://lists.nongnu.org/archive/html/qemu-devel/2016-08/msg02029.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoconf: Add new secret type "tls"
John Ferlan [Thu, 14 Jul 2016 19:09:08 +0000 (15:09 -0400)]
conf: Add new secret type "tls"

Add a new secret usage type known as "tls" - it will handle adding the
secret objects for various TLS objects that need to provide some sort
of passphrase in order to access the credentials.

The format is:

   <secret ephemeral='no' private='no'>
     <description>Sample TLS secret</description>
     <usage type='tls'>
       <name>mumblyfratz</name>
     </usage>
</secret>

Once defined and a passphrase set, future patches will allow the UUID
to be set in the qemu.conf file and thus used as a secret for various
TLS options such as a chardev serial TCP connection, a NBD client/server
connection, and migration.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Add the ability to hotplug the TLS X.509 environment
John Ferlan [Mon, 13 Jun 2016 16:30:34 +0000 (12:30 -0400)]
qemu: Add the ability to hotplug the TLS X.509 environment

If the incoming XML defined a path to a TLS X.509 certificate environment,
add the necessary 'tls-creds-x509' object to the VIR_DOMAIN_CHR_TYPE_TCP
character device.

Likewise, if the environment exists the hot unplug needs adjustment as
well.  Note that all the return ret were changed to goto cleanup since
the cfg needs to be unref'd

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Add support for TLS X.509 path to TCP chardev backend
John Ferlan [Thu, 9 Jun 2016 22:30:55 +0000 (18:30 -0400)]
qemu: Add support for TLS X.509 path to TCP chardev backend

When building a chardev device string for tcp, add the necessary pieces to
access provide the TLS X.509 path to qemu.  This includes generating the
'tls-creds-x509' object and then adding the 'tls-creds' parameter to the
VIR_DOMAIN_CHR_TYPE_TCP command line.

Finally add the tests for the qemu command line. This test will make use
of the "new(ish)" /etc/pki/qemu setting for a TLS certificate environment
by *not* "resetting" the chardevTLSx509certdir prior to running the test.
Also use the default "verify" option (which is "no").

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Introduce chartcp_tls_x509_cert_dir
John Ferlan [Tue, 14 Jun 2016 19:52:37 +0000 (15:52 -0400)]
conf: Introduce chartcp_tls_x509_cert_dir

Add a new TLS X.509 certificate type - "chardev". This will handle the
creation of a TLS certificate capability (and possibly repository) for
properly configured character device TCP backends.

Unlike the vnc and spice there is no "listen" or "passwd" associated. The
credentials eventually will be handled via a libvirt secret provided to
a specific backend.

Make use of the default verify option as well.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoconf: Add new default TLS X.509 certificate default directory
John Ferlan [Tue, 14 Jun 2016 18:14:31 +0000 (14:14 -0400)]
conf: Add new default TLS X.509 certificate default directory

Rather than specify perhaps multiple TLS X.509 certificate directories,
let's create a "default" directory which can then be used if the service
(e.g. for now vnc and spice) does not supply a default directory.

Since the default for vnc and spice may have existed before without being
supplied, the default check will first check if the service specific path
exists and if so, set the cfg entry to that; otherwise, the default will
be set to the (now) new defaultTLSx509certdir.

Additionally add a "default_tls_x509_verify" entry which can also be used
to force the peer verification option (for vnc it's a x509verify option).
Add/alter the macro for the option being found in the config file to accept
the default value.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Remove stale transient def when migration fails
Jiri Denemark [Thu, 8 Sep 2016 13:22:28 +0000 (15:22 +0200)]
qemu: Remove stale transient def when migration fails

If a migration of a domain which is already defined on the destination
host failed early (before we tried to start QEMU), we would forget to
remove the incoming transient definition. Later on when someone starts
the domain on the destination host, we will use the stale incoming
definition and the persistent definition will just be ignored.

https://bugzilla.redhat.com/show_bug.cgi?id=1368774

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoAdd helper for removing transient definition
Jiri Denemark [Thu, 8 Sep 2016 13:16:58 +0000 (15:16 +0200)]
Add helper for removing transient definition

The code for replacing domain's transient definition with the persistent
one is repeated in several places and we'll need to add one more. Let's
make a nice helper for it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agovirt-admin: Fix some English grammar in the manpage
Erik Skultety [Thu, 8 Sep 2016 08:45:28 +0000 (10:45 +0200)]
virt-admin: Fix some English grammar in the manpage

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovirt-admin: Document srv-list command in virt-admin's man page
Erik Skultety [Wed, 7 Sep 2016 11:42:06 +0000 (13:42 +0200)]
virt-admin: Document srv-list command in virt-admin's man page

srv-list command was missing in the man page.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovirsh: Fix *-event error string
Christophe Fergeau [Tue, 6 Sep 2016 11:14:34 +0000 (13:14 +0200)]
virsh: Fix *-event error string

When using
virsh net-event non-existing-net
the error message says that 'either --list or event type is required'
This is misleading as 'virsh net-event $valid-event-type' is not going
to work either. What is expected is 'virsh net-event --event
$valid-event-type'

This commit fixes the string in pool-event, nodedev-event, event, and
net-event.

8 years agosecurity: Fixing wrong label in virt-aa-helper.c.
Julio Faracco [Wed, 7 Sep 2016 21:43:53 +0000 (18:43 -0300)]
security: Fixing wrong label in virt-aa-helper.c.

There is an issue with a wrong label inside vah_add_path().
The compilation fails with the error:
make[3]: Entering directory '/tmp/libvirt/src'
  CC       security/virt_aa_helper-virt-aa-helper.o
security/virt-aa-helper.c: In function 'vah_add_path':
security/virt-aa-helper.c:769:9: error: label 'clean' used but not defined
         goto clean;

This patch moves 'clean' label to 'cleanup' label.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
8 years agoAvoid segfault in virt-aa-helper when handling read-only filesystems
Rufo Dogav [Wed, 24 Aug 2016 23:15:29 +0000 (00:15 +0100)]
Avoid segfault in virt-aa-helper when handling read-only filesystems

This patch fixes a segfault in virt-aa-helper caused by attempting to
modify a static string literal. It is triggered when a domain has a
<filesystem> with type='mount' configured read-only and libvirt is
using the AppArmor security driver for sVirt confinement. An "R" is
passed into the function and converted to 'r'.

8 years agostorage: Delete extra wrap after vol-resize error
Yanqiu Zhang [Thu, 25 Aug 2016 02:49:55 +0000 (10:49 +0800)]
storage: Delete extra wrap after vol-resize error

This patch is to delete the extra wrap "\n" after failed vol-resize
error for both "Failed to change size of volume to" and "Failed to change
size of volume by". For error with wrap, there will be an extra wrap
between two errors, such as:

   (1)# virsh vol-resize --pool default --vol vol-test 5M
        error: Failed to change size of volume 'vol-test' to 5M

        error: invalid argument: Can't shrink capacity below current capacity unless shrink flag explicitly specified

   (2)# virsh vol-resize /var/lib/libvirt/images/volds --shrink --delta 10M
        error: Failed to change size of volume 'volds' by 10M

        error: invalid argument: can't shrink capacity below existing allocation

8 years agoqemu: driver: Remove unnecessary condition
Peter Krempa [Wed, 7 Sep 2016 11:59:25 +0000 (13:59 +0200)]
qemu: driver: Remove unnecessary condition

At this point it's guaranteed that 'persistentDef' is non-NULL so we
don't need to check it again.

8 years agoqemu: process: Fix start with unpluggable vcpus with NUMA pinning
Peter Krempa [Wed, 7 Sep 2016 11:20:00 +0000 (13:20 +0200)]
qemu: process: Fix start with unpluggable vcpus with NUMA pinning

Similarly to vcpu hotplug the emulator thread cgroup numa mapping needs
to be relaxed while hot-adding vcpus so that the threads can allocate
data in the DMA zone.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1370084

8 years agoqemu: cgroup: Extract temporary relaxing of cgroup setting for vcpu hotplug
Peter Krempa [Wed, 7 Sep 2016 11:11:59 +0000 (13:11 +0200)]
qemu: cgroup: Extract temporary relaxing of cgroup setting for vcpu hotplug

When hot-adding vcpus qemu needs to allocate some structures in the DMA
zone which may be outside of the numa pinning. Extract the code doing
this in a set of helpers so that it can be reused.

8 years agovirt-admin: Output srv-clients-set data as unsigned int rather than signed
Erik Skultety [Mon, 5 Sep 2016 11:51:21 +0000 (13:51 +0200)]
virt-admin: Output srv-clients-set data as unsigned int rather than signed

Unfortunately, commit a8962f70 only fixed first half of the reported issue of
virt-admin outputting negative values where unsigned int is expected by
BZ below, so this commit represents the other missing half of the fix.

resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1356769

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoutil: fix crash in virClassIsDerivedFrom for CloseCallbacks objects
Maxim Nestratov [Mon, 6 Jun 2016 14:42:16 +0000 (17:42 +0300)]
util: fix crash in virClassIsDerivedFrom for CloseCallbacks objects

There is a possibility that qemu driver frees by unreferencing its
closeCallbacks pointer as it has the only reference to the object,
while in fact not all users of CloseCallbacks called thier
virCloseCallbacksUnset.

Backtrace is the following:
Thread #1:
0  in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
1  in virCondWait (c=<optimized out>, m=<optimized out>)
    at util/virthread.c:154
2  in virThreadPoolFree (pool=0x7f0810110b50)
    at util/virthreadpool.c:266
3  in qemuStateCleanup () at qemu/qemu_driver.c:1116
4  in virStateCleanup () at libvirt.c:808
5  in main (argc=<optimized out>, argv=<optimized out>)
    at libvirtd.c:1660

Thread #2:
0  in virClassIsDerivedFrom (klass=0xdeadbeef, parent=0x7f0837c694d0) at util/virobject.c:169
1  in virObjectIsClass (anyobj=anyobj@entry=0x7f08101d4760, klass=<optimized out>) at util/virobject.c:365
2  in virObjectLock (anyobj=0x7f08101d4760) at util/virobject.c:317
3  in virCloseCallbacksUnset (closeCallbacks=0x7f08101d4760, vm=vm@entry=0x7f08101d47b0, cb=cb@entry=0x7f081d078fc0 <qemuProcessAutoDestroy>) at util/virclosecallbacks.c:163
4  in qemuProcessAutoDestroyRemove (driver=driver@entry=0x7f081018be50, vm=vm@entry=0x7f08101d47b0) at qemu/qemu_process.c:6368
5  in qemuProcessStop (driver=driver@entry=0x7f081018be50, vm=vm@entry=0x7f08101d47b0, reason=reason@entry=VIR_DOMAIN_SHUTOFF_SHUTDOWN, asyncJob=asyncJob@entry=QEMU_ASYNC_JOB_NONE, flags=flags@entry=0) at qemu/qemu_process.c:5854
6  in processMonitorEOFEvent (vm=0x7f08101d47b0, driver=0x7f081018be50) at qemu/qemu_driver.c:4585
7  qemuProcessEventHandler (data=<optimized out>, opaque=0x7f081018be50) at qemu/qemu_driver.c:4629
8  in virThreadPoolWorker (opaque=opaque@entry=0x7f0837c4f820) at util/virthreadpool.c:145
9  in virThreadHelper (data=<optimized out>) at util/virthread.c:206
10 in start_thread () from /lib64/libpthread.so.0

Let's reference CloseCallbacks object in virCloseCallbacksSet and
unreference in virCloseCallbacksUnset.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
8 years agoqemu: guest agent: introduce new error code VIR_ERR_AGENT_UNSYNCED
Yuri Pudgorodskiy [Thu, 28 Jan 2016 08:55:09 +0000 (11:55 +0300)]
qemu: guest agent: introduce new error code VIR_ERR_AGENT_UNSYNCED

A separate error code will help recognize real failures from
necessity to try again

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>