Commit Graph

352 Commits

Author SHA1 Message Date
Pavel Hrdina
c1b8d87bab qemu_monitor: rephrase error message if qemu closes monitor
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-06-08 13:50:31 +02:00
Peter Krempa
2fde4e724e qemu: monitor: Remove 'supportMaxOptions' argument from qemuMonitorGetBlockIoThrottle
The caller is already aware that the params are missing and the
extractor is ignoring the missing ones so the parameter isn't necessary.
2016-05-25 16:59:58 +02:00
Peter Krempa
894dc85fd1 qemu: process: Fix and improve disk data extraction
Extract information for all disks and update tray state and source only
for removable drives. Additionally store whether a drive is removable
and whether it has a tray.
2016-05-25 10:15:54 +02:00
Ján Tomko
02c2097571 Remove qemuProcessInitPCIAddresses with dependencies
It was only called for QEMUs without QEMU_CAPS_DEVICE,
which we no longer support.
2016-05-20 07:43:39 +02:00
Michal Privoznik
b1e2f2d84d qemu: Introduce qemuMonitorGetRTCTime
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-05-03 11:44:13 +02:00
Peter Krempa
7434eba7c7 qemu: monitor: Kill legacy PCI hotplug code 2016-05-02 09:12:14 +02:00
Peter Krempa
c01f4e9e55 qemu: monitor: Kill legacy USB monitor code
Code was obsoleted by using -device.
2016-05-02 09:12:14 +02:00
Andrea Bolognani
12209ba5bd qemu: Probe GIC capabilities
QEMU introduced the query-gic-capabilities QMP command
with commit 4468d4e0f383: use the command, if available,
to probe available GIC capabilities.

The information obtained is stored in a virQEMUCaps
instance, and will be later used to fill in a
virDomainCaps instance.
2016-04-20 12:46:48 +02:00
Richard W.M. Jones
beaa447a29 Add functions for handling exponential backoff loops.
In a few places in libvirt we busy-wait for events, for example qemu
creating a monitor socket.  This is problematic because:

 - We need to choose a sufficiently small polling period so that
   libvirt doesn't add unnecessary delays.

 - We need to choose a sufficiently large polling period so that
   the effect of busy-waiting doesn't affect the system.

The solution to this conflict is to use an exponential backoff.

This patch adds two functions to hide the details, and modifies a few
places where we currently busy-wait.

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
2016-04-15 16:54:28 +01:00
ShaoHe Feng
8979c5ddb9 qemu: monitor: add migration parameters accessors
Signed-off-by: ShaoHe Feng <shaohe.feng@intel.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-04-14 14:57:40 +02:00
Nikolay Shirokovskiy
231b25db67 migration: qemu: add option to select compression methods
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-04-14 14:57:40 +02:00
Peter Krempa
650e8d2c59 qemu: monitor: Add support for ACPI_DEVICE_OST event handling
The event is emitted on ACPI OSPM Status Indication events.

ACPI standard documentation describes the method as:

This object is an optional control method that is invoked by OSPM to
indicate processing status to the platform. During device ejection,
device hot add, or other event processing, OSPM may need to perform
specific handshaking with the platform. OSPM may also need to indicate
to the platform its inability to complete a requested operation; for
example, when a user presses an ejection button for a device that is
currently in use or is otherwise currently incapable of being ejected.
In this case, the processing of the ACPI Eject Request notification by
OSPM fails. OSPM may indicate this failure to the platform through the
invocation of the _OST control method. As a result of the status
notification indicating ejection failure, the platform may take certain
action including reissuing the notification or perhaps turning on an
appropriate indicator light to signal the failure to the user.
2016-04-13 13:26:29 +02:00
Peter Krempa
9f7d9891f0 qemu: monitor: Remove JSON impls of drive_add and drive_del
qemu won't ever add those functions directly to QMP. They will be
replaced with 'blockdev-add' and 'blockdev-del' eventually. At this time
there's no need to keep the stubs around.

