]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
11 years agoqemu: allow filtering events by regex
Eric Blake [Thu, 6 Feb 2014 21:46:52 +0000 (14:46 -0700)]
qemu: allow filtering events by regex

When listening for a subset of monitor events, it can be tedious
to register for each event name in series; nicer is to register
for multiple events in one go.  Implement a flag to use regex
interpretation of the event filter.

While at it, prove how much I hate the shift key, by adding a
way to filter for 'shutdown' instead of 'SHUTDOWN'. :)

* include/libvirt/libvirt-qemu.h
(virConnectDomainQemuMonitorEventRegisterFlags): New enum.
* src/libvirt-qemu.c (virConnectDomainQemuMonitorEventRegister):
Document flags.
* tools/virsh-domain.c (cmdQemuMonitorEvent): Expose them.
* tools/virsh.pod (qemu-monitor-event): Document this.
* src/conf/domain_event.c
(virDomainQemuMonitorEventStateRegisterID): Add flags.
(virDomainQemuMonitorEventFilter): Handle regex, and optimize
client side.
(virDomainQemuMonitorEventCleanup): Clean up regex.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: enable monitor event filtering by name
Eric Blake [Fri, 31 Jan 2014 14:02:25 +0000 (07:02 -0700)]
qemu: enable monitor event filtering by name

Filtering monitor events by name requires tracking the name for
the duration of the filtering.  In order to free the name, I
found it easiest to just piggyback on the user's freecb function,
which gets called when the event is deregistered.

For events without a name filter, we have the design of multiple
client registrations sharing a common server registration, because
the server side uses the same callback function and we reject
duplicate use of the same function.  But with events in the mix,
we want to be able to allow the same function pointer to be used
with more than one event name.  The solution is to tweak the
duplicate detection code to only act when there is no additional
filtering; if name filtering is in use, there is exactly one
client registration per server registration.  Yes, this means
that there is no longer a bound on the number of server
registrations possible, so a malicious client could repeatedly
register for the same name event to exhaust server memory.  On
the other hand, we already restricted monitor events to require
write access (compared to normal events only needing read access),
and separated it into the intentionally unsupported
libvirt-qemu.so, with documentation that using this function is
for debug purposes only; so it is not a security risk worth
worrying about a client trying to abuse multiple registrations.

* src/conf/domain_event.c (virDomainQemuMonitorEventData): New
struct.
(virDomainQemuMonitorEventFilter)
(virDomainQemuMonitorEventCleanup): New functions.
(virDomainQemuMonitorEventDispatchFunc)
(virDomainQemuMonitorEventStateRegisterID): Use new struct.
* src/conf/object_event.c (virObjectEventCallbackListCount)
(virObjectEventCallbackListAddID)
(virObjectEventCallbackListRemoveID)
(virObjectEventCallbackListMarkDeleteID): Drop duplicate detection
when filtering is in effect.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: enable monitor event reporting
Eric Blake [Thu, 30 Jan 2014 00:14:44 +0000 (17:14 -0700)]
qemu: enable monitor event reporting

Wire up all the pieces to send arbitrary qemu events to a
client using libvirt-qemu.so.  If the extra bookkeeping of
generating event objects even when no one is listening turns
out to be noticeable, we can try to further optimize things
by adding a counter for how many connections are using events,
and only dump events when the counter is non-zero; but for
now, I didn't think it was worth the code complexity.

* src/qemu/qemu_driver.c
(qemuConnectDomainQemuMonitorEventRegister)
(qemuConnectDomainQemuMonitorEventDeregister): New functions.
* src/qemu/qemu_monitor.h (qemuMonitorEmitEvent): New prototype.
(qemuMonitorDomainEventCallback): New typedef.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONIOProcessEvent):
Report events.
* src/qemu/qemu_monitor.c (qemuMonitorEmitEvent): New function, to
pass events through.
* src/qemu/qemu_process.c (qemuProcessHandleEvent): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: wire up RPC for qemu monitor events
Eric Blake [Wed, 29 Jan 2014 22:30:44 +0000 (15:30 -0700)]
qemu: wire up RPC for qemu monitor events

These are the first async events in the qemu protocol, so this
patch looks rather big compared to most RPC additions.  However,
a large majority of this patch is just mechanical copy-and-paste
from recently-added network events.  It didn't help that this
is also the first virConnect rather than virDomain prefix
associated with a qemu-specific API.

* src/remote/qemu_protocol.x (qemu_*_domain_monitor_event_*): New
structs and RPC messages.
* src/rpc/gendispatch.pl: Adjust naming conventions.
* daemon/libvirtd.h (daemonClientPrivate): Track qemu events.
* daemon/remote.c (remoteClientFreeFunc): Likewise.
(remoteRelayDomainQemuMonitorEvent)
(qemuDispatchConnectDomainMonitorEventRegister)
(qemuDispatchConnectDomainMonitorEventDeregister): New functions.
* src/remote/remote_driver.c (qemuEvents): Handle qemu events.
(doRemoteOpen): Register for events.
(remoteNetworkBuildEventLifecycle)
(remoteConnectDomainQemuMonitorEventRegister)
(remoteConnectDomainQemuMonitorEventDeregister): New functions.
* src/qemu_protocol-structs: Regenerate.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: create object for qemu monitor events
Eric Blake [Tue, 31 Dec 2013 13:33:42 +0000 (06:33 -0700)]
qemu: create object for qemu monitor events

Create qemu monitor events as a distinct class to normal domain
events, because they will be filtered differently.  For ease of
review, the logic for filtering by event name is saved for a later
patch.

* src/conf/domain_event.c (virDomainQemuMonitorEventClass): New
class.
(virDomainEventsOnceInit): Register it.
(virDomainQemuMonitorEventDispose, virDomainQemuMonitorEventNew)
(virDomainQemuMonitorEventDispatchFunc)
(virDomainQemuMonitorEventStateRegisterID): New functions.
* src/conf/domain_event.h (virDomainQemuMonitorEventNew)
(virDomainQemuMonitorEventStateRegisterID): New prototypes.
* src/libvirt_private.syms (conf/domain_conf.h): Export them.

11 years agoqemu: virsh wrapper for qemu events
Eric Blake [Fri, 31 Jan 2014 23:52:17 +0000 (16:52 -0700)]
qemu: virsh wrapper for qemu events

