]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
6 years agovirsh: Implement vshTable API to vcpupin, iothreadinfo, domfsinfo
Simon Kobyda [Fri, 21 Sep 2018 14:17:21 +0000 (16:17 +0200)]
virsh: Implement vshTable API to vcpupin, iothreadinfo, domfsinfo

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agovirsh: Implement vshTable API to domiflist
Simon Kobyda [Fri, 21 Sep 2018 14:17:20 +0000 (16:17 +0200)]
virsh: Implement vshTable API to domiflist

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agovirsh: Implement vshTable API to domblklist
Simon Kobyda [Fri, 21 Sep 2018 14:17:19 +0000 (16:17 +0200)]
virsh: Implement vshTable API to domblklist

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agovirsh: Implement vshTable API to domblkinfo
Simon Kobyda [Fri, 21 Sep 2018 14:17:18 +0000 (16:17 +0200)]
virsh: Implement vshTable API to domblkinfo

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agovirsh: Set up cmdDomblkinfo() and cmdDomblkinfoPrint() for vshTable API implementation
Simon Kobyda [Fri, 21 Sep 2018 14:17:17 +0000 (16:17 +0200)]
virsh: Set up cmdDomblkinfo() and cmdDomblkinfoPrint() for vshTable API implementation

I've moved all the printing from cmdDomblkinfoPrint() to cmdDomblkinfo(),
and renamed the cmdDomblkinfoPrint() to cmdDomblkinfoGet(), since nature of
that function changed from gathering and printing informations only to
gathering information. This I believe simplifies the functions and
makes the implementation of vshTable API simpler.

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agovirsh: Implement vshTable API to snapshot-list.
Simon Kobyda [Fri, 21 Sep 2018 14:17:16 +0000 (16:17 +0200)]
virsh: Implement vshTable API to snapshot-list.

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agovirsh: Implement vshTable API to nwfilter-list and nwfilterbinding-list
Simon Kobyda [Fri, 21 Sep 2018 14:17:15 +0000 (16:17 +0200)]
virsh: Implement vshTable API to nwfilter-list and nwfilterbinding-list

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agovirsh: Implement vshTable API to secret-list
Simon Kobyda [Fri, 21 Sep 2018 14:17:14 +0000 (16:17 +0200)]
virsh: Implement vshTable API to secret-list

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agovirsh: Implement vshTable API to net-list and net-dhcp-leases
Simon Kobyda [Fri, 21 Sep 2018 14:17:13 +0000 (16:17 +0200)]
virsh: Implement vshTable API to net-list and net-dhcp-leases

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agovirsh: Implement vsh-table to iface-list
Simon Kobyda [Fri, 21 Sep 2018 14:17:12 +0000 (16:17 +0200)]
virsh: Implement vsh-table to iface-list

Signed-off-by: Simon Kobyda <skobyda@redhat.com>
6 years agoqemu: Update hostdevs device lists before connecting qemu monitor
Wu Zongyong [Fri, 21 Sep 2018 02:33:53 +0000 (10:33 +0800)]
qemu: Update hostdevs device lists before connecting qemu monitor

In a following case:

    virsh start $domain
    service libvirtd stop
    <shutdown> the guest from within the $domain
    service libvirtd start

Notice that PCI devices which have been assigned to the $domain will
still be bound to stub drivers instead rebound to host drivers.
In that case the call stack is like below:

    libvirtd start
        qemuProcessReconnect
            qemuProcessStop (because $domain was shutdown without
                             libvirtd event to process that)
                qemuHostdevReAttachDomainDevices
                    qemuHostdevReAttachPCIDevices
                        virHostdevReAttachPCIDevices

However, because qemuHostdevUpdateActiveDomainDevices was called
after the qemuConnectMonitor, the setup of the tracking of each
host device in the $domain on either the activePCIHostdevs list
or inactivePCIHostdev list will not occur in an orderly manner.
Therefore, virHostdevReAttachPCIDevices just neglects these host PCI
devices which are bound to stub drivers and doesn't rebind them to
host drivers.

This patch fixs that by moving qemuHostdevUpdateActiveDomainDevices before
qemuConnectMonitor during libvirtd reconnection processing.

Signed-off-by: Wu Zongyong <cordius.wu@huawei.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Fix deadlock if create qemuProcessReconnect thread failed
Wang Yechao [Fri, 21 Sep 2018 04:35:11 +0000 (12:35 +0800)]
qemu: Fix deadlock if create qemuProcessReconnect thread failed

Use the new qemuDomainRemoveInactiveJobLocked to remove the
@obj during the virDomainObjListForEach call which holds a
lock on the domain object list.

Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Introduce qemuDomainRemoveInactiveJobLocked
Wang Yechao [Fri, 21 Sep 2018 04:35:09 +0000 (12:35 +0800)]
qemu: Introduce qemuDomainRemoveInactiveJobLocked

Create a qemuDomainRemoveInactiveJobLocked which copies
qemuDomainRemoveInactiveJob except of course calling
another new helper qemuDomainRemoveInactiveLocked.

The qemuDomainRemoveInactiveLocked is a copy of
qemuDomainRemoveInactive except that instead of calling
virDomainObjListRemove it calls virDomainObjListRemoveLocked.

Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Split up qemuDomainRemoveInactive
Wang Yechao [Fri, 21 Sep 2018 04:35:08 +0000 (12:35 +0800)]
qemu: Split up qemuDomainRemoveInactive

Introduce qemuDomainRemoveInactiveJobCommon to handle what will
be the common parts of the code with a new function that will
be used to call virDomainObjListRemoveLocked instead of the
unlocked variant.

