]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
6 years agoapi: disallow virConnectGetDomainCapabilities on read-only connections v1.3.3-maint
Ján Tomko [Fri, 14 Jun 2019 07:16:14 +0000 (09:16 +0200)] 
api: disallow virConnectGetDomainCapabilities on read-only connections

This API can be used to execute arbitrary emulators.
Forbid it on read-only connections.

Fixes: CVE-2019-10167
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 8afa68bac0cf99d1f8aaa6566685c43c22622f26)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
6 years agoapi: disallow virDomainSaveImageGetXMLDesc on read-only connections
Ján Tomko [Fri, 14 Jun 2019 06:47:42 +0000 (08:47 +0200)] 
api: disallow virDomainSaveImageGetXMLDesc on read-only connections

The virDomainSaveImageGetXMLDesc API is taking a path parameter,
which can point to any path on the system. This file will then be
read and parsed by libvirtd running with root privileges.

Forbid it on read-only connections.

Fixes: CVE-2019-10161
Reported-by: Matthias Gerstner <mgerstner@suse.de>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit aed6a032cead4386472afb24b16196579e239580)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Conflicts:
  src/libvirt-domain.c
  src/remote/remote_protocol.x

Upstream commit 12a51f372 which introduced the VIR_DOMAIN_SAVE_IMAGE_XML_SECURE
alias for VIR_DOMAIN_XML_SECURE is not backported.
Just skip the commit since we now disallow the whole API on read-only
connections, regardless of the flag.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
8 years agoPrep for release 1.3.3.3 v1.3.3.3
Cole Robinson [Wed, 10 May 2017 20:19:02 +0000 (16:19 -0400)] 
Prep for release 1.3.3.3

8 years agovirtlogd: Don't stop or restart along with libvirtd
Andrea Bolognani [Tue, 20 Sep 2016 13:22:04 +0000 (15:22 +0200)] 
virtlogd: Don't stop or restart along with libvirtd

Commit 839a060 tied the lifecycle of virtlogd more
closely to that of libvirtd. Unfortunately, while starting
virtlogd when libvirtd is started is definitely a good idea,
restarting virtlogd or shutting it down at any time outside
of system poweroff is not.

Revert part of that commit by removing the PartOf= lines,
meaning that only startup requests will be propagated from
libvirtd to virtlogd.

Resolves: https://bugzilla.redhat.com/1372576
(cherry picked from commit f496ce1df35df7498bd3d9d7e113bb2eb3e51ba9)

8 years agovirtlogd.socket: Tie lifecycle to libvirtd.service
Andrea Bolognani [Tue, 6 Sep 2016 13:16:24 +0000 (15:16 +0200)] 
virtlogd.socket: Tie lifecycle to libvirtd.service

We already guarantee that virtlogd.socket is enabled/disabled
along with libvirtd.service, but if libvirtd.service has just
been installed and is started before rebooting, then
virtlogd.socket will not be running and guest startup will
fail.

Add Requires=virtlogd.socket to libvirtd.service to make sure
virtlogd.socket is always started along with libvirtd.service,
and add Before=libvirtd.service to both virtlogd.socket and
virtlogd.service so that virtlogd never disappears before
libvirtd has exited.

Also add PartOf=libvirtd.service to both virtlogd.socket and
virtlogd.service, so that virtlogd can be shut down when not
needed.

Resolves: https://bugzilla.redhat.com/1372576
(cherry picked from commit 839a060890d8b2408c0ea20e3c5997c7b2a4a079)

8 years agoschema: Don't validate paths
Michal Privoznik [Fri, 12 Aug 2016 08:52:30 +0000 (10:52 +0200)] 
schema: Don't validate paths

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

On UNIX like systems there are no constraints on what characters
can be in file/dir names (except for NULL, obviously). Moreover,
some values that we think of as paths (e.g. disk source) are not
necessarily paths at all. For instance, some hypervisors take
that as an arbitrary identifier and corresponding file is then
looked up by hypervisor in its table. Instead of trying to fix
our regular expressions (and forgetting to include yet another
character there), lets drop the validation completely.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit c4b92f1a8a9cb64a2c4a9f0ed899ed8a7d95d935)

8 years agomaint: fix syntax-check sc_prohibit_int_ijk exclude rule
Pavel Hrdina [Mon, 23 May 2016 23:00:07 +0000 (01:00 +0200)] 
maint: fix syntax-check sc_prohibit_int_ijk exclude rule

Fix the regex for excluding files for this syntax-rule.  The rule "include/"
will not work, because we are matching the whole line like this
"^(...|include/|...)$ so we need to use "include/libvirt/libvirt.+".  The second
issue is that we are using only one '$' but there should be two of those at the
end.  The last small adjustment is to escape dots '.' so it match only dot.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit a94efa50e253cb59a2925dca2705bce801f46fb1)

8 years agoutil: bitmap: clarify virBitmapLastSetBit() behavior for empty bitmaps
Marc Hartmayer [Wed, 6 Jul 2016 12:02:26 +0000 (14:02 +0200)] 
util: bitmap: clarify virBitmapLastSetBit() behavior for empty bitmaps

Before the variable 'bits' was initialized with 0 (commit
3470cd860d517760b13e26d97b6a842ff72687a1), the following bug was
possible.

A function call with an empty bitmap leads to undefined
behavior. Because if 'bitmap->map_len == 0' 'unusedBits' will be <= 0
and 'sz == 1'. So the non global and non static variable 'bits' would
have never been set. Consequently the check 'bits == 0' results in
undefined behavior.

This patch clarifies the current version of the function by handling the
empty bitmap explicitly. Also, for an empty bitmap there is obviously no
bit set so we can just return -1 (indicating no bit set) right away. The
explicit check for 'bits == 0' after the loop is unnecessary because we
only get to this point if no set bit was found.

Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
(cherry picked from commit 7cd01a248b3995909adad29a6edbe76d3d16510f)

8 years agoFix building with -Og
Martin Kletzander [Fri, 3 Jun 2016 11:26:30 +0000 (13:26 +0200)] 
Fix building with -Og

When building using -Og, gcc sees that some variables can be used
uninitialized  It can be debatable whether it is possible with our
codeflow, but functions should be self-contained and initializations are
always good.  The return instead of goto is due to actualType being used
in the cleanup.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 3470cd860d517760b13e26d97b6a842ff72687a1)

8 years agoqemu: Only use memory-backend-file with NUMA if needed
Martin Kletzander [Fri, 23 Sep 2016 09:31:30 +0000 (11:31 +0200)] 
qemu: Only use memory-backend-file with NUMA if needed

If this reminds you of a commit message from around a year ago, it's
41c2aa729f0af084ede95ee9a06219a2dd5fb5df and yes, we're dealing with
"the same thing" again.  Or f309db1f4d51009bad0d32e12efc75530b66836b and
it's similar.

There is a logic in place that if there is no real need for
memory-backend-file, qemuBuildMemoryBackendStr() returns 0.  However
that wasn't the case with hugepage backing.  The reason for that was
that we abused the 'pagesize' variable for storing that information, but
we should rather have a separate one that specifies whether we really
need the new object for hugepage backing.  And that variable should be
set only if this particular NUMA cell needs special treatment WRT
hugepages.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 4372a7845acbc6974f6027ef68e7dd3eeb47f425)

9 years agoPrep for release 1.3.3.2 v1.3.3.2
Cole Robinson [Mon, 18 Jul 2016 22:32:47 +0000 (18:32 -0400)] 
Prep for release 1.3.3.2

