]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
9 years agoadmin: Introduce virAdmConnectGetLibVersion
Erik Skultety [Mon, 5 Oct 2015 15:17:51 +0000 (17:17 +0200)]
admin: Introduce virAdmConnectGetLibVersion

Introduce a new API to get libvirt version. It is worth noting, that
libvirt-admin and libvirt share the same version number. Unfortunately,
our existing API isn't generic enough to be used with virAdmConnectPtr
as well. Also this patch wires up this API to the virt-admin client
as a generic cmdVersion command.

9 years agoadmin: Add support for connection close callbacks
Erik Skultety [Mon, 12 Oct 2015 15:10:57 +0000 (17:10 +0200)]
admin: Add support for connection close callbacks

As we need a client disconnect handler, we also need a mechanism to register
such handlers for a client. This patch introduced both the close callbacks and
also the client vshAdmCatchDisconnect handler to be registered with it. By
registering the handler we still need to make sure the client can react to
daemon's events like disconnect or keepalive, so asynchronous I/O event polling
is necessary to be enabled too.

9 years agoadmin: Add support for URI aliases
Erik Skultety [Fri, 30 Oct 2015 11:11:52 +0000 (12:11 +0100)]
admin: Add support for URI aliases

Now that we introduced URI support in libvirt-admin, we should also support URI
aliases during connection establishment phase. After applying this patch,
virAdmConnectOpen will also support VIR_CONNECT_NO_ALIASES flag.

9 years agolivirt: Move URI alias matching to util
Erik Skultety [Fri, 6 Nov 2015 09:44:53 +0000 (10:44 +0100)]
livirt: Move URI alias matching to util

As we need to provide support for URI aliases in libvirt-admin as well, URI
alias matching needs to be internally visible. Since
virConnectOpenResolveURIAlias does have a compatible signature, it could be
easily reused by libvirt-admin. This patch moves URI alias matching to util,
renaming it accordingly.

9 years agoadmin: Add URI support and introduce virAdmGetDefaultURI
Erik Skultety [Mon, 12 Oct 2015 14:07:52 +0000 (16:07 +0200)]
admin: Add URI support and introduce virAdmGetDefaultURI

Since virt-admin should be able to connect to various admin servers
on hosted different daemons, we need to provide URI support to
libvirt-admin.

9 years agoadmin: Do not generate remoteAdminConnect{Open,Close}
Erik Skultety [Mon, 12 Oct 2015 15:08:29 +0000 (17:08 +0200)]
admin: Do not generate remoteAdminConnect{Open,Close}

As we plan to add more and more logic to remote connecting methods,
these cannot be generated from admin_protocol.x anymore. Instead,
this patch implements these to methods explicitly.

9 years agoadmin: Move remote admin API version to a separate module
Erik Skultety [Thu, 15 Oct 2015 12:48:58 +0000 (14:48 +0200)]
admin: Move remote admin API version to a separate module

By moving the remote version into a separate module, we gain a slightly
better maintainability in the long run than just by leaving it in one
place with the existing libvirt-admin library which can start getting
pretty messy later on.

9 years agoadmin: Introduce virAdmConnectIsAlive
Erik Skultety [Wed, 14 Oct 2015 13:10:02 +0000 (15:10 +0200)]
admin: Introduce virAdmConnectIsAlive

Since most of our APIs rely on an acive functional connection to a daemon and
we have such a mechanism in libvirt already, there's need to have such a way in
libvirt-admin as well. By introducing a new public API, this patch provides
support to check for an active connection.

9 years agovirt-admin: Introduce first working skeleton
Erik Skultety [Mon, 12 Oct 2015 15:07:21 +0000 (17:07 +0200)]
virt-admin: Introduce first working skeleton

This patch introduces virt-admin client which is based on virsh client,
but had to reimplement several methods to meet virt-admin specific needs
or remove unnecessary virsh specific logic.

9 years agoadmin: introduce virAdmGetVersion
Erik Skultety [Thu, 26 Nov 2015 14:08:36 +0000 (15:08 +0100)]
admin: introduce virAdmGetVersion

Unfortunately, client side version retrieval API virGetVersion uses
one-time initialization (due to the fact we might not have initialized the
library by calling connect prior to this) which is not completely compatible
with admin initialization. This API is rather simplistic and reimplementing
it for admin might be the preferred method of reusing it. Note that even though
the method will be reimplemented, the version number is still the same for both
the libvirt and libvirt-admin library.

9 years agolibvirt: Move config getters to util
Erik Skultety [Mon, 12 Oct 2015 14:09:53 +0000 (16:09 +0200)]
libvirt: Move config getters to util

virConnectGetConfig and virConnectGetConfigPath were static libvirt
methods, merely because there hasn't been any need for having them
internally exported yet. Since libvirt-admin also needs to reference
its config file, 'xGetConfig' should be exported.
Besides moving, this patch also renames the methods accordingly,
as they are libvirt config specific.

9 years agoadmin: Introduce libvirt-admin.conf
Erik Skultety [Thu, 12 Nov 2015 14:30:43 +0000 (15:30 +0100)]
admin: Introduce libvirt-admin.conf

Since libvirt-admin is a separate library, it should also have a separate
config file. Available settings are currently the same as for libvirt.conf.

