]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
6 years agotests: qemuxml2argv: Fork CAPS_LATEST test cases for 'blockdev'
Peter Krempa [Thu, 10 May 2018 12:16:20 +0000 (14:16 +0200)]
tests: qemuxml2argv: Fork CAPS_LATEST test cases for 'blockdev'

The blockdev support will change existing approach to add disks to VMs
so all tests using the DO_TEST_CAPS_LATEST approach which have any disks
need to be forked so that the changes can be applied.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemu: Drop disk from hostdev-mdev tests
Peter Krempa [Mon, 23 Jul 2018 11:10:53 +0000 (13:10 +0200)]
tests: qemu: Drop disk from hostdev-mdev tests

The disk is not necessary to test the mdevs.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: monitor: Add 'nodename' argument for 'block_resize'
Peter Krempa [Tue, 7 Aug 2018 07:31:04 +0000 (09:31 +0200)]
qemu: monitor: Add 'nodename' argument for 'block_resize'

Allow referring to individual node name to resize.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: monitor: Allow using 'qdev' instead of 'device' for getting disk throttling
Peter Krempa [Wed, 25 Jul 2018 13:14:43 +0000 (15:14 +0200)]
qemu: monitor: Allow using 'qdev' instead of 'device' for getting disk throttling

The 'device' field reported by 'query-block' is empty when -blockdev is
used. Add an argument which will allow matching disk by using the qdev
id so we can use this code with -blockdev.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: monitor: Allow using 'id' instead of 'device' for 'block_set_io_throttle'
Peter Krempa [Wed, 25 Jul 2018 13:14:43 +0000 (15:14 +0200)]
qemu: monitor: Allow using 'id' instead of 'device' for 'block_set_io_throttle'

The 'device' argument matches only the legacy drive alias. For blockdev
we need to set the throttling for a QOM id and thus we'll need to use
the 'id' field.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: monitor: Reuse qemuMonitorJSONQueryBlock in qemuMonitorJSONBlockIoThrottleInfo
Peter Krempa [Wed, 25 Jul 2018 13:48:09 +0000 (15:48 +0200)]
qemu: monitor: Reuse qemuMonitorJSONQueryBlock in qemuMonitorJSONBlockIoThrottleInfo

The wrapper executes the command and does error detection so there's no
need to open-code all of those things.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: Prepare disk source in qemuDomainAttachDeviceDiskLive
Peter Krempa [Mon, 13 Aug 2018 13:17:36 +0000 (15:17 +0200)]
qemu: hotplug: Prepare disk source in qemuDomainAttachDeviceDiskLive

Move the preparation steps from qemuDomainAttachDiskGeneric up into
qemuDomainAttachDeviceDiskLive so that also media changing can use the
prepared file.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: hotplug: consolidate media change code paths
Peter Krempa [Mon, 13 Aug 2018 12:05:12 +0000 (14:05 +0200)]
qemu: hotplug: consolidate media change code paths

Use qemuDomainAttachDeviceDiskLive to change the media in
qemuDomainChangeDiskLive as the former function already does all the
necessary steps to prepare the new medium.

This also allows us to turn qemuDomainChangeEjectableMedia static.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoRevert "qemu: monitor: Add the 'query-nodes' argument for query-blockstats"
Peter Krempa [Mon, 30 Jul 2018 15:08:37 +0000 (17:08 +0200)]
Revert "qemu: monitor: Add the 'query-nodes' argument for query-blockstats"

Turns out that 'query-nodes' is not what we want and the
'query-blockstats' command was in fact buggy. Revert the new field since
it's not needed.

This reverts commit 50edca1331298bfcb2622e8fe588d493aff9ab68.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: monitor: Remove unused 'locked' property from struct qemuDomainDiskInfo
Peter Krempa [Mon, 6 Aug 2018 11:44:18 +0000 (13:44 +0200)]
qemu: monitor: Remove unused 'locked' property from struct qemuDomainDiskInfo

We don't use it for anything useful so it does not make much sense to
extract it.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: monitor: Remove unsupported function check for 'block_resize'
Peter Krempa [Tue, 7 Aug 2018 07:22:55 +0000 (09:22 +0200)]
qemu: monitor: Remove unsupported function check for 'block_resize'

QEMU supports 'block_resize' since 0.14 so we don't need to do explicit
checking. Additionally the caller did not use the different value at
all.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: Improve errors in qemuDomainBlockResize
Peter Krempa [Tue, 7 Aug 2018 07:47:53 +0000 (09:47 +0200)]
qemu: Improve errors in qemuDomainBlockResize

Remove the pointless "empty path" check and use a better error message
if the disk was not found.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: qemumonitorjson: Simplify debugging of 'blockInfo' test
Peter Krempa [Mon, 6 Aug 2018 12:35:20 +0000 (14:35 +0200)]
tests: qemumonitorjson: Simplify debugging of 'blockInfo' test

Print the differences in case when the expected data does not match.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu: process: Fix alias for disk-tray-moved event
Peter Krempa [Mon, 13 Aug 2018 14:11:49 +0000 (16:11 +0200)]
qemu: process: Fix alias for disk-tray-moved event

Currently we'd report the alias of the drive which is backing the cdrom
rather than the device itself:

 $ virsh event ds tray-change --loop
 event 'tray-change' for domain ds disk drive-ide0-0-1: opened
 event 'tray-change' for domain ds disk drive-ide0-0-1: closed

Report the disk device alias as we document in the API docs:

https://libvirt.org/html/libvirt-libvirt-domain.html#virConnectDomainEventTrayChangeCallback

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Parse guestfwd channel device info again
Michal Privoznik [Mon, 20 Aug 2018 16:37:30 +0000 (18:37 +0200)]
conf: Parse guestfwd channel device info again

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

Due to historical reasons we were not parsing device info on
guestfwd channel. Sure, it doesn't make much sense to parse
<address/> but it surely makes sense to parse its alias (which
might be an user alias).

