Commit Graph

18070 Commits

Author SHA1 Message Date
Michal Privoznik
b093e85224 qemuBuildVhostuserCommandLine: Unify -netdev creation
Currently, what we do for vhost-user network is generate the
following part of command line:

-netdev type=vhost-user,id=hostnet0,chardev=charnet0

There's no need for 'type=' it is the default. Drop it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-10-14 11:45:01 +08:00
Michal Privoznik
0c61cf3158 qemuBuildVhostuserCommandLine: Reuse qemuBuildChrChardevStr
There's no need to reinvent the wheel here. We already have a
function to format virDomainChrSourceDefPtr. It's called
qemuBuildChrChardevStr(). Use that instead of some dummy
virBufferAsprintf().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-10-14 11:44:53 +08:00
Michal Privoznik
336d4a71fe qemuBuildChrChardevStr: Introduce @nowait argument
This alone makes not much sense. But the aim is to reuse this
function in qemuBuildVhostuserCommandLine() where 'nowait' is not
supported for vhost-user devices.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-10-14 10:15:51 +08:00
Michal Privoznik
1dcbef8a0f qemuBuildHostNetStr: Explicitly enumerate net types
We tend to prevent using 'default' in switches. And it is for a
good reason - control may end up in paths we wouldn't want for
new values. In this specific case, if qemuBuildHostNetStr is
called over VIR_DOMAIN_NET_TYPE_VHOSTUSER it would produce
meaningless output. Fortunately, there no such call yet.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-10-14 10:15:51 +08:00
Michal Privoznik
c266b60440 qemuDomainAttachNetDevice: Explicitly list allowed types for hotplug
Instead of blindly claim support for hot-plugging of every
interface type out there we should copy approach we have for
device types: white listing supported types and explicitly error
out on unsupported ones.
For instance, trying to hotplug vhostuser interface results in
nothing usable from guest currently. vhostuser typed interfaces
require additional work on our side.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-10-14 10:15:51 +08:00
Michal Privoznik
5b65d772dd qemuDomainAttachNetDevice: Move hostdev handling a bit further
The idea is to have function that does some checking at its
beginning and then have one big switch for all the interface
types it supports.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-10-14 10:15:51 +08:00
Michal Privoznik
0bce012d7f qemuBuildInterfaceCommandLine: Move from if-else forest to switch
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-10-14 10:15:51 +08:00
Michal Privoznik
4a74ccdb92 qemuBuildInterfaceCommandLine: Move vhostuser handling a bit further
The idea is to have function that does some checking of the
arguments at its beginning and then have one big switch for all
the interface types it supports. Each one of them generating the
corresponding part of the command line.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-10-14 10:15:51 +08:00
Michal Privoznik
ec7f612a56 qemuBuildInterfaceCommandLine: Move hostdev handling a bit further
The idea is to have function that does some checking of the
arguments at its beginning and then have one big switch for all
the interface types it supports. Each one of them generating the
corresponding part of the command line.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-10-14 10:15:51 +08:00
Michal Privoznik
507032d98d virDomainNetGetActualType: Return type is virDomainNetType
This function for some weird reason returns integer instead of
virDomainNetType type. It is important to return the correct type
so that we know what values we can expect.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-10-14 10:15:51 +08:00
Michal Privoznik
94a10de26b virDomainNetDefParseXML: Realign
There are couple of formatting issues. No functional change
though.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-10-14 10:15:51 +08:00
Michal Privoznik
a564568f06 virLogDefineOutputs: Fix build without syslog.h
Not every system out there has syslog, that's why we check for it
in our configure script. However, in 640b58abdf while fixing
another issue, some variables and functions are called that are
defined only when syslog.h is present. But these function
calls/variables were not guarded by #ifdef-s.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-10-14 10:12:49 +08:00
Peter Krempa
fef3a810c7 qemu: command: escape smbios entry strings
We pass free-form strings from the users to qemu, thus we need escape
commas since they are passed to qemu monitor.

