Commit Graph

27852 Commits

Author SHA1 Message Date
Michal Privoznik
937f319536 qemuBuildDeviceAddressStr: Prefer default alias for PCI bus
https://bugzilla.redhat.com/show_bug.cgi?id=1434451

Just like in 9324f67a57 we need to put default pci-root
alias onto the command line instead of the one provided by user.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-11-20 10:35:03 +01:00
Michal Privoznik
f66e5896ad qemuBuildDriveDevStr: Prefer default alias for SATA bus
https://bugzilla.redhat.com/show_bug.cgi?id=1434451

Just like in 9324f67a57 we need to put default sata alias
(which is hardcoded to "ide", obvious, right?) onto the command
line instead of the one provided by user.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-11-20 10:35:03 +01:00
Michal Privoznik
481f8fdca1 virQEMUCapsHasPCIMultiBus: Fix @def type
This function only queries domain @def. It doesn't change it.
Therefore it should take const pointer.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-11-20 10:35:03 +01:00
Andrea Bolognani
18dfc00145 conf,qemu: Use type-aware switches where possible
The compiler can warn us if we add a value to the
virDomainChrSerialTargetType enumeration but forget to handle
it properly in the code. Let's take advantage of that.

This commit is best viewed with 'git diff -w'.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-20 10:14:44 +01:00
Pino Toscano
593639ffff qemu: add QEMU_CAPS_DEVICE_SCLPLMCONSOLE
Add a separate capability for the sclplmconsole device, and check it
specifically instead of using QEMU_CAPS_DEVICE_SCLPCONSOLE for that too.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2017-11-20 10:13:53 +01:00
Pino Toscano
98b55862ef qemu: rename QEMU_CAPS_SCLP_S390 to QEMU_CAPS_DEVICE_SCLPCONSOLE
Give a better name to the capability for the sclpconsole device.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2017-11-20 10:13:45 +01:00
Andrea Bolognani
87eabeb17d qemu: Add QEMU_CAPS_DEVICE_SPAPR_VTY
Up until now we assumed the spapr-vty device would always be
present, which is not very nice. Check for its availability before
using it instead.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-20 10:13:32 +01:00
intrigeri
3343ab0cd9 AppArmor: add mount rules needed with additional mediation features brought by Linux 4.14
This set of rules was proposed by Christian Boltz <apparmor@cboltz.de>
on https://bugzilla.opensuse.org/show_bug.cgi?id=1065123.
2017-11-19 19:16:27 +01:00
intrigeri
3b1d19e6c9 AppArmor: add rules needed with additional mediation features brought by Linux 4.14. 2017-11-19 19:16:27 +01:00
John Ferlan
2f3054c22a libvirtd: Fix order of cleanup processing
Current cleanup processing is ad-hoc at best - it's led to a couple of
strange and hard to diagnose timing problems and crashes.

So rather than perform cleanup in a somewhat random order, let's
perform cleanup in the exact opposite order of startup.

NB: It is possible that virNetlinkEventServerStart fails and we jump
to cleanup before driversInitialized has been set. That could leave
things inconsistent; however, resolution of that possibility is perhaps
more trouble than it's worth to handle.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-11-18 07:51:43 -05:00
John Ferlan
723cadd9ff libvirtd: Alter order of virNetDaemonNew
Let's be sure we can get a Daemon object before the server object.
This is a more "orderly" way to do things since the svr object would
be added to the dmn object afterwards.
2017-11-18 07:51:43 -05:00
John Ferlan
b5726b7ee9 libvirtd: Move pid_file_fd setup to before run_dir
Once we have forked the daemon successfully, let's claim the pidfile
immediately rather than waiting for setup of run_dir.
2017-11-18 07:51:43 -05:00
Marc-André Lureau
13f5903919 news: add vmcoreinfo feature details
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-11-18 10:45:10 +01:00
Marc-André Lureau
7e4177a35b qemu: add vmcoreinfo support
Starting from qemu 2.11, the `-device vmcoreinfo` will create a fw_cfg
entry for a guest to store dump details, necessary to process kernel
dump with KASLR enabled and providing additional kernel details.

