]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
9 years agogendispatch: Use proper error for limit checking
Martin Kletzander [Thu, 10 Mar 2016 14:25:52 +0000 (15:25 +0100)]
gendispatch: Use proper error for limit checking

All other places use VIR_ERR_RPC except this one, let's be consistent,
shall we?

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agovirt-admin: Don't tell everyone needlessly we're connected
Martin Kletzander [Thu, 10 Mar 2016 05:34:03 +0000 (06:34 +0100)]
virt-admin: Don't tell everyone needlessly we're connected

There are cases when we don't want to tell the user we are connected.
That's for example when we first connect to the server without the
command 'connect' itself.  That helps to clear out output of first
command, mainly when running non-interactively.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoremote: Generate what's possible
Martin Kletzander [Wed, 9 Mar 2016 12:33:56 +0000 (13:33 +0100)]
remote: Generate what's possible

Since gendisplatch can now generate "modern" *ListAll* functions, let
them all be generated.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agogendispatch: Support modern listing of more types
Martin Kletzander [Wed, 9 Mar 2016 12:32:55 +0000 (13:32 +0100)]
gendispatch: Support modern listing of more types

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agogendispatch: Remember the name of snapshot variable name
Martin Kletzander [Wed, 9 Mar 2016 19:38:06 +0000 (20:38 +0100)]
gendispatch: Remember the name of snapshot variable name

Until now, the script assumed that snapshot name is 'snap', but that's
going to change.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agogendispatch: Accept server as an argument
Martin Kletzander [Wed, 9 Mar 2016 12:40:27 +0000 (13:40 +0100)]
gendispatch: Accept server as an argument

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoadmin: Generate ConnectListServers dispatch helpers
Martin Kletzander [Wed, 2 Mar 2016 14:32:55 +0000 (15:32 +0100)]
admin: Generate ConnectListServers dispatch helpers

Since we have the opportunity now, let's save some precious code lines.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agogendispatch: Be able to generate multi-return values
Martin Kletzander [Tue, 1 Mar 2016 16:35:28 +0000 (17:35 +0100)]
gendispatch: Be able to generate multi-return values

Let's call it modern_ret_as_list as opposed to single_ret_as_list.  The
latter was able to return list of things.  However the new, more modern,
version came and it is used since listAllDomains till nowadays in
ListServers.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agogendispatch: Cluster, don't capture if not needed
Martin Kletzander [Wed, 9 Mar 2016 20:51:56 +0000 (21:51 +0100)]
gendispatch: Cluster, don't capture if not needed

We were using parentheses for grouping admin|remote even though we didn't
need to capture what's in it.  That caused some changes to be greater
than needed and, to be honest, some confusion as well.  Let's use it as
it should be used.  It'll also make future changes more consistent.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoadmin: Be consistent when resetting errors
Martin Kletzander [Wed, 2 Mar 2016 15:29:11 +0000 (16:29 +0100)]
admin: Be consistent when resetting errors

Resetting an error should be the first thing public API does.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agovirt-admin: Don't leak uri in cmdSrvList
Martin Kletzander [Tue, 1 Mar 2016 16:36:55 +0000 (17:36 +0100)]
virt-admin: Don't leak uri in cmdSrvList

virAdmConnectGetURI() returns string that needs to be free()'d but we
haven't done that.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoadmin: Don't use priority for admin APIs
Martin Kletzander [Tue, 1 Mar 2016 16:34:19 +0000 (17:34 +0100)]
admin: Don't use priority for admin APIs

There are no priority workers as they don't make sense for now.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoChange virNetDaemonGetServerNames to virNetDaemonGetServers
Martin Kletzander [Tue, 1 Mar 2016 15:28:58 +0000 (16:28 +0100)]
Change virNetDaemonGetServerNames to virNetDaemonGetServers

For now it does not matter which ones we return as the code is similarly
complex, however it will fit in with other constructs in the future,
mainly when we will be able to generate dispatch helpers.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoadmin: Do not work with virAdm on the server side
Martin Kletzander [Tue, 1 Mar 2016 14:31:18 +0000 (15:31 +0100)]
admin: Do not work with virAdm on the server side

virAdm is prefix only used on the client side.  Or at least for now.  On
server, though, this corresponds to virNet structures (virAdmConnect is
virNetDaemon, virAdmServer should be virNetServer, in the future
virAdmClient will be resolved to virNetServerClient, and so on).

This will also make future work clearer and easier.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoExpose virNetServerGetName
Martin Kletzander [Tue, 1 Mar 2016 15:26:32 +0000 (16:26 +0100)]
Expose virNetServerGetName

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agodaemon: Properly check for clients
Martin Kletzander [Tue, 1 Mar 2016 14:42:32 +0000 (15:42 +0100)]
daemon: Properly check for clients

