]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
7 years agoapibuild: Avoid double sorting of ids
Radostin Stoyanov [Tue, 20 Mar 2018 06:48:57 +0000 (06:48 +0000)]
apibuild: Avoid double sorting of ids

The uniq() function returns a sorted list, there is no need
to sort this list again.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
7 years agoapibuild: Simplify uniq function
Radostin Stoyanov [Tue, 20 Mar 2018 06:48:56 +0000 (06:48 +0000)]
apibuild: Simplify uniq function

Use a set (unordered collections of unique elements) [1] to remove
repeated elements in a list.

1: https://docs.python.org/3/tutorial/datastructures.html#sets

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
7 years agoWmiClass: Don't share "versions" between instances
Radostin Stoyanov [Tue, 20 Mar 2018 06:48:55 +0000 (06:48 +0000)]
WmiClass: Don't share "versions" between instances

Lists in Python are mutable and when used as a default value of a
parameter for class constructor, its value will be shared between
all class instances.

Example:

class Test:
    def __init__(self, mylist=[]):
        self.mylist = mylist

A = Test()
B = Test()
A.mylist.append("mylist from instance A")
print(B.mylist) # Will print ['mylist from instance A']

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
7 years agopython: Remove space around = in keyword args
Radostin Stoyanov [Tue, 20 Mar 2018 06:48:54 +0000 (06:48 +0000)]
python: Remove space around = in keyword args

PEP8 recommends not having spaces around = in a keyword argument or
a default parameter value.

https://www.python.org/dev/peps/pep-0008/#other-recommendations

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
7 years agoapibuild: Simplify conditional statements
Radostin Stoyanov [Tue, 20 Mar 2018 06:48:53 +0000 (06:48 +0000)]
apibuild: Simplify conditional statements

Improve readability by reducing the complexity and length of
conditional statements.

Example: The following condition:

if (o >= 97 and o <= 122) or
   (o >= 65 and o <= 90) or
   (o >= 48 and o <= 57) or
   (" \t(){}:;,+-*/%&!|[]=><".find(line[i]) == -1):

Will be True for every character that is not in string:
" \t(){}:;,+-*/%&!|[]=><"

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
7 years agocfg.mk: check ctype_macros only on *.[c|h] files
Radostin Stoyanov [Tue, 20 Mar 2018 06:48:52 +0000 (06:48 +0000)]
cfg.mk: check ctype_macros only on *.[c|h] files

The functions like isalnum(), isalpha(), isdigit(), etc. are also
available in Python, however `make syntax-check` do not intend to
prohibit them.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
7 years agoesx_vi_generator: Simplify alignment function
Radostin Stoyanov [Tue, 20 Mar 2018 06:48:51 +0000 (06:48 +0000)]
esx_vi_generator: Simplify alignment function

Generate whitespace using the standard function ljust() that is
available in both Py3 [1] and Py2 [2].

1: https://docs.python.org/3/library/stdtypes.html?highlight=strip#str.ljust
2: https://docs.python.org/2.7/library/string.html#string.ljust

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
7 years agoesx_vi_generator: Simplify get_occurrence_comment
Radostin Stoyanov [Tue, 20 Mar 2018 06:48:50 +0000 (06:48 +0000)]
esx_vi_generator: Simplify get_occurrence_comment

Reduce the number of if-statements and use a single return.
Utilise a dictionary to map between occurrences and values.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
7 years agoesx_vi_generator: Simplify generate_helper_header
Radostin Stoyanov [Tue, 20 Mar 2018 06:48:49 +0000 (06:48 +0000)]
esx_vi_generator: Simplify generate_helper_header

The function generate_helper_header() only returns a formatted string.
This could be achieved without performing string concatenation.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
7 years agoesx_vi_generator: Simplify generate_helper_source
Radostin Stoyanov [Tue, 20 Mar 2018 06:48:48 +0000 (06:48 +0000)]
esx_vi_generator: Simplify generate_helper_source

The generate_helper_source() function returns a formatted string.
This could be achieved without the use of a local variable "source"
and string concatenation.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
7 years agopython: Add whitespace around = and % operators
Radostin Stoyanov [Tue, 20 Mar 2018 06:48:47 +0000 (06:48 +0000)]
python: Add whitespace around = and % operators

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
7 years agoapibuild: Remove whitespace before ', ' and ':'
Radostin Stoyanov [Tue, 20 Mar 2018 06:48:46 +0000 (06:48 +0000)]
apibuild: Remove whitespace before ', ' and ':'

PEP8 recommends removing whitespace immediately before a comma,
semicolon, or colon [1]. In addition remove multiple spaces after
keyword (PEP8 - E271).

1: https://www.python.org/dev/peps/pep-0008/#whitespace-in-expressions-and-statements

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
7 years agoapibuild: Split imports on separate lines
Radostin Stoyanov [Tue, 20 Mar 2018 06:48:45 +0000 (06:48 +0000)]
apibuild: Split imports on separate lines

PEP8 recommends imports to be on separate lines. [1]

1: https://www.python.org/dev/peps/pep-0008/#imports

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
7 years agoapibuild: Use isinstance for type checking
Radostin Stoyanov [Tue, 20 Mar 2018 06:48:44 +0000 (06:48 +0000)]
apibuild: Use isinstance for type checking