Any new API deserves a good virsh wrapper :)

    qemu-monitor-event [<domain>] [<event>] [--pretty] [--loop] [--timeout <number>]

Very similar to the previous work on 'virsh event'.  For an
example session:

$ virsh -c qemu:///system qemu-monitor-event --event SHUTDOWN&
$ virsh -c qemu:///system start f18-live
Domain f18-live started

$ virsh -c qemu:///system destroy f18-live
Domain f18-live destroyed

event SHUTDOWN at 1391212552.026544 for domain f18-live: (null)
events received: 1

[1]+  Done                    virsh -c qemu:///system qemu-monitor-event --event SHUTDOWN
$

* tools/virsh-domain.c (cmdQemuMonitorEvent): New command.
* tools/virsh.pod (qemu-monitor-event): Document it.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: new API for tracking arbitrary monitor events
Eric Blake [Thu, 19 Dec 2013 14:06:35 +0000 (07:06 -0700)]
qemu: new API for tracking arbitrary monitor events

Several times in the past, qemu has implemented a new event,
but libvirt has not yet caught up to reporting that event to
the user applications.  While it is possible to track libvirt
logs to see that an unknown event was received and ignored,
it would be nicer to copy what 'virsh qemu-monitor-command'
does, and expose this information to the end developer as
one of our unsupported qemu-specific commands.

If you find yourself needing to use this API for more than
just development purposes, please ask on the libvirt list
for a supported counterpart event to be added in libvirt.so.

While the supported virConnectDomainEventRegisterAny() API
takes an id which determines the signature of the callback,
this version takes a string filter and always uses the same
signature.  Furthermore, I chose to expose this as a new API
instead of trying to add a new eventID at the top level, in
part because the generic option lacks event name filtering,
and in part because the normal domain event namespace should
not be polluted by a qemu-only event.  I also added a flags
argument; unused for now, but we might decide to use it to
allow a user to request event names by glob or regex instead
of literal match.

This API intentionally requires full write access (while
normal event registration is allowed on read-only clients);
this is in part due to the fact that it should only be used
by debugging situations, and in part because the design of
per-event filtering in later patches ended up allowing for
duplicate registrations that could potentially be abused to
exhaust server memory - requiring write privileges means
that such abuse will not serve as a denial of service attack
against users with higher privileges.

* include/libvirt/libvirt-qemu.h
(virConnectDomainQemuMonitorEventCallback)
(virConnectDomainQemuMonitorEventRegister)
(virConnectDomainQemuMonitorEventDeregister): New prototypes.
* src/libvirt-qemu.c (virConnectDomainQemuMonitorEventRegister)
(virConnectDomainQemuMonitorEventDeregister): New functions.
* src/libvirt_qemu.syms (LIBVIRT_QEMU_1.2.1): Export them.
* src/driver.h (virDrvConnectDomainQemuMonitorEventRegister)
(virDrvConnectDomainQemuMonitorEventDeregister): New callbacks.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoFix indentation in iscsi storage backend
Ján Tomko [Thu, 20 Mar 2014 12:23:42 +0000 (13:23 +0100)]
Fix indentation in iscsi storage backend

11 years agoIgnore missing files on pool refresh
Ján Tomko [Thu, 20 Mar 2014 15:35:00 +0000 (16:35 +0100)]
Ignore missing files on pool refresh

If we cannot stat/open a file on pool refresh, returning -1 aborts
the refresh and the pool is undefined.

Only treat missing files as fatal unless VolOpenCheckMode is called
with the VIR_STORAGE_VOL_OPEN_ERROR flag. If this flag is missing
(when it's called from virStorageBackendProbeTarget in
virStorageBackendFileSystemRefresh), only emit a warning and return
-2 to let the caller skip over the file.

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

11 years agoIgnore char devices in storage pools by default
Ján Tomko [Thu, 20 Mar 2014 15:42:52 +0000 (16:42 +0100)]
Ignore char devices in storage pools by default

Without this, using /dev/mapper as a directory pool
fails in virStorageBackendUpdateVolTargetInfoFD:
cannot seek to end of file '/dev/mapper/control': Illegal seek

Skip over character devices by default.

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

11 years agoAdd test for virISCSIScanTargets
Ján Tomko [Wed, 19 Mar 2014 13:02:09 +0000 (14:02 +0100)]
Add test for virISCSIScanTargets

11 years agoAdd test for virISCSIGetSession
Ján Tomko [Fri, 21 Feb 2014 09:59:10 +0000 (10:59 +0100)]
Add test for virISCSIGetSession

Parse iscsiadm output with and without the recently introduced
flashnode info. [1]

This should check that commits like 57e17a7 (fixing [2]) do
not break iscsiadm output parsing.

[1] https://github.com/mikechristie/open-iscsi/commit/181af9a
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1067173

11 years agoMove functions using iscsiadm to viriscsi.c
Ján Tomko [Wed, 19 Mar 2014 15:03:11 +0000 (16:03 +0100)]
Move functions using iscsiadm to viriscsi.c

Remove the 'StorageBackend' from names of the functions and fix
indentation.

11 years agoRemove storage pool from the arguments of a few functions
Ján Tomko [Wed, 19 Mar 2014 14:54:08 +0000 (15:54 +0100)]
Remove storage pool from the arguments of a few functions

virStorageBackendISCSISession only needs the path of the source
device and virStorageBackendISCSIRescanLUNs doesn't need the pool
at all.

This will allow the functions to be moved to src/util.

11 years agoDon't create iscsiadm command line in ISCSIPool{Start,Stop}
Ján Tomko [Wed, 19 Mar 2014 14:52:51 +0000 (15:52 +0100)]
Don't create iscsiadm command line in ISCSIPool{Start,Stop}

Create ISCSIConnection{Login,Logout} wrappers for that.

11 years agoSwitch virCommandRunRegex to use virStringSplit
Ján Tomko [Wed, 19 Mar 2014 12:16:13 +0000 (13:16 +0100)]
Switch virCommandRunRegex to use virStringSplit

Instead of running the command asynchronously and reading the output
via fgets, let virCommand collect the output and split it with
virStringSplit.

11 years agoMove virStorageBackendRun to vircommand
Ján Tomko [Tue, 18 Mar 2014 14:35:01 +0000 (15:35 +0100)]
Move virStorageBackendRun to vircommand