virHashForEach() returns 0 if everything went nice, so our session
daemon was timing out even when there was a client connected.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agodaemon: Set error for unknown server name
Martin Kletzander [Tue, 1 Mar 2016 14:41:43 +0000 (15:41 +0100)]
daemon: Set error for unknown server name

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agovirerror: Introduce new error type NO_SERVER
Martin Kletzander [Tue, 8 Mar 2016 16:22:46 +0000 (17:22 +0100)]
virerror: Introduce new error type NO_SERVER

This serves the same purpose as VIR_ERR_NO_xxx where xxx is any object
that API can be called upon.  Only this particular one is used for
daemon's servers.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agodaemon: Get server name from the server itself
Martin Kletzander [Tue, 1 Mar 2016 14:40:31 +0000 (15:40 +0100)]
daemon: Get server name from the server itself

Since servers know their name, there is no need to supply such
information twice.  Also defeats inconsistencies.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoserver: Store server name in server object
Martin Kletzander [Tue, 1 Mar 2016 14:34:15 +0000 (15:34 +0100)]
server: Store server name in server object

At first I did not want to do this, but after trying to implement some
newer feaures in the admin API I realized we need that to make our lives
easier.  On the other hand they are not saved redundantly and the
virNetServer objects are still kept in a hash table.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoadmin: Check for flags properly
Martin Kletzander [Tue, 1 Mar 2016 14:03:04 +0000 (15:03 +0100)]
admin: Check for flags properly

Function virAdmConnectListServers() forgot to check for flags at all,
virAdmConnectOpen() on the other hand checked them but did no dispatch
the error.  virCheckFlags() should be used only when there should be no
other thing done after erroring out and since they are used on different
places then just public API, they cannot dispatch errors.  So let's use
virCheckFlagsGoto instead.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoadmin: Make virAdmServerFree() handle NULL gracefully
Martin Kletzander [Tue, 1 Mar 2016 13:56:12 +0000 (14:56 +0100)]
admin: Make virAdmServerFree() handle NULL gracefully

We don't want to end up like with virDomainFree() and other, right?

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: Introduce qemuBuildNetCommandLine
John Ferlan [Thu, 18 Feb 2016 15:32:07 +0000 (10:32 -0500)]
qemu: Introduce qemuBuildNetCommandLine

Add new function to manage adding the network device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Introduce qemuBuildFSDevCommandLine
John Ferlan [Thu, 18 Feb 2016 15:06:14 +0000 (10:06 -0500)]
qemu: Introduce qemuBuildFSDevCommandLine

Add new function to manage adding the -fsdev options to the
command line removing that task from the mainline qemuBuildCommandLine.
Alter the code slightly to perform the !caps and fsdev failure check
up front.

Since both qemuBuildFSStr and qemuBuildFSDevStr are local, make them
static and fix their prototypes to use the const virDomainDef as well.
Make some minor formatting changes for long lines.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Introduce qemuBuildDiskDriveCommandLine
John Ferlan [Thu, 18 Feb 2016 14:56:10 +0000 (09:56 -0500)]
qemu: Introduce qemuBuildDiskDriveCommandLine

Add new function to manage adding the disk -drive options to the
command line removing that task from the mainline qemuBuildCommandLine.

Also since using const virDomainDef in new function, that means other
functions called needed to change their usage.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Introduce qemuBuildHubCommandLine
John Ferlan [Thu, 18 Feb 2016 14:30:28 +0000 (09:30 -0500)]
qemu: Introduce qemuBuildHubCommandLine

Add new function to manage adding the hub -device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Also make qemuBuildHubDevStr static to the module since it's only
used here.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Introduce qemuBuildControllerDevCommandLine
John Ferlan [Thu, 18 Feb 2016 13:33:39 +0000 (08:33 -0500)]
qemu: Introduce qemuBuildControllerDevCommandLine

Add new function to manage adding the controller -device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Also adjust to using const virDomainDef instead of virDomainDefPtr.
This causes collateral damage in order to modify called APIs to use
the const virDomainDef instead as well.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Introduce qemuBuildGlobalControllerCommandLine
John Ferlan [Thu, 18 Feb 2016 13:18:18 +0000 (08:18 -0500)]
qemu: Introduce qemuBuildGlobalControllerCommandLine

Add new function to manage adding the -global controller options to
the command line removing that task from the mainline qemuBuildCommandLine.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Introduce qemuBuildBootCommandLine
John Ferlan [Thu, 18 Feb 2016 13:15:10 +0000 (08:15 -0500)]
qemu: Introduce qemuBuildBootCommandLine

Add new function to manage adding the -boot options to the command
line removing that task from the mainline qemuBuildCommandLine.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Introduce qemuBuildPMCommandLine
John Ferlan [Thu, 18 Feb 2016 13:06:17 +0000 (08:06 -0500)]
qemu: Introduce qemuBuildPMCommandLine

Add new function to manage adding the power management options to the
command line removing that task from the mainline qemuBuildCommandLine.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Introduce qemuBuildClockCommandLine
John Ferlan [Thu, 18 Feb 2016 11:42:45 +0000 (06:42 -0500)]
qemu: Introduce qemuBuildClockCommandLine

Add new function to manage adding the '-clock' options to the command
line removing that task from the mainline qemuBuildCommandLine.