The isinstance() function [1] returns true if an object argument is an
instance of a classinfo argument or of a direct, indirect subclass
thereof.

1: https://docs.python.org/3/library/functions.html#isinstance

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
7 years agoqemu: Don't assign alias to disabled balloon device
Jiri Denemark [Mon, 19 Mar 2018 17:14:52 +0000 (18:14 +0100)]
qemu: Don't assign alias to disabled balloon device

<memballoon model='none'/> is the only way to disable balloon driver
since libvirt will add one automatically if the memballoon element is
missing. In other words, there's no balloon device if model is 'none'
and generating an alias for it makes no sense. The alias will be ignored
when parsing the XML and it will disappear once libvirtd is restarted.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agognulib: switch to use https:// instead of git:// protocol
Daniel P. Berrangé [Fri, 16 Mar 2018 17:27:14 +0000 (17:27 +0000)]
gnulib: switch to use https:// instead of git:// protocol

Some contributors are behind obnoxious firewalls that block everything
except http(s) traffic, preventing checkout of modules using the git://
protocol. Since git.savannah.gnu.org is using the modern, fast HTTP
transport, there's no real downside to using that by default.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agovirt-aa-helper: resolve file symlinks
Christian Ehrhardt [Mon, 19 Mar 2018 10:10:29 +0000 (11:10 +0100)]
virt-aa-helper: resolve file symlinks

In a recent change b932ed69: "virt-aa-helper: resolve yet to be created
paths" several cases with symlinks in paths were fixed, but it regressed
cases where the file being last element of the path was the actual link.

In the case of the last element being the symlink realpath can (and shall)
be called on the full path that was passed.

Examples would be zfs/lvm block devices like:
 <disk type='block' device='disk'>
    <driver name='qemu' type='raw'/>
    <source dev='/dev/mapper/testlvm-testvol1'/>
    <target dev='vdd' bus='virtio'/>
 </disk>
With the target being:
 /dev/mapper/testlvm-testvol1 -> ../dm-0

That currently is rendered as
 "/dev/mapper/testlvm-testvol1" rwk,
but instead should be (and is with the fix):
 "/dev/dm-0" rwk,

Fixes: b932ed69: "virt-aa-helper: resolve yet to be created paths"
Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1756394
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 years agotools: fix variable scope in in check_guests_shutdown
Christian Ehrhardt [Mon, 19 Mar 2018 11:44:31 +0000 (12:44 +0100)]
tools: fix variable scope in in check_guests_shutdown

libvirt-guests.sh when run with more active guests than requested to
shut down in parallel will run until it times out only shutting down
the first set of guests.

This patch fixes parallel shutdown by fixing a variable scope issue
where check_guests_shutdown unintentionally reset $guests which
prevented further progress.

Fixes: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1688508
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 years agopython: Drop explicit version where possible
Andrea Bolognani [Thu, 15 Mar 2018 16:56:34 +0000 (17:56 +0100)]
python: Drop explicit version where possible

Some of our scripts are known to work both with Python 2 and
Python 3, so for them we shouldn't be forcing any specific
version of the interpreter when they're called directly; we
always use $(PYTHON) explicitly in our build rules anyway.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoqemu: hostdev: Fix the error on VM start with an mdev when IOMMU is off
Erik Skultety [Thu, 15 Mar 2018 13:58:22 +0000 (14:58 +0100)]
qemu: hostdev: Fix the error on VM start with an mdev when IOMMU is off

Commit b4c2ac8d56 made a false assumption that IOMMU support necessary
for an mdev device to be assigned to a VM. Unlike direct PCI assignment,
IOMMU support is not needed for mediated devices, as the physical parent
device provides the isolation, therefore, simply checking for VFIO
presence is enough to successfully start a VM.

Luckily, this issue is not serious, since as of yet, libvirt mandates
mdevs to be pre-created prior to a domain's launch - if it is,
everything does work smoothly even with IOMMU disabled, because the
parent device will ensure the iommu groups we try to access exist.
However, if there are *no* IOMMU groups yet, thus no mdev exists yet, one
would see the following error:

"unsupported configuration: Mediated host device assignment requires VFIO
support"

The error msg above is simply wrong and doesn't even reflect the IOMMU
reality, so after applying this patch one would rather see the following
error in such case instead:

"device not found: mediated device '<UUID>' not found"

Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agoutil: mdev: Improve the error msg on non-existent mdev prior to VM start
Erik Skultety [Fri, 16 Mar 2018 09:06:04 +0000 (10:06 +0100)]
util: mdev: Improve the error msg on non-existent mdev prior to VM start

What one currently gets is:
failed to read '/sys/bus/mdev/devices/<UUID>/mdev_type/device_api': No
such file or directory

This indicates that something is missing within the device's sysfs tree
which likely might be not be the case here because the device simply
doesn't exist yet. So, when creating our internal mdev obj, let's check
whether the device exists first prior to trying to verify the
user-provided model within domain XML.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
7 years agovirNetlinkDumpCommand: Don't leak response buffer
Michal Privoznik [Mon, 19 Mar 2018 06:39:08 +0000 (07:39 +0100)]
virNetlinkDumpCommand: Don't leak response buffer