The only storage-specific parameter is the pool object, which
is only used for passing to the callback function.

11 years agoSort includes in storage_backend_iscsi.c
Ján Tomko [Tue, 18 Mar 2014 15:20:01 +0000 (16:20 +0100)]
Sort includes in storage_backend_iscsi.c

11 years agoRequire K&R styled curly braces around function bodies
Martin Kletzander [Fri, 20 Sep 2013 15:56:38 +0000 (17:56 +0200)]
Require K&R styled curly braces around function bodies

Although not explicitly requested, we are using K&R (or Kernel)
indentation for curly braces around functions in HACKING file and most
of the code.  Using grep -P, this patch add the syntax-check rule for
it (while skipping all the false positives with foreach constructs).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoUse K&R style for curly braces in remaining files
Martin Kletzander [Tue, 18 Mar 2014 08:19:33 +0000 (09:19 +0100)]
Use K&R style for curly braces in remaining files

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoUse K&R style for curly braces in src/vbox/
Martin Kletzander [Tue, 18 Mar 2014 08:18:32 +0000 (09:18 +0100)]
Use K&R style for curly braces in src/vbox/

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoUse K&R style for curly braces in src/network/bridge_driver.c
Martin Kletzander [Tue, 18 Mar 2014 08:18:16 +0000 (09:18 +0100)]
Use K&R style for curly braces in src/network/bridge_driver.c

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoUse K&R style for curly braces in src/lxc/lxc_driver.c
Martin Kletzander [Tue, 18 Mar 2014 08:18:09 +0000 (09:18 +0100)]
Use K&R style for curly braces in src/lxc/lxc_driver.c

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoUse K&R style for curly braces in src/uml/
Martin Kletzander [Tue, 18 Mar 2014 08:17:39 +0000 (09:17 +0100)]
Use K&R style for curly braces in src/uml/

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoUse K&R style for curly braces in src/test/test_driver.c
Martin Kletzander [Tue, 18 Mar 2014 08:17:30 +0000 (09:17 +0100)]
Use K&R style for curly braces in src/test/test_driver.c

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoUse K&R style for curly braces in src/nwfilter/
Martin Kletzander [Tue, 18 Mar 2014 08:16:54 +0000 (09:16 +0100)]
Use K&R style for curly braces in src/nwfilter/

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoUse K&R style for curly braces in src/openvz/
Martin Kletzander [Tue, 18 Mar 2014 08:16:47 +0000 (09:16 +0100)]
Use K&R style for curly braces in src/openvz/

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoUse K&R style for curly braces in src/storage/
Martin Kletzander [Tue, 18 Mar 2014 08:15:36 +0000 (09:15 +0100)]
Use K&R style for curly braces in src/storage/

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoUse K&R style for curly braces in src/qemu/
Martin Kletzander [Tue, 18 Mar 2014 08:15:21 +0000 (09:15 +0100)]
Use K&R style for curly braces in src/qemu/

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoUse K&R style for curly braces in src/conf/
Martin Kletzander [Tue, 18 Mar 2014 08:15:05 +0000 (09:15 +0100)]
Use K&R style for curly braces in src/conf/

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoUse K&R style for curly braces in src/rpc/
Martin Kletzander [Tue, 18 Mar 2014 08:14:54 +0000 (09:14 +0100)]
Use K&R style for curly braces in src/rpc/

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoUse K&R style for curly braces in src/util/
Martin Kletzander [Tue, 18 Mar 2014 08:14:35 +0000 (09:14 +0100)]
Use K&R style for curly braces in src/util/

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoUse K&R style for curly braces in src/xen*/
Martin Kletzander [Tue, 18 Mar 2014 08:14:16 +0000 (09:14 +0100)]
Use K&R style for curly braces in src/xen*/

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoUse K&R style for curly braces in tests/
Martin Kletzander [Tue, 18 Mar 2014 08:13:43 +0000 (09:13 +0100)]
Use K&R style for curly braces in tests/

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agois_selinux_enabled() returns -1 on error, account for this.
Scott Sullivan [Thu, 20 Mar 2014 15:05:14 +0000 (16:05 +0100)]
is_selinux_enabled() returns -1 on error, account for this.

Per the documentation, is_selinux_enabled() returns -1 on error.
Account for this. Previously when -1 was being returned the condition
would still be true. I was noticing this because on my system that has
selinux disabled I was getting this in the libvirt.log every 5
seconds:

error : virIdentityGetSystem:173 : Unable to lookup SELinux process context: Invalid argument

With this patch applied, I no longer get these messages every 5
seconds. I am submitting this in case its deemed useful for inclusion.
Anyone have any comments on this change? This is a patch off current
master.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agobhyve: host API support
Wojciech Macek [Thu, 20 Mar 2014 08:39:23 +0000 (09:39 +0100)]
bhyve: host API support

New functionalities:
- connectGetMaxVcpus - on bhyve hardcode this value to 16
- nodeGetFreeMemory - do not use physmem_get on FreeBSD, since
                      it might get wrong value on systems with
                      more than 100GB of RAM
- nodeGetCPUMap - wrapper only for mapping function, currently not
                  supported by FreeBSD
- nodeSet/GetMemoryParameters - wrapper only for future improvements,
                                currently not supported by FreeBSD

11 years agoFix unitialized data in virSocketAddrMask
Daniel P. Berrange [Thu, 20 Mar 2014 10:31:37 +0000 (10:31 +0000)]
Fix unitialized data in virSocketAddrMask

The virSocketAddrMask method did not initialize all fields
in the sockaddr_in6 struct. In paticular the 'sin6_scope_id'
field could contain random garbage, which would in turn
affect the result of any later virSocketAddrFormat calls.
This led to ip6tables rules in the FORWARD chain which
matched on random garbage sin6_scope_id. Fortunately these
were ACCEPT rules, so the impact was merely that desired
traffic was blocked, rather than undesired traffic allowed.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix virQEMUCapsLoadCache leaks
Ján Tomko [Wed, 19 Mar 2014 16:13:19 +0000 (17:13 +0100)]
Fix virQEMUCapsLoadCache leaks

Valgrind reported leaking of maxCpus and arch strings from
virXPathString, as well as the leak of the machineMaxCpus array.

Don't use 'str' for the strings we don't want to free, to allow
freeing of 'str' in the cleanup label and free machineMaxCpus
in virCapsReset too.