9 years agospec: Fix indentation
Andrea Bolognani [Wed, 13 Jul 2016 17:01:14 +0000 (19:01 +0200)] 
spec: Fix indentation

Commit ffc49e579c14 broke syntax-check:

  cppi: libvirt.spec.in: line 622: not properly indented
  cppi: libvirt.spec.in: line 624: not properly indented
  cppi: libvirt.spec.in: line 640: not properly indented
  cppi: libvirt.spec.in: line 642: not properly indented
  maint.mk: incorrect preprocessor indentation
  cfg.mk:697: recipe for target 'sc_spec_indentation' failed

Indent the new conditionals properly.

(cherry picked from commit 55d8daa07e7419a929efd677923a428e3d76345b)

9 years agoconf: Allow disks with identical WWN or serial
Peter Krempa [Fri, 24 Jun 2016 15:01:27 +0000 (17:01 +0200)] 
conf: Allow disks with identical WWN or serial

Disallowing them broke a use case of testing multipath configurations
for storage. Originally this was added as it was impossible to
use certain /dev/disk-by... links but the disks worked properly.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1349895
(cherry picked from commit 5da28cc3069b573f54f0bcaf8eb75476bcfdc6e9)

9 years agolibvirt.spec.in: require systemd-container on >= f24
Daniel P. Berrange [Tue, 12 Jul 2016 14:57:39 +0000 (15:57 +0100)] 
libvirt.spec.in: require systemd-container on >= f24

The systemd-machined tools libvirt uses were split into a
systemd-container RPM. Without depending on this, libvirt
may silently fallback to the non-systemd cgroup impl which
is not desirable.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit ffc49e579c14b1d3f24af8d004ded6e3a0e8900f)

9 years agoqemu: SCSI hostdev hot-plug: Fix automatic creation of SCSI controllers
Marc Hartmayer [Mon, 27 Jun 2016 14:43:47 +0000 (16:43 +0200)] 
qemu: SCSI hostdev hot-plug: Fix automatic creation of SCSI controllers

Ensure that the given controller and all controllers with a smaller
index exist; there must not be any missing index in between.

Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
(cherry picked from commit 12ec22b68befce0ae8020635e7fd71d783b1d716)

 Conflicts:
src/qemu/qemu_hotplug.c: - context of the first hunk changed

9 years agoqemu: hot-plug: Fix broken SCSI disk hot-plug
Marc Hartmayer [Mon, 27 Jun 2016 14:43:46 +0000 (16:43 +0200)] 
qemu: hot-plug: Fix broken SCSI disk hot-plug

The commit "qemu: hot-plug: Assume support for -device in
qemuDomainAttachSCSIDisk" dropped the code for the automatic SCSI
controller creation used in SCSI disk hot-plugging. If we are
hot-plugging a SCSI disk to a domain and there is no proper SCSI
controller defined, it results in an "error: internal error: Could not
find scsi controller with index X required for device" error.

For that reason reverting a hunk of the commit
d4d32005d6e8b2cc0a2f26b483ca1de10171db6d.

This patch also adds an extra comment to the code to clarify the
loop.

Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
(cherry picked from commit 58d07db9b0c294e92e294cadd737eee8597bf747)

9 years agoqemu: Let empty default VNC password work as documented
Jiri Denemark [Tue, 28 Jun 2016 12:39:58 +0000 (14:39 +0200)] 
qemu: Let empty default VNC password work as documented

CVE-2016-5008

Setting an empty graphics password is documented as a way to disable
VNC/SPICE access, but QEMU does not always behaves like that. VNC would
happily accept the empty password. Let's enforce the behavior by setting
password expiration to "now".

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit bb848feec0f3f10e92dd8e5231ae7aa89b5598f3)

9 years agovirCgroupValidateMachineGroup: Reflect change in CGroup struct naming
Michal Privoznik [Thu, 5 May 2016 15:35:38 +0000 (17:35 +0200)] 
virCgroupValidateMachineGroup: Reflect change in CGroup struct naming

Fron c3bd0019c0e on instead of creating the following path for
cgroups:

  /sys/fs/cgroupX/$name.libvirt-$driver

we generate rather more verbose one:

  /sys/fs/cgroupX/$driver-$id-$name.libvirt-$driver

where $name is optional and included iff contains allowed chars.
See original commit for more reasoning. Now, problem with the
original commit is that we are unable to start any LXC domain
after it. Because when starting LXC container, the CGroup layout
is created by our lxc_controller process and then detected and
validated by libvirtd. The validation is done by trying to match
detected layout against all the possible patterns for cgroup
paths that we've ever had. And the commit in question forgot to
update this part of the code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit fb377701f253559268e903377707ed3d265823cd)

9 years agospec: Advertise nvram paths of official fedora edk2 builds
Cole Robinson [Fri, 20 May 2016 19:50:16 +0000 (15:50 -0400)] 
spec: Advertise nvram paths of official fedora edk2 builds

Fedora now ships edk2 firmware in its official repos, so adapt
the nvram path list to match. Eventually we can remove the nightly
links as well once some integration kinks have been worked out,
and documentation updated.

Move the macro building into the %build target, which lets us
build up a shell variable and make things a bit more readable

https://bugzilla.redhat.com/show_bug.cgi?id=1335395
(cherry picked from commit e9ef4dfac88806d02bd2f31eeb3f3bbafe505888)

9 years agoqemu: hotplug: wait for the tray to eject only for drives with a tray
Peter Krempa [Thu, 19 May 2016 13:30:12 +0000 (15:30 +0200)] 
qemu: hotplug: wait for the tray to eject only for drives with a tray

Use the detected tray presence flag to trigger the tray waiting code
only if the given storage device in qemu reports to have a tray.

This is necessary as the floppy device lost it's tray as of qemu commit:

commit abb3e55b5b718d6392441f56ba0729a62105ac56
Author: Max Reitz <mreitz@redhat.com>
Date:   Fri Jan 29 20:49:12 2016 +0100

    Revert "hw/block/fdc: Implement tray status"

(cherry picked from commit 72a7ff6b507bcf389cc493ac0ba07d32de266d6e)

9 years agoqemu: hotplug: Fix error reported when cdrom tray is locked
Peter Krempa [Mon, 23 May 2016 14:32:06 +0000 (16:32 +0200)] 
qemu: hotplug: Fix error reported when cdrom tray is locked

Commit 1fad65d49aae364576bd91352a001249510f8d4e used a really big hammer
and overwrote the error message that might be reported by qemu if the
tray is locked. Fix it by reporting the error only if no error is
currently set.

Error after commit mentioned above:
error: internal error: timed out waiting for disk tray status update

New error:
error: internal error: unable to execute QEMU command 'eject': Tray of
device 'drive-ide0-0-0' is not open

(cherry picked from commit 2e75da42e41af0cd48ca6f75d0606b40a366cc54)

9 years agoqemu: hotplug: Extract code for waiting for tray eject
Peter Krempa [Mon, 23 May 2016 12:50:17 +0000 (14:50 +0200)] 
qemu: hotplug: Extract code for waiting for tray eject

The code grew rather convoluted. Extract it to a separate function.

(cherry picked from commit 0aa19f35e0f3c1712f2569986d4d0a93b488c35c)

9 years agoqemu: hotplug: Report error if we hit tray status timeout
Cole Robinson [Mon, 2 May 2016 23:07:34 +0000 (19:07 -0400)] 
qemu: hotplug: Report error if we hit tray status timeout

If we exceed the timeout waiting for the tray status to change,
we don't report an error. Fix it

(cherry picked from commit 1fad65d49aae364576bd91352a001249510f8d4e)