==16451== 32,768 bytes in 2 blocks are definitely lost in loss record 1,007 of 1,013
==16451==    at 0x4C2AF0F: malloc (vg_replace_malloc.c:299)
==16451==    by 0x7CADB40: nl_recv (in /usr/lib64/libnl-3.so.200.23.0)
==16451==    by 0x532DFAC: virNetlinkDumpCommand (virnetlink.c:363)
==16451==    by 0x53236AE: virNetDevIPCheckIPv6Forwarding (virnetdevip.c:641)
==16451==    by 0xE3E4A1A: networkStartNetworkVirtual (bridge_driver.c:2490)
==16451==    by 0xE3E55F5: networkStartNetwork (bridge_driver.c:2832)
==16451==    by 0xE3DFFE5: networkAutostartConfig (bridge_driver.c:531)
==16451==    by 0x53F47E0: virNetworkObjListForEachHelper (virnetworkobj.c:1412)
==16451==    by 0x52FE69F: virHashForEach (virhash.c:606)
==16451==    by 0x53F4857: virNetworkObjListForEach (virnetworkobj.c:1439)
==16451==    by 0xE3E0BF4: networkStateAutoStart (bridge_driver.c:808)
==16451==    by 0x55689CE: virStateInitialize (libvirt.c:758)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
7 years agodocs: Import print_function in reformat-news.py
Andrea Bolognani [Thu, 15 Mar 2018 16:53:13 +0000 (17:53 +0100)]
docs: Import print_function in reformat-news.py

The script already works perfectly fine with Python 2, but that's
more by chance than by design: we have a single occurrence of
print(), and it just so happens that its only argument is an
expression. Importing print_function makes the script more future,
err, past proof.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoqemu: fix a mem leak
Chen Hanxiao [Sat, 17 Mar 2018 10:24:09 +0000 (18:24 +0800)]
qemu: fix a mem leak

fix a mem leak

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agovirarptable: fix some leaks and format issue
Chen Hanxiao [Sat, 17 Mar 2018 10:24:08 +0000 (18:24 +0800)]
virarptable: fix some leaks and format issue

fix some leaks and format issue
Also support virArpTableFree to get NULL.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
7 years agolibxl: MigratePrepare: use standard begin and end API pattern
Jim Fehlig [Tue, 13 Mar 2018 16:48:28 +0000 (10:48 -0600)]
libxl: MigratePrepare: use standard begin and end API pattern

libxlDomainMigrationPrepare adds the incoming domain def to the list
of domains via virDomainObjListAdd, but never adds its own ref to the
returned virDomainObj as other callers of virDomainObjListAdd do.
libxlDomainMigrationPrepareTunnel3 suffers the same discrepancy.

Change both to add a ref to the virDomainObj after a successful
virDomainObjListAdd, similar to other callers. This ensures a consistent
pattern throughout the drivers and allows using the virDomainObjEndAPI
function for cleanup.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agolibxl: Use virDomainObjListFindBy{UUID|ID}Ref
John Ferlan [Fri, 9 Mar 2018 16:48:00 +0000 (11:48 -0500)]
libxl: Use virDomainObjListFindBy{UUID|ID}Ref

For libxlDomainLookupByID and libxlDomainLookupByUUID let's
return a locked and referenced @vm object so that callers can
then use the common and more consistent virDomainObjEndAPI in
order to handle cleanup rather than needing to know that the
returned object is locked and calling virObjectUnlock.

The LookupByName already returns the ref counted and locked object,
so this will make things more consistent.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
7 years agolibxl: Properly cleanup after libxlDomObjFromDomain
John Ferlan [Fri, 9 Mar 2018 16:47:59 +0000 (11:47 -0500)]
libxl: Properly cleanup after libxlDomObjFromDomain

Commit id '9ac945078' altered libxlDomObjFromDomain to return
a locked *and* ref counted object for some specific purposes;
however, it neglected to alter all the consumers of the helper
to use virDomainObjEndAPI thus leaving many objects with extra
ref counts.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Jim Fehlig <jfehlig@suse.com>
7 years agoapibuild: Fix -refs.xml building
Cole Robinson [Fri, 16 Mar 2018 17:49:58 +0000 (13:49 -0400)]
apibuild: Fix -refs.xml building

Another usage of deprecated 'string' functions. We are just trying to
match ascii letters here, so use a simple regex. And again drop the
aggressive exception handling, it doesn't seem to trigger for anything
in libvirt code.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
7 years agoapibuild: Fix errors on python3
Cole Robinson [Fri, 16 Mar 2018 17:47:36 +0000 (13:47 -0400)]
apibuild: Fix errors on python3

Module 'string' function lower doesn't exist in python3. The canonical
way is to call .lower() on a str instance. Do that, and make the
exception handling more specific, which would have made this issue
obvious.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
7 years agolibxl: MigratePerform: properly cleanup after libxlDomObjFromDomain
Jim Fehlig [Tue, 13 Mar 2018 17:05:36 +0000 (11:05 -0600)]
libxl: MigratePerform: properly cleanup after libxlDomObjFromDomain

libxlDomObjFromDomain to returns locked and ref counted virDomainObj but
libxlDomainMigratePerform3Params only unlocks the object on exit. Convert
it to use the virDomainObjEndAPI function for cleanup.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agolibxl: MigrateConfirm: Dont unlock virDomainObj in helper function
Jim Fehlig [Mon, 12 Mar 2018 18:22:34 +0000 (12:22 -0600)]
libxl: MigrateConfirm: Dont unlock virDomainObj in helper function

