]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
7 years agotools: Provide bash autompletion file
Michal Privoznik [Thu, 2 Nov 2017 13:41:53 +0000 (14:41 +0100)]
tools: Provide bash autompletion file

The only purpose of this file is to be sourced. After that one
can use completion even for their bash:

  # virsh list --<TAB><TAB>
  --all                   --inactive ...

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agovsh: Introduce complete command
Michal Privoznik [Wed, 1 Nov 2017 14:34:14 +0000 (15:34 +0100)]
vsh: Introduce complete command

This command is going to be called from bash completion script in
the following form:

  virsh complete -- start --domain

Its only purpose is to return list of possible strings for
completion. Note that this is a 'hidden', unlisted command and
therefore there's no documentation to it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agovsh: Filter --options
Michal Privoznik [Fri, 29 Dec 2017 10:25:38 +0000 (11:25 +0100)]
vsh: Filter --options

Similarly to the previous commit, once we've presented an
--option for a command to the user it makes no sense to offer it
again. Therefore, we can prune all already specified options. For
instance, after this patch:

  virsh # migrate --verbose <TAB><TAB>

will no longer offer --verbose option.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agovsh: Prune string list returned by completer
Michal Privoznik [Thu, 28 Dec 2017 11:26:41 +0000 (12:26 +0100)]
vsh: Prune string list returned by completer

Instead of having completers prune returned string list based on
user's input we can do that right after the callback is called.
Only strings matching the prefix will be presented to the user
then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agovsh: Call vshCmdOptDef completer
Michal Privoznik [Tue, 21 Nov 2017 16:45:50 +0000 (17:45 +0100)]
vsh: Call vshCmdOptDef completer

Now that we have everything prepared we can call options'
completer again. At the same time, pass partially parsed input to
the completer callback - it will help the callbacks to narrow
down the list of returned options based on user's input. For
instance, if the completer is supposed to return list of
interfaces depending on user input it may return just those
interfaces defined for already specified domain. Of course,
completers might ignore this parameter.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agovsh: Fix vshCompleter signature
Michal Privoznik [Tue, 7 Nov 2017 09:41:00 +0000 (10:41 +0100)]
vsh: Fix vshCompleter signature

The first argument passed to this function is vshControl *.
There's no need to use void pointer.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoutil: Introduce virStringListMerge
Michal Privoznik [Sat, 25 Nov 2017 08:29:54 +0000 (09:29 +0100)]
util: Introduce virStringListMerge

For two string lists merge one into the other one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agovshCommandOpt: Allow caller avoiding assert()
Michal Privoznik [Thu, 9 Nov 2017 17:06:11 +0000 (18:06 +0100)]
vshCommandOpt: Allow caller avoiding assert()

In the future, completer callbacks will receive partially parsed
command (and thus possibly incomplete). However, we still want
them to use command options fetching APIs we already have (e.g.
vshCommandOpt*()) and at the same time don't report any errors
(nor call any asserts).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agovshReadlineParse: Use string list
Michal Privoznik [Tue, 21 Nov 2017 16:23:11 +0000 (17:23 +0100)]
vshReadlineParse: Use string list

It's better to fetch list of either commands or options just once
and then iterate over it. Moreover, it makes future completers
way simpler as they will return string lists too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agovshReadlineParse: Escape returned results if needed
Michal Privoznik [Mon, 13 Nov 2017 12:34:54 +0000 (13:34 +0100)]
vshReadlineParse: Escape returned results if needed

When returning a string that needs escaping there are two
scenarios that can happen. Firstly, user already started the
string with a quote (or double quote) in which case we don't need
to do anything - readline takes care of that. However, if they
haven't typed anything yet, we need to escape the string
ourselves.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agovshReadlineParse: Drop code duplication
Michal Privoznik [Tue, 21 Nov 2017 14:07:34 +0000 (15:07 +0100)]
vshReadlineParse: Drop code duplication

Now that we have a way of retrieving partly parsed command we
don't need duplicate code that parses the user's input.

Yes, this code removes call of opt's completer, but:
  a) current implementation is broken anyway, and
  b) it will be added back shortly

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agovshCommandStringParse: Allow retrieving partial result
Michal Privoznik [Mon, 6 Nov 2017 14:46:50 +0000 (15:46 +0100)]
vshCommandStringParse: Allow retrieving partial result

In the future, this function is going to be called from
vshReadlineParse() to provide parsed input for completer
callbacks. The idea is to allow the callbacks to provide more
specific data. For instance, for the following input:

  virsh # domifaddr --domain fedora --interface <TAB><TAB>

the --interface completer callback is going to be called. Now, it
is more user friendly if the completer offers only those
interfaces found in 'fedora' domain. But in order to do that it
needs to be able to retrieve partially parsed result.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agovshCommandParse: Don't leak @tkdata
Michal Privoznik [Mon, 13 Nov 2017 13:46:36 +0000 (14:46 +0100)]
vshCommandParse: Don't leak @tkdata

When parsing cmd line which has "--" on it, this is leaked.
Problem is, parser->getNextArg() allocates new string and stores
it into tkdata. But as soon as "--" is detected 'continue' is
issued without any free of the allocated memory.

  ==5304== 3 bytes in 1 blocks are definitely lost in loss record 1 of 782
  ==5304==    at 0x4C2AF50: malloc (vg_replace_malloc.c:299)
  ==5304==    by 0x8BB5AA9: strdup (strdup.c:42)
  ==5304==    by 0x55842CA: virStrdup (virstring.c:941)
  ==5304==    by 0x172B21: _vshStrdup (vsh.c:162)
  ==5304==    by 0x175E8E: vshCommandArgvGetArg (vsh.c:1622)
  ==5304==    by 0x17551D: vshCommandParse (vsh.c:1418)
  ==5304==    by 0x175F25: vshCommandArgvParse (vsh.c:1638)
  ==5304==    by 0x130940: virshParseArgv (virsh.c:820)
  ==5304==    by 0x130C49: main (virsh.c:922)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agovsh: Drop useless check for cmd != NULL
