Commit Graph

25984 Commits

Author SHA1 Message Date
Jiri Denemark
d84b93fad5 qemu: Move common code in virQEMUCapsInitCPUModel one layer up
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-04-07 10:12:24 +02:00
Jiri Denemark
05e91c79f1 cpu: Introduce virCPUCopyMigratable
This new internal API makes a copy of virCPUDef while removing all
features which would block migration. It uses cpu_map.xml as a database
of such features, which should only be used as a fallback when we cannot
get the data from a hypervisor. The main goal of this API is to decouple
this filtering from virCPUUpdate so that the hypervisor driver can
filter the features according to the hypervisor.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-04-07 10:12:24 +02:00
Jiri Denemark
f0ad8e7ee0 Properly ignore files in build-aux directory
We want to ignore all files except *.pl in build-aux directory, however
the unignore pattern "!/build-aux/*.pl" doesn't have any effect because
a previous "/build-aux/" pattern ignores the directory itself rather
than individual files in it.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-04-07 10:08:33 +02:00
Martin Kletzander
8f0b731d22 util: Add virStringTrimOptionalNewline
And use it in virFileRead*

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-04-07 08:49:34 +02:00
Martin Kletzander
b11e893224 util: Fix virDirRead() description
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-04-07 08:49:34 +02:00
Martin Kletzander
6369ee0483 conf: Fix possible memleak in capabilities
If formatting NUMA topology fails, the function returns immediatelly,
but the buffer structure allocated on the stack references lot of
heap-allocated memory and that would get lost in such case.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-04-07 08:49:34 +02:00
Jiri Denemark
ae102b5d7b qemu: Fix regression when hyperv/vendor_id feature is used
qemuProcessVerifyHypervFeatures is supposed to check whether all
requested hyperv features were actually honored by QEMU/KVM. This is
done by checking the corresponding CPUID bits reported by the virtual
CPU. In other words, it doesn't work for string properties, such as
VIR_DOMAIN_HYPERV_VENDOR_ID (there is no CPUID bit we could check). We
could theoretically check all 96 bits corresponding to the vendor
string, but luckily we don't have to check the feature at all. If QEMU
is too old to support hyperv features, the domain won't even start.
Otherwise, it is always supported.

Without this patch, libvirt refuses to start a domain which contains

  <features>
    <hyperv>
      <vendor_id state='on' value='...'/>
    </hyperv>
  </features>

reporting internal error: "unknown CPU feature __kvm_hv_vendor_id.

This regression was introduced by commit v3.1.0-186-ge9dbe7011, which
(by fixing the virCPUDataCheckFeature condition in
qemuProcessVerifyHypervFeatures) revealed an old bug in the feature
verification code. It's been there ever since the verification was
implemented by commit v1.3.3-rc1-5-g95bbe4bf5, which effectively did not
check VIR_DOMAIN_HYPERV_VENDOR_ID at all.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-04-06 14:32:00 +02:00
Ján Tomko
e73889b631 Split out -Wframe-larger-than warning from WARN_CLFAGS
Introduce STRICT_FRAME_LIMIT_CFLAGS that will be used for
production code and RELAXED_FRAME_LIMIT_CFLAGS for tests.

Raising the limit for tests allows building them with clang
with optimizations disabled.
2017-04-06 12:29:35 +02:00
Andrea Bolognani
2e5de445a1 qemu: Move some functions to qemu_capspriv.h
This header file has been created so that we can expose
internal functions to the test suite without making them
public: those in qemu_capabilities.h bearing the comment

  /* Only for use by test suite */

are obvious candidates for being moved over.
2017-04-06 10:07:43 +02:00
Andrea Bolognani
611ddefc16 storage: Avoid leak in virStorageUtilGlusterExtractPoolSources()
The contents of volname would be leaked if the function were
to be passed an invalid pooltype by the caller.