The libxlDomainMigrateConfirm3Params API locks and ref counts the associated
virDomainObj but relies on the helper function libxlDomainMigrationConfirm
to unlock the object. Unref'ing the object is not done in either function.
libxlDomainMigrationConfirm is also used by libxlDomainMigratePerform3Params
for p2p migration, but in that case the lock/ref and unref/unlock are
properly handled in the API entry point.

Remove the unlock from libxlDomainMigrationConfirm and adjust
libxlDomainMigrateConfirm3Params to properly unref/unlock the virDomainObj
on success and error paths.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agolibxl: MigrateBegin: Dont call EndAPI in helper function
Jim Fehlig [Mon, 12 Mar 2018 17:51:43 +0000 (11:51 -0600)]
libxl: MigrateBegin: Dont call EndAPI in helper function

The libxlDomainMigrateBegin3Params API locks and ref counts the associated
virDomainObj but relies on the helper function libxlDomainMigrationBegin
to unref/unlock the object. libxlDomainMigrationBegin is also used by
libxlDomainMigratePerform3Params for p2p migration, but in that case the
lock/ref and unref/unlock are properly handled in the API entry point. So
p2p migrations suffer a double unref/unlock in the Perform API.

Remove the unref/unlock (virDomainObjEndAPI) from libxlDomainMigrationBegin
and adjust libxlDomainMigrateBegin3Params to properly unref/unlock
the virDomainObj on success and error paths.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agodocs: mention viewing security notices on front page
Daniel P. Berrangé [Fri, 16 Mar 2018 17:12:00 +0000 (17:12 +0000)]
docs: mention viewing security notices on front page

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agodocs: link to security.libvirt.org website
Daniel P. Berrangé [Thu, 15 Mar 2018 16:03:20 +0000 (16:03 +0000)]
docs: link to security.libvirt.org website

We forgot to tell anyone that we were publishing security notices
online at https://security.libvirt.org

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agorpm: depend on python2, not bare python
Daniel P. Berrangé [Thu, 15 Mar 2018 13:44:31 +0000 (13:44 +0000)]
rpm: depend on python2, not bare python

Fedora requires packages to depend on "python2" RPM, not the unversioned
"python" name. Fortunately even though RHEL-6 ships a "python" RPM, it
has a virtual Provides for the "python2" name, so we don't need to
conditionalize this.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoqemu: Build usb controller command line more wisely
Michal Privoznik [Fri, 16 Mar 2018 14:53:32 +0000 (15:53 +0100)]
qemu: Build usb controller command line more wisely

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

When building command line for USB controllers we have to do more
than just put controller's alias onto the command line. QEMU has
concept of these joined USB controllers. For instance ehci and
uhci controllers need to create the same USB bus. To achieve that
the slave controller needs to refer the master controller. This
worked until we've introduced user aliases because both master
and slave had the same alias. With user aliases slave can have
different alias than master. Therefore, when generating command
line for slave we need to look up the master's alias.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoqemu: Use correct bus type for input devices
Farhan Ali [Thu, 8 Mar 2018 16:07:04 +0000 (11:07 -0500)]
qemu: Use correct bus type for input devices

commit 7210cef452db 'qemu: build command line for virtio input devices'
introduced an error, by checking if input bus type is
VIR_DOMAIN_DISK_BUS_VIRTIO.

Fix it by using the correct bus type for input devices.

Signed-off-by: Farhan Ali <alifm@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoqemu: Fix comment for 'qemuValidateDevicePCISlotsChipsets'
Farhan Ali [Thu, 8 Mar 2018 16:07:01 +0000 (11:07 -0500)]
qemu: Fix comment for 'qemuValidateDevicePCISlotsChipsets'

Commit id '177db487' renamed 'qemuValidateDevicePCISlotsChipsets' to
'qemuDomainValidateDevicePCISlotsChipsets', but didn't adjust comment.

Signed-off-by: Farhan Ali <alifm@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agovirnetlink: Provide virNetlinkGetNeighbor non-Linux stub
Michal Privoznik [Fri, 16 Mar 2018 07:44:20 +0000 (08:44 +0100)]
virnetlink: Provide virNetlinkGetNeighbor non-Linux stub

This function is exported and therefore we have to have
implementation for all platforms.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agovirarptable: Avoid cast align warnings
Michal Privoznik [Thu, 15 Mar 2018 14:08:58 +0000 (15:08 +0100)]
virarptable: Avoid cast align warnings

We have to use VIR_WARNINGS_NO_CAST_ALIGN to avoid clang warning
about increased required alignment caused by some netlink macros.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoremote: Set eventID explicitly to an invalid value
Marc Hartmayer [Thu, 8 Mar 2018 12:20:39 +0000 (13:20 +0100)]
remote: Set eventID explicitly to an invalid value

Set the eventID for remoteRelayDomainQemuMonitorEvent explicitly to an
invalid value. Although the value is not used by
remoteRelayDomainQemuMonitorEvent, but it might be less prone to
errors for further refactorings.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agostream: Access stream->prog instead of a hard-coded global variable
Marc Hartmayer [Thu, 8 Mar 2018 12:20:38 +0000 (13:20 +0100)]
stream: Access stream->prog instead of a hard-coded global variable