Michal Privoznik [Tue, 2 Jan 2018 13:33:45 +0000 (14:33 +0100)]
vsh: Drop useless check for cmd != NULL

All our internal *Free() functions are capable of handling NULL.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agovsh: Drop useless check for opts != NULL
Michal Privoznik [Fri, 29 Dec 2017 11:19:47 +0000 (12:19 +0100)]
vsh: Drop useless check for opts != NULL

All our internal *Free() functions are capable of handling NULL.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agodocs: Add missing encryption type
John Ferlan [Thu, 11 Jan 2018 15:40:37 +0000 (10:40 -0500)]
docs: Add missing encryption type

Update the text to include "luks" as a possible value.

7 years agotests: Break symlink loop
Andrea Bolognani [Thu, 11 Jan 2018 13:18:59 +0000 (14:18 +0100)]
tests: Break symlink loop

distcheck, and possibly more stuff, breaks because of it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agotests: virhostcputest: testcase for S390 system
Bjoern Walk [Tue, 19 Dec 2017 10:08:01 +0000 (11:08 +0100)]
tests: virhostcputest: testcase for S390 system

Let's add a testcase for a S390 system running kernel version 4.14 on
LPAR.

Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
7 years agoutil: virhostcpu: parse frequency information on S390
Bjoern Walk [Tue, 19 Dec 2017 10:08:00 +0000 (11:08 +0100)]
util: virhostcpu: parse frequency information on S390

Since kernel version 4.7, processor frequency information is available
on S390. Let's adjust the parser so this information shows up for virsh
nodeinfo:

    # virsh nodeinfo
    CPU model:           s390x
    CPU(s):              8
    CPU frequency:       5000 MHz
    CPU socket(s):       1
    Core(s) per socket:  8
    Thread(s) per core:  1
    NUMA cell(s):        1
    Memory size:         16273908 KiB

Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
7 years agostorage: Complete implementation volume by hash object
John Ferlan [Tue, 10 Oct 2017 22:32:40 +0000 (18:32 -0400)]
storage: Complete implementation volume by hash object

Alter the volume logic to use the hash tables instead of forward
linked lists. There are three hash tables to allow for fast lookup
by name, target.path, and key.

Modify the virStoragePoolObjAddVol to place the object in all 3
tables if possible using self locking RWLock on the volumes object.
Conversely when removing the volume, it's a removal of the object
from the various hash tables.

Implement functions to handle remote ForEach and Search Volume
type helpers. These are used by the disk backend in order to
facilitate adding a primary, extended, or logical partition.

Implement the various VolDefFindBy* helpers as simple (and fast)
hash lookups. The NumOfVolumes, GetNames, and ListExport helpers
are all implemented using standard for each hash table calls.

7 years agostorage: Introduce _virStorageVolObj[List]
John Ferlan [Tue, 10 Oct 2017 20:49:04 +0000 (16:49 -0400)]
storage: Introduce _virStorageVolObj[List]

Prepare for hash table volume lists by creating the object infrastructure
for a Volume Object and Volume Object List

The _virStorageVolObj will contain just a pointer to the "current"
(and live) volume definition.

The _virStorageVolObjList will contain three hash tables, one for
each of the lookup options allowed for a volume.

7 years agostorage: Modify virStorageBackendDiskMakeDataVol logic
John Ferlan [Tue, 9 Jan 2018 16:31:01 +0000 (11:31 -0500)]
storage: Modify virStorageBackendDiskMakeDataVol logic

Alter the logic such that we only add the volume to the pool once
we've filled in all the information and cause failure to go to a
common error: label. Patches to place the @vol into a few hash tables
will soon "require" that at least the keys (name, target.path, and key)
be populated with valid data.

7 years agostorage: When delete volume avoid disk backend removal
John Ferlan [Tue, 9 Jan 2018 13:40:24 +0000 (08:40 -0500)]
storage: When delete volume avoid disk backend removal

For a disk backend, the deleteVol code will clear all the
volumes in the pool and perform a pool refresh, thus the
storageVolDeleteInternal should not use access @voldef
after deleteVol succeeds.

7 years agocpu_x86: Copy CPU signature from ancestor
Jiri Denemark [Fri, 5 Jan 2018 16:43:03 +0000 (17:43 +0100)]
cpu_x86: Copy CPU signature from ancestor

When specifying a new CPU model in cpu_map.xml as an extension to an
existing model, we forgot to copy the signature (family + model) from
the original CPU model.

We don't use this way of specifying CPU models, but it's still supported
and it becomes useful when someone wants to quickly hack up a CPU model
for testing or when creating additional variants of existing models to
help with fixing some spectral issues.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agocpu_x86: Add debug messages to x86DecodeUseCandidate
Jiri Denemark [Fri, 5 Jan 2018 16:43:27 +0000 (17:43 +0100)]
cpu_x86: Add debug messages to x86DecodeUseCandidate

When translating CPUID data into CPU model + features, the code
sometimes uses an unexpected CPU model. There may be several reasons for
this, starting with wrong expectations and ending with an actual bug in
our code. These debug messages will help determining the reason.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agocputest: Fix cpu-cpuid.py diff command
Jiri Denemark [Fri, 5 Jan 2018 13:35:42 +0000 (14:35 +0100)]
cputest: Fix cpu-cpuid.py diff command

