Commit Graph

28953 Commits

Author SHA1 Message Date
Peter Krempa
9c75425aa2 tests: utils: Fix out-of-bounds access to memory in virTestCompareToFile
Similarly to 3506f1ecfd, the contents of 'cmpcontent' may be an empty
string so the following code would access memory out of the array.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-04 12:04:21 +02:00
Daniel P. Berrangé
c018533156 rpm: add deps on rpcgen/libtirpc-devel
Since RPC support moved out of glibc we need to have explicit deps on
the new packages providing this functionality

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-04-03 16:05:51 +01:00
Peter Krempa
a801f0e79b qemu: domain: Move initialization of disk cachemode for <shareable> disks
The qemu command line generator code set disk caching of shareable disks
to 'none' when formatting the command line silently. Move this code to a
common place when preparing the domain definition for startup so that it
does not have to be duplicated.

The new test case shows that the actual cache mode will now be recorded
in the live XML definition.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 15:48:38 +02:00
Peter Krempa
f0a528ce06 tests: qemuxml2argv: Allow testing of config processed at startup
Add a new kind of XML output test for the files in qemuxml2argvtest
where we can validate setup and defaults applied when starting up the
VM.

This is achieved by formatting of the definition processed by the
qemuxml2argvtest into a XML and it's compared against files in
qemuxml2startupxmloutdata. This test is automatically executed if the
output file is present and it's skipped otherwise.

The first example test case is created from 'disk-drive-shared' test
case.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 15:48:38 +02:00
Peter Krempa
6227c8ae5d tests: qemu: Test QCOW2 + LUKS support
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 15:48:38 +02:00
Peter Krempa
026114b564 qemu: command: Add support for qcow2 + luks
The old qcow2 encryption format was buggy, so the new approach is to use
luks inside qcow2. As it turns out, it didn't require that many changes.

It was necessary to fix the command line formatter to stop mangling the
format when secrets are present and specify the encryption format and
secret in correct format.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 15:48:38 +02:00
Peter Krempa
f849efac72 qemu: domain: Validate support for LUKS encryption of QCOW2 images
Reject configurations when qemu would not support the image.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 15:48:38 +02:00
Peter Krempa
b874e297b2 qemu: caps: Add capability for LUKS encrypted qcow2 image support
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 15:48:38 +02:00
Peter Krempa
2d12d9482e qemu: domain: Forbid VIR_STORAGE_FILE_ISO as a disk format
This format is used by the storage driver and other hypervisors but qemu
does not have notion of the 'iso' format and libvirt does not translate
it to anything useful, so it would not work anyways. Users should use
'raw' instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 15:48:38 +02:00
Peter Krempa
d9833497a4 qemu: domain: Forbid VIR_STORAGE_FILE_DIR as a disk format
This is a storage driver type, which is not handled in qemu driver
properly. For accessing directories, disk type 'dir' is used instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 15:48:38 +02:00
Peter Krempa
00e394a2c5 qemu: domain: Forbid storage type 'cow' in qemu
QEMU does not support it so save us the hassle and forbid it right away.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 15:48:38 +02:00
Peter Krempa
4a8d1f7d9e qemu: domain: Add helper to initialize detected parts of the backing chain
It will be necessary to initialize various aspects for the detected
members of the backing chain. Add a function that will handle it and
call it from qemuDomainPrepareDiskSource and qemuDomainDetermineDiskChain

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 15:48:38 +02:00
Peter Krempa
8fc5e5bfdc conf: Extract logic for updating 'detect_zeroes' mode
For some reason we've decided to silently translate the disk
detect_zeroes mode if it would be invalid. Extract the
logic so that it does not need to be copypasta'd across the code base.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 15:48:37 +02:00
Peter Krempa
1cb7f41568 conf: Don't require 'def' in virDomainDiskDefParse
In some use cases (mostly in tests) it is not required to check the
seclabel definition validity. Add possibility to call
virDomainDiskDefParse without the domain definition.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 15:48:37 +02:00
Peter Krempa
295b128e09 conf: Refactor/rename virDomainDiskDefSourceParse
Make the function more usable by returning the full disk definition and
fix the only caller for the new semantics. The new name for the function
is virDomainDiskDefParse.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 15:48:37 +02:00
Peter Krempa
dff110d232 tests: utils: Tolerate NULL actual data in virTestCompareToFile
The function docs state that 'strcontent' may be NULL. This was added in
8b3a0b28ba but that commit neglected to fix rest of the function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 15:48:37 +02:00
Jiri Denemark
452c2cc7e7 qemu_monitor_json: Properly check "return" type
My commit 2e0d6cdec4 claimed qemuMonitorJSONCheckError guarantees
"return" object exists in the JSON reply. But it only makes sure the key
is there, while the type of the value is not checked. A lot of callers
do not care since they only want to see whether their QMP command failed
or not, but any caller which needs to read some data from the reply
wants to make sure the correct data type was returned.