Use stream->prog instead of a hard-coded "remoteProgram" since at
stream creation in daemonCreateClientStream "remoteProgram" is used
so we should use that especially since these functions are intended
as generic helpers for streams.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agoremote: remove unneeded global variables
Marc Hartmayer [Thu, 8 Mar 2018 12:20:37 +0000 (13:20 +0100)]
remote: remove unneeded global variables

Remove unneeded global variables and convert them into local variables
where they're needed.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agotest: fix error path in testConnectOpen
Marc Hartmayer [Thu, 8 Mar 2018 12:20:35 +0000 (13:20 +0100)]
test: fix error path in testConnectOpen

In case of an error do the cleanup of the private data of the
connection.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agotest: introduce testDriverCloseInternal
Marc Hartmayer [Thu, 8 Mar 2018 12:20:34 +0000 (13:20 +0100)]
test: introduce testDriverCloseInternal

Refactor testConnectClose as it's then obvious that conn->privateData
is set to NULL in all cases. In addition, 'testConnectCloseInternal'
can be better reused.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agotest: rename defaultConn to defaultPrivconn
Marc Hartmayer [Thu, 8 Mar 2018 12:20:33 +0000 (13:20 +0100)]
test: rename defaultConn to defaultPrivconn

Rename the variable @defaultConn to @defaultPrivconn as it doesn't
point to a default connection but to the private data used for the
shared default connection of the test driver.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agotest: testConnectClose: Set privateData to NULL in all cases
Marc Hartmayer [Thu, 8 Mar 2018 12:20:32 +0000 (13:20 +0100)]
test: testConnectClose: Set privateData to NULL in all cases

Set privateData to NULL also for a connection that uses @defaultConn
as privateData regardless of whether @defaultConn was freed or
not. @defaultConn is shared between multiple connections and it's
ensured that there will be no memory leak by counting references.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agotest: testConnectAuthenticate: Take the lock when accessing mutable values
Marc Hartmayer [Thu, 8 Mar 2018 12:20:31 +0000 (13:20 +0100)]
test: testConnectAuthenticate: Take the lock when accessing mutable values

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agotest: testOpenFromFile: return VIR_DRV_OPEN_SUCCESS in case of success
Marc Hartmayer [Thu, 8 Mar 2018 12:20:30 +0000 (13:20 +0100)]
test: testOpenFromFile: return VIR_DRV_OPEN_SUCCESS in case of success

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agotest: testOpenDefault: introduce cleanup path
Marc Hartmayer [Thu, 8 Mar 2018 12:20:29 +0000 (13:20 +0100)]
test: testOpenDefault: introduce cleanup path

The two code paths have some cleanup in common so lets refactor it.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agodriver: Add typedef for the anonymous enum used for driver features
Marc Hartmayer [Thu, 8 Mar 2018 12:20:24 +0000 (13:20 +0100)]
driver: Add typedef for the anonymous enum used for driver features

Add typedef for the anonymous enum used for the driver features. This
allows the usage of the type in a switch statement and taking
advantage of the compilers feature to detect uncovered cases.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
7 years agotools: Clean up the vol-resize man page
John Ferlan [Mon, 12 Mar 2018 20:26:40 +0000 (16:26 -0400)]
tools: Clean up the vol-resize man page

Instead of appearing as one long paragraph, split the output to list
each command option on its own line for better readability.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agovirsh: Fix man page argument ordering for vol-{path|name|key} commands
John Ferlan [Mon, 12 Mar 2018 20:14:56 +0000 (16:14 -0400)]
virsh: Fix man page argument ordering for vol-{path|name|key} commands

The proper command order is 'virsh vol-path volume pool', or
'virsh vol-name volume pool', or 'virsh vol-key volume'. While
making the modification clean up the description a bit too in order
to help clarify under what circumstances the volume could be found
if the pool name was not provided.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agovirsh: Clean up man page formatting for vol-list and vol-pool
John Ferlan [Mon, 12 Mar 2018 20:12:25 +0000 (16:12 -0400)]
virsh: Clean up man page formatting for vol-list and vol-pool

Make the output more readable.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agovirsh: Fix man page argument ordering for vol-info command
John Ferlan [Mon, 12 Mar 2018 20:08:11 +0000 (16:08 -0400)]
virsh: Fix man page argument ordering for vol-info command

The proper command order is 'virsh vol-info volume pool'. While
making the modification clean up the description a bit too in order
to help clarify under what circumstances the volume could be found
if the pool name was not provided.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agovirsh: Fix man page argument ordering for vol-dumpxml command
John Ferlan [Mon, 12 Mar 2018 19:45:28 +0000 (15:45 -0400)]
virsh: Fix man page argument ordering for vol-dumpxml command

The proper command order is 'virsh vol-dumpxml volume pool'. While
making the modification clean up the description a bit too in order
to help clarify under what circumstances the volume could be found
if the pool name was not provided.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agovirsh: Fix man page argument ordering for vol-wipe command
John Ferlan [Mon, 12 Mar 2018 17:14:18 +0000 (13:14 -0400)]
virsh: Fix man page argument ordering for vol-wipe command

The proper command order is 'virsh vol-wipe volume pool algorithm'. While
making the modification clean up the description a bit too in order
to help clarify under what circumstances the volume could be found
if the pool name was not provided.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agovirsh: Fix man page argument ordering for vol-download command
John Ferlan [Mon, 12 Mar 2018 19:18:06 +0000 (15:18 -0400)]
virsh: Fix man page argument ordering for vol-download command