Partially resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1373535
2016-10-14 04:04:05 +02:00
Peter Krempa
ec45439512 qemu: command: Don't bother reporting errors in smbios formatters
qemuBuildSmbiosBiosStr and qemuBuildSmbiosSystemStr return NULL if
there's nothing to format on the commandline. Reporting errors from
buffer creation doesn't make sense since it would be ignored.
2016-10-14 04:03:52 +02:00
Peter Krempa
8d67e2849e qemu: command: Fix up coding style of smbios commandine formatters 2016-10-14 03:52:34 +02:00
Michal Privoznik
b7d2d4af2b src: Treat PID as signed
This initially started as a fix of some debug printing in
virCgroupDetect. However it turned out that other places suffer
from the similar problem. While dealing with pids, esp. in cases
where we cannot use pid_t for ABI stability reasons, we often
chose an unsigned integer type. This makes no sense as pid_t is
signed.
Also, new syntax-check rule is introduced so we won't repeat this
mistake.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-10-13 17:58:56 +08:00
Michal Privoznik
e1a33ed18c testNodeGetCellsFreeMemory: Fix off by one error
Consider the following scenario:

  virsh # freecell --all
      0:       2048 KiB
      1:       4096 KiB
  --------------------
  Total:       6144 KiB

  virsh # freecell 0
  0: 2048 KiB

  virsh # freecell 1
  1: 4096 KiB

And now before this change:

  virsh # freecell 2

After this change:

  virsh # freecell 2
  error: invalid argument: Range exceeds available cells

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-10-13 09:26:41 +08:00
Michal Privoznik
c72690e279 testOpenDefault: Rename loop variable
We have inclination to calling our loop variables i, j, k, not u.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-10-13 09:26:35 +08:00
Pavel Hrdina
fb8f3b1c22 qemu_command: add support to use virtio as secondary video device
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1369633

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-10-12 17:46:48 +02:00
Pavel Hrdina
ac987148a8 qemu_command: introduce enum of secondary models for video device
There are two video devices with models without VGA compatibility mode.
They are primary used as secondary video devices, but in some cases it
is required to use them also as primary video devices.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-10-12 17:46:48 +02:00
Pavel Hrdina
724d51786e qemu_command: cleanup qemuBuildVideoCommandLine
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-10-12 17:46:48 +02:00
Pavel Hrdina
4c029e8cfa qemu_command: properly detect which model to use for video device
This improves commit 706b5b6277 in a way that we check qemu capabilities
instead of what architecture we are running on to detect whether we can
use *virtio-vga* model or not.  This is not a case only for arm/aarch64.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-10-12 17:46:48 +02:00
Pavel Hrdina
6869428c12 qemu_capabilities: check for existence of virtio-vga
Commit 21373feb added support for primary virtio-vga device but it was
checking for virtio-gpu.  Let's check for existence of virtio-vga if we
want to use it.

Virtio video device is currently represented by three different models
*virtio-gpu-device*, *virtio-gpu-pci* and *virtio-vga*.  The first two
models are tied together and if virtio video devices is compiled in they
both exist.  However, the *virtio-vga* model doesn't have to exist on
some architectures even if the first two models exist.  So we cannot
group all three together.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-10-12 17:46:48 +02:00
Pavel Hrdina
9562fb55bf qemu_command: pass only video device to qemuBuildVgaVideoCommand
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-10-12 17:46:47 +02:00
Pavel Hrdina
55d5a9bc06 qemu_command: separate code for video device via -vga attribute
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-10-12 17:46:47 +02:00
Pavel Hrdina
33af92a91c qemu_process: always check capabilities for video devices
Before this patch we've checked qemu capabilities for video devices
only while constructing qemu command line using "-device" option.

Since we support qemu only if "-device" option is present we can use
the same capabilities to check also video devices while using "-vga"
option to construct qemu command line.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-10-12 17:46:47 +02:00
Pavel Hrdina
8fed30d004 qemu_process: move video validation out of qemu_command
Runtime validation that depend on qemu capabilities should be moved
into qemuProcessStartValidateXML.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-10-12 17:46:47 +02:00
Pavel Hrdina
133fb1401f qemu_domain: move video validation out of qemu_command
All definition validation that doesn't depend on qemu capabilities
and was allowed previously as valid definition should be placed into
qemuDomainDefValidate.