9 years agolibvirt: introduce libvirt/libvirt-common.h.in
Erik Skultety [Thu, 26 Nov 2015 14:02:49 +0000 (15:02 +0100)]
libvirt: introduce libvirt/libvirt-common.h.in

As it turned out, we need to share some enums and declarations between
libvirt.h and libvirt-admin.h, but since our policy forbids direct includes of
libvirt*.h, there has to be some header exempt from this rule. This patch moves
the relevant part of code from libvirt.h.in to libvirt-common.h.in. Moreover,
since there is no need to have libvirt.h generated anymore, introduce a new
header libvirt.h which was previosly ignored from git and make the common
header ignored and generated instead.

9 years agoqemu: add virtio-gpu virgl support
Marc-André Lureau [Wed, 25 Nov 2015 08:42:33 +0000 (09:42 +0100)]
qemu: add virtio-gpu virgl support

Check if virtio-gpu provides virgl option, and add qemu command line
formatter.

It is enabled with the existing accel3d attribute:
<model type='virtio' heads='1'>
 <acceleration accel3d='yes'/>
</model>

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: add virtio video device
Marc-André Lureau [Wed, 25 Nov 2015 08:42:32 +0000 (09:42 +0100)]
qemu: add virtio video device

qemu 2.5 provides virtio video device.  It can be used with -device
virtio-vga for primary devices, or -device virtio-gpu for non-vga
devices. However, only the primary device (VGA) is supported with this
patch.

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

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agodomain: replace bool accel{2d, 3d} with a tristate
Marc-André Lureau [Wed, 25 Nov 2015 08:42:31 +0000 (09:42 +0100)]
domain: replace bool accel{2d, 3d} with a tristate

Allowing to have the extra undefined/default state.

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoReplace support{2d,3d} with accel{2d,3d}
Marc-André Lureau [Wed, 25 Nov 2015 08:42:30 +0000 (09:42 +0100)]
Replace support{2d,3d} with accel{2d,3d}

Following the domain XML naming

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
9 years agosystemd: Escape only needed characters for machined
Martin Kletzander [Fri, 27 Nov 2015 13:24:38 +0000 (14:24 +0100)]
systemd: Escape only needed characters for machined

Machine name escaping follows the same rules as serice name escape,
except that '.' and '-' must not be escaped in machine names, due
to a bug in systemd-machined.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agovirtlogd: Fix build without DBus
Martin Kletzander [Fri, 27 Nov 2015 13:00:39 +0000 (14:00 +0100)]
virtlogd: Fix build without DBus

The rule for virrotatingfiletest was defined in DBUS-only block even
though the test does not use DBus at all.  Also DBUS_CFLAGS and
DBUS_LIBS are removed from the rules.  The original error was:

/usr/lib/gcc/x86_64-pc-linux-gnu/5.2.0/../../../../lib64/Scrt1.o: In
function `_start':
(.text+0x20): undefined reference to `main'

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agologging: remove reference to non-existent augeas files
Daniel P. Berrange [Fri, 27 Nov 2015 14:24:25 +0000 (14:24 +0000)]
logging: remove reference to non-existent augeas files

The libvirt_logd.aug and test_libvirt_logd.aug.in files
have never existed so shouldn't be in EXTRA_DIST. It was
a copy+paste mistake when closing virtlogd from virtlockd

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agologging: avoid variables called 'daemon' due to function clash
Daniel P. Berrange [Fri, 27 Nov 2015 09:26:46 +0000 (09:26 +0000)]
logging: avoid variables called 'daemon' due to function clash

With some versions of GLibC / GCC, a variable called 'daemon'
will result in a warning about clashing with the function also
named 'daemon'. Rename it to 'dmn' to avoid the clash.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agovirtlogd: use %llu to print 64bit types
Guido Günther [Thu, 26 Nov 2015 17:00:09 +0000 (18:00 +0100)]
virtlogd: use %llu to print 64bit types

Otherwise we fail on 32bit with:

CC     logging/virtlogd-log_daemon_dispatch.o
logging/log_daemon_dispatch.c: In function 'virLogManagerProtocolDispatchDomainReadLogFile':
logging/log_daemon_dispatch.c:120:9: error: format '%zu' expects argument of type 'size_t', but argument 7 has type 'uint64_t' [-Werror=format]

9 years agovirtlockd: fix misc memory leaks and other bugs
Daniel P. Berrange [Tue, 24 Nov 2015 13:16:23 +0000 (13:16 +0000)]
virtlockd: fix misc memory leaks and other bugs

Fix memory leaks, failure to restore umask and missing man
page docs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agologging: inhibit virtlogd shutdown while log files are open
Daniel P. Berrange [Tue, 24 Nov 2015 11:47:41 +0000 (11:47 +0000)]
logging: inhibit virtlogd shutdown while log files are open

The virtlogd daemon is launched with a 30 second timeout for
unprivileged users. Unfortunately the timeout is only inhibited
while RPC clients are connected, and they only connect for a
short while to open the log file descriptor. We need to hold
an inhibition for as long as the log file descriptor itself
is open.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: add support for sending QEMU stdout/stderr to virtlogd
Daniel P. Berrange [Tue, 3 Nov 2015 11:13:25 +0000 (11:13 +0000)]
qemu: add support for sending QEMU stdout/stderr to virtlogd