The cpuidMap in cpu-cpuid.py was created for converting old data files
(with QEMU's feature-words bits) to the new model-expansion based data.
When I added tests for CPU live update based on disabled/enabled feature
lists I shamelessly used the existing cpuidMap for generating the
*-{enabled,disabled}.xml data files. Thus any new CPUID bits which are
not present in the original cpuidMap would be ignored. The correct thing
to do is to use cpu_map.xml.

All data files were fixed by running the following command:

    ./cpu-cpuid.py diff *.json

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoapparmor, virt-aa-helper: drop static channel rule
Christian Ehrhardt [Tue, 9 Jan 2018 15:04:05 +0000 (16:04 +0100)]
apparmor, virt-aa-helper: drop static channel rule

This is now covered by DomainSetPathLabel being implemented in apparmor.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 years agosecurity, apparmor: add (Set|Restore)ChardevLabel
Christian Ehrhardt [Tue, 9 Jan 2018 15:04:04 +0000 (16:04 +0100)]
security, apparmor: add (Set|Restore)ChardevLabel

Since 1b4f66e "security: introduce virSecurityManager
(Set|Restore)ChardevLabel" this is a public API of security manager.

Implementing this in apparmor avoids miss any rules that should be
added for devices labeled via these calls.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 years agosecurity: full path option for DomainSetPathLabel
Christian Ehrhardt [Tue, 9 Jan 2018 15:04:03 +0000 (16:04 +0100)]
security: full path option for DomainSetPathLabel

virSecurityManagerDomainSetPathLabel is used to make a path known
to the security modules, but today is used interchangably for
 - paths to files/dirs to be accessed directly
 - paths to a dir, but the access will actually be to files therein

Depending on the security module it is important to know which of
these types it will be.

The argument allowSubtree augments the call to the implementations of
DomainSetPathLabel that can - per security module - decide if extra
actions shall be taken.

For now dac/selinux handle this as before, but apparmor will make
use of it to add a wildcard to the path that was passed.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agosecurity, apparmor: implement domainSetPathLabel
Christian Ehrhardt [Tue, 9 Jan 2018 15:04:02 +0000 (16:04 +0100)]
security, apparmor: implement domainSetPathLabel

This came up in discussions around huge pages, but it will cover
more per guest paths that should be added to the guests apparmor profile:
 - keys via qemuDomainWriteMasterKeyFile
 - per domain dirs via qemuProcessMakeDir
 - memory backing paths via qemuProcessBuildDestroyMemoryPathsImpl

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 years agoapparmor, virt-aa-helper: Allow access to /sys/bus/usb/devices
Jamie Strandboge [Wed, 20 Dec 2017 10:56:43 +0000 (11:56 +0100)]
apparmor, virt-aa-helper: Allow access to /sys/bus/usb/devices

Required to generate correct profiles when using usb passthrough.

Bug-Ubuntu: https://bugs.launchpad.net/bugs/565691

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Acked-by: Jamie Strandboge <jamie@ubuntu.com>
Acked-by: Intrigeri <intrigeri@boum.org>
7 years agoapparmor, libvirtd: Allow ixr to /var/lib/libvirt/virtd*
Jamie Strandboge [Tue, 19 Dec 2017 15:03:43 +0000 (16:03 +0100)]
apparmor, libvirtd: Allow ixr to /var/lib/libvirt/virtd*

This is required for the ebtables functionality added in
libvirt 0.8.0.

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
7 years agoapparmor, libvirt-qemu: qemu won't call qemu-nbd
Christian Ehrhardt [Tue, 19 Dec 2017 15:03:42 +0000 (16:03 +0100)]
apparmor, libvirt-qemu: qemu won't call qemu-nbd

While libvirtd might do so, qemu itself as a guest will not need
to call qemu-nbd so remove it from the profile.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
7 years agoapparmor, libvirt-qemu: add default pki path of libvirt-spice
Christian Ehrhardt [Wed, 20 Dec 2017 11:41:55 +0000 (12:41 +0100)]
apparmor, libvirt-qemu: add default pki path of libvirt-spice

Adding the PKI path that is used as default suggestion in src/qemu/qemu.conf
If people use non-default paths they should use local overrides but the
suggested defaults we should open up.

This is the default path as referenced by src/qemu/qemu.conf in libvirt.

While doing so merge the several places we have to cover PKI access into
one.

Bug-Ubuntu: https://bugs.launchpad.net/bugs/1690140

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 years agoapparmor, libvirt-qemu: Allow qemu-block-extra libraries
Jamie Strandboge [Wed, 20 Dec 2017 07:41:08 +0000 (08:41 +0100)]
apparmor, libvirt-qemu: Allow qemu-block-extra libraries

Allows (multi-arch enabled) access to libraries under the
/usr/lib/@{multiarch}/qemu/*.so path in the Debian/Ubuntu
qemu-block-extra package and all such libs for the paths
of rpm qemu-block-* packages.

Bug-Ubuntu: https://bugs.launchpad.net/bugs/1554761

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 years agoapparmor, libvirt-qemu: Silence lttng related deny messages
Stefan Bader [Tue, 19 Dec 2017 15:03:35 +0000 (16:03 +0100)]
apparmor, libvirt-qemu: Silence lttng related deny messages

Prevent denial messages related to attempted reads on lttng
files from spamming the logs.

Bug-Ubuntu: https://bugs.launchpad.net/bugs/1432644

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
7 years agoapparmor, libvirt-qemu: Allow use of sgabios
Serge Hallyn [Tue, 19 Dec 2017 15:03:34 +0000 (16:03 +0100)]
apparmor, libvirt-qemu: Allow use of sgabios

Bug-Ubuntu: https://bugs.launchpad.net/bugs/1393548

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
7 years agoqemu: Prepare BIOS/UEFI when starting a domain
Michal Privoznik [Wed, 3 Jan 2018 07:08:07 +0000 (08:08 +0100)]
qemu: Prepare BIOS/UEFI when starting a domain

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

Users might use a block device as UEFI VAR store. Or even have
OVMF stored there. Therefore, when starting a domain and separate
mount namespace is used, we have to create all the /dev entries
that are configured for the domain.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agonews: add change of hot unplug redirdev
Chen Hanxiao [Fri, 5 Jan 2018 02:47:48 +0000 (10:47 +0800)]
news: add change of hot unplug redirdev

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
7 years agoqemu: Add support for hot unplugging redirdev device
Chen Hanxiao [Fri, 5 Jan 2018 02:47:47 +0000 (10:47 +0800)]
qemu: Add support for hot unplugging redirdev device

Commit id '162efa1a' added support hotplug a redirdev, but
did not add the hot unplug. This patch will add that support
to allow usage of the detach-device --live on the device.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
7 years agoutil: Don't report CPU frequency for ARM hosts
Andrea Bolognani [Mon, 11 Dec 2017 15:09:20 +0000 (16:09 +0100)]
util: Don't report CPU frequency for ARM hosts

Some ARM platforms, such as the original Raspberry Pi, report the
CPU frequency in the BogoMIPS field of /proc/cpuinfo, so libvirt
parsed that field and returned it through its API.

However, not only many more boards don't report any value there,
but several - including ARMv8-based server hardware, and even the
more recent Raspberry Pi 3 - use this field as originally intended:
to report the BogoMIPS value instead of the CPU frequency.

Since we have no way of detecting how the field is being used,
it's better to report no information at all rather than something
ludicrous like "your shiny 96-core aarch64 virtualization host's
CPUs are running at a whopping 100 MHz".

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoutil: Improve CPU frequency parsing
Andrea Bolognani [Mon, 11 Dec 2017 14:32:49 +0000 (15:32 +0100)]
util: Improve CPU frequency parsing

Make the parser both more strict, by not ignoring errors reported
by virStrToLong_ui(), and more permissive, by not failing due to
unrelated fields which just happen to have a know prefix and
accepting any amount of whitespace before the numeric value.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
7 years agoutil: Print architecture name in /proc/cpuinfo parser
Andrea Bolognani [Thu, 14 Dec 2017 12:26:26 +0000 (13:26 +0100)]
util: Print architecture name in /proc/cpuinfo parser

Instead of a generic "your architecture", print the actual
architecture name.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
7 years agoutil: virhostcpu: factor out frequency parsing
Bjoern Walk [Thu, 30 Nov 2017 11:50:47 +0000 (12:50 +0100)]
util: virhostcpu: factor out frequency parsing

All different architectures use the same copy-pasted code to parse
processor frequency information from /proc/cpuinfo. Let's extract that
code into a function to avoid repetition.

We now also tolerate if the parsing of /proc/cpuinfo is not successful
and just report a warning instead of bailing out and abandoning the rest
of the CPU information.

Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
7 years agotests: Add host CPU data for Moonshot (RHEL 7.4)
Andrea Bolognani [Mon, 11 Dec 2017 15:30:39 +0000 (16:30 +0100)]
tests: Add host CPU data for Moonshot (RHEL 7.4)

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemuDomainAttachDeviceMknodHelper: Remove symlink before creating it
Michal Privoznik [Thu, 4 Jan 2018 10:11:53 +0000 (11:11 +0100)]
qemuDomainAttachDeviceMknodHelper: Remove symlink before creating it

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

So imagine you have /dev/blah symlink which points to /dev/sda.
You attach /dev/blah as disk to your domain. Libvirt correctly
creates the /dev/blah -> /dev/sda symlink in the qemu namespace.
However, then you detach the disk, change the symlink so that it
points to /dev/sdb and tries to attach the disk again. This time,
however, the attach fails (well, qemu attaches wrong disk)
because the code assumes that symlinks don't change. Well they
do.

This is inspired by test fix written by Eduardo Habkost.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
7 years agoqemu: Add support for pseries machine's max-cpu-compat= parameter
Shivaprasad G Bhat [Fri, 5 Jan 2018 13:48:00 +0000 (19:18 +0530)]
qemu: Add support for pseries machine's max-cpu-compat= parameter

When the -machine pseries,max-cpu-compat=X is supported use
machine parameter instead of -cpu host,compat=X parameter as
that is deprecated now with qemu >= v2.10.

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

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
7 years agoqemu: Add capability for pseries machine's max-cpu-compat= parameter
Shivaprasad G Bhat [Fri, 5 Jan 2018 13:47:46 +0000 (19:17 +0530)]
qemu: Add capability for pseries machine's max-cpu-compat= parameter

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
7 years agoqemuDomainDiskChangeSupported: Forbid alias change
Michal Privoznik [Wed, 13 Dec 2017 14:12:01 +0000 (15:12 +0100)]
qemuDomainDiskChangeSupported: Forbid alias change

Since we have user aliases it may happen that users want to
change it using 'update-device'. Instead of ignoring it silently,
error out loudly. Note that we don't limit the check just for
"ua-" prefixes because users might try to change libvirt
generated aliases too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Alter dump-guest-memory command generation
John Ferlan [Fri, 17 Nov 2017 19:25:01 +0000 (14:25 -0500)]
qemu: Alter dump-guest-memory command generation

The qemuMonitorJSONMakeCommand can properly handle a NULL string
by using the "S:" parameter instead of "s:", so let's use that
of having in if/else condition that only adds the "s:".

7 years agoqemu: Clean up style for the qemuDumpToFd definition
John Ferlan [Fri, 17 Nov 2017 19:50:34 +0000 (14:50 -0500)]
qemu: Clean up style for the qemuDumpToFd definition

Alter the function definition to follow more recent style

7 years agotest: Use virStoragePoolObjIsDuplicate for storage define/create
John Ferlan [Mon, 18 Dec 2017 12:41:16 +0000 (07:41 -0500)]
test: Use virStoragePoolObjIsDuplicate for storage define/create

Avoid the chance that there could be a duplicate storage pool UUID
or Name from the test driver storage pool define/create functions.

7 years agoconf: Use bool for @check_active parameter
John Ferlan [Mon, 18 Dec 2017 12:47:30 +0000 (07:47 -0500)]
conf: Use bool for @check_active parameter

Use a bool as that's how the variable is used in the function.

7 years agoconf: Need to unlock pools on object allocation failure
John Ferlan [Sun, 17 Dec 2017 17:41:03 +0000 (12:41 -0500)]
conf: Need to unlock pools on object allocation failure

The RW pool could be left locked if allocation fails.

7 years agoqemu: capabilities: force update if the microcode version does not match
Paolo Bonzini [Tue, 12 Dec 2017 15:23:41 +0000 (16:23 +0100)]
qemu: capabilities: force update if the microcode version does not match

A microcode update can cause the CPUID bits to change; an example
from the past was the update that disabled TSX on several Haswell
and Broadwell machines.

Therefore, place microcode version in the virQEMUCaps struct and
XML, and rebuild the cache if the versions do not match.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoconf: include x86 microcode version in virsh capabilities
Paolo Bonzini [Tue, 12 Dec 2017 15:23:40 +0000 (16:23 +0100)]
conf: include x86 microcode version in virsh capabilities

A microcode update can cause the CPUID bits to change; an example
from the past was the update that disabled TSX on several Haswell and
Broadwell machines.

In order to track the x86 microcode version in the QEMU capabilities,
we have to fetch it and store it in the host CPU.  This also makes the
version visible in "virsh capabilities", which is a nice side effect.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agocpu_x86: Rename virCPUx86MapInitialize
Jiri Denemark [Wed, 13 Dec 2017 21:30:31 +0000 (22:30 +0100)]
cpu_x86: Rename virCPUx86MapInitialize

The function will be used to initialize internal data of the x86 CPU
driver (including the CPU map).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoutil: introduce virHostCPUGetMicrocodeVersion
Paolo Bonzini [Tue, 12 Dec 2017 15:23:41 +0000 (16:23 +0100)]
util: introduce virHostCPUGetMicrocodeVersion

This new API reads host's CPU microcode version from /proc/cpuinfo.

Unfortunately, there is no other way of reading microcode version which
would be usable from both system and session daemon.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoutil: add virFileReadHeaderQuiet wrapper around virFileReadHeaderFD
Paolo Bonzini [Tue, 12 Dec 2017 15:23:40 +0000 (16:23 +0100)]
util: add virFileReadHeaderQuiet wrapper around virFileReadHeaderFD

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoconf: Fix generating addresses for SCSI hostdev
John Ferlan [Tue, 5 Dec 2017 16:36:01 +0000 (11:36 -0500)]
conf: Fix generating addresses for SCSI hostdev

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

Commit id 'dc692438' reverted the automagic addition of a SCSI
controller attempt during virDomainHostdevAssignAddress; however,
the logic to determine where to place the next_unit depended upon
the "new" controller being added.  Without the new controller the
the next time through the call for the next SCSI hostdev found
would result in the "next_unit" never changing from 0 (zero) and
as a result the addition of the device will fail due to being a
duplicate unit number of the first with the error message:

  virDomainDefCheckDuplicateDriveAddresses:$line : unsupported
      configuration: SCSI host address controller='0' bus='1'
      target='0' unit='0' in use by another SCSI host device

So instead of walking the controller list looking for SCSI
controllers, all we can do is "pretend" that they exist and
allow other code to create them later as necessary.

7 years agoconf: Use existing SCSI hostdev model to create new
John Ferlan [Mon, 4 Dec 2017 20:52:57 +0000 (15:52 -0500)]
conf: Use existing SCSI hostdev model to create new

In virDomainDefMaybeAddHostdevSCSIcontroller when we add a new
controller because someone neglected to add one or we're adding
one because the existing one is full, we should copy over the
model number from the existing controller since whatever we
create should at least have the same characteristics as the one
we cannot use because it's full.

NB: This affects the existing hostdev-scsi-autogen-address test
which would add a default ('lsi') SCSI controller for the various
scsi_host's that would create a controller for the hostdev.

7 years agoqemu: Use same model when adding hostdev SCSI controller
John Ferlan [Mon, 4 Dec 2017 19:33:30 +0000 (14:33 -0500)]
qemu: Use same model when adding hostdev SCSI controller

When qemuDomainFindOrCreateSCSIDiskController adds a controller,
let's use the same model as a currently found controller under the
assumption that the reason to add the controller in hotplug is
because virDomainHostdevAssignAddress determined that there were
too many devices on the existing controller, but only assigned a
new controller index and did not add a new controller and we
desire to use the same controller model as any existing controller
and not take a chance that qemuDomainSetSCSIControllerModel would
use a default that may be incompatible.

7 years agorpc: remove redundant logic
Pavel Hrdina [Thu, 4 Jan 2018 13:22:11 +0000 (14:22 +0100)]
rpc: remove redundant logic

Introduced by commit <0eaa59dce1>.  That comparison already returns
true or false.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agonodedev: Move device enumumeration out of nodeStateInitialize
John Ferlan [Wed, 22 Nov 2017 16:55:10 +0000 (11:55 -0500)]
nodedev: Move device enumumeration out of nodeStateInitialize

Let's move the udevEnumerateDevices into a thread to "speed
up" the initialization process. If the enumeration fails we
can set the Quit flag to ensure that udevEventHandleCallback
will not run.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
7 years agorpc: Replace virNetServerClientNeedAuth with virNetServerClientIsAuthenticated
Marc Hartmayer [Thu, 21 Dec 2017 14:29:08 +0000 (15:29 +0100)]
rpc: Replace virNetServerClientNeedAuth with virNetServerClientIsAuthenticated

Replace virNetServerClientNeedAuth with
virNetServerClientIsAuthenticated because it makes it clearer what it
means.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
7 years agorpc: Remove virNetServerClientNeedAuthLocked
Marc Hartmayer [Thu, 21 Dec 2017 14:29:07 +0000 (15:29 +0100)]
rpc: Remove virNetServerClientNeedAuthLocked

'Squash' virNetServerClientNeedAuthLocked into
virNetServerClientNeedAuth and remove virNetServerClientNeedAuthLocked
as it's not longer needed.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
7 years agotests: virnetdaemontest: Enable testing for 'auth_pending'
Marc Hartmayer [Thu, 21 Dec 2017 14:29:06 +0000 (15:29 +0100)]
tests: virnetdaemontest: Enable testing for 'auth_pending'

Enable testing for 'auth_pending' in the virnetdaemon test case.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agorpc: virnetserver: Fix race on srv->nclients_unauth
Marc Hartmayer [Thu, 21 Dec 2017 14:29:05 +0000 (15:29 +0100)]
rpc: virnetserver: Fix race on srv->nclients_unauth

There is a race between virNetServerProcessClients (main thread) and
remoteDispatchAuthList/remoteDispatchAuthPolkit/remoteSASLFinish (worker
thread) that can lead to decrementing srv->nclients_unauth when it's
zero. Since virNetServerCheckLimits relies on the value
srv->nclients_unauth the underrun causes libvirtd to stop accepting
new connections forever.

Example race scenario (assuming libvirtd is using policykit and the
client is privileged):
  1. The client calls the RPC remoteDispatchAuthList =>
     remoteDispatchAuthList is executed on a worker thread (Thread
     T1). We're assuming now the execution stops for some time before
     the line 'virNetServerClientSetAuth(client, 0)'
  2. The client closes the connection irregularly. This causes the
     event loop to wake up and virNetServerProcessClient to be
     called (on the main thread T0). During the
     virNetServerProcessClients the srv lock is hold. The condition
     virNetServerClientNeedAuth(client) will be checked and as the
     authentication is not finished right now
     virNetServerTrackCompletedAuthLocked(srv) will be called =>
     --srv->nclients_unauth => 0
  3. The Thread T1 continues, marks the client as authenticated, and
     calls virNetServerTrackCompletedAuthLocked(srv) =>
     --srv->nclients_unauth => --0 => wrap around as nclient_unauth is
     unsigned
  4. virNetServerCheckLimits(srv) will disable the services forever

To fix it, add an auth_pending field to the client struct so that it
is now possible to determine if the authentication process has already
been handled for this client.

Setting the authentication method to none for the client in
virNetServerProcessClients is not a proper way to indicate that the
counter has been decremented, as this would imply that the client is
authenticated.

Additionally, adjust the existing test cases for this new field.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
7 years agorpc: Introduce virNetServerSetClientAuthenticated
Marc Hartmayer [Thu, 21 Dec 2017 14:29:04 +0000 (15:29 +0100)]
rpc: Introduce virNetServerSetClientAuthenticated

Combine virNetServerClientSetAuth(client,
VIR_NET_SERVER_SERVICE_AUTH_NONE) and virNetServerTrackCompletedAuth
into one new function named virNetServerSetClientAuthenticated.

After using this new function the function
virNetServerTrackCompletedAuth was superfluous and is therefore
removed. In addition, it is not very common that a
'{{function}}' (virNetServerTrackCompletedAuth) does more than just
the locking compared to
'{{function}}Locked' (virNetServerTrackCompletedAuthLocked).

virNetServerTrackPendingAuth was already superfluous and therefore
it's also removed.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agorpc: Correct locking and simplify the function
Marc Hartmayer [Thu, 21 Dec 2017 14:29:03 +0000 (15:29 +0100)]
rpc: Correct locking and simplify the function

The lock for @client must not only be held for the duration of
checking whether the client wants to close, but also for as long as
we're closing the client. The same applies to the tracking of
authentications.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
7 years agorpc: Refactor the condition whether a client needs authentication
Marc Hartmayer [Thu, 21 Dec 2017 14:29:02 +0000 (15:29 +0100)]
rpc: Refactor the condition whether a client needs authentication

Add virNetServerClientAuthMethodImpliesAuthenticated() for deciding
whether a authentication method implies that a client is automatically
authenticated or not. Use this new function in
virNetServerClientNeedAuthLocked().

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
7 years agorpc: First test if authentication is required
Marc Hartmayer [Thu, 21 Dec 2017 14:29:01 +0000 (15:29 +0100)]
rpc: First test if authentication is required

This makes the code more efficient.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agorpc: Be more precise in which cases the authentication is needed and introduce *Locked
Marc Hartmayer [Thu, 21 Dec 2017 14:29:00 +0000 (15:29 +0100)]
rpc: Be more precise in which cases the authentication is needed and introduce *Locked

Be more precise in which cases the authentication is needed and
introduce *Locked.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agorpc: Add typedef for the anonymous enum used for authentication methods
Marc Hartmayer [Thu, 21 Dec 2017 14:28:59 +0000 (15:28 +0100)]
rpc: Add typedef for the anonymous enum used for authentication methods

Add typedef for the anonymous enum used for the authentication methods
and remove the default case. This allows the usage of the type in a
switch statement and taking advantage of the compilers feature to
detect uncovered cases.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agorpc: Use the enum value instead of a numerical value
Marc Hartmayer [Thu, 21 Dec 2017 14:28:58 +0000 (15:28 +0100)]
rpc: Use the enum value instead of a numerical value

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agotests: virnetserverclienttest: Fix memory leak @client
Marc Hartmayer [Thu, 21 Dec 2017 14:28:57 +0000 (15:28 +0100)]
tests: virnetserverclienttest: Fix memory leak @client

Direct leak of 104 byte(s) in 1 object(s) allocated from:
    #0 0x7f904bfbe12b  (/lib64/liblsan.so.0+0xe12b)
    #1 0x7f904ba0ad67 in virAlloc ../../src/util/viralloc.c:144
    #2 0x7f904bbc11a4 in virNetMessageNew ../../src/rpc/virnetmessage.c:42
    #3 0x7f904bbb8e77 in virNetServerClientNewInternal ../../src/rpc/virnetserverclient.c:392
    #4 0x7f904bbb9921 in virNetServerClientNew ../../src/rpc/virnetserverclient.c:440
    #5 0x402ce5 in testIdentity ../../tests/virnetserverclienttest.c:55
    #6 0x403bed in virTestRun ../../tests/testutils.c:180
    #7 0x402c1e in mymain ../../tests/virnetserverclienttest.c:146
    #8 0x404c80 in virTestMain ../../tests/testutils.c:1119
    #9 0x4030d5 in main ../../tests/virnetserverclienttest.c:152
    #10 0x7f9047f7f889 in __libc_start_main (/lib64/libc.so.6+0x20889)

Indirect leak of 4 byte(s) in 1 object(s) allocated from:
    #0 0x7f904bfbe12b  (/lib64/liblsan.so.0+0xe12b)
    #1 0x7f904ba0adc7 in virAllocN ../../src/util/viralloc.c:191
    #2 0x7f904bbb8ec7 in virNetServerClientNewInternal ../../src/rpc/virnetserverclient.c:395
    #3 0x7f904bbb9921 in virNetServerClientNew ../../src/rpc/virnetserverclient.c:440
    #4 0x402ce5 in testIdentity ../../tests/virnetserverclienttest.c:55
    #5 0x403bed in virTestRun ../../tests/testutils.c:180
    #6 0x402c1e in mymain ../../tests/virnetserverclienttest.c:146
    #7 0x404c80 in virTestMain ../../tests/testutils.c:1119
    #8 0x4030d5 in main ../../tests/virnetserverclienttest.c:152
    #9 0x7f9047f7f889 in __libc_start_main (/lib64/libc.so.6+0x20889)

SUMMARY: LeakSanitizer: 108 byte(s) leaked in 2 allocation(s).

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agorpc: Remove duplicate declaration of virNetServerAddClient
Marc Hartmayer [Thu, 21 Dec 2017 14:28:56 +0000 (15:28 +0100)]
rpc: Remove duplicate declaration of virNetServerAddClient

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu_cgroup: Fix 'rc' argument on virDomainAuditCgroupPath() calls
Eduardo Habkost [Thu, 28 Dec 2017 17:41:28 +0000 (15:41 -0200)]
qemu_cgroup: Fix 'rc' argument on virDomainAuditCgroupPath() calls

All calls to virDomainAuditCgroupPath() were passing 'rc == 0' as
argument, when it was supposed to pass the 'rc' value directly.

As a consequence, the audit events that were supposed to be
logged (actual cgroup changes) were never being logged, and bogus
audit events were logged when using regular files as disk image.

Fix all calls to use the return value of
virCgroup{Allow,Deny}Device*() directly as the 'rc' argument.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agovirstringtest: Fix alignment of backslashes
Michal Privoznik [Thu, 4 Jan 2018 08:29:49 +0000 (09:29 +0100)]
virstringtest: Fix alignment of backslashes

We don't try to right align the backslashes anymore.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agomaint: update to latest gnulib
Eric Blake [Tue, 10 Oct 2017 08:56:31 +0000 (09:56 +0100)]
maint: update to latest gnulib

This pulls in updates for the 2018 copyright year, among other things.

Signed-off-by: Eric Blake <eblake@redhat.com>
7 years agoapparmor: fix virt-aa-helper profile
Cédric Bosdonnat [Tue, 2 Jan 2018 08:54:46 +0000 (09:54 +0100)]
apparmor: fix virt-aa-helper profile

Fix rule introduced by commit 0f33025a:
  * to handle /var/run not being a symlink to /run
  * to be properly parsed: missing comma at the end.

7 years agostorage: Fixing missing 'backingStore' tag from volume XML dumps.
Julio Faracco [Tue, 2 Jan 2018 18:52:20 +0000 (16:52 -0200)]
storage: Fixing missing 'backingStore' tag from volume XML dumps.

After commit a693fdb 'vol-dumpxml' missed the ability to show backingStore
information. This commit adds a volume type for files that fixes this
problem.

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

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
7 years agoqemuBuildMemPathStr: Forbid memoryBacking/access for non-numa case
Michal Privoznik [Tue, 12 Dec 2017 13:03:13 +0000 (14:03 +0100)]
qemuBuildMemPathStr: Forbid memoryBacking/access for non-numa case

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

If a domain has no numa nodes, that means we don't put any
memory-backend-file onto the qemu command line. That in turn
means we can't set access='shared'. Therefore, we should produce
an error instead of ignoring the setting silently.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu: monitor: Decrease logging verbosity
Peter Krempa [Wed, 20 Dec 2017 12:09:07 +0000 (13:09 +0100)]
qemu: monitor: Decrease logging verbosity

The PROBE macro used in qemuMonitorIOProcess and the VIR_DEBUG message
in qemuMonitorJSONIOProcess create a lot of logging churn when debug
logging is enabled during monitor communication.

The messages logged from the PROBE macro are rather useless since they
are reporting the partial state of receiving the reply from qemu. The
actual full reply is still logged in qemuMonitorJSONIOProcessLine once
the full message is received.

7 years agoutil: probe: Add quiet versions of the "PROBE" macro
Peter Krempa [Wed, 20 Dec 2017 11:58:36 +0000 (12:58 +0100)]
util: probe: Add quiet versions of the "PROBE" macro

PROBE macro adds a logging entry, when used in places seeing a lot of
traffic this can cause a significant slowdown.

7 years agoutil: virstring: Tweak a few more descriptions.
Chen Hanxiao [Wed, 3 Jan 2018 09:56:35 +0000 (17:56 +0800)]
util: virstring: Tweak a few more descriptions.

There are a few more description-related issues that commit @9026d115
forgot to address.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agolxc: set a hostname based on the container name
Cédric Bosdonnat [Mon, 18 Dec 2017 14:48:33 +0000 (15:48 +0100)]
lxc: set a hostname based on the container name

Set a transient hostname on containers. The hostname is computed from
the container name, only keeping the valid characters [a-zA-Z0-9-] in it.
This filtering is based on RFC 1123 and allows a digit to start the
hostname.

7 years agoAdd virStringFilterChars() string utility
Cédric Bosdonnat [Mon, 18 Dec 2017 14:46:53 +0000 (15:46 +0100)]
Add virStringFilterChars() string utility

Add a function to filter a string based on a list of valid characters.

7 years agoutil: fix the description of virStringSearch
Chen Hanxiao [Sat, 23 Dec 2017 09:49:08 +0000 (17:49 +0800)]
util: fix the description of virStringSearch

There's no argument named @result, use @matches instead.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agoapparmor: allow unix stream for p2p migrations
Christian Ehrhardt [Tue, 19 Dec 2017 13:13:06 +0000 (14:13 +0100)]
apparmor: allow unix stream for p2p migrations

On live migration with --p2p like:
 $ virsh migrate --live --p2p kvmguest-bionic-normal \
       qemu+ssh://10.6.221.80/system

We hit an apparmor deny like:
  apparmor="DENIED" operation="file_inherit"
  profile="/usr/sbin/libvirtd" pid=23477 comm="ssh" family="unix"
  sock_type="stream" protocol=0 requested_mask="send receive"
  denied_mask="send" addr=none peer_addr=none peer="unconfined"

The rule is not perfect, but can't be restricted further at the moment
(new upstream kernel features needed). For now the lack of a profile on the
peer as well as comm not being a conditional on rules do not allow to filter
further.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 years agosrc: Export virDomainMemoryAccessType*String
Michal Privoznik [Tue, 12 Dec 2017 12:52:50 +0000 (13:52 +0100)]
src: Export virDomainMemoryAccessType*String

These are already exported at header file level because of
VIR_ENUM_DECL being in numa_conf.h. However, they are not being
exported at object level because of missing libvirt_private.syms
record.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agodocs: Fix serial console configuration examples
Andrea Bolognani [Tue, 2 Jan 2018 14:51:59 +0000 (15:51 +0100)]
docs: Fix serial console configuration examples

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoqemu: Enforce vCPU hotplug granularity constraints
Andrea Bolognani [Thu, 14 Dec 2017 14:54:59 +0000 (15:54 +0100)]
qemu: Enforce vCPU hotplug granularity constraints

QEMU 2.7 and newer don't allow guests to start unless the initial
vCPUs count is a multiple of the vCPU hotplug granularity, so
validate it and report an error if needed.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoqemu: Invert condition nesting in qemuDomainDefValidate()
Andrea Bolognani [Thu, 14 Dec 2017 14:29:28 +0000 (15:29 +0100)]
qemu: Invert condition nesting in qemuDomainDefValidate()

While at the moment we're only performing a single check that is
connected to vCPU hotplugging, we're going to introduce a second
one soon. Move the topology check underneath the capability check
to make that easier; since, after this change, the 'topologycpus'
variable doesn't need to have function scope, we move its
declaration to the inner scope as well.

The comments around the check are modified in order to explain
the different QEMU versions involved.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoconf: honor maxnames in nodeListDevices API
Pavel Hrdina [Tue, 2 Jan 2018 09:18:17 +0000 (10:18 +0100)]
conf: honor maxnames in nodeListDevices API

Introduced by commit <4ae9dbea99c>.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7 years agoqemu: Move TCP and haveTLS checks into qemuDomainDelChardevTLSObjects
John Ferlan [Wed, 20 Dec 2017 11:36:26 +0000 (06:36 -0500)]
qemu: Move TCP and haveTLS checks into qemuDomainDelChardevTLSObjects

Similar to qemuDomainAddChardevTLSObjects let's move the chardev
source must be TCP and it has the @haveTLS flag set checks before
trying to delete the TLS objects.

For the Chr device this represents no change; however, for RNG device
this is an additionaly check that was missed in commit id '68808516'.
Before adding the objects, TCP and haveTLS are checked.

7 years agoqemu: Introduce qemuDomainDelChardevTLSObjects
John Ferlan [Tue, 19 Dec 2017 22:46:41 +0000 (17:46 -0500)]
qemu: Introduce qemuDomainDelChardevTLSObjects

Let's make a comment deletion helper similar to the Add helper
that can be called after the ExitMonitor.

The modify qemuDomainRemoveChrDevice and qemuDomainRemoveRNGDevice
to call the helper instead of inlining the copy and pasted code.

7 years agonetserver: close clients before stopping all drivers
Cédric Bosdonnat [Wed, 20 Dec 2017 16:36:10 +0000 (17:36 +0100)]
netserver: close clients before stopping all drivers

So far clients were closed when disposing the daemon, after the state
driver cleanup. This was leading to libvirtd crashing at shutdown due
to missing driver.

Moving the client close in virNetServerClose() fixes the problem.

Reviewed-by: Erik Skultety <eskultet@redhat.com>
7 years agovirt-aa-helper: handle more disk images
Cédric Bosdonnat [Mon, 11 Dec 2017 10:09:31 +0000 (11:09 +0100)]
virt-aa-helper: handle more disk images

virt-aa-helper needs read access to the disk image to resolve symlinks
and add the proper rules to the profile. Its profile whitelists a few
common paths, but users can place their images anywhere.

This commit helps users allowing access to their images by adding their
own rules in apparmor.d/local/usr.lib.libvirt.virt-aa-helper.

This commit also adds rules to allow reading files named:
  - *.raw as this is a rather common disk image extension
  - /run/libvirt/**[vd]d[a-z] as these are used by virt-sandbox

7 years agoautogen.sh: tell user the correct make command
Daniel P. Berrange [Tue, 4 Jul 2017 14:59:51 +0000 (15:59 +0100)]
autogen.sh: tell user the correct make command

When autogen.sh finishes it helpfully prints

  "Now type 'make' to compile libvirt."

which is fine if on a host with GNU make, but on *BSD running
'make' will end in tears. We should tell users to run 'gmake'
on these platforms. If 'gmake' doesn't exist then we should
report an error too

  "GNU make is required to build libvirt"

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>