Make sure the memory is released instead.
2017-04-06 10:03:26 +02:00
Boris Fiuczynski
ff483133fe qemu: Fix VPATH syntax-check for qemuSecurity wrappers enforcment
Fixing make syntax-check broken by commit 4da534c0b9.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
2017-04-05 18:30:55 +02:00
Michal Privoznik
9c037c6cae virISCSIGetSession: Don't leak memory
This function runs an iscsi command and parses its output.
However, due to the nature of things, virISCSIExtractSession()
callback can be called multiple times. In each run it would
allocate new memory and overwrite the variable where we keep
pointer to it and thus leaking old allocations.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-04-05 15:18:30 +02:00
Michal Privoznik
c455591f37 virNetworkObjDispose: Don't leak virMacMap object
Even though the virMacMap object is not necessarily created at
the same time as the network object, the former makes no sense
without the latter and thus should be unref'd in the network
object dispose function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-04-05 15:18:30 +02:00
Michal Privoznik
349badbffd virStorageSourceClear: Don't leave dangling pointers behind
Imagine that this function is called twice over the same disk
source. While in the first run all allocated memory is freed, not
all pointers are set to NULL (e.g. def->srcpool). So when called
again, these poitners are freed again resulting in double free.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2017-04-05 15:18:30 +02:00
Jiri Denemark
d658c8594e qemu: Break endless loop if qemuMigrationResetTLS fails
Jumping to "endjob" label from a code after this label is not a very
good idea.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-04-05 15:00:10 +02:00
Peter Krempa
e72b544a09 qemu: monitor: No need to debug-log the 'mon' pointer
QEMU_CHECK_MONITOR_* already logs the object and vm name
2017-04-05 14:01:46 +02:00
Peter Krempa
62ed907a7b docs: Add news.rng to EXTRA_DIST 2017-04-05 13:17:53 +02:00
Peter Krempa
a200ebbc6f storage: gluster: Implement 'checkPool' method so that state is restored
After restart of libvirtd the 'checkPool' method is supposed to validate
that the pool is online. Since libvirt then refreshes the pool contents
anyways just return whether the pool was supposed to be online so that
the code can be reached. This is necessary since if a pool does not
implement the method it's automatically considered as inactive.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1436065
2017-04-05 12:21:17 +02:00
Peter Krempa
8e0139869a docs: Move news.rng out of docs/schemas
docs/schemas directory is meant for schemas which are installed on the
system. The schema for the news file does not need to be installed.
Store it along with the file it describes for simplicity.
2017-04-05 09:51:51 +02:00
Peter Krempa
4661a1868b docs: Document limitation of maximum vcpu count used with <topology>
qemu requires that the topology equals to the maximum vcpu count.
Document this along with the API to set maximum vcpu count and the XML
element.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1426220
2017-04-05 09:00:44 +02:00
John Ferlan
2e8c60958a qemu: Fix resource leak in qemuDomainAddChardevTLSObjects error path
On any failure, call virJSONValueFree for the *Props.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-04-04 12:40:27 -04:00
John Ferlan
83c58ea396 qemu: Initialize 'data' argument
Initialize stack variable to {0}

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-04-04 12:40:27 -04:00
John Ferlan
466a53af05 tests: Pass BlockIOThrottle arguments by reference not value
Pass the data by reference rather than everything on the stack.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2017-04-04 12:40:27 -04:00
Andrea Bolognani
4ceac4bf29 tests: Rename VIRT_TEST_* macros to VIR_TEST_*
We use the "vir" prefix pretty consistently in our
APIs, both external and internal, which made these
macros stood out.
2017-04-04 17:30:03 +02:00
Peter Krempa
dff04e0af0 storage: gluster: Use volume name as "<name>" field in the XML
For native gluster pools the <dir> field denotes a directory inside the
pool. For the actual pool name the <name> field has to be used.
2017-04-04 16:36:15 +02:00
Peter Krempa
5df6992e1c storage: Fix XPath for looking up gluster volume name
Use the relative lookup specifier rather than the global one. Otherwise
only the first name would be looked up. Add a test case to cover the
scenario.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1436574
2017-04-04 16:36:15 +02:00
Peter Krempa
69cc498676 test: Introduce testing of virStorageUtilGlusterExtractPoolSources
Add a test program called virstorageutiltest and test the gluster pool
detection code.
2017-04-04 16:36:10 +02:00
Peter Krempa
e238bfa6d4 storage: util: Split out the gluster volume extraction code into new function
To allow testing of the algorithm, split out the extractor into a
separate helper.
2017-04-04 16:30:45 +02:00
Peter Krempa
a92160dbd5 storage: util: Pass pool type to virStorageBackendFindGlusterPoolSources
The native gluster pool source list data differs from the data used for
attaching gluster volumes as netfs pools. Currently the only difference
was the format. Since native pools don't use it and later there will be
more differences add a more deterministic way to switch between the
types instead.
2017-04-04 16:30:45 +02:00
Nikolay Shirokovskiy
609cc5a880 vz: fix typo that breaks build 2017-04-04 14:27:18 +02:00
Ján Tomko
04be4111d9 util: ignore -Wcast-align in virNetlinkDumpCommand
Similar to commit b202c39 ignore the warning that breaks the build
with clang:
util/virnetlink.c:365:52: error: cast from 'char *' to 'struct nlmsghdr *'
 increases required alignment from 1 to 4 [-Werror,-Wcast-align]
        for (msg = resp; NLMSG_OK(msg, len); msg = NLMSG_NEXT(msg, len)) {
                                                   ^~~~~~~~~~~~~~~~~~~~
/usr/include/linux/netlink.h:87:7: note: expanded from macro 'NLMSG_NEXT'
         (struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len)))
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2017-04-04 12:53:23 +02:00
Peter Krempa
079832103c qemu: hotplug: Validate that vcpu-hotplug does not break config
Make sure that non-hotpluggable vcpus stay clustered at the beginning
after modifying persistent definition.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1437010
2017-04-04 09:20:02 +02:00
Peter Krempa
ee86d45de3 qemu: hotplug: Add validation for coldplug of individual vcpus
Validate that users don't try to disable vcpu 0.
2017-04-04 09:17:59 +02:00
Peter Krempa
b416a33a6f qemu: hotplug: Clear vcpu ordering for coldplug of vcpus
Vcpu order is required to stay sequential. Clear the order on cpu
coldplug to avoid issues with removing vcpus out of sequence.
2017-04-04 09:10:03 +02:00
Peter Krempa
86d69c3091 qemu: hotplug: Fix formatting strings in qemuDomainFilterHotplugVcpuEntities
'next' is declared as 'ssize_t' so use '%zd'
2017-04-04 09:10:03 +02:00
Peter Krempa
315f443dbb qemu: hotplug: Iterate over vcpu 0 in individual vcpu hotplug code
Buggy condition meant that vcpu0 would not be iterated in the checks.
Since it's not hotpluggable anyways we would not be able to break the
configuration of a live VM.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1437013
2017-04-04 09:10:03 +02:00
Ján Tomko
3af6c37816 news.rng: work around a bug in old libxml2
Similar to commit c3c2cc6, use a literal newsline instead of \n
inside the brackets.
2017-04-04 08:56:26 +02:00
Erik Skultety
c3272e5e12 qemu: Add device id for mediated devices on qemu command line
Like all devices, add the 'id' option for mdevs as well. Patch also
adjusts the test accordingly.

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2017-04-04 08:15:43 +02:00
John Ferlan
b7d44f450c storage: Fix capacity value for LUKS encrypted volumes
https://bugzilla.redhat.com/show_bug.cgi?id=1371892