The proper command order is 'virsh vol-download volume file pool'. While
making the modification clean up the description a bit too in order
to help clarify under what circumstances the volume could be found
if the pool name was not provided.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agovirsh: Fix man page argument ordering for vol-upload command
John Ferlan [Mon, 12 Mar 2018 19:12:23 +0000 (15:12 -0400)]
virsh: Fix man page argument ordering for vol-upload command

The proper command order is 'virsh vol-upload volume file pool'. While
making the modification clean up the description a bit too in order
to help clarify under what circumstances the volume could be found
if the pool name was not provided.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agovirsh: Fix man page argument ordering for vol-delete command
John Ferlan [Mon, 12 Mar 2018 15:26:24 +0000 (11:26 -0400)]
virsh: Fix man page argument ordering for vol-delete command

The proper command order is 'virsh vol-delete volume pool'. While
making the modification clean up the description a bit too in order
to help clarify under what circumstances the volume could be found
if the pool name was not provided.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agovirsh: Fix man page argument ordering for vol-clone command
John Ferlan [Mon, 12 Mar 2018 16:59:14 +0000 (12:59 -0400)]
virsh: Fix man page argument ordering for vol-clone command

The proper command order is 'virsh vol-clone source-vol target-vol pool'.
While making the modification clean up the description a bit too in
order to help clarify under what circumstances the source-vol could be
found if the pool name was not provided.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agovirsh: Clean up formatting of the vol-create* commands
John Ferlan [Mon, 12 Mar 2018 20:01:48 +0000 (16:01 -0400)]
virsh: Clean up formatting of the vol-create* commands

Clean up the formatting to make the output a bit more readable at
least with respect to not having one paragraph of output. Each
option will start on its own line.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agodocs: Fix apibuild.py syntax
John Ferlan [Thu, 15 Mar 2018 20:17:05 +0000 (16:17 -0400)]
docs: Fix apibuild.py syntax

Commit id '477502de3' altered the entry to add one too many closing
parenthesis ')' and that propagated into commit id '9176b42bd'.

Signed-off-by: John Ferlan <jferlan@redhat.com>
7 years agopython3: Fix sort function
Andrea Bolognani [Thu, 15 Mar 2018 09:57:16 +0000 (10:57 +0100)]
python3: Fix sort function

This deals with cls.version possibly being None.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agopython3: Open files in text instead of binary mode
Andrea Bolognani [Thu, 15 Mar 2018 09:56:42 +0000 (10:56 +0100)]
python3: Open files in text instead of binary mode

We use text operations on the contents after reading them.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agopython3: Replace keys() + sort() with sorted()
Andrea Bolognani [Thu, 15 Mar 2018 09:51:57 +0000 (10:51 +0100)]
python3: Replace keys() + sort() with sorted()

The keys() method no longer returns a list, so converting the
return value would be necessary before calling sort() on it;
alternatively, we can just call sorted(), which returns a
sorted list.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agopython3: Call list() explicitly as needed
Andrea Bolognani [Thu, 15 Mar 2018 09:54:07 +0000 (10:54 +0100)]
python3: Call list() explicitly as needed

For list concatenation to work, the value returned by the
keys() method must be converted to a list first.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agopython3: Remove uses of string.*() functions
Andrea Bolognani [Thu, 15 Mar 2018 09:42:44 +0000 (10:42 +0100)]
python3: Remove uses of string.*() functions

All of these have been replaced with methods.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agopython3: Use the 'in' keyword
Andrea Bolognani [Thu, 15 Mar 2018 09:39:49 +0000 (10:39 +0100)]
python3: Use the 'in' keyword

This replaces uses of the has_key() method.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agopython3: Use the repr() function
Andrea Bolognani [Thu, 15 Mar 2018 09:36:06 +0000 (10:36 +0100)]
python3: Use the repr() function

This replaces the `` built-in.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agopython3: Use the print() function
Andrea Bolognani [Thu, 15 Mar 2018 09:30:03 +0000 (10:30 +0100)]
python3: Use the print() function

It has replaced the 'print' statement.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agotravis: Don't install xz on macOS
Andrea Bolognani [Thu, 15 Mar 2018 15:01:21 +0000 (16:01 +0100)]
travis: Don't install xz on macOS

It's already being dragged in by Python.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agolockd: fix typo in virtlockd-admin.socket
Jim Fehlig [Wed, 14 Mar 2018 22:42:39 +0000 (16:42 -0600)]
lockd: fix typo in virtlockd-admin.socket

Commit ce7ae55ea1 introduced a typo in virtlockd-admin socket file

/usr/lib/systemd/system/virtlockd-admin.socket:7: Unknown lvalue
'Server' in section 'Socket'

Change 'Server' to 'Service'.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
7 years agotravis: unlink python package before upgrading brew packages
Daniel P. Berrangé [Thu, 15 Mar 2018 13:05:55 +0000 (13:05 +0000)]
travis: unlink python package before upgrading brew packages

The 'brew upgrade' command is pulling in the python2 package which
promptly fails due to clashing symlinks installed by the new python
package (which is python3 based):

==> Pouring python@2-2.7.14_3.sierra.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/2to3-2
Target /usr/local/bin/2to3-2
is a symlink belonging to python. You can unlink it:
  brew unlink python
To force the link and overwrite all conflicting files:
  brew link --overwrite python@2
