]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
5 years agovirbpf: Set errno instead of reporting errors
Michal Privoznik [Wed, 26 Feb 2020 08:24:27 +0000 (09:24 +0100)]
virbpf: Set errno instead of reporting errors

The virbpf module wraps syscalls to BPF. However, if the kernel
headers used at the compile time don't have support for BPF the
module offers stubs which return a negative one to signal error
to the caller. But there is a slight discrepancy between real
functions and these stubs. While the former set errno and return
-1 the latter report an error (without setting the errno) and
return -1. This is not optimal because the caller might see stale
errno and overwrite the error message with a less accurate one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirCgroupV2DevicesAvailable: Print stringified errno in the debug log
Michal Privoznik [Mon, 9 Mar 2020 12:14:07 +0000 (13:14 +0100)]
virCgroupV2DevicesAvailable: Print stringified errno in the debug log

In the virCgroupV2DevicesAvailable() function we try to determine
whether CGroups version 2 are available. We do this by opening
what we believe is the CGroup mount point and issuing a BPF call.
When the call fails, a debug message is printed. However, the BPF
call sets errno too. Include it in the debug message to help us
with debugging.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirDomainDiskTranslateSourcePool: Check for disk type correctly
Michal Privoznik [Mon, 9 Mar 2020 15:40:57 +0000 (16:40 +0100)]
virDomainDiskTranslateSourcePool: Check for disk type correctly

When rewriting the virDomainDiskTranslateSourcePool() function in
v6.1.0-rc1~184 a typo was introduced. Previously, we allowed
startup policy only for those volumes which translated to
VIR_STORAGE_TYPE_FILE. But starting with the referenced commit,
the value we checked for was changed to VIR_STORAGE_VOL_FILE
which comes from a different enum and has a different value too.
This is wrong, because virStorageSourceGetActualType() returns a
value from the original enum.

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agocputest: Add data for Intel(R) Core(TM) i7-8550U CPU without TSX
Jiri Denemark [Fri, 6 Mar 2020 09:50:11 +0000 (10:50 +0100)]
cputest: Add data for Intel(R) Core(TM) i7-8550U CPU without TSX

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
5 years agoqemumonitorjsontest: GetCPUModelBaseline: use g_auto
Ján Tomko [Fri, 21 Feb 2020 23:55:50 +0000 (00:55 +0100)]
qemumonitorjsontest: GetCPUModelBaseline: use g_auto

Use g_autoptr for the virCPUDef variables.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemumonitorjsontest: GetCPUModelComparison: use g_auto
Ján Tomko [Fri, 21 Feb 2020 23:55:50 +0000 (00:55 +0100)]
qemumonitorjsontest: GetCPUModelComparison: use g_auto

Use g_autoptr for the virCPUDef variables and get rid
of the cleanup label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agovirsystemdtest: do not leak socket path
Ján Tomko [Fri, 21 Feb 2020 23:57:33 +0000 (00:57 +0100)]
virsystemdtest: do not leak socket path

Use an autofree'd helper variable to store the socket path
and free it after the function finishes.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 5b8569dd6e284b9159c701e8bffafb196983fc4a
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemumonitorjsontest: use virCPUDefNew()
Ján Tomko [Sat, 22 Feb 2020 00:06:51 +0000 (01:06 +0100)]
qemumonitorjsontest: use virCPUDefNew()

virCPUDefPtr uses refcounting internally and must be allocated
using virCPUDefNew, otherwise virCPUDefFree would be a no-op.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: fa2404bf4f91813431beb797fc30a1237a743823
Fixes: eee09435eec46553aac4fdf1c2d8f3214167bded
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemumonitorjsontest: do not leak qapiData.schema
Ján Tomko [Fri, 21 Feb 2020 23:57:07 +0000 (00:57 +0100)]
qemumonitorjsontest: do not leak qapiData.schema

Free the x86_64 schema before overwriting it with s390x schema.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: eee09435eec46553aac4fdf1c2d8f3214167bded
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: valgrind: do not trace system binaries
Ján Tomko [Fri, 21 Feb 2020 23:51:41 +0000 (00:51 +0100)]
tests: valgrind: do not trace system binaries