9 years agoqemu: hotplug: Skip waiting for tray opening if qemu doesn't notify us
Peter Krempa [Fri, 29 Apr 2016 11:49:13 +0000 (13:49 +0200)] 
qemu: hotplug: Skip waiting for tray opening if qemu doesn't notify us

If qemu doesn't support DEVICE_TRAY_MOVED event the code that attempts
to change media would attempt to re-eject the tray even if it wouldn't
be notified when the tray opened. Add a capability bit and skip retrying
for old qemus.

(cherry picked from commit 833ae6b4356934e7b779c4be01bd2bf051930dde)

9 years agoqemu: process: Fix and improve disk data extraction
Peter Krempa [Thu, 19 May 2016 13:29:02 +0000 (15:29 +0200)] 
qemu: process: Fix and improve disk data extraction

Extract information for all disks and update tray state and source only
for removable drives. Additionally store whether a drive is removable
and whether it has a tray.

(cherry picked from commit 894dc85fd1ebcd63d8c897b355c550e68a5f432d)

9 years agoqemu: Move and rename qemuDomainCheckEjectableMedia to qemuProcessRefreshDisks
Peter Krempa [Mon, 23 May 2016 12:00:35 +0000 (14:00 +0200)] 
qemu: Move and rename qemuDomainCheckEjectableMedia to qemuProcessRefreshDisks

Move it to a more sane place since it's refreshing data about disks.

(cherry picked from commit d9bee413ade28e1e43ef222c7aaaa3c6d6fda0f1)

9 years agoqemu: Extract more information about qemu drives
Peter Krempa [Thu, 19 May 2016 12:57:41 +0000 (14:57 +0200)] 
qemu: Extract more information about qemu drives

Extract whether a given drive has a tray and whether there is no image
inserted.

Negative logic for the image insertion is chosen so that the flag is set
only if we are certain of the fact.

(cherry picked from commit f1690dc3d7934bf70f4fbc84d55bf210276c6f27)

9 years agoqemu: Move struct qemuDomainDiskInfo to qemu_domain.h
Peter Krempa [Fri, 20 May 2016 05:21:04 +0000 (07:21 +0200)] 
qemu: Move struct qemuDomainDiskInfo to qemu_domain.h

(cherry picked from commit 5f963d89b1220460fadb1bf6fc347d26b311c1b2)

9 years agoqemu: process: Refresh ejectable media tray state on VM start
Peter Krempa [Fri, 29 Apr 2016 11:38:51 +0000 (13:38 +0200)] 
qemu: process: Refresh ejectable media tray state on VM start

Empty floppy drives start with tray in "open" state and libvirt did not
refresh it after startup. The code that inserts media into the tray then
waited until the tray was open before inserting the media and thus
floppies could not be inserted.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1326660
(cherry picked from commit a34faf33011c5c0d7b47ee0849bf1e11635e17c5)

9 years agoiscsi: Remove initiatoriqn from virISCSIScanTargets
John Ferlan [Fri, 13 May 2016 15:38:45 +0000 (11:38 -0400)] 
iscsi: Remove initiatoriqn from virISCSIScanTargets

No longer necessary to have it, so remove it.

(cherry picked from commit 027986f5bff0d89375e94e1344074f82eed27d7b)

9 years agoutil: Remove disabling of autologin for iscsi-targets
Fritz Elfert [Fri, 13 May 2016 15:19:09 +0000 (11:19 -0400)] 
util: Remove disabling of autologin for iscsi-targets

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