Also includes some minor formatting cleanups.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: enable debug threads
Marc-André Lureau [Thu, 10 Mar 2016 19:46:39 +0000 (20:46 +0100)]
qemu: enable debug threads

When debug-threads is enabled, individual threads are given a separate
name (on Linux)

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

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: check for debug-threads capability
Marc-André Lureau [Thu, 10 Mar 2016 19:46:38 +0000 (20:46 +0100)]
qemu: check for debug-threads capability

QEMU (somewhere around 2.0) added a new sub-option to the -name flag
-name debug-threads=on.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agolibxl_conf: reuse virDomainNetGetActualtype in libxlMakeNicList
Chunyan Liu [Thu, 10 Mar 2016 02:50:41 +0000 (10:50 +0800)]
libxl_conf: reuse virDomainNetGetActualtype in libxlMakeNicList

Reuse existing helper function virDomainNetGetActualtype.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoqemuxml2argvtest: Fix monitor path in serial-file-log
Jiri Denemark [Thu, 10 Mar 2016 17:54:59 +0000 (18:54 +0100)]
qemuxml2argvtest: Fix monitor path in serial-file-log

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agodocs: generic.css: Indentation and spacing tweaks
Cole Robinson [Thu, 10 Mar 2016 01:57:59 +0000 (20:57 -0500)]
docs: generic.css: Indentation and spacing tweaks

- Add line-height:150% spacing for all text. This makes text lines far
  less cramped, and seems closer visually to what wikipedia uses.

- Remove bottom and top margin from lists: entries seemed needlessly
  spread out.

- Reduce sublist indentation a bit

- Add a bottom border after headings: IMO this greatly helps in break
  up the vertical flow of a big page of text. Doesn't look great on the
  front page, but helps a lot on dense pages like formatdomain

9 years agodocs: generic.css: font size tweaks
Cole Robinson [Thu, 10 Mar 2016 01:53:58 +0000 (20:53 -0500)]
docs: generic.css: font size tweaks

- change font-family to just 'sans-serif' rather than hardcode a few
  font families. this means we abide the user's browser font setting,
  and makes us consistent with other sites like en.wikipedia.org
- raise font-size to 90%. this is what en.wikipedia.org uses.

With these two tweaks, libvirt.org text renders the same as
en.wikipedia.org with fedora firefox out of the box config. Previously
the font on libvirt.org was very small and difficult to read.

9 years agodocs: generic.css: minor cleanups
Cole Robinson [Thu, 10 Mar 2016 01:42:26 +0000 (20:42 -0500)]
docs: generic.css: minor cleanups

- Drop some redundant bits
- Use consistent spacing
- Group similar blocks near each other

There should be no functional change

9 years agodocs: website: Remove the et.redhat.com footer
Cole Robinson [Thu, 10 Mar 2016 01:35:37 +0000 (20:35 -0500)]
docs: website: Remove the et.redhat.com footer

This is long since obsolete, just scrap it all

9 years agoqemu: support use of virtlogd with file based chardevs
Daniel P. Berrange [Tue, 23 Feb 2016 13:41:57 +0000 (13:41 +0000)]
qemu: support use of virtlogd with file based chardevs

Currently the file based character devices let QEMU write
directly to a file on disk. This allows a malicious QEMU
to inflict a denial of service by consuming all free space.

Switch QEMU to use a pipe to virtlogd, which will enforce
file rollover.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: use virtlogd for character device log files
Daniel P. Berrange [Tue, 23 Feb 2016 13:05:09 +0000 (13:05 +0000)]
qemu: use virtlogd for character device log files

If use of virtlogd is enabled, then use it for backing the
character device log files too. This avoids the possibility
of a guest denial of service by writing too much data to
the log file.

9 years agologging: support truncation of logfiles when opening
Daniel P. Berrange [Mon, 29 Feb 2016 12:26:02 +0000 (12:26 +0000)]
logging: support truncation of logfiles when opening

The virtlogd daemon currently opens all files for append, but
in some cases the user may wish to discard existing data. Define
a new flag to indicate that logfiles should be truncated when
opening.

9 years agoqemu: move functions for handling FD passing
Daniel P. Berrange [Mon, 29 Feb 2016 12:24:40 +0000 (12:24 +0000)]
qemu: move functions for handling FD passing

The functions for handling FD passing when building command line
arguments need to be used by many different bits of code, so need
to be at the start of the source file

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: don't append -chardev arg until after value is formatted
Daniel P. Berrange [Mon, 29 Feb 2016 12:21:14 +0000 (12:21 +0000)]
qemu: don't append -chardev arg until after value is formatted

The act of formatting a chardev backend value may need to
append command line arguments for passing FDs. If we append
the -chardev arg before formatting the value, then the
resulting arguments will end up interspersed

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: add support for logging chardev output to a file
Daniel P. Berrange [Tue, 23 Feb 2016 11:56:34 +0000 (11:56 +0000)]
qemu: add support for logging chardev output to a file