Additionally the drive_del stub in JSON contained dead code in the
attempt to report errors. (VIR_ERR_OPERATION_UNSUPPORTED was never
reported). Since the text impl does have the same message it is reported
anyways.
2016-03-29 15:25:16 +02:00
Peter Krempa
552bf13f45 qemu: monitor: Drop qemuMonitorAttachDrive and leaves in call tree
Functions no longer required for attaching SCSI disks since
QEMU_CAPS_DEVICE is expected.
2016-03-29 15:23:10 +02:00
Cristian Klein
41d786b915 qemu: Add QMP functions for post-copy migration
Signed-off-by: Cristian Klein <cristiklein@gmail.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-21 15:15:46 +01:00
Jiri Denemark
ee47d8e8dd qemu: Handle postcopy-active migration state
Migration enters "postcopy-active" state after QEMU switches to
post-copy and pauses guest CPUs. From libvirt's point of view this state
is similar to "completed" because we need to transfer guest execution to
the destination host.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-21 15:15:46 +01:00
Pavel Hrdina
b4a5fd95f7 qemu: introduce vram64 attribute for QXL video device
This attribute is used to extend secondary PCI bar and expose it to the
guest as 64bit memory.  It works like this: attribute vram is there to
set size of secondary PCI bar and guest sees it as 32bit memory,
attribute vram64 can extend this secondary PCI bar.  If both attributes
are used, guest sees two memory bars, both address the same memory, with
the difference that the 32bit bar can address only the first part of the
whole memory.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-01 14:17:09 +01:00
Jiri Denemark
8c9ff9960b qemu: Process monitor EOF in a job
Stopping a domain without a job risks a race condition with another
thread which started a job a which does not expect anyone else to be
messing around with the same domain object.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-02-19 15:41:57 +01:00
Peter Krempa
4e615aabe2 qemu: monitor: Remove unused qemuMonitorMigrateToFile
With the currently supported qemus we always migrate to file
descriptors so the old function is not required any more.

Additionally QEMU_MONITOR_MIGRATE_TO_FILE_TRANSFER_SIZE macro is now
unused.
2016-02-17 15:54:44 +01:00
Jiri Denemark
56635345ad qemu: Add support for migration iteration event
The corresponding event in QEMU is called MIGRATION_PASS.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-01-21 16:36:08 +01:00
Jiri Denemark
09bbd96239 qemu: Rename qemuMonitorMigrationStatus struct
The structure actually contains migration statistics rather than just
the status as the name suggests. Renaming it as
qemuMonitorMigrationStats removes the confusion.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-01-08 18:18:58 +01:00
Jiri Denemark
5fed699a2d qemu: Reorder migration status enum
A migration is in "setup" state after it was "inactive" and before it
becomes "active". Let's reflect this in our migration status enum.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-01-08 18:18:58 +01:00
Peter Krempa
7912d87920 qemu: monitor: Remove weird return values from qemuMonitorSetCPU
Let the function report errors internally and change it to return
standard return codes.
2015-12-09 14:57:12 +01:00
Daniel P. Berrange
a48539c013 qemu: convert monitor to use qemuDomainLogContextPtr indirectly
Currently the QEMU monitor is given an FD to the logfile. This
won't work in the future with virtlogd, so it needs to use the
qemuDomainLogContextPtr instead, but it shouldn't directly
access that object either. So define a callback that the
monitor can use for reporting errors from the log file.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2015-11-26 14:30:15 +00:00
Daniel P. Berrange
69b0992178 qemu: unify code for reporting errors from QEMU log files
There are two pretty similar functions qemuProcessReadLog and
qemuProcessReadChildErrors. Both read from the QEMU log file
and try to strip out libvirt messages. The latter then reports
an error, while the former lets the callers report an error.

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

