Commit Graph

34721 Commits

Author SHA1 Message Date
Marc-André Lureau
ddd40dba12 tests: mock execv/execve
Learn to override the paths to the program to execute (vhost-user
helpers are executed to check for runtime capabilities).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-09-24 13:19:09 -04:00
Marc-André Lureau
fc91a182d7 qemu: add vhost-user-gpu helper unit
Similar to the qemu_tpm.c, add a unit with a few functions to
start/stop and setup the cgroup of the external vhost-user-gpu
process. See function documentation.

The vhost-user connection fd is set on qemuDomainVideoPrivate struct.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-09-24 13:19:09 -04:00
Marc-André Lureau
ca60ecfa8c qemu: add qemuDomainVideoPrivate
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-09-24 13:19:09 -04:00
Marc-André Lureau
3dbf3941ad conf: add privateData to virDomainVideoDef
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-09-24 13:19:08 -04:00
Marc-André Lureau
019db0d944 qemu: add qemuSecurityStartVhostUserGPU helper
See function documentation. Used in a following patch.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-09-24 13:19:08 -04:00
Marc-André Lureau
13248e1688 qemu: add vhost-user helpers
Add qemuVhostUserFetchConfigs() to discover vhost-user helpers.

qemuVhostUserFillDomainGPU() will find the first matching GPU helper
with the required capabilities and set the associated
vhost_user_binary.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-09-24 13:19:08 -04:00
Marc-André Lureau
d27abda98d qemu: restrict 'virgl=' option to non-vhostuser video type
vhost-user device doesn't have a virgl option, it is passed to the
vhost-user-gpu helper process instead.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-09-24 12:30:33 -04:00
Marc-André Lureau
c3d0831745 qemu: validate virtio-gpu with vhost-user
Check qemu capability, and accept 3d acceleration. 3d acceleration
support is checked when looking for a suitable vhost-user helper.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
2019-09-24 12:30:02 -04:00
Marc-André Lureau
6396a478f4 qemu: check that qemu is vhost-user-vga capable
To support virtio VGA with vhost-user, vhost-user-vga device is necessary.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-09-24 12:29:33 -04:00
Marc-André Lureau
86e068e5d6 qemu: add vhost-user-gpu capabilities checks
Those new devices are available since QEMU 4.1.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-09-24 12:29:29 -04:00
Marc-André Lureau
fe3b720687 qemu-cgroup: allow accel rendernode access
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-09-24 12:17:39 -04:00
Marc-André Lureau
1394bf1091 domain: add rendernode attribute on <accel>
vhost-user-gpu helper takes --render-node option to specify on which
GPU should the renderning be done.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-09-24 12:17:39 -04:00
Marc-André Lureau
bc1e924cf0 conf: format/parse/rng/docs for video <driver name='qemu|vhostuser'/>
Accept a new driver name attribute to specify usage of helper process, ex:

  <video>
    <driver name='vhostuser'/>
    <model type='virtio'/>
  </video>

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-09-24 12:17:39 -04:00
Marc-André Lureau
58a76d45ca qemu: generalize qemuFetchConfigs
The same config files disovery & priority rules are used for
vhost-user backends.

No functional change, the only difference is that
qemuInteropFetchConfigs() takes a "name" argument and construct paths
with it (ex: "firmware").

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-09-24 12:17:10 -04:00
Daniel P. Berrangé
ada268012a build: force a UTF-8 locale for python
Python3 versions less than 3.7 have very unhelpful handling
of the C locale where they assume data is 7-bit only. This
violates POSIX which requires the C locale to be 8-bit clean.
Python3 >= 3.7 now assumes that the C locale is always UTF-8.

Set env variables to force LC_CTYPE to en_US.UTF-8 so that
we get UTF-8 handling on all python versions. Note we do
not use C.UTF-8 since not all C libraries support that.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-09-24 15:46:22 +01:00
Daniel P. Berrangé
851dba3f47 build: ensure Makefile.inc.am is checked for long lines
The filename match rule was accidentally excluding the
Makefile.inc.am files from the long lines check.

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-09-24 11:50:27 +01:00
Daniel Henrique Barboza
87ecf62d4c qemu: hotplug: Use VIR_AUTOFREE() instead VIR_FREE for strings
Cleanup labels are also dropped where possible.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-09-23 18:33:10 +02:00
Peter Krempa
15340ff583 qemu: snapshot: Do ACL check prior to checkpoint interlocking
Commit 7efe930ec3 introduced interlock of snapshots and checkpoints,
but the check is executed prior to the snapshot API ACL check. This
means that an unauthorized user can see whether a VM exists if it has a
checkpoint.

