]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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

9 years agoutil: add virDiskNameParse to handle disk and partition idx
Joao Martins [Fri, 13 Nov 2015 13:14:44 +0000 (13:14 +0000)]
util: add virDiskNameParse to handle disk and partition idx

Introduce a new helper function "virDiskNameParse" which extends
virDiskNameToIndex but handling both disk index and partition index.
Also rework virDiskNameToIndex to be based on virDiskNameParse.
A test is also added for this function testing both valid and
invalid disk names.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
9 years agolibxl: implement virDomainMemorystats
Joao Martins [Fri, 13 Nov 2015 13:14:42 +0000 (13:14 +0000)]
libxl: implement virDomainMemorystats

Introduce support for domainMemoryStats API call, which
consequently enables the use of `virsh dommemstat` command to
query for memory statistics of a domain. We support
the following statistics: balloon info, available and currently
in use. swap-in, swap-out, major-faults, minor-faults require
cooperation of the guest and thus currently not supported.

We build on the data returned from libxl_domain_info and deliver
it in the virDomainMemoryStat format.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
9 years agovirSetUIDGID: Don't leak supplementary groups
Richard Weinberger [Tue, 23 Jun 2015 11:48:42 +0000 (13:48 +0200)]
virSetUIDGID: Don't leak supplementary groups

The LXC driver uses virSetUIDGID() to become UID/GID 0.
It passes an empty groups list to virSetUIDGID()
to get rid of all supplementary groups from the host side.
But virSetUIDGID() calls setgroups() only if the supplied list
is larger than 0.
This leads to a container root with unrelated supplementary groups.
In most cases this issue is unoticed as libvirtd runs as UID/GID 0
without any supplementary groups.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agolxc: Bind mount container TTYs
Richard Weinberger [Tue, 23 Jun 2015 14:38:57 +0000 (16:38 +0200)]
lxc: Bind mount container TTYs

Instead of creating symlinks, bind mount the devices to
/dev/pts/XY.
Using bind mounts it is no longer needed to add pts devices
to files like /etc/securetty.

Signed-off-by: Richard Weinberger <richard@nod.at>
9 years agolxc: Don't make container's TTY a controlling TTY
Richard Weinberger [Tue, 23 Jun 2015 13:18:53 +0000 (15:18 +0200)]
lxc: Don't make container's TTY a controlling TTY

Userspace does not expect that the initial console
is a controlling TTY. systemd can deal with that, others not.
On sysv init distros getty will fail to spawn a controlling on
/dev/console or /dev/tty1. Which will cause to whole container
to reboot upon ctrl-c.

This patch changes the behavior of libvirt to match the kernel
behavior where the initial TTY is also not controlling.

The only user visible change should be that a container with
bash as PID 1 would complain. But this matches exactly the kernel
be behavior with init=/bin/bash.
To get a controlling TTY for bash just run "setsid /bin/bash".

Signed-off-by: Richard Weinberger <richard@nod.at>
9 years agolocking: Add io_timeout to sanlock
Michal Privoznik [Fri, 23 Oct 2015 11:21:22 +0000 (13:21 +0200)]
locking: Add io_timeout to sanlock

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

So, if domain loses access to storage, sanlock tries to kill it
after some timeout. So far, the default is 80 seconds. But for
some scenarios this might not be enough. We should allow users to
adjust the timeout according to their needs.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: ppc64: Support memory hotplug without NUMA enabled
Peter Krempa [Tue, 13 Oct 2015 17:12:23 +0000 (19:12 +0200)]
qemu: ppc64: Support memory hotplug without NUMA enabled

ppc64 guests don't require adding a NUMA node for hotplug memory to
work. Lift the requirement and add test cases.

9 years agoqemu: command: Prepare memory device def formatter for missing target node
Peter Krempa [Tue, 13 Oct 2015 00:02:22 +0000 (02:02 +0200)]
qemu: command: Prepare memory device def formatter for missing target node

Prepare the command line generator for the possibility that in some
configurations the target NUMA node info will be missing.

9 years agoconf: Prepare making memory device target node optional
Peter Krempa [Wed, 7 Oct 2015 11:52:45 +0000 (13:52 +0200)]
conf: Prepare making memory device target node optional

Adjust the config code so that it does not enforce that target memory
node is specified. To avoid breakage, adjust the qemu memory hotplug
config checker to disallow such config for now.

9 years agoqemu: command: Move dimm device checks from formatter to checker
Peter Krempa [Thu, 8 Oct 2015 05:25:32 +0000 (07:25 +0200)]
qemu: command: Move dimm device checks from formatter to checker

Aggregate the checks of the dimm device into the verification function
rather than having them in the formatter.

9 years agoqemu: domain: Add common function to perform memory hotplug checks
Peter Krempa [Thu, 8 Oct 2015 04:06:15 +0000 (06:06 +0200)]
qemu: domain: Add common function to perform memory hotplug checks

