]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
9 years agodaemonSetupNetworking: Don't leak services
Michal Privoznik [Thu, 18 Jun 2015 12:11:21 +0000 (14:11 +0200)]
daemonSetupNetworking: Don't leak services

When setting up the daemon networking, new services are created. These
services then have sockets to listen on. Once created, the service
objects are added to corresponding server object. However, during that
process, server increases reference counter of the service object. So,
at the end of the function, we should decrease it again. This way the
service objects will have only 1 reference, but that's okay since
servers are the only objects having a reference.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agolib: setvcpus: Remove bogus flag check
Peter Krempa [Tue, 16 Jun 2015 16:55:24 +0000 (18:55 +0200)]
lib: setvcpus: Remove bogus flag check

Since VIR_DOMAIN_AFFECT_CURRENT is 0 the flag check does not make sense
as masking @flags with 0 will always equal to false.

9 years agoscsi: Adjust return status from getBlockDevice
John Ferlan [Fri, 12 Jun 2015 11:22:34 +0000 (07:22 -0400)]
scsi: Adjust return status from getBlockDevice

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

Currently it's not possible to determine the difference between a
fatal memory allocation or failure to open/read the directory error
with a perhaps less fatal, I didn't find the "block" device in the
directory (which may be a disk entry without a block device).

In the case of the latter, we shouldn't cause failure to continue
searching in the caller (virStorageBackendSCSIFindLUs), rather we
should allow trying reading the next directory entry.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirsh: selective block device migration
Pavel Boldin [Mon, 15 Jun 2015 22:42:11 +0000 (01:42 +0300)]
virsh: selective block device migration

Add `virsh migrate' option `--migrate-disks' that allows CLI user to
explicitly specify block devices to migrate.

Signed-off-by: Pavel Boldin <pboldin@mirantis.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: migration: selective block device migration
Pavel Boldin [Mon, 15 Jun 2015 22:42:10 +0000 (01:42 +0300)]
qemu: migration: selective block device migration

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

Implement a `migrate_disks' parameters for the QEMU driver. This multi-
value parameter can be used to explicitly specify what block devices
are to be migrated using the NBD server. Tunnelled migration using NBD
is to be done.

Signed-off-by: Pavel Boldin <pboldin@mirantis.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoutil: add virTypedParamsAddStringList
Pavel Boldin [Mon, 15 Jun 2015 22:42:09 +0000 (01:42 +0300)]
util: add virTypedParamsAddStringList

The `virTypedParamsAddStringList' function provides interface to add a
NULL-terminated array of string values as a multi-value to the params.

Signed-off-by: Pavel Boldin <pboldin@mirantis.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoutil: virTypedParams{Filter,GetStringList}
Pavel Boldin [Mon, 15 Jun 2015 22:42:08 +0000 (01:42 +0300)]
util: virTypedParams{Filter,GetStringList}

Add multikey API:

 * virTypedParamsFilter that filters all the parameters with specified name.
 * virTypedParamsGetStringList that returns a list with all the values for
   specified name and string type.

Signed-off-by: Pavel Boldin <pboldin@mirantis.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoutil: multi-value parameters in virTypedParamsAdd*
Pavel Boldin [Mon, 15 Jun 2015 22:42:07 +0000 (01:42 +0300)]
util: multi-value parameters in virTypedParamsAdd*

Allow multi-value parameters to be build using virTypedParamsAdd*
functions by removing check for duplicates.

Signed-off-by: Pavel Boldin <pboldin@mirantis.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoutil: multi-value virTypedParameter
Pavel Boldin [Mon, 15 Jun 2015 22:42:06 +0000 (01:42 +0300)]
util: multi-value virTypedParameter

The `virTypedParamsValidate' function now can be instructed to allow
multiple entries for some of the keys. For this flag the type with
the `VIR_TYPED_PARAM_MULTIPLE' flag.

Add unit tests for this new behaviour.

Signed-off-by: Pavel Boldin <pboldin@mirantis.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemuMigrationDriveMirror: Force raw format for NBD
Michal Privoznik [Mon, 15 Jun 2015 22:42:05 +0000 (01:42 +0300)]
qemuMigrationDriveMirror: Force raw format for NBD

When playing with disk migration lately, I've noticed this warning in
domain logs:

WARNING: Image format was not specified for 'nbd://masina:49153/drive-virtio-disk0' and probing guessed raw.
         Automatically detecting the format is dangerous for raw images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the restrictions.

So I started digging into qemu source code to see what has triggered
the warning. I'd expect qemu to know formats of guest's disks since we
tell them on command line. This lead me to qmp_drive_mirror() where
the following can be found:

    if (!has_format) {
        format = mode == NEW_IMAGE_MODE_EXISTING ? NULL : bs->drv->format_name;
    }