Signed-off-by: Wang Yechao <wang.yechao255@zte.com.cn>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Drop QEMU_CAPS_DEVICE_SCSI_GENERIC
Andrea Bolognani [Tue, 18 Sep 2018 10:29:10 +0000 (12:29 +0200)]
qemu: Drop QEMU_CAPS_DEVICE_SCSI_GENERIC

It was already available in 1.5.0, so we can assume it's
present and avoid checking for it at runtime.

This commit is best viewed with 'git show -w'.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agotests: Fix duplicated capabilities
Andrea Bolognani [Tue, 18 Sep 2018 10:32:44 +0000 (12:32 +0200)]
tests: Fix duplicated capabilities

A bunch of SCSI test cases in qemuxml2argv used

  DO_TEST(...
          QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_VIRTIO_SCSI,
          ...);

instead of the intended

  DO_TEST(...
          QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI,
          ...);

which is used correctly in qemuxml2xml. Fix them.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: Prefer qemu-system-* binaries
Andrea Bolognani [Fri, 14 Sep 2018 12:36:15 +0000 (14:36 +0200)]
qemu: Prefer qemu-system-* binaries

We already prefer them in capabilities, and domcapabilities
should be consistent with that.

This commit is best viewed with 'git show -w'.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: Refactor virQEMUCapsCacheLookupByArch()
Andrea Bolognani [Fri, 14 Sep 2018 12:29:51 +0000 (14:29 +0200)]
qemu: Refactor virQEMUCapsCacheLookupByArch()

The new implementation contains less duplicated code and
is easier to extend.

This commit is best viewed with 'git show -w'.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: Rename qemubinCaps => qemuCaps
Andrea Bolognani [Tue, 18 Sep 2018 16:24:35 +0000 (18:24 +0200)]
qemu: Rename qemubinCaps => qemuCaps

The latter is used throughout libvirt, so use it here as
well for consistency.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: Simplify QEMU binary search
Andrea Bolognani [Tue, 18 Sep 2018 15:45:40 +0000 (17:45 +0200)]
qemu: Simplify QEMU binary search

Now that we have reduced the number of sensible options down
to either the native QEMU binary or RHEL's qemu-kvm, we can
make virQEMUCapsInitGuest() a bit simpler.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: Don't look for "qemu-kvm" and "kvm" binaries
Andrea Bolognani [Tue, 18 Sep 2018 15:26:37 +0000 (17:26 +0200)]
qemu: Don't look for "qemu-kvm" and "kvm" binaries

Both Fedora's qemu-kvm and Debian's/Ubuntu's kvm are nothing
more than paper-thin wrappers around the native QEMU binary,
so we gain nothing by looking for them.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: Remove unnecessary variables
Andrea Bolognani [Tue, 18 Sep 2018 15:06:48 +0000 (17:06 +0200)]
qemu: Remove unnecessary variables

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: Expect a single binary in virQEMUCapsInitGuest()
Andrea Bolognani [Tue, 18 Sep 2018 14:55:20 +0000 (16:55 +0200)]
qemu: Expect a single binary in virQEMUCapsInitGuest()

We're only ever passing a single binary when calling this
function, so we can remove all code dealing with the
possibility of a second binary being specified.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: Stop looking after finding the first binary
Andrea Bolognani [Tue, 18 Sep 2018 14:49:40 +0000 (16:49 +0200)]
qemu: Stop looking after finding the first binary

When the guest is native, we are currently looking at
potential KVM binaries regardless of whether or not we have
already located a QEMU binary suitable to run the guest.

This made sense back when KVM support was not part of QEMU
proper, but these days the KVM binaries are in most cases
just trivial wrapper scripts around the native QEMU binary
so it doesn't make sense to poke at them unless they're
the only binaries on the system, such as when running on
RHEL.

This will allow us to simplify both virQEMUCapsInitGuest()
and virQEMUCapsInitGuestFromBinary().

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: Move armv7l-on-aarch64 special case
Andrea Bolognani [Tue, 18 Sep 2018 14:27:42 +0000 (16:27 +0200)]
qemu: Move armv7l-on-aarch64 special case

When running an armv7l guest on an aarch64 hosts, the
qemu-system-aarch64 binary should be our first choice instead
of qemu-system-arm since the former can take advantage of KVM
acceleration.

Move the special case to virQEMUCapsFindBinaryForArch() so
that it's handled along with all other cases rather than on
its own later on.

Doing so will also make further refactoring easier.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: Don't duplicate binary name in capabilities
Andrea Bolognani [Fri, 14 Sep 2018 11:10:27 +0000 (13:10 +0200)]
qemu: Don't duplicate binary name in capabilities

virCapabilitiesAddGuestDomain() takes an optional binary
name: this is intended for cases where a certain domain
type can't use the default one registered for the guest
architecture, but has to use a special binary instead.

The current code, however, will pass 'binary' again when
'kvmbin' is not defined, which is unnecessary as 'binary'
has been registered as default earlier, and will result
in capabilities output such as

  <emulator>/usr/bin/qemu-system-x86_64</emulator>
  <domain type='qemu'/>
  <domain type='kvm'>
    <emulator>/usr/bin/qemu-system-x86_64</emulator>
  </domain>

with the second <emulator> element providing no additional
information.

Change it so that, when 'kvmbin' is not defined, NULL is
passed and so the default emulator will be used instead.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: Move comments to virQEMUCapsGuestIsNative()
Andrea Bolognani [Tue, 18 Sep 2018 11:32:29 +0000 (13:32 +0200)]
qemu: Move comments to virQEMUCapsGuestIsNative()