This patch adds a new API called qemuMonitorJSONCheckReply which calls
qemuMonitorJSONCheckError and checks "return" contains a value of the
specified type.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2018-04-03 14:13:07 +02:00
Peter Krempa
56b7d94f11 util: json: Privatize struct _virJSONValue and sub-structs
Enforce usage of accessors by hiding the implementation in the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 13:34:33 +02:00
Peter Krempa
167028e37f qemu: monitor: Don't resist stealing 'actions' in qemuMonitorJSONTransaction
Rather than trying to prevent stealing of the 'actions' virJSONValue
into the monitor command replace the code so that it does the same
thing, since 'actions' was actually not really used after calling the
monitor.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 13:34:33 +02:00
Peter Krempa
66cb1fa231 util: qemu: Don't access virJSONValue directly in virQEMUBuildCommandLineJSONRecurse
Use the accessors instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 13:34:33 +02:00
Peter Krempa
1cbe6aa220 util: json: Add accessor for geting a VIR_JSON_TYPE_NUMBER as string
Sometimes it's desired to get a JSON number as string. Add a helper.
This will help in cases where we'd want to convert the internal type from
string to something else.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 13:34:33 +02:00
Peter Krempa
0f0ad1116c json: Replace access to virJSONValue->type by virJSONValueGetType
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 13:34:33 +02:00
Peter Krempa
91813b8783 qemu: agent: Avoid unnecessary JSON object type check
Use virJSONValueObjectGetArray instead of virJSONValueObjectGet so that
it's not necessary to check whether it's an array.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 13:34:33 +02:00
Peter Krempa
d78a91afee qemu: monitor: Use virJSONValueObjectKeysNumber in qemuMonitorJSONGetCPUModelExpansion
Replace direct access to virJSONValue members by accessor.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 13:34:33 +02:00
Peter Krempa
d4dd836edc tests: json: Validate that attribute values are properly stolen
Make sure that the 'a' and 'A' modifiers for virJSONValueObjectAddVArgs
behave correctly.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 13:34:33 +02:00
Peter Krempa
ea520f6b67 util: json: Fix freeing of objects appended to virJSONValue
It was not possible to determine whether virJSONValueObjectAddVArgs and
the functions using it would consume a virJSONValue or not when used
with the 'a' or 'A' modifier depending on when the loop failed.

Fix this by passing in a pointer to the pointer so that it can be
cleared once it's successfully consumed and the callers don't have to
second-guess leaving a chance of leaking or double freeing the value
depending on the ordering.

Fix all callers to pass a double pointer too.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-04-03 13:34:33 +02:00
Radostin Stoyanov
5dda119a44 lxc_container: Set source file description
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
2018-04-03 11:32:48 +02:00
Erik Skultety
52bddb1b60 news: Update release news with mediated devices hot {plug,unplug}
Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-04-03 07:33:30 +02:00
Erik Skultety
5905291402 qemu: hotplug: Introduce hot unplug for mediated devices
Mediated devices support hot-{plug,unplug} since their introduction in
kernel 4.10, however libvirt has still been missing support for this.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-04-03 07:25:07 +02:00
Erik Skultety
70d193de19 qemu: hotplug: Introduce hot plug support for mediated devices
Mediated devices support hot-{plug,unplug} since their introduction in
kernel 4.10, however libvirt has still been missing support for this.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2018-04-03 07:25:07 +02:00
John Ferlan
849b6a7b6a lxc: Use virDomainObjEndAPI after FindByName
For consistency, rather than open coding the Unref and Unlock,
just use the virDomainObjEndAPI API.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-04-02 09:38:19 -04:00
Kashyap Chamarthy
bb0e0bcf6a docs: formatdomain: Clarify CPU feature policy option "require"
Using the 'require' value for the 'policy' attribute indicates
that the guest will have the feature so the host CPU does not
need to support it if the hypervisor can emulate it.

E.g. 'x2apic' is emulated by QEMU even if the host does not support it:

    <feature policy='require' name='x2apic'/>

Signed-off-by: Kashyap Chamarthy <kchamart@redhat.com>
2018-04-02 06:42:13 -04:00
Ján Tomko
439c27b1ae qemu: s/acceptible/acceptable/
Prefer the contemporary spelling.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-04-01 18:00:35 +02:00
Ján Tomko
6f5161fe54 qemuDomainRemoveDevice: add qemuDomainRemoveWatchdog
qemuDomainDetachWatchdog uses the infrastructure for waiting
for the DEVICE_DELETED event, but the asynchronous delete
was not implemented.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-04-01 17:59:48 +02:00
Ján Tomko
1943d89b72 Replace QEmu with QEMU
QEMU is the preferred spelling used on QEMU website.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-04-01 17:42:29 +02:00
Pino Toscano
5c744a2d44 vmx: convert any amount of NICs
Scan the parsed VMX file, and gather the biggest index of the network
interfaces there: this way, it is possible to parse all the available
network interfaces, instead of just 4 maximum.