Honour the <log file='...'/> element in chardevs to output
data to a file. This requires QEMU >= 2.6

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoconf: allow use of a logfile with chardev backends
Daniel P. Berrange [Fri, 11 Dec 2015 16:58:13 +0000 (16:58 +0000)]
conf: allow use of a logfile with chardev backends

Extend the chardev source XML so that there is a new optional
<log/> element, which is applicable to all character device
backend types. For example, to log output of a TCP backed
serial port

    <serial type='tcp'>
      <source mode='connect' host='127.0.0.1' service='9999'/>
      <protocol type='raw'/>
      <log file='/var/log/libvirt/qemu/demo-serial0.log' append='on'/>
      <target port='0'/>
    </serial>

Not all hypervisors will support use of logfiles.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agologging: allow inode/offset params to be NULL
Daniel P. Berrange [Fri, 11 Dec 2015 10:58:29 +0000 (10:58 +0000)]
logging: allow inode/offset params to be NULL

Not all callers of virLogManagerDomainOpenLogFile will
care about getting the current inode/offset, so we should
allow those parameters to be NULL

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: cpu: Don't remove pinning of cold-unplugged cpu
Peter Krempa [Thu, 10 Mar 2016 08:37:08 +0000 (09:37 +0100)]
qemu: cpu: Don't remove pinning of cold-unplugged cpu

After adding support for offline vcpu pinning the code that removes the
pinning for cpu cold-unplug was forgotten. This fixes up commit 02ae21d

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

9 years agoqemu: Fix memory leak in qemuGetSchedInfo
Peter Krempa [Thu, 10 Mar 2016 08:57:13 +0000 (09:57 +0100)]
qemu: Fix memory leak in qemuGetSchedInfo

Memory returned from virStringSplit shall be freed with
virStringFreeList rather than VIR_FREE. Introduced in commit 511e7c5b.

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

9 years agoconf: Fix off-by-one in virDomainDefGetVcpu
Peter Krempa [Thu, 10 Mar 2016 08:46:53 +0000 (09:46 +0100)]
conf: Fix off-by-one in virDomainDefGetVcpu

Cpus are indexed starting from '0' so the check was invalid.

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

9 years agoqemu: Refactor bitmap handling in qemuDomainPinVcpuFlags
Peter Krempa [Tue, 23 Feb 2016 18:15:01 +0000 (19:15 +0100)]
qemu: Refactor bitmap handling in qemuDomainPinVcpuFlags

Now that the function was extracted we can get rid of some temp
variables. Additionally formatting of the bitmap string for the event
code should be checked.

9 years agoqemu: vcpupin: Extract live vcpupin setting into a separate function
Peter Krempa [Tue, 23 Feb 2016 12:41:43 +0000 (13:41 +0100)]
qemu: vcpupin: Extract live vcpupin setting into a separate function

The function was now beyond maintainability.

9 years agoutil: virfile: Only setuid for virFileRemove if on NFS
Cole Robinson [Wed, 9 Mar 2016 17:20:37 +0000 (12:20 -0500)]
util: virfile: Only setuid for virFileRemove if on NFS

NFS with root-squash is the only reason we need to do setuid/setgid
crazyness in virFileRemove, so limit that behavior to the NFS case.

9 years agoutil: virfile: Clarify setuid usage for virFileRemove
Cole Robinson [Wed, 9 Mar 2016 15:53:54 +0000 (10:53 -0500)]
util: virfile: Clarify setuid usage for virFileRemove

Break these checks out into their own function, and clearly document
each one. This shouldn't change behavior

9 years agoqemu: add support for offline vcpupin
Peter Krempa [Fri, 12 Feb 2016 13:57:45 +0000 (14:57 +0100)]
qemu: add support for offline vcpupin

Allow pinning for inactive vcpus. The pinning mask will be automatically
applied as we would apply the default mask in case of a cpu hotplug.

Setting the scheduler settings for a vcpu has the same semantics.

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

9 years agoconf: extract ignoring of inactive vcpu pinning information
Peter Krempa [Tue, 23 Feb 2016 11:35:40 +0000 (12:35 +0100)]
conf: extract ignoring of inactive vcpu pinning information

Introduce VIR_DOMAIN_DEF_FEATURE_OFFLINE_VCPUPIN domain feature flag
whcih will allow to skip ignoring of the pinning information for
hypervisor drivers which will want to implement forward-pinning of
vcpus.

9 years agoconf: refactor checking for unsupported memory devices
Peter Krempa [Tue, 23 Feb 2016 09:58:10 +0000 (10:58 +0100)]
conf: refactor checking for unsupported memory devices

Introduce a helper to check supported device and domain config and move
the memory hotplug checks to it.

The advantage of this approach is that by default all new features are
considered unsupported by all hypervisors unless specifically changed
rather than the previous approach where every hypervisor would need to
declare that a given feature is unsupported.

9 years agoconf: introduce parser feature flags
Peter Krempa [Tue, 23 Feb 2016 09:32:19 +0000 (10:32 +0100)]
conf: introduce parser feature flags

