Commit Graph

17642 Commits

Author SHA1 Message Date
Jiri Denemark
1ac897a15d cpu_x86: Properly drop non-migratable features
By removing a non-migratable feature in a for loop we would fail to drop
every second non-migratable feature if the features array contained
several of them in a row.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-08-10 14:25:24 +02:00
Jiri Denemark
dbb14bb0f1 cpu_x86: Introduce x86FeatureIsMigratable
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-08-10 14:25:24 +02:00
Erik Skultety
9e5e7f3a5b virt-admin: Properly fix the default session daemon URI to admin server
Commit 30ce2f0e tried to fix the issue with an incorrect session URI to admin
server but it messed up the checks:

    if (geteuid == 0 && VIR_STRDUP(*uristr, "libvirtd:///system") < 0)
        return -1;
    else if (VIR_STRDUP(*uristr, "libvirtd:///session") < 0)
        return -1;

So if a client executed with root privileges tries to connect, its euid is
checked (true) and the correct URI is successfully copied to @uristr (false),
therefore the 'else' branch is taken and @uristr is replaced by the session URI
which for root results in:
    Failed to connect socket to '/root/.cache/libvirt/libvirt-admin-sock':
    No such file or directory

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-08-09 15:24:19 +02:00
Erik Skultety
30ce2f0e2a admin: Fix the default uri for session daemon to libvirtd:///session
Just like we decide on which URI we go with based on EUID for qemu in remote
driver, do a similar thing for admin except we do not spawn a daemon in this
case.

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-08-09 13:25:22 +02:00
Marc Hartmayer
cdf065537f virsystemd: Fix error check
Commit b3e4401dc6 introduced a check to ignore an error if the guest
is already terminated. However the check accidentally compared
error.code with VIR_ERR_ERROR, which is an error level, not an error
code. Because of this, almost every error got silently ignored.

