Commit Graph

16386 Commits

Author SHA1 Message Date
Pavel Hrdina
4b75237fe6 domain_conf: introduce virDomainGraphicsListenAppendAddress
This effectively removes virDomainGraphicsListenSetAddress which was
used only to change the address of listen structure and possible change
the listen type.  The new function will auto-expand the listens array
and append a new listen.

The old function was used on pre-allocated array of listens and in most
cases it only "add" a new listen.  The two remaining uses can access the
listen structure directly.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-04-13 10:43:49 +02:00
Peter Krempa
8eb1cbb8bd conf: extract disk geometry parsing code 2016-04-13 08:21:39 +02:00
Peter Krempa
b4be29336d conf: Refactor virDomainDiskDefMirrorParse
Now that the mirror parsing code is not crammed in the main disk parser
we can employ better coding style.
2016-04-13 08:21:38 +02:00
Peter Krempa
109fe3fea1 conf: disk: Split out parsing of disk mirror data
Changes are indentation and 'cleanup' label instead of 'error'.
2016-04-13 08:21:38 +02:00
Peter Krempa
14e4c4e465 conf: virDomainDiskDefIotuneParse: Report malformed number errors
Rest of the fields of the iotune data structure did not check for
malformed integers. Use the previously defined macro to extract them
which will simplify the code and add error reporting.
2016-04-13 08:21:38 +02:00
Peter Krempa
112ae48192 conf: virDomainDiskDefIotuneParse: simplify parsing
Since the structure was pre-initialized to 0 we don't need to set every
single member to 0 if it's not present in the XML. Additionally if we
put the name of the field into the error message the code can be
simplified using a macro to parse the members.
2016-04-13 08:21:27 +02:00
Peter Krempa
71760e90d2 conf: disk: Remove error label from virDomainDiskDefIotuneParse
Since this function isn't doing any cleanup, the label is not necessary.
2016-04-13 08:20:45 +02:00
Peter Krempa
5fce412d9a conf: disk: Extract iotune parsing into a separate func 2016-04-13 08:20:44 +02:00
Peter Krempa
65da41de14 conf: disk: Remove one unnecessary level of indentation
Also simplify the code by switching to a for loop.
2016-04-13 08:20:44 +02:00
Peter Krempa
4bbac0f9b9 conf: disk: Don't initialize fields allocated by calloc
All the fields were initialized to 0.
2016-04-13 08:20:44 +02:00
Peter Krempa
dcf02a704f util: Rename and move virStrIsPrint to virStringIsPrintable 2016-04-13 08:15:24 +02:00
Maxim Nestratov
1ee1b58fc3 vz: add Hypervisor prefix to vz and parallels Driver structures 2016-04-12 21:05:21 +03:00
Maxim Nestratov
f376069fa5 vz: remove drivername field from vzConn structure
No need to remember connection name and have corresponding
domain type to keep backward compatibility with former
'parallels' driver. It is enough to be able to accept 'parallels'
uri and domain types.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
2016-04-12 21:05:05 +03:00
Maxim Nestratov
419aaf23ce vz: change the order of capabilities reported
'vz' goes first now to make clients like virt-manager choose 'vz'
instead of 'parallels'

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
2016-04-12 21:04:53 +03:00
Nikolay Shirokovskiy
4517eb0f4e vz: fix memory leak
we don't need to allocate macstr at all as it is an array
and already has the the space it needs.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-04-12 12:44:26 +03:00
Ján Tomko
1278688921 conf: use VIR_APPEND_ELEMENT in virDomainDefAddImplicitVideo 2016-04-12 10:45:35 +02:00
Ján Tomko
1485be1784 conf: reduce indentation in virDomainDefAddImplicitVideo
Return early if there is nothing to do.
2016-04-12 10:45:35 +02:00
Ján Tomko
35e3c4a684 conf: delete useless primaryVideo variable
If we encounter a video device with primary=yes, we insert it
at def->videos[0].