The function performing the checks, rather than its callers,
should contain comments explaining the rationale behind said
checks.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agovirsh: Display vhostuser socket path in domiflist
Michal Privoznik [Tue, 18 Sep 2018 09:01:53 +0000 (11:01 +0200)]
virsh: Display vhostuser socket path in domiflist

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

The domiflist command is designed to show a brief information on
domain interfaces. One piece of information that is shows is
"Source" - source network, device, name, bridge. However, it's
ignoring vhostuser for which we can show the unix socket it's
associated with.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu_hotplug: Fetch vhostuser ifname on hotplug
Michal Privoznik [Tue, 18 Sep 2018 08:59:05 +0000 (10:59 +0200)]
qemu_hotplug: Fetch vhostuser ifname on hotplug

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

Since 2a13a0a1033 we are querying the vhostuser's interface name
when building qemu command line. However, we forgot to do so on
hotplug.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoxen_common: Change xenParseCharDev to use virConfGetValueStringList
Fabiano Fidêncio [Thu, 20 Sep 2018 13:28:52 +0000 (15:28 +0200)]
xen_common: Change xenParseCharDev to use virConfGetValueStringList

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoxen_common: Change xenParseVfbs to use virConfGetValueStringList
Fabiano Fidêncio [Thu, 20 Sep 2018 13:28:51 +0000 (15:28 +0200)]
xen_common: Change xenParseVfbs to use virConfGetValueStringList

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoxen_common: Change xenParsePCIList to use virConfGetValueStringList
Fabiano Fidêncio [Thu, 20 Sep 2018 13:28:50 +0000 (15:28 +0200)]
xen_common: Change xenParsePCIList to use virConfGetValueStringList

The `if(!list || list->type != VIR_CONF_LIST)` check couldn't be
written in a 100% similar way. Instead, we're just checking whether
`virConfGetValueStringList() <= 0` and creating a new function to:
- return -1 in case virConfGetValueStringList fails either due to some
  allocation failure or when traversing the list;
- resetting the last error and return 0 otherwise;

Taking this approach we can have the behaviour with the new code as
close as possible to the old one.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoxen_common: Change xenConfigGetString to use virConfGetValueString
Fabiano Fidêncio [Thu, 20 Sep 2018 13:28:49 +0000 (15:28 +0200)]
xen_common: Change xenConfigGetString to use virConfGetValueString

This change actually changes the behaviour of xenConfigGetString() as
now it returns a newly-allocated string.

Unfortunately, there's not much that can be done in order to avoid that
and all the callers have to be changed in order to avoid leaking the
return value.

Also, as a side-effect of the change above, the function now takes a
"char **" argument instead of a "const char **" one.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoxen_common: Change xenConfigGetUUID to use virConfGetValueString
Fabiano Fidêncio [Thu, 20 Sep 2018 13:28:48 +0000 (15:28 +0200)]
xen_common: Change xenConfigGetUUID to use virConfGetValueString

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoxen_common: Change xenConfigCopyStringInternal to use virConfGetValueString
Fabiano Fidêncio [Thu, 20 Sep 2018 13:28:47 +0000 (15:28 +0200)]
xen_common: Change xenConfigCopyStringInternal to use virConfGetValueString

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agotests: domaincaps: Add QEMU 3.0 for s390x
Boris Fiuczynski [Thu, 20 Sep 2018 10:20:57 +0000 (12:20 +0200)]
tests: domaincaps: Add QEMU 3.0 for s390x

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
6 years agotests: Add capabilities data for QEMU 3.0.0 on s390x
Boris Fiuczynski [Thu, 20 Sep 2018 10:20:56 +0000 (12:20 +0200)]
tests: Add capabilities data for QEMU 3.0.0 on s390x

The QEMU binary is compiled from the v3.0.0 tag.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
6 years agoutil: Fix travis build error
John Ferlan [Thu, 20 Sep 2018 18:57:22 +0000 (14:57 -0400)]
util: Fix travis build error

Commit 12093f1f used %ld instead of %zd for a size_t.

Signed-off-by: John Ferlan <jferlan@redhat.com>
6 years agoRemove ignore_value or void from unlink calls
John Ferlan [Thu, 20 Sep 2018 12:08:19 +0000 (08:08 -0400)]
Remove ignore_value or void from unlink calls

There seems to be no need to add the ignore_value wrapper or
caste with (void) to the unlink() calls, so let's just remove
them. I assume at one point in time Coverity complained. So,
let's just be consistent - those that care to check the return
status can and those that don't can just have the naked unlink.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoconf: Introduce RDT monitor host capability
Wang Huaqiang [Thu, 20 Sep 2018 10:10:50 +0000 (18:10 +0800)]
conf: Introduce RDT monitor host capability

This patch is introducing cache monitor(CMT) to cache and
memory bandwidth monitor(MBM) for monitoring CPU memory
bandwidth.

The host capability of the two monitors is also introduced
in this patch.

For CMT, the host capability is shown like:
  <host>
  ...
    <cache>
      <bank id='0' level='3' type='both' size='15' unit='MiB' cpus='0-5'>
        <control granularity='768' min='1536' unit='KiB' type='both' maxAllocs='4'/>
      </bank>
      <monitor level='3' 'reuseThreshold'='270336' maxMonitors='176'>
        <feature name='llc_occupancy'/>
      </monitor>
    </cache>
    ...
  </host>