Instead of disabling auto-login of all scsi targets (even those
that do not "belong" to libvirt), use iscsiadm's "--op nonpersistent"
during discovery of iSCSI targets (e.g. "iscsiadm --mode discovery
--type sendtargets") in order to avoid the node database being altered
which led to the need for the "large hammer" approach taken by
commit id '3c12b654'.

This commit removes the virISCSITargetAutologin adjustment (eg. the setting
of node.startup to "manual"). The iscsiadm command has supported this mode
of operation as of commit id 'ad873767' to open-iscsi.

(cherry picked from commit 56057900dc53df490d953d56de1195ebfa025bdd)

9 years agoiscsi: Add exit status checking for virISCSIGetSession
John Ferlan [Fri, 13 May 2016 17:25:30 +0000 (13:25 -0400)] 
iscsi: Add exit status checking for virISCSIGetSession

Utilize the exit status parameter for virCommandRunRegex in order to
check the return error from the 'iscsiadm --mode session' command.
Without this enabled, if there are no sessions running then virCommandRun
would have displayed an error such as:

    2016-05-13 15:17:15.165+0000: 10920: error : virCommandWait:2553 :
               internal error: Child process (iscsiadm --mode session)
               unexpected exit status 21: iscsiadm: No active sessions.

It is possible that for certain paths (when probe is true) we only care
whether it's running or not to make certain decisions.  Spitting out
the error for those paths is unnecessary.

If we do have a situation where probe = false and there's an error,
then display the error from iscsiadm if it's there.

(cherry picked from commit 8f54e0d6328eb593c2226459a03afed0da23043d)

9 years agoutil: Add exitstatus parameter to virCommandRunRegex
John Ferlan [Fri, 13 May 2016 16:36:39 +0000 (12:36 -0400)] 
util: Add exitstatus parameter to virCommandRunRegex

Rather than have virCommandRun just spit out the error, allow callers
to decide to pass the exitstatus so the caller can make intelligent
decisions based on the error.

(cherry picked from commit 8b1049473317c09d34b3ce9671d0f9e91dd4f1c0)

9 years agoxlconfigtests: use qemu-xen in all test data files
Jim Fehlig [Thu, 12 May 2016 20:40:29 +0000 (14:40 -0600)] 
xlconfigtests: use qemu-xen in all test data files

Some of the test configuration files in tests/xlconfigdata
use the old qemu-dm as the emulator. Many of the configuration
features tested (spice, rbd, multi-usb) are not even usable with
the old qemu. Change these files to use the new qemu-xen (also
known as qemu upstream) emulator.

Note: This change fixes xlconfigtest failures when the old
qemu is actually installed on the system. During device post
parse, the libxl driver attempts to invoke the emulator to
determine if it is the old or new qemu so it can properly set
video RAM defaults. With the old qemu installed, the default
video RAM was set differently than the expected value.
Changing all the test data files to use qemu-xen ensures
predictable results wrt default video RAM size.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
(cherry picked from commit b90c4b5f505698d600303c5b4f03f5d229b329dd)

9 years agolibxl: don't attempt to probe a non-existent emulator
Jim Fehlig [Thu, 12 May 2016 20:40:28 +0000 (14:40 -0600)] 
libxl: don't attempt to probe a non-existent emulator

When probing the <emulator> with '-help' to determine if
it is the old qemu, errors are reported if the emulator
doesn't exist

libvirt:  error : internal error: Child process
(/usr/lib/xen/bin/qemu-dm -help) unexpected exit status 127:
libvirt:  error : cannot execute binary /usr/lib/xen/bin/qemu-dm:
No such file or directory

Avoid the probe if the specified emulator doesn't exist,
squelching the error. There is no behavior change since
libxlDomainGetEmulatorType() would return
LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN if the probe failed
via virCommandRun().

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
(cherry picked from commit 400e716d7d8371fa718c27bb4f05b9a68929e64a)

9 years agoFix tests to include video ram size
Ján Tomko [Thu, 12 May 2016 12:19:52 +0000 (14:19 +0200)] 
Fix tests to include video ram size

My commit 3e42867 started filling out the video size in post-parse,
but did not adjust the tests.

(cherry picked from commit 96b21fb0ecf8242ceb298607da61b5718511a388)

9 years agoFill out default vram in DeviceDefPostParse
Ján Tomko [Wed, 11 May 2016 10:39:52 +0000 (12:39 +0200)] 
Fill out default vram in DeviceDefPostParse

Move filling out the default video (v)ram to DeviceDefPostParse.

This means it can be removed from virDomainVideoDefParseXML
and qemuParseCommandLine. Also, we no longer need to special case
VIR_DOMAIN_VIRT_XEN, since the per-driver callback gets called
before the generic one.

(cherry picked from commit 538012c8a30230065d1bfe09892279dd8b89193f)

9 years agoCall per-device post-parse callback even on implicit video
Ján Tomko [Wed, 11 May 2016 10:13:51 +0000 (12:13 +0200)] 
Call per-device post-parse callback even on implicit video

Commit 6879be48 moved adding of an implicit video device after XML
parsing. As a result, libxlDomainDeviceDefPostParse() is no longer
called to set the default vram when adding an implicit device.
Commit 6879be48 assumes virDomainVideoDefaultRAM() will set the
default vram, but it returns 0 if the domain virtType is
VIR_DOMAIN_VIRT_XEN. Attempting to start an HVM domain with vram=0
results in

error: unsupported configuration: videoram must be at least 4MB for CIRRUS

The default vram setting for Xen HVM domains depends on the device
model used (qemu-xen vs qemu-traditional), hence setting the
default is deferred to libxlDomainDeviceDefPostParse().

Call the device post-parse callback even for implicit video,
to fill out the default vram even for VIR_DOMAIN_VIRT_XEN.

https://bugzilla.redhat.com/show_bug.cgi?id=1334557
Most-of-commit-message-by: Jim Fehlig <jfehlig@suse.com>
(cherry picked from commit 3e4286703273b06a21ae07f3e76a66f9661199dc)

9 years agoMove virDomainDefPostParseInternal after virDomainDeviceDefPostParse
Ján Tomko [Wed, 11 May 2016 09:57:33 +0000 (11:57 +0200)] 
Move virDomainDefPostParseInternal after virDomainDeviceDefPostParse

Future commit will call DeviceDefPostParse on a device auto-added
in DomainDefPostParse.

(cherry picked from commit e4d131b8cb12679814b6fda159281f472b615524)

9 years agoconf: use VIR_APPEND_ELEMENT in virDomainDefAddImplicitVideo
Ján Tomko [Mon, 11 Apr 2016 13:28:29 +0000 (15:28 +0200)] 
conf: use VIR_APPEND_ELEMENT in virDomainDefAddImplicitVideo

(cherry picked from commit 1278688921b5721b6b9af63899fad0310f63b979)

9 years agoconf: reduce indentation in virDomainDefAddImplicitVideo
Ján Tomko [Mon, 11 Apr 2016 13:26:06 +0000 (15:26 +0200)] 
conf: reduce indentation in virDomainDefAddImplicitVideo

Return early if there is nothing to do.

(cherry picked from commit 1485be178461b6e9504d21216b7ef480f4980ffa)

9 years agodomain_conf: fix migration/managedsave with usb keyboard 5/head
Pavel Hrdina [Fri, 6 May 2016 11:55:15 +0000 (13:55 +0200)] 
domain_conf: fix migration/managedsave with usb keyboard

Commin 36785c7e refactored the code for input devices but introduced a
bug where we removed all keyboard from migratable XML.  We have to
remove only implicit keyboards like PS2 or XEN.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agoPrep for release 1.3.3.1 v1.3.3.1
Cole Robinson [Wed, 4 May 2016 23:40:19 +0000 (19:40 -0400)] 
Prep for release 1.3.3.1

9 years agospec: Use proper indentation
Andrea Bolognani [Tue, 26 Apr 2016 15:37:16 +0000 (17:37 +0200)] 
spec: Use proper indentation

Commit 1d4400082a02 added some code that was not indented properly
and broke syntax-check. Fix it.

(cherry picked from commit a528ae7fb7e24e448d2636012218109ae3ef82b6)

9 years agolibvirt.spec: remove duplicate files from -docs package
Daniel P. Berrange [Wed, 4 May 2016 09:11:37 +0000 (10:11 +0100)] 
libvirt.spec: remove duplicate files from -docs package

Previous commit moved some lists out of the -devel package
and into the -docs package

  commit feffcc03a0d3690dcffd860682dcbaa61d726b39
  Author: Cole Robinson <crobinso@redhat.com>
  Date:   Wed Apr 13 10:37:42 2016 -0400

    spec: Only pull in API docs with -devel package

What was not realized is that the rule 'libvirt-docs/*'
and ' docs/*.html docs/html docs/*.gif' actually point
to the exact same content. ie, we had previously included
the website HTML in *both* the -docs and -devel packages.

So this change ended up listing the files twice, which
caused RPM to print a load of warnings:

warning: File listed twice: /usr/share/doc/libvirt-docs/html
warning: File listed twice: /usr/share/doc/libvirt-docs/html/32favicon.png
warning: File listed twice: /usr/share/doc/libvirt-docs/html/404.html
warning: File listed twice: /usr/share/doc/libvirt-docs/html/acl.html
warning: File listed twice: /usr/share/doc/libvirt-docs/html/aclpolkit.html

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit d6c25c34ef682a69f73f6ec200129e61b2932088)

9 years agonetwork: Fix segfault on daemon reload
Cole Robinson [Sun, 24 Apr 2016 21:37:13 +0000 (17:37 -0400)] 
network: Fix segfault on daemon reload

We will segfault of a daemon reload picks up a new network config
that needs to be autostarted. We shouldn't be passing NULL for
network_driver here. This seems like it was missed in the larger
rework in commit 1009a61e

(cherry picked from commit 26af7e4e932d72e7ead88e2e687b3ee0ca4718bb)

9 years agosend default USB controller in xml to destination during migration
Shivaprasad G Bhat [Fri, 29 Apr 2016 14:01:51 +0000 (19:31 +0530)] 
send default USB controller in xml to destination during migration

The default USB controller is not sent to destination as the older versions
of libvirt(0.9.4 or earlier as I see in commit log of 409b5f54) didn't
support them. For some archs where the support started much later can
safely send the USB controllers without this worry. So, send the controller
to destination for all archs except x86. Moreover this is not very applicable
to x86 as the USB controller has model ich9_ehci1 on q35 and for pc-i440fx,
there cant be any slots before USB as it is fixed on slot 1.

The patch fixes a bug that, if the USB controller happens to occupy
a slot after disks/interfaces and one of them is hot-unplugged, then
the default USB controller added on destination takes the smallest slot
number and that would lead to savestate mismatch and migration
failure. Seen and verified on PPC64.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
(cherry picked from commit 192a53e07c5fefd9dad2f310886209b76dcc5d83)

9 years agovirsh: Fix support for 64 migration options
Nikolay Shirokovskiy [Wed, 20 Apr 2016 13:51:43 +0000 (16:51 +0300)] 
virsh: Fix support for 64 migration options

Add ULL suffix to all related operands of << or shift will give
all zeros instead of correct mask.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
(cherry picked from commit 4d28d0931f87177a762f6a78cfdbcc2e30d6d4af)

9 years agoqemu: Regenerate VNC socket paths
Martin Kletzander [Tue, 26 Apr 2016 12:27:16 +0000 (14:27 +0200)] 
qemu: Regenerate VNC socket paths