There is no need to record this in a separate variable,
just check if there already is a primary video at def->videos[0].
2016-04-12 10:45:35 +02:00
Ján Tomko
b2b8fc919d conf: use insertAt instead of j
We call VIR_INSERT_ELEMENT_INPLACE either with 0 (for primary video)
or def->nvideos (for the rest).

Use a variable with more semantic name, since j is usually used
for iterating.
2016-04-12 10:45:35 +02:00
Ján Tomko
ca70db398e conf: use the iterator directly when parsing video devices
We start with both i and def->nvideos at 0 and increment both
after every successful iteration.

Use i directly, instead of passing the def->nvideos value through j.
2016-04-12 10:45:35 +02:00
Ján Tomko
6d8b6d2847 conf: also mark the implicit video as primary
Commit 119cd06 started setting the primary bool for the first
user-specified video even if user omitted the 'primary' attribute.

However this was done before the addition of the implicit device.
This broke startup of transient qemu domains with no <video>:
https://bugzilla.redhat.com/show_bug.cgi?id=1325757

Move this default to virDomainDefPostParseInternal,
after the addition of the implicit video device, to catch the implicit
video as well.
2016-04-12 10:45:35 +02:00
Ján Tomko
6879be484c conf: move default video addition after XML parsing
Separate parsing of the XML from auto-generating the device.
2016-04-12 10:45:35 +02:00
Andrea Bolognani
c81f058bd0 util: Fix 'exempt from syntax-check' comment 2016-04-12 10:30:10 +02:00
Nikolay Shirokovskiy
ad584cbb6c vz: implement memory setting functions
Quite straigthforward as vz sdk memory setting function makes
just what we want to that is set "amount of physical memory
allocated to a domain".