Convert all callers to use qemuProcessReportLogError.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2015-11-26 14:30:15 +00:00
Peter Krempa
0076d8db97 qemu: monitor: Explain logic of qemuMonitorGetCPUInfo
The return value has non-obvious semantics. Document it.
2015-11-24 13:55:35 +01: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
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
Shivangi Dhir
7383b8cc06 qemu: Make virtType of type virDomainVirtType
Earlier virtType was of type int. After, introducing the enum VIR_DOMAIN_VIRT_NONE,
the type of virtType is modified to virDomainVirtType.
2015-09-25 15:34:09 -04:00
Cao jin
17cba9fb51 qemuMonitorOpenInternal: remove redundant code
There's no need to set mon->fd to a dummy value since
it's initialized to proper value just a few lines below.

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
2015-08-10 13:47:33 +02:00
Jiri Denemark
e68f395fcb qemu: Remember incoming migration errors
If QEMU fails during incoming migration, the domain disappears including
a possibly useful error message read from QEMU log file. Let's remember
the error in virQEMUDriver so that Finish can report more than just "no
such domain".

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-07-10 11:47:13 +02:00
Jiri Denemark
04d5fb2e0a qemu: Drop LFs at the end of error from QEMU log
Libvirt's error messages do not end with a LF. However, when reading the
error from QEMU log, we would read the LF from the log and keep it in
the message.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-07-09 21:58:44 +02:00
Jiri Denemark
3df4d2a45a qemu: Enable migration events on QMP monitor
Even if QEMU supports migration events it doesn't send them by default.
We have to enable them by calling migrate-set-capabilities. Let's enable
migration events everytime we can and clear QEMU_CAPS_MIGRATION_EVENT in
case migrate-set-capabilities does not support events.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-07-09 21:44:07 +02:00
Jiri Denemark
a60ee613c4 qemu_monitor: Wire up MIGRATION event
Thanks to Juan's work QEMU finally emits an event whenever migration
state changes.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-07-09 21:44:07 +02:00
Peter Krempa
78aefb5275 qemu: monitor: Remove qemuMonitorGetBlockExtent
Now that qemuMonitorGetAllBlockStatsInfo collects also wr_highest_offset
the whole function can be killed.
2015-06-26 16:41:24 +02:00
Jiri Denemark
2ad46e5b0e qemu: Do not poll for spice migration status
QEMU_CAPS_SEAMLESS_MIGRATION capability says QEMU supports
SPICE_MIGRATE_COMPLETED event. Thus we can just drop all code which
polls query-spice and replace it with waiting for the event.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-19 15:15:11 +02:00
Jiri Denemark
bfbbb78ca3 qemu_monitor: Wire up SPICE_MIGRATE_COMPLETED event
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-19 15:15:11 +02:00
Jiri Denemark
3a18bd2d7a qemu: Refactor qemuMonitorBlockJobInfo
"query-block-jobs" QMP command returns all running block jobs at once,
while qemuMonitorBlockJobInfo would only report one. This is not very
nice in case we need to check several block jobs. This patch refactors
the monitor code to always parse all block jobs and store them in a
hash.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-06-19 15:15:11 +02:00
Boris Fiuczynski
840eca32ab qemu: monitor: Add memory balloon support for virtio-ccw
The search for the memory balloon driver object is extended by a
second known name "virtio-balloon-ccw" in support for virtio-ccw.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Daniel Hansel <daniel.hansel@linux.vnet.ibm.com>
Reviewed-by: Eric Farman <farman@linux.vnet.ibm.com>
Reviewed-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
2015-06-15 17:05:32 +02:00
Ján Tomko
568aba8811 Turn qemuMonitorFindBalloonObjectPath into a void function
We were effectively ignoring its errors anyway.
2015-06-05 16:19:21 +02:00
Ján Tomko
19c633c678 Do not access the domain definition in qemuMonitorFindBalloonObjectPath
The monitor code does not hold the virDomainObjPtr lock and should
not access the defitinion.
2015-06-05 16:19:07 +02:00
Ján Tomko
c09e1729df Remove path argument from qemuMonitorJSONFindLinkPath
All the callers use "/" anyway.
2015-06-05 16:01:23 +02:00
Ján Tomko
5aca919b6c Introduce qemuMonitorJSONFindLinkPath
When traversing through the QOM tree, we're looking for
a link to a device, e.g.:
link<virtio-balloon-pci>

Introduce a helper that will format the link name at the start,
instead of doing it every time while recursing through the tree.
2015-06-05 16:00:51 +02:00
Ján Tomko
88710cee75 Move qemuMonitorFindObjectPath to qemu_monitor_json
This function is specific to the JSON monitor.
2015-06-05 15:55:22 +02:00
Peter Krempa
987b70777a qemu: monitor: Make qemuMonitorSetBalloon operate on unsinged long long 2015-06-03 09:42:08 +02:00
Peter Krempa
efe8b44a84 monitor: Move documentation for qemuMonitorGetBalloonInfo
Document the top level function rather than both bottom level ones. It
makes looking the docs up quicker.
2015-06-03 09:42:08 +02:00
Zhang Bo
6f5d29f40d qemu: make qemuMonitorChardevInfoFree non-static
It would be used in qemumonitorjsontest, thus we make it non-static.

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
Signed-off-by: Zhou Yimin <zhouyimin@huawei.com>
2015-04-28 16:50:11 +02:00
John Ferlan
b515339fe7 qemu: Remove need for qemuMonitorIOThreadInfoFree
Replace with just VIR_FREE.
2015-04-28 06:33:49 -04:00
John Ferlan
4c2ca5664a qemu: Remove need for qemuDomainParseIOThreadAlias
Rather than have a separate routine to parse the alias of an iothread
returned from qemu in order to get the iothread_id value, parse the alias
when returning and just return the iothread_id in qemuMonitorIOThreadInfoPtr

This set of patches removes the function, changes the "char *name" to
"unsigned int" and handles all the fallout.
2015-04-28 06:33:30 -04:00
Peter Krempa
c44108522b qemu: monitor: Refactor and fix monitor checking
Among all the monitor APIs some where checking if mon is NULL and some
were not. Since it's possible to have mon equal to NULL in case a second
call is attempted once entered the monitor. This requires that every
single API checks for the monitor.

This patch adds a macro that helps checking the state of the monitor and
either refactors existing checking code to use the macro or adds it in
case it was missing.
2015-04-16 14:49:46 +02:00