Similarly to what commit 714080791778 did with some internal paths,
clear vnc socket paths that were generated by us.  Having such path in
the definition can cause trouble when restoring the domain.  The path is
generated to the per-domain directory that contains the domain ID.
However, that ID will be different upon restoration, so qemu won't be
able to create that socket because the directory will not be prepared.

To be able to migrate to older libvirt, skip formatting the socket path
in migratable XML if it was autogenerated.  And mark it as autogenerated
if it already exists and we're parsing live XML.

Best viewed with '-C'.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 55320c23dd163e75eb61ed6bea2f339ccfeff4f9)

9 years agoqemu: conf: Set default logging approach in virQEMUDriverConfigNew
Peter Krempa [Wed, 27 Apr 2016 10:58:13 +0000 (12:58 +0200)] 
qemu: conf: Set default logging approach in virQEMUDriverConfigNew

Instead of setting the default qemu stdio logging approach in
virQEMUDriverConfigLoadFile set it in virQEMUDriverConfigNew so that
it's properly set even when the config is not present.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1325075
(cherry picked from commit 63e2b766a5a704eb19b8bdaeb1cf0fa91f990cb8)

9 years agoqemu: Unref cfg in qemuDomainDefPostParse
Martin Kletzander [Tue, 26 Apr 2016 12:38:14 +0000 (14:38 +0200)] 
qemu: Unref cfg in qemuDomainDefPostParse

Introduced by commit 15ad2ecf114d.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit d3d4fb4b187e88d470d37867cdaff3f32e01efef)

9 years agospec: If installing default network, restart libvirtd
Cole Robinson [Thu, 16 Apr 2015 19:42:05 +0000 (15:42 -0400)] 
spec: If installing default network, restart libvirtd

If libvirt-daemon-config-network is installed while libvirtd is already
running, the daemon doesn't notice the network. Users then have to
manually restart libvirtd (or reboot) to pick up the network.

Instead let's trigger a daemon restart when the package is first installed.
Then the default network is available immediately if libvirtd was already
running.

https://bugzilla.redhat.com/show_bug.cgi?id=867546
(cherry picked from commit 1d4400082a02c41b152cc9ab7b4cfc428cc527ee)

9 years agoqemu: fix error log in qemuAssignPCIAddresses()
Laine Stump [Tue, 19 Apr 2016 16:53:02 +0000 (12:53 -0400)] 
qemu: fix error log in qemuAssignPCIAddresses()

This error message was too specific, based on the incorrect assumption
that any error was cause by auto-added bridges:

  failed to create PCI bridge on bus 2: too many devices
  with fixed addresses

In practice you can't know if a bridge with an index <= the bus it's
connecting to was added automatically, or if it was a mistake in
explicit config, and the auto-add problem is going to be dealt with in
a different way in an upcoming patch. The new message is this:

  PCI Controller at index 1 (0x01) has "
  bus='0x02', but bus must be <= index

(note that index is given in both decimal and hex because it is
formatted as decimal in the XML, but bus is formatted as hex, and
displaying the hex value of index makes it easier to see the problem
when index > 9 (which will often be the case with PCIe, since most
controllers only have a single port, not 32 slots as with standard
PCI)).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1004593
(cherry picked from commit ff2126225df019566e4e580d92e69e9df3ca96c0)

9 years agovirsh: host: Use bitmap size in bytes rather than bit count
Peter Krempa [Mon, 25 Apr 2016 08:38:01 +0000 (10:38 +0200)] 
virsh: host: Use bitmap size in bytes rather than bit count

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1329819
(cherry picked from commit 3a703b8120d9f996840bd315b6f74c45a7e98aad)

9 years agoqemu: Fix off-by-one error in block I/O throttle messages
Martin Kletzander [Mon, 25 Apr 2016 09:54:56 +0000 (11:54 +0200)] 
qemu: Fix off-by-one error in block I/O throttle messages

QEMU_BLOCK_IOTUNE_MAX is the maximum inclusively, so let's modify the
message so it makes sense.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 72c313bce9043a181cc951871f38a37f6cbeb785)

9 years agoconf: Drop restrictions on rng backend path
Cole Robinson [Wed, 13 Apr 2016 19:09:30 +0000 (15:09 -0400)] 
conf: Drop restrictions on rng backend path

Currently we only allow /dev/random and /dev/hwrng as host input
for <rng><backend model='random'/> device. This was added after
various upstream discussions in commit 4932ef45

However this restriction has generated quite a few complaints over
the years, so a new discussion was initiated:

http://www.redhat.com/archives/libvir-list/2016-April/msg00987.html

Several people suggested removing the restriction, and nobody really
spoke up to defend it. So this patch drops the path restriction
entirely

https://bugzilla.redhat.com/show_bug.cgi?id=1074464
(cherry picked from commit 67f2b72723c242969c5282fcb9acf00cc01f2a54)

9 years agovbox: VIR_WARN if we don't support the API version
Cole Robinson [Fri, 22 Apr 2016 21:53:08 +0000 (17:53 -0400)] 
vbox: VIR_WARN if we don't support the API version

We presently don't give any indication if the VirtualBox version
isn't in our support whitelist.

(cherry picked from commit 18644491de68f9a654061f2748486f1c69900d17)

9 years agoqemu: Limit maximum block device I/O tune values
Martin Kletzander [Wed, 20 Apr 2016 14:14:02 +0000 (16:14 +0200)] 
qemu: Limit maximum block device I/O tune values

The values are currently limited to LLONG_MAX which causes some
problems.  QEMU conveniently changed their maximum to 1e15 (1 PB) which
is enough for some time and we need to adapt to that so that we don't
throw "Unknown error" messages.  Strictly limiting these values actually
fixes some corner case values (off-by-one checks in QEMU probably).

Since values out of the new specified range do not overflow anything,
change the type of error as well.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 2d04f6de77d437fa60361950e5f18fac8c1c922d)

9 years agovirconf: Handle conf file without ending newline
Cole Robinson [Thu, 21 Apr 2016 00:25:31 +0000 (20:25 -0400)] 
virconf: Handle conf file without ending newline

$ echo -n 'log_level=1' > ~/.config/libvirt/libvirtd.conf
$ libvirtd --timeout=10
2014-10-10 10:30:56.394+0000: 6626: info : libvirt version: 1.1.3.6, package: 1.fc20 (Fedora Project, 2014-09-08-17:50:42, buildvm-05.phx2.fedoraproject.org)
2014-10-10 10:30:56.394+0000: 6626: error : main:1261 : Can't load config file: configuration file syntax error: /home/rjones/.config/libvirt/libvirtd.conf:1: expecting a value: /home/rjones/.config/libvirt/libvirtd.conf

Rather than try to fix this in the depths of the parser, just catch
the case when a config file doesn't end in a newline, and manually
append a newline to the content before parsing

https://bugzilla.redhat.com/show_bug.cgi?id=1151409
(cherry picked from commit 3cc2a9e0d412776a07780b090cf286cc603cea84)

9 years agonetwork: fix DHCPv6 on networks with prefix != 64
Laine Stump [Thu, 21 Apr 2016 18:03:18 +0000 (14:03 -0400)] 
network: fix DHCPv6 on networks with prefix != 64

According to the dnsmasq manpage, the netmask for IPv4 address ranges
will be auto-deteremined from the interface dnsmasq is listening on,
but it can't do this for IPv6 for some reason - it instead assumes a
network prefix of 64 for all IPv6 address ranges. If this is
incorrect, dnsmasq will refuse to give out an address to clients,
instead logging this message:

 dnsmasq-dhcp[2380]: no address range available for DHCPv6 request via virbr0