The check whether video type is supported or not was based on an enum
that translates type into model.  Use switch to ensure that if new
video type is added, it will be properly handled.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-10-12 17:46:47 +02:00
Pavel Hrdina
f5eae0a595 qemu_capabilities: detect properties for virtio-gpu-device
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-10-12 17:46:47 +02:00
Pavel Hrdina
db4491571d qemu_capabilities: rename QEMU_CAPS_VIRTIO_GPU_VIRGL
We generally uses QEMU_CAPS_DEVICE_$NAME to probe for existence of some
device and QEMU_CAPS_$NAME_$PROP to probe for existence of some property
of that device.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-10-12 17:46:47 +02:00
Pavel Hrdina
05af6784b1 qemu_capabilities: mark QEMU_CAPS_VGA_QXL capability as deprecated
If QEMU in question supports QMP, this capability is set if
QEMU_CAPS_DEVICE_QXL was set based on existence of "-device qxl". If
libvirt needs to parse *help*, because there is no QMP support, it
checks for existence of "-vga qxl", but it also parses output of
"-device ?" and sets QEMU_CAPS_DEVICE_QXL too.

Now that libvirt supports only QEMU that has "-device" implemented it's
safe to drop this capability and stop using it.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-10-12 17:46:47 +02:00
Pavel Hrdina
34a4447bd4 qemu_capabilities: join capabilities for qxl and qxl-vga devices
This patch simplifies QEMU capabilities for QXL video device.  QEMU
exposes this device as *qxl-vga* and *qxl* and they are both the same
device with the same set of parameters, the only difference is that
*qxl-vga* includes VGA compatibility.

Based on QEMU code they are tied together so it's safe to check only for
presence of only one of them.

This patch also removes an invalid test case "video-qxl-sec-nodevice"
where there is only *qxl-vga* device and *qxl* device is not present.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-10-12 17:46:47 +02:00
Pavel Hrdina
971d552e68 qemu_command: remove xenner leftover from video device code
Qemu supports *xen* video device only with XEN and this code was part
of xenner code.  We dropped support for xenner in commit de9be0a.

Before this patch if you used 'xen' video type you ended up with
domain without any video device at all.  Now we don't allow to start
such domain.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-10-12 17:46:47 +02:00
Pavel Hrdina
3632ddc766 qemu_process: move qemuProcessStartValidateGraphics to correct place
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-10-12 17:46:46 +02:00
Peter Krempa
3507af63ae util: bitmap: Make bitmaps const in virBitmapNewData and virBitmapDataToString
The functions just read the passed pointer so it can be marked as const.
2016-10-12 17:29:07 +02:00
Martin Kletzander
d17fab69be qemu: Disable migration with ivshmem
It was never safe anyway and as such shouldn't have been enabled in the
first place.  Future patches will allow hot-(un)pluging of some ivshmem
devices as a workaround.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-10-12 13:08:28 +02:00
Martin Kletzander
d7107959c3 conf: Don't complicate find loop
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-10-12 13:08:28 +02:00
Martin Kletzander
ae612493ff conf: Fix virDomainShmemDefFind
Due to the switch of parameters in a call to virDomainShmemDefEquals()
no device was found when looking for device with all the information
except address.  Also fix the indentation.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-10-12 13:08:28 +02:00
Martin Kletzander
44bf83e313 Clean timer in virObjectEventStateFlush
If the last event callback is unregistered while the event loop is
dispatching, it is only marked as deleted, but not removed.  The number
of callbacks is more than zero in that case, so the timer is not
removed.  Because it can be removed in this function now (but also
accessed afterwards so that we set 'isDispatching = false' and have it
locked), we need to temporarily increase the reference counter of the
state for the duration of this function.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-10-12 12:54:47 +02:00
Martin Kletzander
6fecf9523a De-duplicate code into virObjectEventStateCleanupTimer()
There is a repeating pattern of code that removes the timer if it's not
needed.  So let's move it to a new function.  We'll also use it later.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-10-12 12:54:47 +02:00
Martin Kletzander
3d279e23e7 Reference state when using it as opaque
There should be one more reference because it is being kept in the list
of callbacks as an opaque.  We also unref it properly using
virObjectFreeCallback.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-10-12 12:54:47 +02:00
Martin Kletzander
1827f2ac5d Change virDomainEventState to virObjectLockable
This way we get reference counting and we can get rid of locking
function.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-10-12 12:54:47 +02:00
Corey S. McQuay
8ee8f939fe qemu: migration: Disallow migration of read only disk
Currently Libvirt allows attempts to migrate read only disks. Qemu
cannot handle this as read only disks cannot be written to on the
destination system. The end result is a cryptic error message and a
failed migration.