So, format is automatically initialized from the disk iff mode !=
"existing". Unfortunately, in migration we are tied to use this mode
(NBD doesn't support creating new images). Therefore the only way to
avoid this warning is to pass format. The discussion on the mail-list [1]
resulted in the code that always forces NBD export as "raw" format.

[1] https://www.redhat.com/archives/libvir-list/2015-June/msg00153.html
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Pavel Boldin <pboldin@mirantis.com>
9 years agoqemuMigrationBeginPhase: Fix function header indentation
Michal Privoznik [Mon, 15 Jun 2015 22:42:04 +0000 (01:42 +0300)]
qemuMigrationBeginPhase: Fix function header indentation

This function is returning a string (domain XML). Since d3ce7363
when it was first introduced, it was indented incorrectly:

static char
*qemuMigrationBeginPhase(..)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirDomainDiskGetSource: Mark passed disk as 'const'
Michal Privoznik [Mon, 15 Jun 2015 22:42:03 +0000 (01:42 +0300)]
virDomainDiskGetSource: Mark passed disk as 'const'

The disk is not changed anywhere in the function. Mark this fact
in the function header too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: Fix double space in error message in qemuDomainGetVcpusFlags
Peter Krempa [Thu, 18 Jun 2015 13:31:52 +0000 (15:31 +0200)]
qemu: Fix double space in error message in qemuDomainGetVcpusFlags

9 years agoqemu: Jump to correct label in qemuDomainPinIOThread
Peter Krempa [Thu, 18 Jun 2015 13:29:20 +0000 (15:29 +0200)]
qemu: Jump to correct label in qemuDomainPinIOThread

If virDomainObjGetDefs used in qemuDomainPinIOThread would fail the code
would jump to the 'cleanup' label after acquiring the job, thus the VM
would be locked forever.

Introduced in commit cac6d639.

9 years agoconf: Move vcpu info parsing code into a separate function
Peter Krempa [Mon, 8 Jun 2015 14:58:46 +0000 (16:58 +0200)]
conf: Move vcpu info parsing code into a separate function

9 years agoqemu: 'privileged' flag is not really configuration
Peter Krempa [Mon, 15 Jun 2015 18:59:58 +0000 (20:59 +0200)]
qemu: 'privileged' flag is not really configuration

The privileged flag will not change while the configuration might
change. Make the 'privileged' flag member of the driver again and mark
it immutable. Should that ever change add an accessor that will group
reads of the state.

9 years agoqemu: Reuse virDomainObjGetDefs in qemuDomainGetMemoryParameters
Peter Krempa [Mon, 15 Jun 2015 18:48:44 +0000 (20:48 +0200)]
qemu: Reuse virDomainObjGetDefs in qemuDomainGetMemoryParameters

Simplify the code by restructuring control flow and reusing the better
helper.

9 years agoqemu: Refactor qemuDomainGetMemoryParameters
Peter Krempa [Mon, 15 Jun 2015 18:27:17 +0000 (20:27 +0200)]
qemu: Refactor qemuDomainGetMemoryParameters

Replace the for loops with case inside with temp variables and a macro.

9 years agoqemu: Refactor qemuDomainSetNumaParameters
Peter Krempa [Mon, 15 Jun 2015 18:06:30 +0000 (20:06 +0200)]
qemu: Refactor qemuDomainSetNumaParameters

Use virDomainObjGetDefs and sanitize the control flow.

9 years agoqemu: Simplify qemuDomainSetInterfaceParameters by using virDomainObjGetDefs
Peter Krempa [Mon, 15 Jun 2015 17:46:28 +0000 (19:46 +0200)]
qemu: Simplify qemuDomainSetInterfaceParameters by using virDomainObjGetDefs

9 years agoqemu: Simplify qemuDomainGetVcpusFlags by using virDomainObjGetOneDef
Peter Krempa [Mon, 15 Jun 2015 17:10:49 +0000 (19:10 +0200)]
qemu: Simplify qemuDomainGetVcpusFlags by using virDomainObjGetOneDef

virDomainObjGetOneDef is simpler to use than virDomainObjGetDefs

9 years agoqemu: Simplify qemuDomainGetEmulatorPinInfo by using virDomainObjGetOneDef
Peter Krempa [Mon, 15 Jun 2015 17:10:49 +0000 (19:10 +0200)]
qemu: Simplify qemuDomainGetEmulatorPinInfo by using virDomainObjGetOneDef

virDomainObjGetOneDef is simpler to use than virDomainObjGetDefs

9 years agoqemu: Simplify qemuDomainGetVcpuPinInfo by using virDomainObjGetOneDef
Peter Krempa [Mon, 15 Jun 2015 17:10:49 +0000 (19:10 +0200)]
qemu: Simplify qemuDomainGetVcpuPinInfo by using virDomainObjGetOneDef

virDomainObjGetOneDef is simpler to use than virDomainObjGetDefs

9 years agoqemu: Simplify qemuDomainGetNumaParameters by using virDomainObjGetOneDef
Peter Krempa [Mon, 15 Jun 2015 17:10:49 +0000 (19:10 +0200)]
qemu: Simplify qemuDomainGetNumaParameters by using virDomainObjGetOneDef

9 years agoqemu: Simplify qemuDomainGetInterfaceParameters by using virDomainObjGetOneDef
Peter Krempa [Mon, 15 Jun 2015 17:10:49 +0000 (19:10 +0200)]
qemu: Simplify qemuDomainGetInterfaceParameters by using virDomainObjGetOneDef

9 years agoconf: Introduce helper to help getting correct def for getter functions
Peter Krempa [Mon, 15 Jun 2015 17:04:41 +0000 (19:04 +0200)]
conf: Introduce helper to help getting correct def for getter functions

virDomainObjGetOneDef will help to retrieve the correct definition
pointer from @vm in cases where VIR_DOMAIN_AFFECT_LIVE and
VIR_DOMAIN_AFFECT_CONFIG are mutually exclusive. The function simply
returns the correct pointer. This similarly to virDomainObjGetDefs will
greatly simplify the code.

9 years agoconf: Fix virDomainObjGetDefs when getting persistent config on a live vm
Peter Krempa [Fri, 12 Jun 2015 12:37:18 +0000 (14:37 +0200)]
conf: Fix virDomainObjGetDefs when getting persistent config on a live vm

If @flags contains only VIR_DOMAIN_AFFECT_CONFIG and @vm is active, the
function would return the active config rather than the persistent one
that it should return. This happened due to the fact that
virDomainObjGetDefs was checking the updated flags which may not contain
VIR_DOMAIN_AFFECT_LIVE if it is not requested even if @vm is active.

Additionally the function would not take the flags into account when
setting the pointers which was later used to determine whether the code
needs to update the given configuration.

The mistake was caught by the virt-test suite.

9 years agoqemu: implement address for isa-serial
James Cowgill [Tue, 16 Jun 2015 13:07:59 +0000 (14:07 +0100)]
qemu: implement address for isa-serial

I needed to specify the iobase address for certain exotic mips configurations.

Signed-off-by: James Cowgill <james410@cowgill.org.uk>
9 years agoqemu: Add a check for slot and base dimm address conflicts
Luyao Huang [Mon, 15 Jun 2015 12:33:49 +0000 (20:33 +0800)]
qemu: Add a check for slot and base dimm address conflicts

When hotplugging a memory device, there wasn't a check to determine
if there is a conflict with the address space being used by the to
be added memory device and any existing device which is disallowed by qemu.

This patch adds a check to ensure the new device address doesn't
conflict with any existing device.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agodaemon: Add the admin service to the admin server only if it was allocated
Peter Krempa [Thu, 18 Jun 2015 09:40:08 +0000 (11:40 +0200)]
daemon: Add the admin service to the admin server only if it was allocated

If the admin service is disabled it would not be allocated, but the NULL
pointer still would be added to the admin server. Since
virNetServerAddService would dereference it, the daemon would crash.

Move the service registration into the block that allocates it.

9 years agorpc: Actually increase reference count on @srv in virNetDaemonAddServer
Peter Krempa [Thu, 18 Jun 2015 09:37:17 +0000 (11:37 +0200)]
rpc: Actually increase reference count on @srv in virNetDaemonAddServer

VIR_APPEND_ELEMENT would clear @srv to NULL after it successfully
inserted it thus the reference count could not be increased afterwards.

Switch to VIR_APPEND_ELEMENT_COPY. This fixes crash after terminating
the daemon.

9 years agoparallels: Fix false error messages in libvirt log
Mikhail Feoktistov [Wed, 17 Jun 2015 12:35:00 +0000 (15:35 +0300)]
parallels: Fix false error messages in libvirt log

There was many errors in libvirt.log caused by prlsdkDelNet function because
job variable was always initialized as PRL_INVALID_HANDLE
In this patch job variable gets return value of PrlSrv_DeleteVirtualNetwork function()

9 years agoparallels: Fix initialization of buflen variable in each loop iteration
Mikhail Feoktistov [Wed, 17 Jun 2015 12:35:00 +0000 (15:35 +0300)]
parallels: Fix initialization of buflen variable in each loop iteration

We need to initialize buflen every time when we get network adapter's
friendly name because we call PrlVmDev_GetFriendlyName in a loop

9 years agoremove redundant condition
Ján Tomko [Wed, 17 Jun 2015 15:57:56 +0000 (17:57 +0200)]
remove redundant condition

If the address type is SPAPRVIO, it will match the != NONE condition.

9 years agovirSysinfo: Introduce SMBIOS type 2 support
Michal Privoznik [Tue, 12 May 2015 14:47:49 +0000 (16:47 +0200)]
virSysinfo: Introduce SMBIOS type 2 support

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

This type of information defines attributes of a system
baseboard. With one exception: board type is yet not implemented
in qemu so it's not introduced here either.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: Report all supported machine types in capabilities
Jiri Denemark [Fri, 12 Jun 2015 12:36:51 +0000 (14:36 +0200)]
qemu: Report all supported machine types in capabilities

Some machine types are only reported as canonical names for other
machine types, which make it a bit harder to find what machine types are
supported by a specific QEMU binary. Ideally, one would just use
/capabilities/guest/arch[@name='...']/machine/text() XPath to get a list
of all supported machine types, but it doesn't work right now.

For example, we report

    <machine canonical='pc-i440fx-2.3' maxCpus='255'>pc</machine>

in guest capabilities, but the corresponding

    <machine maxCpus='255'>pc-i440fx-2.3</machine>

is missing.

This is a result of QMP probing. With "-machine ?" parsing QEMU sends
us two lines:

pc                   Standard PC (i440FX + PIIX, 1996) (alias of pc-i440fx-2.3)
pc-i440fx-2.3        Standard PC (i440FX + PIIX, 1996) (default)

while query-machines QMP command reports both in the same entry:

{"name": "pc-i440fx-2.3", "is-default": true, "cpu-max": 255, "alias": "pc"}

Let's make sure we always report separate <machine/> for both the
canonical name and its alias and using the canonical name as the default
machine type (i.e., inserting it before its alias) in case is-default is
true.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agotests: Sort EXTRA_DIST in the Makefile
Michal Privoznik [Wed, 17 Jun 2015 16:11:25 +0000 (18:11 +0200)]
tests: Sort EXTRA_DIST in the Makefile

We tend to keep the folders in the EXTRA_DIST sorted alphabetically.
However, we've failed sometimes and the list is not ordered anymore.
Reorder it back.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agodaemon: Don't just include admin RPC
Michal Privoznik [Wed, 17 Jun 2015 13:36:16 +0000 (15:36 +0200)]
daemon: Don't just include admin RPC

So, it's a little paradox that we use the file twice. Firstly to build
libvirt-admin.la (a client side of the Admin API), then once again to
build the server side. Well, the problem is, this does not play nicely
with the distclean since the file is generated. So while it's removed
in the src/ the distclean running in daemon/ will not find the file
and fail. The file is needed because it contains the RPC wrappers. So
let's leave the client code as is and from the daemon/ just link the
client library. The linker will find desired symbols and use them.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agonodedev: update netdev feature bits before each dumpxml
Laine Stump [Tue, 16 Jun 2015 15:57:11 +0000 (11:57 -0400)]
nodedev: update netdev feature bits before each dumpxml

As with several other attributes of devices (link status, sriov VF
list, IOMMU group list), the detdev feature bits aren't automatically
updated in the nodedev driver's cache when they change. In order to
get a properly up-to-date list when getting the XML of a device, we
must reget them in update-caps prior to each dumpxml.

This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1232880

9 years agolibvirt.spec: Don't expect virt-admin in libvirt-admin yet
Michal Privoznik [Wed, 17 Jun 2015 11:49:35 +0000 (13:49 +0200)]
libvirt.spec: Don't expect virt-admin in libvirt-admin yet

While Martin introduced the binary (and its manpage) in commit
4e7ccf87133 it was pushed by mistake. Therefore it was reverted in
220393bfb043. The problem is, the original commit was not quite right
as the binary was added into the spec file in a different commit:
55e0c840af. So as long as the binary does not exist, we must remove it
from the spec file too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agotests: Follow virnetserver to virnetdaemon transition
Michal Privoznik [Wed, 17 Jun 2015 11:29:14 +0000 (13:29 +0200)]
tests: Follow virnetserver to virnetdaemon transition

In a4746114582 the virnetserver test was renamed to virnetdaemon.
Moreover, as the test relies on some data stored under
virnetserverdata/ the folder was renamed too. But this was not
reflected in the Makefile. Therefore when building outside of the
repository, the data folder was not distributed and test failed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agodaemon: Distribute admin_server.h
Michal Privoznik [Wed, 17 Jun 2015 11:25:47 +0000 (13:25 +0200)]
daemon: Distribute admin_server.h

The Admin API consists of a few files on daemon side. Notably
daemon/admin_server.{ch}. While they are both on the repo, only
the .c file is mentioned in Makefile. Therefore, .h is not
distributed and 'make rpm' fails.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoparallels: substitute parallels with vz spec file and Makefile
Maxim Nestratov [Wed, 10 Jun 2015 07:50:00 +0000 (10:50 +0300)]
parallels: substitute parallels with vz spec file and Makefile

Since we have changed the name of the driver to vz, let's
reference it as vz everywhere.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
9 years agoparallels: rename all parallels files and driver directory to vz
Maxim Nestratov [Wed, 10 Jun 2015 07:50:00 +0000 (10:50 +0300)]
parallels: rename all parallels files and driver directory to vz

This patch moves all src/parallels/parallels* files to vz/vz*
and fixes build accordingly.
No functional changes.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
9 years agoparallels: substitute parallels with vz in strings
Maxim Nestratov [Wed, 10 Jun 2015 07:50:00 +0000 (10:50 +0300)]
parallels: substitute parallels with vz in strings

Here we stop referencing vz driver by different names
in error messages. 'parallels driver', 'Parallels Cloud
Server', 'Parallels driver' all become just 'vz driver'.
No functional changes. Only renaming and a bit of rewording.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
9 years agoparallels: change parallels prefixes to vz
Maxim Nestratov [Wed, 10 Jun 2015 07:50:00 +0000 (10:50 +0300)]
parallels: change parallels prefixes to vz

This patch changes all parallels/vz driver structure and
function prefixes from parallels to vz.
No functional changes.

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
9 years agodaemon/Makefile: Add forgotten dependency
Michal Privoznik [Tue, 16 Jun 2015 16:11:17 +0000 (18:11 +0200)]
daemon/Makefile: Add forgotten dependency

In latest patches we added Admin API. However, the Makefile in daemon
was missing one dependency: admin_server.c is including generated file
admin_dispatch.h. However, this dependency was not explicitly marked
in the Makefile therefore the build happened to fail on some
occasions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirfile: virDirCreate: Insert blank lines to assure slightly better readability
Erik Skultety [Tue, 16 Jun 2015 06:50:03 +0000 (08:50 +0200)]
virfile: virDirCreate: Insert blank lines to assure slightly better readability

9 years agoutil: virfile: Fix 'unknown cause' error if NFS mount point creation fails
Erik Skultety [Thu, 11 Jun 2015 08:51:23 +0000 (10:51 +0200)]
util: virfile: Fix 'unknown cause' error if NFS mount point creation fails

This happens if user requires creation of a directory with specified
UID/GID permissions. To accomplish this, we use fork approach and
set particular UID/GID permissions in child process. However, child
process doesn't have a valid descriptor to a logfile (this is prohibited
explicitly) and since parent process doesn't handle negative exit codes from
child in any way, 'uknown cause' error is returned to the user.