Add a function that will aggregate various checks related to memory
hotplug so that they aren't scattered accross various parts of the
code.

9 years agoqemu: command: Always execute memory device formatter
Peter Krempa [Wed, 7 Oct 2015 13:40:58 +0000 (15:40 +0200)]
qemu: command: Always execute memory device formatter

Since we already make sure before that the domain configuration is
valid we may execute it always at the cost of doing 0 iterations of the
for loop.

This patch will simplify later refactor as it will avoid whitespace
changes.

9 years agoqemu: command: Make qemuBuildMemoryBackendStr usable without NUMA
Peter Krempa [Wed, 7 Oct 2015 12:17:43 +0000 (14:17 +0200)]
qemu: command: Make qemuBuildMemoryBackendStr usable without NUMA

Make the function usable so that -1 can be passed to it as cell ID so
that we can later enable memory hotplug on non-NUMA guests for certain
architectures.

9 years agolibvirt-guests: Disable shutdown timeout
Guido Günther [Tue, 17 Nov 2015 07:39:46 +0000 (08:39 +0100)]
libvirt-guests: Disable shutdown timeout

Since we can't know at service start how many VMs will be running we
can't calculate an apropriate shutdown timeout. So instead of killing
off the service just let it use it's own internal timeout mechanism.

References:
    http://bugs.debian.org/803714
    https://bugzilla.redhat.com/show_bug.cgi?id=1195544

9 years agotpm: adapt sysfs cancel path for new TPM driver
Stefan Berger [Wed, 18 Nov 2015 00:44:13 +0000 (19:44 -0500)]
tpm: adapt sysfs cancel path for new TPM driver

This patch addresses BZ 1244895.

Adapt the sysfs TPM command cancel path for the TPM driver that
does not use a miscdevice anymore since Linux 4.0. Support old
and new paths and check their availability.

Add a mockup for the test cases to avoid the testing for
availability of the cancel path.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
9 years agolibxl: implement virDomainGetCPUStats
Joao Martins [Fri, 13 Nov 2015 13:14:41 +0000 (13:14 +0000)]
libxl: implement virDomainGetCPUStats

Introduce support for domainGetCPUStats API call and consequently
allow us to use `virsh cpu-stats`. The latter returns a more brief
output than the one provided by`virsh vcpuinfo`.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agobhyve: monitor: do not override domain's privateData
Roman Bogorodskiy [Wed, 4 Nov 2015 15:08:00 +0000 (18:08 +0300)]
bhyve: monitor: do not override domain's privateData

Current monitor code overrides domain object's privateData, e.g.
in virBhyveProcessStart():

  vm->privateData = bhyveMonitorOpen(vm, driver);

where bhyveMonitorPtr() returns bhyveMonitorPtr.

This is not right thing to do, so make bhyveMonitorPtr
a part of the bhyveDomainObjPrivate struct and change related code
accordingly.

9 years agosyntax-check: Add prohibit_space_in_label rule
Andrea Bolognani [Mon, 2 Nov 2015 11:12:22 +0000 (12:12 +0100)]
syntax-check: Add prohibit_space_in_label rule

This guards against code such as

 cleanup :

which is happily accepted by the compiler but does not conform
to our style guidelines.

9 years agoutil: remove unnecessary needSize
Chen Hanxiao [Sat, 14 Nov 2015 06:56:06 +0000 (14:56 +0800)]
util: remove unnecessary needSize

Use toadd->use directly.

Signed-off-by: Chen Hanxiao <chenhanxiao@gmail.com>
9 years agostorage: Don't assume storage pool exists for FC/SCSI refresh thread
John Ferlan [Mon, 2 Nov 2015 22:21:11 +0000 (17:21 -0500)]
storage: Don't assume storage pool exists for FC/SCSI refresh thread

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

The virStoragePoolFCRefreshThread had passed a pointer to the pool obj
in the virStoragePoolFCRefreshInfoPtr; however, we cannot assume that
the pool exists still since we don't keep the pool lock throughout
the duration of the thread.

Therefore, instead of passing the pool obj pointer, pass the UUID of
the pool and perform a lookup.  If found, then we can perform the
refresh using the locked pool obj pointer; otherwise, we just exit
the thread since the pool is now gone.

9 years agostorage: Introduce virStoragePoolObjFindPoolByUUID
John Ferlan [Mon, 2 Nov 2015 22:15:41 +0000 (17:15 -0500)]
storage: Introduce virStoragePoolObjFindPoolByUUID

Add a new API to search the currently defined pool list for a pool with
a matching UUID and return the locked pool object pointer.

9 years agostorage: Change cbdata scsi refresh thread field name
John Ferlan [Mon, 2 Nov 2015 19:46:32 +0000 (14:46 -0500)]
storage: Change cbdata scsi refresh thread field name

Change the field name from 'name' to 'fchost_name' to better id it.