This patch causes migration to fail earlier and provides a meaningful
error message stating that migrating read only disks is not supported.

Signed-off-by: Corey S. McQuay <csmcquay@linux.vnet.ibm.com>
Reviewed-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2016-10-12 10:14:20 +02:00
Peter Krempa
043ba4a40a qemu: Reuse virDomainDeGetVcpusTopology to calculate total vcpu count
Rather than multiplying sockets, cores, and threads use the new helper
for getting the vcpu count resulting from the topology.
2016-10-11 13:52:09 +02:00
Peter Krempa
da0d82d15f conf: Sanitize cpu topology numbers
Make sure that the topology results into a sane number of cpus (up to
UINT_MAX) so that it can be sanely compared to the vcpu count of the VM.

Additionally the helper added in this patch allows to fetch the total
number the topology results to so that it does not have to be
reimplemented later.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1378290
2016-10-11 13:52:09 +02:00
John Ferlan
6aba53468a util: Remove need for local 'nelems'
Since it's only used in loop - just go direct.
2016-10-10 16:08:39 -04:00
John Ferlan
6de78c63a4 util: Resolve memory leaks in virLogParse{Output|Filter}
In both virLogParseOutput and virLogParseFilter, rather than returning
NULL, goto cleanup since it's possible that for each the first condition
passes, but the || condition doesn't and thus we leak memory.
2016-10-10 15:27:45 -04:00
John Ferlan
c951cdbff9 conf: Remove incorrect check when encoding shmem audit message
Remove the !size check since size is initialized to NULL and thus
causing the condition to always be true
2016-10-10 15:27:45 -04:00
Martin Wilck
4ac20b3ae4 network: add dnsmasq option 'dhcp-authoritative'
The dnsmasq man page recommends that dhcp-authoritative "should be
set when dnsmasq is definitely the only DHCP server on a network".
This is the case for libvirt-managed virtual networks.