Currently the QEMU stdout/stderr streams are written directly to
a regular file (eg /var/log/libvirt/qemu/$GUEST.log). While those
can be rotated by logrotate (using copytruncate option) this is
not very efficient. It also leaves open a window of opportunity
for a compromised/broken QEMU to DOS the host filesystem by
writing lots of text to stdout/stderr.

This makes it possible to connect the stdout/stderr file handles
to a pipe that is provided by virtlogd. The virtlogd daemon will
read from this pipe and write data to the log file, performing
file rotation whenever a pre-determined size limit is reached.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: convert monitor to use qemuDomainLogContextPtr indirectly
Daniel P. Berrange [Thu, 12 Nov 2015 13:54:04 +0000 (13:54 +0000)]
qemu: convert monitor to use qemuDomainLogContextPtr indirectly

Currently the QEMU monitor is given an FD to the logfile. This
won't work in the future with virtlogd, so it needs to use the
qemuDomainLogContextPtr instead, but it shouldn't directly
access that object either. So define a callback that the
monitor can use for reporting errors from the log file.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: convert process stop/attach to use qemuDomainLogContextPtr
Daniel P. Berrange [Thu, 12 Nov 2015 13:21:47 +0000 (13:21 +0000)]
qemu: convert process stop/attach to use qemuDomainLogContextPtr

When the qemuProcessAttach/Stop methods write a marker into
the log file, they can use qemuDomainLogContextWrite to
write a formatted message.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: convert qemuLogOperation to take a qemuDomainLogContextPtr
Daniel P. Berrange [Thu, 12 Nov 2015 13:02:46 +0000 (13:02 +0000)]
qemu: convert qemuLogOperation to take a qemuDomainLogContextPtr

Instead of writing directly to a log file descriptor, change
qemuLogOperation to use qemuDomainLogContextWrite().

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: change qemuDomainTaint APIs to accept qemuDomainLogContextPtr
Daniel P. Berrange [Thu, 12 Nov 2015 12:56:30 +0000 (12:56 +0000)]
qemu: change qemuDomainTaint APIs to accept qemuDomainLogContextPtr

The qemuDomainTaint APIs currently expect to be passed a log file
descriptor. Change them to instead use a qemuDomainLogContextPtr
to hide the implementation details.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: convert log file creation to use qemuDomainLogContextPtr
Daniel P. Berrange [Thu, 12 Nov 2015 14:28:36 +0000 (14:28 +0000)]
qemu: convert log file creation to use qemuDomainLogContextPtr

Convert the places which create/open log files to use the new
qemuDomainLogContextPtr object instead.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: introduce a qemuDomainLogContext object
Daniel P. Berrange [Thu, 12 Nov 2015 12:43:29 +0000 (12:43 +0000)]
qemu: introduce a qemuDomainLogContext object

Introduce a qemuDomainLogContext object to encapsulate
handling of I/O to/from the domain log file. This will
hide details of the log file implementation from the
rest of the driver, making it easier to introduce
support for virtlogd later.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: unify code for reporting errors from QEMU log files
Daniel P. Berrange [Thu, 12 Nov 2015 11:01:07 +0000 (11:01 +0000)]
qemu: unify code for reporting errors from QEMU log files

There are two pretty similar functions qemuProcessReadLog and
qemuProcessReadChildErrors. Both read from the QEMU log file
and try to strip out libvirt messages. The latter then reports
an error, while the former lets the callers report an error.

Re-write qemuProcessReadLog so that it uses a single read
into a dynamically allocated buffer. Then introduce a new
qemuProcessReportLogError that calls qemuProcessReadLog
and reports an error.

Convert all callers to use qemuProcessReportLogError.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: remove writing to QEMU log file for rename operation
Daniel P. Berrange [Wed, 11 Nov 2015 16:06:07 +0000 (16:06 +0000)]
qemu: remove writing to QEMU log file for rename operation

The rename operation only works on inactive virtual machines,
but it none the less writes to the log file used by the QEMU
processes. This log file is not intended to provide a general
purpose audit trail of operations performed on VMs. The audit
subsystem has recording of important operations. If we want
to extend that to cover all significant public APIs that is
a valid thing to consider, but we shouldn't arbitrarily log
specific APIs into the QEMU log file in the meantime.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agologging: add client for virtlogd daemon
Daniel P. Berrange [Tue, 3 Nov 2015 11:09:25 +0000 (11:09 +0000)]
logging: add client for virtlogd daemon

Add the virLogManager API which allows for communication with
the virtlogd daemon to RPC program. This provides the client
side API to open log files for guest domains.

The virtlogd daemon is setup to auto-spawn on first use when
running unprivileged. For privileged usage, systemd socket
activation is used instead.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agologging: introduce log handling protocol
Daniel P. Berrange [Tue, 3 Nov 2015 11:01:21 +0000 (11:01 +0000)]
logging: introduce log handling protocol

Define a new RPC protocol for the virtlogd daemon that provides
for handling of logs. The initial RPC method defined allows a
client to obtain a file handle to use for writing to a log
file for a guest domain. The file handle passed back will not
actually refer to the log file, but rather an anonymous pipe.
The virtlogd daemon will forward I/O between them, ensuring
file rotation happens when required.