To list all files that would be deleted:
  brew link --overwrite --dry-run python@2

By running 'brew unlink python' we can get rid of the python3 links that
we didn't want in the first place and avoid this error.

This is the working fix for what we previously attempted todo in:

  commit c9c9fc90ce77ac4a3079c99f42b621937b464700
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   Mon Mar 5 10:13:12 2018 +0000

    travis: force install of python2 into $PATH on macOS

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agotravis: move macOS before_install tasks into osx matrix entry
Daniel P. Berrangé [Thu, 15 Mar 2018 10:10:53 +0000 (10:10 +0000)]
travis: move macOS before_install tasks into osx matrix entry

The list of commands we're running for the before_install task
is rather large. We have it all on one line because we're
wrapping it all in a test against TRAVIS_OS_NAME env variable.

By moving it into the osx matrix entry we can remove the need
for the conditional shell test. This lets us put each command
on a separate line making the steps clear to understand.

Fortunately the 'before_install' task does not have the crazy
behaviour whereby travis ignores errors and runs all commands
regardless, like the 'script' task does. The first command
failing will cause an immediate stop with error status.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agovirarptable: Include rtnetlink.h only on Linux
Michal Privoznik [Thu, 15 Mar 2018 12:27:55 +0000 (13:27 +0100)]
virarptable: Include rtnetlink.h only on Linux

And at the same time, do that from .c rather than .h file.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Chen Hanxiao<chenhanxiao@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agosrc: Don't add virarptable.c to setuid library
Michal Privoznik [Thu, 15 Mar 2018 12:46:48 +0000 (13:46 +0100)]
src: Don't add virarptable.c to setuid library

The setuid-rpc-client.la is intended to be small and contain only
bare minimum of source files. virarptable.c is not one of them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Chen Hanxiao<chenhanxiao@gmail.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agospec: Drop polkit-devel from BuildRequires
Andrea Bolognani [Thu, 15 Mar 2018 11:25:09 +0000 (12:25 +0100)]
spec: Drop polkit-devel from BuildRequires

As of 2499d1a09508 we don't link against libpolkit anymore, so
we only need the polkit package to be available during build.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agonews: qemu: use arp table of host to get the IP address of guests
Chen Hanxiao [Thu, 8 Mar 2018 07:11:59 +0000 (15:11 +0800)]
news: qemu: use arp table of host to get the IP address of guests

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
7 years agovirsh: add --source arp to domifaddr
Chen Hanxiao [Thu, 8 Mar 2018 07:11:58 +0000 (15:11 +0800)]
virsh: add --source arp to domifaddr

We can use:
  domifaddr f26-cloud --source arp
to get the address.

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
7 years agoqemu: introduce qemuARPGetInterfaces to get IP from host's arp table
Chen Hanxiao [Thu, 8 Mar 2018 07:11:57 +0000 (15:11 +0800)]
qemu: introduce qemuARPGetInterfaces to get IP from host's arp table

introduce VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_ARP to get ip address
of VM from the message of netlink RTM_GETNEIGH

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoutil: introduce helper to parse message from RTM_GETNEIGH query
Chen Hanxiao [Thu, 8 Mar 2018 07:11:56 +0000 (15:11 +0800)]
util: introduce helper to parse message from RTM_GETNEIGH query

introduce helper to parse RTM_GETNEIGH query message and
store it in struct virArpTable.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agoutil: introduce virNetlinkGetNeighbor to get neighbor table entry
Chen Hanxiao [Thu, 8 Mar 2018 07:11:55 +0000 (15:11 +0800)]
util: introduce virNetlinkGetNeighbor to get neighbor table entry

use RTM_GETNEIGH to query arp table entry by netlink socket

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
7 years agoqemu: hotplug: Clean up memory backing files after failed memory hotplug
Peter Krempa [Tue, 13 Mar 2018 17:19:39 +0000 (18:19 +0100)]
qemu: hotplug: Clean up memory backing files after failed memory hotplug

Libvirt provides full path to the backing file since commit
fec8f9c49afb479f6. This made qemu create the backend object but did not
delete it. This was fixed for unplug case in 4d83a6722f but not in case
of failure to hotplug the frontend. We'd leave the files behind which
would make memory unusable in case of hugepages.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
7 years agoqemu: Switch context for job related private XML parsing
Jiri Denemark [Tue, 13 Mar 2018 14:50:41 +0000 (15:50 +0100)]
qemu: Switch context for job related private XML parsing

Having to repeat "./job[1]/" XPath prefix for every single element or
attribute we want to parse is suboptimal. And even more so once we
further extract code from qemuDomainObjPrivateXMLParseJob into separate
functions.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agoqemu: Parse all job related private XML in dedicated function
Jiri Denemark [Tue, 13 Mar 2018 14:43:00 +0000 (15:43 +0100)]
qemu: Parse all job related private XML in dedicated function

Commit dc567cc22b introduced qemuDomainObjPrivateXMLParseJob, but forgot
to move "./job[1]/@type" parsing into it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7 years agodaemonStreamHandleWriteData: Preserve error when aborting stream
Michal Privoznik [Mon, 12 Mar 2018 09:18:05 +0000 (10:18 +0100)]
daemonStreamHandleWriteData: Preserve error when aborting stream