For MBM, the capability is shown like this:
  <host>
    ...
    <memory_bandwidth>
      <node id='1' cpus='6-11'>
        <control granularity='10' min ='10' maxAllocs='4'/>
      </node>
      <monitor maxMonitors='176'>
        <feature name='mbm_total_bytes'/>
        <feature name='mbm_local_bytes'/>
      </monitor>
    </memory_bandwidth>
    ...
  </host>

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoconf: Refactor memory bandwidth capability structure
Wang Huaqiang [Thu, 20 Sep 2018 10:10:49 +0000 (18:10 +0800)]
conf: Refactor memory bandwidth capability structure

Move memory bandwidth capability nodes into one data structure,
this allows us to add a monitor for memory bandwidth.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoconf: Refactor cache bank capability structure
Wang Huaqiang [Thu, 20 Sep 2018 10:10:48 +0000 (18:10 +0800)]
conf: Refactor cache bank capability structure

Move all cache banks into one data structure, this allows
us to add other cache component, such as cache monitor.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Introduce monitor capability interface
Wang Huaqiang [Thu, 20 Sep 2018 10:10:47 +0000 (18:10 +0800)]
util: Introduce monitor capability interface

This patch introduces the resource monitor and creates the interface
for getting host capability of resource monitor from the system resource
control file system.

The resource monitor takes the role of RDT monitoring group and could be
used to monitor the resource consumption information, such as the last
level cache occupancy and the utilization of memory bandwidth.

Signed-off-by: Wang Huaqiang <huaqiang.wang@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agolibxl: fallback to lib probe if pkgconfig file not found
Jim Fehlig [Wed, 19 Sep 2018 16:16:23 +0000 (10:16 -0600)]
libxl: fallback to lib probe if pkgconfig file not found

With the assumption that all Xen >= 4.6 contains a pkgconfig file for
libxenlight, commit 5bdcef13 dropped the fallback check to probe
libxenlight with LIBVIRT_CHECK_LIB. At the time it was not known that
the various Xen pkgconfig files are in the -runtime package in Fedora,
instead of the traditional -devel package. This bug [1] was fixed in
Fedora > 28, but until Fedora 28 reaches EOL we'll need to re-introduce
the fallback check.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1629643

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
6 years agobuild: remove unused variables from virt-driver-libxl.m4
Jim Fehlig [Wed, 19 Sep 2018 18:35:02 +0000 (12:35 -0600)]
build: remove unused variables from virt-driver-libxl.m4

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
6 years agostorage: Save error during refresh failure processing
John Ferlan [Wed, 12 Sep 2018 15:25:37 +0000 (11:25 -0400)]
storage: Save error during refresh failure processing

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

Save the error from the refresh failure because the stopPool
processing may overwrite the error or even worse clear it
due to calling an external libvirt API that resets the last
error such as is the case with the SCSI pool which may call
virGetConnectNodeDev (see commit decaeb288) in order to
process deleting an NPIV vport.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agostorage: Introduce storagePoolRefreshFailCleanup
John Ferlan [Wed, 12 Sep 2018 13:35:42 +0000 (09:35 -0400)]
storage: Introduce storagePoolRefreshFailCleanup

Create a common pool refresh failure handling method as the
same code is repeated multiple times.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agostorage: Create error label path for storagePoolCreateXML
John Ferlan [Wed, 12 Sep 2018 15:17:17 +0000 (11:17 -0400)]
storage: Create error label path for storagePoolCreateXML

Rather than duplicate the error code, let's create an error
label to keep code common.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agostorage: Clean up storagePoolUpdateStateCallback processing
John Ferlan [Wed, 12 Sep 2018 15:05:51 +0000 (11:05 -0400)]
storage: Clean up storagePoolUpdateStateCallback processing

Alter the code path to remove the need to to go cleanup and thus
remove the label completely.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agostorage: Clean up stateFile if refreshPool fails
John Ferlan [Wed, 12 Sep 2018 12:29:32 +0000 (08:29 -0400)]
storage: Clean up stateFile if refreshPool fails

If the virStoragePoolRefresh fails and we call stopPool, the
code neglected to clean up the state file leading to the next
libvirtd restart attempting to start the pool. For a transient
pool this could make it unexpectedly reappear.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoqemu: Ignore nwfilter binding instantiation issues during reconnect
John Ferlan [Fri, 24 Aug 2018 13:29:24 +0000 (09:29 -0400)]
qemu: Ignore nwfilter binding instantiation issues during reconnect

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

It's essentially stated in the nwfilterBindingDelete that we
will allow the admin to shoot themselves in the foot by deleting
the nwfilter binding which then allows them to undefine the
nwfilter that is in use for the running guest...

However, by allowing this we cause a problem for libvirtd
restart reconnect processing which would then try to recreate
the missing binding attempting to use the deleted filter
resulting in an error and thus shutting the guest down.

So rather than keep adding virDomainConfNWFilterInstantiate
flags to "ignore" specific error conditions, modify the logic
to ignore, but VIR_WARN errors other than ignoreExists. This
will at least allow the guest to not shutdown for only nwfilter
binding errors that we can now perhaps recover from since we
have the binding create/delete capability.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agosrc: More cleanup of some system headers already contained in internal.h
Erik Skultety [Tue, 18 Sep 2018 13:55:56 +0000 (15:55 +0200)]
src: More cleanup of some system headers already contained in internal.h

All of the ones being removed are pulled in by internal.h. The only
exception is sanlock which expects the application to include <stdint.h>
before sanlock's headers, because sanlock prototypes use fixed width
int, but they don't include stdint.h themselves, so we have to leave
that one in place.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
6 years agointernal: Move <stdio.h> include to internal.h
Erik Skultety [Tue, 18 Sep 2018 13:21:22 +0000 (15:21 +0200)]
internal: Move <stdio.h> include to internal.h