Initially the log setup is hardcoded to cap log files at
128 KB, and keep 3 backups when rolling over, which gives
a max usage of 512 KB per guest.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoImport stripped down virtlockd code as basis of virtlogd
Daniel P. Berrange [Mon, 9 Feb 2015 16:35:05 +0000 (16:35 +0000)]
Import stripped down virtlockd code as basis of virtlogd

Copy the virtlockd codebase across to form the initial virlogd
code. Simple search & replace of s/lock/log/ and gut the remote
protocol & dispatcher. This gives us a daemon that starts up
and listens for connections, but does nothing with them.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoutil: add APIs for reading/writing from/to rotating files
Daniel P. Berrange [Fri, 6 Nov 2015 14:25:48 +0000 (14:25 +0000)]
util: add APIs for reading/writing from/to rotating files

Add virRotatingFileReader and virRotatingFileWriter objects
which allow reading & writing from/to files with automation
rotation to N backup files when a size limit is reached. This
is useful for guest logging when a guaranteed finite size
limit is required. Use of external tools like logrotate is
inadequate since it leaves the possibility for guest to DOS
the host in between invokations of logrotate.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agosystemd: Escape machine name for machined
Martin Kletzander [Tue, 24 Nov 2015 14:56:12 +0000 (15:56 +0100)]
systemd: Escape machine name for machined

According to the documentation, CreateMachine accepts only 7bit ASCII
characters in the machinename parameter, so let's make sure we can start
machines with unicode names with systemd.  We already have a function
for that, we just forgot to use it.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agovirsh: Try to keep printed XML pretty with change-media
Martin Kletzander [Fri, 6 Nov 2015 14:11:36 +0000 (15:11 +0100)]
virsh: Try to keep printed XML pretty with change-media

When adding a new media with change-media and --print-xml, let's try
making it more readable and nice.

Before:
<disk type="file" device="cdrom">
...
      <target dev="hdb" bus="ide"/>
      <address type="drive" controller="0" bus="0" target="0" unit="1"/>
    <source file="/tmp/a.iso"/></disk>

After:
<disk type="file" device="cdrom">
...
      <source file="/tmp/a.iso"/>
      <target dev="hdb" bus="ide"/>
      <address type="drive" controller="0" bus="0" target="0" unit="1"/>
    </disk>

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoschema: use a better regex for listen addresses
Ján Tomko [Thu, 26 Nov 2015 09:39:54 +0000 (10:39 +0100)]
schema: use a better regex for listen addresses

A domain with '::' as the listen address fails to validate.

Reuse the 'ipAddr' and 'dnsName' regexes from basictypes instead
of reinventing them.

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

9 years agoEnhance documentation of virDomainDetachDevice
Jiri Denemark [Wed, 25 Nov 2015 15:39:17 +0000 (16:39 +0100)]
Enhance documentation of virDomainDetachDevice

Link it to virDomainDetachDeviceFlags.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Use qemuProcessLaunch in migration Prepare phase
Jiri Denemark [Tue, 10 Nov 2015 12:43:04 +0000 (13:43 +0100)]
qemu: Use qemuProcessLaunch in migration Prepare phase

Using qemuProcess{Init,Launch,FinishStartup} allows us to run
pre-migration commands on destination before asking QEMU to wait for
incoming migration data.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Skip starting NBD servers for offline migration
Jiri Denemark [Tue, 10 Nov 2015 11:56:29 +0000 (12:56 +0100)]
qemu: Skip starting NBD servers for offline migration

NBD storage migration will not work with offline migration anyway and we
already checked that the user did not ask for it. Thus it doesn't make
sense to keep the code after 'done' label where we jump in case of
offline migration.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Kill QEMU process if Prepare phase fails
Jiri Denemark [Tue, 10 Nov 2015 11:41:01 +0000 (12:41 +0100)]
qemu: Kill QEMU process if Prepare phase fails

Some failure paths in qemuMigrationPrepareAny forgot to kill the just
started QEMU process. This patch fixes this by combining 'stop' and
'endjob' label into a new label 'stopjob'. This name was chosen to avoid
confusion with the most common semantics of 'endjob'. Normally, 'endjob'
is always called at the end of an API to stop the job we entered at the
beginning. In qemuMigrationPrepareAny we only want to stop the job in
failure path; on success we need to carry the job over to the Finish
phase.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Separate incoming URI generation from qemuMigrationPrepareAny
Jiri Denemark [Thu, 5 Nov 2015 14:21:02 +0000 (15:21 +0100)]
qemu: Separate incoming URI generation from qemuMigrationPrepareAny

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Introduce qemuProcessFinishStartup
Jiri Denemark [Tue, 10 Nov 2015 12:29:40 +0000 (13:29 +0100)]
qemu: Introduce qemuProcessFinishStartup

Finishes starting a new domain launched by qemuProcessLaunch.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Introduce qemuProcessLaunch
Jiri Denemark [Tue, 10 Nov 2015 15:58:41 +0000 (16:58 +0100)]
qemu: Introduce qemuProcessLaunch

Once qemuProcessInit was called, qemuProcessLaunch will launch a new
QEMU process with stopped virtual CPUs.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Introduce qemuProcessInit
Jiri Denemark [Tue, 10 Nov 2015 15:58:12 +0000 (16:58 +0100)]
qemu: Introduce qemuProcessInit