The effect of this is that VMs that fail to renew their DHCP lease
in time (e.g. if the VM or host is suspended) will be able to
re-acquire the lease even if it's expired, unless the IP address has
been taken by some other host. This avoids various annoyances caused
by changing VM IP addresses.
2016-10-10 15:15:11 -04:00
Martin Kletzander
77d24de674 Don't update timer if there's none.
Sometimes virObjectEventStateFlush can be called without timer (if the
last event was unregistered right when the timer fired).  There is a
check for timer == -1, but that triggers warning and other log messages,
which is unnecessary.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-10-10 11:15:00 +02:00
Erik Skultety
6fe47467cb virlog: Split parsing and setting priority
Handling of outputs and filters has been changed in a way that splits
parsing and defining. Do the same thing for logging priority as well, this
however, doesn't need much of a preparation.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:25 +02:00
Erik Skultety
adda3e4f9b virlog: Remove functions that aren't used anywhere anymore
This is mainly virLogAddOutputTo* which were replaced by virLogNewOutputTo* and
the previously poorly named ones virLogParseAndDefine* functions. All of these
are unnecessary now, since all the original callers were transparently switched
to the new model of separate parsing and defining logic.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:25 +02:00
Erik Skultety
30b650b2ba daemon: Split filter parsing and filter defining
Similar to outputs, parser should do parsing only, thus the 'define' logic
is going to be stripped from virLogParseAndDefineFilters by replacing calls to
this method to virLogSetFilters instead.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:25 +02:00
Erik Skultety
c9279169a1 daemon: Split output parsing and output defining
Since virLogParseAndDefineOutputs is going to be stripped from 'output defining'
logic, replace all relevant occurrences with virLogSetOutputs call to make the
change transparent to all original callers (daemons mostly).

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:25 +02:00
Erik Skultety
c33babfe31 virlog: Introduce virLogSetFilters
This method will eventually replace virLogParseAndDefineFilters which
currently does both parsing and defining.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:25 +02:00
Erik Skultety
6db7b8cbb5 virlog: Introduce virLogSetOutputs
This API is the entry point to output modification of the logger. Currently,
everything is done by virLogParseAndDefineOutputs. Parsing and defining will be
split into two operations both handled by this method transparently.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:25 +02:00
Erik Skultety
09d7ced8ee virlog: Introduce virLogParseFilters
Abstraction added over parsing a single filter. The method parses potentially a
set of logging filters, while adding each filter logging object to a
caller-provided array.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:25 +02:00
Erik Skultety
4b266c180b virlog: Introduce virLogParseOutputs
Another abstraction added on the top of parsing a single logging output. This
method takes and parses the whole set of outputs, adding each single output
that has already been parsed into a caller-provided array. If the user-supplied
string contained duplicate outputs, only the last occurrence is taken into
account (all the others are removed from the list), so we silently avoid
duplicate logs.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:25 +02:00
Erik Skultety
77a45f2ff0 virlog: Introduce virLogParseFilter
Same as for outputs, introduce a new method, that is basically the same as
virLogParseAndDefineFilter with the difference that it does not define the
filter. It rather returns a newly created object that needs to be inserted into
a list and then defined separately.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:24 +02:00
Erik Skultety
09b7cbb121 virlog: Introduce virLogParseOutput
Introduce a method to parse an individual logging output. The difference
compared to the virLogParseAndDefineOutput is that this method does not define
the output, instead it makes use of the virLogNewOutputTo* methods introduced
in the previous patch and just returns the virLogOutput object that has to be
added to a list of object which then can be defined as a whole via
virLogDefineOutputs. The idea remains still the same - split parsing and
defining of the logging primitives (outputs, filters).
Additionally, since virLogNewOutputTo* methods are now finally used,
ATTRIBUTE_UNUSED can be successfully removed from the methods' definitions,
since that was just to avoid compiler complaints about unused static functions.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:24 +02:00
Erik Skultety
640b58abdf virlog: Take a special care of syslog when setting new set of log outputs
Now that we're in the critical section, syslog connection can be re-opened
by issuing openlog, which is something that cannot be done beforehand, since
syslog keeps its file descriptor private and changing the tag earlier might
introduce a log inconsistency if something went wrong with preparing a new set
of logging outputs in order to replace the existing one.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:24 +02:00
Erik Skultety
4c35229580 virlog: Introduce virLogNewOutputTo* as a replacement for virLogAddOutputTo*
Continuing with the effort to split output parsing and defining, these new
functions return a logging object reference instead of defining the output.
Eventually, these functions will replace the existing ones (virLogAddOutputTo*)
which will then be dropped.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:24 +02:00
Erik Skultety
58ab1b6f89 virlog: Introduce virLogDefineFilters
Prepare a method that only defines a set of filters. It takes a list of
filters, preferably created by virLogParseFilters. The original set of filters
is reset and replaced by the new user-provided set of filters.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:24 +02:00
Erik Skultety
d9d6b61f6d virlog: Introduce virLogDefineOutputs
Prepare a method that only defines a set of outputs. It takes a list of
outputs, preferably created by virLogParseOutputs. The original set of outputs
is reset and replaced by the new user-provided set of outputs.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:24 +02:00
Erik Skultety
b5004b09f5 virlog: Introduce virLogFindOutput
Outputs are a bit trickier than filters, since the user(config)-specified
set of outputs can contain duplicates. That would lead to logging the same
message twice. For compatibility reasons, we cannot just error out and forbid
the daemon to start if we find duplicate outputs which do not make sense.
Instead, we could silently take into account only the last occurrence of the
duplicate output and remove all the previous ones, so that the logger will not
try to use them when it is looping over all of its registered outputs.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:24 +02:00
Erik Skultety
435200cab4 virlog: Introduce virLogFilterNew
This method allocates a new filter object which it then returns back to caller.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:24 +02:00
Erik Skultety
b0f5dc9147 virlog: Introduce virLogOutputNew
In order to later split output parsing and output defining, introduce a new
function which will create a new virLogOutput object which the parser will
insert into a list with the list being eventually defined.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:24 +02:00
Erik Skultety
a2405a889e virlog: Store the journald fd within the output object
There is really no reason why we could not keep journald's fd within the
journald output object the same way as we do for regular file-based outputs.
By doing this we later won't have to special case the journald-based output
(due to the fd being globally shared) when replacing the existing set of outputs
with a new one. Additionally, by making this change, we don't need the
virLogCloseJournald routine anymore, plain virLogCloseFd will suffice.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:24 +02:00
Erik Skultety
b8c370a96e virlog: Rename virLogParse* to virLogParseAndDefine*
Right now virLogParse* functions are doing both parsing and defining of filters
and outputs which should be two separate operations. Since the naming is
apparently a bit poor this patch renames these functions to
virLogParseAndDefine* which eventually will be replaced by virLogSet*.
Additionally, virLogParse{Filter,Output} will be later (after the split) reused,
so that these functions do exactly what the their name suggests.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:24 +02:00
Erik Skultety
6aa3a6a48f virlog: Remove unused macro IS_SPACE
During first stage of virlog.c refactor, commit 0b231195 forgot to remove the
macro definition along with its usage.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-10 08:27:24 +02:00
John Ferlan
0f3f8ac97e util: Check/ignore already disabled event
If the event is already disabled, then don't bother with setting it
disabled again.  Causes unnecessary error on systems that don't support
the feature anyway.
2016-10-07 13:27:21 -04:00
John Ferlan
12b2aebeba util: Clear up some perf error messages
Make it clearer that the perf event is based/for the host cpu and
use the virPerfEventTypeToString to convert the type to a string
2016-10-07 13:27:21 -04:00
John Ferlan
12629888fc docs: Alter descriptions of perf cpu_cycles
https://bugzilla.redhat.com/show_bug.cgi?id=1381714