9 years agostorage: Make active boolean
John Ferlan [Mon, 2 Nov 2015 21:07:34 +0000 (16:07 -0500)]
storage: Make active boolean

Since we treat it like a boolean, let's store it that way. At least one
path had already treated as true/false anyway.

9 years agoqemu: Explain mlock limit size more in detail
Peter Krempa [Wed, 11 Nov 2015 05:44:56 +0000 (06:44 +0100)]
qemu: Explain mlock limit size more in detail

Based on Alex's explanation [1] in the recent discussion let's update
the comment explaining the memory lock limit calculation.

[1]
http://www.redhat.com/archives/libvir-list/2015-November/msg00329.html

9 years agoqemu: domain: Restructurate control flow in qemuDomainGetMlockLimitBytes
Peter Krempa [Wed, 11 Nov 2015 05:49:06 +0000 (06:49 +0100)]
qemu: domain: Restructurate control flow in qemuDomainGetMlockLimitBytes

Break early when hard limit is set so that it's not intermixed by other
logic for determining the limit.

9 years agoqemu: Fix job entry debug message
Jiri Denemark [Fri, 30 Oct 2015 08:37:14 +0000 (09:37 +0100)]
qemu: Fix job entry debug message

Logging current async job while in BeginJob is useful, but the async job
we want to start is even more interesting.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agotests: Add QEMU 2.4.0 capabilities
Jiri Denemark [Thu, 15 Oct 2015 19:56:22 +0000 (21:56 +0200)]
tests: Add QEMU 2.4.0 capabilities

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agotests: Remove qemuxmlnstest
Jiri Denemark [Tue, 20 Oct 2015 14:01:01 +0000 (16:01 +0200)]
tests: Remove qemuxmlnstest

It's just a copy&paste of qemuxml2argv test anyway. We can test most of
them (except for qemuxmlns-qemu-ns-domain.xml which fails to validate
against our schema) by qemuxml2argv test.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Fix style in qemuProcessStart
Jiri Denemark [Fri, 30 Oct 2015 17:18:10 +0000 (18:18 +0100)]
qemu: Fix style in qemuProcessStart

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agosecurity: Cleanup DAC driver
Jiri Denemark [Fri, 30 Oct 2015 09:20:37 +0000 (10:20 +0100)]
security: Cleanup DAC driver

Fixes several style issues and removes "DEF" (what is it supposed to
mean anyway?) from debug messages.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agodomain-conf: reorder usb controllers so the master is first
Pavel Hrdina [Wed, 11 Nov 2015 14:20:15 +0000 (15:20 +0100)]
domain-conf: reorder usb controllers so the master is first

USB controllers can share the same 'index' which indicates, that there
is some sort of master-companion relationship.  Reorder the controllers
in XML in to place the master controller before its companions.  This is
required by QEMU to not fail with error message:

error: internal error: process exited while connecting to monitor:
2015-10-26T16:25:17.630265Z qemu-system-x86_64:
-device ich9-usb-uhci1,masterbus=usb.0,firstport=0,bus=pci.0,multifunction=on,addr=0x6:
USB bus 'usb.0' not found

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agodomain-conf: cleanup controller insert function
Pavel Hrdina [Wed, 11 Nov 2015 14:18:07 +0000 (15:18 +0100)]
domain-conf: cleanup controller insert function

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agovirsh-domain: update attach-interface to support type=hostdev
Pavel Hrdina [Wed, 21 Oct 2015 10:59:41 +0000 (12:59 +0200)]
virsh-domain: update attach-interface to support type=hostdev

Adding this feature will allow users to easily attach a hostdev network
interface using PCI passthrough.

The interface can be attached using --type=hostdev and PCI address or
as --source.  This command also allows you to tell, whether the interface
should be managed.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agovirsh.pod: improve attach-interface section
Pavel Hrdina [Wed, 11 Nov 2015 14:01:37 +0000 (15:01 +0100)]
virsh.pod: improve attach-interface section

Rewrite the attach-interface section in man page to be more readable and
extendable.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agovz: support cpu time in driver's domainGetInfo
Nikolay Shirokovskiy [Wed, 28 Oct 2015 14:29:00 +0000 (17:29 +0300)]
vz: support cpu time in driver's domainGetInfo

Just straight-forward patch.
Use reference counting for privdom as stats internally could drop domain lock.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agoqemu: fix parsing of -sdl arg
Daniel P. Berrange [Tue, 10 Nov 2015 12:18:47 +0000 (12:18 +0000)]
qemu: fix parsing of -sdl arg

The previous commit

  commit 4e8993a25006bc5d7c95311d430cc01d8de63564
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Mon Nov 9 16:20:08 2015 +0000

    qemu: assume various QEMU 0.10 features are always available

Added broken handling of -sdl. Instead of duplicating existing
SDL handling code, just ensure it is invoked in the right
scenarios.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>