In essence, it is similar to -fw_cfg name=etc/vmcoreinfo,file=X but in
this case it is not backed by a file, but collected by QEMU itself.

Since the device is a singleton and shouldn't use additional hardware
resources, it is presented as a <feature> element in the libvirt
domain XML.

The device is arm/x86 only for now (targets that support fw_cfg+dma).

Related to:
https://bugzilla.redhat.com/show_bug.cgi?id=1395248

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2017-11-18 10:45:10 +01:00
Martin Kletzander
d807014563 tests: Add resctrl-skx-twocaches test case to vircaps2xmltest
This doesn't add very much value for now, but future test for virresctrl will
take information from vircaps2xmldata (since it is dependent on the same info
then why duplicate it) and this particular use case helps us cover bit more of
the code regarding proper formatting and handling errors.  And one more test for
vircaps2xmltest doesn't hurt either.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-18 10:45:10 +01:00
Martin Kletzander
993c7f0030 tests: Minor adjustments for test data
This patch modifies some not yet used test data so that the adding a test using
this data is a clean patch and not an addition of huge file with some
adjustments in small files that will be hidden in the middle of that commit.
These changes include:

- Add system dir in vircaps2xmldata/linux-caches

  Back when data for systems with resctrl support were added they had the
  /sys/fs/system directory put into a system/ subdir of the test and
  /sys/fs/resctrl in a resctrl/ subdir of that test.  However, if we also want a
  negative test for the resctrl (requesting allocation on a system that does not
  support resctrl), we need one a test case with any sensible (with cache info)
  system/ subdir and no resctrl/ one.  Easiest way is to add a
  system -> . symlink into existing test case.

- Change default group schemata for linux-resctrl and linux-resctrl-cdp

  That way we can fit some allocation in.

- Remove one cache from resctrl-skx's schemata and make some room for
  allocations

  That system already has only one cache, so that file was wrong anyway.  We
  have a version with 2 caches already (linux-resctrl-skx-twocaches), so this
  will also add variety to future tests.

- Add some empty allocation for resctrl-skx

  Just to have slightly more coverage and variety.  We can be sure nothing bad
  happens if such allocation exists in case we have that in the tests.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-11-18 10:45:10 +01:00