qemuProcessStart is going to be split in three parts: qemuProcessInit,
qemuProcessLaunch, and qemuProcessFinish so that migration Prepare phase
can insert additional code in the process. qemuProcessStart will be a
small wrapper for all other callers.

qemuProcessInit prepares the domain up to the point when priv->qemuCaps
is initialized.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoconf: reject multiple panic devices of same model
Dmitry Andreev [Tue, 24 Nov 2015 12:26:38 +0000 (15:26 +0300)]
conf: reject multiple panic devices of same model

Only one panic device per model is allowed.

9 years agoAllow multiple panic devices
Dmitry Andreev [Tue, 24 Nov 2015 12:26:36 +0000 (15:26 +0300)]
Allow multiple panic devices

'model' attribute was added to a panic device but only one panic
device is allowed. This patch changes panic device presence
from 'optional' to 'zeroOrMore'.

9 years agoqemu: add support for hv_crash feature as a panic device
Dmitry Andreev [Tue, 24 Nov 2015 12:26:33 +0000 (15:26 +0300)]
qemu: add support for hv_crash feature as a panic device

Panic device type used depends on 'model' attribute.

If no model is specified then device type depends on hypervisor
and guest arch. 'pseries' model is used for pSeries guest and
'isa' model is used in other cases.

XML:
<devices>
  <panic model='hyperv'/>
</devices>

QEMU command line:
qemu -cpu <cpu_model>,hv_crash

9 years agotests: add tests for the new panic device attribute - 'model'
Dmitry Andreev [Tue, 24 Nov 2015 12:26:32 +0000 (15:26 +0300)]
tests: add tests for the new panic device attribute - 'model'

9 years agoconf: add 'model' attribute for panic device with values isa, pseries, hyperv
Dmitry Andreev [Tue, 24 Nov 2015 12:26:31 +0000 (15:26 +0300)]
conf: add 'model' attribute for panic device with values isa, pseries, hyperv

Libvirt already has two types of panic devices - pvpanic and pSeries firmware.
This patch introduces the 'model' attribute and a new type of panic device.

'isa' model is for ISA pvpanic device.
'pseries' model is a default value for pSeries guests.
'hyperv' model is the new type. It's used for Hyper-V crash.

Schema and docs are updated for the new attribute.

9 years agoconf: refactor code for checking ABI stability of panic device
Dmitry Andreev [Tue, 24 Nov 2015 12:26:30 +0000 (15:26 +0300)]
conf: refactor code for checking ABI stability of panic device

9 years agoapparmor: add missing qemu binaries
Guido Günther [Tue, 24 Nov 2015 15:04:18 +0000 (16:04 +0100)]
apparmor: add missing qemu binaries

This adds the qemu binaries as of 1.2.4 in Debian. It also removes a
duplicate sparc64 entry.

9 years agonodedev: report maxCount for virtual_functions capability
Laine Stump [Mon, 23 Nov 2015 19:19:13 +0000 (14:19 -0500)]
nodedev: report maxCount for virtual_functions capability

A PCI device may have the capability to setup virtual functions (VFs)
but have them currently all disabled. Prior to this patch, if that was
the case the the node device XML for the device wouldn't report any
virtual_functions capability.

With this patch, if a file called "sriov_totalvfs" is found in the
device's sysfs directory, its contents will be interpreted as a
decimal number, and that value will be reported as "maxCount" in a
capability element of the device's XML, e.g.:

   <capability type='virtual_functions' maxCount='7'/>

This will be reported regardless of whether or not any VFs are
currently enabled for the device.

NB: sriov_numvfs (the number of VFs currently active) is also
available in sysfs, but that value is implied by the number of items
in the list that is inside the capability element, so there is no
reason to explicitly provide it as an attribute.

sriov_totalvfs and sriov_numvfs are available in kernels at least as far
back as the 2.6.32 that is in RHEL6.7, but in the case that they
simply aren't there, libvirt will behave as it did prior to this patch
- no maxCount will be displayed, and the virtual_functions capability
will be absent from the device's XML when 0 VFs are enabled.

9 years agoconf: support reporting maxCount attribute for virtual_functions cap
Laine Stump [Mon, 23 Nov 2015 19:50:31 +0000 (14:50 -0500)]
conf: support reporting maxCount attribute for virtual_functions cap

Report the maximum possible number of VFs for an SRIOV PF, like this:

   <capability type='virtual_functions' maxCount='7'>
      ...
   </capability>

I've just discovered that the virtual_functions and physical_functions
capabilities are not supported in the virNodeDeviceParse functions,
only in virNodeDeviceFormat (I suppose because they are only reported,
not set from XML). This should probably be remedied, but is less
immediately useful than the current patch.

9 years agoqemu: monitor: Explain logic of qemuMonitorGetCPUInfo
Peter Krempa [Thu, 29 Oct 2015 13:30:23 +0000 (14:30 +0100)]
qemu: monitor: Explain logic of qemuMonitorGetCPUInfo

The return value has non-obvious semantics. Document it.

9 years agoPost-release version bump to 1.3.0
Pavel Hrdina [Tue, 24 Nov 2015 11:48:50 +0000 (12:48 +0100)]
Post-release version bump to 1.3.0

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agoconf: Drop useless check when parsing cpu scheduler info
Peter Krempa [Mon, 19 Oct 2015 12:36:14 +0000 (14:36 +0200)]
conf: Drop useless check when parsing cpu scheduler info