11 years agodaemon: Enhance documentation for changing NOFILE limit
Jiri Denemark [Mon, 10 Feb 2014 14:17:05 +0000 (15:17 +0100)]
daemon: Enhance documentation for changing NOFILE limit

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agolibxl: move domain event handler to libxl_domain
Jim Fehlig [Wed, 26 Feb 2014 22:50:57 +0000 (15:50 -0700)]
libxl: move domain event handler to libxl_domain

Move the domain event handler and shutdown thread out of the main
driver module and into libxl_domain module

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
11 years agolibxl: include a pointer to the driver in libxlDomainObjPrivate
Jim Fehlig [Wed, 26 Feb 2014 22:43:37 +0000 (15:43 -0700)]
libxl: include a pointer to the driver in libxlDomainObjPrivate

Include a pointer to the libxl driver in libxlDomainObjPrivate
object so it can be used in the domain event handler and
shutdown thread.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
11 years agolibxl: move libxlVmStart to libxl_domain
Jim Fehlig [Wed, 26 Feb 2014 21:11:30 +0000 (14:11 -0700)]
libxl: move libxlVmStart to libxl_domain

Move libxlVmStart from libxl_driver to libxl_domain for
use by other libxl modules.  For consistency, rename to
libxlDomainStart.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
11 years agolibxl: move libxlFreeMem to libxl_domain
Jim Fehlig [Wed, 26 Feb 2014 20:51:36 +0000 (13:51 -0700)]
libxl: move libxlFreeMem to libxl_domain

Move libxlFreeMem from libxl_driver to libxl_domain for
use by other libxl modules.  For consistency, rename to
libxlDomainFreeMem.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
11 years agolibxl: move libxlDomainSetVcpuAffinities to libxl_domain
Jim Fehlig [Wed, 26 Feb 2014 20:48:11 +0000 (13:48 -0700)]
libxl: move libxlDomainSetVcpuAffinities to libxl_domain

Move libxlDomainSetVcpuAffinities from libxl_driver to libxl_domain
for use by other libxl modules.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
11 years agolibxl: move libxlDoNodeGetInfo to libxl_conf
Jim Fehlig [Wed, 26 Feb 2014 20:44:09 +0000 (13:44 -0700)]
libxl: move libxlDoNodeGetInfo to libxl_conf

Move libxlDoNodeGetInfo from libxl_driver to libxl_conf
for use by other libxl modules.  For consistency, rename to
libxlDriverNodeGetInfo.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
11 years agolibxl: move libxlDomainAutoCoreDump to libxl_domain
Jim Fehlig [Wed, 26 Feb 2014 19:33:46 +0000 (12:33 -0700)]
libxl: move libxlDomainAutoCoreDump to libxl_domain

Move libxlDomainAutoCoreDump from libxl_driver to libxl_domain
for use by other libxl modules.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
11 years agolibxl: move libxlDomEventsRegister to libxl_domain
Jim Fehlig [Wed, 26 Feb 2014 19:28:44 +0000 (12:28 -0700)]
libxl: move libxlDomEventsRegister to libxl_domain

Move libxlDomEventsRegister from libxl_driver to libxl_domain for
use by other libxl modules.  For consistency, rename to
libxlDomainEventsRegister.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
11 years agolibxl: move libxlVmCleanup{,Job} to libxl_domain
Jim Fehlig [Wed, 26 Feb 2014 19:04:34 +0000 (12:04 -0700)]
libxl: move libxlVmCleanup{,Job} to libxl_domain

Move libxlVmCleanup and libxlVmCleanupJob from libxl_driver to
libxl_domain for use by other libxl modules.  For consistency,
rename to libxlDomainCleanup and libxlDomainCleanupJob.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
11 years agolibxl: move libxlSaveImageOpen to libxl_domain
Jim Fehlig [Wed, 26 Feb 2014 04:28:51 +0000 (21:28 -0700)]
libxl: move libxlSaveImageOpen to libxl_domain

Move libxlSaveImageOpen from libxl_driver to libxl_domain for
use by other libxl modules.  For consistency, rename to
libxlDomainSaveImageOpen.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
11 years agolibxl: move libxlDomainManagedSavePath to libxl_domain
Jim Fehlig [Wed, 26 Feb 2014 03:55:47 +0000 (20:55 -0700)]
libxl: move libxlDomainManagedSavePath to libxl_domain

Move libxlDomainManagedSavePath from libxl_driver to libxl_domain
for use by other libxl modules.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
11 years agolibxl: move libxlDomainEventQueue to libxl_domain
Jim Fehlig [Wed, 26 Feb 2014 01:51:52 +0000 (18:51 -0700)]
libxl: move libxlDomainEventQueue to libxl_domain

Move libxlDomainEventQueue from libxl_driver to libxl_domain for
use by other libxl modules.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
11 years agovirNetClientSetTLSSession: Restore original signal mask
Michal Privoznik [Wed, 19 Mar 2014 17:10:34 +0000 (18:10 +0100)]
virNetClientSetTLSSession: Restore original signal mask

Currently, we use pthread_sigmask(SIG_BLOCK, ...) prior to calling
poll(). This is okay, as we don't want poll() to be interrupted.
However, then - immediately as we fall out from the poll() - we try to
restore the original sigmask - again using SIG_BLOCK. But as the man
page says, SIG_BLOCK adds signals to the signal mask:

SIG_BLOCK
      The set of blocked signals is the union of the current set and the set argument.

Therefore, when restoring the original mask, we need to completely
overwrite the one we set earlier and hence we should be using:

SIG_SETMASK
      The set of blocked signals is set to the argument set.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agonwfilter: Fix double free of pointer
Stefan Berger [Wed, 19 Mar 2014 17:38:44 +0000 (13:38 -0400)]
nwfilter: Fix double free of pointer

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

Commit 49b59a15 fixed one problem but masks another one related to pointer
freeing.

Avoid putting of the virNWFilterSnoopReq once the thread has been started.
It belongs to the thread and the thread will call virNWFilterSnoopReqPut() on it.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
11 years agodomiftune: Reword bandwidth clearing paragraph
Michal Privoznik [Wed, 19 Mar 2014 10:25:03 +0000 (11:25 +0100)]
domiftune: Reword bandwidth clearing paragraph

