]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
8 years agoqemu_cgroup: Kill qemuSetupHostSCSIVHostDeviceCgroup
Michal Privoznik [Thu, 9 Feb 2017 09:30:23 +0000 (10:30 +0100)]
qemu_cgroup: Kill qemuSetupHostSCSIVHostDeviceCgroup

There's no need for this function. Currently it is passed as a
callback to virSCSIVHostDeviceFileIterate(). However, SCSI host
devices have just one file path. Therefore we can mimic approach
used in qemuDomainGetHostdevPath() to get path and call
virCgroupAllowDevicePath() directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8 years agoqemu_cgroup: Kill qemuSetupHostSCSIDeviceCgroup
Michal Privoznik [Thu, 9 Feb 2017 09:25:28 +0000 (10:25 +0100)]
qemu_cgroup: Kill qemuSetupHostSCSIDeviceCgroup

There's no need for this function. Currently it is passed as a
callback to virSCSIDeviceFileIterate(). However, SCSI devices
have just one file path. Therefore we can mimic approach used in
qemuDomainGetHostdevPath() to get path and call
virCgroupAllowDevicePath() directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8 years agoqemu_cgroup: Kill qemuSetupHostUSBDeviceCgroup
Michal Privoznik [Thu, 9 Feb 2017 09:16:12 +0000 (10:16 +0100)]
qemu_cgroup: Kill qemuSetupHostUSBDeviceCgroup

There's no need for this function. Currently it is passed as a
callback to virUSBDeviceFileIterate(). However, USB devices have
just one file path. Therefore we can mimic approach used in
qemuDomainGetHostdevPath() to get path and call
virCgroupAllowDevicePath() directly.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8 years agoutil: virvhba: fix typo that breaks build on non-linux systems
Pavel Hrdina [Sun, 19 Feb 2017 14:47:27 +0000 (15:47 +0100)]
util: virvhba: fix typo that breaks build on non-linux systems

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
8 years agotests: Add createVHBAByNodeDevice-parent-fabric-wwn to fchosttest
John Ferlan [Tue, 24 Jan 2017 18:53:08 +0000 (13:53 -0500)]
tests: Add createVHBAByNodeDevice-parent-fabric-wwn to fchosttest

Add a test that allows providing the parent fabric_wwn in the input XML
in order to create the vHBA.

This also fixes a mixed setting of the fabric_wwn field from the read
test driver XML strings.

8 years agotests: Add createVHBAByNodeDevice-parent-wwn to fchosttest
John Ferlan [Tue, 24 Jan 2017 18:49:35 +0000 (13:49 -0500)]
tests: Add createVHBAByNodeDevice-parent-wwn to fchosttest

Add a test that allows providing the parent wwnn/wwpn in the input XML
in order to create the vHBA.

8 years agotests: Add createVHBAByNodeDevice-no-parent to fchosttest
John Ferlan [Tue, 24 Jan 2017 18:45:48 +0000 (13:45 -0500)]
tests: Add createVHBAByNodeDevice-no-parent to fchosttest

Add a test that allows not providing a parent in the input XML, but still
being able to create finding a VPORT capable NPIV HBA.

8 years agonodedev: Rework virNodeDeviceGetParentHost
John Ferlan [Tue, 24 Jan 2017 17:21:26 +0000 (12:21 -0500)]
nodedev: Rework virNodeDeviceGetParentHost

Rework the code to perform the various searches by parent, parent_wwnn/
parent_wwpn, parent_fabric_wwn, or vport capable in order to return the
'parent_host' number that is vHBA capable.

The former virNodeDeviceGetParentHost is renamed to add the ByParent
on it fixes an issue where if no parent was supplied in the XML to
create the vHBA, then virNodeDeviceFindByName was called with a NULL
second parameter which had bad results.

The reworked code will make the various calls to fetch the NPIV host
by the passed parameter options or if none are provided find a vport
capable NPIV HBA to perform the create. If the call is from the delete
path, then this option won't be allowed.

Each of virNodeDeviceGetParentHostBy* functions is now static, so
remove them external definitions.

A secondary benefit of this is the test_driver now can make use of
the new API to add some new tests to test the various creation options.

8 years agonodedev: Keep the node device lock longer in nodeDeviceDestroy
John Ferlan [Tue, 24 Jan 2017 17:26:25 +0000 (12:26 -0500)]
nodedev: Keep the node device lock longer in nodeDeviceDestroy

While perhaps improbable, it could be possible that after finding our
object that another thread running essentially in parallel could attempt
to delete the same vHBA.

So rather than dropping the lock right after finding the object, keep
the lock around while we drop the object lock and work on deleting the
object. Once the delete occurs we can safely drop the driver lock again.

Cleanup some of the usage of cleanup instead out for the goto label.

8 years agotests: Add new fchosttest tests for management of a vHBA
John Ferlan [Tue, 24 Jan 2017 15:49:23 +0000 (10:49 -0500)]
tests: Add new fchosttest tests for management of a vHBA

Add a test that will mimic creation and destruction of a vHBA
by using node device XML. The design will allow for testing the
multiple mechanisms.

The first test uses just <parent> in the node device XML. This is
somewhat similar to the existing objecteventtest, except that this
test will not provide input wwnn/wwpn's (similar to how the process
is described for the the libvirt wiki).

This requires mocking the virRandomGenerateWWN since parsing the
input XML (virNodeDevCapSCSIHostParseXML) requires either a provided
wwnn/wwpn in the XML or the ability to randomly generate the wwnn/wwpn.

8 years agoutil: Move scsi_host specific functions from virutil
John Ferlan [Mon, 23 Jan 2017 19:48:12 +0000 (14:48 -0500)]
util: Move scsi_host specific functions from virutil

Create a virscsihost.c and place the functions there. That removes the
last #ifdef __linux__ from virutil.c.

Take the opporunity to also change the function names and in one case
the parameters slightly

8 years agoutil: Replace virStoragePoolGetVhbaSCSIHostParent
John Ferlan [Sat, 18 Feb 2017 13:26:21 +0000 (08:26 -0500)]
util: Replace virStoragePoolGetVhbaSCSIHostParent