Alter the descriptions to match what the cpu_cycles actually is
2016-10-07 13:27:16 -04:00
Daniel P. Berrange
5dee668632 qemu: fix command line building for iommu devices
The intel-iommu device has existed since QEMU 2.2.0, but
it was only possible to create it with -device since
QEMU 2.7.0, thanks to:

  commit 621d983a1f9051f4cfc3f402569b46b77d8449fc
  Author: Marcel Apfelbaum <marcel@redhat.com>
  Date:   Mon Jun 27 18:38:34 2016 +0300

    hw/iommu: enable iommu with -device

    Use the standard '-device intel-iommu' to create the IOMMU device.
    The legacy '-machine,iommu=on' can still be used.

The libvirt capability check & command line formatting code
is thus broken for all QEMU versions 2.2.0 -> 2.6.0 inclusive.

This fixes it to use iommu=on instead.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-10-07 16:52:35 +01:00
Erik Skultety
1eeeb1e89b private_syms: add virLogFilterListFree to libvirt_private.syms
Commit 660468b1 forgot to add it, so let's add it now to prevent future linker
issues.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-10-06 18:13:43 +02:00
Peter Krempa
9bc4179dd4 qemu: monitor: Properly configure backend for UDP chardevs
Since introduction of chardev hotplug the code was wrong for the UDP
case and basically created a TCP socket instead. Use proper objects and
type for UDP.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1377602
2016-10-06 09:13:39 +02:00
Peter Krempa
386fe237b2 qemu: monitor: Simplify construction of chardev backends 2016-10-06 09:13:39 +02:00
Peter Krempa
4a0da345d0 conf: Sanitize formatting of UDP chardev source
Use much simpler logic to determine parts of the code to print.
2016-10-06 08:56:51 +02:00
John Ferlan
c7d3cf2e3b conf: Add a formatting macro for all the blkiotune values
Rather than copy-paste - use a macro

