Commit Graph

3589 Commits

Author SHA1 Message Date
Erik Skultety
e3a7b8740f qemu: Fix updating balloon period in live XML
Up until now, we set memballoon period in monitor successfully, however
we did not update domain definition structure, thus dumpxml was omitting
period attribute in memballoon element

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1140960
2014-10-02 16:10:53 -04:00
Erik Skultety
f4ba3385ba qemu: Fix updating bandwidth limits in live XML
When trying to update bandwidth limits on a running domain, limits get
updated in our internal structures, however XML parser reads
bandwidth limits from network 'actual' definition. Committing this patch
it is now available to update bandwidth 'actual' definition as well,
thus updating domain runtime XML.
2014-10-02 16:10:53 -04:00
Guido Günther
4882618ed1 qemu: use systemd's TerminateMachine to kill all processes
If we don't properly clean up all processes in the
machine-<vmname>.scope systemd won't remove the cgroup and subsequent vm
starts fail with

  'CreateMachine: File exists'

Additional processes can e.g. be added via

  echo $PID > /sys/fs/cgroup/systemd/machine.slice/machine-${VMNAME}.scope/tasks

but there are other cases like

  http://bugs.debian.org/761521

Invoke TerminateMachine to be on the safe side since systemd tracks the
cgroup anyway. This is a noop if all processes have terminated already.
2014-10-01 20:17:46 +02:00
Peter Krempa
92427948b3 maint: Prohibit "devname" by a syntax check rules
and tweak the code to avoid using it.
2014-10-01 16:39:01 +02:00
Peter Krempa
72945c0629 qemu: monitor: Avoid shadowing variable "devname" on FreeBSD. Again.
FreeBSD's compiler complains that we shadow the symbol. Sigh.

s/devname/dev_name/
2014-10-01 14:39:23 +02:00
Peter Krempa
58699b77ee qemu: json: Fix missing break in error reporting function
Otherwise we'd report a different error.

Reported by John Ferlan's coverity run.
2014-10-01 14:33:09 +02:00
Francesco Romani
7557ddf8be qemu: bulk stats: add block allocation information
Management software wants to be able to allocate disk space on demand.
To support this they need keep track of the space occupation of the
block device.  This information is reported by qemu as part of block
stats.

This patch extend the block information in the bulk stats with the
allocation information.

To keep the same behaviour a helper is extracted from
qemuMonitorJSONGetBlockExtent in order to get per-device allocation
information.

Signed-off-by: Francesco Romani <fromani@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2014-10-01 10:58:33 +02:00
Peter Krempa
8caded6b8e qemu: monitor: Add helper function to fill physical/virtual image size
While our code gathers block stats via "query-blockstats" some
information need to be gathered via "query-block". Add a helper function
that will update the blockstats structure if requested.
2014-10-01 10:58:33 +02:00
Chris St. Pierre
fe808d95bf Allow setting migration max downtime any time
This removes the artificial and unnecessary restriction that
virDomainSetMaxDowntime() only be called while a migration is in
progress.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2014-09-30 13:35:20 +02:00
Peter Krempa
bd2b0968c1 qemu: monitor: Avoid shadowing variable "devname" on FreeBSD
FreeBSD's compiler complains that we shadow the symbol. Sigh.

s/devname/dev_name/
2014-09-30 11:41:43 +02:00
Peter Krempa
96c0f57a82 qemu: monitor: return block stats data as a hash to avoid disk mixup
The current block stats code matched up the disk name with the actual
stats by the order in the data returned from qemu. This unfortunately
isn't right as qemu may return the disks in any order. Fix this by
returning a hash of stats and index them by the disk alias.
2014-09-30 11:01:55 +02:00
Ján Tomko
ec5f817f2e Don't verify CPU features with host-passthrough
Commit fba6bc4 introduced the non-migratable invtsc feature,
breaking save/migration with host-model and host-passthrough.

On hosts with this feature present it was automatically included
in the CPU definition, regardless of QEMU support.

Commit de0aeaf stopped including it by default for host-model,
but failed to fix host-passthrough.

This commit ignores checking of CPU features with host-passthrough,
since we don't pass them to QEMU (only -cpu host is passed),
allowing domains using host-passthrough that were saved with
the broken version of libvirtd to be restored.

https://bugzilla.redhat.com/show_bug.cgi?id=1147584
2014-09-30 10:47:02 +02:00
Ján Tomko
e26bbf49cc Fix crash cpu_shares change event crash on domain startup
Introduced by commit 0dce260.