Use the new virNodeDeviceGetParentName instead. Modify the callers to
build the node device scsi_host# name string in order to call the new
function so that proper lookup occurs.

8 years agonodedev: Introduce virNodeDeviceGetParentName
John Ferlan [Sat, 18 Feb 2017 13:25:07 +0000 (08:25 -0500)]
nodedev: Introduce virNodeDeviceGetParentName

Create a function which takes a node device "name" entry to lookup
and returns a string containing the parent name for the node device.

8 years agoutil: Create a new virvhba module and move/rename API's
John Ferlan [Mon, 23 Jan 2017 17:54:42 +0000 (12:54 -0500)]
util: Create a new virvhba module and move/rename API's

Rather than have them mixed in with the virutil apis, create a separate
virvhba.c module and move the vHBA related calls into there. Soon there
will be more added.

Also modify the names of the functions and some arguments to be more
indicative of what is really happening. Adjust the callers respectively.

While I was changing fchosttest, rather than the non-descriptive names
test1...test6, rename them to match what the test is doing.

8 years agotest: Fix fchosttest resource leak
John Ferlan [Thu, 19 Jan 2017 11:37:43 +0000 (06:37 -0500)]
test: Fix fchosttest resource leak

Commit id '666bee3' made fabric_name optional; however, if fabric name
was present, then a leak would occur.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agotests: Create a more realistic vHBA
John Ferlan [Tue, 24 Jan 2017 01:52:24 +0000 (20:52 -0500)]
tests: Create a more realistic vHBA

Modify the code to react more like a real HBA -> vHBA creation.

Currently the code would just modify the input XML definition to
set the name to a wwpn and then modify the scsi_host capability
entry for the defintion to change the scsi_host# and unique_id
before adding that into the node device.

This patch does things a bit better. It finds and copies a known
existing vHBA (scsi_host11) in the node_device database and modifies
that definition to change the name to scsi_host12 and set the wwnn/
wwpn to what the input XML would expect before adding the def to the
node device object list.

Then rather than create a returned "dev" using the (poorly) mocked
name - perform the lookup using the new device name.

8 years agotest: Add helper to create vHBA for testNodeDeviceCreateXML
John Ferlan [Tue, 24 Jan 2017 12:48:36 +0000 (07:48 -0500)]
test: Add helper to create vHBA for testNodeDeviceCreateXML

Rather than inline the dummy creation of a vHBA to add to the node
devices - create a helper to do that work.

Also just tidy up a couple of things while at it...

8 years agotest: Add new NPIV capable HBA and a vHBA
John Ferlan [Tue, 24 Jan 2017 11:32:03 +0000 (06:32 -0500)]
test: Add new NPIV capable HBA and a vHBA

Predefine a second NPIV capable HBA as well as a vHBA using the first
NPIV capable HBA. This will allow for a mechanism to perform more
realistic create vHBA testing.

8 years agotests: Alter test_driver HBA name/data to be closer to reality
John Ferlan [Mon, 23 Jan 2017 20:24:59 +0000 (15:24 -0500)]
tests: Alter test_driver HBA name/data to be closer to reality

Alter "test-scsi-host-vport" to be "scsi_host1" to match the real
environment. This is the vport capable HBA - IOW the NPIV device.
Add more fields to scsi_host1 as well.

Alter the XML being used by the objecttest to create a vHBA in order
to match the scsi_host1 parent name and to use validateable wwnn/wwpn.
This will allow for realistic testing.

8 years agonodedev: fix build with clang
Roman Bogorodskiy [Sat, 18 Feb 2017 11:46:28 +0000 (15:46 +0400)]
nodedev: fix build with clang

Build fails with:

conf/node_device_conf.c:825:62: error: comparison of unsigned enum expression < 0 is always false [-Werror,-Wtautological-compare]
    if ((data->drm.type = virNodeDevDRMTypeFromString(type)) < 0) {
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
conf/node_device_conf.c:1801:59: error: comparison of unsigned enum expression < 0 is always false [-Werror,-Wtautological-compare]
        if ((type = virNodeDevDevnodeTypeFromString(tmp)) < 0) {
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
2 errors generated.

Fix by using intermediate variable to store the result similarly
to how it's done for other FromString* calls.

8 years agonodedev: Introduce new drm cap
Michal Privoznik [Fri, 17 Feb 2017 15:09:15 +0000 (16:09 +0100)]
nodedev: Introduce new drm cap

After 7f1bdec5fa0a0cd25 our nodedev driver is capable of
determining DRM devices (DRM stands for Direct Render Manager not
Digital rights management). There is still one bit missing
though: virConnectListAllNodeDevices() is capable of listing
either all devices or just those with specified capability. Well,
DRM capability is missing there.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: add rendernode argument
Marc-André Lureau [Tue, 14 Feb 2017 21:04:13 +0000 (01:04 +0400)]
qemu: add rendernode argument

Add a new attribute 'rendernode' to <gl> spice element.

Give it to QEMU if qemu supports it (queued for 2.9).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agonodedev: add drm capability
Marc-André Lureau [Tue, 14 Feb 2017 21:04:12 +0000 (01:04 +0400)]
nodedev: add drm capability

Add a new 'drm' capability for Direct Rendering Manager (DRM) devices,
providing device type information.

Teach the udev backend to populate those devices.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agonodedev: parse <path>
Marc-André Lureau [Tue, 14 Feb 2017 21:04:11 +0000 (01:04 +0400)]
nodedev: parse <path>

This should have been added with c4a4603de (or 0bdefd9b04).

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8 years agonodedev: add <devnode> paths
Marc-André Lureau [Tue, 14 Feb 2017 21:04:10 +0000 (01:04 +0400)]
nodedev: add <devnode> paths

Add new <devnode> top-level <device> element, that list the associated
/dev files. Distinguish the main /dev name from symlinks with a 'type'
attribute of value 'dev' or 'symlink'.

Update a test to check XML schema, and actually add it to the test list
since it was missing.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8 years agonodedev: fix extra space in dump
Marc-André Lureau [Tue, 14 Feb 2017 21:04:09 +0000 (01:04 +0400)]
nodedev: fix extra space in dump

This is a cosmetic change, shouldn't change XML parsing, and doesn't
break any test.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
8 years agocputest: Fix name of the file removed by cpu-parse.sh
Jiri Denemark [Thu, 16 Feb 2017 13:44:33 +0000 (14:44 +0100)]
cputest: Fix name of the file removed by cpu-parse.sh

We want to remove the file created by

    json <<<"$data" >$fname.json

in case it was empty.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agonodedev: Return the parent for a virNodeDevicePtr struct
John Ferlan [Tue, 7 Feb 2017 18:04:08 +0000 (13:04 -0500)]
nodedev: Return the parent for a virNodeDevicePtr struct

When the 'parent' was added to the virNodeDevicePtr structure
by commit id 'e8a4ea75a' the 'parent' field was not properly filled
in when a virGetNodeDevice call was made within driver/config code.
Only the device name was ever filled in. Fetching the parent required
a second trip via virNodeDeviceGetParent into the node device lookup
code was required in order to retrieve the specific parent field (and
still the parent field was never filled in although it was free'd).

Since we have the data when we initially call virGetNodeDevice from
within driver/node_config code - let's just fill in the parent field
as well for anyone that wants it without requiring another trip into
the node_device lookup just to get the parent.

This will allow API's such as virConnectListAllNodeDevices,
virNodeDeviceLookupByName, and virNodeDeviceLookupSCSIHostByWWN
to retrieve both name and parent in the returned virNodeDevicePtr.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agolibxl: fix coverity issues introduced by 6a95edf
Joao Martins [Thu, 16 Feb 2017 16:43:05 +0000 (16:43 +0000)]
libxl: fix coverity issues introduced by 6a95edf

As discussed here [0][1] Coverity reported two issues:

- On libxlDomainMigrationPrepareTunnel3 @@mig will be leaked on failures
after sucessfull call libxlDomainMigrationPrepareAny hence we free it.

Setting mig = NULL after @mig is assigned plus adding libxlMigrationCookieFree
on error paths addresses the issue. In case virThreadCreate fails,
unref of args frees the cookie on dispose function (libxlMigrationDstArgsDispose)

- On libxlMigrationStartTunnel @tc would be leaked.

Fixed by correctly saving the newly allocated @tc onto @tnl such that
libxlMigrationStopTunnel would free it up.

[0] https://www.redhat.com/archives/libvir-list/2017-February/msg00791.html
[1] https://www.redhat.com/archives/libvir-list/2017-February/msg00833.html

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
8 years agoqemu: Allow empty script path to <interface/>
Michal Privoznik [Thu, 2 Feb 2017 13:16:20 +0000 (14:16 +0100)]
qemu: Allow empty script path to <interface/>

Before 9c17d665fdc5f (v1.3.2 - I know, right?) it was possible to
have the following interface configuration:

  <interface type='ethernet'/>
    <script path=''/>
  </interface>

This resulted in -netdev tap,script=,.. Fortunately, qemu helped
us to get away with this as it just ignored the empty script
path. However, after the commit mentioned above it's libvirtd
who is executing the script. Unfortunately without special
case-ing empty script path.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agonews: add entries for libxl driver improvements and bug fixes
Jim Fehlig [Thu, 16 Feb 2017 04:15:27 +0000 (21:15 -0700)]
news: add entries for libxl driver improvements and bug fixes

8 years agoValidate required CPU features even for host-passthrough
Ján Tomko [Sat, 28 Jan 2017 10:32:13 +0000 (11:32 +0100)]
Validate required CPU features even for host-passthrough

Commit adff345 allowed enabling features with -cpu host
without ajdusting the validity checks on domain startup
and migration.

8 years agoEnsure disk names follow the disk name regex
Nitesh Konkar [Wed, 15 Feb 2017 11:14:58 +0000 (16:44 +0530)]
Ensure disk names follow the disk name regex

Currently disk names do not follow the
(regex) /^[fhv]d[a-z]+[0-9]*$/ completely
and hence one can assign disk names like
vd2 etc. This patch ensures that the
disk names follow the regex mentioned.
This patch also adds a testcase.

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agolibxl: fix potential double free in libxlDriverGetDom0MaxmemConf
Jim Fehlig [Wed, 15 Feb 2017 17:45:27 +0000 (10:45 -0700)]
libxl: fix potential double free in libxlDriverGetDom0MaxmemConf

Commit 4ab0c959 fixed a memory leak in libxlDriverGetDom0MaxmemConf
but introduced a potential double free of mem_tokens

*** Error in `/usr/sbin/libvirtd': double free or corruption (out):
    0x00007fffc808cfd0 ***

Avoid double free by setting mem_tokens to NULL after calling
virStringListFree.

8 years agonews: fix spelling of tunneled
Jim Fehlig [Wed, 15 Feb 2017 23:37:34 +0000 (16:37 -0700)]
news: fix spelling of tunneled

s/tunnelled/tunneled/ in news for the libxl tunneled migration feature.

8 years agonews: document libxl tunnelled migration support
Joao Martins [Wed, 15 Feb 2017 22:56:24 +0000 (22:56 +0000)]
news: document libxl tunnelled migration support

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
8 years agolibxl: add tunnelled migration support
Bob Liu [Wed, 15 Feb 2017 11:17:38 +0000 (11:17 +0000)]
libxl: add tunnelled migration support

Tunnelled migration doesn't require any extra network connections
beside the libvirt daemon.  It's capable of strong encryption and the
default option of openstack-nova.

This patch adds the tunnelled migration(Tunnel3params) support to
libxl.  On the source side, the data flow is:

 * libxlDoMigrateSend() -> pipe libxlTunnel3MigrationFunc() polls pipe
 * out and then write to dest stream.

While on the destination side:
 * Stream -> pipe -> 'recvfd of libxlDomainStartRestore'

The usage is the same as p2p migration, execpt adding one extra
'--tunnelled' to the libvirt p2p migration command.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
8 years agolibxl: refactor libxlDomainMigrationPrepare
Joao Martins [Wed, 15 Feb 2017 11:17:37 +0000 (11:17 +0000)]
libxl: refactor libxlDomainMigrationPrepare

The newly introduced function libxlDomainMigrationPrepareAny
will be shared between P2P and tunnelled variations.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
8 years agoqemu_conf: Properly check for retval of qemuDomainNamespaceAvailable
Michal Privoznik [Wed, 15 Feb 2017 14:40:01 +0000 (15:40 +0100)]
qemu_conf: Properly check for retval of qemuDomainNamespaceAvailable

This function is returning a boolean therefore check for '< 0'
makes no sense. It should have been
'!qemuDomainNamespaceAvailable'.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu_conf: Check for namespaces availability more wisely
Michal Privoznik [Wed, 15 Feb 2017 09:06:09 +0000 (10:06 +0100)]
qemu_conf: Check for namespaces availability more wisely

The bare fact that mnt namespace is available is not enough for
us to allow/enable qemu namespaces feature. There are other
requirements: we must copy all the ACL & SELinux labels otherwise
we might grant access that is administratively forbidden or vice
versa.
At the same time, the check for namespace prerequisites is moved
from domain startup time to qemu.conf parser as it doesn't make
much sense to allow users to start misconfigured libvirt just to
find out they can't start a single domain.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoapparmor: don't fail on non-apparmor <seclabel>
Jim Fehlig [Fri, 3 Feb 2017 02:26:13 +0000 (19:26 -0700)]
apparmor: don't fail on non-apparmor <seclabel>

If the apparmor security driver is loaded/enabled and domain config
contains a <seclabel> element whose type attribute is not 'apparmor',
starting the domain fails when attempting to label resources such
as tap FDs.

Many of the apparmor driver entry points attempt to retrieve the
apparmor security label from the domain def, returning failure if
not found. Functions such as AppArmorSetFDLabel fail even though
domain config contains an explicit 'none' secuirty driver, e.g.

  <seclabel type='none' model='none'/>

Change the entry points to succeed if the domain config <seclabel>
is not apparmor. This matches the behavior of the selinux driver.

8 years agoapparmor: don't overwrite error from reload_profile
Jim Fehlig [Fri, 3 Feb 2017 02:17:29 +0000 (19:17 -0700)]
apparmor: don't overwrite error from reload_profile

Like other callers of reload_profile, don't overwrite errors in
AppArmorSetSecurityHostdevLabelHelper.

8 years agoqemu_monitor_json: Properly check GetArray return value
Jiri Denemark [Mon, 13 Feb 2017 08:32:21 +0000 (09:32 +0100)]
qemu_monitor_json: Properly check GetArray return value

Commit 2a8d40f4ec refactored qemuMonitorJSONGetCPUx86Data and replaced
virJSONValueObjectGet(reply, "return") with virJSONValueObjectGetArray.
While the former is guaranteed to always return non-NULL pointer the
latter may return NULL if the returned JSON object is not an array.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu: Call chmod() after mknod()
Andrea Bolognani [Tue, 14 Feb 2017 14:46:23 +0000 (15:46 +0100)]
qemu: Call chmod() after mknod()

mknod() is affected my the current umask, so we're not
guaranteed the newly-created device node will have the
right permissions.

Call chmod(), which is not affected by the current umask,
immediately afterwards to solve the issue.

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

8 years agospec: Require libacl when building the QEMU driver
Andrea Bolognani [Tue, 14 Feb 2017 13:42:54 +0000 (14:42 +0100)]
spec: Require libacl when building the QEMU driver

For the namespaces feature to work properly we need to be able
to make a perfect copy of the original /dev, including ACLs.

By adding a BuildRequires on libacl-devel we ensure that ACL
support will be enabled at configure time and made available
to the QEMU driver.

8 years agoconfigure: Move ACL checks to a separate file
Andrea Bolognani [Tue, 14 Feb 2017 14:21:29 +0000 (15:21 +0100)]
configure: Move ACL checks to a separate file

8 years agoutil: fix off-by-one when expanding a bitmap
Ján Tomko [Mon, 30 Jan 2017 12:52:02 +0000 (13:52 +0100)]
util: fix off-by-one when expanding a bitmap

To make sure bit 'b' fits into the bitmap, we need to allocate b+1
bits, since we number from 0.

Adjust the bitmap test to set a bit at a multiple of 16.
That way the test fails without this fix, because the VIR_REALLOC
call clears the newly added memory even if the original pointer
has not changed.

8 years agovalgrind: add suppression for bash memory leak
Tomáš Golembiovský [Mon, 13 Feb 2017 22:49:06 +0000 (23:49 +0100)]
valgrind: add suppression for bash memory leak

Add suppression for memory leak in bash observerd with bash 4.4.011 on
Arch Linux.

Signed-off-by: Tomáš Golembiovský <tgolembi@redhat.com>
8 years agoqemu: enforce maximum ports value for nec-xhci
Ján Tomko [Mon, 28 Nov 2016 16:37:39 +0000 (17:37 +0100)]
qemu: enforce maximum ports value for nec-xhci

This controller only allows up to 15 ports.

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

8 years agodocs: document bhyve e1000 support
Roman Bogorodskiy [Sun, 12 Feb 2017 16:42:31 +0000 (20:42 +0400)]
docs: document bhyve e1000 support

 * Add bhyve e1000 support entry to release notes
 * Update the bhyve driver page with usage sample

8 years agoconf: check port range even for USB hubs
Ján Tomko [Mon, 30 Jan 2017 14:56:10 +0000 (15:56 +0100)]
conf: check port range even for USB hubs

Move the range check introduced by commit 2650d5e into
virDomainUSBAddressFindPort. That way both virDomainUSBAddressRelease
and virDomainUSBAddressSetAddHub can benefit from it.

Reported-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: assign USB port on a selected hub for all devices
Ján Tomko [Fri, 27 Jan 2017 17:08:22 +0000 (18:08 +0100)]
qemu: assign USB port on a selected hub for all devices

Due to a logic error, the autofilling of USB port when a bus is
specified:
    <address type='usb' bus='0'/>
does not work for non-hub devices on domain startup.

Fix the logic in qemuDomainAssignUSBPortsIterator to also
assign ports for USB addresses that do not yet have one.

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

8 years agorpc: Fix potentially segfaults
Marc Hartmayer [Thu, 9 Feb 2017 14:13:38 +0000 (15:13 +0100)]
rpc: Fix potentially segfaults

We have to allocate first and if, and only if, it was successful we
can set the count. A segfault has occurred in
virNetServerServiceNewPostExecRestart() when VIR_ALLOC_N(svc->socks,
n) has failed, but svc->nsocsk = n was already set. Thus
virObejectUnref(svc) was called and therefore it was possible that
virNetServerServiceDispose was called => segmentation fault.  For
safeness NULL pointer check were added in
virNetServerServiceDispose().

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
8 years agobhyve: add e1000 nic support
Roman Bogorodskiy [Sat, 27 Aug 2016 12:30:34 +0000 (15:30 +0300)]
bhyve: add e1000 nic support

Recently e1000 NIC support was added to bhyve; implement that in
the bhyve driver:

 - Add capability check by analyzing output of the 'bhyve -s 0,e1000'
   command
 - Modify bhyveBuildNetArgStr() to support e1000 and also pass
   virConnectPtr so it could call bhyveDriverGetCaps() to check if this
   NIC is supported
 - Modify command parsing code to add support for e1000 and adjust tests
 - Add net-e1000 test

8 years agoutil: Fix indentation for virnetdevmacvlan
Nitesh Konkar [Fri, 10 Feb 2017 14:35:23 +0000 (20:05 +0530)]
util: Fix indentation for virnetdevmacvlan

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agolibxl: Resolve possible resource leak in dom0 maximum memory setting
John Ferlan [Fri, 10 Feb 2017 11:54:56 +0000 (06:54 -0500)]
libxl: Resolve possible resource leak in dom0 maximum memory setting

If either the "if (STRPREFIX(mem_tokens[j], "max:"))" is never entered
or the "if (virStrToLong_ull(mem_tokens[j] + 4, &p, 10, maxmem) < 0)" break
is hit, control goes back to the outer loop processing 'cmd_tokens' and
it's possible that the 'mem_tokens' would be overwritten.

Found by Coverity

8 years agostorage: Fix checking whether source filesystem is mounted
Erik Skultety [Tue, 7 Feb 2017 09:19:21 +0000 (10:19 +0100)]
storage: Fix checking whether source filesystem is mounted

Right now, we use simple string comparison both on the source paths
(mount's output vs pool's source) and the target (mount's mnt_dir vs
pool's target). The problem are symlinks and mount indeed returns
symlinks in its output, e.g. /dev/mappper/lvm_symlink. The same goes for
the pool's source/target, so in order to successfully compare these two
replace plain string comparison with virFileComparePaths which will
resolve all symlinks and canonicalize the paths prior to comparison.

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoutil: Introduce virFileComparePaths
Erik Skultety [Tue, 7 Feb 2017 09:19:06 +0000 (10:19 +0100)]
util: Introduce virFileComparePaths

So rather than comparing 2 paths (strings) as they are, which can very
easily lead to unnecessary errors (e.g. in storage driver) that the paths
are not the same when in fact they'd be e.g. just symlinks to the same
location, we should put our best effort into resolving any symlinks and
canonicalizing the path and only then compare the 2 paths for equality.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agostorage: Fix reporting an error on an already mounted filesystem
Erik Skultety [Mon, 6 Feb 2017 14:03:52 +0000 (15:03 +0100)]
storage: Fix reporting an error on an already mounted filesystem

When FS pool's source is already mounted on the target location instead
of just simply marking the pool as active, thus starting it we fail with
an error stating that the source is indeed already mounted on the target.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agotests: Link virusbmock with probes
John Ferlan [Fri, 10 Feb 2017 13:00:41 +0000 (08:00 -0500)]
tests: Link virusbmock with probes

Seeing similar error to commit id '997be5c27' with the inability
to find the libvirt_event_poll_purge_timeout_semaphore symbol
causing a virusbtest failure.

8 years agoremote generator: Increase upper limit on lists of node devices
Boris Fiuczynski [Fri, 10 Feb 2017 13:56:51 +0000 (14:56 +0100)]
remote generator: Increase upper limit on lists of node devices

On a system with 697 SCSI disks each configured with 8 paths the command
virsh nodedev-list fails with
error: Failed to list node devices
error: internal error: Too many node_devices '16816' for limit '16384'
Increasing the upper limit on lists of node devices from 16K to 64K.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
8 years agoMention the min duration for nodesuspend explicitly
Nitesh Konkar [Tue, 7 Feb 2017 12:53:45 +0000 (18:23 +0530)]
Mention the min duration for nodesuspend explicitly

Although currently this is documented in virsh man page
and virsh help, the expicit mention in the error message
is helful for tools using the API directly.

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agoqemuMonitorCPUModelInfoFree: Don't leak model_info->props
Michal Privoznik [Mon, 6 Feb 2017 08:09:12 +0000 (09:09 +0100)]
qemuMonitorCPUModelInfoFree: Don't leak model_info->props

==11846== 240 bytes in 1 blocks are definitely lost in loss record 81 of 107
==11846==    at 0x4C2BC75: calloc (vg_replace_malloc.c:624)
==11846==    by 0x18C74242: virAllocN (viralloc.c:191)
==11846==    by 0x4A05E8: qemuMonitorCPUModelInfoCopy (qemu_monitor.c:3677)
==11846==    by 0x446E3C: virQEMUCapsNewCopy (qemu_capabilities.c:2171)
==11846==    by 0x437335: testQemuCapsCopy (qemucapabilitiestest.c:108)
==11846==    by 0x437CD2: virTestRun (testutils.c:180)
==11846==    by 0x437AD8: mymain (qemucapabilitiestest.c:176)
==11846==    by 0x4397B6: virTestMain (testutils.c:992)
==11846==    by 0x437B44: main (qemucapabilitiestest.c:188)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agotestUSBList: don't leak @dev
Michal Privoznik [Fri, 3 Feb 2017 13:56:43 +0000 (14:56 +0100)]
testUSBList: don't leak @dev

==22187== 77 (56 direct, 21 indirect) bytes in 1 blocks are definitely lost in loss record 23 of 37
==22187==    at 0x4C2BC75: calloc (vg_replace_malloc.c:624)
==22187==    by 0x4E75685: virAlloc (viralloc.c:144)
==22187==    by 0x4F0613A: virUSBDeviceNew (virusb.c:332)
==22187==    by 0x4F05BA2: virUSBDeviceSearch (virusb.c:183)
==22187==    by 0x4F05F95: virUSBDeviceFind (virusb.c:296)
==22187==    by 0x403514: testUSBList (virusbtest.c:209)
==22187==    by 0x403BD8: virTestRun (testutils.c:180)
==22187==    by 0x4039E5: mymain (virusbtest.c:285)
==22187==    by 0x4056BC: virTestMain (testutils.c:992)
==22187==    by 0x403A4A: main (virusbtest.c:293)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agovirusbmock: Link with libvirt_utils
Michal Privoznik [Fri, 3 Feb 2017 13:55:28 +0000 (14:55 +0100)]
virusbmock: Link with libvirt_utils

We are using couple of functions from there (e.g. virStrdup) and
rely that the binary linking us has the libvirt_utils linked
already. Well, this makes valgrind sad.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agotests: Trace re-executing processes with valgrind
Michal Privoznik [Fri, 3 Feb 2017 12:15:43 +0000 (13:15 +0100)]
tests: Trace re-executing processes with valgrind

A lot of our tests re-execute themeselves after loading their
mock library. This, however, makes valgrind sad because currently
we do not tell it to trace the process after exec().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoFix indentation in datatypes.h
Nitesh Konkar [Thu, 2 Feb 2017 09:20:08 +0000 (14:50 +0530)]
Fix indentation in datatypes.h

Signed-off-by: Nitesh Konkar <nitkon12@linux.vnet.ibm.com>
8 years agoremote generator: handle remoteDomainCreateWithFlags()
Marc Hartmayer [Thu, 19 Jan 2017 20:17:12 +0000 (21:17 +0100)]
remote generator: handle remoteDomainCreateWithFlags()

This commit removes the handcrafted code for
remoteDomainCreateWithFlags() and lets it auto generate.

A little bit of history repeating...
Commit 03d813bbcd7b4a183601055006 removed the auto generation of
remoteDomainCreateWithFlags() because it was thought that the design
flaw in the remote protocol for virDomainCreate is also within the
remote protocol for virDomainCreateWithFlags. As the commit message of
ddaf15d7a3863d54e242f8ff75 mentions this is not the case therefore we
can auto generate the client part.

Even worse there was a typo in remoteDomainCreateWithFlags()

'remote_domain_create_with_flags_args ret;' but in fact it has to be
'remote_domain_create_with_flags_ret ret;'.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
8 years agoutil: reset the counters to zero
Marc Hartmayer [Thu, 9 Feb 2017 14:13:37 +0000 (15:13 +0100)]
util: reset the counters to zero

After freeing the data structures we have to reset the counters to
zero. This fixes a segmentation fault when virNetDevIPInfoClear is
called twice (e.g. this is possible in virDomainNetDefParseXML() if
virDomainNetIPInfoParseXML(...) fails with ret < 0 (this leads to the
first call of 'virNetDevIPInfoClear(&def->guestIP)') and the resulting
call of virDomainNetDefFree(def) in the error path of
virDomainNetDefParseXML() (this leads to the second call of
virNetDevIPInfoClear(&def->guestIP), and finally to the segmentation
fault).

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
8 years agoconf: Fix libvirtd free() segfault if virDomainChrSourceDefNew(...) fails
Marc Hartmayer [Thu, 9 Feb 2017 14:13:36 +0000 (15:13 +0100)]
conf: Fix libvirtd free() segfault if virDomainChrSourceDefNew(...) fails

If virDomainChrSourceDefNew(xmlopt) fails, it will lead to free()ing
the uninitialized pointer bus. The fix for this is to initialize bus
with NULL.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
8 years agoqemu: Check if virQEMUCapsNewCopy(...) has failed
Marc Hartmayer [Thu, 9 Feb 2017 14:13:35 +0000 (15:13 +0100)]
qemu: Check if virQEMUCapsNewCopy(...) has failed

Check if virQEMUCapsNewCopy(...) has failed, thus a segmentation fault
in virQEMUCapsFilterByMachineType(...) will be avoided.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
8 years agoqemu: Fix live migration over RDMA with IPv6
David Dai [Fri, 27 Jan 2017 15:01:43 +0000 (09:01 -0600)]
qemu: Fix live migration over RDMA with IPv6

Using libvirt to do live migration over RDMA via IPv6 address failed.

For example:
    rhel73_host1_guest1 qemu+ssh://[deba::2222]/system --verbose
root@deba::2222's password:
error: internal error: unable to execute QEMU command 'migrate': RDMA
ERROR: could not rdma_getaddrinfo address deba

As we can see, the IPv6 address used by rdma_getaddrinfo() has only
"deba" part because we didn't properly enclose the IPv6 address in []
and passed rdma:deba::2222:49152 as the migration URI in
qemuMonitorMigrateToHost.

Signed-off-by: David Dai <zdai@linux.vnet.ibm.com>
8 years agolibxl: fix dom0 maximum memory setting
Jim Fehlig [Wed, 1 Feb 2017 00:10:34 +0000 (17:10 -0700)]
libxl: fix dom0 maximum memory setting

When the libxl driver is initialized, it creates a virDomainDef
object for dom0 and adds it to the list of domains. Total memory
for dom0 was being set from the max_memkb field of libxl_dominfo
struct retrieved from libxl, but this field can be set to
LIBXL_MEMKB_DEFAULT (~0ULL) if dom0 maximum memory has not been
explicitly set by the user.

This patch adds some simple parsing of the Xen commandline,
looking for a dom0_mem parameter that also specifies a 'max' value.
If not specified, dom0 maximum memory is effectively all physical
host memory.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
8 years agolibxl: fix reporting of maximum memory
Jim Fehlig [Mon, 16 Jan 2017 17:51:40 +0000 (10:51 -0700)]
libxl: fix reporting of maximum memory

The libxl driver reports different values of maximum memory depending
on state of a domain. If inactive, maximum memory value is reported
correctly. When active, maximum memory is derived from max_pages value
returned by the XEN_SYSCTL_getdomaininfolist sysctl operation. But
max_pages can be changed by toolstacks and does not necessarily
represent the maximum memory a domain can use during its active
lifetime.

A better location for determining a domain's maximum memory is the
/local/domain/<id>/memory/static-max node in xenstore. This value
is set from the libxl_domain_build_info.max_memkb field when creating
the domain. Currently it cannot be changed nor can its value be
exceeded by a balloon operation. From libvirt's perspective, always
reporting maximum memory with virDomainDefGetMemoryTotal() will produce
the same results as reading the static-max node in xenstore.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
8 years agolibxl: fix disk detach when <driver> not specified
Jim Fehlig [Tue, 7 Feb 2017 19:05:15 +0000 (12:05 -0700)]
libxl: fix disk detach when <driver> not specified

When a user does not explicitly set a <driver> in the disk config,
libvirt defers selection of a default to libxl. This approach works
fine when starting a domain with such configuration or attaching a
disk to a running domain. But when detaching such a disk, libxl
will fail with "unrecognized disk backend type: 0". libxl makes no
attempt to recalculate a default backend (driver) on detach and
simply fails when uninitialized.

This patch updates the libvirt disk config with the backend selected
by libxl when starting a domain or attaching a disk to a running
domain. Another benefit of this approach is that the live XML is
also updated with the backend driver selected by libxl.

8 years agolibxl: set default disk format in device post-parse
Jim Fehlig [Tue, 7 Feb 2017 18:00:33 +0000 (11:00 -0700)]
libxl: set default disk format in device post-parse

When starting a domian, a libxl_domain_config object is created from
virDomainDef. Any virDomainDiskDef devices with a format of
VIR_STORAGE_FILE_NONE are mapped to LIBXL_DISK_FORMAT_RAW in the
corresponding libxl_disk_device, but the virDomainDiskDef format is
never updated to reflect the change.

A better place to set a default format for disk devices is the
device post-parse callback, ensuring the virDomainDiskDef object
reflects the default format.

8 years agodocs: Document new ovs_timeout configuration knob
Boris Fiuczynski [Thu, 9 Feb 2017 16:20:24 +0000 (17:20 +0100)]
docs: Document new ovs_timeout configuration knob

Document the ovs_timeout introduced to libvirtd.conf in previous
patches.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agolibvirtd: set openvswitch timeout value based on config data
Boris Fiuczynski [Tue, 7 Feb 2017 15:16:44 +0000 (16:16 +0100)]
libvirtd: set openvswitch timeout value based on config data

Since a successful completion of the calls to openvswitch is expected
a longer timeout should be able to be chosen to account for loaded systems.
Therefore this patch provides the ability to specify the timeout value for
openvswitch calls in the libvirtd configuration file.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
8 years agonetwork: allow to specify timeout for openvswitch calls
Boris Fiuczynski [Tue, 7 Feb 2017 15:16:43 +0000 (16:16 +0100)]
network: allow to specify timeout for openvswitch calls

This patchs allows to set the timeout value used for all
openvswitch calls. The default timeout value remains as
before at 5 seconds.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agolibvirtd: add openvitch timeout value
Boris Fiuczynski [Tue, 7 Feb 2017 15:16:42 +0000 (16:16 +0100)]
libvirtd: add openvitch timeout value

Provide the ability to specify a default timeout value for
successful completion of openvswitch calls in the libvirtd
configuration file.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agodocs: Document new <memoryBacking/> elements
Jaroslav Safka [Thu, 9 Feb 2017 13:24:51 +0000 (14:24 +0100)]
docs: Document new <memoryBacking/> elements

Document the extensions made to domain <memoryBacking/> element
made in previous commits.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemu: Add args generation for file memory backing
Jaroslav Safka [Thu, 2 Feb 2017 13:27:33 +0000 (13:27 +0000)]
qemu: Add args generation for file memory backing

This patch add support for file memory backing on numa topology.

The specified access mode in memoryBacking can be overriden
by specifying token memAccess in numa cell.

8 years agoconf: Add new xml elements for file memorybacking support
Jaroslav Safka [Thu, 2 Feb 2017 13:27:32 +0000 (13:27 +0000)]
conf: Add new xml elements for file memorybacking support

This part introduces new xml elements for file based
memorybacking support and their parsing.
(It allows vhost-user to be used without hugepages.)

New xml elements:
<memoryBacking>
  <source type="file|anonymous"/>
  <access mode="shared|private"/>
  <allocation mode="immediate|ondemand"/>
</memoryBacking>

8 years agoqemu_conf: Add param memory_backing_dir
Jaroslav Safka [Thu, 2 Feb 2017 13:27:31 +0000 (13:27 +0000)]
qemu_conf: Add param memory_backing_dir

Add new parameter memory_backing_dir where files will be stored when memoryBacking
source is selected as file.

Value is stored inside char* memoryBackingDir

8 years agoqemu, conf: Rename virNumaMemAccess to virDomainMemoryAccess
Jaroslav Safka [Thu, 2 Feb 2017 13:27:30 +0000 (13:27 +0000)]
qemu, conf: Rename virNumaMemAccess to virDomainMemoryAccess

Rename to avoid duplicate code. Because virDomainMemoryAccess will be
used in memorybacking for setting default behaviour.

NOTE: The enum cannot be moved to qemu/domain_conf because of headers
dependency

8 years agocpu: fix typo: rename __kvm_hv_spinlock to __kvm_hv_spinlocks
Maxim Nestratov [Tue, 31 Jan 2017 14:12:13 +0000 (17:12 +0300)]
cpu: fix typo: rename __kvm_hv_spinlock to __kvm_hv_spinlocks

Strings associated with virDomainHyperv values in domain_conf.c are used to
construct HyperV CPU features names to be compared with names defined in
cpu_x86_data.h and the names for HyperV "spinlocks" feature don't match.
This leads to a misleading warning:
"host doesn't support hyperv 'spinlocks' feature" even when it's supported.
Let's fix it and rename along with it VIR_CPU_x86_KVM_HV_SPINLOCK to
VIR_CPU_x86_KVM_HV_SPINLOCKS.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
8 years agoqemu_command: Fix check for gluster disks
Jiri Denemark [Thu, 9 Feb 2017 10:16:19 +0000 (11:16 +0100)]
qemu_command: Fix check for gluster disks

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoqemu_blockjob: Avoid dereferencing NULL on OOM
Jiri Denemark [Thu, 9 Feb 2017 09:49:23 +0000 (10:49 +0100)]
qemu_blockjob: Avoid dereferencing NULL on OOM

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agocpu_x86: Fix memory leak in virCPUx86Translate
Jiri Denemark [Thu, 9 Feb 2017 08:25:51 +0000 (09:25 +0100)]
cpu_x86: Fix memory leak in virCPUx86Translate

virCPUDefStealModel is called with keepVendor == true which means the
cpu structure will keep its original vendor/vendor_id values. Thus it
makes no sense to copy them to the translated definition as they won't
be used there anyway. Except that the translated->vendor pointer might
get lost in x86Decode.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agovz: cleanup: remove unused constant
Maxim Nestratov [Wed, 8 Feb 2017 14:19:59 +0000 (17:19 +0300)]
vz: cleanup: remove unused constant

PARALLELS_STATISTICS_DROP_COUNT isn't used anymore

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
8 years agovz: fix event handle leak in prlsdkHandlePerfEvent
Maxim Nestratov [Wed, 8 Feb 2017 14:14:12 +0000 (17:14 +0300)]
vz: fix event handle leak in prlsdkHandlePerfEvent

When we happen to lose a domain but still get a performance event
for it, we should also free the event handle.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
8 years agovz: fix handle leak in prlsdkHandleVmStateEvent
Maxim Nestratov [Wed, 8 Feb 2017 14:09:57 +0000 (17:09 +0300)]
vz: fix handle leak in prlsdkHandleVmStateEvent

Every successful call of PrlEvent_GetParamByName allocates a handle,
which has to be freed.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
8 years agoqemu_security: Introduce ImageLabel APIs
Michal Privoznik [Fri, 3 Feb 2017 16:09:33 +0000 (17:09 +0100)]
qemu_security: Introduce ImageLabel APIs

Just like we need wrappers over other virSecurityManager APIs, we
need one for virSecurityManagerSetImageLabel and
virSecurityManagerRestoreImageLabel. Otherwise we might end up
relabelling device in wrong namespace.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agolibxl: use init and dispose functions with libxl_physinfo
Jim Fehlig [Wed, 1 Feb 2017 03:07:30 +0000 (20:07 -0700)]
libxl: use init and dispose functions with libxl_physinfo

The typical pattern when calling libxl functions that populate a
structure is

  libxl_foo foo;
  libxl_foo_init(&foo);
  libxl_get_foo(ctx, &foo);
  ...
  libxl_foo_dispose(&foo);

Fix several instances of libxl_physinfo missing the init and
dispose calls.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
8 years agolibxl: honor autoballoon setting in libxl.conf
Jim Fehlig [Mon, 30 Jan 2017 18:43:15 +0000 (11:43 -0700)]
libxl: honor autoballoon setting in libxl.conf

libxlGetAutoballoonConf is supposed to honor user-specified
autoballoon setting in libxl.conf. As written, the user-specified
setting could be overwritten by the subsequent logic to check
dom0_mem parameter. If user-specified setting is present and
correct, accept it. Only fallback to checking Xen dom0_mem
command line parameter if user-specfied setting is not present.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
8 years agoxenconfig: fix xml to xl.cfg conversion with no graphics
Joao Martins [Wed, 8 Feb 2017 12:32:36 +0000 (12:32 +0000)]
xenconfig: fix xml to xl.cfg conversion with no graphics

If no graphics element is in XML xenFormatXLSpice will access
graphics without checking it has one in the first place, leading to a
segmentation fault.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
8 years agoqemuDomainNamespaceSetupDisk: Simplify disk check
Michal Privoznik [Fri, 3 Feb 2017 16:23:10 +0000 (17:23 +0100)]
qemuDomainNamespaceSetupDisk: Simplify disk check

Firstly, instead of checking for next->path the
virStorageSourceIsEmpty() function should be used which also
takes disk type into account.
Secondly, not every disk source passed has the correct type set
(due to our laziness). Therefore, instead of checking for
virStorageSourceIsBlockLocal() and also S_ISBLK() the former can
be refined to just virStorageSourceIsLocalStorage().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuDomainDiskChainElement{Prepare,Revoke}: manage /dev entry
Michal Privoznik [Fri, 3 Feb 2017 16:01:31 +0000 (17:01 +0100)]
qemuDomainDiskChainElement{Prepare,Revoke}: manage /dev entry

Again, one missed bit. This time without this commit there is no
/dev entry  in the namespace of the qemu process when doing disk
snapshots or block-copy.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuDomainNamespace{Setup,Teardown}Disk: Don't pass pointer to full disk
Michal Privoznik [Fri, 3 Feb 2017 14:53:28 +0000 (15:53 +0100)]
qemuDomainNamespace{Setup,Teardown}Disk: Don't pass pointer to full disk

These functions do not need to see the whole virDomainDiskDef.
Moreover, they are going to be called from places where we don't
have access to the full disk definition. Sticking with
virStorageSource is more than enough.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
8 years agoqemuDomainNamespaceSetupDisk: Drop useless @src variable
Michal Privoznik [Sat, 4 Feb 2017 17:02:07 +0000 (18:02 +0100)]
qemuDomainNamespaceSetupDisk: Drop useless @src variable

Since its introduction in 81df21507bef9 this variable was never
used.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>