It doesn't really make sense for us to have stdlib.h and string.h but
not stdio.h in the internal.h header.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
6 years agolibxl: remove configure check for libxl_domain_config_from_json
Jim Fehlig [Fri, 14 Sep 2018 19:33:04 +0000 (13:33 -0600)]
libxl: remove configure check for libxl_domain_config_from_json

The libxl_domain_config_from_json API appeared in Xen 4.5, hence
there is no need to check for its existence after changing the
minimum supported Xen version to 4.6. Remove the check and its
use in the tests.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agosecret: Makefile: Fix an EXTRA_DIST typo
Erik Skultety [Wed, 19 Sep 2018 13:37:26 +0000 (15:37 +0200)]
secret: Makefile: Fix an EXTRA_DIST typo

So, when trying to add some secret util sources, we referenced them with
a non-existent symbol.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agocpu_map: Add Icelake CPU models
Jiri Denemark [Wed, 29 Aug 2018 12:29:20 +0000 (14:29 +0200)]
cpu_map: Add Icelake CPU models

Introduced in QEMU by commit v3.0.0-156-g8a11c62da9.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6 years agocpu_map: Add features for Icelake CPUs
Jiri Denemark [Wed, 29 Aug 2018 12:28:39 +0000 (14:28 +0200)]
cpu_map: Add features for Icelake CPUs

QEMU commits:

    e37a5c7fa4 (v2.12.0)
        i386: Add Intel Processor Trace feature support

    c2f193b538 (v2.7.0)
        target-i386: Add support for UMIP and RDPID CPUID bits

    aff9e6e46a (v2.12.0)
        x86/cpu: Enable new SSE/AVX/AVX512 cpu features

    f77543772d (v2.9.0)
        x86: add AVX512_VPOPCNTDQ features

    5131dc433d (v3.1.0)
        i386: Add CPUID bit for PCONFIG

    59a80a19ca (v3.1.0)
        i386: Add CPUID bit for WBNOINVD

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6 years agoqemu: Fix error reporting in qemuDomainSaveImageStartVM
Jiri Denemark [Tue, 18 Sep 2018 07:42:06 +0000 (09:42 +0200)]
qemu: Fix error reporting in qemuDomainSaveImageStartVM

When restoring a domain from a compressed image, we launch an
intermediate process for decompressing the saved data. If QEMU fails to
load the data for some reason, we force close the stdin/stdout file
descriptors of the intermediate process and wait for it to die. However,
virCommandWait can report various errors which would overwrite the real
error from QEMU. Thus instead of getting something useful:

    internal error: process exited while connecting to monitor:
    2018-09-17T15:17:29.998910Z qemu-system-x86_64: can't apply global
    Skylake-Client-x86_64-cpu.osxsave=off: Property '.osxsave' not found

we could get an irrelevant error message:

    internal error: Child process (lzop -dc --ignore-warn) unexpected
    fatal signal 13

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoDrop \n at the end of VIR_DEBUG messages
Jiri Denemark [Mon, 17 Sep 2018 15:06:30 +0000 (17:06 +0200)]
Drop \n at the end of VIR_DEBUG messages

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovirsh: Honour user locale in cmdList
Michal Privoznik [Wed, 19 Sep 2018 08:23:53 +0000 (10:23 +0200)]
virsh: Honour user locale in cmdList

In 2e97450425e we've mistakenly removed gettext macro for
translating static strings. This results in table header being
printed in English regardless of user locale.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agosecurity_selinux: Lock metadata when running transaction
Michal Privoznik [Mon, 10 Sep 2018 09:19:55 +0000 (11:19 +0200)]
security_selinux: Lock metadata when running transaction

Lock all the paths we want to relabel to mutually exclude other
libvirt daemons.

The only hitch here is that directories can't be locked.
Therefore, when relabeling a directory do not lock it (this
happens only when setting up some domain private paths anyway,
e.g. huge pages directory).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agosecurity_selinux: Move transaction handling up one level
Michal Privoznik [Mon, 10 Sep 2018 08:10:25 +0000 (10:10 +0200)]
security_selinux: Move transaction handling up one level

So far the whole transaction handling is done
virSecuritySELinuxSetFileconHelper(). This needs to change for
the sake of security label remembering and locking. Otherwise we
would be locking a path when only appending it to transaction
list and not when actually relabelling it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirSecuritySELinuxRestoreFileLabel: Adjust code pattern
Michal Privoznik [Mon, 10 Sep 2018 07:55:51 +0000 (09:55 +0200)]
virSecuritySELinuxRestoreFileLabel: Adjust code pattern

Firstly, the following code pattern is harder to follow:

  if (func() < 0) {
      error();
  } else {
      /* success */
  }

We should put 'goto cleanup' into the error branch and move the
else branch one level up.
Secondly, 'rc' should really be named 'ret' because it holds
return value of the function. Not some intermediate value.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirSecuritySELinuxRestoreFileLabel: Rename 'err' label
Michal Privoznik [Mon, 10 Sep 2018 07:45:56 +0000 (09:45 +0200)]
virSecuritySELinuxRestoreFileLabel: Rename 'err' label

This label is used in both successful and error paths. Therefore
it should be named 'cleanup' and not 'err'.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agosecurity_dac: Lock metadata when running transaction
Michal Privoznik [Fri, 7 Sep 2018 12:04:44 +0000 (14:04 +0200)]
security_dac: Lock metadata when running transaction

Lock all the paths we want to relabel to mutually exclude other
libvirt daemons.