qemuDomainEventQueue was called with qemuDomainObjPrivatePtr instead
of virQEMUDriverPtr.

https://bugzilla.redhat.com/show_bug.cgi?id=1147494
2014-09-29 13:58:43 +02:00
Guido Günther
9e159b521d qemu: remove capabilities.monitor.sock when done
Prompted by

   http://bugs.debian.org/761131
2014-09-26 19:01:16 +02:00
Daniel P. Berrange
42571dfa86 Fix typo s/EMULATORIN/EMULATORPIN/
Fix the typo in VIR_DOMAIN_TUNABLE_CPU_EMULATORIN

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2014-09-26 11:20:56 +01:00
Daniel P. Berrange
0778c0be8d Rename tunable event constants
For the new VIR_DOMAIN_EVENT_ID_TUNABLE event we have a bunch of
constants added

   VIR_DOMAIN_EVENT_CPUTUNE_<blah>
   VIR_DOMAIN_EVENT_BLKDEVIOTUNE_<blah>

This naming convention is bad for two reasons

  - There is no common prefix unique for the events to both
    relate them, and distinguish them from other event
    constants

  - The values associated with the constants were chosen
    to match the names used with virConnectGetAllDomainStats
    so having EVENT in the constant name is not applicable in
    that respect

This patch proposes renaming the constants to

    VIR_DOMAIN_TUNABLE_CPU_<blah>
    VIR_DOMAIN_TUNABLE_BLKDEV_<blah>

ie, given them a common VIR_DOMAIN_TUNABLE prefix.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2014-09-26 10:58:15 +01:00
Michal Privoznik
3a3c3780b4 qemuPrepareNVRAM: Save domain after NVRAM path generation
On a domain startup, the variable store path is generated if needed.
The path is intended to be generated only once. However, the updated
domain definition is not saved into config dir rather than state XML
only. So later, whenever the domain is destroyed and the daemon is
restarted, the generated path is forgotten and the file may be left
behind on virDomainUndefine() call.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-09-26 10:14:34 +02:00
Tomoki Sekiyama
efafc9c1ce nodeinfo: fix version of nodeAllocPages
Fix comments about the version in which '.nodeAllocPages' are added.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
2014-09-26 09:58:01 +02:00
Peter Krempa
fe7ef7b112 qemu: Always re-detect backing chain
Since 363e9a68 we track backing chain metadata when creating snapshots
the right way even for the inactive configuration. As we did not yet
update other code paths that modify the backing chain (blockpull) the
newDef backing chain gets out of sync.

After stopping of a VM the new definition gets copied to the next start
one. The new VM then has incorrect backing chain info. This patch
switches the backing chain detector to always purge the existing backing
chain and forces re-detection to avoid this issue until we'll have full
backing chain tracking support.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1144922
2014-09-26 09:35:33 +02:00
Pavel Hrdina
18fc3199c2 blkdeviotune: trigger tunable event for blkdeviotune updates
Use the universal tunable event to report changes to user. All
blkdeviotune values are prefixed with "blkdeviotune".

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2014-09-25 11:50:13 +02:00
Pavel Hrdina
783fe9ca8c blkdeviotune: fix bug with saving values into live XML
When you updated some blkdeviotune values for running domain the values
were stored only internally, but not saved into the live XML so they
won't survive restarting the libvirtd.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2014-09-25 11:50:03 +02:00
Michal Privoznik
0228fa11c0 nodeinfo: Implement nodeAllocPages
And add stubs to other drivers like: lxc, qemu, uml and vbox.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-09-25 10:24:45 +02:00
Ján Tomko
2d79e1752a qemu: wire up virtio-net segment offloading options
Format the segment offloading options specified by
<driver>
  <host .../>
  <guest .../>
</driver>
on virtio-net command line.
2014-09-24 16:16:45 +02:00
Peter Krempa
639a00984a qemu: Report better errors from broken backing chains
Request erroring out from the backing chain traveller and drop qemu's
internal backing chain integrity tester.

The backing chain traveller reports errors by itself with possibly more
detail than qemuDiskChainCheckBroken ever could.

We also need to make sure that we reconnect to existing qemu instances
even at the cost of losing the backing chain info (this really should be
stored in the XML rather than reloaded from disk, but that needs some
work).
2014-09-24 10:18:47 +02:00
Peter Krempa
172ca0e748 qemu: Sanitize argument names and empty disk check in qemuDomainDetermineDiskChain
Reuse virStorageSourceIsEmpty and rename "force" argument to
"force_probe".
2014-09-24 09:30:12 +02:00
Peter Krempa
b8549877a1 util: storage: Allow metadata crawler to report useful errors
Add a new parameter to virStorageFileGetMetadata that will break the
backing chain detection process and report useful error message rather
than having to use virStorageFileChainGetBroken.