Martin Kletzander
02e822e041 tests: Remove executable bits on plain data files
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-18 10:45:10 +01:00
Martin Kletzander
63d95a19cc conf: Format cache banks in capabilities with virFormatIntPretty
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-18 10:45:10 +01:00
Martin Kletzander
b4698edcb0 conf: Sort cache banks in capabilities XML
Because the cache banks are initialized based on the order in which their
respective directories exist on the filesystem, they can appear in different
order.  This is here mainly for tests because the cache directory might have
different order of children nodes and tests would fail otherwise.  It should not
be the case with sysfs, but one can never be sure.  And this does not take
almost any extra time, mainly because it gets initialized once per driver.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-18 10:45:10 +01:00
Martin Kletzander
baca005367 util: Introduce virBitmapShrink
Sometimes the size of the bitmap matters and it might not be guessed correctly
when parsing from some type of input.  For example virBitmapNewData() has Byte
granularity, virBitmapNewString() has nibble granularity and so on.
virBitmapParseUnlimited() can be tricked into creating huge bitmap that's not
needed (e.g.: "0-2,^99999999").  This function provides a way to shrink the
bitmap.  It is not supposed to free any memory.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-18 10:45:10 +01:00
Martin Kletzander
449442c34d util: Reintroduce virBitmapSubtract
Already introduced in the past with 9479642fd3, but then renamed to
virBitmapIntersect by a908e9e45e.  This time we'll really use it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-18 10:45:10 +01:00
Martin Kletzander
2e5579a43b util: Introduce virBitmapNewString
Our bitmaps can be represented as data (raw bytes for which we have
virBitmapNewData() and virBitmapToData()), human representation (list
of numbers in a string for which we have virBitmapParse() and
virBitmapFormat()) and hexadecimal string (for which we have only
virBitmapToString()).  So let's add the missing complement for the
last one so that we can parse hexadecimal strings.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-18 10:45:10 +01:00
Martin Kletzander
fb10602875 util: Don't output too many zeros from virBitmapToString
Truncate the output so that it is only as big as is needed to fit all
the bits, not all the units from the map.  This will be needed in the
future in order to properly format bitmaps for kernel's sysfs files.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-18 10:45:10 +01:00
Martin Kletzander
5d893ed6ad util: Rename virBitmapDataToString to virBitmapDataFormat
It is literally only a wrapper around virBitmapNewData() and
virBitmapFormat(), only the naming was wrong since it was introduced.
And because we have virBitmap*String functions where the meaning of
the 'String' is constant, this might confuse someone.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-18 10:45:10 +01:00
Martin Kletzander
68d7cc649c util: Rename virBitmapString to virBitmapToString
This follows the virBitmapToData() function and, similarly to
virBitmapNewData(), we'll be able to have virBitmapNewString() later
on without name confusion.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-18 10:45:10 +01:00
Martin Kletzander
d127aced0a util: Make prefix optional in virBitampString
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-18 10:45:10 +01:00
Martin Kletzander
87a8a30d61 util: Introduce virFormatIntPretty
We can't output better memory sizes if we want to be compatible with libvirt
older than the one which introduced /memory/unit, but for new things we can just
output nicer capacity to the user if available.  And this function enables that.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-18 10:45:10 +01:00
Martin Kletzander
b8bbc23fea Only output initialized capabilities with VIR_TEST_DEBUG > 1
Currenty virTestInit() outputs all capabilities that it created when running
with VIR_TEST_DEBUG=1.  Since this is quite a lot of output for every call of
this function (and it is not needed until debugging a really deep-down issue)
let's just output the info when VIR_TEST_DEBUG is strictly greater than 1.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-18 10:45:10 +01:00
Martin Kletzander
e399641561 tests: Remove pointless _CFLAGS variables
If _CFLAGS for a binary is not specified it uses AM_CFLAGS.  So doing

  $binary_CFLAGS = $(AM_CFLAGS)

or

  $binary_CFLAGS = $(AM_CFLAGS) $(something_that_is_already_in_AM_CFLAGS)

is pointless.  So remove it for cleaner Makefile.am

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-11-18 10:45:10 +01:00
Martin Kletzander
74a13be4a4 build: Use XDR_CFLAGS in more places
Since update to glibc-2.26 removed the /usr/include/rpc/rpc.h we used until now,
it showed us a problem with not using XDR_CFLAGS properly.  On linux that
variable has usually -I/usr/include/tirpc because we already probe for it
properly, we just don't use it everywhere we need.  It is needed by wireshark
dissector as well as testutilsqemu.c (through includes) so the build fails with:

wireshark/src/packet-libvirt.c:33:10: fatal error: rpc/xdr.h: No such file or directory
 #include <rpc/xdr.h>
          ^~~~~~~~~~~

and

In file included from ../src/logging/log_manager.h:29:0,
                 from ../src/qemu/qemu_domain.h:40,
                 from testutilsqemu.c:11:
../src/logging/log_protocol.h:9:10: fatal error: rpc/rpc.h: No such file or directory
 #include <rpc/rpc.h>
          ^~~~~~~~~~~