The solution is for libvirt to add ",$prefix" to all IPv6 dhcp-range
arguments when building the dnsmasq.conf file.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1033739
(cherry picked from commit bf3d9f305ebad9d8abd68e4600d2db996b860e68)

9 years agorpc: Don't leak fd via CreateXMLWithFiles
Ben Gray [Sat, 23 Apr 2016 22:38:21 +0000 (18:38 -0400)] 
rpc: Don't leak fd via CreateXMLWithFiles

FD passing APIs like CreateXMLWithFiles or OpenGraphicsFD will leak
file descriptors. The user passes in an fd, which is dup()'d in
virNetClientProgramCall. The new fd is what is transfered to the
server virNetClientIOWriteMessage.

Once all the fds have been written though, the parent msg->fds list
is immediately free'd, so the individual fds are never closed.

This closes each FD as its send to the server, so all fds have been
closed by the time msg->fds is free'd.

https://bugzilla.redhat.com/show_bug.cgi?id=1159766
(cherry picked from commit 5ba48584fbc5079c0ddbc9e9a52c96d7bcef0761)

9 years agolibvirt: Fix crash on URI without scheme
Cole Robinson [Wed, 20 Apr 2016 17:25:07 +0000 (13:25 -0400)] 
libvirt: Fix crash on URI without scheme

My commit 0d1579572 crashes on a URI without a scheme, like via
'virsh --connect frob'

Add a check on uri->server too while we are at it, and centralize
them all

(cherry picked from commit f1bae376b71ecc712e5d8359382290db1120e13e)

9 years agotests: fix xen-related tests
Ján Tomko [Tue, 12 Apr 2016 12:58:43 +0000 (14:58 +0200)] 
tests: fix xen-related tests

My commit 6879be4 moved the addition of the implicit video device
from the XML parser to the PostParse function, but did not regenerate
all the tests.

(cherry picked from commit 4b35a7155ad6b4346591dd54f03abead2f8c6e1f)

9 years agoman: Clarify virsh vol-clone works within a single pool
Cole Robinson [Tue, 19 Apr 2016 21:34:57 +0000 (17:34 -0400)] 
man: Clarify virsh vol-clone works within a single pool

virsh vol-clone is expected to clone a volume within a single
pool; it doesn't work for cloning across pools. Clarify the docs

https://bugzilla.redhat.com/show_bug.cgi?id=1103714
(cherry picked from commit 2f1dc3de4672f4d7aa42bb4984618d382388e0d2)

9 years agonetwork: Don't use ERR_NO_SUPPORT for invalid net-update requests
Cole Robinson [Tue, 19 Apr 2016 18:48:30 +0000 (14:48 -0400)] 
network: Don't use ERR_NO_SUPPORT for invalid net-update requests

VIR_ERR_NO_SUPPORT maps to the error string

    this function is not supported by the connection driver

and is largely only used for when a driver doesn't have any
implementation for a public API. So its usage with invalid
net-update requests is a bit out of place. Instead use
VIR_ERR_OPERATION_UNSUPPORTED which maps to:

    Operation not supported

And is what qemu's hotplug routines use in similar scenarios

(cherry picked from commit cdb4caac81606b8c1bb6ed6f3c0e5d06e4b8b3d6)

9 years agoRevert "daemon: use socket activation with systemd"
Cole Robinson [Mon, 11 Apr 2016 22:36:20 +0000 (18:36 -0400)] 
Revert "daemon: use socket activation with systemd"

This reverts commit 1e9808d3a1e00a7121bae8b163d9c42d441d2ca8.

We shouldn't advertise libvirtd.socket activation, since currently
it means VM/network/... autostart won't work as expected.

We tried to find a middle ground by installing the config file without
an [Install] section, since systemd won't allow .socket to be enabled
without one... or at least it did do that; presently on f24 it allows
activating the socket quite happily. This also caused user confusion[1]

Just remove the socket file. I've filed a new RFE to track coming up
with a solution to the autostart problem[2], we can point users at that
if there's more confusion:

[1]: https://bugzilla.redhat.com/show_bug.cgi?id=1279348
[2]: https://bugzilla.redhat.com/show_bug.cgi?id=1326136

(cherry picked from commit 3b9100a4d255fdb5f731fcfa49326746d371894a)

9 years agoExplicitly error on uri=qemu://system
Cole Robinson [Sat, 16 Apr 2016 12:59:08 +0000 (08:59 -0400)] 
Explicitly error on uri=qemu://system

It's a fairly common error that a user tries to connect to a URI
like qemu://system or qemu://session (missing a slash). This errors
like:

$ virsh --connect qemu://session
error: failed to connect to the hypervisor
error: Unable to resolve address 'session' service '16514': No address associated with hostname

If you already know that the standard qemu URI has 3 slashes, that
error will make it obvious enough. But new user's may not get it.
There's even a RHEL support page explicitly mentioning it!:

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Virtualization_Deployment_and_Administration_Guide/sect-Troubleshooting-Common_libvirt_errors_and_troubleshooting.html