This patch just introduces the option, usage will be provided
separately.
2014-09-24 09:28:29 +02:00
Pavel Hrdina
0dce260cc8 cputune_event: queue the event for cputune updates
Now we have universal tunable event so we can use it for reporting
changes to user. The cputune values will be prefixed with "cputune" to
distinguish it from other tunable events.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2014-09-23 21:58:09 +02:00
Jiri Denemark
ad56f86378 qemu: Fix memory leak in RDMA migration code
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2014-09-23 15:23:10 +02:00
Michal Privoznik
de31dcc89a qemuBuildNumaArgStr: Discard def->cpu check
In the function at one place we check if def->cpu is NULL prior
to accessing def->cpu->ncells. Then, later in the code,
def->cpu->ncells is accessed directly, without the check. This
makes coverity unhappy, because the first check makes it think
def->cpu can be NULL. However, the function is not called if
def->cpu is NULL. Therefore, remove the first check and hopefully
make coverity cheer again.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2014-09-23 13:08:39 +02:00
Michael R. Hines
9cc1586d2b qemu: Memory pre-pinning support for RDMA migration
RDMA Live migration requires registering memory with the hardware, and
thus QEMU offers a new 'capability' to pre-register / mlock() the guest
memory in advance for higher RDMA performance before the migration
begins. This capability is disabled by default, which means QEMU will
register the memory with the hardware in an on-demand basis.

This patch exposes this capability with the following example usage:

virsh migrate --live --rdma-pin-all --migrateuri rdma://hostname domain qemu+ssh://hostname/system

Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2014-09-23 08:11:50 +02:00
Michael R. Hines
ed22a47434 qemu: RDMA migration support
This patch adds support for RDMA protocol in migration URIs.

USAGE: $ virsh migrate --live --migrateuri rdma://hostname domain qemu+ssh://hostname/system

Since libvirt runs QEMU in a pretty restricted environment, several
files needs to be added to cgroup_device_acl (in qemu.conf) for QEMU to
be able to access the host's infiniband hardware. Full documenation of
the feature can be found on QEMU wiki:
http://wiki.qemu.org/Features/RDMALiveMigration

Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2014-09-23 08:11:50 +02:00
Jiri Denemark
b3fd95e368 qemu: Add RDMA migration capabilities 2014-09-23 08:11:49 +02:00
Jiri Denemark
e16a39fcd3 qemu: Prepare support for arbitrary migration protocol
Currently we only support TCP protocol for native QEMU migration but
this is going to be changed. Let's make the code more general and remove
hardcoded TCP protocol from several places.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2014-09-23 08:11:49 +02:00
Jiri Denemark
1cffb25c16 qemu: Fix old tcp:host URIs more cleanly
For compatibility with old libvirt we need to support both tcp:host and
tcp://host migration URIs. Let's make the code that parses them a bit
cleaner.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2014-09-23 08:11:35 +02:00
Michael R. Hines
30b24df165 qemu: Expose additional migration statistics
RDMA migration uses the 'setup' state in QEMU to optionally lock
all memory before the migration starts. The total time spent in
this state is exposed as VIR_DOMAIN_JOB_SETUP_TIME.

Additionally, QEMU also exports migration throughput (mbps) for both
memory and disk, so let's add them too: VIR_DOMAIN_JOB_MEMORY_BPS,
VIR_DOMAIN_JOB_DISK_BPS.

Signed-off-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2014-09-23 08:10:30 +02:00
Giuseppe Scrivano
75d6f42f42 qemu: raise an error when trying to use readonly sata disks
commit 72f919f558 introduced an user
friendly error message when trying to use IDE disks as readonly.