The only hitch here is that directories can't be locked.
Therefore, when relabeling a directory do not lock it (this
happens only when setting up some domain private paths anyway,
e.g. huge pages directory).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agosecurity_dac: Fix info messages when chown()-ing
Michal Privoznik [Wed, 22 Aug 2018 13:37:57 +0000 (15:37 +0200)]
security_dac: Fix info messages when chown()-ing

Firstly, the message that says we're setting uid:gid shouldn't be
called from virSecurityDACSetOwnershipInternal() because
virSecurityDACRestoreFileLabelInternal() is calling it too.
Secondly, there are places between us reporting label restore and
us actually doing it where we can quit. Don't say we're doing
something until we are actually about to do it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agosecurity_dac: Move transaction handling up one level
Michal Privoznik [Wed, 22 Aug 2018 13:35:05 +0000 (15:35 +0200)]
security_dac: Move transaction handling up one level

So far the whole transaction handling is done
virSecurityDACSetOwnershipInternal(). This needs to change for
the sake of security label remembering and locking. Otherwise we
would be locking a path when only appending it to transaction
list and not when actually relabeling it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agosecurity_manager: Introduce metadata locking APIs
Michal Privoznik [Fri, 7 Sep 2018 09:11:44 +0000 (11:11 +0200)]
security_manager: Introduce metadata locking APIs

Two new APIs are added so that security driver can lock and
unlock paths it wishes to touch. These APIs are not for other
drivers to call but security drivers (DAC and SELinux). That is
the reason these APIs are not exposed through our
libvirt_private.syms file.

Three interesting things happen in this commit. The first is the
global @lockManagerMutex. Unfortunately, this has to exist so that
there is only one thread talking to virtlockd at a time. If there
were more threads and one of them closed the connection
prematurely, it would cause virtlockd killing libvirtd. Instead
of complicated code that would handle that, let's have a mutex
and keep the code simple.

The second interesting thing is keeping connection open between
lock and unlock API calls. This is achieved by duplicating client
FD and keeping it open until unlock is called. This trick is used
by regular disk content locking code when the FD is leaked to
qemu.

Finally, the third thing is polling implemented at client side.
Since virtlockd has only one thread that handles locking
requests, all it can do is either acquire lock or error out.
Therefore, the polling has to be implemented in client. The
polling is capped at 60 second timeout, which should be plenty
since the metadata lock is held only for a fraction of a second.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agosecurity_manager: Load lock plugin on init
Michal Privoznik [Wed, 5 Sep 2018 14:30:15 +0000 (16:30 +0200)]
security_manager: Load lock plugin on init

Now that we know what metadata lock manager user wishes to use we
can load it when initializing security driver. This is achieved
by adding new argument to virSecurityManagerNewDriver() and
subsequently to all functions that end up calling it.

The cfg.mk change is needed in order to allow lock_manager.h
inclusion in security driver without 'syntax-check' complaining.
This is safe thing to do as locking APIs will always exist (it's
only backend implementation that changes). However, instead of
allowing the include for all other drivers (like cpu, network,
and so on) allow it only for security driver. This will still
trigger the error if including from other drivers.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu_conf: Introduce metadata_lock_manager
Michal Privoznik [Tue, 21 Aug 2018 09:55:55 +0000 (11:55 +0200)]
qemu_conf: Introduce metadata_lock_manager

This config option allows users to set and enable lock manager
for domain metadata. The lock manager is going to be used by
security drivers to serialize each other when changing a file
ownership or changing the SELinux label. The only supported lock
manager is 'lockd' for now.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agolock_manager: Allow disabling configFile for virLockManagerPluginNew
Michal Privoznik [Tue, 21 Aug 2018 12:08:54 +0000 (14:08 +0200)]
lock_manager: Allow disabling configFile for virLockManagerPluginNew

In some cases we might want to not load the lock driver config.
Alter virLockManagerPluginNew() and the lock drivers to cope with
this fact.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agolock_driver: Introduce VIR_LOCK_MANAGER_ACQUIRE_ROLLBACK
Michal Privoznik [Fri, 7 Sep 2018 14:07:13 +0000 (16:07 +0200)]
lock_driver: Introduce VIR_LOCK_MANAGER_ACQUIRE_ROLLBACK

Soon there will be a virtlockd client that wants to either lock
all the resources or none (in order to avoid virtlockd killing
the client on connection close). Because on the RPC layer we can
only acquire one resource at a time, we have to perform a
rollback once we hit a resource that can't be acquired.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agolock_driver: Introduce VIR_LOCK_MANAGER_RESOURCE_TYPE_METADATA
Michal Privoznik [Wed, 22 Aug 2018 11:03:13 +0000 (13:03 +0200)]
lock_driver: Introduce VIR_LOCK_MANAGER_RESOURCE_TYPE_METADATA

This is a new type of object that lock drivers can handle.
Currently, it is supported by lockd driver only.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years ago_virLockManagerLockDaemonPrivate: Move @hasRWDisks into dom union
Michal Privoznik [Wed, 22 Aug 2018 08:23:36 +0000 (10:23 +0200)]
_virLockManagerLockDaemonPrivate: Move @hasRWDisks into dom union

The fact whether domain has or doesn't have RW disks is specific
to VIR_LOCK_MANAGER_OBJECT_TYPE_DOMAIN and therefore should
reside in union specific to it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agolock_driver: Introduce new VIR_LOCK_MANAGER_OBJECT_TYPE_DAEMON
Michal Privoznik [Wed, 22 Aug 2018 07:39:00 +0000 (09:39 +0200)]
lock_driver: Introduce new VIR_LOCK_MANAGER_OBJECT_TYPE_DAEMON