s/of value/value of/

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoconf: consistent comments about disk enum usage
Eric Blake [Wed, 19 Mar 2014 15:09:02 +0000 (09:09 -0600)]
conf: consistent comments about disk enum usage

Before refactoring this struct, I found it helpful to track which
'int' fields really contain an enum value.

* src/conf/domain_conf.h (_virDomainDiskDef): Add comments.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: Make sure src/util/virprobe.h is distributed
Jiri Denemark [Wed, 19 Mar 2014 13:46:01 +0000 (14:46 +0100)]
build: Make sure src/util/virprobe.h is distributed

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoqemuhotplugtest: Fix mem-leaking testcases
Nehal J Wani [Tue, 18 Mar 2014 23:08:12 +0000 (04:38 +0530)]
qemuhotplugtest: Fix mem-leaking testcases

While running qemuhotplugtest, it was found that valgrind pointed out
the following memory leak:

==7906== 5 bytes in 1 blocks are definitely lost in loss record 7 of 121
==7906==    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==7906==    by 0x3E782A754D: xmlStrndup (in /usr/lib64/libxml2.so.2.7.6)
==7906==    by 0x4CDAE03: virDomainDeviceInfoParseXML.isra.32 (domain_conf.c:3685)
==7906==    by 0x4CE3BB9: virDomainNetDefParseXML (domain_conf.c:6707)
==7906==    by 0x4CFBA08: virDomainDefParseXML (domain_conf.c:12235)
==7906==    by 0x4CFBC1E: virDomainDefParseNode (domain_conf.c:13039)
==7906==    by 0x4CFBD95: virDomainDefParse (domain_conf.c:12981)
==7906==    by 0x41FEB4: testQemuHotplug (qemuhotplugtest.c:66)
==7906==    by 0x420F41: virtTestRun (testutils.c:201)
==7906==    by 0x41F287: mymain (qemuhotplugtest.c:422)
==7906==    by 0x4216BD: virtTestMain (testutils.c:784)
==7906==    by 0x3E6CE1ED1C: (below main) (libc-start.c:226)
...and 10 more.

Problem is, since 20745748 we do both, parse <alias/> elements from
XML files and call qemuAssignDeviceAliases(). While generating runtime
info for domain at runtime is just fine in the test, we can parse just
inactive XML and remove all <alias/>-es from the XML files.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agobuild: Fix make distcheck
Martin Kletzander [Wed, 19 Mar 2014 13:27:08 +0000 (14:27 +0100)]
build: Fix make distcheck

I forgot to delete the underscore in object_locking_SOURCES when
changing the name in one of previous cleanups.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agobuild: Fix build with old automake
Jiri Denemark [Fri, 14 Mar 2014 10:35:46 +0000 (11:35 +0100)]
build: Fix build with old automake

Ancient automake (such as from RHEL5) does not provide abs_srcdir and
abs_builddir variables which are used by a recent commit of mine
(e562e82).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
11 years agoAdd ability to register callback for virCommand dry run
Daniel P. Berrange [Fri, 7 Mar 2014 11:39:48 +0000 (11:39 +0000)]
Add ability to register callback for virCommand dry run

To allow for fault injection of the virCommand dry run,
add the ability to register a callback. The callback will
be passed the argv, env and stdin buffer and is expected
to return the exit status and optionally fill stdout and
stderr buffers.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoChange CMD_STOPONERR(1) to use true
Daniel P. Berrange [Fri, 14 Mar 2014 16:01:57 +0000 (16:01 +0000)]
Change CMD_STOPONERR(1) to use true

The CMD_STOPONERR macro uses its parameter as a boolean, so should
be passed true rather than 1.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoChange 'int isTempChain' to bool in nwfilter
Daniel P. Berrange [Fri, 14 Mar 2014 16:00:49 +0000 (16:00 +0000)]
Change 'int isTempChain' to bool in nwfilter

The 'int isTempChain' parameter to various nwfilter methods
only takes two values so should be a bool type.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove pointless return values in nwfilter methods
Daniel P. Berrange [Fri, 14 Mar 2014 13:39:51 +0000 (13:39 +0000)]
Remove pointless return values in nwfilter methods

Many nwfilter methods have an int return value but only ever
return 0 and their callers never check the return value either.
These methods can all be void.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove 'int stopOnError' parameters in nwfilter methods
Daniel P. Berrange [Fri, 14 Mar 2014 13:31:57 +0000 (13:31 +0000)]
Remove 'int stopOnError' parameters in nwfilter methods

Many nwfilter methods have an 'int stopOnError' parameter but
with 1 exception, the callers always pass '1'. The parameter
can therefore be removed from all except one method. That method
will be changed to 'bool stopOnError'

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRemove pointless brackets around boolean
Daniel P. Berrange [Fri, 14 Mar 2014 13:24:28 +0000 (13:24 +0000)]
Remove pointless brackets around boolean

A lot of methods have a 'bool incoming' parameter but then
do  (incoming) ? ... : .... The round brackets here add nothing
to the code so can be removed.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoChange 'int incoming' to 'bool incoming' in nwfilter code
Daniel P. Berrange [Fri, 14 Mar 2014 13:21:52 +0000 (13:21 +0000)]
Change 'int incoming' to 'bool incoming' in nwfilter code

Many methods in the nwfilter code have an 'int incoming' parameter
that only takes 0 or 1, so should use a bool instead.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agovirhostdev.h: remove ATTRIBUTE_NONNULL from oldStateDir
Chunyan Liu [Wed, 19 Mar 2014 03:17:22 +0000 (11:17 +0800)]
virhostdev.h: remove ATTRIBUTE_NONNULL from oldStateDir

In libxl driver oldStateDir is NULL when calling
virHostdevReAttachDomainHostdevs. This is allowed.
Remove ATTRIBUTE_NONNULL setting from oldStateDir.

Introduced by commit 6225cb3.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
11 years agolibxl: fix framebuffer port setting for HVM domains
Jim Fehlig [Mon, 17 Mar 2014 20:22:44 +0000 (14:22 -0600)]
libxl: fix framebuffer port setting for HVM domains

libxl uses the libxl_vnc_info and libxl_sdl_info fields from the
hvm union in libxl_domain_build_info struct when generating QEMU
args for VNC or SDL.  These fields were left unset by the libxl
driver, causing libxl to ignore any user settings.  E.g. with

  <graphics type='vnc' port='5950'/>