The daemonStreamHandleWriteData() function is called whenever
server side of stream is able to receive some data. Nevertheless,
it calls virStreamSend() (to pass data down to virFDStream) and
depending on its return value it may abort the stream. However,
the functions it called when doing so are public APIs and as such
reset any error set previously. Therefore, if there was any error
in writing data to stream (i.e. repored in virStreamSend) it is
reset before virNetServerProgramSendReplyError() can get to it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
7 years agovirsysinfo: Use more virSkipSpacesBackwards()
Michal Privoznik [Tue, 13 Mar 2018 15:03:13 +0000 (16:03 +0100)]
virsysinfo: Use more virSkipSpacesBackwards()

Some fields reported by dmidecode have plenty of useless spaces
(in fact some have nothing but spaces). To deal with this we have
introduced virSkipSpacesBackwards() and use it in
virSysinfoParseX86Processor() and virSysinfoParseX86Memory().
However, other functions (e.g. virSysinfoParseX86Chassis()) don't
use it at all and thus we are reporting nonsense:

  <sysinfo type='smbios'>
    <chassis>
      <entry name='manufacturer'>FUJITSU</entry>
      <entry name='version'>                      </entry>
      <entry name='serial'>                </entry>
      <entry name='asset'>                                        </entry>
      <entry name='sku'>Default string</entry>
    </chassis>
  </sysinfo>

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
7 years agom4: Fix xenstore detection
Andrea Bolognani [Wed, 14 Mar 2018 14:40:07 +0000 (15:40 +0100)]
m4: Fix xenstore detection

Commit 596fc3e3897e introduced the ability to detect xenstore
using pkg-config for systems with Xen 4.9, but accidentally broke
detection for all other systems. Fix the logic so that it works
in all cases.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
7 years agoqemu: avoid denial of service reading from QEMU guest agent (CVE-2018-1064)
Daniel P. Berrangé [Thu, 1 Mar 2018 14:55:26 +0000 (14:55 +0000)]
qemu: avoid denial of service reading from QEMU guest agent (CVE-2018-1064)

We read from the agent until seeing a \r\n pair to indicate a completed
reply or event. To avoid memory denial-of-service though, we must have a
size limit on amount of data we buffer. 10 MB is large enough that it
ought to cope with normal agent replies, and small enough that we're not
consuming unreasonable mem.

This is identical to the flaw we had reading from the QEMU monitor
as CVE-2018-5748, so rather embarrassing that we forgot to fix
the agent code at the same time.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
7 years agoDo not check for pkcheck
Ján Tomko [Wed, 7 Mar 2018 09:17:57 +0000 (10:17 +0100)]
Do not check for pkcheck

All we need is D-Bus.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
7 years agoMerge WITH_POLKIT1 and WITH_POLKIT
Ján Tomko [Wed, 7 Mar 2018 09:14:23 +0000 (10:14 +0100)]
Merge WITH_POLKIT1 and WITH_POLKIT

There is just one polkit now.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
7 years agoDo not generate polkit rules file
Ján Tomko [Wed, 14 Mar 2018 11:08:37 +0000 (12:08 +0100)]
Do not generate polkit rules file

This essentially reverts commit <e1019e9>, which added
an extra step for generating the policy file.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
7 years agoRemove Policy-Kit support
Ján Tomko [Tue, 6 Mar 2018 15:47:44 +0000 (16:47 +0100)]
Remove Policy-Kit support

Policy-Kit has been replaced by polkit (referred to, respectively,
as POLKIT0 and POLKIT1 in our Makefiles).

The last build fix with old Policy-Kit was in May 2013:
commit <442eb2ba> and build with -Wunused-label was broken
since April 2016: commit <8437130>

Signed-off-by: Ján Tomko <jtomko@redhat.com>
7 years agoconf: Extract parsing of storage source related data
Peter Krempa [Mon, 12 Mar 2018 14:09:28 +0000 (15:09 +0100)]
conf: Extract parsing of storage source related data

Split out the parser and separate it from the private data part so that
it can be later reused in other parts of the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
7 years agoconf: Parse and validate disk source seclabels together with the source
Peter Krempa [Thu, 8 Mar 2018 16:32:15 +0000 (17:32 +0100)]
conf: Parse and validate disk source seclabels together with the source

Since seclabels are formatted along with the source element and will
also make sense to be passed for the backing chain we should parse them
in the place where we parse the disk source. Same applies for
validation.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
7 years agoconf: Separate seclabel validation from parsing
Peter Krempa [Thu, 8 Mar 2018 15:42:04 +0000 (16:42 +0100)]
conf: Separate seclabel validation from parsing

Rather than checking that the security label is legal when parsing it
move the code into a separate function.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
7 years agoconf: Validate disk source configuration also for the backing store
Peter Krempa [Thu, 8 Mar 2018 16:23:46 +0000 (17:23 +0100)]
conf: Validate disk source configuration also for the backing store

Since we already parse the <backingStore> of a disk source, we should
also validate the configuration for the whole backing chain and not only
for the top level image.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
7 years agoconf: disk: Separate virStorageSource formatting
Peter Krempa [Mon, 5 Mar 2018 14:13:41 +0000 (15:13 +0100)]
conf: disk: Separate virStorageSource formatting

Move out formatting of 'startuPolicy' which is a property of the disk
out of the <source> element. Extracting the code formating the content
and attributes will also allow reuse in other parts of the code.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>