The checked predicate is a deduction from the following checks:

1) maximum cpu id is checked for every parsed <vcpusched> element
2) the resulting bitmaps are checked for overlaps
3) there has to be at least one cpu per <vcpusched>

From the above checks we can indeed deduce that if we have one
<vcpusched> element per CPU we will have at most 'maxvcpus' of them.

Drop the explicit check since it's redundant.

9 years agoqemu: pass the asyncJob to qemuProcessStartCPUs
Ján Tomko [Tue, 24 Nov 2015 12:14:29 +0000 (13:14 +0100)]
qemu: pass the asyncJob to qemuProcessStartCPUs

Now that new domains are started inside a QEMU_ASYNC_JOB_START job,
we need to pass it down to qemuProcessStartCPUs too.

This removes the warning:
qemuDomainObjEnterMonitorInternal:1750 : This thread seems to be the
async job owner; entering monitor without asking for a nested job is
dangerous

Introduced by commit 04c721f, before that this code path was only
executed with QEMU_ASYNC_JOB_NONE.

(This code is not executed on migration, because qemuMigrationPrepareAny
 sets the VIR_QEMU_PROCESS_START_PAUSED flag.)

9 years agoxenapi: Refactor extraction of vcpu count
Peter Krempa [Fri, 16 Oct 2015 13:38:48 +0000 (15:38 +0200)]
xenapi: Refactor extraction of vcpu count

To simplify further refactors change the way the vcpu count is extracted
to use a temp variable rather than juggling with def->maxvcpus.

9 years agophyp: Refactor extraction of vcpu count
Peter Krempa [Fri, 16 Oct 2015 13:38:48 +0000 (15:38 +0200)]
phyp: Refactor extraction of vcpu count

To simplify further refactors change the way the vcpu count is extracted
to use a temp variable rather than juggling with def.maxvcpus.

9 years agoopenvz: Refactor extraction of vcpu count
Peter Krempa [Fri, 16 Oct 2015 13:38:48 +0000 (15:38 +0200)]
openvz: Refactor extraction of vcpu count

To simplify further refactors change the way the vcpu count is extracted
to use a temp variable rather than juggling with def->maxvcpus.

9 years agohyperv: Allocate 'def' via virDomainDefNew
Peter Krempa [Mon, 19 Oct 2015 17:06:55 +0000 (19:06 +0200)]
hyperv: Allocate 'def' via virDomainDefNew

Use the helper that is necessary to fill out some values rather than
allocating it directly.

9 years agodocument virCommandRunRegex function
Christian Loehle [Mon, 23 Nov 2015 14:06:37 +0000 (15:06 +0100)]
document virCommandRunRegex function

Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agoqemuSetupChrSourceCgroup: rename dev to source
Ján Tomko [Thu, 19 Nov 2015 15:26:56 +0000 (16:26 +0100)]
qemuSetupChrSourceCgroup: rename dev to source

We do not have a pointer to the device here, just its source.

9 years agoSimplify qemuSetupChrSourceCgroup and its callers
Ján Tomko [Thu, 19 Nov 2015 13:25:44 +0000 (14:25 +0100)]
Simplify qemuSetupChrSourceCgroup and its callers

The domain definition is not needed in any of these functions.
Only pass it to qemuSetupChardevCgroup, which is used as a callback
for virDomainChrDefForeach.

Use the right type for passing virDomainObjPtr instead of
void* where possible.

9 years agorename qemuSetupHostdevCGroup to qemuSetupHostdevCgroup
Ján Tomko [Thu, 19 Nov 2015 13:35:46 +0000 (14:35 +0100)]
rename qemuSetupHostdevCGroup to qemuSetupHostdevCgroup

Change CGroup to Cgroup to match other functions in the file.

9 years agoqemu: handle more machines with a single builtin IDE controller
Guido Günther [Sat, 21 Nov 2015 18:58:56 +0000 (19:58 +0100)]
qemu: handle more machines with a single builtin IDE controller

like I440FX by moving the condition into qemuDomainMachineHasBuiltinIDE
and adding more machines.

Reference: http://bugs.debian.org/805189

9 years agostorage: Change virStorageBackendVolOpen to use virFileOpenAs
John Ferlan [Tue, 17 Nov 2015 15:13:43 +0000 (10:13 -0500)]
storage: Change virStorageBackendVolOpen to use virFileOpenAs

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

Rather than using just open on the path, allow for the possibility that
the path to be opened resides on an NFS root-squash target and was created
under a different uid/gid.

Without using virFileOpenAs an attempt to get the volume size data may fail
if the current user doesn't have permissions to read the volume, such as
would be the case if mode wasn't supplied in the volume XML and the default
VIR_STORAGE_DEFAULT_VOL_PERM_MODE (e.g. 0600) was used. Under this scenario
the owner/group is not root:root, thus this path run under root would fail
to open/read the volume.

NB: The virFileOpenAs code using OPEN_FORK will only work when the failure
is not EACESS/EPERM and the path resolves to a shared file system.

9 years agostorage: Really fix setting mode for backend exec in NFS root-squash env
John Ferlan [Tue, 17 Nov 2015 13:49:19 +0000 (08:49 -0500)]
storage: Really fix setting mode for backend exec in NFS root-squash env

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