Unfortunately due to how the RNG schema was written keeping the 'value'
and 'value'_max next to each other in the XML causes a schema failure,
so the FORMAT has to write out singly rather than optimizing to write
out both values at once

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-10-05 18:53:55 -04:00
John Ferlan
85f05f66f4 qemu: Adjust how supportMaxOptions is used.
We're about to add more options, let's avoid having multiple if-then-else
which each try to set up the qemuMonitorJSONMakeCommand call with all the
parameters it knows about.

Instead, use the fact that when a NULL is found in the argument list that
processing of the remaining arguments stops and just have call.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-10-05 18:53:55 -04:00
John Ferlan
a1417d5305 qemu: Convert from shorthand to longer throttling names
We're about to add 6 new options and it appears (from testing) one cannot
utilize both the shorthand (alias) and (much) longer names for the arguments.
So modify the command builder to use the longer name and of course alter the
test output .args to have the similarly innocuous long name.

Also utilize a macro to build that name makes it so much more visually
appealing and saves a few characters or potential cut-n-paste issues.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-10-05 18:53:55 -04:00
Laine Stump
22afd44171 qemu: allow 32 slots on pcie-expander-bus, not just 1
When I added support for the pcie-expander-bus controller in commit
bc07251f, I incorrectly thought that it only had a single slot
available. Actually it has 32 slots, just like the root complex aka
pcie-root (the part that I *did* get correct is that unlike pcie-root
a pcie-expander-bus doesn't allow any integrated endpoint devices -
only pcie-root-ports and dmi-to-pci-controllers are allowed).
2016-10-05 12:40:53 -04:00
John Ferlan
59539ebff3 qemu: Create helper qemuMonitorJSONGetBlockDevDevice
This will fetch "this device" from the recently returned 'dev' and perform
common error checking for the paths that call it.
2016-10-05 11:12:27 -04:00
John Ferlan
c6c5fc0b2b qemu: Create helper qemuMonitorJSONGetBlockDev
This will grab the 'dev' from devices and do the common validation checks.
2016-10-05 11:12:26 -04:00
John Ferlan
b0ab72bd43 qemu: Create common code for JSON "query-block" call
Reduce some cut-n-paste code by creating common helper. Make use of the
recently added virJSONValueObjectStealArray to grab the devices list as
part of the common code (we we can Free the reply) and return devices for
each of the callers to continue to parse.

NB: This also adds error checking to qemuMonitorJSONDiskNameLookup

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-10-05 11:12:26 -04:00
John Ferlan
ebf8b783bf util: Introduce virJSONValueObjectStealArray
Provide the Steal API for any code paths that will desire to grab the
object array and then free it afterwards rather than relying to freeing
the whole chain from the reply.
2016-10-05 11:12:02 -04:00
John Ferlan
8546f723db rbd: Move the encryption check in build
No sense opening a connection only to fail because we don't support the
type of build being attempted.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-10-05 11:08:09 -04:00
John Ferlan
15118aca28 rbd: Change to using heap allocated state contexts
Rather than use stack allocated state context pointers, let's allocate and
free the state context pointer.  In doing so, we'll shrink the code a bit
since many routines perform the same initialization sequence.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-10-05 11:08:09 -04:00
John Ferlan
23671359f5 rbd: Change virStorageBackendRBDCloseRADOSConn to be static void
Since none of the callers check the status, let's just alter it to
a static void.

While we're at it - scrap the local runtime variable and just do the
math in the VIR_DEBUG directly.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-10-05 11:07:52 -04:00
Peter Krempa
dfcd164ba9 qemu: Allow making vcpus hotpluggable with virDomainSetVcpusFlags
Implement support for VIR_DOMAIN_VCPU_HOTPLUGGABLE so that users can
choose to make vcpus added by the API removable.
2016-10-05 09:05:59 +02:00
Peter Krempa
2c739866df qemu: attach: Close monitor socket on connection failure
If attaching to a qemu process fails after opening the monitor socket
libvirt does not clean up the monitor. As the monitor also holds a
reference to the domain object the qemu attach API basically leaks it.

QEMU also does not interact on a second monitor connection and thus a
further attempt to attach to it would lock up.