Do the same thing for the SATA bus.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2014-09-22 17:22:39 +02:00
Peter Krempa
4f3c2e39e5 qemu: hook: Provide hook when restoring a domain save image 2014-09-22 17:11:56 +02:00
Peter Krempa
3035123d65 qemu: save image: Split out checks done only when editing the save img
Move them to the single corresponding function rather than having them
in the common chunk of code.
2014-09-22 16:42:47 +02:00
Peter Krempa
4e215bcb2f qemu: save image: Split out new definition check/update
Split out the call to the update method only to places where it is
actually used rather than having a mega-method that does all the stuff.
2014-09-22 09:45:36 +02:00
Peter Krempa
eb9595b725 qemu: save image: Add possibility to return XML stored in the image
Add a new parameter that will allow to return the XML stored in the save
image for further manipulation and adjust the callers. This option will
be used in later patches.
2014-09-22 09:45:36 +02:00
Peter Krempa
92e1df2529 qemu: save image: Split out user provided XML checker
Extract code used to check save image XMLs provided by users to separate
use.
2014-09-22 09:45:36 +02:00
John Ferlan
74eaa0918b qemu: Process the hostdev "rawio" setting
Mimic the "Disk" processing for 'rawio', but for a scsi_host hostdev
lun device.
2014-09-19 07:49:06 -04:00
John Ferlan
320825b4ca domain_conf: Change virDomainDiskDef 'rawio' to use virTristateBool
Adjust disk definition for 'rawio' to use the TristateBool logic
2014-09-19 05:59:36 -04:00
John Ferlan
8921d48868 qemu: Add missing goto on rawio
Commit id '9a2f36ec' added a build conditional of CAP_SYS_RAWIO
in order to determine whether or not a disk definition using rawio
should be allowed on platforms without CAP_SYS_RAWIO. If one was
found, virReportError was used but the code didn't goto cleanup.

This patch adds the goto.
2014-09-19 05:54:00 -04:00
Pavel Hrdina
da7799d879 Move the FIPS detection from capabilities
We are not detecting the presence of FIPS from QEMU, but from procfs and
that means it's not QEMU capability. It was decided that we will pass
this flag to QEMU even if it's not supported by old QEMU binaries.

This patch also reverts changes done by commit a21cfb0f to
qemucapabilitestest and implements a new test case in qemuxml2argvtest.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2014-09-19 09:08:23 +02:00
Ján Tomko
c1480871bb Fixes for domains with no iothreads
Plug a memory leak and silence a warning.
2014-09-18 14:49:01 +02:00
John Ferlan
15ee3c2511 qemu: Don't fail startup/attach for IOThreads if no JSON
If the qemu being used doesn't support JSON, then querying for IOThread
data would fail. In that case, ensure the *iothreads is NULL and return 0
as the count of iothreads available.
2014-09-18 06:24:49 -04:00
Roman Bogorodskiy
e29d28e7f2 Fix build in qemu_command
Currently, build with clang fails with:

  CC       qemu/libvirt_driver_qemu_impl_la-qemu_command.lo
qemu/qemu_command.c:6580:58: error: implicit conversion from enumeration type
'virMemAccess' to different enumeration type 'virTristateSwitch'
[-Werror,-Wenum-conversion]
        virTristateSwitch memAccess = def->cpu->cells[i].memAccess;
                          ~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~^~~~~~~~~
1 error generated.

Fix that by using virMemAccess instead of virTristateSwitch.
2014-09-18 13:37:12 +04:00
Roman Bogorodskiy
3b3947ea37 Fix build in qemu_capabilities
Commit f05b6a91 added virQEMUDriverConfigPtr argument to the
virQEMUCapsFillDomainCaps function and it uses forward declaration
of virQEMUDriverConfig and virQEMUDriverConfigPtr that casues clang
build to fail:

gmake[3]: Entering directory `/usr/home/novel/code/libvirt/src'
  CC       qemu/libvirt_driver_qemu_impl_la-qemu_capabilities.lo
In file included from qemu/qemu_capabilities.c:43:
In file included from qemu/qemu_hostdev.h:27:
qemu/qemu_conf.h:63:37: error: redefinition of typedef 'virQEMUDriverConfig'
is a C11 feature [-Werror,-Wtypedef-redefinition]
typedef struct _virQEMUDriverConfig virQEMUDriverConfig;
                                    ^
qemu/qemu_capabilities.h:328:37: note: previous definition is here
typedef struct _virQEMUDriverConfig virQEMUDriverConfig;
                                    ^

Fix that by passing loader and nloader config attributes directly
instead of passing complete config.
2014-09-18 13:37:12 +04:00
Ján Tomko
540ee87249 qemu: fix crash with shared disks
Commit f36a94f introduced a double free on all success paths
in qemuSharedDeviceEntryInsert.

Only call qemuSharedDeviceEntryFree on the error path and
set entry to NULL before jumping there if the entry already
is in the hash table.

https://bugzilla.redhat.com/show_bug.cgi?id=1142722
2014-09-18 09:05:21 +02:00