Since lot of tests use testutilsqemu.c it is easier to add XDR_CFLAGS to
AM_CFLAGS than adding it to all $binary_CFLAGS.  It's just for tests and we
already have bunch of CFLAGS there anyway.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-11-18 10:45:10 +01:00
Jim Fehlig
ce3b585bc4 xenconfig: fix compilation error
Commit 03d0959a introduced a compilation error in
src/xenconfig/xen_xl.c on ARM. Found by Xen's osstest

http://logs.test-lab.xenproject.org/osstest/logs/116216/build-armhf-libvirt/6.ts-libvirt-build.log
2017-11-17 10:35:12 -07:00
Daniel P. Berrange
9061b3090e docs: add a page describing support guarantees for libvirt features
While we have collective knowledge about the support status of various
parts of libvirt, this has never been formally documented, leaving our
users to guess.

Note, this document makes one change to our previous policy. It explicitly
declares the RPC protocol of libvirtd as being a supported interface. THis
accepts the reality that we can a) never change it without breaking compat
with old libvirt.so, b) there are both rust + go impls that are written
against the RPC protocol already.

Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-11-17 16:39:14 +00:00
Daniel P. Berrange
01fb183c5b docs: don't use https in XML namespace URIs
The XML namespace URI for the QEMU/LXC drivers must use http as the protocol
otherwise it won't match the parser's expectations.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-11-16 17:13:14 +00:00
John Ferlan
2dd70901db storage: Resolve storage driver crash
Resolve a storage driver crash as a result of a long running
storageVolCreateXML when the virStorageVolPoolRefreshThread is
run as a result of when a storageVolUpload completed and ran the
virStoragePoolObjClearVols without checking if the creation
code was currently processing a buildVol after incrementing
the driver->asyncjob count.

The refreshThread will now check the pool asyncjob count before
attempting to pursue the pool refresh. Adjust the documentation
to describe the condition.

Crash from valgrind is as follows (with a bit of editing):

==21309== Invalid read of size 8
==21309==    at 0x153E47AF: storageBackendUpdateVolTargetInfo
==21309==    by 0x153E4C30: virStorageBackendUpdateVolInfo
==21309==    by 0x153E52DE: virStorageBackendVolRefreshLocal
==21309==    by 0x153DE29E: storageVolCreateXML
==21309==    by 0x562035B: virStorageVolCreateXML
==21309==    by 0x147366: remoteDispatchStorageVolCreateXML
...
==21309==  Address 0x2590a720 is 64 bytes inside a block of size 336 free'd
==21309==    at 0x4C2F2BB: free
==21309==    by 0x54CB9FA: virFree
==21309==    by 0x55BC800: virStorageVolDefFree
==21309==    by 0x55BF1D8: virStoragePoolObjClearVols
==21309==    by 0x153D967E: virStorageVolPoolRefreshThread
...
==21309==  Block was alloc'd at
==21309==    at 0x4C300A5: calloc
==21309==    by 0x54CB483: virAlloc
==21309==    by 0x55BDC1F: virStorageVolDefParseXML
==21309==    by 0x55BDC1F: virStorageVolDefParseNode
==21309==    by 0x55BE5A4: virStorageVolDefParse
==21309==    by 0x153DDFF1: storageVolCreateXML
==21309==    by 0x562035B: virStorageVolCreateXML
==21309==    by 0x147366: remoteDispatchStorageVolCreateXML
...
2017-11-16 11:34:26 -05:00
Pavel Hrdina
b98add7571 qemu: taint domain if virDomainQemuAgentCommand API is used
This is similar to the virDomainQemuMonitorCommand API, it can change
the domain state in a way that libvirt may not understand.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-16 14:58:01 +01:00
Julio Faracco
c7543a7286 virsh: fixing wrong datatype of 'set-lifcycle-action' command options.
The 'set-lifcycle-action' is throwing a weird error after executing it with
the '--help' option. The command output is showing the options 'type' and
'action' are as optional, but they aren't. Both are required.