Although commit id '77346f27' resolves part of the problem regarding creating
a qemu-img image in an NFS root-squash environment, it really didn't fix the
entire problem. Unfortunately it only masked the problem. It seems qemu-img
must open/create the image using 0644, which if used by target.perms would
result in the chmod not being called since the mode desired and set match.

Although qemu-img could conceivably ignore the mode when creating, libvirt
has more knowledge of the environment and can make the adjustment to the
mode far more easily by using virFileOpenAs with VIR_FILE_OPEN_FORCE_MODE.
If that's successful, then we know on return the file will have the right
owner and mode, so we can declare success

9 years agoqemu: Always set locked memory limit for ppc64 domains
Andrea Bolognani [Fri, 13 Nov 2015 09:58:07 +0000 (10:58 +0100)]
qemu: Always set locked memory limit for ppc64 domains

Unlike other architectures, ppc64 domains need to lock memory
even when VFIO is not used.

Change qemuDomainRequiresMlock() to reflect this fact.

9 years agoqemu: Add ppc64-specific math to qemuDomainGetMlockLimitBytes()
Andrea Bolognani [Fri, 13 Nov 2015 09:37:12 +0000 (10:37 +0100)]
qemu: Add ppc64-specific math to qemuDomainGetMlockLimitBytes()

The amount of memory a ppc64 domain might need to lock is different
than that of a equally-sized x86 domain, so we need to check the
domain's architecture and act accordingly.

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

9 years agoqemu: Use qemuDomainRequiresMlock() when attaching PCI hostdev
Andrea Bolognani [Wed, 18 Nov 2015 11:10:33 +0000 (12:10 +0100)]
qemu: Use qemuDomainRequiresMlock() when attaching PCI hostdev

The function is used everywhere else to check whether the locked
memory limit should be set / updated, and it should be used here
as well.

Moreover, qemuDomainGetMlockLimitBytes() expects the hostdev to
have already been added to the domain definition, but we only do
that at the end of qemuDomainAttachHostPCIDevice(). Work around
the issue by adding the hostdev before adjusting the locked memory
limit and removing it immediately afterwards.

9 years agoqemu: Use qemuDomainRequiresMlock() in qemuBuildCommandLine()
Andrea Bolognani [Thu, 12 Nov 2015 15:32:53 +0000 (16:32 +0100)]
qemu: Use qemuDomainRequiresMlock() in qemuBuildCommandLine()

This removes a duplication of the logic used to decide whether
the memory locking limit should be set.

9 years agoprocess: Log when limiting the amount of locked memory
Andrea Bolognani [Thu, 12 Nov 2015 13:46:12 +0000 (14:46 +0100)]
process: Log when limiting the amount of locked memory

This can be useful for debugging.

9 years agolibxl: don't unlock virDomainObj if refcnt is 0
Jim Fehlig [Wed, 18 Nov 2015 22:47:25 +0000 (15:47 -0700)]
libxl: don't unlock virDomainObj if refcnt is 0

Commit 6472e54a unlocks the virDomainObj even if libxlDomainObjEndJob
returns false, indicating that its refcnt has dropped to 0.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agolibxl: unref libxlDriverConfig object
Jim Fehlig [Wed, 18 Nov 2015 22:47:24 +0000 (15:47 -0700)]
libxl: unref libxlDriverConfig object

Commits b6e19cf4 and 6472e54a missed unref'ing the
libxlDriverConfig object. Add missing calls to virObjectUnref.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoqemu: Fix build error in Coverity environment
John Ferlan [Thu, 19 Nov 2015 11:21:22 +0000 (06:21 -0500)]
qemu: Fix build error in Coverity environment

Commit id '08600de37' changed the prototype to reduce an argument, but
didn't adjust the ATTRIBUTE_NONNULL(11) to (10)

9 years agovz: implementation of domainReboot callback
Mikhail Feoktistov [Thu, 19 Nov 2015 12:16:48 +0000 (15:16 +0300)]
vz: implementation of domainReboot callback

Diff from v1.
1. Add virCheckFlags() call in vzDomainReboot

9 years agovz: allow only en-us keymap for VNC
Mikhail Feoktistov [Wed, 18 Nov 2015 15:19:07 +0000 (18:19 +0300)]
vz: allow only en-us keymap for VNC

In virtuozzo we support only en-us keymap for VMs and containers.
If keymap is specified than check that it's en-us, otherwise
show error message.

9 years agoqemu: Close logfd when closing monitor
Jiri Denemark [Wed, 4 Nov 2015 11:45:15 +0000 (12:45 +0100)]
qemu: Close logfd when closing monitor

Remembering to call qemuMonitorSetDomainLog in the right paths before
calling qemuProcessStop is annoying and easy to forget. And I already
forgot to do so in commit v1.2.8-52-g0389060: logfd may be leaked if
QEMU process dies between Prepare and Finish migration phases.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Do not infer flags from other qemuProcessStart arguments
Jiri Denemark [Thu, 5 Nov 2015 13:32:16 +0000 (14:32 +0100)]
qemu: Do not infer flags from other qemuProcessStart arguments