Catch this error early in libvirt.c virConnectOpen for qemu (and vbox
which has similar rules

https://bugzilla.redhat.com/show_bug.cgi?id=1038304
(cherry picked from commit 0d1579572a864c33621da4d01408f8bcb6de5d4a)

9 years agolxc: explicitly error on interface type=ethernet
Cole Robinson [Mon, 11 Apr 2016 14:48:20 +0000 (10:48 -0400)] 
lxc: explicitly error on interface type=ethernet

It isn't implemented and does not work:

error: internal error: guest failed to start: /usr/lib/libvirt/libvirt_lxc: option '--veth' requires an argument
syntax: /usr/lib/libvirt/libvirt_lxc [OPTIONS] ...

We previously threw an explicit error, but this changed in
22cff52a2b8e06c913b1f97767e5d390fb17fc3b , which I suspect was
untested for LXC

(cherry picked from commit 27f2b74782e15c528079c8a93e5ccf216fe7b22c)

9 years agotests: Fix syntax in iSCSI auth/secret tests
John Ferlan [Sat, 16 Apr 2016 12:11:00 +0000 (08:11 -0400)] 
tests: Fix syntax in iSCSI auth/secret tests

While working on the tests for the secret initialization vector, I found
that the existing iSCSI tests were lacking in how they defined the IQN.
Many had IQN's of just 'iqn.1992-01.com.example' for one disk while using
'iqn.1992-01.com.example/1' for the second disk (same for hostdevs - guess
how they were copied/generated).

Typically (and documented this way), IQN's would include be of the form
'iqn.1992-01.com.example:storage/1' indicating an IQN using "storage" for
naming authority specific string and "/1" for the iSCSI LUN.

So modify the input XML's to use the more proper format - this of course
has a ripple effect on the output XML and the args.

Also note that the "%3A" is generated by the virURIFormat/xmlSaveUri
to represent the colon.

Signed-off-by: John Ferlan <jferlan@redhat.com>
(cherry picked from commit dd1400280eb0fcd38906b17a9341ac9fe6317498)

9 years agoLibvirt: virTypedParamsValidate: Fix detection of multiple parameters
Jason J. Herne [Tue, 12 Apr 2016 14:13:27 +0000 (10:13 -0400)] 
Libvirt: virTypedParamsValidate: Fix detection of multiple parameters

virTypedParamsValidate currently uses an index based check to find
duplicate parameters. This check does not work. Consider the following
simple example:

We have only 2 keys
A  (multiples allowed)
B  (multiples NOT allowed)

We are given the following list of parameters to check:
A
A
B

If you work through the validation loop you will see that our last iteration
through the loop has i=2 and j=1. In this case, i > j and keys[j].value.i will
indicate that multiples are not allowed. Both conditionals are satisfied so
an incorrect error will be given: "parameter '%s' occurs multiple times"

This patch replaces the index based check with code that remembers
the name of the last parameter seen and only triggers the error case if
the current parameter name equals the last one. This works because the
list is sorted and duplicate parameters will be grouped together.

In reality, we hit this bug while using selective block migration to migrate
a guest with 5 disks. 5 was apparently just the right number to push i > j
and hit this bug.

virsh migrate --live guestname --copy-storage-all
              --migrate-disks vdb,vdc,vdd,vde,vdf
              qemu+ssh://dsthost/system

Signed-off-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Reviewed-by: Eric Farman <farman@linux.vnet.ibm.com>
(cherry picked from commit 0e570a6acc13ebbca913e69026f1468daf28240f)

9 years agoResolve a couple of memory leaks
John Ferlan [Thu, 14 Apr 2016 14:21:27 +0000 (10:21 -0400)] 
Resolve a couple of memory leaks

Commit id '4b75237f' seems to have triggered Coverity into finding
at least one memory leak in xen_xl.c for error path for cleanup where
the listenAddr would be leaked. Reviewing other callers, it seems that
qemu_parse_command.c would have the same issue, so just it too.

(cherry picked from commit 727a3c5860ef5e1fb8878da9d44c6e5e33a4f4ae)

9 years agolibxl: use LIBXL_API_VERSION 0x040200
Jim Fehlig [Thu, 14 Apr 2016 22:10:32 +0000 (16:10 -0600)] 
libxl: use LIBXL_API_VERSION 0x040200

To ensure the libvirt libxl driver will build with future versions
of Xen where the libxl API may change in incompatible ways,
explicitly use LIBXL_API_VERSION 0x040200. The libxl driver
does use new libxl APIs that have been added since Xen 4.2, but
currently it does not make use of any changes made to existing
APIs such as libxl_domain_create_restore or libxl_set_vcpuaffinity.
The version can be bumped if/when the libxl driver consumes the
changed APIs.

Further details can be found in the following discussion thread

https://www.redhat.com/archives/libvir-list/2016-April/msg00178.html
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
(cherry picked from commit e744065679ccba8471d28b2cf6e93f443cd20c8c)

9 years agoAdd functions for handling exponential backoff loops.
Richard W.M. Jones [Fri, 8 Apr 2016 11:11:10 +0000 (12:11 +0100)] 
Add functions for handling exponential backoff loops.

In a few places in libvirt we busy-wait for events, for example qemu
creating a monitor socket.  This is problematic because:

 - We need to choose a sufficiently small polling period so that
   libvirt doesn't add unnecessary delays.

 - We need to choose a sufficiently large polling period so that
   the effect of busy-waiting doesn't affect the system.

The solution to this conflict is to use an exponential backoff.

This patch adds two functions to hide the details, and modifies a few
places where we currently busy-wait.

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
(cherry picked from commit beaa447a2982bc78adb26c183560d0ee566c1268)

9 years agospec: Only pull in API docs with -devel package
Cole Robinson [Wed, 13 Apr 2016 14:37:42 +0000 (10:37 -0400)] 
spec: Only pull in API docs with -devel package

Move some API specific documentation out of -docs package and into
-devel, and some end user docs out of -devel and into -docs, then
drop the -devel dep on -docs. This is more in line with the suggested
Fedora guidelines.

https://bugzilla.redhat.com/show_bug.cgi?id=1310155
(cherry picked from commit feffcc03a0d3690dcffd860682dcbaa61d726b39)

9 years agoutil: Add virGettextInitialize, convert the code
Cole Robinson [Tue, 12 Apr 2016 22:29:52 +0000 (18:29 -0400)] 
util: Add virGettextInitialize, convert the code

Take setlocale/gettext error handling pattern from tools/virsh-*
and use it for all standalone binaries via a new shared
virGettextInitialize routine. The virsh* pattern differed slightly
from other callers. All users now consistently:

* Ignore setlocale errors. virsh has done this forever, presumably for
  good reason. This has been partially responsible for some bug reports:

  https://bugzilla.redhat.com/show_bug.cgi?id=1312688
  https://bugzilla.redhat.com/show_bug.cgi?id=1026514
  https://bugzilla.redhat.com/show_bug.cgi?id=1016158

* Report the failed function name
* Report strerror

(cherry picked from commit e7db22781071a39668276a395fb547c0dd90875d)

9 years agoman: virsh: Document lxc-enter-namespace --noseclabel
Cole Robinson [Mon, 11 Apr 2016 21:02:25 +0000 (17:02 -0400)] 
man: virsh: Document lxc-enter-namespace --noseclabel

https://bugzilla.redhat.com/show_bug.cgi?id=1147737
(cherry picked from commit 0f8be2531c44f04854af0b0569d3f2c373b1bba6)

9 years agostorage: mpath: Don't error on target_type=NULL
Cole Robinson [Wed, 13 Apr 2016 21:29:59 +0000 (17:29 -0400)] 
storage: mpath: Don't error on target_type=NULL

We use device-mapper to enumerate all dm devices, and filter out
the list of multipath devices by checking the target_type string
name. The code however cancels all scanning if we encounter
target_type=NULL

I don't know how to reproduce that situation, but a user was hitting
it in their setup, and inspecting the lvm2/device-mapper code shows
many places where !target_type is explicitly ignored and processing
continues on to the next device. So I think we should do the same

https://bugzilla.redhat.com/show_bug.cgi?id=1069317
(cherry picked from commit 8f8c0feb113420625f15b7f1e17bfd719c977eeb)

9 years agoqemu: command: don't overwrite watchdog dump action
Cole Robinson [Wed, 13 Apr 2016 15:20:19 +0000 (11:20 -0400)] 
qemu: command: don't overwrite watchdog dump action

The watchdog cli refactoring in 4666b762 dropped the temporary variable
we use to convert to action=dump to action=pause for the qemu cli, and
stored the converted value in the domain structure. Our other watchdog
handling code then treated it as though the user requested action=pause,
which broke action=dump handling.

Revive the temporary variable to fix things.

(cherry picked from commit a91177c8f7b432e67d2e232650d7debbbfc694da)

9 years agorpc: daemon: Fix virtlog/virtlock daemon reload
Cole Robinson [Wed, 13 Apr 2016 14:13:12 +0000 (10:13 -0400)] 
rpc: daemon: Fix virtlog/virtlock daemon reload

Trying to reload/SIGUSR1 virtlogd or virtlockd fails with:

error : virNetDaemonRun:747 : internal error: Not all servers restored, cannot run server

Commit 252610f7 changed the daemon state json to allow tracking
multiple servers. However it missed clearing dmn->srvObject after
the json is empty, like the previous code paths handled.  Later on in
virNewDaemonRun, dmn->srvObject is expected to be empty otherwise we
throw the above error.

https://bugzilla.redhat.com/show_bug.cgi?id=1311013
(cherry picked from commit 9b69f02243f2abec4170576dfe28f8a4bb398b4e)

9 years agoconf: also mark the implicit video as primary
Ján Tomko [Mon, 11 Apr 2016 12:26:06 +0000 (14:26 +0200)] 
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.

(cherry picked from commit 6d8b6d2847f31a3d7a234536c12b8feca751a02f)

9 years agoconf: move default video addition after XML parsing
Ján Tomko [Mon, 11 Apr 2016 12:06:03 +0000 (14:06 +0200)] 
conf: move default video addition after XML parsing

Separate parsing of the XML from auto-generating the device.

(cherry picked from commit 6879be484c9502394e55c799f5bb95c24c510644)

9 years agovirtlogd: Fix a couple minor memory leaks
Cole Robinson [Sun, 10 Apr 2016 23:19:25 +0000 (19:19 -0400)] 
virtlogd: Fix a couple minor memory leaks

https://bugzilla.redhat.com/show_bug.cgi?id=1303885
(cherry picked from commit cdced0128a45fb44c687325376311dabb1116324)

9 years agoqemu: Free priv->machineName
Martin Kletzander [Fri, 8 Apr 2016 13:29:40 +0000 (15:29 +0200)] 
qemu: Free priv->machineName

Commit c3bd0019c0e3 forgot to cleanup after itself.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 16b41728b59a7188f643937303e3aec4c299a980)