Fixes: b3e4401dc6 ("systemd: don't report an error if the guest is
already terminated")

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Sascha Silbe <silbe@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2016-08-08 08:15:59 +02:00
Kai Kang
7e1ca80d87 nsslinktest: also build virAtomic.h
When build for architecture that don't use gcc atomic ops but pthread,
it fails to build for armel:

| ../tools/nss/.libs/libnss_libvirt_impl.a(libvirt_nss_la-virobject.o): In function `virClassNew':
| /buildarea2/kkang/builds/qemuarm-Aug03/bitbake_build/tmp/work/armv5e-wrs-linux-gnueabi/libvirt/1.3.5-r0/build/src/../../libvirt-1.3.5/src/util/virobject.c:153: undefined reference to `virAtomicLock'
| ../tools/nss/.libs/libnss_libvirt_impl.a(libvirt_nss_la-virobject.o): In function `virObjectNew':
| /buildarea2/kkang/builds/qemuarm-Aug03/bitbake_build/tmp/work/armv5e-wrs-linux-gnueabi/libvirt/1.3.5-r0/build/src/../../libvirt-1.3.5/src/util/virobject.c:205: undefined reference to `virAtomicLock'
| ../tools/nss/.libs/libnss_libvirt_impl.a(libvirt_nss_la-virobject.o): In function `virObjectUnref':
| /buildarea2/kkang/builds/qemuarm-Aug03/bitbake_build/tmp/work/armv5e-wrs-linux-gnueabi/libvirt/1.3.5-r0/build/src/../../libvirt-1.3.5/src/util/virobject.c:277: undefined reference to `virAtomicLock'
| ../tools/nss/.libs/libnss_libvirt_impl.a(libvirt_nss_la-virobject.o): In function `virObjectRef':
| /buildarea2/kkang/builds/qemuarm-Aug03/bitbake_build/tmp/work/armv5e-wrs-linux-gnueabi/libvirt/1.3.5-r0/build/src/../../libvirt-1.3.5/src/util/virobject.c:298: undefined reference to `virAtomicLock'
| collect2: error: ld returned 1 exit status

It is similar with:

http://libvirt.org/git/?p=libvirt.git;a=commit;h=12dc729

Signed-off-by: Kai Kang <kai.kang@windriver.com>
2016-08-08 08:06:56 +02:00
Nikolay Shirokovskiy
492a383e58 vz: add vzDomainGetJobStats
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-08-06 22:01:29 +03:00
Nikolay Shirokovskiy
dd7b0a388f vz: add getting job info for migration
Unfortunately vz sdk do not provide detail information on migration
progress, only progress percentage. Thus vz driver provides percents
instead of bytes in data fields of virDomainJobInfoPtr.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-08-06 22:01:02 +03:00
Eric Blake
f33f03d015 build: centralize use of extra Cygwin LDFLAGS
The build was failing with:

  CCLD     lockd.la
libtool:   error: can't build i686-pc-cygwin shared library unless -no-undefined is specified

Rather than add yet another $(CYGWIN_EXTRA_LDFLAGS) to all the
impacted *_la_LDFLAGS, it was easier to just pull the extra
flags into ALL libraries via AM_LDFLAGS.

Then, fix lockd_la_LDFLAGS to include AM_LDFLAGS, like all other
libraries.

Signed-off-by: Eric Blake <eblake@redhat.com>
2016-08-06 07:50:19 -06:00
Eric Blake
aa760cd522 build: use XDR_CFLAGS for Cygwin build
Without XDR_CFLAGS, compilation on Cygwin fails with:

  CC       libvirt_driver_la-libvirt-stream.lo
In file included from libvirt-stream.c:26:0:
rpc/virnetprotocol.h:9:21: fatal error: rpc/rpc.h: No such file or directory

Signed-off-by: Eric Blake <eblake@redhat.com>
2016-08-06 07:27:03 -06:00
Michal Privoznik
5f5a5a42e5 lxcDomainCreateXMLWithFiles: Avoid crash
https://bugzilla.redhat.com/show_bug.cgi?id=1363773

Imagine that you're creating a transient domain, but for some reason,
starting it fails. That is virLXCProcessStart() returns an error. With
current code, in the error handling code the domain object is removed
from the domain object list, @vm is set to NULL and controls jump to
enjob label where virLXCDomainObjEndJob() is called which dereference vm
leading to instant crash.

The fix is to end the job in the error handling code and only after that
remove the domain from the list and jump onto cleanup label instead of
endjob.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-08-05 15:50:19 +02:00
John Ferlan
fbfd6f2103 storage: Don't remove the pool for buildPool failure in storagePoolCreate
https://bugzilla.redhat.com/show_bug.cgi?id=1362349

When adding the ability to build the pool during the start pool processing
using the similar flags as buildPool processing would use, the code was
essentially cut-n-pasted from storagePoolCreateXML.  However, that included
a call to virStoragePoolObjRemove which shouldn't happen within the
storagePoolCreate path since that'll remove the pool from the list of
pools only to be rediscovered if libvirtd restarts.

So on failure, just fail and return as we should expect
2016-08-05 09:30:54 -04:00
Ján Tomko
3f19ac3486 Fix indentation 2016-08-05 10:25:10 +02:00
Jiri Denemark
a80827a7f9 qemu: Add tests for virQEMUCapsNewCopy
Doing a load, copy, format cycle on all QEMU capabilities XML files
should make sure we don't forget to update virQEMUCapsNewCopy when
adding new elements to QEMU capabilities.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-08-05 10:06:01 +02:00
Jiri Denemark
c611c886f5 qemu: Copy missing QEMU caps elements
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-08-05 10:06:01 +02:00
Jiri Denemark
79057b8b3b qemu: Copy QEMU caps elements in order of definition
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-08-05 10:06:01 +02:00
Erik Skultety
5a3558c620 storage: Fix a NULL ptr dereference in virStorageBackendCreateQemuImg
There was a missing check for vol->target.encryption being NULL
at one particular place (modified by commit a48c71411) which caused a crash
when user attempted to create a raw volume using a non-raw file volume as
source.

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

Signed-off-by: Erik Skultety <eskultet@redhat.com>
2016-08-05 09:07:00 +02:00
Peter Krempa
5b7dedc995 internal: Introduce macro for stealing pointers
VIR_STEAL_PTR copies the pointer from the second argument into the
first argument and then sets the second to NULL.
2016-08-05 08:38:20 +02:00
John Ferlan
d5813d72ad tests: Fix broken build
Commit id 'f522b7d2' caused a build failure :

GEN      check-augeas-virtlogd
Test failure:test_libvirtd_qemu.aug:69.3-147.28:
 Expected:
{
...
  { "nvram"
    { "1" = "/usr/share/OVMF/OVMF_CODE.fd:/usr/share/OVMF/OVMF_VARS.fd" }
    { "2" = "/usr/share/AAVMF/AAVMF_CODE.fd:/usr/share/AAVMF/AAVMF_VARS.fd" }
  }
...
 Actual:
...
{
  { "nvram"
    { "1" = "/usr/share/OVMF/OVMF_CODE.fd:/usr/share/OVMF/OVMF_VARS.fd" }
    { "2" = "/usr/share/OVMF/OVMF_CODE.secboot.fd:/usr/share/OVMF/OVMF_VARS.fd" }
    { "3" = "/usr/share/AAVMF/AAVMF_CODE.fd:/usr/share/AAVMF/AAVMF_VARS.fd" }
  }
...

This patch adds the OVMF_CODE.secboot.fd to the aug.in file

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-08-04 15:25:23 -04:00
Boris Fiuczynski
202846f8c3 qemu: fix capability counting
Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
2016-08-04 17:48:19 +02:00
Michal Privoznik
f522b7d269 qemu: Advertise OVMF_CODE.secboot.fd
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-08-04 17:22:48 +02:00
Michal Privoznik
9c1524a01c qemu: Enable secure boot
In qemu, enabling this feature boils down to adding the following
onto the command line:

  -global driver=cfi.pflash01,property=secure,value=on

However, there are some constraints resulting from the
implementation. For instance, System Management Mode (SMM) is
required to be enabled, the machine type must be q35-2.4 or
later, and the guest should be x86_64. While technically it is
possible to have 32 bit guests with secure boot, some non-trivial
CPU flags tuning is required (for instance lm and nx flags must
be prohibited). Given complexity of our CPU driver, this is not
trivial. Therefore I've chosen to forbid 32 bit guests for now.
If there's ever need, we can refine the check later.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-08-04 17:22:20 +02:00
Michal Privoznik
64c2480043 Introduce @secure attribute to os loader element
This element will control secure boot implemented by some
firmwares. If the firmware used in <loader/> does support the
feature we must tell it to the underlying hypervisor. However, we
can't know whether loader does support it or not just by looking
at the file. Therefore we have to have an attribute to the
element where users can tell us whether the firmware is secure
boot enabled or not.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-08-04 17:14:20 +02:00
Michal Privoznik
d0e4be9d02 Introduce SMM feature
Since its release of 2.4.0 qemu is able to enable System
Management Module in the firmware, or disable it. We should
expose this capability in the XML. Unfortunately, there's no good
way to determine whether the binary we are talking to supports
it. I mean, if qemu's run with real machine type, the smm
attribute can be seen in 'qom-list /machine' output. But it's not
there when qemu's run with -M none. Therefore we're stuck with
version based check.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-08-04 17:14:20 +02:00
Michal Privoznik
90b42f0fad qemuBuildMachineCommandLine: Follow our pattern
We use 'goto cleanup' for a reason. If a function can exit at
many places but doesn't follow the pattern, it has to copy the
free code in multiple places.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-08-04 17:14:20 +02:00
Michal Privoznik
b660238eb1 virObjectEventNew: Use virObjectUnref() to free virObjectEvent
While no leak was observed yet, there might be one if
virObjectEventClass is ever derived from another class. Because
in that case plain VIR_FREE() will not call dispose() from parent
classes possibly leaking some memory.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-08-04 15:32:22 +02:00
Michal Privoznik
b3df357da6 libxlDoMigrateReceive: Drop useless check for !vm
In the cleanup path, @vm cannot be possibly NULL. If it were so,
we would receive SIGSEGV much earlier. At the beginning of the
function we do libxlDomainObjBeginJob(.., vm, ..); and so on.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-08-04 15:32:21 +02:00
Michal Privoznik
84b476e2bd virqemu: Reflect return type of virJSONValueArraySize()
The virJSONValueArraySize() function return ssize_t (with
possibly returning -1 if the passed json is not an array).
Storing the return value into size_t is possibly dangerous then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-08-04 15:30:38 +02:00
Peter Krempa
041f35340b qemu: domain: Simplify return values of qemuDomainRefreshVcpuInfo
Call the vcpu thread info validation separately to decrease complexity
of returned values by qemuDomainRefreshVcpuInfo.

This function now returns 0 on success and -1 on error. Certain
failures of qemu to report data are still considered as success. Any
error reported now is fatal.
2016-08-04 08:08:40 +02:00
Peter Krempa
2bdc300a34 qemu: domain: Improve vCPU data checking in qemuDomainRefreshVcpu
Validate the presence of the thread id according to state of the vCPU
rather than just checking the vCPU count. Additionally put the new
validation code into a separate function so that the information
retrieval can be split from the validation.
2016-08-04 08:08:31 +02:00
Peter Krempa
5965fa759c qemu: monitor: Rename qemuMonitor(JSON|Text)GetCPUInfo
Use a name that contains the command used to get the information.
2016-08-04 08:03:58 +02:00
Peter Krempa
8f56b5baaf qemu: domain: Rename qemuDomainDetectVcpuPids to qemuDomainRefreshVcpuInfo
The function will eventually do more useful stuff than just detection of
thread ids.
2016-08-04 08:03:58 +02:00
Peter Krempa
dd976f786c qemu: Improve error message in virDomainGetVcpus
If the VM is offline we can't retrieve the runtime statistical
information. Pinning could be retrieved but there are separate APIs for
that.
2016-08-04 08:03:46 +02:00
Peter Krempa
0f889e725e qemu: monitor: Add do-while block to QEMU_CHECK_MONITOR_FULL
Assure that it's just one statement to avoid problems when used with
conditions.
2016-08-04 08:03:46 +02:00
Peter Krempa
78806cd21b qemu: monitor: Add monitor API for device_add supporting JSON objects
Rather than formatting a string and splitting it back to a JSON object
add API that will take a JSON object directly.
2016-08-04 08:01:29 +02:00
Cole Robinson
e584615b81 conf: events: Fix coverity warning
Since 2bfa75134 virObjectEventNew can be passed a NULL 'uuid' value,
so drop the ATTRIBUTE_NONNULL annotation
2016-08-03 18:45:50 -04:00
Jim Fehlig
c0960aab7e libxl: allow libxl to calculate shadow mem requirements
Long, long ago before libxl_get_required_shadow_memory() was
made publicly available, its code was copied to the libxl driver
for calculating shadow memory requirements of HVM domains.

Long ago, libxl_get_required_shadow_memory() was exported in
libxl_utils.h and included in xen-devel packages everywhere.

Remove the copied code, which has become stale, and let libxl
provode a proper shadow memory value.
2016-08-03 14:07:23 -06:00
John Ferlan
e4e4d17c9c qemu: Add support to get/set IOThread period and quota cgroup values
https://bugzilla.redhat.com/show_bug.cgi?id=1356937

Add support for IOThread quota/bandwidth and period parameters for non
session mode. If in session mode, then error out.  Uses all the same
places where {vcpu|emulator|global}_{period|quota} are adjusted and
adds the iothread values.
2016-08-03 06:36:22 -04:00
John Ferlan
2197ea56d7 conf: Add IOThread quota and period scheduler/cputune defs
https://bugzilla.redhat.com/show_bug.cgi?id=1356937

Add the definitions to allow for viewing/setting cgroup period and quota
limits for IOThreads.

This is similar to the work done for emulator quota and period by
commit ids 'b65dafa' and 'e051c482'.

Being able to view/set the IOThread specific values is related to more
recent changes adding global period (commmit id '4d92d58f') and global
quota (commit id '55ecdae') definitions and qemu support (commit id
'4e17ff79' and 'fbcbd1b2'). With a global setting though, if somehow
the IOThread value in the cgroup hierarchy was set "outside of libvirt"
to a value that is incompatible with the global value.

Allowing control over IOThread specific values provides the capability
to alter the IOThread values as necessary.
2016-08-03 06:36:22 -04:00
Daniel P. Berrange
24555136bf Don't error when attaching security label of model "none"
If you invoke virDomainLxcEnterSecurityLabel() on security
model of "none" it will report an error. Logically a "none"
security model should be treated as a no-op, so we should
just return success immediately, instead of an error.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-08-03 10:58:31 +01:00
Daniel P. Berrange
9cf3c44ff5 qemu: only report errno in trace message on failure
Avoid reporting a stale errno value when the syscall succeeds,
instead always pass 0.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-08-03 10:54:38 +01:00
Peter Krempa
6293644eb0 remote: Fix indentation of the remote protocol structs check file 2016-08-02 16:17:40 +02:00
John Ferlan
1149fe4c15 qemu: Use the hostdev alias in qemuDomainAttachHostSCSIDevice error path
https://bugzilla.redhat.com/show_bug.cgi?id=1289391

Rather than pass the whole drive string (which contained the alias),
pass only the alias for the qemuMonitorDriveDel call in the error
path when adding a host device in the monitor fails.
2016-08-02 10:11:11 -04:00
John Ferlan
8527a25b32 qemu: Use qemuAliasFromHostdev
When building the command line alias and for SCSI Host Device deletion,
use the common API to build the alias
2016-08-02 10:11:11 -04:00
John Ferlan
647bc753d4 qemu: Introduce qemuAliasFromHostdev
Introduce a common API to generate the alias for a host device
2016-08-02 10:11:11 -04:00
John Ferlan
97ca6eed9a qemu: Add attempt to call qemuMonitorDriveDel for AttachSCSI failure path
Completion of fix for:
    https://bugzilla.redhat.com/show_bug.cgi?id=1336225

Similar to the other disk types, add the qemuMonitorDriveDel in the failure
to add/hotplug a SCSI disk.
2016-08-02 10:11:11 -04:00
John Ferlan
190e22c06b qemu: Add attempt to call qemuMonitorDriveDel for USB failure path
Partial fix for:
    https://bugzilla.redhat.com/show_bug.cgi?id=1336225

Similar to the other disk types, add the qemuMonitorDriveDel in the failure
to add/hotplug a USB.

Added a couple of other formatting changes just to have a less cluttered look
2016-08-02 10:11:11 -04:00
John Ferlan
dd0dbe1d66 qemu: Make QEMU_DRIVE_HOST_PREFIX more private
Move QEMU_DRIVE_HOST_PREFIX into the qemu_alias.c to dissuade future
callers from using it. Create qemuAliasDiskDriveSkipPrefix in order
to handle the current consumers that desire to check if an alias has
the drive- prefix and "get beyond it" in order to get the disk alias.
2016-08-02 10:11:11 -04:00
John Ferlan
f0f16c1e28 qemu: Use qemuAliasFromDisk to generate drive alias
Rather than open code build the drive alias command in multiple places,
use the helper to ensure consistency.
2016-08-02 10:11:11 -04:00
John Ferlan
13effcafd2 qemu: Use qemuAliasFromDisk instead of qemuDeviceDriveHostAlias
Since we already have a function that will generate the drivestr from
the alias, let's use it and remove the qemuDeviceDriveHostAlias.

Move the QEMU_DRIVE_HOST_PREFIX definition into qemu_alias.h

Also alter qemuAliasFromDisk to use the QEMU_DRIVE_HOST_PREFIX instead
of "drive-%s".
2016-08-02 10:11:11 -04:00