To avoid having to forbid new features added to domain XML in post parse
callbacks for individual hypervisor drivers the feature flag mechanism
will allow to add a central check that will be disabled for the drivers
that will add support.

As a first example flag, the 'hasWideSCSIBus' is converted to the new
bitmap.

9 years agoqemu: Report pinning for all vCPUs in qemuDomainGetVcpuPinInfo
Peter Krempa [Fri, 12 Feb 2016 13:57:41 +0000 (14:57 +0100)]
qemu: Report pinning for all vCPUs in qemuDomainGetVcpuPinInfo

The API documentation states that the function is returning pinning for
all vCPUs, so we can actually do so if the user passes a large enough
array.

9 years agoconf: Extract code filling data for virDomainGetVcpuPinInfo
Peter Krempa [Mon, 22 Feb 2016 14:29:25 +0000 (15:29 +0100)]
conf: Extract code filling data for virDomainGetVcpuPinInfo

The implementation of the inner guts of the function is similar for all
drivers, so we can add a helper and not have to reimplement it three
times.

9 years agovirsh: vcpupin: Ask for pinning info for all vCPUs
Peter Krempa [Wed, 17 Feb 2016 14:53:42 +0000 (15:53 +0100)]
virsh: vcpupin: Ask for pinning info for all vCPUs

The API docs state that the API queries pinning info for all vCPUs and
thus we should allocate the bitmap even for the inactive ones.

The API will currently return bitmap only for the active vCPUs but that
will change in the future.

9 years agoqemu: Add support for job completed event
Jiri Denemark [Wed, 17 Feb 2016 23:12:33 +0000 (00:12 +0100)]
qemu: Add support for job completed event

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoIntroduce job completed event
Jiri Denemark [Wed, 17 Feb 2016 20:20:11 +0000 (21:20 +0100)]
Introduce job completed event

The VIR_DOMAIN_EVENT_ID_JOB_COMPLETED event will be triggered once a job
(such as migration) finishes and it will contain statistics for the job
as one would get by calling virDomainGetJobStats. Thanks to this event
it is now possible to get statistics of a completed migration of a
transient domain on the source host.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Do not report completed stats until the job finishes
Jiri Denemark [Tue, 23 Feb 2016 11:40:47 +0000 (12:40 +0100)]
qemu: Do not report completed stats until the job finishes

We would happily report and free statistics of a completed migration
even before it actually completed (on the source host while migration is
in the Finish phase).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Fix a race when computing migration downtime
Jiri Denemark [Tue, 23 Feb 2016 09:47:01 +0000 (10:47 +0100)]
qemu: Fix a race when computing migration downtime

Computing a total downtime during a migration requires us to store a
time stamp when guest CPUs get stopped. The value (and all other
statistics) is then transferred to the destination to compute the
downtime. Because the stopped time stamp is stored by a STOP event
handler while the statistics which will be sent over to the destination
are copied synchronously within qemuMigrationWaitForCompletion.

Depending on the timing of STOP and MIGRATION events, we may end up
copying (and transferring) statistics without the stopped time stamp
set. Let's make sure we always use the correct time stamp.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Don't explicitly stop CPUs after migration
Jiri Denemark [Tue, 5 Jan 2016 21:19:28 +0000 (22:19 +0100)]
qemu: Don't explicitly stop CPUs after migration

With a very old QEMU which doesn't support events we need to explicitly
call qemuMigrationSetOffline at the end of migration to update our
internal state. On the other hand, if we talk to QEMU using QMP, we
should just wait for the STOP event and let the event handler update the
state and trigger a libvirt event.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Properly update completed migration stats
Jiri Denemark [Thu, 18 Feb 2016 13:44:48 +0000 (14:44 +0100)]
qemu: Properly update completed migration stats

We should not overwrite all migration statistics on the source with the
numbers sent by the destination since the source may have an updated
view in some cases (such as post-copy migration). It's safer to update
just the timing info we need to get from the destination and be prepared
for the future. And we should only do all this after a successful
migration.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Store completed stats at the very end of migration
Jiri Denemark [Thu, 18 Feb 2016 13:02:15 +0000 (14:02 +0100)]
qemu: Store completed stats at the very end of migration

Statistics for a completed migration only make sense if the migration
was successful. Let's not store them in priv->job.completed until we
are sure it was a success.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agohostdev: Remove explicit NULL checks
Andrea Bolognani [Thu, 25 Feb 2016 13:50:54 +0000 (14:50 +0100)]
hostdev: Remove explicit NULL checks

NULL checks are performed implicitly in the rest of the module,
including other allocations in the very same function.

9 years agohostdev: Fix indentation
Andrea Bolognani [Wed, 24 Feb 2016 12:44:09 +0000 (13:44 +0100)]
hostdev: Fix indentation

9 years agohostdev: Remove inaccurate comment
Andrea Bolognani [Mon, 7 Mar 2016 13:14:54 +0000 (14:14 +0100)]
hostdev: Remove inaccurate comment