We will want virtlockd to lock files on behalf of libvirtd and
not qemu process, because it is libvirtd that needs an exclusive
access not qemu. This requires new lock context.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agolock_driver_lockd: Introduce VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_METADATA flag
Michal Privoznik [Wed, 22 Aug 2018 11:01:28 +0000 (13:01 +0200)]
lock_driver_lockd: Introduce VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_METADATA flag

This flag causes virtlockd to use different offset when locking
the file.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirlockspace: Allow caller to specify start and length offset in virLockSpaceAcquireR...
Michal Privoznik [Tue, 14 Aug 2018 10:25:36 +0000 (12:25 +0200)]
virlockspace: Allow caller to specify start and length offset in virLockSpaceAcquireResource

So far the virLockSpaceAcquireResource() locks the first byte in
the underlying file. But caller might want to lock other range.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoctags: Generate tags for headers, i.e. function prototypes
Erik Skultety [Tue, 18 Sep 2018 12:21:33 +0000 (14:21 +0200)]
ctags: Generate tags for headers, i.e. function prototypes

From time to time it's handy to jump directly to a function prototype in
a header. However, generating tags for headers is disabled by default in
ctags, let's enable it by using --c-kinds=+p.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agotests: Follow up on qemucaps2xmldata rename
Andrea Bolognani [Mon, 17 Sep 2018 14:51:23 +0000 (16:51 +0200)]
tests: Follow up on qemucaps2xmldata rename

The directory has been renamed in 562990849a9d, but a
reference to it was not updated at the same time, causing
'make dist' to fail ever since. Fix it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: Don't check for /dev/kvm presence
Andrea Bolognani [Fri, 14 Sep 2018 06:43:44 +0000 (08:43 +0200)]
qemu: Don't check for /dev/kvm presence

The file being present doesn't necessarily mean anything these
days, as it's created independently of whether the kvm module
has been loaded[1]; moreover, we're already gathering all the
information we need through QMP, so poking the filesystem at
all is entirely unnecessary.

[1] https://github.com/systemd/systemd/commit/d35d6249d5a7ed3228

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
6 years agoqemu: Clarify QEMU_CAPS_KVM
Andrea Bolognani [Thu, 13 Sep 2018 14:56:55 +0000 (16:56 +0200)]
qemu: Clarify QEMU_CAPS_KVM

This capability is documented as having one meaning (whether
KVM is enabled by default) but is actually assigned two other
meanings over its life: whether the query-kvm QMP command is
available at first, and later on whether KVM is usable / was
used during probing.

Since the query-kvm QMP command was available in 1.5.0, we
can avoid probing for it; additionally, we can simplify the
logic by setting the flag when it applies instead of initially
setting it and then clearing it when it doesn't.

The flag's description is also updated to reflect reality.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
6 years agoqemu: Avoid probing non-native binaries all the time
Andrea Bolognani [Mon, 17 Sep 2018 10:23:43 +0000 (12:23 +0200)]
qemu: Avoid probing non-native binaries all the time

A side effect of recent changes is that we would always try
to regenerate the capabilities cache for non-native QEMU
binaries based on /dev/kvm availability, which is of course
complete nonsense. Make sure that doesn't happen.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
6 years agoqemu: Drop QEMU_CAPS_ENABLE_KVM
Andrea Bolognani [Thu, 13 Sep 2018 15:40:51 +0000 (17:40 +0200)]
qemu: Drop QEMU_CAPS_ENABLE_KVM

It was already available in 1.5.0.

Moreover, we're not even formatting it on the QEMU command
line, ever: we just use it as part of some logic that decides
whether KVM support should be advertised, and as it turns out
that logic is actually buggy and dropping this capability
fixes it.

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

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
6 years agotests: Add more tests to qemucaps2xml
Andrea Bolognani [Thu, 13 Sep 2018 16:28:59 +0000 (18:28 +0200)]
tests: Add more tests to qemucaps2xml

More specifically, everything that's tested by qemucapabilities
now goes through qemucaps2xml as well.

Ideally we'll rewrite both so that listing all test cases is
unnecessary and they get picked up automatically by listing the
contents of the input directory instead, but that's a refactor
for another day :)

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
6 years agotests: Reuse qemucapabilities data for qemucaps2xml
Andrea Bolognani [Thu, 13 Sep 2018 16:06:20 +0000 (18:06 +0200)]
tests: Reuse qemucapabilities data for qemucaps2xml

While qemucaps2xml has a meager two test cases to its name, we
have plenty of data from qemucapabilities which is taken from
actual QEMU binaries, covers pretty much all supported QEMU
versions and architectures and is even in the right format already!

Rewrite qemucaps2xml so that it uses qemucapabilities data as
input. Right now we have a single test case, but we're going to
add a lot more next.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
6 years agosyntax-check: Check for incorrect indentation in function body
Shi Lei [Thu, 13 Sep 2018 08:55:19 +0000 (16:55 +0800)]
syntax-check: Check for incorrect indentation in function body