Add /usr/bin/* to -trace-children-skip

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: valgrind.supp: suppress g_type_register_static leaks
Ján Tomko [Fri, 21 Feb 2020 23:48:27 +0000 (00:48 +0100)]
tests: valgrind.supp: suppress g_type_register_static leaks

When a type is registered, it holds allocated memory until
the program exits.

Add an exception to valgrind.supp to make the output of
  make -C tests valgrind
more readable.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoqemu: Tell secdrivers which images are top parent
Michal Privoznik [Thu, 27 Feb 2020 10:20:51 +0000 (11:20 +0100)]
qemu: Tell secdrivers which images are top parent

When preparing images for block jobs we modify their seclabels so
that QEMU can open them. However, as mentioned in the previous
commit, secdrivers base some it their decisions whether the image
they are working on is top of of the backing chain. Fortunately,
in places where we call secdrivers we know this and the
information can be passed to secdrivers.

The problem is the following: after the first blockcommit from
the base to one of the parents the XATTRs on the base image are
not cleared and therefore the second attempt to do another
blockcommit fails. This is caused by blockcommit code calling
qemuSecuritySetImageLabel() over the base image, possibly
multiple times (to ensure RW/RO access). A naive fix would be to
call the restore function. But this is not possible, because that
would deny QEMU the access to the base image.  Fortunately, we
can use the fact that seclabels are remembered only for the top
of the backing chain and not for the rest of the backing chain.
And thanks to the previous commit we can tell secdrivers which
images are top of the backing chain.

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agosecurity: Introduce VIR_SECURITY_DOMAIN_IMAGE_PARENT_CHAIN_TOP flag
Michal Privoznik [Thu, 27 Feb 2020 10:06:22 +0000 (11:06 +0100)]
security: Introduce VIR_SECURITY_DOMAIN_IMAGE_PARENT_CHAIN_TOP flag

Our decision whether to remember seclabel for a disk image
depends on a few factors. If the image is readonly or shared or
not the chain top the remembering is suppressed for the image.
However, the virSecurityManagerSetImageLabel() is too low level
to determine whether passed @src is chain top or not. Even though
the function has the @parent argument it does not necessarily
reflect the chain top - it only points to the top level image in
the chain we want to relabel and not to the topmost image of the
whole chain. And this can't be derived from the passed domain
definition reliably neither - in some cases (like snapshots or
block copy) the @src is added to the definition only after the
operation succeeded. Therefore, introduce a flag which callers
can use to help us with the decision.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agorpc: getaddrinfo: also accept IPv4-mapped IPv6 addresses
Zhimin Feng [Mon, 2 Mar 2020 08:26:51 +0000 (16:26 +0800)]
rpc: getaddrinfo: also accept IPv4-mapped IPv6 addresses

If only IPv6 is configured on the host, getaddrinfo with AI_ADDRCONFIG
in hints would return EAI_ADDRFAMILY for nodenames that resolve to IPv4.

Also pass AI_V4MAPPED to accept IPv4-mapped addresses on IPv6-only
systems.

Signed-off-by: Zhimin Feng <fengzhimin1@huawei.com>
[rewrote the commit message - jtomko]
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agologging: Use default timeout of 120 seconds for virtlogd
Andrea Bolognani [Thu, 5 Mar 2020 16:39:23 +0000 (17:39 +0100)]
logging: Use default timeout of 120 seconds for virtlogd

This is the same timeout of all other daemons, and just like them
virtlogd is socket-activated, so it will automatically be started
on demand whenever that's necessary.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agosrc: fix mixup of stack and heap allocated data in auth callback
Daniel P. Berrangé [Thu, 5 Mar 2020 15:42:53 +0000 (15:42 +0000)]
src: fix mixup of stack and heap allocated data in auth callback

In the following recent change:

  commit db72866310d1e520efa8ed2d4589bdb5e76a1c95
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Tue Jan 14 10:40:52 2020 +0000

    util: add API for reading password from the console

the fact that "bufptr" pointer may point to either heap or stack
allocated data was overlooked. As a result, when the strdup was
removed, we ended up returning a pointer to the local stack to
the caller. When the caller referenced this stack pointer they
got out garbage which fairly quickly resulted in a crash.

We need to copy the stack buffer into heap memory in the username
case.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoutil: viraudit: remove unnecessary includes
Ján Tomko [Wed, 26 Feb 2020 17:56:46 +0000 (18:56 +0100)]
util: viraudit: remove unnecessary includes

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoutil: audit: drop support for old libaudit
Ján Tomko [Wed, 26 Feb 2020 17:51:19 +0000 (18:51 +0100)]
util: audit: drop support for old libaudit

Virtualization event types were added in 2.0.5:
https://github.com/linux-audit/audit-userspace/commit/3755e9ff

Even Ubuntu 14.04 (which we don't support) has 2.3.2.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agovirthread: Free thread name only after worker has finished
Michal Privoznik [Fri, 6 Mar 2020 15:11:09 +0000 (16:11 +0100)]
virthread: Free thread name only after worker has finished

When spawning a thread via our virThread APIs we let pthread
spawn this helper thread which sets couple of thread local
variables (e.g. thread job name or thread worker name) and as of
v6.1.0-40-gc85256b31b it also sets pthread name (which is then
visible in `ps' output for instance). Only after these steps the
intended function is called. However, just before calling it we
free the buffer that holds the thread name which results in
invalid memory reads:

==47027== Invalid read of size 1
==47027==    at 0x48389C2: strlen (vg_replace_strmem.c:459)
==47027==    by 0x58BB3D6: __vfprintf_internal (vfprintf-internal.c:1645)
==47027==    by 0x58CE6E0: __vasprintf_internal (vasprintf.c:57)
==47027==    by 0x574BA28: g_vasprintf (in /usr/lib64/libglib-2.0.so.0.6000.7)
==47027==    by 0x57240CC: g_strdup_vprintf (in /usr/lib64/libglib-2.0.so.0.6000.7)
==47027==    by 0x48E0EFA: vir_g_strdup_vprintf (glibcompat.c:209)
==47027==    by 0x493AA05: virLogVMessage (virlog.c:573)
==47027==    by 0x493A8FE: virLogMessage (virlog.c:513)
==47027==    by 0x4992FC7: virThreadJobClear (virthreadjob.c:121)
==47027==    by 0x4992844: virThreadHelper (virthread.c:237)
==47027==    by 0x5817496: start_thread (pthread_create.c:486)
==47027==    by 0x59563CE: clone (clone.S:95)

The problem is that neither virThreadJobSetWorker() nor
virThreadJobSet() create a copy of passed name. They just set a
thread local variable to point to the buffer which is then
freed. Moving the free towards the end of the wrapper function
solves the issue.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agotest: fix leak of authentication info
Daniel P. Berrangé [Thu, 5 Mar 2020 15:41:49 +0000 (15:41 +0000)]
test: fix leak of authentication info

The 'auths' struct in the test driver was not free()d. This was easy to
miss because the default XML doesn't include auth info.

Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoaa-helper: use g_autofree in create_profile
Ján Tomko [Thu, 5 Mar 2020 16:21:54 +0000 (17:21 +0100)]
aa-helper: use g_autofree in create_profile

'template' might be used uninitialized.

Use g_autofree for everything and remove all the custom labels.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agovz: use g_autofree in prlsdkConvertCpuInfo
Ján Tomko [Thu, 5 Mar 2020 16:17:55 +0000 (17:17 +0100)]
vz: use g_autofree in prlsdkConvertCpuInfo

Convert the function to use g_autofree to silence -Wmaybe-uninitialized.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agovirmacmap: Use g_autofree in virMacMapWriteFileLocked
Ján Tomko [Thu, 5 Mar 2020 16:16:29 +0000 (17:16 +0100)]
virmacmap: Use g_autofree in virMacMapWriteFileLocked

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agodocs: add page describing the libvirt daemons
Daniel P. Berrangé [Mon, 14 Oct 2019 09:54:22 +0000 (10:54 +0100)]
docs: add page describing the libvirt daemons

Now that we have more than just the libvirtd daemon, we should be
explaining to users what they are all for & important aspects of their
configuration.

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoVIR_FREE: Replace internals by g_clear_pointer
Peter Krempa [Thu, 5 Mar 2020 08:42:23 +0000 (09:42 +0100)]
VIR_FREE: Replace internals by g_clear_pointer

Our implementation masks GCC warnings of uninitialized use of the passed
argument. After changing this I got a load of following warnings:

src/conf/virnetworkportdef.c: In function 'virNetworkPortDefSaveStatus':
/usr/include/glib-2.0/glib/gmem.h:136:8: error: 'path' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  136 |     if (_p)                \
      |        ^
src/conf/virnetworkportdef.c:447:11: note: 'path' was declared here
  447 |     char *path;
      |           ^~~~

For the curious, g_clear_pointer is still safe for arguments with
side-effect. Here's the pre-processed output of trying to do a
VIR_FREE(*(test2++)):

 do {
     typedef char _GStaticAssertCompileTimeAssertion_1[(sizeof *(&(*(test2++))) == sizeof (gpointer)) ? 1 : -1] __attribute__((__unused__));
     __typeof__((&(*(test2++)))) _pp = (&(*(test2++)));
     __typeof__(*(&(*(test2++)))) _ptr = *_pp;

     *_pp = ((void *)0);
     if (_ptr)
        (g_free) (_ptr);
 } while (0) ;

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotestQemuMonitorJSONqemuMonitorJSONGetTargetArch: Fix uninitialized use of 'arch'
Peter Krempa [Thu, 5 Mar 2020 08:33:55 +0000 (09:33 +0100)]
testQemuMonitorJSONqemuMonitorJSONGetTargetArch: Fix uninitialized use of 'arch'

Refactor the cleanup control flow and use g_autofree for 'arch' so that
it's mandated that it's initialized.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agocmdDomHostname: Fix uninitialized use of 'hostname' by refactoring cleanup
Peter Krempa [Thu, 5 Mar 2020 08:29:02 +0000 (09:29 +0100)]
cmdDomHostname: Fix uninitialized use of 'hostname' by refactoring cleanup

Use 'g_autoptr' which mandates initialization for 'hostname' and also
for 'domain' to allow full refactor of the cleanup path.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirLXCProcessSetupNamespaceName: Fix potential uninitialized free of 'path'
Peter Krempa [Thu, 5 Mar 2020 08:25:35 +0000 (09:25 +0100)]
virLXCProcessSetupNamespaceName: Fix potential uninitialized free of 'path'

'path' could be accessed uninitialized. Fix it by using g_autofree which
also mandates initialization.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agovirNetworkPortDefSaveStatus: Fix potentially uninitialized 'path' by refactoring...
Peter Krempa [Thu, 5 Mar 2020 08:20:48 +0000 (09:20 +0100)]
virNetworkPortDefSaveStatus: Fix potentially uninitialized 'path' by refactoring cleanup

Use 'g_autofree' to clean both 'path' and 'xml' which mandates
initialization and get rid of the 'cleanup' label and 'ret variable.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agosrc: add pthread_np.h include for FreeBSD
Daniel P. Berrangé [Thu, 5 Mar 2020 15:13:45 +0000 (15:13 +0000)]
src: add pthread_np.h include for FreeBSD

On FreeBSD the non-portable pthread APIs need to be obtained
via the pthread_np.h header.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: improve thread naming with human targetted names
Daniel P. Berrangé [Fri, 14 Feb 2020 11:20:10 +0000 (11:20 +0000)]
src: improve thread naming with human targetted names

Historically threads are given a name based on the C function,
and this name is just used inside libvirt. With OS level thread
naming this name is now visible to debuggers, but also has to
fit in 15 characters on Linux, so function names are too long
in some cases.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agosrc: set the OS level thread name
Daniel P. Berrangé [Fri, 14 Feb 2020 10:44:01 +0000 (10:44 +0000)]
src: set the OS level thread name

Setting the thread name makes it easier to debug libvirtd
when many threads are running.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: drop ability to open monitor from FD
Daniel P. Berrangé [Wed, 12 Feb 2020 14:08:01 +0000 (14:08 +0000)]
qemu: drop ability to open monitor from FD

The qemuMonitorOpenFD method has not been used since it
was first introduced.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: drop support for agent connections on PTYs
Daniel P. Berrangé [Wed, 12 Feb 2020 11:45:10 +0000 (11:45 +0000)]
qemu: drop support for agent connections on PTYs

Libvirt has never configured the QEMU agent to support
running on a PTY implicitly. In theory an end user may
have written such an XML config, but this is reasonably
unlikely since when a bare <channel> is provided, libvirt
will auto-expand it to a UNIX socket backend.

With this change a user who has use the PTY backend will
have to switch to the UNIX backend if they wish to use
libvirt APIs for interacting with the agent. This will
not have guest ABI impact.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemuhotplugtestcpus: Always use 'query-cpus-fast'
Peter Krempa [Wed, 4 Mar 2020 11:19:39 +0000 (12:19 +0100)]
qemuhotplugtestcpus: Always use 'query-cpus-fast'

Use the new command in the test suite by asserting the capability
and adjusting test data to the correct field names as they changed
compared to 'query-cpus'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemuMonitorJSONSetMigrationParams: Refactor command construction and cleanup
Peter Krempa [Wed, 4 Mar 2020 09:10:56 +0000 (10:10 +0100)]
qemuMonitorJSONSetMigrationParams: Refactor command construction and cleanup

qemuMonitorJSONMakeCommandInternal does the full command construction if
you pass in what would become the value of the 'arguments' key. Refactor
the open-coded implementation to use the helper and use modern cleanup
helpers at the same time.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoutil: json: Convert virJSONValueNewObject() to g_new0
Peter Krempa [Wed, 4 Mar 2020 09:04:33 +0000 (10:04 +0100)]
util: json: Convert virJSONValueNewObject() to g_new0

Make it obvious that the function always returns a valid pointer and fix
all callers.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu_shim: Ignore SIGPIPE
Michal Privoznik [Fri, 28 Feb 2020 14:36:49 +0000 (15:36 +0100)]
qemu_shim: Ignore SIGPIPE

I've found that if my virtlogd is socket activated but the daemon
doesn't run yet, then the virt-qemu-run is killed right after it
tries to start the domain. The problem is that because the default
setting is to use virtlogd, the domain create code tries to
connect to virtlogd socket, which in turn tries to detect who is
connecting (virNetSocketGetUNIXIdentity()) and as a part of it,
it will try to open /proc/${PID_OF_SHIM}/stat which is denied by
SELinux:

  type=AVC msg=audit(1582903501.927:323): avc:  denied  { search } for  \
  pid=1210 comm="virtlogd" name="1843" dev="proc" ino=37224 \
  scontext=system_u:system_r:virtlogd_t:s0-s0:c0.c1023 \
  tcontext=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 tclass=dir \
  permissive=0

Virtlogd reacts by closing the connection which the shim sees as
SIGPIPE. Since the default response to the signal is Term, we
don't even get to reporting any error nor to removing the
temporary directory.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu_shim: Allow other users to enter the root dir
Michal Privoznik [Fri, 28 Feb 2020 13:42:44 +0000 (14:42 +0100)]
qemu_shim: Allow other users to enter the root dir

When virt-qemu-run is ran without any root directory specified on
the command line, a temporary directory is made and used instead.
But since we are using g_dir_make_tmp() to create the directory
it is going to have 0700 mode. So even though we create the whole
directory structure under it and label everything, QEMU is very
likely to not have the access. This is because in this case there
is no qemu.conf and thus distro default UID:GID is used to run
QEMU (e.g. qemu:kvm on Fedora). Change the mode of the temporary
directory so that everybody has eXecute permission.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: Don't compare local and remote hostnames on migration
Michal Privoznik [Tue, 25 Feb 2020 14:53:12 +0000 (15:53 +0100)]
qemu: Don't compare local and remote hostnames on migration

Libvirt tries to forbid migration onto the same host and it does
that by checking if local and remote hostnames are the same and
whether local and remote UUIDs are the same. Well, the latter
makes sense but the former doesn't really because libvirtd can be
running inside an UTS namespace and hostnames can appear the same
on both sides of migration. On the other hand, host UUIDs are
unique, so rely on them when trying to prevent migration onto the
same host.

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoadmin: use g_autofree
Gaurav Agrawal [Wed, 4 Mar 2020 18:06:13 +0000 (23:36 +0530)]
admin: use g_autofree

Signed-off-by: Gaurav Agrawal <agrawalgaurav@gnome.org>
[removed dead assignment]
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: do not include skipped tests in failedTests
Ján Tomko [Wed, 4 Mar 2020 15:48:27 +0000 (16:48 +0100)]
tests: do not include skipped tests in failedTests

We recognize three return values from tests:
* OK    -> 0
* SKIP  -> EXIT_AM_SKIP
* ERROR -> anything else

Also check for EXIT_AM_SKIP when building a bitmap of failed tests,
otherwise the skipped tests would be printed in the suggested range
of tests that shoud be re-run.

Reported-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: cebb468ef5e82b8d4253e27ef70c67812cf93c5a
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
5 years agoqemu: Don't request nested entries in qemuBlockGetNamedNodeData
Peter Krempa [Tue, 21 Jan 2020 15:51:40 +0000 (16:51 +0100)]
qemu: Don't request nested entries in qemuBlockGetNamedNodeData

Use the 'flat' flag for 'query-named-block-nodes' if qemu supports
QEMU_CAPS_QMP_QUERY_NAMED_BLOCK_NODES_FLAT in qemuBlockGetNamedNodeData.

We don't need the data so plumb in whether qemu supports the
'flat' output.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: monitor: Add 'flat' parameter for qemuMonitorJSONQueryNamedBlockNodes
Peter Krempa [Tue, 21 Jan 2020 15:42:49 +0000 (16:42 +0100)]
qemu: monitor: Add 'flat' parameter for qemuMonitorJSONQueryNamedBlockNodes

Modern qemu allows to skip the nested redundant data in the output of
query-named-block-nodes. Plumb in the support for the argument that
enables it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemuCheckpointDiscardBitmaps: Use qemuBlockGetNamedNodeData
Peter Krempa [Wed, 26 Feb 2020 11:50:53 +0000 (12:50 +0100)]
qemuCheckpointDiscardBitmaps: Use qemuBlockGetNamedNodeData

Replace qemuMonitorBlockGetNamedNodeData by qemuBlockGetNamedNodeData.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: monitor: Refactor variable cleanup in qemuMonitorJSONQueryNamedBlockNodes
Peter Krempa [Tue, 21 Jan 2020 15:33:12 +0000 (16:33 +0100)]
qemu: monitor: Refactor variable cleanup in qemuMonitorJSONQueryNamedBlockNodes

Use g_autoptr to get rid of the cleanup section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: capabilities: Add capability for the 'flat' argument of 'query-named-block...
Peter Krempa [Tue, 21 Jan 2020 14:13:47 +0000 (15:13 +0100)]
qemu: capabilities: Add capability for the 'flat' argument of 'query-named-block-nodes'

Detect the presence of the flag and make it available internally as
QEMU_CAPS_QMP_QUERY_NAMED_BLOCK_NODES_FLAT.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoqemu: monitor: Remove leftovers from password callback
Peter Krempa [Tue, 21 Jan 2020 13:54:37 +0000 (14:54 +0100)]
qemu: monitor: Remove leftovers from password callback

The monitor password callback was removed long time ago but the callback
type and variable were left around. Finish the cleanup.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agotests: qemucapabilities: Update capabilities of qemu-5.0.0 on x86_64
Peter Krempa [Thu, 23 Jan 2020 16:21:15 +0000 (17:21 +0100)]
tests: qemucapabilities: Update capabilities of qemu-5.0.0 on x86_64

Update to v4.2.0-1858-gdb736e0437 which contains my commit for 'flat'
output of 'query-named-block-nodes'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoconf: default to virtio bus for input passthrough
Ján Tomko [Tue, 25 Feb 2020 14:46:31 +0000 (15:46 +0100)]
conf: default to virtio bus for input passthrough

Other buses are not supported.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoconf: only allow virtio bus for input passthrough
Ján Tomko [Tue, 25 Feb 2020 14:44:23 +0000 (15:44 +0100)]
conf: only allow virtio bus for input passthrough

Other buses are not supported.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
https://bugzilla.redhat.com/show_bug.cgi?id=1724928
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
5 years agoqemu: build vhost-user-fs device command line
Ján Tomko [Tue, 6 Aug 2019 16:21:32 +0000 (18:21 +0200)]
qemu: build vhost-user-fs device command line

Format the 'vhost-user-fs' device on the QEMU command line.

This device provides shared file system access using the FUSE protocol
carried over virtio.
The actual file server is implemented in an external vhost-user-fs device
backend process.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: use the vhost-user schemas to find binary
Ján Tomko [Tue, 28 Jan 2020 14:38:52 +0000 (15:38 +0100)]
qemu: use the vhost-user schemas to find binary

Look into /usr/share/qemu/vhost-user to see whether we can find
a suitable virtiofsd binary, in case the user did not provide one
in the domain XML.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: put virtiofsd in the emulator cgroup
Ján Tomko [Tue, 18 Feb 2020 15:12:29 +0000 (16:12 +0100)]
qemu: put virtiofsd in the emulator cgroup

Wire up the code to put virtiofsd in the emulator cgroup on domain
startup.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: add code for handling virtiofsd
Ján Tomko [Fri, 1 Nov 2019 11:34:52 +0000 (12:34 +0100)]
qemu: add code for handling virtiofsd

Start virtiofsd for each <filesystem> device using it.

Pre-create the socket for communication with QEMU and pass it
to virtiofsd.

Note that virtiofsd needs to run as root.

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

Introduced by QEMU commit a43efa34c7d7b628cbf1ec0fe60043e5c91043ea

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: forbid migration with vhost-user-fs device
Ján Tomko [Thu, 30 Jan 2020 16:28:27 +0000 (17:28 +0100)]
qemu: forbid migration with vhost-user-fs device

This is not yet supported.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: validate virtiofs filesystems
Ján Tomko [Wed, 18 Dec 2019 16:46:54 +0000 (17:46 +0100)]
qemu: validate virtiofs filesystems

Reject unsupported configurations.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
5 years agoqemu: add virtiofsd_debug to qemu.conf
Ján Tomko [Wed, 11 Dec 2019 21:30:06 +0000 (22:30 +0100)]
qemu: add virtiofsd_debug to qemu.conf

Add a 'virtiofsd_debug' option for tuning whether to run virtiofsd
in debug mode.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
5 years agoconf: add virtiofs-related elements and attributes
Ján Tomko [Tue, 21 Jan 2020 07:14:46 +0000 (08:14 +0100)]
conf: add virtiofs-related elements and attributes

Add more elements for tuning the virtiofsd daemon
and the vhost-user-fs device:

  <driver type='virtiofs' queue='1024' xattr='on'>
    <binary path='/usr/libexec/virtiofsd'>
      <cache mode='always'/>
      <lock posix='off' flock='off'/>
    </binary>
  </driver>

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
5 years agoconf: qemu: add virtiofs fsdriver type
Ján Tomko [Tue, 16 Jul 2019 05:01:30 +0000 (07:01 +0200)]
conf: qemu: add virtiofs fsdriver type

Introduce a new 'virtiofs' driver type for filesystem.

<filesystem type='mount' accessmode='passthrough'>
  <driver type='virtiofs'/>
  <source dir='/path'/>
  <target dir='mount_tag'>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</filesystem>

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
5 years agodocs: add virtiofs kbase
Ján Tomko [Wed, 11 Dec 2019 12:10:07 +0000 (13:10 +0100)]
docs: add virtiofs kbase

Add a document describing the usage of virtiofs.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: add QEMU_CAPS_DEVICE_VHOST_USER_FS
Ján Tomko [Wed, 6 Feb 2019 12:29:00 +0000 (13:29 +0100)]
qemu: add QEMU_CAPS_DEVICE_VHOST_USER_FS

Introduced by QEMU commit 98fc1ada4cf70af0f1df1a2d7183cf786fc7da05
    virtio: add vhost-user-fs base device

Released in QEMU v4.2.0.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemuxml2xmltest: set driver as privileged
Ján Tomko [Wed, 26 Feb 2020 11:51:44 +0000 (12:51 +0100)]
qemuxml2xmltest: set driver as privileged

Some validation check might reject unprivileged drivers in the future.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemu: pass virDomainObjPtr to qemuExtDevicesSetupCgroup
Ján Tomko [Wed, 26 Feb 2020 11:45:02 +0000 (12:45 +0100)]
qemu: pass virDomainObjPtr to qemuExtDevicesSetupCgroup

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
5 years agoqemuExtDevicesStart: pass logManager
Ján Tomko [Sat, 25 Jan 2020 17:35:13 +0000 (18:35 +0100)]
qemuExtDevicesStart: pass logManager

Pass logManager to qemuExtDevicesStart for future usage.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
5 years agoschema: wrap fsDriver in a choice group
Ján Tomko [Tue, 21 Jan 2020 08:02:58 +0000 (09:02 +0100)]
schema: wrap fsDriver in a choice group

Allow adding new groups without changing indentation.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Tested-by: Andrea Bolognani <abologna@redhat.com>
5 years agogitdm: Add missing entries
Andrea Bolognani [Fri, 28 Feb 2020 18:25:39 +0000 (19:25 +0100)]
gitdm: Add missing entries

A few new companies have contributed to libvirt since the last
time the gitdm configuration was updated.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agogitdm: Fix sorting
Andrea Bolognani [Fri, 28 Feb 2020 18:25:32 +0000 (19:25 +0100)]
gitdm: Fix sorting

Fixes: 3a3a85c529e92ad767fb2222e01587186854c175
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agogitdm: Add entry for example.com
Andrea Bolognani [Fri, 28 Feb 2020 18:29:02 +0000 (19:29 +0100)]
gitdm: Add entry for example.com

We already have one instance of it being used in our git history,
and more are probably bound to show up eventually.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agoci: Drop handling of $PKG_CONFIG_LIBDIR
Andrea Bolognani [Tue, 25 Feb 2020 14:41:23 +0000 (15:41 +0100)]
ci: Drop handling of $PKG_CONFIG_LIBDIR

As of libvirt-jenkins-ci commit e41e341f0d8f, we no longer bake
this environment variable into our container images.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agomaint: Post-release version bump to 6.2.0
Michal Privoznik [Wed, 4 Mar 2020 09:32:58 +0000 (10:32 +0100)]
maint: Post-release version bump to 6.2.0

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoRelease of libvirt-6.1.0
Daniel Veillard [Tue, 3 Mar 2020 13:14:08 +0000 (14:14 +0100)]
Release of libvirt-6.1.0

* docs/news.xml: updated for the release

Signed-off-by: Daniel Veillard <veillard@redhat.com>
5 years agonews: Update for libvirt 6.1.0
Andrea Bolognani [Fri, 28 Feb 2020 17:50:51 +0000 (18:50 +0100)]
news: Update for libvirt 6.1.0

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agonews: Document recent storage improvements
Peter Krempa [Thu, 27 Feb 2020 08:38:06 +0000 (09:38 +0100)]
news: Document recent storage improvements

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agokbase: backing_chains: Add steps how to securely probe image format
Peter Krempa [Thu, 27 Feb 2020 08:08:26 +0000 (09:08 +0100)]
kbase: backing_chains: Add steps how to securely probe image format

We document steps how to fix images if they are rejected for missing
the 'backing file format' field. Document also how to securely probe
the image format if it's unknown.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
5 years agodaemon: set default memlock limit for systemd service
Pavel Hrdina [Wed, 26 Feb 2020 12:23:00 +0000 (13:23 +0100)]
daemon: set default memlock limit for systemd service

The default memlock limit is 64k which is not enough to start a single
VM. The requirements for one VM are 12k, 8k for eBPF map and 4k for eBPF
program, however, it fails to create eBPF map and program with 64k limit.
By testing I figured out that the minimal limit is 80k to start a single
VM with functional eBPF and if I add 12k I can start another one.

This leads into following calculation:

80k as memlock limit worked to start a VM with eBPF which means there
is 68k of lock memory that I was not able to figure out what was using
it.  So to get a number for 4096 VMs:

        68 + 12 * 4096 = 49220

If we round it up we will get 64M of memory lock limit to support 4096
VMs with default map size which can hold 64 entries for devices.

This should be good enough as a sane default and users can change it if
the need to.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: document port isolated property in domain/network/networkport
Laine Stump [Wed, 26 Feb 2020 00:47:07 +0000 (19:47 -0500)]
docs: document port isolated property in domain/network/networkport

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agodocs: fix docs about bandwidth setting with bridge networks
Daniel P. Berrangé [Tue, 25 Feb 2020 15:49:03 +0000 (15:49 +0000)]
docs: fix docs about bandwidth setting with bridge networks

We now support setting bandwidth on networks with type bridge.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: Do not set default CPU for archs without CPU driver
Jiri Denemark [Tue, 25 Feb 2020 15:05:06 +0000 (16:05 +0100)]
qemu: Do not set default CPU for archs without CPU driver

Whenever there is a guest CPU configured in domain XML, we will call
some CPU driver APIs to validate the CPU definition and check its
compatibility with the hypervisor. Thus domains with guest CPU
specification can only be started if the guest architecture is supported
by the CPU driver. But we would add a default CPU to any domain as long
as QEMU reports it causing failures to start any domain on affected
architectures.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agokbase: backing_chains: Clarify some aspects of image probing
Peter Krempa [Tue, 25 Feb 2020 12:39:42 +0000 (13:39 +0100)]
kbase: backing_chains: Clarify some aspects of image probing

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agovirStorageFileGetMetadataRecurse: Allow format probing under special circumstances
Peter Krempa [Mon, 17 Feb 2020 09:08:25 +0000 (10:08 +0100)]
virStorageFileGetMetadataRecurse: Allow format probing under special circumstances

Allow format probing to work around lazy clients which did not specify
their format in the overlay. Format probing will be allowed only, if we
are able to probe the image, the probing result was successful and the
probed image does not have any backing or data file.

This relaxes the restrictions which were imposed in commit 3615e8b39bad
in cases when we know that the image probing will not result in security
issues or data corruption.

We perform the image format detection and in the case that we were able
to probe the format and the format does not specify a backing store (or
doesn't support backing store) we can use this format.

With pre-blockdev configurations this will restore the previous
behaviour for the images mentioned above as qemu would probe the format
anyways. It also improves error reporting compared to the old state as
we now report that the backing chain will be broken in case when there
is a backing file.

In blockdev configurations this ensures that libvirt will not cause data
corruption by ending the chain prematurely without notifying the user,
but still allows the old semantics when the users forgot to specify the
format.

Users thus don't have to re-invent when image format detection is safe
to do.

The price for this is that libvirt will need to keep the image format
detector still current and working or replace it by invocation of
qemu-img.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoqemu: domain: Convert detected 'iso' image format into 'raw'
Peter Krempa [Tue, 25 Feb 2020 12:28:10 +0000 (13:28 +0100)]
qemu: domain: Convert detected 'iso' image format into 'raw'

While our code can detect ISO as a separate format, qemu does not use it
as such and just passes it through as raw. Add conversion for detected
parts of the backing chain so that the validation code does not reject
it right away.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agoconf: include virnetworkportdef.h in domain_conf.h
Ján Tomko [Mon, 17 Feb 2020 17:51:55 +0000 (18:51 +0100)]
conf: include virnetworkportdef.h in domain_conf.h

Now that this file no longer transitively includes
domain_conf.h, it can be included here.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: reduce includes in virnetworkportdef.h
Ján Tomko [Sat, 22 Feb 2020 16:01:14 +0000 (17:01 +0100)]
conf: reduce includes in virnetworkportdef.h

All the _conf includes are only needed in the C file.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: do not pass vm object to virDomainClearNetBandwidth
Ján Tomko [Mon, 17 Feb 2020 17:37:25 +0000 (18:37 +0100)]
conf: do not pass vm object to virDomainClearNetBandwidth

This function only uses the domain definition.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: virNetDevSupportsBandwidth: move into the C file
Ján Tomko [Mon, 17 Feb 2020 17:35:37 +0000 (18:35 +0100)]
conf: virNetDevSupportsBandwidth: move into the C file

Make the header easier to read and let the compiler inline
what it wants.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: rename virNetDevSupportBandwidth to virNetDevSupportsBandwidth
Ján Tomko [Mon, 17 Feb 2020 17:17:23 +0000 (18:17 +0100)]
conf: rename virNetDevSupportBandwidth to virNetDevSupportsBandwidth

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Pavel Mores <pmores@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: virnetworkportdef: include virnetdevmacvlan
Ján Tomko [Sat, 22 Feb 2020 16:08:57 +0000 (17:08 +0100)]
conf: virnetworkportdef: include virnetdevmacvlan

This is pulled in via domain_conf.h somehow, but it is directly used.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agobridge: include netdev_bandwidth_conf.h
Ján Tomko [Sat, 22 Feb 2020 15:57:50 +0000 (16:57 +0100)]
bridge: include netdev_bandwidth_conf.h

This file uses the virNetDevBandwidth*Floor helpers
without including the correct include,
relying on virnetworkportdef.h to include it.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 17f430eb5cfaaa3388077f2b0856f011f0b2a4c3
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agoconf: virnwfilterbindingdef: include virxml.h
Ján Tomko [Sun, 16 Feb 2020 22:09:05 +0000 (23:09 +0100)]
conf: virnwfilterbindingdef: include virxml.h

The ParseNode function takes arguments with types
from libxml.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
5 years agotests: fix missing test data for network port XML
Daniel P. Berrangé [Tue, 25 Feb 2020 11:08:41 +0000 (11:08 +0000)]
tests: fix missing test data for network port XML

The network port XML files were not including any usage of vlan
tags or port options, and one of the files was not even processed.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
5 years agolxc: Replacing default strings definitions by g_autofree statement
Julio Faracco [Mon, 24 Feb 2020 14:24:27 +0000 (11:24 -0300)]
lxc: Replacing default strings definitions by g_autofree statement

There are a lots of strings being handled inside some LXC functions.
They can be moved to g_autofree to avoid declaring a return value to get
proper code cleanups. This commit is changing functions from
lxc_{controller,cgroup,fuse} only.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
5 years agotests: libxl: do not run the emulator
Ján Tomko [Sat, 22 Feb 2020 12:56:19 +0000 (13:56 +0100)]
tests: libxl: do not run the emulator

Ever since commit c5a00350 the libxl parser invokes the emulator
to probe which device model to use.

Commit b90c4b5 introduced a workaround that used a stable path
which was very likely to result in the answer matching the default.
However the test is still affected by the host state and the binary
gets invoked if present.

Mock the libxlDomainGetEmulatorType function to stop wasting CPU
cycles every time a 'make check' is run on a system with xen installed.

For example xlconfigtest gets faster by 90 %

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: b90c4b5f505698d600303c5b4f03f5d229b329dd
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
5 years agotests: link the libxl tests with libxltestdriver.la
Ján Tomko [Sat, 22 Feb 2020 13:51:05 +0000 (14:51 +0100)]
tests: link the libxl tests with libxltestdriver.la

This lets us mock functions from the libxl driver.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
5 years agolibxl: do not mock virFileMakePath
Ján Tomko [Sat, 22 Feb 2020 12:12:17 +0000 (13:12 +0100)]
libxl: do not mock virFileMakePath

Point the logDir to abs_builddir instead.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
5 years agolibxl: split out DriverConfigInit out of DriverConfigNew
Ján Tomko [Sat, 22 Feb 2020 12:01:38 +0000 (13:01 +0100)]
libxl: split out DriverConfigInit out of DriverConfigNew

Take the parts affected by the host state out of DriverConfigNew
and put them into a separate function.

Adjust all the callers to call both functions.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
5 years agolibxl: StateInitialize: use g_autofree
Ján Tomko [Sat, 22 Feb 2020 12:02:27 +0000 (13:02 +0100)]
libxl: StateInitialize: use g_autofree

Use g_autofree to free the driver config file path.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
5 years agolibxl: conf: move default keepalive settings to libxlDriverConfigNew
Ján Tomko [Sat, 22 Feb 2020 12:02:18 +0000 (13:02 +0100)]
libxl: conf: move default keepalive settings to libxlDriverConfigNew

These hardcoded defaults do not need to be read from
the file. Move them out of libxlDriverConfigLoadFile.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
5 years agotestutilsxen: error out on initialization failure
Ján Tomko [Sat, 22 Feb 2020 11:44:45 +0000 (12:44 +0100)]
testutilsxen: error out on initialization failure

libxlDriverConfigNew can possibly fail on wrong
firmware values (unlikely) or on failure to create
the log directory (possible if you're debugging
tests with VIR_FILE_ACCESS)

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Fixes: 4a4132b4625778cf80acb9c92d06351b44468ac3
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
5 years agosecurity: Don't fail if locking a file on NFS mount fails
Michal Privoznik [Thu, 20 Feb 2020 14:38:43 +0000 (15:38 +0100)]
security: Don't fail if locking a file on NFS mount fails

The way that our file locking works is that we open() the file we
want to lock and then use fcntl(fd, F_SETLKW, ...) to lock it.
The problem is, we are doing all of these as root which doesn't
work if the file lives on root squashed NFS, because if it does
then the open() fails. The way to resolve this is to make this a
non fatal error and leave callers deal with this (i.e. disable
remembering) - implemented in the previous commit.

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>