This reverts commit 47a3dd46ead20e6fdc30bcdc1b8e707e250d33da
which fixed https://bugzilla.redhat.com/show_bug.cgi?id=1172526.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu: caps: Format SEV platform data into qemuCaps cache
Erik Skultety [Thu, 9 Aug 2018 13:27:26 +0000 (15:27 +0200)]
qemu: caps: Format SEV platform data into qemuCaps cache

Since we're not saving the platform-specific data into a cache, we're
not going to populate the structure, which in turn will cause a crash
upon calling virNodeGetSEVInfo because of a NULL pointer dereference.
Ultimately, we should start caching this data along with host-specific
capabilities like NUMA and SELinux stuff into a separate cache, but for
the time being, this is a semi-proper fix for a potential crash.

Backtrace (requires libvirtd restart to load qemu caps from cache):
    #0 qemuGetSEVInfoToParams
    #1 qemuNodeGetSEVInfo
    #2 virNodeGetSEVInfo
    #3 remoteDispatchNodeGetSevInfo
    #4 remoteDispatchNodeGetSevInfoHelper
    #5 virNetServerProgramDispatchCall
    #6 virNetServerProgramDispatch
    #7 virNetServerProcessMsg
    #8 virNetServerHandleJob
    #9 virThreadPoolWorker
    #10 virThreadHelper

https: //bugzilla.redhat.com/show_bug.cgi?id=1612009
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
Tested-by: Brijesh Singh <brijesh.singh@amd.com>
6 years agoqemu: Fix probing of AMD SEV support
Erik Skultety [Tue, 14 Aug 2018 13:54:46 +0000 (15:54 +0200)]
qemu: Fix probing of AMD SEV support

So the procedure to detect SEV support works like this:
1) we detect that sev-guest is among the QOM types and set the cap flag
2) we probe the monitor for SEV support
    - this is tricky, because QEMU with compiled SEV support will always
    report -object sev-guest and query-sev-capabilities command, that
    however doesn't mean SEV is supported
3) depending on what the monitor returned, we either keep or clear the
capability flag for SEV

Commit a349c6c21c6 added an explicit check for "GenericError" in the
monitor reply to prevent libvirtd to spam logs about missing
'query-sev-capabilities' command. At the same time though, it returned
success in this case which means that we didn't clear the capability
flag afterwards and happily formatted SEV into qemuCaps. Therefore,
adjust all the relevant callers to handle -1 on errors, 0 on SEV being
unsupported and 1 on SEV being supported.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
6 years agoqemu: Define and use a auto cleanup function with virSEVCapability
Erik Skultety [Wed, 15 Aug 2018 15:02:06 +0000 (17:02 +0200)]
qemu: Define and use a auto cleanup function with virSEVCapability

Keep with the recent effort of replacing as many explicit *Free
functions with their automatic equivalents.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
6 years agotests: sev: Test launch-security with specific QEMU version
Erik Skultety [Wed, 15 Aug 2018 12:00:23 +0000 (14:00 +0200)]
tests: sev: Test launch-security with specific QEMU version

In order to test SEV we need real QEMU capabilities. Ideally, this would
be tested with -latest capabilities, however, our capabilities are
currently tied to Intel HW, even the 2.12.0 containing SEV were edited by
hand, so we can only use that one for now, as splitting the capabilities
according to the vendor is a refactor for another day. The need for real
capabilities comes from the extended SEV platform data (PDH, cbitpos,
etc.) we'll need to cache/parse.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
6 years agoqemu: hotplug: Fix asynchronous unplug of 'shmem'
Peter Krempa [Fri, 17 Aug 2018 07:11:34 +0000 (09:11 +0200)]
qemu: hotplug: Fix asynchronous unplug of 'shmem'

commit 5c81c342a7 forgot to skip the detaching of the shmem backend
when async unplug is requested which meant that we've tried to unplug
the backend prior to delivery of the DEVICE_DELETED event.

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

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
6 years agoconf: qemu: add support for Hyper-V PV TLB flush
Vitaly Kuznetsov [Thu, 9 Aug 2018 13:14:21 +0000 (15:14 +0200)]
conf: qemu: add support for Hyper-V PV TLB flush