This patch add syntax-check rule for incorrect indentation and blank
first line in function body by changing check-spacing.pl.
For efficiency, it only checks the first line of function body.
But it's enough for most cases.

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
6 years agotools: remove blank first line in function body
Shi Lei [Thu, 13 Sep 2018 08:55:24 +0000 (16:55 +0800)]
tools: remove blank first line in function body

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
6 years agotests: remove blank first line in function body
Shi Lei [Thu, 13 Sep 2018 08:55:23 +0000 (16:55 +0800)]
tests: remove blank first line in function body

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
6 years agosrc: remove blank first line in function body
Shi Lei [Thu, 13 Sep 2018 08:55:22 +0000 (16:55 +0800)]
src: remove blank first line in function body

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
6 years agotests: fix incorrect indentation in function body by checking first line
Shi Lei [Thu, 13 Sep 2018 08:55:21 +0000 (16:55 +0800)]
tests: fix incorrect indentation in function body by checking first line

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
6 years agosrc: fix incorrect indentation in function body by checking first line
Shi Lei [Thu, 13 Sep 2018 08:55:20 +0000 (16:55 +0800)]
src: fix incorrect indentation in function body by checking first line

Signed-off-by: Shi Lei <shi_lei@massclouds.com>
6 years agoqemu_security: Run transactions more frequently
Michal Privoznik [Wed, 5 Sep 2018 12:00:20 +0000 (14:00 +0200)]
qemu_security: Run transactions more frequently

Now that committing transactions using pid == -1 means that we're
not fork()-ing to run the transaction in a specific namespace, we
can utilize the transaction processing semantics in order to
start, run a or multiple commands, and then commit the
transaction without being concerned with other interactions or
transactions interrupting the processing.  This will eventually
allow us to have a single place where all the paths can be
locked, followed by relabeling and unlocking again.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirSecurityManagerTransactionCommit: Accept pid == -1
Michal Privoznik [Wed, 5 Sep 2018 11:27:50 +0000 (13:27 +0200)]
virSecurityManagerTransactionCommit: Accept pid == -1

It will be desirable to run transactions more often than we
currently do. Even if the domain we're relabeling the paths for
does not run in a namespace. If that's the case, there is no need
to fork() as we are already running in the right namespace. To
differentiate whether transaction code should fork() or not the
@pid argument now accepts -1 (which means do not fork).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu_security: Require full wrappers for APIs that might touch a file
Michal Privoznik [Wed, 5 Sep 2018 09:37:00 +0000 (11:37 +0200)]
qemu_security: Require full wrappers for APIs that might touch a file

In the future, the transactions are not going to be optional and
they will be run regardless of domain using namespace to collect
list of paths to be relabeled.

To make sure there won't be an API that goes behind transaction
code back update the comment that serves as decision manual
whether an API must be fully implemented or plain #define is
sufficient.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu_security: Fully implement qemuSecurity{Set,Restore}SavedStateLabel
Michal Privoznik [Wed, 5 Sep 2018 09:29:46 +0000 (11:29 +0200)]
qemu_security: Fully implement qemuSecurity{Set,Restore}SavedStateLabel

Even though the current use of the functions does not require full
implementation with transactions (none of the callers passes a path
somewhere under /dev), it doesn't hurt either. Moreover, in
future patches the paradigm is going to shift so that any API
that touches a file is required to use transactions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu_security: Fully implement qemuSecurityDomainSetPathLabel
Michal Privoznik [Wed, 5 Sep 2018 09:19:14 +0000 (11:19 +0200)]
qemu_security: Fully implement qemuSecurityDomainSetPathLabel

Even though the current use of the function does not require full
implementation with transactions (none of the callers pass a path
somewhere under /dev), it doesn't hurt either. Moreover, in
future patches the paradigm is going to shift so that any API
that touches a file is required to use transactions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoconf: Move more PCI functions out of device_conf
Andrea Bolognani [Thu, 13 Sep 2018 14:36:25 +0000 (16:36 +0200)]
conf: Move more PCI functions out of device_conf

Functions that deal with virPCIDeviceAddress exclusively
belong to util/virpci.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agonews: Announce dropping support for Xen 4.4 and 4.5
Jim Fehlig [Tue, 27 Mar 2018 22:17:29 +0000 (16:17 -0600)]
news: Announce dropping support for Xen 4.4 and 4.5

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
6 years agolibxl: drop support for Xen < 4.6
Jim Fehlig [Tue, 27 Mar 2018 17:50:14 +0000 (11:50 -0600)]
libxl: drop support for Xen < 4.6

Currently the libxl driver claims support for Xen >= 4.4, but
Xen 4.4 and 4.5 are no longer supported upstream. Let's increase
the minimum supported Xen version to 4.6 and change the defined
LIBXL_API_VERSION to 0x040500, which is the API version defined
when Xen 4.6 was released.

Since Xen 4.6 contains a pkgconfig file, drop the now unused code
that falls back to using LIBVIRT_CHECK_LIB in the absence of
pkgconfig file. In addition, bumping the LIBXL_API_VERSION
required adjusting the calls to libxl_set_vcpuaffinity to account
for the extra parameter in the 0x040500 version of the API.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Return a virArpTablePtr when the nlmsghdr for loop is over
Lin Ma [Thu, 13 Sep 2018 07:54:24 +0000 (15:54 +0800)]
util: Return a virArpTablePtr when the nlmsghdr for loop is over

commit b00c9c39 removed the label end_of_netlink_messages and 'return
table' statement, It causes the function virArpTableGet doesn't return
a proper virArpTable pointer.

How to reproduce:
 # virsh domiflist sles12sp3
Interface  Type       Source     Model       MAC
-------------------------------------------------------
vnet0      network    default    virtio      52:54:00:cd:02:e6

 # virsh domifaddr sles12sp3 --source arp
error: Failed to query for interfaces addresses
error: An error occurred, but the cause is unknown

It seems that the "if (nh->nlmsg_type == NLMSG_DONE)" statement won't be
meted. So this patch adds 'return table' when the iterations of nlmsghdr
for loop is over.

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Chen Hanxiao <chenhanxiao@gmail.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>