Add the VMX file attached to RHBZ#1560917 as testcase esx-in-the-wild-8.

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

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2018-04-01 12:43:42 +02:00
Pino Toscano
e508e04b10 internal: add STRCASEPREFIX
Simple macro to check the prefix of a string in a case-insensitive way.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2018-04-01 12:43:42 +02:00
Pino Toscano
6d394989fd vmx: allocate space for network interfaces if needed
Dynamically grow the array of network interfaces for each interface
read, instead of using a single array of size 4.  This way, in the
future it will be easier to not limit the number of network interfaces
(which this patch still does not change).

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2018-04-01 12:43:42 +02:00
Pino Toscano
5d5430e1fc vmx: check for present/enabled devices earlier
When parsing filesystems, network interfaces, serial ports, and
parallel ports, check earlier whether they are present/enabled, delaying
the allocation of the objects.

This is mostly a small optimization, with no behaviour change.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
2018-04-01 12:43:42 +02:00
Michal Privoznik
c4c32cb300 qemu: Use dynamic buffer for storing PTY aliases
https://bugzilla.redhat.com/show_bug.cgi?id=1560976

For historical reasons we've used 32 bytes long static buffer for
storing PTY aliases. This breaks users scenario where they try to
start a machine with user alias consisting of "ua-$uuid".

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-04-01 12:38:38 +02:00
Michal Privoznik
0cd8068425 Post-release version bump to 4.3.0
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2018-04-01 12:32:36 +02:00
Daniel Veillard
2b7bb7027d Release of libvirt-4.2.0
* docs/news.xml: updated
* po/*.po*: regenerated

Signed-off-by: Daniel Veillard <veillard@redhat.com>
2018-04-01 10:21:27 +02:00
Chen Hanxiao
c595fc788e virsh: add missing help info of --source to domifaddr
commit b4b5c82ce forgot to add this.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
2018-03-29 13:29:49 -04:00
Daniel P. Berrangé
17f223d1aa remote: remove outdated comment about Solaris
When removing a conditional in:

  commit da1ade7a52
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Fri Mar 23 10:50:59 2018 +0000

    remote: remove some __sun conditionals

the corresponding comment was mistakenly left behind.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-03-28 16:12:59 +01:00
John Ferlan
5bb07527c1 openvz: Cleanup indention
Some of the indents were only 2 spaces, make consistent w/ 4 spaces.
Also some indents didn't align properly. Fix them all up.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
2018-03-26 11:20:04 -04:00
Ján Tomko
a1745174e9 qemu: do not drop implicit controllers with non-implicit attributes
If someone set a user alias or pcihole64 on an implicit controller,
we need to format it to migrate the domain properly.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reported-by: Joseph Richard <Joseph.Richard@windriver.com>
2018-03-26 15:13:26 +02:00
Ján Tomko
186412fe76 virDomainDeviceAliasIsUserAlias: tolerate NULL
Do not crash in virDomainDeviceInfoParseXML if someone provides
an 'alias' element without a 'name' attribute.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
2018-03-26 15:13:26 +02:00
Ján Tomko
5123e6ed1f polkit: reintroduce check for pkcheck
Commit 2499d1a0 was too eager and possibly enabled polkit
on all platforms with D-Bus, regardless of whether they use polkit.

Reintroduce the usage of pkcheck as a witness for --with-polkit=check,
but do not require it for --with-polkit=yes.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reported-by: Jiří Denemark <jdenemar@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-03-25 22:27:22 +02:00
Rainer Müller
c28d837c0f build: Remove --with-xml-catalog-file option
After validation against XHTML 1.0 was dropped in f802c9de0,
the XML_CATALOG_FILE is not in use anymore. Therefore the checks in
configure can be removed.

Signed-off-by: Rainer Müller <raimue@codingfarm.de>
2018-03-25 19:49:25 +02:00
Andrea Bolognani
7dd5b0c54b tests: qemucapabilities: Drop mostly duplicated data
When GIC support was introduced (QEMU 2.6 timeframe) we needed
to make sure both GICv2 hardware and GICv3 hardware were handled
correctly, and that was achieved by having separate capabilities
data for each.

Now that we have capabilities data for several QEMU versions we
can stop storing data for GICv2 and GICv3 hardware separately,
and instead have GICv2 data for QEMU <= 2.10 and GICv3 data for
QEMU >= 2.12, without losing any coverage.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2018-03-23 20:27:52 +01:00