Every caller setting migrateFrom already sets
VIR_QEMU_PROCESS_START_PAUSED flag anyway.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Introduce qemuProcessMakeDir
Jiri Denemark [Mon, 2 Nov 2015 12:39:28 +0000 (13:39 +0100)]
qemu: Introduce qemuProcessMakeDir

qemuProcessMakeDir is used for creating a per-domain directory in a
given parent directory.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Separate balloon code from qemuProcessStart
Jiri Denemark [Mon, 2 Nov 2015 10:00:49 +0000 (11:00 +0100)]
qemu: Separate balloon code from qemuProcessStart

qemuProcessStart is so big that any nontrivial code should be moved to
dedicated functions to make the code easier to read and maintain.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Enter monitor within qemuProcessSetLinkStates
Jiri Denemark [Mon, 2 Nov 2015 09:50:21 +0000 (10:50 +0100)]
qemu: Enter monitor within qemuProcessSetLinkStates

Move {Enter,Exit}Monitor calls inside qemuProcessSetLinkStates to
simplify qemuProcessStart.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Separate raw IO code from qemuProcessStart
Jiri Denemark [Mon, 2 Nov 2015 09:35:58 +0000 (10:35 +0100)]
qemu: Separate raw IO code from qemuProcessStart

qemuProcessStart is so big that any nontrivial code should be moved to
dedicated functions to make the code easier to read and maintain.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Separate graphics handling code from qemuProcessStart
Jiri Denemark [Fri, 30 Oct 2015 17:16:53 +0000 (18:16 +0100)]
qemu: Separate graphics handling code from qemuProcessStart

qemuProcessStart is so big that any nontrivial code should be moved to
dedicated functions to make the code easier to read and maintain.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Separate hook handling code from qemuProcessStart
Jiri Denemark [Fri, 30 Oct 2015 16:59:43 +0000 (17:59 +0100)]
qemu: Separate hook handling code from qemuProcessStart

qemuProcessStart is so big that any nontrivial code should be moved to
dedicated functions to make the code easier to read and maintain.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Rename stdin_{fd,path} in qemuProcessStart
Jiri Denemark [Fri, 30 Oct 2015 10:43:30 +0000 (11:43 +0100)]
qemu: Rename stdin_{fd,path} in qemuProcessStart

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Use -incoming defer for migrations
Jiri Denemark [Wed, 11 Nov 2015 17:02:23 +0000 (18:02 +0100)]
qemu: Use -incoming defer for migrations

Traditionally, we pass incoming migration URI on QEMU command line,
which has some drawbacks. Depending on the URI QEMU may initialize its
migration state immediately without giving us a chance to set any
additional migration parameters (this applies mainly for fd: URIs). For
some URIs the monitor may be completely blocked from the beginning until
migration is finished, which means we may be stuck in qmp_capabilities
command without being able to send any QMP commands.

QEMU solved this by introducing "defer" parameter for -incoming command
line option. This will tell QEMU to prepare for an incoming migration
while the actual incoming URI is sent using migrate-incoming QMP
command. Before calling this command we can normally talk to the
monitor and even set any migration parameters which will be honored by
the incoming migration.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Add APIs for migrate-incoming QMP command
Jiri Denemark [Tue, 20 Oct 2015 20:51:48 +0000 (22:51 +0200)]
qemu: Add APIs for migrate-incoming QMP command

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Always set async job when starting a domain
Jiri Denemark [Wed, 21 Oct 2015 08:55:43 +0000 (10:55 +0200)]
qemu: Always set async job when starting a domain

We only started an async job for incoming migration from another host.
When we were starting a domain from scratch or restoring from a saved
state (migration from file) we didn't set any async job. Let's introduce
a new QEMU_ASYNC_JOB_START for these cases.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Introduce qemuProcessIncomingDef
Jiri Denemark [Fri, 6 Nov 2015 17:41:37 +0000 (18:41 +0100)]
qemu: Introduce qemuProcessIncomingDef

Incoming migration may require quite a few parameters (URI, fd, path) to
be considered while starting QEMU and we will soon add another one.
Let's group all of them in a single struct.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Move incoming URI code to qemu_migration
Jiri Denemark [Tue, 20 Oct 2015 13:48:33 +0000 (15:48 +0200)]
qemu: Move incoming URI code to qemu_migration

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Don't generate migration URI in qemuBuildCommandLine
Jiri Denemark [Tue, 20 Oct 2015 11:51:01 +0000 (13:51 +0200)]
qemu: Don't generate migration URI in qemuBuildCommandLine

Make callers of qemuBuildCommandLine responsible for providing the URI
which should be passed as a parameter for -incoming.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Refactor the code to build -incoming command line
Jiri Denemark [Fri, 16 Oct 2015 15:01:39 +0000 (17:01 +0200)]
qemu: Refactor the code to build -incoming command line

Move the code from qemuBuildCommandLine into dedicated functions.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Refactor waiting for completed migration on destination
Jiri Denemark [Thu, 15 Oct 2015 17:49:22 +0000 (19:49 +0200)]
qemu: Refactor waiting for completed migration on destination

Move the code from qemuMigrationFinish into a dedicated function.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agolibvirt-domain: Fix typo in debug message
Cole Robinson [Thu, 19 Nov 2015 00:28:45 +0000 (19:28 -0500)]
libvirt-domain: Fix typo in debug message