port would be ignored and QEMU would instead be invoked with

  -vnc 127.0.0.1:0,to=99

Unlike the libxl_domain_config struct, the libxl_domain_build_info
contains only a single libxl_vnc_info and libxl_sdl_info, so
populate these fields from the first vfb in
libxl_domain_config->vfbs.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Signed-off-by: David Kiarie <davidkiarie4@gmail.com>
11 years agomaint: avoid unbalanced {} across vbox #ifdef
Eric Blake [Tue, 18 Mar 2014 20:10:27 +0000 (14:10 -0600)]
maint: avoid unbalanced {} across vbox #ifdef

Emacs is fairly good about navigating across function and scope
boundaries, provided that the code has balanced {}.  The vbox
code, however, violated that premise, by splitting 'if () {'
across several #ifdef branches, but sharing the '} else {...}'
outside of the branches.  The extra lines of code is worth my
sanity, in a function that is already a horrendous 1100+ lines
long.

* src/vbox/vbox_tmpl.c (vboxDomainGetXMLDesc) Duplicate code
rather than trying to share else branch across #ifdef.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoRemove global log buffer feature entirely
Daniel P. Berrange [Mon, 3 Mar 2014 14:54:33 +0000 (14:54 +0000)]
Remove global log buffer feature entirely

A earlier commit changed the global log buffer so that it only
records messages that are explicitly requested via the log
filters setting. This removes the performance burden, and
improves the signal/noise ratio for messages in the global
buffer. At the same time though, it is somewhat pointless, since
all the recorded log messages are already going to be sent to an
explicit log output like syslog, stderr or the journal. The
global log buffer is thus just duplicating this data on stderr
upon crash.

The log_buffer_size config parameter is left in the augeas
lens to prevent breakage for users on upgrade. It is however
completely ignored hereafter.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoSwitch to filtering based on log source name instead of filename
Daniel P. Berrange [Fri, 28 Feb 2014 13:55:11 +0000 (13:55 +0000)]
Switch to filtering based on log source name instead of filename

Currently the log filter strings are used in a string comparison
against the source filename each time log message is emitted.
If no log filters at all are set, there's obviously no string
comparison to be done. If any single log filter is set though,
this imposes a compute burden on every logging call even if logs
from the file in question are disabled. This string comparison
must also be done while the logging mutex is held, which has
implications for concurrency when multiple threads are emitting
log messages.

This changes the log filtering to be done based on the virLogSource
object name. The virLogSource struct is extended to contain
'serial' and 'priority' fields. Any time the global log filter
rules are changed a global serial number is incremented. When a
log message is emitted, the serial in the virLogSource instance
is compared with the global serial number. If out of date, then
the 'priority' field in the virLogSource instance is updated based
on the new filter rules. The 'priority' field is checked to see
whether the log message should be sent to the log outputs.

The comparisons of the 'serial' and 'priority' fields are done
with no locks held. So in the common case each logging call has
an overhead of 2 integer comparisons, with no locks held. Only
if the decision is made to forward the message to the log output,
or if the 'serial' value is out of date do locks need to be
acquired.

Technically the comparisons of the 'serial' and 'priority' fields
should be done with locks held, or using atomic operations. Both
of these options have a notable performance impact, however, and
since all writes a protected by a global mutex, it is believed
that worst case behaviour where the fields are read concurrently
with being written would merely result in an mistaken emission
or dropping of the log message in question. This is an acceptable
tradeoff for the performance benefit of avoiding locking.

As a quick benchmark, a demo program that registers 500 file
descriptors with the event loop (eg equiv of 500 QEMU monitor
commands), creates pending read I/O on every FD, and then runs
virEventRunDefaultImpl() took 4.6 seconds to do 51200 iterations.
After this optimization it only takes 3.3 seconds, with the log
APIs no longer being a relevant factor in the running time.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd virLogSource variables to all source files
Daniel P. Berrange [Fri, 28 Feb 2014 12:16:17 +0000 (12:16 +0000)]
Add virLogSource variables to all source files

Any source file which calls the logging APIs now needs
to have a VIR_LOG_INIT("source.name") declaration at
the start of the file. This provides a static variable
of the virLogSource type.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoTurn virLogSource into a struct instead of an enum
Daniel P. Berrange [Thu, 27 Feb 2014 17:44:53 +0000 (17:44 +0000)]
Turn virLogSource into a struct instead of an enum

As part of the goal to get away from doing string matching on
filenames when deciding whether to emit a log message, turn
the virLogSource enum into a struct which contains a log
"name". There will eventually be one virLogSource instance
statically declared per source file. To minimise churn in this
commit though, a single global instance is used.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoMove dtrace probe macros into separate header file
Daniel P. Berrange [Thu, 27 Feb 2014 13:41:11 +0000 (13:41 +0000)]
Move dtrace probe macros into separate header file

The dtrace probe macros rely on the logging API. We can't make
the internal.h header include the virlog.h header though since
that'd be a circular include. Instead simply split the dtrace
probes into their own header file, since there's no compelling
reason for them to be in the main internal.h header.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoRefactor code that skips logging of error messages
Daniel P. Berrange [Mon, 3 Mar 2014 18:29:33 +0000 (18:29 +0000)]
Refactor code that skips logging of error messages

The error reporting code will invoke a callback when any error
is raised and the default callback will print to stderr. The
virRaiseErrorFull method also sends all error messages on to the
logging code, which also prints to stderr by default. To avoid
duplicated data on stderr, the logging code has some logic to
skip emission when no log outputs are configured, which checks
whether the virLogSource == VIR_LOG_FROM_ERROR.

Meanwhile the libvirtd daemon can register another callback which
is used to reduce log message priority from error to a lower level.
When this is used we do want messages to end up on stderr, so the
error code will conditionally use either VIR_LOG_FROM_FILE or
VIR_LOG_FROM_ERROR depending on whether such a callback is provided.

This will all complicate later refactoring. By pushing the checks
for whether a log output is present up a level into the error code,
the special cases can be isolated in one place.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoReduce performance overhead of the global log buffer
Daniel P. Berrange [Mon, 24 Feb 2014 17:22:14 +0000 (17:22 +0000)]
Reduce performance overhead of the global log buffer

With the vast number of log debug statements in the code, the
logging framework has a measurable performance impact on libvirt
code, particularly in the daemon event loop.