Prevent libvirt from leaking the monitor by explicitly closing it.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1378401
2016-10-05 08:52:34 +02:00
Peter Krempa
62135ff692 qemu: Don't strictly require JSON monitor for vCPU detection
Attaching to a existing qemu process allows to get us into a situation
when qemu is new enough to have JSON monitor and new vCPU hotplug but
the json monitor is not used. The vCPU detection code would require it
though. This broke attaching to qemu processes.

Make the condition less strict and just skip the vCPU hotplug detection
if JSON monitor is not available.

Resolves one of the symptoms in:
https://bugzilla.redhat.com/show_bug.cgi?id=1378401
2016-10-05 08:52:33 +02:00
Nehal J Wani
1dcbb27402 Don't drop expired lease while reading custom leases file
Libvirt, on its own, shouldn't decide whether an expired lease should
stay in the custom leases database or not. It should rather rely on
the 'DEL' event from dnsmasq.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2016-10-05 08:33:59 +02:00
John Ferlan
66bfc7cc61 remote: Increase bound limit for virDomainGetBlockIoTune
We are about to add 6 new values to fetch. This will put us over the
current limit of 16 (we're at 13 now).

Once there are more than 16 parameters, this will affect existing clients
that attempt to fetch blockiotune config values for the domain from the
remote host since the server side has no mechanism to determine whether
the capability for the emulator exists and thus would attempt to return
all known values from the persistentDef. If attempting to fetch the
blockiotune values from a running domain, the code will check the emulator
capabilities and set maxparams (in qemuDomainGetBlockIoTune) appropriately.

On the client side of the remote connection, it uses this constant in
xdr_remote_domain_get_block_io_tune_ret and virTypedParamsDeserialize
calls, so if a remote server returns more than 16 parameters, then the
client will fail with "Unable to decode message payload".

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-10-04 14:35:17 -04:00
John Ferlan
bb41e19fea remote: Fix erroneous usage of constant
The REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX was erroneously used in the
remoteDomainBlockStatsFlags and remoteDomainGetBlockIoTune calls. Change
the constant to be the right one.

Fortunately, all 3 are defined as 16.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-10-04 14:35:17 -04:00
Michal Privoznik
8cfdd6e4f5 Revert "conf: Skip post parse callbacks when creating copy"
This breaks vCPU hotplug, because when starting a domain, we
create a copy of domain definition (which becomes live XML) and
during the post parse callbacks we might adjust some tunings so
that vCPU hotplug is possible.

This reverts commit 581b7756af.
2016-10-04 18:00:02 +02:00
Michal Privoznik
ddc8bc1cf4 Revert "domain_conf: Introduce VIR_DOMAIN_DEF_PARSE_SKIP_POST_PARSE"
This breaks vCPU hotplug, because when starting a domain, we
create a copy of domain definition (which becomes live XML) and
during the post parse callbacks we might adjust some tunings so
that vCPU hotplug is possible.

This reverts commit c0f90799bc.
2016-10-04 17:58:21 +02:00
Peter Krempa
a88c65e490 qemu: vcpu: Clear vcpu order information rather than making it invalid
Certain operations may make the vcpu order information invalid. Since
the order is primarily used to ensure migration compatibility and has
basically no other user benefits, clear the order prior to certain
operations and document that it may be cleared.

All the operations that would clear the order can still be properly
executed by defining a new domain configuration rather than using the
helper APIs.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1370357
2016-09-30 08:25:20 +02:00
Peter Krempa
80ea1cf6be qemu: Fix coldplug of vcpus
virDomainDefSetVcpus was not designed to handle coldplug of vcpus now
that we can set state of vcpus individually.

Introduce qemuDomainSetVcpusConfig that properly handles state changes
of vcpus when coldplugging so that invalid configurations are not
created.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1375939
2016-09-30 08:25:20 +02:00
Peter Krempa
6ff3e65012 qemu: process: Enforce 'vcpu' order range to <1,maxvcpus>
The current code that validates duplicate vcpu order would not work
properly if the order would exceed def->maxvcpus. Limit the order to the
interval described.
2016-09-30 08:25:20 +02:00