Commit Graph

30986 Commits

Author SHA1 Message Date
Shi Lei
a618b06493 tests: fix incorrect indentation in function body by checking first line
Signed-off-by: Shi Lei <shi_lei@massclouds.com>
2018-09-17 13:29:01 +02:00
Shi Lei
ab9a145926 src: fix incorrect indentation in function body by checking first line
Signed-off-by: Shi Lei <shi_lei@massclouds.com>
2018-09-17 13:29:00 +02:00
Michal Privoznik
37131adada qemu_security: Run transactions more frequently
Now that committing transactions using pid == -1 means that we're
not fork()-ing to run the transaction in a specific namespace, we
can utilize the transaction processing semantics in order to
start, run a or multiple commands, and then commit the
transaction without being concerned with other interactions or
transactions interrupting the processing.  This will eventually
allow us to have a single place where all the paths can be
locked, followed by relabeling and unlocking again.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-09-17 10:58:17 +02:00
Michal Privoznik
d41c162177 virSecurityManagerTransactionCommit: Accept pid == -1
It will be desirable to run transactions more often than we
currently do. Even if the domain we're relabeling the paths for
does not run in a namespace. If that's the case, there is no need
to fork() as we are already running in the right namespace. To
differentiate whether transaction code should fork() or not the
@pid argument now accepts -1 (which means do not fork).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-09-17 10:58:17 +02:00
Michal Privoznik
ccafaacd61 qemu_security: Require full wrappers for APIs that might touch a file
In the future, the transactions are not going to be optional and
they will be run regardless of domain using namespace to collect
list of paths to be relabeled.

To make sure there won't be an API that goes behind transaction
code back update the comment that serves as decision manual
whether an API must be fully implemented or plain #define is
sufficient.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-09-17 10:58:17 +02:00
Michal Privoznik
e2c23982dd qemu_security: Fully implement qemuSecurity{Set,Restore}SavedStateLabel
Even though the current use of the functions does not require full
implementation with transactions (none of the callers passes a path
somewhere under /dev), it doesn't hurt either. Moreover, in
future patches the paradigm is going to shift so that any API
that touches a file is required to use transactions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-09-17 10:58:17 +02:00
Michal Privoznik
da24db2d30 qemu_security: Fully implement qemuSecurityDomainSetPathLabel
Even though the current use of the function does not require full
implementation with transactions (none of the callers pass a path
somewhere under /dev), it doesn't hurt either. Moreover, in
future patches the paradigm is going to shift so that any API
that touches a file is required to use transactions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-09-17 10:58:17 +02:00
Andrea Bolognani
679895eb5d conf: Move more PCI functions out of device_conf
Functions that deal with virPCIDeviceAddress exclusively
belong to util/virpci.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-09-17 09:23:04 +02:00
Jim Fehlig
16858439de news: Announce dropping support for Xen 4.4 and 4.5
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-09-14 11:47:08 -06:00
Jim Fehlig
5bdcef13d1 libxl: drop support for Xen < 4.6
Currently the libxl driver claims support for Xen >= 4.4, but
Xen 4.4 and 4.5 are no longer supported upstream. Let's increase
the minimum supported Xen version to 4.6 and change the defined
LIBXL_API_VERSION to 0x040500, which is the API version defined
when Xen 4.6 was released.

Since Xen 4.6 contains a pkgconfig file, drop the now unused code
that falls back to using LIBVIRT_CHECK_LIB in the absence of
pkgconfig file. In addition, bumping the LIBXL_API_VERSION
required adjusting the calls to libxl_set_vcpuaffinity to account
for the extra parameter in the 0x040500 version of the API.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-09-14 11:47:08 -06:00
Lin Ma
317e3b2865 util: Return a virArpTablePtr when the nlmsghdr for loop is over
commit b00c9c39 removed the label end_of_netlink_messages and 'return
table' statement, It causes the function virArpTableGet doesn't return
a proper virArpTable pointer.

How to reproduce:
 # virsh domiflist sles12sp3
Interface  Type       Source     Model       MAC
-------------------------------------------------------
vnet0      network    default    virtio      52:54:00💿02:e6

 # virsh domifaddr sles12sp3 --source arp
error: Failed to query for interfaces addresses
error: An error occurred, but the cause is unknown