Commit 92d9114e tweaked the way we handle child errors when using fork
approach to set specific permissions (features originally introduced
by 98f6f381). The same logic should be used to create directories with
specified permissions as well.

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

9 years agoutil: virDirCreate: Child now exits with positive errno-code
Erik Skultety [Tue, 16 Jun 2015 11:43:38 +0000 (13:43 +0200)]
util: virDirCreate: Child now exits with positive errno-code

Previous patch of this series proposed a fix to virDirCreate, so that parent
process reports an error if child process failed its task.
However our logic still permits the child to exit with negative errno followed
by a check of the status on the parent side using WEXITSTATUS which, being
POSIX compliant, takes the lower 8 bits of the exit code and returns is to
the caller. However, by taking 8 bits from a negative exit code
(two's complement) the status value we read and append to stream is
'2^8 - abs(original exit code)' which doesn't quite reflect the real cause when
compared to the meaning of errno values.

9 years agolxc: set nosuid+nodev+noexec flags on /proc/sys mount
Eric W. Biederman [Tue, 16 Jun 2015 13:44:36 +0000 (14:44 +0100)]
lxc: set nosuid+nodev+noexec flags on /proc/sys mount

Future kernels will mandate the use of nosuid+nodev+noexec
flags when mounting the /proc/sys filesystem. Unconditionally
add them now since they don't harm things regardless and could
mitigate future security attacks.

9 years agoutil: Fix Coverity RESOURCE_LEAK
John Ferlan [Tue, 16 Jun 2015 13:15:10 +0000 (09:15 -0400)]
util: Fix Coverity RESOURCE_LEAK

Commit id 'e44b0269c9' in advertently checked !dir before calling closedir

9 years agolxc: Rename daemon to dmn
Martin Kletzander [Tue, 16 Jun 2015 12:59:33 +0000 (14:59 +0200)]
lxc: Rename daemon to dmn

On older systems it shadows global declaration of daemon() function.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agonetserver: Remove duplicate forward declaration
Martin Kletzander [Tue, 16 Jun 2015 12:58:00 +0000 (14:58 +0200)]
netserver: Remove duplicate forward declaration

Commit fa14207368820b264123ba8429927b62258f996e added forward
declaration of virNetServerPtr into virnetserver.h even though we are
keeping these in virnetserverprogram.h due to older compilers having
problems with duplicate ones.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoRevert "rpc: Add virNetServerGetNClients"
Martin Kletzander [Tue, 16 Jun 2015 12:09:09 +0000 (14:09 +0200)]
Revert "rpc: Add virNetServerGetNClients"

This reverts commit 6bda9f8aa2cd07a3defda571c7d61401fd66c226.

I mistakenly pushed it along with the Admin API series.

9 years agoRevert "admin: Add virAdmHello function"
Martin Kletzander [Tue, 16 Jun 2015 12:08:59 +0000 (14:08 +0200)]
Revert "admin: Add virAdmHello function"

This reverts commit 5792fabb7b712749147e9d03348c798dc1943651.

I mistakenly pushed it along with the Admin API series.

9 years agoRevert "Example virt-admin"
Martin Kletzander [Tue, 16 Jun 2015 12:08:23 +0000 (14:08 +0200)]
Revert "Example virt-admin"

This reverts commit 4e7ccf87133ac59f68bdd0b4897178fa9e2feefd.

I mistakenly pushed it along with the Admin API series.

9 years agoChange livbirt version to 1.3.0 for the next release
Martin Kletzander [Tue, 16 Jun 2015 11:38:54 +0000 (13:38 +0200)]
Change livbirt version to 1.3.0 for the next release

Since the background for Admin API is merged upstream, we are bumping
the minor release version as discussed previously

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoExample virt-admin
Martin Kletzander [Tue, 17 Mar 2015 09:27:14 +0000 (10:27 +0100)]
Example virt-admin

You had only one job.  That's what you can say about this example
binary.  In future, parts of virsh that are usable for this binary
should be split into separate shell-utils and virt-admin should gain all
the cool features of virsh without too much code addition.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoadmin: Add virAdmHello function
Martin Kletzander [Wed, 15 Apr 2015 14:35:42 +0000 (16:35 +0200)]
admin: Add virAdmHello function

Just one of the simplest functions that returns string "Clients: X"
where X is the number of connected clients to daemon's first
subserver (the original one), so it can be tested using virsh, ipython,
etc.

The subserver is gathered by incrementing its reference
counter (similarly to getting qemu capabilities), so there is no
deadlock with admin subserver in this API.

Here you can see how functions should be named in the client (virAdm*)
and server (adm*).

There is also a parameter @flags that must be 0, which helps testing
proper error propagation into the client.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agorpc: Add virNetServerGetNClients
Martin Kletzander [Wed, 15 Apr 2015 14:39:04 +0000 (16:39 +0200)]
rpc: Add virNetServerGetNClients

This function accesses the number of connected clients while properly
locking the server it returns the data about.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoAdd support for admin API in libvirt daemon
Martin Kletzander [Wed, 15 Apr 2015 14:23:55 +0000 (16:23 +0200)]
Add support for admin API in libvirt daemon

For this to pe properly separated from other protocols used by the
server, there is second server added which allows access to the whole
virNetDaemon to its clients.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoAdd configuration options for permissions on daemon's admin socket
Martin Kletzander [Mon, 13 Apr 2015 14:05:46 +0000 (16:05 +0200)]
Add configuration options for permissions on daemon's admin socket

This is not going to be very widely used, but for some corner cases and
easier (unsafe) debugging, it might be nice.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoAdd XML files with admin API specification
Martin Kletzander [Wed, 15 Apr 2015 14:23:25 +0000 (16:23 +0200)]
Add XML files with admin API specification

No online docs are build from it since it doesn't really fit into our
document structure and new page will need to be created for it, but this
is at least a heads-up commit for easier parsing in order to build some
documentation (or python bindings) later on.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoAdd libvirt-admin library
Martin Kletzander [Wed, 15 Apr 2015 14:16:24 +0000 (16:16 +0200)]
Add libvirt-admin library

Initial scratch of the admin library.  It has its own virAdmConnectPtr
that inherits from virAbstractConnectPtr and thus trivially supports
error reporting.

There's pkg-config file added and spec-file adjusted as well.

Since the library should be "minimalistic" and not depend on any other
library, the list of files is especially crafted for it.  Most of them
could've been put to it's own sub-libraries that would be LIBADD'd to
libvirt_util, libvirt_net_rpc and libvirt_setuid_rpc_client to minimize
the number of object files being built, but that's a refactoring that
isn't the orginal aim of this commit.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoAdd admin error domain
Martin Kletzander [Wed, 15 Apr 2015 14:17:11 +0000 (16:17 +0200)]
Add admin error domain

Just the addition of VIR_FROM_ADMIN to the enum of error domains.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoBuild client headers for admin protocol
Martin Kletzander [Thu, 16 Apr 2015 12:23:16 +0000 (14:23 +0200)]
Build client headers for admin protocol

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoAdd admin protocol
Martin Kletzander [Wed, 15 Apr 2015 14:13:22 +0000 (16:13 +0200)]
Add admin protocol

For now there are only CONNECT_OPEN and CONNECT_CLOSE procedures.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoTeach gendispatch how to handle admin dispatching files
Martin Kletzander [Tue, 17 Mar 2015 09:09:48 +0000 (10:09 +0100)]
Teach gendispatch how to handle admin dispatching files

Since this is just a new option for gendispatch, it looks more like a
cleanup.  The only differences handled by it are connect pointers,
private pointers and API naming customs.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agotests: Adapt virnetservertest to daemon refactor
Martin Kletzander [Thu, 11 Jun 2015 12:02:30 +0000 (14:02 +0200)]
tests: Adapt virnetservertest to daemon refactor

Rename the test to virnetdaemontest and use virNetDaemon objects instead
of virNetServer inside.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoMove daemon-related parts of virNetServer to virNetDaemon
Martin Kletzander [Mon, 16 Mar 2015 14:02:41 +0000 (15:02 +0100)]
Move daemon-related parts of virNetServer to virNetDaemon

This allows to have more servers in one daemon which helps isolating
some resources.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agolxc: properly clean up qemu-nbd
Cédric Bosdonnat [Tue, 26 May 2015 16:29:27 +0000 (18:29 +0200)]
lxc: properly clean up qemu-nbd

Add the qemu-nbd tasks to the container cgroup to make sure those will
be killed when the container is stopped. In order to reliably get the
qemu-nbd tasks PIDs, we use /sys/devices/virtual/block/<DEV>/pid as
qemu-nbd is daemonizing itself.

9 years agoAdd virProcessGetPids to get all tasks of a process
Cédric Bosdonnat [Mon, 1 Jun 2015 12:31:44 +0000 (14:31 +0200)]
Add virProcessGetPids to get all tasks of a process

This function gets all the PIDs listed in /proc/PID/task. This will be
needed at least to move all qmeu-nbd tasks to the container cgroup.

9 years agostorage: Generate correct parameters for CIFS
John Ferlan [Wed, 3 Jun 2015 14:20:56 +0000 (10:20 -0400)]
storage: Generate correct parameters for CIFS

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

When generating the path to the dir for a CIFS/Samba driver, the code
would generate a source path for the mount using "%s:%s" while the
mount.cifs expects to see "//%s/%s". So check for the cifsfs and
format the source path appropriately.

Additionally, since there is no means to authenticate, the mount
needs a "-o guest" on the command line in order to anonymously mount
the Samba directory.

9 years agostorage: Adjust command arglist for gluster
John Ferlan [Mon, 15 Jun 2015 21:20:32 +0000 (17:20 -0400)]
storage: Adjust command arglist for gluster

In order for the glusterfs boolean to be set, the pool->def->type must be
VIR_STORAGE_POOL_NETFS, thus the check within virCommandNewArgList whether
pool->def->type is VIR_STORAGE_POOL_FS will never be true, so remove it

9 years agostorage: Fix the schema and add tests for cifs pool
John Ferlan [Wed, 3 Jun 2015 15:43:00 +0000 (11:43 -0400)]
storage: Fix the schema and add tests for cifs pool

Commit id '887dd362' added support for a netfs pool format type 'cifs'
and 'gluster' in order to add rng support for Samba and glusterfs netfs
pools. Originally, the CIFS type support was added as part of commit
id '61fb6979'. Eventually commit id 'b325be12' fixed the gluster rng
definition to match expectations.

As it turns out the CIFS rng needed a similar change since the directory
path is not an absDirPath, rather just a dirPath will be required.

9 years agoconfigure: Remove check for pkcheck_supports_uid
Guido Günther [Fri, 5 Jun 2015 10:41:22 +0000 (12:41 +0200)]
configure: Remove check for pkcheck_supports_uid

We're using Polkit's DBus API so no need to check wether this feature is
supported. We don't use the result or the path to the pkcheck program
anywhere.

9 years agotests: Use libvirt properly with initialization and error dispatching
Martin Kletzander [Mon, 15 Jun 2015 08:41:17 +0000 (10:41 +0200)]
tests: Use libvirt properly with initialization and error dispatching

We were using "complicated" error printing in virnetservertest even
though we could've just dispatched the error.  Also add some good
practices that might come in handy (the code may fail without proper
initialization and event loop).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoGenerate JSON with mDNS entries only when built --with-avahi
Martin Kletzander [Mon, 15 Jun 2015 09:28:11 +0000 (11:28 +0200)]
Generate JSON with mDNS entries only when built --with-avahi

One string was already used only if that condition was true, second one
is added now.  Both are used in a nicer way.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agorpc: Fix possible crash when MDNSAddEntry fails
Martin Kletzander [Thu, 11 Jun 2015 11:58:43 +0000 (13:58 +0200)]
rpc: Fix possible crash when MDNSAddEntry fails

If virNetServerMDNSAddEntry() fails when adding a service to a server,
it doesn't decrease the number of services.  Hence access to their
members segfaults (e.g. when free()-ing the sruct).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agobuild: Remove unnecessarily repeated rules for syms -> def
Martin Kletzander [Thu, 21 May 2015 23:39:26 +0000 (16:39 -0700)]
build: Remove unnecessarily repeated rules for syms -> def

Suggested-by: Michal Prívozník <mprivozn@redhat.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: monitor: Add memory balloon support for virtio-ccw
Boris Fiuczynski [Wed, 10 Jun 2015 07:02:36 +0000 (09:02 +0200)]
qemu: monitor: Add memory balloon support for virtio-ccw

The search for the memory balloon driver object is extended by a
second known name "virtio-balloon-ccw" in support for virtio-ccw.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Daniel Hansel <daniel.hansel@linux.vnet.ibm.com>
Reviewed-by: Eric Farman <farman@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
9 years agoman: clarify usage of virsh blockcopy with --xml
Ján Tomko [Mon, 15 Jun 2015 12:08:05 +0000 (14:08 +0200)]
man: clarify usage of virsh blockcopy with --xml

The --xml option is mandatory if an XML description is used.
Otherwise the third parameter is treated as the destination.

https://bugzilla.redhat.com/show_bug.cgi?id=1206406#c3

9 years agoqemu: emulatorpin: Don't reset pinning when pinning to all cpus
Peter Krempa [Fri, 12 Jun 2015 13:53:05 +0000 (15:53 +0200)]
qemu: emulatorpin: Don't reset pinning when pinning to all cpus

Similarly to a02a161bb8a6caf0db4dd446ed1cdf53d97b40 remove the default
pinning assumption from emulatorpin.

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

9 years agogetOldStyleBlockDevice: Adjust formatting
Michal Privoznik [Mon, 15 Jun 2015 11:13:27 +0000 (13:13 +0200)]
getOldStyleBlockDevice: Adjust formatting

Instead of initializing return value to zero (success) and overwriting
it on every failure just before the control jumps onto 'out' label,
let's initialize to an error value and set to zero only when we are
sure about the success. Just follow the pattern we have in the rest of
the code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agogetNewStyleBlockDevice: Adjust formatting
Michal Privoznik [Mon, 15 Jun 2015 11:13:27 +0000 (13:13 +0200)]
getNewStyleBlockDevice: Adjust formatting

Instead of initializing return value to zero (success) and overwriting
it on every failure just before the control jumps onto 'out' label,
let's initialize to an error value and set to zero only when we are
sure about the success. Just follow the pattern we have in the rest of
the code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agostorage: Disallow wiping an extended disk partition
John Ferlan [Tue, 9 Jun 2015 22:15:39 +0000 (18:15 -0400)]
storage: Disallow wiping an extended disk partition

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

Check if the disk partition to be wiped is the extended partition, if
so then disallow it. Do this via changing the wipeVol backend to check
the volume before passing to the common virStorageBackendVolWipeLocal

9 years agoqemu caps: spell queue
Ján Tomko [Mon, 15 Jun 2015 08:38:21 +0000 (10:38 +0200)]
qemu caps: spell queue

9 years agoqemu: Do not support 'serial' scsi-block 'lun' devices
John Ferlan [Tue, 9 Jun 2015 20:49:00 +0000 (16:49 -0400)]
qemu: Do not support 'serial' scsi-block 'lun' devices

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

Seems the property has been deprecated for qemu, although seemingly ignored.

This patch enforces from a libvirt perspective that a scsi-block 'lun'
device should not provide the 'serial' property.

9 years agostorage: Need to set secrettype for direct iscsi disk volume
John Ferlan [Mon, 8 Jun 2015 22:41:28 +0000 (18:41 -0400)]
storage: Need to set secrettype for direct iscsi disk volume

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

Commit id '1b4eaa61' added the ability to have a mode='direct' for
an iscsi disk volume.  It relied on virStorageTranslateDiskSourcePool
in order to copy any disk source pool authentication information to
the direct disk volume, but it neglected to also copy the 'secrettype'
field which ends up being used in the domain volume formatting code.
Adding a secrettype for this case will allow for proper formatting later
and allow disk snapshotting to work properly

Additionally libvirtd restart processing would fail to find the domain
since the translation processing code is run after domain xml processing,
so handle the the case where the authdef could have an empty secrettype
field when processing the auth and additionally ignore performing the
actual and expected auth secret type checks for a DISK_VOLUME since that
data will be reassembled later during translation processing of the
running domain.

9 years agovirCapabilitiesDomainDataLookup: Produce saner error message
Michal Privoznik [Thu, 11 Jun 2015 14:15:46 +0000 (16:15 +0200)]
virCapabilitiesDomainDataLookup: Produce saner error message

During a review, I've noticed this error message that was eventually
produced when I was trying to define a domain:

error: invalid argument: could not find capabilities for arch=mips64el
domaintype=(null)

Look at the (null). Why is it there? Well, during XML parsing, we try
to look up the default emulator for given OS type and possibly virt
type too. And this is the problem, because if we don't want to look up
by virt type, a -1 is passed to note this fact. Later, the code
handles -1 just right. Except for error message. When it is
constructed (in a very fabulous way I must say), the value is compared
to zero, not -1. And since we don't have any translation from -1 to a
virt type string, we just print (null).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agolibxl: Add timestamp to the libxl driver log.
Anthony PERARD [Mon, 8 Jun 2015 17:05:06 +0000 (18:05 +0100)]
libxl: Add timestamp to the libxl driver log.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
9 years agoqemu: update netdevs of the same mac addrs correctly
zhang bo [Mon, 8 Jun 2015 08:25:10 +0000 (16:25 +0800)]
qemu: update netdevs of the same mac addrs correctly

If a guest has multiple network devices with the same MAC address,
when we online update the second device, libvirtd always updates
the first one.

commit def31e4c forgot to fix the online updating scenario. We need to
use virDomainNetFindIdx() to find the correct network device.

Signed-off-by: Zhou Yimin <zhouyimin@huawei.com>
Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
9 years agoscsi: Need to translate disk source pool in config attach path
John Ferlan [Thu, 11 Jun 2015 21:07:38 +0000 (17:07 -0400)]
scsi: Need to translate disk source pool in config attach path

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

When attaching a scsi volume lun via the attach-device --config or
--persistent options, there was no translation of the source pool
like there was for the live path, thus the attempt to modify the config
would fail since not enough was known about the disk.

9 years agovirsysinfo: s/system/sysdef/
Michal Privoznik [Fri, 12 Jun 2015 12:51:09 +0000 (14:51 +0200)]
virsysinfo: s/system/sysdef/

A variable can't be named system, obviously. Well, it can if the
compiler is new enough to distinguish a variable named system and a
function call system(). And some older systems, don't have wise
compiler.

  CC     util/libvirt_util_la-virsysinfo.lo
cc1: warnings being treated as errors
../../src/util/virsysinfo.c: In function 'virSysinfoParseSystem':
../../src/util/virsysinfo.c:649: error: declaration of 'system' shadows a global declaration [-Wshadow]
/usr/include/stdlib.h:717: error: shadowed declaration is here [-Wshadow]
make[3]: *** [util/libvirt_util_la-virsysinfo.lo] Error 1

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agocmdNetworkList: Introduce --name, --uuid, --table
Michal Privoznik [Mon, 8 Jun 2015 14:13:28 +0000 (16:13 +0200)]
cmdNetworkList: Introduce --name, --uuid, --table

When reviewing some network patches, I've noticed we don't have
those switches to the 'net-list' command. We should. They are
merely copied over from 'list' command.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agocmdNetworkList: switch to FILTER
Michal Privoznik [Mon, 8 Jun 2015 14:13:14 +0000 (16:13 +0200)]
cmdNetworkList: switch to FILTER

Instead of sticking to old code pattern use the one laid out by
cmdList. Use FILTER() macro instead of series of boolean
variables.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemuBuildDriveStr: s/virBufferEscapeString/virBufferAsprintf/
Michal Privoznik [Mon, 8 Jun 2015 13:42:44 +0000 (15:42 +0200)]
qemuBuildDriveStr: s/virBufferEscapeString/virBufferAsprintf/

We are using it to print a value that can't be NULL and does not need
any escaping anyway.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirQEMUCapsArch: openrisc vs or32
Michal Privoznik [Thu, 11 Jun 2015 14:26:45 +0000 (16:26 +0200)]
virQEMUCapsArch: openrisc vs or32

With a few exceptions, we assume that qemu binary for given
architecture has form of qemu-system-$arch. Well, openrisc is yet
another exception. It's binary is called qemu-system-or32.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirSysinfoDef: Exempt SYSTEM variables
Michal Privoznik [Tue, 12 May 2015 12:33:12 +0000 (14:33 +0200)]
virSysinfoDef: Exempt SYSTEM variables

Move all the system_* fields into a separate struct. Not only this
simplifies the code a bit it also helps us to identify whether BIOS
info is present. We don't have to check all the four variables for
being not-NULL, but we can just check the pointer to the struct.

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