Commit Graph

20908 Commits

Author SHA1 Message Date
Ján Tomko
668a0fef42 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.)
2015-11-24 13:34:56 +01:00
Peter Krempa
8e104ef011 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.
2015-11-24 13:16:55 +01:00
Peter Krempa
e29dfe9b27 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.
2015-11-24 13:16:55 +01:00
Peter Krempa
a44da44b1c 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.
2015-11-24 13:16:55 +01:00
Peter Krempa
1c888bade5 hyperv: Allocate 'def' via virDomainDefNew
Use the helper that is necessary to fill out some values rather than
allocating it directly.
2015-11-24 13:16:55 +01:00
Christian Loehle
e7aa45055c document virCommandRunRegex function
Signed-off-by: Ján Tomko <jtomko@redhat.com>
2015-11-24 08:23:29 +01:00
Ján Tomko
eebe58adeb qemuSetupChrSourceCgroup: rename dev to source
We do not have a pointer to the device here, just its source.
2015-11-23 13:52:18 +01:00
Ján Tomko
b8286f0666 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.
2015-11-23 13:52:18 +01:00
Ján Tomko
b57ce788a7 rename qemuSetupHostdevCGroup to qemuSetupHostdevCgroup
Change CGroup to Cgroup to match other functions in the file.
2015-11-23 13:52:18 +01:00
Guido Günther
e4ab3b5d38 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
2015-11-23 09:39:29 +01:00
John Ferlan
5e3ad0b775 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.
2015-11-20 17:07:13 -05:00
John Ferlan
ce6506b0bc 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
2015-11-20 17:07:13 -05:00
Andrea Bolognani
16562bbc58 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.
2015-11-20 10:25:14 +01:00
Andrea Bolognani
d269ef165c 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
2015-11-20 10:25:14 +01:00
Andrea Bolognani
79b8c97e99 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.
2015-11-20 10:25:14 +01:00
Andrea Bolognani
cf9bd25655 qemu: Use qemuDomainRequiresMlock() in qemuBuildCommandLine()
This removes a duplication of the logic used to decide whether
the memory locking limit should be set.
2015-11-20 10:25:14 +01:00
Andrea Bolognani
a6a5ac9650 process: Log when limiting the amount of locked memory
This can be useful for debugging.
2015-11-20 10:25:14 +01:00
Jim Fehlig
afbb8a4c8c 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>
2015-11-19 08:53:44 -07:00
Jim Fehlig
97b56031a9 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>
2015-11-19 08:52:53 -07:00
John Ferlan
a3c90fcb94 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)
2015-11-19 08:50:29 -05:00
Mikhail Feoktistov
dbc7819921 vz: implementation of domainReboot callback
Diff from v1.
1. Add virCheckFlags() call in vzDomainReboot
2015-11-19 16:19:27 +03:00
Mikhail Feoktistov
1158184f05 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.
2015-11-19 15:53:07 +03:00
Jiri Denemark
2205d58b32 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>
2015-11-19 09:41:23 +01:00
Jiri Denemark
6e92b4438b 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>
2015-11-19 09:41:23 +01:00
Jiri Denemark
856612876d 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>
2015-11-19 09:41:23 +01:00
Jiri Denemark
65e6548e48 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>
2015-11-19 09:41:23 +01:00
Jiri Denemark
f78d070d68 qemu: Enter monitor within qemuProcessSetLinkStates
Move {Enter,Exit}Monitor calls inside qemuProcessSetLinkStates to
simplify qemuProcessStart.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-11-19 09:41:23 +01:00
Jiri Denemark
dd79eb8b77 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>
2015-11-19 09:41:23 +01:00
Jiri Denemark
fe422b673b 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>
2015-11-19 09:41:23 +01:00
Jiri Denemark
8cff921571 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>
2015-11-19 09:41:23 +01:00
Jiri Denemark
da863c2ad1 qemu: Rename stdin_{fd,path} in qemuProcessStart
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-11-19 09:41:23 +01:00
Jiri Denemark
2c4ba8b4f3 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>
2015-11-19 09:41:23 +01:00
Jiri Denemark
93d56e9df1 qemu: Add APIs for migrate-incoming QMP command
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-11-19 09:41:23 +01:00
Jiri Denemark
04c721f22d 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>
2015-11-19 09:41:23 +01:00
Jiri Denemark
2bf5333f45 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>
2015-11-19 09:41:23 +01:00
Jiri Denemark
34b9fe6101 qemu: Move incoming URI code to qemu_migration
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-11-19 09:41:23 +01:00
Jiri Denemark
08600de376 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>
2015-11-19 09:41:23 +01:00
Jiri Denemark
7148364102 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>
2015-11-19 09:41:23 +01:00
Jiri Denemark
6d1f8899a6 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>
2015-11-19 09:41:23 +01:00
Cole Robinson
01131c0b82 libvirt-domain: Fix typo in debug message 2015-11-18 19:28:45 -05:00
Joao Martins
b52779b30c 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>
2015-11-18 13:48:38 -07:00
Joao Martins
6472e54a98 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>
2015-11-18 13:34:04 -07:00
Richard Weinberger
867f34a683 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>
2015-11-18 11:41:12 +00:00
Richard Weinberger
370707a7a9 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>
2015-11-18 11:29:48 +00:00
Richard Weinberger
ea542455b4 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>
2015-11-18 11:22:33 +00:00
Michal Privoznik
bd3e16a3cf 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>
2015-11-18 10:56:56 +01:00
Peter Krempa
4ad31f8f65 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.
2015-11-18 10:32:18 +01:00
Peter Krempa
542fcbc07d 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.
2015-11-18 10:32:18 +01:00
Peter Krempa
83707dc87e 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.
2015-11-18 10:32:18 +01:00
Peter Krempa
6f95618ed3 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.
2015-11-18 10:32:18 +01:00