9 years agoconfigure: Fix check for --with-login-shell on Windows
Andrea Bolognani [Fri, 8 Apr 2016 14:17:16 +0000 (16:17 +0200)] 
configure: Fix check for --with-login-shell on Windows

The check is supposed to stop users from trying to compile
virt-login-shell on Windows by erroring out during the
configure phase; however, there are two flaws in it:

  * the value of "x$with_win" is compared to "yes" instead
    of "xyes" (note the "x" in the first string)

  * "test" is not being used, so the script will actually
    try to run a command called "x$with_win" instead of
    performing string comparison

This patch fixes both issues.

(cherry picked from commit ccf58bd72a426f34481787af694d6eae78b4e64e)

9 years agoutil: move ENODATA redefine to internal.h
Roman Bogorodskiy [Thu, 7 Apr 2016 06:51:11 +0000 (09:51 +0300)] 
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.

(cherry picked from commit edc028d122a45b09988dae6d93510adbd9f5c3e4)

9 years agolibxl: libxl_domain_create_restore has an extra argument
Wei Liu [Tue, 5 Apr 2016 14:20:12 +0000 (15:20 +0100)] 
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
(cherry picked from commit 216650f14b35ad11a45505405347f8027bc294d7)

9 years agoqemu: perf: Fix crash/memory corruption on failed VM start
Peter Krempa [Thu, 7 Apr 2016 10:50:15 +0000 (12:50 +0200)] 
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
(cherry picked from commit 03e8d5fb54c7c897225ed9ea56d83b894930f144)

9 years agoqemu: alias: Fix calculation of memory device aliases
Peter Krempa [Wed, 6 Apr 2016 15:32:12 +0000 (17:32 +0200)] 
qemu: alias: Fix calculation of memory device aliases

For device hotplug, the new alias ID needs to be checked in the list
rather than using the count of devices. Unplugging a device that is not
last in the array will make further hotplug impossible due to alias
collision.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1324551
(cherry picked from commit be6e92f541ab27019de530f1f08ec9b2912765a9)

9 years agoLink libvirt_xenconfig instead of libvirt against libxl
Guido Günther [Thu, 31 Mar 2016 12:57:24 +0000 (14:57 +0200)] 
Link libvirt_xenconfig instead of libvirt against libxl

to avoid the test failure

 7) Test driver "xen"  ... 2016-03-31 12:53:26.950+0000: 22430: debug : virDriverLoadModule:54 : Module load xen
 2016-03-31 12:53:26.950+0000: 22430: error : virDriverLoadModule:73 : failed to load module /build/libvirt-1.3.3~rc1/debian/build/src/.libs/libvirt_driver_xen.so /build/libvirt-1.3.3~rc1/debian/build/src/.libs/libvirt_driver_xen.so: undefined symbol: xlu_cfg_destroy
FAILED

(cherry picked from commit 12b239a9fafe84bf025437fe0324e7af5d12cd67)

9 years agovirt-admin: get rid of LIBVIRT_DEFAULT_ADMIN_URI env var
Ján Tomko [Wed, 6 Apr 2016 12:57:21 +0000 (14:57 +0200)] 
virt-admin: get rid of LIBVIRT_DEFAULT_ADMIN_URI env var

There is a LIBVIRT_ADMIN_DEFAULT_URI environment variable
which is honored by virAdmConnectOpen and documented
in the virt-admin man page.

LIBVIRT_DEFAULT_ADMIN_URI is undocumented and this is its
only occurrence.

(cherry picked from commit df8964308ed3d7eeb4f15f26e17993b5f7af1c51)

9 years agolibvirt-admin: do not crash on URI without a scheme
Ján Tomko [Wed, 6 Apr 2016 08:43:39 +0000 (10:43 +0200)] 
libvirt-admin: do not crash on URI without a scheme

(cherry picked from commit 7f35b6b658288749d41cb5ff138baf9f679e57fd)

9 years agovirsh: read default connection uri from env later
Ján Tomko [Wed, 6 Apr 2016 08:08:55 +0000 (10:08 +0200)] 
virsh: read default connection uri from env later

Postpone filling out the default connection in ctl->connname
after calling virshInit.

This allows printing help without a connection to the daemon.

(cherry picked from commit c0726e0708762e571a7883cb0558cfec32459669)

9 years agobuild: add GCC 6.0 -Wlogical-op workaround
Pavel Hrdina [Sun, 10 Apr 2016 16:22:20 +0000 (18:22 +0200)] 
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>
(cherry picked from commit d713a6b120904c488170e7920c482b2fade70ae1)

9 years agobuild: cleanup GCC < 4.6 -Wlogical-op workaround
Pavel Hrdina [Sun, 10 Apr 2016 16:21:13 +0000 (18:21 +0200)] 
build: cleanup GCC < 4.6 -Wlogical-op workaround

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit 7fb81831fc497aa4a34fdfc036be9c9ae4401084)

9 years agoqemu: support virt-2.6 machine type on arm
Ján Tomko [Fri, 8 Apr 2016 08:46:41 +0000 (10:46 +0200)] 
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
(cherry picked from commit f06ca25d235433f9139cbfb3d5d9eae7409156b9)

9 years agoRelease of libvirt-1.3.3 v1.3.3
Daniel Veillard [Wed, 6 Apr 2016 07:18:46 +0000 (15:18 +0800)] 
Release of libvirt-1.3.3
- docs/news.html.in libvirt.spec.in: update for release
- po/*.po*: regenerated

9 years agodocs: fix logfile paragraph
Boris Fiuczynski [Tue, 5 Apr 2016 12:44:43 +0000 (14:44 +0200)] 
docs: fix logfile paragraph

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
9 years agonetwork: Remove extraneous ATTRIBUTE_NONNULL
John Ferlan [Tue, 5 Apr 2016 09:43:47 +0000 (05:43 -0400)] 
network: Remove extraneous ATTRIBUTE_NONNULL

Commit id '3992ff14' added the prototype for networkGetActualType
with 1 parameter, but added 2 ATTRIBUTE_NONNULL's (assume from a
cut-n-paste), just remove (2).

9 years agoqemu: Fix mis-merge of qemuBuildRedirdevCommandLine
John Ferlan [Mon, 4 Apr 2016 19:27:58 +0000 (15:27 -0400)] 
qemu: Fix mis-merge of qemuBuildRedirdevCommandLine

Commit id '59e7ef3c' misapplied a merge of commit id '019244751'
to place the "-chardev" command after formatting the character
backend value.

9 years agoqemu: Fix mis-merge of qemuBuildConsoleCommandLine
John Ferlan [Mon, 4 Apr 2016 19:26:43 +0000 (15:26 -0400)] 
qemu: Fix mis-merge of qemuBuildConsoleCommandLine

Commit id 'e6944a52' misapplied a merge of commit id '019244751'
to place the "-chardev" command after formatting the character
backend value.