The comment claimed that virPCIDeviceReattach() does not reattach
a device to the host driver; except it actually does, so the
comment is just confusing and we're better off removing it.

9 years agohostdev: Make comments easier to change later
Andrea Bolognani [Mon, 22 Feb 2016 14:02:23 +0000 (15:02 +0100)]
hostdev: Make comments easier to change later

Replace the term "loop" with the more generic "step". This allows us
to be more flexible and eg. have a step that consists in a single
function call.

Don't include the number of steps in the first comment of the
function, so that we can add or remove steps without having to worry
about keeping that comment in sync.

For the same reason, remove the summary contained in that comment.

Clean up some weird vertical spacing while we're at it.

9 years agotests: hostdev: Group test cases
Andrea Bolognani [Thu, 3 Mar 2016 15:13:04 +0000 (16:13 +0100)]
tests: hostdev: Group test cases

Instead of considering each single step its own test case, create
high level test cases that reproduce a certain scenario.

9 years agotests: hostdev: Add more checks on list size
Andrea Bolognani [Wed, 2 Mar 2016 14:33:18 +0000 (15:33 +0100)]
tests: hostdev: Add more checks on list size

Always call CHECK_LIST_COUNT() to check the size of both the active
and inactive devices list.

9 years agotests: hostdev: Use size_t for count variables
Andrea Bolognani [Wed, 2 Mar 2016 14:27:06 +0000 (15:27 +0100)]
tests: hostdev: Use size_t for count variables

virPCIDeviceListCount()'s return type is size_t, so variables that
store its return value should be of that type.

9 years agotests: hostdev: Move variable declaration inside CHECK_LIST_COUNT()
Andrea Bolognani [Wed, 2 Mar 2016 14:23:51 +0000 (15:23 +0100)]
tests: hostdev: Move variable declaration inside CHECK_LIST_COUNT()

The 'actualCount' variable, formerly just 'count', is only used
internally by the macro, so it's better to move its declaration
inside the macro as well: this way, it doesn't have to be declared
by every single user.

The new name is less generic to make clashes less likely.

9 years agotests: hostdev: Use better variable names
Andrea Bolognani [Wed, 2 Mar 2016 14:15:07 +0000 (15:15 +0100)]
tests: hostdev: Use better variable names

Change the extremely generic count1 and count2 to the more
descriptive active_count and inactive_count.

9 years agotests: hostdev: Remove magic numbers
Andrea Bolognani [Wed, 2 Mar 2016 12:17:08 +0000 (13:17 +0100)]
tests: hostdev: Remove magic numbers

When checking the number of devices added to a device list, use the
nhostdevs variable instead of its value, so that the test can keep
working even if more hostdevs are added.

9 years ago_virtualboxCreateMachine: Avoid unbounded stack
Michal Privoznik [Sat, 5 Mar 2016 11:59:45 +0000 (12:59 +0100)]
_virtualboxCreateMachine: Avoid unbounded stack

If the stars are in the right position and you're building with
VBox >= 4.2.0 it will happen that compiler thinks an array
allocated on the stack may be unbounded:

In file included from vbox/vbox_V4_2.c:13:0:
vbox/vbox_tmpl.c: In function '_virtualboxCreateMachine':
vbox/vbox_tmpl.c:2811:1: error: stack usage might be unbounded [-Werror=stack-usage=]
 _virtualboxCreateMachine(vboxGlobalData *data, virDomainDefPtr def, IMachine **machine, char *uuidstr ATTRIBUTE_UNUSED)
 ^

Well, given how the variable is declared, I had some hard time
seeing it is actually bounded. Surprisingly compiler does not
complain because of -Wframe-larger-than. This is because
variable length arrays do not count into that warning.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoAdd secretObjFromSecret
John Ferlan [Mon, 29 Feb 2016 22:15:26 +0000 (17:15 -0500)]
Add secretObjFromSecret

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agolocking: Use bit shift for flag values not constant values.
John Ferlan [Fri, 4 Mar 2016 14:35:19 +0000 (09:35 -0500)]
locking: Use bit shift for flag values not constant values.

So far it hasn't bitten us, but if the next value wasn't 4, then
the logic used to check flag bits would have issues.

9 years agoFix minor typos
Yuri Chornoivan [Mon, 7 Mar 2016 13:24:51 +0000 (15:24 +0200)]
Fix minor typos

9 years agoqemu: improve the error when try to undefine transient network
Shanzhi Yu [Sun, 6 Mar 2016 10:54:21 +0000 (18:54 +0800)]
qemu: improve the error when try to undefine transient network

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

Signed-off-by: Shanzhi Yu <shyu@redhat.com>
9 years agoqemu: rename: Forbid renaming domains with managed save image
Peter Krempa [Mon, 7 Mar 2016 09:06:19 +0000 (10:06 +0100)]
qemu: rename: Forbid renaming domains with managed save image

The code does not handle renaming of the save state file. In addition to
that the resuming code would need to be tweaked to handle the name
change since the XML is extracted from the save image. The easies option
is to make the rename API even less useful by forbiding this.

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