Move the checks to proper places.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
2019-09-23 16:42:54 +02:00
Erik Skultety
8e02fa2e25 docs: kbase: Add a section explaining how to verify SEV from the guest
Commit 50dfabbb59 forgot to add this important bit on how to check that
all the changes to the XML actually worked.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-09-23 10:19:15 +02:00
Daniel Henrique Barboza
e1d5390224 qemu_domain_address: use virPCIDeviceAddressEqual() in conditionals
A common operation in qemu_domain_address is comparing a
virPCIDeviceAddress and assigning domain, bus, slot and function
to a specific value. The former can be done with the existing
virPCIDeviceAddressEqual() helper, as long as we provide
a virPCIDeviceAddress to compare it to.

The later can be done by direct assignment of the now existing
virPCIDeviceAddress struct. The defined values of domain, bus,
slot and function will be assigned to info->addr.pci, the other
values are zeroed (which happens to be their default values too).
It's also worth noticing that all these assignments are being
conditioned by virDeviceInfoPCIAddressIsPresent() calls, thus it's
sensible to discard any non-zero values that might happen to exist
in @cont->info.addr, if we settled beforehand that @cont->info.addr
is not present or bogus.

Suggested-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-09-23 09:11:14 +02:00
Daniel Henrique Barboza
06709296cb qemu_domain_address.c: use VIR_AUTOFREE() in strings
A few 'cleanup' labels gone after using VIR_AUTOFREE() on the
@addrStr variable.

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2019-09-23 08:50:58 +02:00
Laine Stump
b22749334d conf: reattach interface taps to correct bridge on restart
When the bridge re-attach handling was moved out of the network driver
and into the hypervisor driver (commit b806a60e) as a part of the
refactor to split the network driver into a separate daemon, the check
was accidentally changed to only check for type='bridge'. The check for
type in this case needs to check for type='network' as well.

(at the time we thought that the two types could be conflated for
interface actual type, but this turned out to be too problematic to
do).

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2019-09-20 11:42:25 -04:00
Daniel P. Berrangé
d6aaa639e4 remote: fix enablement of IP networking in virtproxyd
This fixes

    commit b7ed8ce981
    Author: Daniel P. Berrangé <berrange@redhat.com>
    Date:   Thu Jul 4 12:33:23 2019 +0100

      remote: introduce virtproxyd daemon to handle IP connectivity

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-09-20 15:02:40 +01:00
Daniel P. Berrangé
ad6189389d gnulib: remove uneccessary func module
The gnulib 'func' modules provides portability to compilers which lack
the '__func__' symbol. We only care about GCC and CLang compilers so do
not need this compatibility code.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-09-20 15:02:37 +01:00
Daniel P. Berrangé
b56ce7b85d gnulib: remove unused secure_getenv function replacement
We removed use of the secure_getenv recently in

  commit 2b0d597670
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Thu Aug 1 13:35:56 2019 +0100

    util: get rid of virGetEnv{Allow,Block}SUID functions

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2019-09-20 15:02:27 +01:00
Peter Krempa
a3b728f860 qemu: monitor: Remove qemuMonitorHMPCommand in favor of qemuMonitorJSONHumanCommand
Use the function directly rather than having a wrapper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-09-20 08:41:50 +02:00
Peter Krempa
19f8309a3b qemu: monitor: Don't handle HMP in qemuMonitorJSONArbitraryCommand
Call to qemuMonitorJSONHumanCommand directly from
qemuMonitorArbitraryCommand.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-09-20 08:41:50 +02:00
Peter Krempa
1155a5721b qemu: monitor: Don't include text monitor in json monitor
It was necessary for fallback functions but last one was deleted in
d828b744ac.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-09-20 08:41:50 +02:00
Peter Krempa
534daeef82 qemu: monitor: Remove HMP command (un)escaping infrastructure
We don't need to escape the commands any more since we use QMP
passthrough, which means we can delete the functions.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-09-20 08:41:50 +02:00
Peter Krempa
d6fc3b937b qemu: monitor: Don't escape HMP commands just to unescape them right away
Historically HMP commands needed to be escaped to work properly.