It seems that the "if (nh->nlmsg_type == NLMSG_DONE)" statement won't be
meted. So this patch adds 'return table' when the iterations of nlmsghdr
for loop is over.

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Chen Hanxiao <chenhanxiao@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-09-14 11:18:28 -04:00
Martin Kletzander
b49a3ad799 util: Add stubs for virDoes{User,Group}Exist() without getpwuid_r
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-09-14 09:14:18 +02:00
Martin Kletzander
b907fd75fa qemu: Report less errors on driver startup
It is not a problem at all if the `tss` user/group does not exist, the code
fallbacks to the `root` user/group.  However we report a warning for no reason
on every start-up.  Fix this by checking if the user/group actually exists.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-09-13 16:19:25 +02:00
Martin Kletzander
b984bbcc0d Add functions for checking if user or group exists
Instead of duplicating the code from virGet{User,Group}IDByName(), which are
static anyway, extend those functions to accept NULL pointers for the result and
a boolean for controlling the error reporting.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2018-09-13 16:19:25 +02:00
Nikolay Shirokovskiy
d7bc6af648 qemu: keep websocketGenerated on libvirtd restarts
Otherwise after libvirtd restart we come back to issues fixed by
introducing this flag in [1].

[1] 61a0026a : qemu: Fix xml dump of autogenerated websocket

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-09-13 14:06:04 +03:00
Nikolay Shirokovskiy
30f9a64cbd qemu: fix typo in vnc port releasing
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-09-13 14:05:17 +03:00
Ján Tomko
51c02bd4f9 qemu: remove unnecessary virQEMUCapsFreeHostCPUModel
After removing the host CPU model re-computation,
this function is no longer necessary.

This reverts commits:
commit d0498881a0
  virQEMUCapsFreeHostCPUModel: Don't always free host cpuData
commit 5276ec712a
  testUpdateQEMUCaps: Don't leak host cpuData

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-09-12 21:12:22 +02:00
Ján Tomko
4ed727a015 tests: turn skipLegacyCPUs into a flag
Make it obvious when it is used intentionally and error
out when used in combination with real capabilities.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-09-12 21:12:22 +02:00
Ján Tomko
c9e5be4e9c tests: do not mangle real qemu caps in xml2argvtest
None of the things testUpdateQEMUCaps adjusts are applicable
for tests that use the DO_TEST_CAPS macros, i.e.
real QEMU capabilities parsed from the XML files:

The architecture must be chosen before we even open the caps
file, CPU models are already present and the expensive HostModel
computation was already done in virQEMUCapsLoadCache.

Introduce FLAG_REAL_CAPS and skip the whole testUpdateQEMUCaps
function for DO_TEST_CAPS.

This speeds up the test by 25 %

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-09-12 21:12:22 +02:00
Ján Tomko
3fb2c456ba tests: report errors in QEMU XML->startup XML tests
Now that the function is only run if requested by
the FLAG_STEAL_VM flag, we know that missing data
is an error, not a request to skip the test.

The existence of the output file is now checked by
virTestCompareToFile, which allows usage of
the VIR_TEST_REGENERATE_OUTPUT=1 env variable
to generate new test cases.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-09-12 21:12:22 +02:00
Ján Tomko
15dd03e082 tests: only run startup XML tests if requested
Use the recently introduced flag as a witness.
This reduces the apparent number of test cases
to the real number of test cases.

Note that this does not suffer from the same problem
as commit 70255fa was fixing, because the condition
for running virTestRun does not depend on results
of previous tests.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-09-12 21:12:22 +02:00
Ján Tomko
18adfc8735 tests: introduce macro for qemu XML->startup XML
Use this macro to indicate the intention to also
run the XML->startup XML test.

It sets the newly introduced FLAG_STEAL_VM flag,
which is the new witness for the XML->argv test
to leave the VM object behind.

This will allow us to report proper errors in
XML->startup tests.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-09-12 21:12:22 +02:00
Ján Tomko
46a73f4801 tests: add a function for checking exclusive flags
We can reject some non-sensical combinations with an error
message, once we add flags for them.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-09-12 21:12:22 +02:00
John Ferlan
61d340a27d conf: Move hypervisor specific nhugepage checks
Commit 82327038 moved a couple of checks out of the XML parser
into the domain validation; however, those checks seem to be more
useful as hypervisor specific checks rather than the more general
domain conf checks (nothing in the docs indicate a specific error).