9 years agovirLXCProcessMonitorInitNotify: Initialize @inode
Michal Privoznik [Fri, 4 Mar 2016 14:21:36 +0000 (15:21 +0100)]
virLXCProcessMonitorInitNotify: Initialize @inode

This is an error message I've just seen. Fix it by initializing
@inode.

  CC       lxc/libvirt_driver_lxc_impl_la-lxc_process.lo
lxc/lxc_process.c: In function 'virLXCProcessMonitorInitNotify':
lxc/lxc_process.c:767:23: error: 'inode' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     virDomainAuditInit(vm, initpid, inode);
                       ^

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agolibxl: reuse virDomainObjUpdateModificationImpact
Nikolay Shirokovskiy [Wed, 2 Mar 2016 14:30:04 +0000 (17:30 +0300)]
libxl: reuse virDomainObjUpdateModificationImpact

Original current flag expansion does not filter out non
_CONFIG and _LIVE flags explicitly but they are prohibited
earlier by virCheckFlags.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agolxc: reuse virDomainObjUpdateModificationImpact
Nikolay Shirokovskiy [Wed, 2 Mar 2016 14:30:03 +0000 (17:30 +0300)]
lxc: reuse virDomainObjUpdateModificationImpact

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agolibxl: Use virDomainLiveConfigHelperMethod for libxlDomainSetMemoryFlags
Nikolay Shirokovskiy [Wed, 24 Feb 2016 08:38:37 +0000 (11:38 +0300)]
libxl: Use virDomainLiveConfigHelperMethod for libxlDomainSetMemoryFlags

Flag expansion is the same as in virDomainObjUpdateModificationImpact
which virDomainLiveConfigHelperMethod calls internally. The difference
is merely in implementation. Note that VIR_DOMAIN_MEM_CONFIG is the
same as VIR_DOMAIN_AFFECT_CONFIG.  Additionally, the called functions
will properly use flag OR and thus handle the VIR_DOMAIN_MEM_MAXIMUM case.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agotools: do not leak uri in disconnect handler
Ján Tomko [Thu, 3 Mar 2016 16:31:47 +0000 (17:31 +0100)]
tools: do not leak uri in disconnect handler

Commit 035947e introduced a call to virConnectGetURI
without a matching free() in virshCatchDisconnect.

Also fix vshAdmCatchDisconnect where it was copied by
commit 6dd7e42.

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

9 years agoInitialize couple of variables.
Michal Privoznik [Thu, 3 Mar 2016 08:10:27 +0000 (09:10 +0100)]
Initialize couple of variables.

While trying to build with -Os couple of compile errors showed
up.

conf/domain_conf.c: In function 'virDomainChrRemove':
conf/domain_conf.c:13666:24: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     virDomainChrDefPtr ret, **arrPtr = NULL;
                        ^
Compiler fails to see that @ret is used only if set in the loop,
but whatever, there's no harm in initializing the variable.

In vboxAttachDrivesNew and _vboxAttachDrivesOld compiler thinks
that @rc may be used uninitialized. Well, not directly, but maybe
after some optimization. Yet again, no harm in initializing a
variable.

In file included from ./util/virthread.h:26:0,
                 from ./datatypes.h:28,
                 from vbox/vbox_tmpl.c:43,
                 from vbox/vbox_V3_1.c:37:
vbox/vbox_tmpl.c: In function '_vboxAttachDrivesOld':
./util/virerror.h:181:5: error: 'rc' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     virReportErrorHelper(VIR_FROM_THIS, code, __FILE__,              \
     ^
In file included from vbox/vbox_V3_1.c:37:0:
vbox/vbox_tmpl.c:1041:14: note: 'rc' was declared here
     nsresult rc;
              ^
Yet again, one uninitialized variable:

qemu/qemu_driver.c: In function 'qemuDomainBlockCommit':
qemu/qemu_driver.c:17194:9: error: 'baseSource' may be used uninitialized in this function [-Werror=maybe-uninitialized]
         qemuDomainPrepareDiskChainElement(driver, vm, baseSource,
         ^

And another one:

storage/storage_backend_logical.c: In function 'virStorageBackendLogicalMatchPoolSource.isra.2':
storage/storage_backend_logical.c:618:33: error: 'thisSource' may be used uninitialized in this function [-Werror=maybe-uninitialized]
                       thisSource->devices[j].path))
                                 ^

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoDrop inline keyword from some functions.
Michal Privoznik [Thu, 3 Mar 2016 07:14:37 +0000 (08:14 +0100)]
Drop inline keyword from some functions.

While trying to build with -Os I've encountered some build
failures.

util/vircommand.c: In function 'virCommandAddEnvFormat':
util/vircommand.c:1257:1: error: inlining failed in call to 'virCommandAddEnv': call is unlikely and code size would grow [-Werror=inline]
 virCommandAddEnv(virCommandPtr cmd, char *env)
 ^
util/vircommand.c:1308:5: error: called from here [-Werror=inline]
     virCommandAddEnv(cmd, env);
     ^