The global log buffer records every single log message triggered
whether anyone cares to see them or not. This makes it impossible
to eliminate the overhead of printf format expansions in any of
the logging code. It is possible to disable the global log buffer
in libvirtd itself, but this doesn't help client side library
code. Also even if disabled by the config file, the existence of
the feature makes other performance improvements in the logging
layer impossible.

Instead of logging every single message to the global buffer, only
log messages that pass the log filters. This if libvirtd is set
to have log_filters="1:libvirt 1:qemu" the global log buffer will
only get filled with those messages instead of everything. This
reduces the performance burden, as well as improving the signal
to noise ratio of the log buffer.

As a quick benchmark, a demo program that registers 500 file
descriptors with the event loop (eg equiv of 500 QEMU monitor
commands), creates pending read I/O on every FD, and then runs
virEventRunDefaultImpl() took 1 minute 40 seconds to do 51200
iterations with nearly all the time shown against the logging
code. After this optimization it only takes 4.6 seconds.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agovirNetServerNewPostExecRestart: Initialize @max_anonymous_clients
Michal Privoznik [Tue, 18 Mar 2014 10:04:27 +0000 (11:04 +0100)]
virNetServerNewPostExecRestart: Initialize @max_anonymous_clients

Coverity spotted a use of possibly undefined variable. If a server is
restarting as an result of update, the JSON file that keeps current
value of some variables will not contain the new variables. This is
the case of @max_anonymous_clients too. We are correctly querying if
there's "max_anonymous_clients" in the JSON, however, we are not
setting a sane default if there's none.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agoqemuDomainSetInterfaceParameters: Allow bandwidth clear out
Michal Privoznik [Tue, 18 Mar 2014 09:50:02 +0000 (10:50 +0100)]
qemuDomainSetInterfaceParameters: Allow bandwidth clear out

We allow translation from no_bandwidth to has_bandwidth for a vnic.
However, going in the opposite direction is not implemented. It's not
limitation of the API rather than internal implementation. The problem
is, we correctly detect that user hasn't specified any outbound (say
he wants to clear out outbound). However, this gets overwritten by
current vnic outbound settings. Then, virNetDevBandwidthSet doesn't
change anything. We need to stop overwriting the outbound if users
don't want us to. Same applies for inbound.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agocfg.mk: Fix whitespaces
Martin Kletzander [Tue, 18 Mar 2014 12:19:21 +0000 (13:19 +0100)]
cfg.mk: Fix whitespaces

Just to align the backslashes with most of the file.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoRemove double space in file name comment check
Ján Tomko [Tue, 18 Mar 2014 12:15:31 +0000 (13:15 +0100)]
Remove double space in file name comment check

Reported by Martin Kletzander

11 years agoDon't leave empty first line in C source files
Martin Kletzander [Fri, 7 Mar 2014 15:47:37 +0000 (16:47 +0100)]
Don't leave empty first line in C source files

If there should be some sort of separator it is better to use comment
with the filename, copyright, description, license information and
authors.

Found by:

git grep -nH '^$' | grep '\.[ch]:1:'

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoExplicitly cast some switch parameters to enum
Martin Kletzander [Fri, 7 Mar 2014 16:21:51 +0000 (17:21 +0100)]
Explicitly cast some switch parameters to enum

This patch is not trying to fix every switch, just the ones I worked
with last time, because some of these were especially unreadable.
Covers enums virDomainGraphicsType and virDomainChrType (where
applicable).

Also sort its cases by their value.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoRequire spaces around equality comparisons
Martin Kletzander [Mon, 17 Mar 2014 09:38:38 +0000 (10:38 +0100)]
Require spaces around equality comparisons

Commit a1cbe4b5 added a check for spaces around assignments and this
patch extends it to checks for spaces around '=='.  One exception is
virAssertCmpInt where comma after '==' is acceptable (since it is a
macro and '==' is its argument).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoRemove duplicate network model characters
Martin Kletzander [Mon, 17 Mar 2014 09:37:23 +0000 (10:37 +0100)]
Remove duplicate network model characters

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agotests: cleanup object-locking test
Martin Kletzander [Thu, 13 Feb 2014 14:20:04 +0000 (15:20 +0100)]
tests: cleanup object-locking test

When ran, cil is throwing out some errors and warnings for obsolete
'or' unused variables and wrong module name (it should not contain a
hyphen; hence the rename).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoqemu: agent availability cleanup
Martin Kletzander [Thu, 27 Feb 2014 10:45:13 +0000 (11:45 +0100)]
qemu: agent availability cleanup

Eliminate all the code re-use which checks for priv->agentError or
priv->agent.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agoFix memory leak in virDomainChrSourceDefClear()
Nehal J Wani [Tue, 18 Mar 2014 07:32:24 +0000 (13:02 +0530)]
Fix memory leak in virDomainChrSourceDefClear()

While running qemuxml2xmltest, it was found that valgrind pointed out
the following memory leak:

==21905== 26 bytes in 1 blocks are definitely lost in loss record 23 of 69
==21905==    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==21905==    by 0x3E782A754D: xmlStrndup (in /usr/lib64/libxml2.so.2.7.6)
==21905==    by 0x4CD986D: virDomainChrSourceDefParseXML (domain_conf.c:7233)
==21905==    by 0x4CE4199: virDomainChrDefParseXML (domain_conf.c:7512)
==21905==    by 0x4CFAF3F: virDomainDefParseXML (domain_conf.c:12303)
==21905==    by 0x4CFB46E: virDomainDefParseNode (domain_conf.c:13031)
==21905==    by 0x4CFB5E9: virDomainDefParse (domain_conf.c:12973)
==21905==    by 0x41E9D8: testCompareXMLToXMLFiles (qemuxml2xmltest.c:40)
==21905==    by 0x41EBAA: testCompareXMLToXMLHelper (qemuxml2xmltest.c:93)
==21905==    by 0x421D21: virtTestRun (testutils.c:199)
==21905==    by 0x41FCE9: mymain.part.0 (qemuxml2xmltest.c:244)
==21905==    by 0x42249D: virtTestMain (testutils.c:782)
==21905==
... and 7 more

11 years agovirsh: Prohibit virConnectOpen* functions in virsh
Martin Kletzander [Fri, 7 Mar 2014 10:15:39 +0000 (11:15 +0100)]
virsh: Prohibit virConnectOpen* functions in virsh