Fortunately only QEMU was processing the memoryBacking, thus
add the changes to qemuDomainDefValidateMemory and change the
code a bit to make usage of the similar deref to def->mem and
the mem->nhugepages filter.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2018-09-12 12:21:05 -04:00
John Ferlan
972acbded1 doc: Update the wording around the backingStore
Commit bc6d3121a was far too terse when describing the new
elements, attributes, and allow values. Provide a few more
words to help describe.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2018-09-12 12:15:21 -04:00
Shi Lei
8174e41bc4 util: netdev: use VIR_AUTOCLOSE instead of VIR_FORCE_CLOSE
Signed-off-by: Shi Lei <shi_lei@massclouds.com>
2018-09-12 17:35:38 +02:00
Shi Lei
4f446cad17 util: netdevbridge: use VIR_AUTOCLOSE instead of VIR_FORCE_CLOSE
Signed-off-by: Shi Lei <shi_lei@massclouds.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-09-12 17:35:38 +02:00
Shi Lei
bd96c753e2 util: file: use VIR_AUTOCLOSE instead of VIR_FORCE_CLOSE
Signed-off-by: Shi Lei <shi_lei@massclouds.com>
2018-09-12 17:35:38 +02:00
Shi Lei
3e0786cc46 cfg.mk: change syntax-check rule for VIR_AUTOCLOSE variable initialization
Signed-off-by: Shi Lei <shi_lei@massclouds.com>
2018-09-12 17:35:38 +02:00
Shi Lei
09d35afd2c util: file: introduce VIR_AUTOCLOSE macro to close fd of the file automatically
Signed-off-by: Shi Lei <shi_lei@massclouds.com>
2018-09-12 17:35:38 +02:00
Laine Stump
7ea7342996 conf: correct false boot order error during domain parse
virDomainDefCollectBootOrder() is called for every item on the list
for each type of device. One of the checks it makes is to gather the
order attributes from the <boot> element of all devices, and assure
that no two devices have been given the same order.

Since (internally to libvirt, *not* in the domain XML) an <interface
type='hostdev'> is on both the list of hostdev devices and the list of
network devices, it will be counted twice, and the code that checks
for multiple devices with the same boot order will give a false
positive.

To remedy this, we make sure to return early for hostdev devices that
have a parent.type != NONE.

This was introduced in commit 5b75a4, which was first in libvirt-4.4.0.

Resolves: https://bugzilla.redhat.com/1601318

Signed-off-by: Laine Stump <laine@laine.org>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-09-12 11:09:53 -04:00
Andrea Bolognani
36504033ae qemu: Drop redundant version checks
We require QEMU 1.5.0 these days, so checking for versions
older than that is pointless.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-09-12 15:36:54 +02:00
Andrea Bolognani
b38a85a321 qemu: Drop QEMU_CAPS_CHARDEV_SPICEPORT
The capability was introduced in QEMU 1.5.0, which is our
minimum supported QEMU version these days.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-09-12 15:36:46 +02:00
Andrea Bolognani
d6a1d0af62 qemu: Drop QEMU_CAPS_VNC_WEBSOCKET
The capability was introduced in QEMU 1.3.1 and we require
QEMU 1.5.0 these days.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
2018-09-12 15:35:58 +02:00
Ján Tomko
b64b14cf8e tests: drop redundant virQEMUCapsFilterByMachineType
Introduced by commit <af204232>.

Made redundant by commit 1e9a083 which switched to using
qemuProcessCreatePretendCmd, where capabilities are filtered
in qemuProcessInit after being fetched from the cache.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-09-12 14:57:00 +02:00
Ján Tomko
484e13f1a5 tests: drop 'drive' from qemuxml2startup tests
Commit 0bdb704 renamed the corresponding xml->argv tests,
but due to the optimistic nature of xml->startup xml testing,
this test was quietly skipped.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-09-12 14:43:03 +02:00
Ján Tomko
cc786a8fd6 qemu: free SEV caps in virQEMUCapsDispose
Commit 77f51ab5 started parsing an copying the SEV capabilities,
but omitted the free call.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-09-12 14:38:32 +02:00
John Ferlan
b975afc725 storage: Allow inputvol to be encrypted
https://bugzilla.redhat.com/show_bug.cgi?id=1613737

When processing the inputvol for encryption, we need to handle
the case where the inputvol is encrypted. This then allows for
the encrypted inputvol to be used either for an output encrypted
volume or an output volume of some XML provided type.