This function is big enough for the compiler to be not inlined.
This is the error message I'm seeing:

Then virDomainNumatuneNodeSpecified is exported and called from
other places. It shouldn't be inlined then.

In file included from network/bridge_driver_platform.h:30:0,
                 from network/bridge_driver_platform.c:26:
network/bridge_driver_linux.c: In function 'networkRemoveRoutingFirewallRules':
./conf/network_conf.h:350:1: error: inlining failed in call to 'virNetworkDefForwardIf.constprop': call is unlikely and code size would grow [-Werror=inline]
 virNetworkDefForwardIf(const virNetworkDef *def, size_t n)
 ^

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: Check if domain is active in GetControlInfo
Jiri Denemark [Thu, 3 Mar 2016 12:26:51 +0000 (13:26 +0100)]
qemu: Check if domain is active in GetControlInfo

Reporting status of a control connection makes no sense for an inactive
domain.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoUse correct LDFLAGS for leaseshelper
Jiri Denemark [Tue, 1 Mar 2016 13:40:39 +0000 (14:40 +0100)]
Use correct LDFLAGS for leaseshelper

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agodaemon: fixup refcounting in close callback handling
Nikolay Shirokovskiy [Thu, 3 Mar 2016 08:01:15 +0000 (11:01 +0300)]
daemon: fixup refcounting in close callback handling

remoteDispatchConnectCloseCallbackRegister introduced in
f484310a has problems. It refcounts network client object and in case of NOOP
driver operations for registering/unregistering close callback (any driver
except for vz) nobody will unref it later. As a result, client connection
will not be disposed and driver connection will not be closed.

The fix is easy. We don't need to refcount at all. We don't get a dangling
pointer because in remoteClientFreeFunc, which is called
upon disposing this network client object, we unregister the close
callback.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agoutil: Cleanup error path for virPolkitAgentCreate
John Ferlan [Wed, 2 Mar 2016 18:59:37 +0000 (13:59 -0500)]
util: Cleanup error path for virPolkitAgentCreate

More fallout from changing to using virPolkitAgent and handling error
paths.  Needed to clear the 'cmd' once stored and of course add the
virCommandFree(cmd) in the error: label.

9 years agodatatypes.c: Replace 'close' with 'closeData'
Michal Privoznik [Tue, 1 Mar 2016 16:39:54 +0000 (17:39 +0100)]
datatypes.c: Replace 'close' with 'closeData'

Older compilers fail to see that 'close' is not used a function
rather than a variable and produce the following error:

cc1: warnings being treated as errors
../../src/datatypes.c: In function 'virConnectCloseCallbackDataReset':
../../src/datatypes.c:149: error: declaration of 'close' shadows a global declaration [-Wshadow]

Replace all the 'close' occurrences with 'closeData' to resolve
this.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoutil: Fix missing initializer for agent
John Ferlan [Wed, 2 Mar 2016 00:36:37 +0000 (19:36 -0500)]
util: Fix missing initializer for agent

In virPolkitAgentCreate neglected to initialize agent to NULL. If
there was an error in the pipe, then we jump to error and would have
an issue. Found by coverity.

9 years agoLibvirt: Add missing default value for config option max_queued_clients
Jason J. Herne [Mon, 29 Feb 2016 13:33:20 +0000 (08:33 -0500)]
Libvirt: Add missing default value for config option max_queued_clients

Commit 1199edb1d4e3 added config option max_queued_clients and documented the
default value as 1000 but never actually set that value. This patch sets the
default value.

This addresses an issue whereby the following error message is reported if too
many migrations are started simultaneously:

error: End of file while reading data: Ncat: Invalid argument.: Input/output error

The problem is that too many ncat processes are spawned on the destination
system. They all attempt to connect to the libvirt socket. Because the
destination libvirtd cannot respond to the connect requests quickly enough we
overrun the socket's pending connections queue.

Signed-off-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
9 years agolibxl: Remove extraneous AFFECT_LIVE and not active check.
Nikolay Shirokovskiy [Wed, 24 Feb 2016 08:38:39 +0000 (11:38 +0300)]
libxl: Remove extraneous AFFECT_LIVE and not active check.

libxlDomainPinVcpuFlags calls virDomainLiveConfigHelperMethod which will
call virDomainObjUpdateModificationImpact make the same AFFECT_LIVE flags
and !active check, so remove this duplicated check.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoconf: Combine if condition in virDomainObjUpdateModificationImpact
Nikolay Shirokovskiy [Wed, 24 Feb 2016 08:38:36 +0000 (11:38 +0300)]
conf: Combine if condition in virDomainObjUpdateModificationImpact

Prior to commit id '3d021381' virDomainObjUpdateModificationImpact was
part of virDomainLiveConfigHelperMethod and the *flags if condition
VIR_DOMAIN_AFFECT_CONFIG checked the ->persistent boolean and made the
virDomainObjGetPersistentDef call.

Since the functions were split the ->persistent check is all that remained
and thus could be combined into one if statement.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>