Addition of vshConnect() makes virConnectOpen() functions obsolete in
virsh.  Thus all virsh-*.[ch] files should be left only with
vshConnect() in the case of need.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agovirsh: Add keepalive in new vshConnect function
Martin Kletzander [Thu, 6 Mar 2014 16:20:11 +0000 (17:20 +0100)]
virsh: Add keepalive in new vshConnect function

Introducing keepalive similarly to Guannan around 2 years ago.  Since
we want to introduce keepalive for every connection, it makes sense to
wrap the connecting function into new virsh one that can deal
keepalive as well.

Function vshConnect() is now used for connecting and keepalive added
in that function (if possible) helps preventing long waits e.g. while
nework goes down during migration.

This patch also adds the options for keepalive tuning into virsh and
fails connecting only when keepalives are explicitly requested and
cannot be set (whether it is due to missing support in connected
driver or remote server).  If not explicitely requested, a debug
message is printed (hence the addition to virsh-optparse test).

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
11 years agovirt-aa-helper: handle 9pfs
Felix Geyer [Sun, 9 Mar 2014 15:03:20 +0000 (16:03 +0100)]
virt-aa-helper: handle 9pfs

Make virt-aa-helper create rules to allow VMs access to filesystem
mounts from the host.

Signed-off-by: Felix Geyer <debfx@fobos.de>
Signed-off-by: Hiroshi Miura <miurahr@linux.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Guido Günther <agx@sigxcpu.org>
11 years agoFix memory leak in virDomainSnapshotDiskDefClear()
Nehal J Wani [Sun, 16 Mar 2014 08:39:30 +0000 (14:09 +0530)]
Fix memory leak in virDomainSnapshotDiskDefClear()

While running domainsnapshotxml2xmltest, it was found that valgrind pointed out
the following memory leak:

==32176== 42 (32 direct, 10 indirect) bytes in 1 blocks are definitely lost in loss record 42 of 66
==32176==    at 0x4A069EE: malloc (vg_replace_malloc.c:270)
==32176==    by 0x4A06B62: realloc (vg_replace_malloc.c:662)
==32176==    by 0x4C65A07: virReallocN (viralloc.c:243)
==32176==    by 0x4C65B2E: virExpandN (viralloc.c:292)
==32176==    by 0x4C65E30: virInsertElementsN (viralloc.c:434)
==32176==    by 0x4CD71F3: virDomainDiskSourceDefParse (domain_conf.c:5078)
==32176==    by 0x4CF6EF4: virDomainSnapshotDefParseNode (snapshot_conf.c:151)
==32176==    by 0x4CF7314: virDomainSnapshotDefParseString (snapshot_conf.c:410)
==32176==    by 0x41FB8D: testCompareXMLToXMLHelper (domainsnapshotxml2xmltest.c:100)
==32176==    by 0x420FD1: virtTestRun (testutils.c:199)
==32176==    by 0x41F859: mymain (domainsnapshotxml2xmltest.c:222)
==32176==    by 0x42174D: virtTestMain (testutils.c:782)
==32176==
... and one more.

11 years agobhyve: allow to destroy only active domains
Roman Bogorodskiy [Sat, 15 Mar 2014 15:47:15 +0000 (19:47 +0400)]
bhyve: allow to destroy only active domains

Add a check that domain is active before attempting to destroy it.

11 years agoGive virNWFilterVarCombIterNext saner semantics
Daniel P. Berrange [Mon, 17 Mar 2014 11:38:20 +0000 (11:38 +0000)]
Give virNWFilterVarCombIterNext saner semantics

The virNWFilterVarCombIterNext method will free its
parameter when it gets to the end of the iterator.
This is somewhat misleading design, making it appear
as if the caller has a memory leak. Remove the free'ing
of the parameter and ensure that the calling method
ebiptablesCreateRuleInstanceIterate free's it instead.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix leak on OOM when creating nwfilter rule instances
Daniel P. Berrange [Mon, 17 Mar 2014 11:58:34 +0000 (11:58 +0000)]
Fix leak on OOM when creating nwfilter rule instances

The ebiptablesAddRuleInst method would leak an instance
of ebiptablesRuleInstPtr if it hit OOM when adding it
to the list of instances. Remove the pointless helper
method virNWFilterRuleInstAddData and just inline the
call to VIR_APPEND_ELEMENT and free the instance on
failure.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAvoid warning message from libxl driver on non-Xen kernels
Daniel P. Berrange [Mon, 17 Mar 2014 12:14:11 +0000 (12:14 +0000)]
Avoid warning message from libxl driver on non-Xen kernels

The libxl driver reads /proc/xen/capabilities to see if it
is on a Dom0 kernel. If that file does not even exist though,
an error is logged. Check for the file existance before trying
to read its contents to avoid the log message.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agobhyve: fix hostbridge device command generation
Roman Bogorodskiy [Sat, 15 Mar 2014 15:17:14 +0000 (19:17 +0400)]
bhyve: fix hostbridge device command generation

Addition of the hostbridge device was mistakenly placed to
bhyveBuildNetArgStr(). This could result in hostbridge device not being
added to the commandline if there are no network devices specified, but
hostbridge device should be added unconditionally.

Fix by placing it to virBhyveProcessBuildBhyveCmd().

11 years agobhyve: add support for virtio block devices
Roman Bogorodskiy [Sat, 15 Mar 2014 14:52:19 +0000 (18:52 +0400)]
bhyve: add support for virtio block devices

11 years agoEnforce attribute check of the virRegister functions
Pavel Hrdina [Mon, 17 Mar 2014 14:55:31 +0000 (15:55 +0100)]
Enforce attribute check of the virRegister functions

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
11 years agodaemon: Introduce max_anonymous_clients
Michal Privoznik [Tue, 4 Mar 2014 17:55:24 +0000 (18:55 +0100)]
daemon: Introduce max_anonymous_clients

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

This config tunable allows users to determine the maximum number of
accepted but yet not authenticated users.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
11 years agovirNetServer: Introduce unauth clients counter
Michal Privoznik [Tue, 4 Mar 2014 14:37:27 +0000 (15:37 +0100)]
virNetServer: Introduce unauth clients counter

The counter gets incremented on each unauthenticated client added to the
server and decremented whenever the client authenticates.

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