The backdoor for calling HMP commands via QMP must unescape them so that
arguments aren't messed up.

Since we now only support the QMP passthrough the escape->unescape dance
is pointless.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-09-20 08:41:50 +02:00
Peter Krempa
4fbdebea40 qemu: monitor: Remove support for HMP commands with fds
The remaining HMP commands don't require fd passing so we can purge
filedescriptor passing support from qemuMonitorJSONHumanCommandWitFd and
rename it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-09-20 08:41:50 +02:00
Peter Krempa
46a276b277 qemu: monitor: Remove qemuMonitorHMPCommand macro
qemuMonitorHMPCommandWithFd is only called via qemuMonitorHMPCommand
macro, so we can remove the macro and the extra unused cruft from the
function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-09-20 08:41:50 +02:00
Peter Krempa
6acda58495 qemu: monitor: Remove legacy monitor commands for FD manipulation
The handlers for 'add-fd' and 'remove-fd' are unused now and riddled
with legacy cruft. Purge them.

Last use was removed in f2019083de.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-09-20 08:41:50 +02:00
Xu Yandong
d72ed16ba7 qemuCheckDiskConfigAgainstDomain: Validate disk's SCSI address iff disk is SCSI
Check the disk SCSI address only when the disk actually is of
SCSI type.

Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2019-09-19 16:32:56 +02:00
Xu Yandong
5f646ffda0 qemuSharedDeviceEntryRemove: Free domain name before VIR_DELETE_ELEMENT
The macro VIR_DELETE_ELEMENT assume that the items being deleted
have already been cleared, so we must explicitly free domain name
from the list of domains using the shared device to prevent a
memory leak.

Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2019-09-19 16:32:56 +02:00
Xu Yandong
89d724b157 object_event: reference state only if virEventAddTimeout succeeded
When registering new callback for an event, the event loop timer
must be created and registered. The timer has domain event state
object as an opaque argument which must be ref()-ed but only if
the timer was being created and registered successfully. We must
not ref it every time the virObjectEventStateRegisterID() runs.

Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2019-09-19 16:32:52 +02:00
Xu Yandong
b030f35e40 remote: fix a memory free error
In function remoteDeserializeDomainDiskErrors, there is a typo.

Signed-off-by: Xu Yandong <xuyandong2@huawei.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2019-09-19 16:15:50 +02:00
Peter Krempa
56c56b3bf8 Revert "configure: Colorize output"
The colors are not based on the semantics of the message but rather
on the message itself. This means that the default human-perceived
semantics (red = bad, green = good) don't really apply and spotting a
color does not mean anythting.

This is amplified by the sheer amount of output which configure produces
and the fact that some of the messages have negative semantics or
additional output.

In case of any problem the user will have to go through everything
anyways as spotting a red or yellow line has 0 information value.

Here are a few examples:

1) some 'no' messages are not a problem:

  checking minix/config.h presence... no

2) some 'no' messages are actually positive:

  checking for special C compiler options needed for large files... no

3) in some cases a 'yes' would mean that something is broken or needs
   workaround

  checking whether stat file-mode macros are broken... no
  checking whether wint_t is too small... no
  checking whether stdint.h predates C++11... no
  checking whether the inttypes.h PRIxNN macros are broken... no
  checking whether clang gives bogus warnings for -Wdouble-promotion... no
  checking whether gettimeofday clobbers localtime buffer... no

4) due to string match based colors extra text makes messages yellow

  checking for a traditional french locale... none
  checking for working nanosleep... no (mishandles large arguments)
  checking for library containing gethostbyname... none required
  checking whether mbrtowc handles incomplete characters... (cached) guessing yes

5) in some cases the yes/no is very context dependant

  checking whether pthread_rwlock_rdlock prefers a writer to a reader... no
  checking whether this build is done by a static analysis tool... no

6) detected paths to binaries and libs are yellow despite being present

  checking for objdump... objdump
  checking for atomic ops implementation... gcc