'useflags' is introduced for non flag function implementation.
We can't just use combination of flags like "live | config" or
we fail for inactive domains. Other combinations have drawbacks
too.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-04-11 20:00:01 +03:00
Nikolay Shirokovskiy
3fbb7dba33 vz: factor out config update flags checks
Actually this is not pure refactoring. Part of common code is
replaced with virDomainObjUpdateModificationImpact and this
a good replacement. It includes removed check of inactive
domain and active flags set. Additionally we resolve
current flag in accordance with current state of domain.
Thus it becames possible to attach/detach devices for
inactive domains if this flag is set.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-04-11 19:58:30 +03:00
Pavel Hrdina
1d9d0c9397 domain_conf: fix graphics parsing
Commit dc98a5bc refactored the code a lot and forget about checking if
listen attribute is specified.  This ensures that listen attribute and
first listen element are compared only if both exist.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-04-11 13:50:55 +02:00
Cole Robinson
cdced0128a virtlogd: Fix a couple minor memory leaks
https://bugzilla.redhat.com/show_bug.cgi?id=1303885
2016-04-11 07:32:57 -04:00
Pavel Hrdina
d713a6b120 build: add GCC 6.0 -Wlogical-op workaround
fdstream.c: In function 'virFDStreamWrite':
fdstream.c:390:29: error: logical 'or' of equal expressions [-Werror=logical-op]
        if (errno == EAGAIN || errno == EWOULDBLOCK) {
                            ^~

Fedora rawhide now uses gcc 6.0 and there is a bug with -Wlogical-op
producing false warnings.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602

Use GCC pragma push/pop and ignore -Wlogical-op for GCC that supports
push/pop pragma and also has this bug.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-04-11 12:09:14 +02:00
Pavel Hrdina
7fb81831fc build: cleanup GCC < 4.6 -Wlogical-op workaround
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-04-11 12:09:11 +02:00
Martin Kletzander
16b41728b5 qemu: Free priv->machineName
Commit c3bd0019c0 forgot to cleanup after itself.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-04-11 11:46:09 +02:00
Peter Krempa
a46aad791c qemu: agent: Fix incorrect and weird debug/warning log entries
Replace the nonsensical debug statement by adding the expected event
code into the existing debug statement.

Since the monitor code always notifies the agent on guest
reboot/shutdown even if that was not initiated by the agent the warning
emitted later is bogus and pollutes the logs in such cases. Delete it
and keep just the original debug message where this info can be
inferred.
2016-04-11 09:48:13 +02:00
Roman Bogorodskiy
acb63aaf41 qemu: fix build without gnutls installed
Move including of gnutls/gnutls.h in qemu/qemu_domain.c under the
"ifdef WITH_GNUTLS" check because otherwise it fails like this:

  CC       qemu/libvirt_driver_qemu_impl_la-qemu_domain.lo
qemu/qemu_domain.c:50:10: fatal error: 'gnutls/gnutls.h' file not found

in case if gnutls is not installed on the system.
2016-04-09 22:04:40 +03:00
Pavel Hrdina
0159b38324 domain_conf: cleanup error paths for graphics parser
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-04-08 17:50:48 +02:00
Pavel Hrdina
537d32a2fd domain_conf: split graphics xml parser into multiple functions
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-04-08 17:36:27 +02:00
Pavel Hrdina
dc98a5bc59 domain_conf: cleanup virDomainGraphicsListensParseXML
Refactor the listen parser to use only one loop.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-04-08 17:36:27 +02:00
Pavel Hrdina
ffce6090f6 domain_conf: introduce virDomainGraphicsListensParseXML
Move code, that parses graphics listens, to its own function.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-04-08 17:36:27 +02:00
Peter Krempa
a3510e33d3 util: netdev: Don't crash in virNetDevSetIPAddress if @peer is NULL
VIR_SOCKET_ADDR_VALID dereferences the pointer, thus if we pass NULL
into virNetDevSetIPAddress it crashes. Regression introduced by
b3d069872c.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1325120
2016-04-08 14:28:11 +02:00
Ján Tomko
f06ca25d23 qemu: support virt-2.6 machine type on arm
Some places already check for "virt-" prefix as well as plain "virt".
virQEMUCapsHasPCIMultiBus did not, resulting in multiple PCI devices
having assigned the same unnumbered "pci" alias.

Add a test for the "virt-2.6" machine type which also omits the
<model type='virtio'/> in <interface>, to check if
qemuDomainDefaultNetModel works too.

https://bugzilla.redhat.com/show_bug.cgi?id=1325085
2016-04-08 14:15:51 +02:00
Andrea Bolognani
4572997aca netdev: Use the correct pointer type for virSocketAddrFormat()
virSocketAddrFormat() wants a single pointer, not a double pointer.

Fixes the following compilation error on FreeBSD:

  util/virnetdev.c:1448:72: error: incompatible pointer types passing
   'virSocketAddr **' to parameter of type 'const virSocketAddr *';
   remove & [-Werror,-Wincompatible-pointer-types]
      if (VIR_SOCKET_ADDR_VALID(peer) && !(peerstr = virSocketAddrFormat(&peer)))
                                                                         ^~~~~
  ./util/virsocketaddr.h:92:48: note: passing argument to parameter 'addr' here
  char *virSocketAddrFormat(const virSocketAddr *addr);
                                                 ^
2016-04-08 13:05:31 +02:00
Roman Bogorodskiy
edc028d122 util: move ENODATA redefine to internal.h
FreeBSD lacks ENODATA, and viruuid.c redefines it to EIO, but it's not
actually using it. On the other hand, we have virrandom.c that's using
ENODATA. So make this re-definition common by moving it to internal.h,
so all the current and possible future users don't need to care about
that.
2016-04-08 10:20:10 +03:00
Vasiliy Tolstov
6e244c659f qemu domain allow to set ip address, peer address and route
Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
2016-04-07 18:34:48 +01:00
Vasiliy Tolstov
afee47d07c lxc domain allow to set peer address
Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
2016-04-07 18:27:15 +01:00
Vasiliy Tolstov
690969af9c libvirt domain xml allow to set peer address
Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
2016-04-07 18:23:01 +01:00
Vasiliy Tolstov
b3d069872c virnetdev allow to set peer address
Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
2016-04-07 18:22:58 +01:00
Wei Liu
216650f14b libxl: libxl_domain_create_restore has an extra argument
In the latest libxenlight code, libxl_domain_create_restore accepts a
new argument. Update libvirt's libxl driver for that. Use the macro
provided by libxenlight to detect which version should be used.

The new parameter (send_back_fd) is set to -1 because libvirt provides
no such fd.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Message-id: 1459866012-27081-1-git-send-email-wei.liu2@citrix.com
2016-04-07 17:34:23 +01:00
Andrea Bolognani
2d23d145a6 qemu: Explicitly check for gnutls_rnd()
Our use of gnutls_rnd(), introduced with commit ad7520e8, is
conditional to the availability of the <gnutls/crypto.h> header
file.

Such check, however, turns out not to be strict enough, as there
are some versions of GnuTLS (eg. 2.8.5 from CentOS 6) that provide
the header file, but not the function itself, which was introduced
only in GnuTLS 2.12.0.

Introduce an explicit check for the function.
2016-04-07 17:55:53 +02:00
Nikolay Shirokovskiy
032c5bf988 vz: support boot order in domain xml dump
As usual we try to deal correctly with vz domains that were
created by other means and thus can have all range of SDK domain
parameters. If vz domain boot order can't be represented
in libvirt os boot section let's give warning and make os boot section
represent SDK to some extent.

1. Os boot section supports up to 4 boot devices. Here we just
cut SDK boot order up to this limit. Not too bad.

2. If there is a floppy in boot order let's just skip it.
Anyway we don't show it in the xml. Not too bad too.

3. SDK boot order with unsupported disks order. Say we have "hdb, hda" in
SDK. We can not present this thru os boot order. Well let's just
give warning but leave double <boot dev='hd'/> in xml. It's
kind of misleading but we warn you!

SDK boot order have an extra parameters 'inUse' and 'sequenceIndex'
which makes our task more complicated. In realitly however 'inUse'
is always on and 'sequenceIndex' is not less than 'boot position index'
which simplifies out task back again! To be on a safe side let's explicitly
check for this conditions!

We have another exercise here. We want to check for unrepresentable
condition 3 (see above). The tricky part is that in contrast to
domains defined thru this driver 3-rd party defined domains can
have device ordering different from default. Thus we need
some id to check that N-th boot disk of os boot section is same as
N-th boot disk of SDK boot. This is what prlsdkBootOrderCheck
for. It uses disks sources paths as id for disks and iface names
for network devices.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
2016-04-07 16:21:41 +03:00
Nikolay Shirokovskiy
bc281f7d7d vz: fix disk order on load domain
We want to report boot order in dumpxml for vz domains.
Thus we want disks devices to be sorted in output compatible with boot
ordering specification. So let's just use virDomainDiskInsert
which makes appropriate sorting.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-04-07 16:21:40 +03:00
Nikolay Shirokovskiy
497dcafc2e vz: support boot order specification on define domain
The patch makes some refactoring of the existing code. Current boot order spec code
makes very simple thing in somewhat obscure way. In case of VMs
it sets the first hdd as the only bootable device. In case of CTs it
doesn't touch the boot order at all if one of the filesystems is mounted to root.
Otherwise like in case of VMs it sets the first hdd as the only bootable
device and additionally sets this device mount point to root. Refactored
code makes all this explicit.

The actual boot order support is simple. Common libvirt domain xml parsing
code makes the exact ordering of disks devices as described in docs
for boot ordering (disks are sorted by bus order first, device target
second. Bus order is the order of disk buses appearence in original
xml. Device targets order is alphabetical). We add devices in the
same order and SDK designates device indexes sequentially for each
device type. Thus device index is equal to its boot index. For
example N-th cdrom in boot specification refers to sdk cdrom with
it's device index N.

If there is no boot spec in xml the parsing code will add <boot dev='hdd'>
for HVMs automatically and we backward compatibly set fist hdd as
bootable.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
2016-04-07 16:21:40 +03:00
Peter Krempa
03e8d5fb54 qemu: perf: Fix crash/memory corruption on failed VM start
The new perf code didn't bother to clear a pointer in 'priv' causing a
double free or other memory corruption goodness if a VM failed to start.

Clear the pointer after freeing the memory.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1324757
2016-04-07 12:50:15 +02:00