Qemu-3.0 supports Hyper-V-style PV TLB flush, Windows guests can benefit
from this feature as KVM knows which vCPUs are not currently scheduled (and
thus don't require any immediate action).

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoconf: qemu: add support for Hyper-V reenlightenment notifications
Vitaly Kuznetsov [Thu, 9 Aug 2018 13:14:20 +0000 (15:14 +0200)]
conf: qemu: add support for Hyper-V reenlightenment notifications

Qemu-3.0 supports so-called 'Reenlightenment' notifications and this (in
conjunction with 'hv-frequencies') can be used make Hyper-V on KVM pass
stable TSC page clocksource to L2 guests.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoconf: qemu: add support for Hyper-V frequency MSRs
Vitaly Kuznetsov [Thu, 9 Aug 2018 13:14:19 +0000 (15:14 +0200)]
conf: qemu: add support for Hyper-V frequency MSRs

Qemu-2.12 gained 'hv-frequencies' cpu flag to enable Hyper-V frequency
MSRs. These MSRs are required (but not sufficient) to make Hyper-V on
KVM pass stable TSC page clocksource to L2 guests.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agospec: Add firmware/nvram paths for edk2 arm and ia32
Cole Robinson [Wed, 15 Aug 2018 21:27:02 +0000 (17:27 -0400)]
spec: Add firmware/nvram paths for edk2 arm and ia32

Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agospec: Change nvram comments to reference edk2 package names
Cole Robinson [Wed, 15 Aug 2018 21:25:08 +0000 (17:25 -0400)]
spec: Change nvram comments to reference edk2 package names

Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu_command: Fix memleak in qemuBuildFloppyCommandLineControllerOptions
Michal Privoznik [Thu, 16 Aug 2018 10:19:26 +0000 (12:19 +0200)]
qemu_command: Fix memleak in qemuBuildFloppyCommandLineControllerOptions

There are some path where the buffer is not passed to
virCommandAddArgBuffer and therefore the buffer might leak.

==191201== 1,010 bytes in 1 blocks are definitely lost in loss record 826 of 836
==191201==    at 0x4C2CE3F: malloc (vg_replace_malloc.c:298)
==191201==    by 0x4C2F1BF: realloc (vg_replace_malloc.c:785)
==191201==    by 0x5D39E82: virReallocN (viralloc.c:245)
==191201==    by 0x5D3E8F2: virBufferGrow (virbuffer.c:150)
==191201==    by 0x5D3E9C8: virBufferAdd (virbuffer.c:185)
==191201==    by 0x56EAC98: qemuBuildFloppyCommandLineControllerOptions (qemu_command.c:2162)
==191201==    by 0x56EB3E1: qemuBuildDisksCommandLine (qemu_command.c:2370)
==191201==    by 0x570055E: qemuBuildCommandLine (qemu_command.c:10315)
==191201==    by 0x575EA7F: qemuProcessCreatePretendCmd (qemu_process.c:6777)
==191201==    by 0x113DAB: testCompareXMLToArgv (qemuxml2argvtest.c:598)
==191201==    by 0x13A75B: virTestRun (testutils.c:180)
==191201==    by 0x138BE8: mymain (qemuxml2argvtest.c:2975)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoapparmor: allow to preserve /dev mountpoints into qemu namespaces
Christian Ehrhardt [Mon, 13 Aug 2018 14:26:15 +0000 (16:26 +0200)]
apparmor: allow to preserve /dev mountpoints into qemu namespaces

Libvirt now tries to preserve all mounts under /dev in qemu namespaces.
The old rules only listed a set of known paths but those are no more enough.

I found some due to containers like /dev/.lxc/* and such but also /dev/console
and /dev/net/tun.

Libvirt is correct to do so, but we can no more predict the names properly, so
we modify the rule to allow a wildcard based pattern matching what libvirt does.

Acked-by: Jamie Strandboge <jamie@canonical.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
6 years agoapparmor: allow expected /tmp access patterns
Christian Ehrhardt [Tue, 14 Aug 2018 05:51:35 +0000 (07:51 +0200)]
apparmor: allow expected /tmp access patterns

Several cases were found needing /tmp, for example ceph will try to list /tmp
This is a compromise of security and usability:
 - we only allow generally enumerating the base dir
 - enumerating anything deeper in the dir is at least guarded by the
   "owner" restriction, but while that protects files of other services
   it won't protect qemu instances against each other as they usually run
   with the same user.
 - even with the owner restriction we only allow read for the wildcard
   path

Acked-by: Jamie Strandboge <jamie@canonical.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
6 years agoapparmor: add mediation rules for unconfined guests
Christian Ehrhardt [Mon, 13 Aug 2018 14:06:04 +0000 (16:06 +0200)]
apparmor: add mediation rules for unconfined guests

If a guest runs unconfined <seclabel type='none'>, but libvirtd is
confined then the peer for signal can only be detected as
'unconfined'. That triggers issues like:
   apparmor="DENIED" operation="signal"
   profile="/usr/sbin/libvirtd" pid=22395 comm="libvirtd"
   requested_mask="send" denied_mask="send" signal=term peer="unconfined"

To fix this add unconfined as an allowed peer for those operations.

I discussed with the apparmor folks, right now there is no better
separation to be made in this case. But there might be further down the
road with "policy namespaces with scope and view control + stacking"

This is more a use-case addition than a fix to the following two changes:
3b1d19e6 AppArmor: add rules needed with additional mediation features
b482925c apparmor: support ptrace checks

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Acked-by: Jamie Strandboge <jamie@canonical.com>
Acked-by: intrigeri <intrigeri+libvirt@boum.org>
6 years agoapparmor: allow openGraphicsFD for virt manager >1.4
Christian Ehrhardt [Mon, 13 Aug 2018 13:58:06 +0000 (15:58 +0200)]
apparmor: allow openGraphicsFD for virt manager >1.4

virt-manager's UI connection will need socket access for openGraphicsFD
to work - otherwise users will face a failed connection error when
opening the UI view.

Depending on the exact versions of libvirt and qemu involved this needs
either a rule from qemu to libvirt or vice versa.

Acked-by: Jamie Strandboge <jamie@canonical.com>
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
6 years agorpc: Don't overwrite virAuthGet{Username|Password}Path errors
John Ferlan [Tue, 14 Aug 2018 14:33:26 +0000 (10:33 -0400)]
rpc: Don't overwrite virAuthGet{Username|Password}Path errors

Now that the virAuthGet*Path API's generate all the error messages
we can remove them from the callers.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
6 years agotest: Don't overwrite virAuthGet{Username|Password} errors
John Ferlan [Tue, 14 Aug 2018 14:30:48 +0000 (10:30 -0400)]
test: Don't overwrite virAuthGet{Username|Password} errors

Now that the virAuthGet*Path API's generate all the error messages
we can remove them from the callers.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
6 years agoxenapi: Don't overwrite virAuthGet{Username|Password} errors
John Ferlan [Tue, 14 Aug 2018 16:32:45 +0000 (12:32 -0400)]
xenapi: Don't overwrite virAuthGet{Username|Password} errors

Now that the virAuthGet*Path API's generate all the error messages
we can remove them from the callers. This means that we will no
longer overwrite the error from the API.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
6 years agophyp: Don't overwrite virAuthGet{Username|Password} errors
John Ferlan [Tue, 14 Aug 2018 16:32:22 +0000 (12:32 -0400)]
phyp: Don't overwrite virAuthGet{Username|Password} errors

Now that the virAuthGet*Path API's generate all the error messages
we can remove them from the callers. This means that we will no
longer overwrite the error from the API.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
6 years agohyperv: Don't overwrite virAuthGet{Username|Password} errors
John Ferlan [Tue, 14 Aug 2018 16:31:52 +0000 (12:31 -0400)]
hyperv: Don't overwrite virAuthGet{Username|Password} errors

Now that the virAuthGet*Path API's generate all the error messages
we can remove them from the callers. This means that we will no
longer overwrite the error from the API.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
6 years agoesx: Don't overwrite virAuthGet{Username|Password} errors
John Ferlan [Tue, 14 Aug 2018 16:30:02 +0000 (12:30 -0400)]
esx: Don't overwrite virAuthGet{Username|Password} errors

Now that the virAuthGet*Path API's generate all the error messages
we can remove them from the callers. This means that we will no
longer overwrite the error from the API.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
6 years agoutil: Alter virAuthGet*Path API to generate auth->cb error
John Ferlan [Tue, 14 Aug 2018 14:14:22 +0000 (10:14 -0400)]
util: Alter virAuthGet*Path API to generate auth->cb error

Rather than forcing the caller to generate an error, let's
generate the Username or Password error message failure if
the auth->cb fails. This is the last error path that needs
a specific message for various callers.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
6 years agoutil: Alter virAuthGet*Path API return processing
John Ferlan [Tue, 14 Aug 2018 14:11:50 +0000 (10:11 -0400)]
util: Alter virAuthGet*Path API return processing

If we never find the valid credtype in the list, then we'd return
NULL without an error signaled forcing the caller to generate one
that will probably be incorrect. Let's be specific.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
6 years agoutil: Remove invalid parameter checks from virAuthGet{Username|Password}
John Ferlan [Tue, 14 Aug 2018 16:34:43 +0000 (12:34 -0400)]
util: Remove invalid parameter checks from virAuthGet{Username|Password}

Now that the virAuthGet*Path helpers make the checks, we can remove
them from here.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
6 years agoutil: Alter virAuthGet*Path API to check valid callback
John Ferlan [Tue, 14 Aug 2018 14:05:33 +0000 (10:05 -0400)]
util: Alter virAuthGet*Path API to check valid callback

Before trying to call @auth->cb, let's ensure it exists.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
6 years agoutil: Alter virAuthGet*Path API to check valid parameters
John Ferlan [Tue, 14 Aug 2018 14:03:10 +0000 (10:03 -0400)]
util: Alter virAuthGet*Path API to check valid parameters

Before trying to dereference @auth, let's ensure it's valid.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
6 years agostorage: Properly terminate secrets
Michal Privoznik [Mon, 13 Aug 2018 08:35:37 +0000 (10:35 +0200)]
storage: Properly terminate secrets

The virSecretGetSecretString() helper looks up a secret for given
pool and returns its value in @secret_value and its length in
@secret_value_size. However, the trailing '\0' is not included in
either of the variables. This is because usually the value of the
secret is passed to some encoder (usually base64 encoder) where
the trailing zero must not be accounted for.

However, in two places we actually want the string as we don't
process it any further.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agovirtestmock: Track action
Michal Privoznik [Sun, 8 Jul 2018 07:32:03 +0000 (09:32 +0200)]
virtestmock: Track action

As advertised in the previous commit, we need the list of
accessed files to also contain action that caused the $path to
appear on the list. Not only this enables us to fine tune our
white list rules it also helps us to see why $path is reported.
For instance:

  /run/user/1000/libvirt/libvirt-sock: connect: qemuxml2argvtest: QEMU XML-2-ARGV net-vhostuser-multiq

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agocheck-file-access: Allow specifying action
Michal Privoznik [Mon, 9 Jul 2018 08:53:17 +0000 (10:53 +0200)]
check-file-access: Allow specifying action

The check-file-access.pl script is used to match access list
generated by virtestmock against whitelisted rules stored in
file_access_whitelist.txt. So far the rules are in form:

  $path: $progname: $testname

This is not sufficient because the rule does not take into
account 'action' that caused $path to appear in the list of
accessed files. After this commit the rule can be in new form:

  $path: $action: $progname: $testname

where $action is one from ("open", "fopen", "access", "stat",
"lstat", "connect"). This way the white list can be fine tuned to
allow say access() but not connect().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemuxml2argvtest: Set more fake drivers
Michal Privoznik [Thu, 12 Jul 2018 07:08:04 +0000 (09:08 +0200)]
qemuxml2argvtest: Set more fake drivers

So far we are setting only fake secret and storage drivers.
Therefore if the code wants to call a public NWFilter API (like
qemuBuildInterfaceCommandLine() and qemuBuildNetCommandLine() are
doing) the virGetConnectNWFilter() function will try to actually
spawn session daemon because there's no connection object set to
handle NWFilter driver.

Even though I haven't experienced the same problem with the rest
of the drivers (interface, network and node dev), the reasoning
above can be applied to them as well.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agotests: qemucapabilities: Update capability data for qemu 3.0.0
Peter Krempa [Mon, 30 Jul 2018 14:49:40 +0000 (16:49 +0200)]
tests: qemucapabilities: Update capability data for qemu 3.0.0

Update for the release of qemu 3.0.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agonews: Add support for MBA (Memory Bandwidth Allocation)
Bing Niu [Tue, 14 Aug 2018 05:05:29 +0000 (13:05 +0800)]
news: Add support for MBA (Memory Bandwidth Allocation)

Signed-off-by: Bing Niu <bing.niu@intel.com>
6 years agorpc: Initialize a worker pool for max_workers=0 as well
Marc Hartmayer [Tue, 7 Aug 2018 11:38:00 +0000 (13:38 +0200)]
rpc: Initialize a worker pool for max_workers=0 as well

Semantically, there is no difference between an uninitialized worker
pool and an initialized worker pool with zero workers. Let's allow the
worker pool to be initialized for max_workers=0 as well then which
makes the API more symmetric and simplifies code. Validity of the
worker pool is delegated to virThreadPoolGetMaxWorkers instead.

This patch fixes segmentation faults in
virNetServerGetThreadPoolParameters and
virNetServerSetThreadPoolParameters for the case when no worker pool
is actually initialized (max_workers=0).

Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
6 years agoxenapi: Drop check for auth
Marcos Paulo de Souza [Fri, 3 Aug 2018 00:27:55 +0000 (21:27 -0300)]
xenapi: Drop check for auth

Since they are done inside virAuthGetPassword and virAuthGetUsername
when needed. Also, only auth is checked, but auth->cb, which that could
lead to a crash if the callback is NULL.

Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
6 years agophyp: Drop check for auth and auth->cb
Marcos Paulo de Souza [Fri, 3 Aug 2018 00:27:54 +0000 (21:27 -0300)]
phyp: Drop check for auth and auth->cb

Since they are done inside virAuthGetPassword and virAuthGetUsername
when needed.

Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
6 years agohyperv: Drop check for auth and auth->cb
Marcos Paulo de Souza [Fri, 3 Aug 2018 00:27:53 +0000 (21:27 -0300)]
hyperv: Drop check for auth and auth->cb

Since they are done inside virAuthGetPassword and virAuthGetUsername
when needed.

Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
6 years agoesx: Drop check for auth and auth->cb
Marcos Paulo de Souza [Fri, 3 Aug 2018 00:27:52 +0000 (21:27 -0300)]
esx: Drop check for auth and auth->cb

Since they are done inside virAuthGetPassword and virAuthGetUsername
when needed.

Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
6 years agovirauth.c: Check for valid auth callback
Marcos Paulo de Souza [Fri, 3 Aug 2018 00:27:51 +0000 (21:27 -0300)]
virauth.c: Check for valid auth callback

Instead of adding the same check for every drivers, execute the checks
in virAuthGetUsername and virAuthGetPassword. These funtions are called
when user is not set in the URI.

Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
6 years agolibvirt_iohelper: record the libvirt_iohelper's error message at virFileWrapperFdFree
xinhua.Cao [Mon, 23 Jul 2018 12:22:41 +0000 (20:22 +0800)]
libvirt_iohelper: record the libvirt_iohelper's error message at virFileWrapperFdFree

Currently iohelper's error log is recorded in virFileWrapperFdClose.
However, if something goes wrong the caller might not even get to
calling virFileWrapperFdClose and call virFileWrapperFdFree
directly. Therefore the error reporting should happen there.

Signed-off-by: xinhua.Cao <caoxinhua@huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agotests: Add linux-high-ids test
Andrea Bolognani [Thu, 2 Aug 2018 15:24:48 +0000 (17:24 +0200)]
tests: Add linux-high-ids test

This proves libvirt can now handle high socket_id and
core_id values correctly and ensures we won't introduce
regressions in this area.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agoutils: Remove arbitrary limit on socket_id/core_id
Andrea Bolognani [Fri, 3 Aug 2018 08:15:16 +0000 (10:15 +0200)]
utils: Remove arbitrary limit on socket_id/core_id

While in most cases the values are going to be much
smaller than our arbitrary 4096 limit, there is really
no guarantee that would be the case: in fact, a few
aarch64 servers have been spotted in the wild with
core_id as high as 6216.

Take advantage of virBitmap's ability to automatically
alter its size at runtime to accomodate such values.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agotests: Drop core_siblings/thread_siblings files
Andrea Bolognani [Thu, 2 Aug 2018 14:20:41 +0000 (16:20 +0200)]
tests: Drop core_siblings/thread_siblings files

The latter are no longer used by libvirt, and the former
never were; moreover, both have a corresponding *_list
file which we can manipulate very conveniently using our
bitmap APIs, so dropping them makes sure in the future
developers will look into that rather than trying to
parse the kernel binary bitmaps.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agoutil: Rewrite virHostCPUCountThreadSiblings()
Andrea Bolognani [Thu, 2 Aug 2018 14:15:02 +0000 (16:15 +0200)]
util: Rewrite virHostCPUCountThreadSiblings()

We already have a function which parses
thread_siblings_list for a CPU and returns the
corresponding bitmap, and a bunch of utility functions
that perform operations on bitmaps such as counting
the number of set bits: use those to implement the
function instead of having an additional ad-hoc parser
for thread_siblings.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agotests: Add missing thread_siblings_list files
Andrea Bolognani [Thu, 2 Aug 2018 13:45:07 +0000 (15:45 +0200)]
tests: Add missing thread_siblings_list files

Some of the data dumps didn't include them; luckily,
we're not actually missing any information since we
can recreate them by looking at the corresponding
thread_sibilings files.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agotests: Drop unused data
Andrea Bolognani [Thu, 2 Aug 2018 16:09:04 +0000 (18:09 +0200)]
tests: Drop unused data

Added by mistake with commit a0fdd2f6f9a0.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agoutil: Drop VIR_HOST_CPU_MASK_LEN
Andrea Bolognani [Wed, 1 Aug 2018 08:32:50 +0000 (10:32 +0200)]
util: Drop VIR_HOST_CPU_MASK_LEN

Unused since commit c67e04e25fa5.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agospec: Enable the iscsi-direct storage driver conditionally
Andrea Bolognani [Tue, 14 Aug 2018 12:31:35 +0000 (14:31 +0200)]
spec: Enable the iscsi-direct storage driver conditionally

Most distributions we build RPMs on don't ship a
recent enough version of libiscsi, so we can't enable
the driver unconditionally. Add an explicit dependency
on the runtime package while at it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6 years agospec: Require libiscsi-devel instead of libiscsi
Andrea Bolognani [Tue, 14 Aug 2018 11:39:51 +0000 (13:39 +0200)]
spec: Require libiscsi-devel instead of libiscsi

Commit 34a6962c41b4 added a BuildRequires for the
iscsi-direct backend, but we need the headers rather
than the runtime package to be available in order to
link against the library.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agovirsh: Add missed fields to pool-define-as item entry
John Ferlan [Mon, 13 Aug 2018 12:19:30 +0000 (08:19 -0400)]
virsh: Add missed fields to pool-define-as item entry

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

Commit id d45bee449 updated the pool-define-as qualifier descriptions
to add some new fields, but neglected to modify the command item list
in order to add those fields as well.

Signed-off-by: John Ferlan <jferlan@redhat.com>
6 years agoFix build on non-linux platforms after another VIR_AUTOPTR patches
Erik Skultety [Tue, 14 Aug 2018 10:08:51 +0000 (12:08 +0200)]
Fix build on non-linux platforms after another VIR_AUTOPTR patches

Caused by commit f7d0663d49. The problem is missing libnl library on
these platforms, so the VIR_DEFINE_AUTOPTR_FUNC has to be compiled in
conditionally.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
6 years agoconf: rename Match functions
Anya Harter [Mon, 13 Aug 2018 15:55:16 +0000 (11:55 -0400)]
conf: rename Match functions

name match functions to be the vir prefix and interface name followed by ObjMatch

    ex. for virNetworkObjListExport, the match function is named
        virNetworkObjMatch

Signed-off-by: Anya Harter <aharter@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoconf: rename Export Callback functions
Anya Harter [Mon, 13 Aug 2018 15:55:15 +0000 (11:55 -0400)]
conf: rename Export Callback functions

name functions to be the name of the export function followed by Callback

    ex. for virInterfaceObjListExport, the callback function is named
        virInterfaceObjListExportCallback

Signed-off-by: Anya Harter <aharter@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoconf: rename structs used by Export function
Anya Harter [Mon, 13 Aug 2018 15:55:14 +0000 (11:55 -0400)]
conf: rename structs used by Export function

name structs to be the name of the Export function followed by Data
also tweak definitions to follow standard struct definition pattern

    ex. for virInterfaceObjListExport, the struct is defined as follows:

        typedef struct _virInterfaceObjListExportData virInterfaceObjListExportData;
        typedef virInterfaceObjListExportData *virInterfaceObjListExportDataPtr;
        struct _virInterfaceObjListExportData {...};

Signed-off-by: Anya Harter <aharter@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoesx: Fix build when libcurl debug is enabled
Marcos Paulo de Souza [Sat, 11 Aug 2018 14:39:29 +0000 (11:39 -0300)]
esx: Fix build when libcurl debug is enabled

When building libvirt with libcurl debug enabled (with
ESX_VI__CURL__ENABLE_DEBUG_OUTPUT set), the message bellow pops up:

make[3]: Entering directory '/mnt/data/gitroot/libvirt/src'
  CC       esx/libvirt_driver_esx_la-esx_vi.lo
esx/esx_vi.c: In function 'esxVI_CURL_Debug':
esx/esx_vi.c:191:5: error: enumeration value 'CURLINFO_SSL_DATA_IN' not handled in switch [-Werror=switch-enum]
     switch (type) {
     ^~~~~~
esx/esx_vi.c:191:5: error: enumeration value 'CURLINFO_SSL_DATA_OUT' not handled in switch [-Werror=switch-enum]
esx/esx_vi.c:191:5: error: enumeration value 'CURLINFO_END' not handled in switch [-Werror=switch-enum]

Our build requires at least libcurl 7.18.0, which is pretty stable since
it was release in 2008. Fix this problem by handling the mentioned enums
in the code.

Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoconf: Add memory bandwidth allocation capability of host
Bing Niu [Mon, 30 Jul 2018 03:12:41 +0000 (11:12 +0800)]
conf: Add memory bandwidth allocation capability of host

Add new XML section to report host's memory bandwidth allocation
capability. The format as below example:

 <host>
 .....
   <memory_bandwidth>
     <node id='0' cpus='0-19'>
       <control granularity='10' min ='10' maxAllocs='8'/>
     </node>
   </memory_bandwidth>
</host>

granularity   ---- granularity of memory bandwidth, unit percentage.
min           ---- minimum memory bandwidth allowed, unit percentage.
maxAllocs     ---- maximum memory bandwidth allocation group supported.

Signed-off-by: Bing Niu <bing.niu@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoconf: Add return value check to virResctrlAllocForeachCache
Bing Niu [Mon, 30 Jul 2018 03:12:40 +0000 (11:12 +0800)]
conf: Add return value check to virResctrlAllocForeachCache

Add return value check to virResctrlAllocForeachCache in
virDomainCachetuneDefFormat. The virResctrlAllocForeachCache does have
return value, so need check return value to make sure function executed
without error.

Signed-off-by: Bing Niu <bing.niu@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoconf: Add support for memorytune XML processing for resctrl MBA
Bing Niu [Mon, 30 Jul 2018 03:12:39 +0000 (11:12 +0800)]
conf: Add support for memorytune XML processing for resctrl MBA

Introduce a new section memorytune to support memory bandwidth allocation.
This is consistent with existing cachetune. As the example:
below:
  <cputune>
    ......
    <memorytune vcpus='0'>
      <node id='0' bandwidth='30'/>
    </memorytune>
  </cputune>

vpus      --- vpus subjected to this memory bandwidth.
id        --- on which node memory bandwidth to be set.
bandwidth --- the memory bandwidth percent to set.

Signed-off-by: Bing Niu <bing.niu@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoconf: Factor out virDomainResctrlDef update from virDomainCachetuneDefParse
Bing Niu [Mon, 30 Jul 2018 03:12:38 +0000 (11:12 +0800)]
conf: Factor out virDomainResctrlDef update from virDomainCachetuneDefParse

Factor out vcpus virDomainResctrlDef update from
virDomainCachetuneDefParse and introduce virDomainResctrlAppend.
virDomainResctrlAppend will format vcpus string and append a new
virDomainResctrlDef to virDomainDefPtr. So that this logic can
be reusable.

Signed-off-by: Bing Niu <bing.niu@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoconf: Factor out vcpus overlapping from virDomainCachetuneDefParse
Bing Niu [Mon, 30 Jul 2018 03:12:37 +0000 (11:12 +0800)]
conf: Factor out vcpus overlapping from virDomainCachetuneDefParse

Factor out vcpus overlapping detecting part from
virDomainCachetuneDefParse and introduce virDomainResctrlVcpuMatch.
Instead of allocating virResctrlAllocPtr by default, allocating
virResctrlAllocPtr after confirm vcpus not overlap with existing ones.
And virDomainResctrlVcpuMatch can be reused by other resource control
technologies. virDomainResctrlVcpuMatch can clarify old vcpus overlap
error whether an overlap or a redefinition.

Signed-off-by: Bing Niu <bing.niu@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoconf: Factor out vcpus parsing part from virDomainCachetuneDefParse
Bing Niu [Mon, 30 Jul 2018 03:12:36 +0000 (11:12 +0800)]
conf: Factor out vcpus parsing part from virDomainCachetuneDefParse

Extract vcpus parsing part from virDomainCachetuneDefParse into one
function called virDomainResctrlParseVcpus. So that vcpus parsing logic
can be reused by other resource control technologies. Adjust error
message and use node->name so that the error message can fit to all
technologies.

Signed-off-by: Bing Niu <bing.niu@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoconf: Rename cachetune to resctrl
Bing Niu [Mon, 30 Jul 2018 03:12:35 +0000 (11:12 +0800)]
conf: Rename cachetune to resctrl

Resctrl not only supports cache tuning, but also memory bandwidth
tuning. Renaming cachetune to resctrl to reflect that. With resctrl,
all allocation for different resources (cache, memory bandwidth) are
aggregated and represented by a virResctrlAllocPtr inside
virDomainResctrlDef.

Signed-off-by: Bing Niu <bing.niu@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Introduce virResctrlAllocSetMemoryBandwidth
Bing Niu [Mon, 30 Jul 2018 03:12:34 +0000 (11:12 +0800)]
util: Introduce virResctrlAllocSetMemoryBandwidth

Introduce an API to allow setting of the MBA from domain XML.

Signed-off-by: Bing Niu <bing.niu@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Introduce virResctrlAllocForeachMemory
Bing Niu [Mon, 30 Jul 2018 03:12:33 +0000 (11:12 +0800)]
util: Introduce virResctrlAllocForeachMemory

Introduce an API that will traverse the memory bandwidth data calling
a callback function for each defined bandwidth entry.

Signed-off-by: Bing Niu <bing.niu@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Add support to calculate MBA utilization
Bing Niu [Mon, 30 Jul 2018 03:12:32 +0000 (11:12 +0800)]
util: Add support to calculate MBA utilization

Introduce virResctrlMemoryBandwidthSubtract and
virResctrlAllocMemoryBandwidth to be used as part of
the virResctrlAllocAssign processing to configure
the available memory bandwidth.

Signed-off-by: Bing Niu <bing.niu@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Add MBA schemata parse and format methods
Bing Niu [Mon, 30 Jul 2018 03:12:31 +0000 (11:12 +0800)]
util: Add MBA schemata parse and format methods

Introduce virResctrlAllocMemoryBandwidthFormat and
virResctrlAllocParseMemoryBandwidthLine which will format
and parse an entry in the schemata file for MBA.

Signed-off-by: Bing Niu <bing.niu@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Add MBA allocation to virresctrl
Bing Niu [Mon, 30 Jul 2018 03:12:30 +0000 (11:12 +0800)]
util: Add MBA allocation to virresctrl

Add memory bandwidth allocation support to virresctrl class.
Introducing virResctrlAllocMemBW which is used for allocating memory
bandwidth. Following virResctrlAllocPerType, it also employs a
nested sparse array to indicate whether allocation is available for
particular last level cache.

Signed-off-by: Bing Niu <bing.niu@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Add MBA check to virResctrlInfoGetCache
Bing Niu [Mon, 30 Jul 2018 03:12:29 +0000 (11:12 +0800)]
util: Add MBA check to virResctrlInfoGetCache

If we have some membw_info data, then we need to calculate the number
of MBA controllers on the system. The value cannot be obtained from a
direct query to the RDT kernel module, but it is the same as the last
level cache value which is calculated by traversing the cache hierarchy
of host(/sys/bus/cpu/devices/cpuX/cache/).

Signed-off-by: Bing Niu <bing.niu@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Add MBA capability information query to resctrl
Bing Niu [Mon, 30 Jul 2018 03:12:28 +0000 (11:12 +0800)]
util: Add MBA capability information query to resctrl

Introducing virResctrlInfoMemBW for the information memory bandwidth
allocation information.

Signed-off-by: Bing Niu <bing.niu@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Refactor virResctrlAllocFormat of virresctrl
Bing Niu [Mon, 30 Jul 2018 03:12:27 +0000 (11:12 +0800)]
util: Refactor virResctrlAllocFormat of virresctrl

Refactor virResctrlAllocFormat so that it is easy to support other
resource allocation technologies.

Signed-off-by: Bing Niu <bing.niu@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Refactor virResctrlGetInfo in virresctrl
Bing Niu [Mon, 30 Jul 2018 03:12:26 +0000 (11:12 +0800)]
util: Refactor virResctrlGetInfo in virresctrl

Separate resctrl common information parts from CAT specific parts,
so that common information parts can be reused among different
resource allocation technologies.

Signed-off-by: Bing Niu <bing.niu@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Rename some functions of virresctrl
Bing Niu [Mon, 30 Jul 2018 03:12:25 +0000 (11:12 +0800)]
util: Rename some functions of virresctrl

Some functions in virresctrl are for CAT only, while some of other
functions are for resource allocation, not just CAT. So change
their names to reflect the reality.

Signed-off-by: Bing Niu <bing.niu@intel.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: netdevopenvswitch: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Thu, 9 Aug 2018 04:12:18 +0000 (09:42 +0530)]
util: netdevopenvswitch: use VIR_AUTOPTR for aggregate types

By making use of GNU C's cleanup attribute handled by the
VIR_AUTOPTR macro for declaring aggregate pointer variables,
majority of the calls to *Free functions can be dropped, which
in turn leads to getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: netdevip: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Thu, 9 Aug 2018 04:12:17 +0000 (09:42 +0530)]
util: netdevip: use VIR_AUTOPTR for aggregate types

By making use of GNU C's cleanup attribute handled by the
VIR_AUTOPTR macro for declaring aggregate pointer variables,
majority of the calls to *Free functions can be dropped, which
in turn leads to getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: netdevbridge: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Thu, 9 Aug 2018 04:12:14 +0000 (09:42 +0530)]
util: netdevbridge: use VIR_AUTOPTR for aggregate types

By making use of GNU C's cleanup attribute handled by the
VIR_AUTOPTR macro for declaring aggregate pointer variables,
majority of the calls to *Free functions can be dropped, which
in turn leads to getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: netdevbridge: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Thu, 9 Aug 2018 04:12:13 +0000 (09:42 +0530)]
util: netdevbridge: use VIR_AUTOFREE instead of VIR_FREE for scalar types

By making use of GNU C's cleanup attribute handled by the
VIR_AUTOFREE macro for declaring scalar variables, majority
of the VIR_FREE calls can be dropped, which in turn leads to
getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: netlink: use VIR_AUTOPTR for aggregate types
Sukrit Bhatnagar [Thu, 9 Aug 2018 04:12:12 +0000 (09:42 +0530)]
util: netlink: use VIR_AUTOPTR for aggregate types

By making use of GNU C's cleanup attribute handled by the
VIR_AUTOPTR macro for declaring aggregate pointer variables,
majority of the calls to *Free functions can be dropped, which
in turn leads to getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: netlink: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Thu, 9 Aug 2018 04:12:11 +0000 (09:42 +0530)]
util: netlink: use VIR_AUTOFREE instead of VIR_FREE for scalar types

By making use of GNU C's cleanup attribute handled by the
VIR_AUTOFREE macro for declaring scalar variables, majority
of the VIR_FREE calls can be dropped, which in turn leads to
getting rid of most of our cleanup sections.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: netlink: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC
Sukrit Bhatnagar [Thu, 9 Aug 2018 04:12:10 +0000 (09:42 +0530)]
util: netlink: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC

Using the new VIR_DEFINE_AUTOPTR_FUNC macro defined in
src/util/viralloc.h, define a new wrapper around an existing
cleanup function which will be called when a variable declared
with VIR_AUTOPTR macro goes out of scope. Also, drop the redundant
viralloc.h include, since that has moved from the source module into
the header.

This commit also typedefs virNetlinkMsg to struct nl_msg type for use
with the cleanup macros.

When a variable of type virNetlinkMsg * is declared using VIR_AUTOPTR,
the function nlmsg_free will be run automatically on it when it
goes out of scope.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: iscsi: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Sukrit Bhatnagar [Thu, 9 Aug 2018 04:12:09 +0000 (09:42 +0530)]
util: iscsi: use VIR_AUTOFREE instead of VIR_FREE for scalar types

Add another usage for VIR_AUTOFREE macro which was left in the
commit ec3e878, thereby dropping a VIR_FREE call and and a cleanup
section.

Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agospec: Add libvirt-daemon-driver-storage-iscsi-direct
Cole Robinson [Wed, 8 Aug 2018 23:43:25 +0000 (19:43 -0400)]
spec: Add libvirt-daemon-driver-storage-iscsi-direct

Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu: Prefer nvdimmPath over hugepages for memory-backend-file
Michal Privoznik [Thu, 9 Aug 2018 14:29:17 +0000 (16:29 +0200)]
qemu: Prefer nvdimmPath over hugepages for memory-backend-file

If a domain has hugepages configured and we're currently building
memory-backend-file for a nvdimm device that domain has we will
put hugepages path onto the command line. It should have been
nvdimm path configured in the XML.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovircgroup: fix MinGW build
Pavel Hrdina [Mon, 13 Aug 2018 14:03:03 +0000 (16:03 +0200)]
vircgroup: fix MinGW build

Broken by commit <901d2b9c87>.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
6 years agoesx: Fix nodeGetInfo so cpu model fits inside nodeinfo->model
Marcos Paulo de Souza [Sun, 12 Aug 2018 11:05:19 +0000 (08:05 -0300)]
esx: Fix nodeGetInfo so cpu model fits inside nodeinfo->model

Commit 6c0d0210cbcd5d647f0d882c07f077d444bc707d changed the behavior of
virStr*cpy* functions, so now the nodeGetInfo call fails. Version 4.1.0
(default for Fedora 28) works:

Model: Intel Core i7-4500U CPU @ 1.80G

Current master tries to write "Intel Core i7-4500U CPU @ 1.80GHz", but
the string is bigger than nodeinfo->model (which is a char[32]). So this
patch "cuts" the string, and presents the same output from 4.1.0.

Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
6 years agoRevert "build: add --with-jansson"
Ján Tomko [Mon, 13 Aug 2018 11:41:14 +0000 (13:41 +0200)]
Revert "build: add --with-jansson"

This reverts commit 12b34f094e2f1c7f414f4bb8f880a9d65c8fcd85.

Jansson cannot parse QEMU's quirky JSON.
Revert back to yajl.

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

Conflicts:
  configure.ac:
    Commit 8aa85e0b introduced LIBVIRT_*_LIBISCSI macros.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoRevert "build: undef WITH_JANSSON for SETUID_RPC_CLIENT"
Ján Tomko [Mon, 13 Aug 2018 11:40:25 +0000 (13:40 +0200)]
Revert "build: undef WITH_JANSSON for SETUID_RPC_CLIENT"

This reverts commit 93fdc9e0b0cbb2eec32745a868ac4633f0912ad5.

Jansson cannot parse QEMU's quirky JSON.
Revert back to yajl.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>