As of the reasons above I don't think the colorization of the configure
output helps users or developers to debug the build process and
thus is not worth the extra code or output clutter.

This reverts commit c98174ce08.

ACKed-by: Michal Prívozník <mprivozn@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2019-09-19 14:31:15 +02:00
Peter Krempa
1a1c293ec6 Revert "virt-result.m4: Colourize summary printings"
The colorization based on the string itself makes little to no sense as
the semantic meaning of the color (red = bad, green = good) is not
extracted from the semantics of the message:

1) If there is some additional string a 'yes' is marked yellow:

configure:       driver_modules: yes (CFLAGS='' LIBS='-ldl')

2) In some cases a 'no' is actually good:

configure:                  hal: no

3) Few good/recommended configuration options are still yellow:

configure:                 QEMU: qemu:qemu

while using 'root:root' would still be yellow.

4) fields dumping config (e.g. the warning flags line) is a giant blob
  of colored text which makes little sense

configure:        Warning Flags:  -fno-common -W -Wabsolute-value
-Waddress -Waddress-of-packed-member -Waggressive-loop-optimizations
-Wall -Wattribute-warning -Wattributes -Wbad-function-cast
-Wbool-compare -Wbool-operation -Wbuiltin-declaration-mismatch
-Wbuiltin-macro-redefined -Wcannot-profile -Wcast-align
-Wcast-align=strict -Wcast-function-type -Wchar-subscripts -Wclobbered
-Wcomment -Wcomments -Wcoverage-mismatch -Wcpp -Wdangling-else
-Wdate-time -Wdeprecated-declarations -Wdesignated-init
-Wdiscarded-array-qualifiers -Wdiscarded-qualifiers -Wdiv-by-zero
-Wdouble-promotion -Wduplicated-cond -Wduplicate-decl-speci ...

In addition if the idea is to switch to a more usable build system it
does not make sense to clutter the current one with more code.

This reverts commit 4b3ab5d213.

ACKed-by: Michal Prívozník <mprivozn@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2019-09-19 14:31:15 +02:00
Peter Krempa
47b35f4d0e conf: secret: Refactor cleanup in secretXMLParseNode
Use VIR_AUTO* for temporary locals and get rid of the 'cleanup' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-09-19 14:31:15 +02:00
Peter Krempa
8d301bd435 conf: secret: Register VIR_AUTOPTR function for virSecretDef
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-09-19 14:31:15 +02:00
Peter Krempa
db2c3c80c2 conf: domain: Refactor cleanup in virDomainDefParseNode
Use VIR_AUTOPTR for temporary locals and get rid of the cleanup label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-09-19 14:31:15 +02:00
Peter Krempa
f02b4fc4ea conf: domain: Register VIR_AUTOPTR function for virDomainDef
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-09-19 14:31:15 +02:00
Peter Krempa
a8de158713 conf: Use VIR_AUTOPTR for xmlDoc and xmlXPath objects
Refactor functions using these two object types together with
VIR_AUTOPTR.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-09-19 14:31:15 +02:00
Peter Krempa
8aa2233099 conf: Use automatic pointers for xmlXPathContext
Clean up functions which grab and free the context to use VIR_AUTOPTR.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-09-19 14:31:15 +02:00
Peter Krempa
475777c9ec conf: Refactor resource cleanup in virDomainDeviceDefParse
Use VIR_AUTO* helpers to get rid of the convoluted cleanup path.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-09-19 14:31:15 +02:00
Peter Krempa
8944f261f5 conf: network: Use VIR_AUTOPTR in virNetworkDefUpdateSection
Add automatic cleanup for variables of xmlDoc and xmlXPathContext type
to remove the cleanup section.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-09-19 14:31:15 +02:00
Peter Krempa
bfedd14955 util: xml: Add wrapper for xmlXPathNewContext
The wrapper reports libvirt errors for the libxml2 function so that
the same does not have to be repeated over and over.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
2019-09-19 14:31:15 +02:00
Peter Krempa
73aaa8f8c8 virsh: Don't open-code virJSONStringReformat in cmdQemuMonitorCommand
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-09-19 14:31:15 +02:00
Peter Krempa
d2335ac577 virsh: Use VIR_AUTO machinery in cmdQemuMonitorCommand
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2019-09-19 14:31:15 +02:00