The 'capacity' value (e.g. guest logical size) for a LUKS volume is
smaller than the 'physical' value of the file in the file system, so
we need to account for that.

When peeking at the encryption information about the volume add a fetch
of the payload_offset which is described as the offset to the start of
the volume data (in 512 byte sectors) in QEMU's QCryptoBlockLUKSHeader.

Then adjust the ->capacity appropriately when we determine that the
volume target encryption has a payload_offset value.
2017-04-03 16:15:29 -04:00
Cédric Bosdonnat
b202c39adc virNetDevIPCheckIPv6ForwardingCallback fixes
Add check for more than one RTA_OIF, even though this is rather
unlikely.

Get rid of the buggy switch / break as this code won't need to
handle more attributes.

Use VIR_WARNINGS_NO_CAST_ALIGN to fix impossible to fix
util/virnetdevip.c:560:17: error: cast increases required alignment of target type [-Werror=cast-align]
2017-04-03 14:23:15 -04:00
Andrea Bolognani
deb38c4503 tests: Test ACPI, UEFI requirements
Make sure every combination of ACPI and UEFI works, or fails to
work, as expected.
2017-04-03 10:58:00 +02:00
Andrea Bolognani
396ca36cb0 qemu: Enforce ACPI, UEFI requirements
Depending on the architecture, requirements for ACPI and UEFI can
be different; more specifically, while on x86 UEFI requires ACPI,
on aarch64 it's the other way around.