virsh # set-lifecycle-action --help
...
  SYNOPSIS
    set-lifecycle-action <domain> [--type <string>] [--action <string>] ...
...
  OPTIONS
    [--domain] <string>  domain name, id or uuid
error: internal error: bad options in command: 'set-lifecycle-action'

After applying this patch, both arguments are required now.

virsh # set-lifecycle-action --help
...
  SYNOPSIS
    set-lifecycle-action <domain> <type> <action> [--config] ...

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

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
2017-11-16 10:27:46 +01:00
Erik Skultety
996500d6fa daemon: virtlockd: Call virNetDaemonGetServer regardless of post exec
We need to call it anyway, so the else branch is redundant here.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2017-11-15 15:11:55 +01:00
Erik Skultety
700b0d2a2d daemon: virtlogd: Drop the server shortcut ref pointer
We put the server into a hash table as we do with the other daemons,
there is no compelling reason why it should have another pointer
dedicated just to the server. Besides, the locking daemon doesn't have
it and virtlogd is essentially a copy paste of virtlockd.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2017-11-15 15:11:54 +01:00
Chen Hanxiao
2721577495 hooks: Fix a wrong description
In the definition of virHookQemuOpType and virHookNetworkOpType,
we should use 'stopped' rather than 'shutdown'.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
2017-11-15 13:52:13 +01:00
Andrea Bolognani
52125f90c9 news: Update for configuration of HPT resizing
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-14 16:47:19 +01:00
Andrea Bolognani
ba5329ec52 docs: Document configuration of HPT resizing
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-14 16:47:19 +01:00
Andrea Bolognani
5e192a3620 tests: Add tests for configuration of HPT resizing
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-14 16:47:04 +01:00
Andrea Bolognani
85b2ae96df qemu: Enable configuration of HPT resizing for pSeries guests
Most of the time it's okay to leave this up to negotiation between
the guest and the host, but in some situations it can be useful to
manually decide the behavior, especially to enforce its availability.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2017-11-14 16:29:55 +01:00
Jiri Denemark
5f244e3161 vircapstest: Avoid (im)possible strcmp call with NULL argument
Some compilers may get confused and decide we are calling strcmp with
NULL argument from test_virCapsDomainDataLookupLXC. Although this does
not really happen since the call is guarded with
(data->machinetype != expect_machinetype), using STRNEQ_NULLABLE is
easier to understand, less fragile, and doing so makes sure strcmp is
never called with NULL argument.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-11-14 14:45:19 +01:00
Jim Fehlig
f9d8b0270f news: add entries for specifying distance between vNUMA cells
Add two new entries under new features for 3.10.0. One
advertising support for specifying distance between vNUMA cells
and another advertising Xen's support for vNUMA configuration.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2017-11-13 18:35:20 -07:00
Jiri Denemark
6118fd9cb9 qemu: Properly report errors from qemuDomainFixupCPUs
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2017-11-13 17:42:44 +01:00
Peter Krempa
50712e14f4 conf: Fix message when maximum vCPU count is less than current
Reword the message and drop the numbers (which were reversed) from it
so that it actually makes sense.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1509151
2017-11-13 13:41:45 +01:00
Peter Krempa
acc15025ed qemu: process: Setup disk secrets when preparing disks
Setup everything related to disks in one place rather than calling in
from various places.

The change to ordering of the setup steps is necessary since secrets
need the master key to be present.
2017-11-13 13:29:58 +01:00
Peter Krempa
2c82fddca9 qemu: domain: Don't allocate storage source private data if not needed 2017-11-13 13:28:49 +01:00
Peter Krempa
8056721cbb qemu: Tolerate storage source private data being NULL
In some cases it does not make sense to pursue that the private data
will be allocated (especially when we don't need to put anything in it).

Ensure that the code works without it.

This also fixes few crashes pointed out in
https://bugzilla.redhat.com/show_bug.cgi?id=1510323
2017-11-13 13:28:49 +01:00