Add tests to show the various conversion options when either input
or output is encrypted. This includes when both are encrypted.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-09-12 07:24:04 -04:00
John Ferlan
8041471858 storage: Allow for inputvol to have any format for encryption
Commit 39cef12a9 altered/fixed the inputvol processing to create
a multistep process when using an inputvol to create an encrypted
output volume; however, it unnecessarily assumed/restricted the
inputvol to be of 'raw' format only.

Modify the processing code to allow the inputvol format to be checked
and used in order to create the encrypted volume.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-09-12 07:24:04 -04:00
John Ferlan
f6aa977fab storage: Remove secretPath from _virStorageBackendQemuImgInfo
There's really no need for it to be there since it's only ever
used inside virStorageBackendCreateQemuImgCmdFromVol

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-09-12 07:24:04 -04:00
Michal Privoznik
e7d9a8f1f0 qemu_domain: Drop namespace check from top level functions
In some cases we are checking if the mount namespace is enabled
at two places: one is at the beginning of exported function (e.g.
qemuDomainNamespaceSetupDisk()) and the other is at the beginning
of qemuDomainNamespaceMknodPaths() which is called from the
former function anyway. Then we have some other functions which
rely on the later check solely.

In order to compensate for possibly needless function call,
qemuDomainNamespaceMknodPaths() returns early if @npaths is zero.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
2018-09-12 10:59:09 +02:00
Shi Lei
ffd31684be util: netlink: Use virNetlinkNewLink helper to simplify virNetDev*Create
This patch simplifies virNetDevBridgeCreate and virNetDevMacVLanCreate
functions by making use of the virNetlinkNewLink helper.

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2018-09-12 09:27:26 +02:00
Shi Lei
b6ba2b961a util: netlink: Add some wrapper macros to get rid of redundancy
This patch adds wrapper macros around nla_nest_[start|end] and nla_put,
thus getting rid of some redundancy and making virNetlinkNewLink more
readable.

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-09-12 09:27:26 +02:00
Shi Lei
a2e5aad003 util: netlink: Introduce virNetlinkNewLink helper
This patch introduces virNetlinkNewLink helper which wraps the common
libnl/netlink code to create a new link.

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-09-12 09:27:26 +02:00
Jim Fehlig
5ea2abb3bf libxl: join with thread receiving migration data
It is possible the incoming VM is not fully started when the finish
phase of migration is executed. In libxlDomainMigrationDstFinish,
wait for the thread receiving the VM to complete before executing
finish phase tasks.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-09-11 09:20:17 -06:00
Jim Fehlig
0149464afc libxl: fix job handling across migration phases on dst
The libxlDomainMigrationDst* functions are a bit flawed in their
handling of modify jobs. A job begins when the destination host
begins receiving the incoming VM and ends after the VM is started.
The finish phase contains another BeginJob/EndJob sequence.

This patch changes the logic to begin a job for the incoming VM
in the prepare phase and end the job in the finish phase.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-09-11 09:19:31 -06:00
Jim Fehlig
47da84e090 libxl: fix job handling across migration phases on src
The libxlDomainMigrationSrc* functions are a bit flawed in their
handling of modify jobs. A job begins at the start of the begin
phase but ends before the phase completes. No job is running for
the remaining phases of migration on the source host.

Change the logic to keep the job running after a successful begin
phase, and end the job in the confirm phase. The job must also end
in the perform phase in the case of error since confirm phase would
not be executed.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-09-11 09:18:41 -06:00
Jim Fehlig
e39c66d3ce libxl: fix logic in P2P migration
libxlDoMigrateSrcP2P() performs all phases of the migration
protocol for peer-to-peer migration. Unfortunately the logic
was a bit flawed since it is possible to skip the confirm
phase after a successfull begin and prepare phase. Fix the
logic to always call the confirm phase after a successful begin
and perform. Skip the confirm phase if begin or perform fail.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-09-11 09:17:44 -06:00
Jim Fehlig
60b4fd9021 libxl: migration: defer removing VM until finish phase
If for any reason the restore of a VM fails on the destination host
in a migration operation, the VM is removed (if not persistent) from
the virDomainObjList, meaning it is no longer available for additional
cleanup or processing in the finish phase. Defer removing the VM from
the virDomainObjList until the finish phase, which already contains
logic to remove the VM.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-09-11 09:15:04 -06:00
Jim Fehlig
e447775273 news: Mention Xen support for PM suspend and wakeup
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
2018-09-11 08:53:08 -06:00