Commit Graph

21283 Commits

Author SHA1 Message Date
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
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
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
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
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
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
Farhan Ali
24149bc060 qemu: Add support for virtio input ccw devices
QEMU on S390 (since v2.11) can support virtio input ccw devices.
So build the qemu command line for ccw devices.

Also add test cases for virtio-{keyboard, mouse, tablet}-ccw.

Signed-off-by: Farhan Ali <alifm@linux.vnet.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2018-03-23 19:40:20 +01:00
Farhan Ali
f79e38795e qemu: Introduce capabilities for virtio input ccw devices
QEMU on S390 (since v2.11) can support virtio input ccw devices.
Introduce qemu capabilities for these devices.

Signed-off-by: Farhan Ali <alifm@linux.vnet.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2018-03-23 19:40:20 +01:00
Farhan Ali
2a0c3490dd qemu: Change default video model type to virtio for S390
S390 guests can only support a virtio-gpu-ccw device as a video
device. So set default video model type to VIR_DOMAIN_VIDEO_TYPE_VIRTIO
for S390 guests.

Signed-off-by: Farhan Ali <alifm@linux.vnet.ibm.com>
2018-03-23 19:40:20 +01:00
Farhan Ali
4bbf7f8cb5 qemu: Add support for virtio-gpu-ccw video device on S390
QEMU on S390 (since v2.11) can support the virtio-gpu-ccw device,
which can be used as a video device.

Signed-off-by: Farhan Ali <alifm@linux.vnet.ibm.com>
2018-03-23 19:40:20 +01:00
Farhan Ali
a6441402a5 qemu: Introduce a new capability for virtio-gpu-ccw
QEMU on S390 (since v2.11) can support virtio-gpu-ccw device.
Let's introduce a new qemu capability for the device.

Signed-off-by: Farhan Ali <alifm@linux.vnet.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2018-03-23 19:40:20 +01:00
Daniel P. Berrangé
f0fd90d722 conf: avoid reporting errors when network driver is disabled
In previous releases all these methods were a no-op if the network
driver is disabled. These helper methods are called unconditionally for
all types of network interface, so must be no-ops if missing. Other code
will already generate an error if the network driver is disabled and a
NIC with type=network is used.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-03-23 15:32:50 +00:00
Daniel P. Berrangé
da1ade7a52 remote: remove some __sun conditionals
The libvirtd daemon has some arbitrary logic to drop privileges, but
only on Solaris platforms. This was added during Xen days, when Xen was
the only driver running in libvirtd. There's no expectation or testing
that this works with the new libxl stack, nor whether dropping
privileges breaks any of the secondary drivers. Finally, we'll be
splitting drivers out into their own independant daemons, so this won't
be applicable to libvirtd in future anyway.

The remote driver client meanwhile arbitrarily disables daemon
auto-spawn when connecting as non-root, breaking a key feature of
libvirt unprivileged connections.

Since we've not had any contributions for Solaris since circa 2012
and we don't do any CI testing we should consider this platform
unmaintained and thus reasonable to remove this cruft. If someone steps
forward to maintain Solaris again, this code would need re-evaluating to
come up with something more targetted.

There's various __sun conditionals in the Xen driver code, but those are
not touched. This is all for the legacy Xen driver, which will be
entirely removed at some point in future, so not benefit to hacking out
just the Solaris parts.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2018-03-23 15:10:25 +00:00
Michal Privoznik
42900ec622 qemu: Build smartcard command line more wisely
https://bugzilla.redhat.com/show_bug.cgi?id=1558317

Similarly to b133fac356 we need to look up alias of CCID
controller when constructing smartcard command line instead of
relying on broken assumption it will always be 'ccid0'. After
user aliases it can be anything.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
2018-03-23 15:57:06 +01:00
John Ferlan
1706bef617 qemu: Fix virQEMUCapsCommands formatting
Starting with commit id 'fab9d6e1' the formatting of:

{ "command-name", QEMU_CAPS_NAME },

was altered to:

{ "command-name", QEMU_CAPS_NAME},

and then commit id 'e2b05c9a' altered that to:

{ "command-name", QEMU_CAPS_NAME}

So, let's just fix that up to make things consistent with the
rest of the structures.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2018-03-23 10:11:17 -04:00
Peter Krempa
9f7373e8c1 qemu: domain: Drop declaration of qemuDomainDefValidateDisk
There is no such function in our code. Commit abca72faa4 added it
spuriously.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-23 15:02:07 +01:00
Peter Krempa
3283950057 qemu: qapi: Return correct entry in virQEMUQAPISchemaTraverse
virQEMUQAPISchemaTraverse would return previous-to-last queried item on
a query. It would not be a problem if checking if the given path exists
since error reporting works properly but if the caller is interested in
the result, it would be wrong.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-23 14:52:07 +01:00
Peter Krempa
57cd22bc54 util: json: Add accessor for looking up JSON value type
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-23 14:52:07 +01:00
Peter Krempa
38b3b20c66 qemu: monitor: Move processing of QMP schema to the new file
The JSON array was processed to the hash table used by the query apis in
the monitor code. Move it to a new helper in qemu_qapi.c.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-23 14:52:07 +01:00
Peter Krempa
ab8c5fe63f qemu: qapi: Fix naming of moved functions
Change the prefix of the functions to 'virQEMUQapi' and rename the two
public APIs so that the verb is put last.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-23 14:52:07 +01:00
Peter Krempa
367697c54c qemu: caps: Move QAPI schema related code into separate file
Extract the code into qemu_qapi.c/h so that we separate it from various
parts of the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-23 14:52:07 +01:00
Peter Krempa
9be9e26b74 util: buffer: Tolerate NULL 'buf' in virBufferStrcat
Most other buffer APIs tolerate the buffer being NULL.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2018-03-23 14:52:07 +01:00
Prafull
3f9e02b40a lxc: report error message raised by the failing function
The code that calls VIR_WARN after a function fails, doesn't
report the error message raised by the failing function.
Such error messages are now reported in lxc/lxc_driver.c

Signed-off-by: Prafullkumar Tale <talep158@gmail.com>
2018-03-23 13:13:38 +00:00