Enforce these requirements when validating the domain, and make
the error message more accurate by mentioning that they're not
necessarily applicable to all architectures.

Several aarch64 test cases had to be tweaked because they would
have failed the validation step otherwise.
2017-04-03 10:58:00 +02:00
Andrea Bolognani
560335c35c qemu: Advertise ACPI support for aarch64 guests
So far, libvirt has assumed that only x86 supports ACPI,
but that's inaccurate since aarch64 supports it too.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1429509
2017-04-03 10:58:00 +02:00
Andrea Bolognani
5fbb16ba53 qemu: Remove redundant capabilities
Now that the NO_ACPI and NO_HPET capabilities are set
automatically by virQEMUCapsInitQMPBasicArch() if
appropriate for the architecture, they shouldn't be
used manually to avoid masking bugs.
2017-04-03 10:58:00 +02:00
Andrea Bolognani
1cf3e52abb tests: Initialize basic capabilities properly
The capabilities used in test cases should match those used
during normal operation for the tests to make any sense.

This results in the generated command line for a few test
cases (most notably non-x86 test cases that were wrongly
assuming they could use -no-acpi) changing.
2017-04-03 10:58:00 +02:00
Andrea Bolognani
a8fc7ef834 qemu: Split virQEMUCapsInitArchQMPBasic()
Instead of having a single function that probes the
architecture from the monitor and then sets a bunch of
basic capabilities based on it, have a separate function
for each part: virQEMUCapsInitQMPArch() only sets the
architecture, and virQEMUCapsInitQMPBasicArch() only sets
the capabilities.

This split will be useful later on, when we will want to
set basic capabilities from the test suite without having
to go through the pain of mocking the monitor.
2017-04-03 10:58:00 +02:00
Andrea Bolognani
a26603f684 news: Allow empty <section> elements
Creating dummy <change> elements was a workaround for the
HTML DTD not allowing empty <ul> elements, but we can do
better by tweaking the the XSLT stylesheet.
2017-04-03 10:49:42 +02:00
Andrea Bolognani
f6332457b3 news: Remove handling of random HTML tags
Now that the source file is validated against a schema that
only allows the <code> HTML tag to be used, we can rely on
that assumption to simplify our XSLT stylesheet.
2017-04-01 16:20:00 +02:00
Peter Krempa
f3a8e80c13 storage: driver: Remove unavailable transient pools after restart
If a transient storage pool is deemed inactive after libvirtd restart it
would not be deleted from the list. Reuse virStoragePoolUpdateInactive
along with a refactor necessary to properly update the state.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1242801
2017-04-03 08:42:09 +02:00
Peter Krempa
aced6b2356 storage: driver: Split out code fixing pool state after deactivation
After a pool is made inactive the definition objects need to be updated
(if a new definition is prepared) and transient pools need to be
completely removed. Split out the code doing these steps into a separate
function for later reuse.
2017-04-03 08:42:09 +02:00