Commit Graph

16338 Commits

Author SHA1 Message Date
Pavel Hrdina
ddc0e6bcdc qemu_process: introduce qemuProcessPrepareHost
Move all code that modifies host system to this function.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-22 15:15:48 +01:00
Pavel Hrdina
f8e712feb4 qemu_process: introduce qemuProcessPrepareDomain
Move all code that modifies only live XML to this function.  The new
VIR_QEMU_PROCESS_START_PRETEND flag will be used by qemuXMLToNative and
qemuxml2argvtest later in order to reuse the same code as
qemuProcessStart uses.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-22 15:15:48 +01:00
Pavel Hrdina
15ad2ecf11 nvram: generate it's path in qemuDomainDefPostParse
The postParse callback is the correct place to generate default values
that should be present in offline XML.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-22 15:15:38 +01:00
Pavel Hrdina
5b9e77883b qemu_process: check for correct return value while starting domain
Function qemuProcessLaunch returns '-2' in case there was an error and
we need to cleanup labels.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-22 13:59:13 +01:00
Pavel Hrdina
0f4d317204 qemu-hotplug: fix eject media
QEMU changed the error message to:

        "Tray of device 'drive-sata0-0-1' is not open"

and they may change the error massage in the future.

This updates the code to not depend on the text from the error message
but only on error itself.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
2016-03-22 13:26:46 +01:00
Bjoern Walk
a243316ac6 conf: node_device: fix up SCSI target
When reading in an XML definition for a SCSI target device, the name
property of struct scsi_target refers to the @target element.

Let's fix this obvious typo and also extend the XML schema to provide
validation.

Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
2016-03-21 12:06:49 -04:00
Jim Fehlig
6ce9b85dee libxl: support enabling and disabling <hap> feature
Until now, the libxl driver ignored any <hap> setting in domain XML
and deferred to libxl, which enables hap if not specified. While
this is a good default, it prevents disabling hap if desired.

This change allows disabling hap with <hap state='off'/>. hap is
explicitly enabled with <hap/> or <hap state='on/>. Absense of <hap>
retains current behavior of deferring default state to libxl.
2016-03-21 09:28:18 -06:00
Jim Fehlig
10c3db7308 Xen drivers: show hap enabled by default in capabilities
Hardware Assisted Paging is enabled by default in Xen. Change
the capabilities output to reflect this.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2016-03-21 09:28:17 -06:00
Jim Fehlig
4c9ffc5388 xenconfig: change 'hap' setting to align with Xen behavior
hap is enabled by default in xm and xl config and usually only
specified when it is desirable to disable hap (hap = 0). Change
the xm,xl <-> xml converter to behave similarly. I.e. only
produce 'hap = 0' when <hap state='off'/> and vice versa.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2016-03-21 09:28:17 -06:00
Jim Fehlig
9d243e0895 conf: add 'state' attribute to <hap> feature
Most hypervisors use Hardware Assisted Paging by default and don't
require specifying the feature in domain conf. But some hypervisors
support disabling HAP on a per-domain basis. To enable HAP by default
yet provide a knob to disable it, extend the <hap> feature with a
'state=on|off' attribute, similar to <pvspinlock> and <vmport> features.

In the absence of <hap>, the hypervisor default (on) is used. <hap>
without the state attribute would be the same as <hap state='on'/> for
backwards compatibility. And of course <hap state='off'/> disables hap.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2016-03-21 09:28:17 -06:00
Jiri Denemark
109017d9b3 qemu: Add flags to qemuMigrationWaitForCompletion
The function already takes two bool arguments, switching to flags makes
it a lot easier to read. Especially in case we need to add another
boolean in the future.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-21 15:15:46 +01:00
Jiri Denemark
d64adcdb96 qemu: Refuse to abort migration in post-copy mode
In post-copy mode none of the hosts has a complete guest state and
rolling back migration is impossible. Thus aborting it would be
equivalent to destroying the domain.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-21 15:15:46 +01:00
Jiri Denemark
630517d860 qemu: Handle post-copy migration failures
When migration fails in the post-copy mode, it's impossible to just kill
the destination domain and resume the source since the source no longer
contains current guest state. Let's mark domains on both sides as
VIR_DOMAIN_PAUSED_POSTCOPY_FAILED to let the upper layer decide what to
do with them.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-21 15:15:46 +01:00
Jiri Denemark
81b2a2c749 qemu: Refactor qemuProcessRecoverMigration
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-21 15:15:46 +01:00
Jiri Denemark
f6ea8a9f19 qemu: Don't kill running migrated domain on daemon restart
When destination libvirtd is restarted during migration in Finish phase
just after the point we started guest CPUs, we should not kill the
domain.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-21 15:15:46 +01:00
Cristian Klein
51a3e4df72 qemu: Implement virDomainMigrateStartPostCopy
Signed-off-by: Cristian Klein <cristiklein@gmail.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-21 15:15:46 +01:00
Cristian Klein
e8d2ff6ff2 qemu: Add support for VIR_MIGRATE_POSTCOPY flag
Signed-off-by: Cristian Klein <cristiklein@gmail.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-21 15:15:46 +01: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
Cristian Klein
1a1246ec7d Add public APIs for post-copy migration
To use post-copy one has to start the migration with
VIR_MIGRATE_POSTCOPY flag and, while migration is in progress, call
virDomainMigrateStartPostCopy() to switch from pre-copy to post-copy.

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
5a9cbc6265 Add event and state details for post-copy
VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY and VIR_DOMAIN_PAUSED_POSTCOPY are
used on the source host once migration enters post-copy mode (which
means the domain gets paused on the source. After the destination host
takes over the execution of the domain, its virtual CPUs are resumed and
the domain enters VIR_DOMAIN_RUNNING_POSTCOPY state and
VIR_DOMAIN_EVENT_RESUMED_POSTCOPY event is emitted.

In case migration fails during post-copy mode and none of the hosts have
complete state of the domain, both domains will remain paused with
VIR_DOMAIN_PAUSED_POSTCOPY_FAILED reason and an upper layer may decide
what to do.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-21 15:15:46 +01:00
Martin Kletzander
573c41a275 util: Add virSocketAddrSetIPv[46]AddrNetOrder and use it
This allows setting the address in host and/or network order and makes
the naming consistent.  Now you don't need to call [hn]to[nh]l()
functions as that is taken care of by these functions.  Also, now
the *NetOrder take the address in network order, the other functions in
host order so the naming and usage is consistent.  Some places were
having the address in network order and calling ntohl() just so the
original function can call htonl() again.  This makes it nicer to read.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-21 11:28:33 +01:00
Christophe Fergeau
6d28ef912c qemu: Don't add -spice port=0 when no port is specified
If a <graphics type='spice'> has no port nor tlsPort set, the generated
QEMU command line will contain -spice port=0.
This is later going to be ignored by spice-server, but it's better not
to add it at all in this situation.
As an empty -spice is not allowed, we still need to append port=0 if we
did not add any other argument.
2016-03-21 10:43:40 +01:00
Christophe Fergeau
8dab3d1d19 qemu: Omit SPICE address if no port is specified
Currently -spice addr=127.0.0.1 is generated, but spice-server is going
to ignore this as no port is specified.
2016-03-21 10:43:39 +01:00
Christophe Fergeau
9e17d219b3 qemu: Make all SPICE command-line args optional
The end goal is to avoid adding -spice port=0,addr=127.0.0.1 to QEMU command
line when no SPICE port is specified in libvirt XML.

Currently, the code relies on port=xx to always be present, so subsequent
args can be unconditionally appended with a leading ','. Since port=0
will no longer be added in a subsequent commit, we append a ',' to every
arg instead of prepending, and remove the last one before adding it to
the arg list.
2016-03-21 10:43:38 +01:00
Richard Laager
0c7245994f zfs: Only unencrypted volumes are supported 2016-03-21 08:47:05 +03:00
Richard Laager
bb5f2dc91f zfs: Only raw volumes are supported 2016-03-21 08:47:03 +03:00
Richard Laager
6682d6219d logical: Only raw volumes are supported 2016-03-21 08:47:01 +03:00
Richard Laager
98ee86e76c storage: Improve code consistency between backends
This improves the code consistency around freeing vol->target.path in
createVol implementations.
2016-03-21 08:46:57 +03:00
Richard Laager
ed0221d6b3 sheepdog: Use a consistent error message
This also reduces the number of strings to translate.
2016-03-21 08:46:54 +03:00
Richard Laager
e7d5c4e877 rbd: Use proper error type 2016-03-21 08:46:49 +03:00
Cole Robinson
9a423d1826 domain: Add virDomainDefAddImplicitDevices
It's just a combination of AddImplicitControllers, and AddConsoleCompat.
Every caller that wants ImplicitControllers also wants the ConsoleCompat
AFAICT, so lump them together. We also need it for future patches.
2016-03-20 16:11:04 -04:00
Cole Robinson
c770472c48 bhyve: caps: Log error message when CPU init fails
virBhyveCapsInitCPU will raise a libvirt error; even though we treat
it as non-fatal we should log the actual message.
2016-03-18 18:33:53 -04:00
Cole Robinson
2dabe2e03e domain: Remove controller/net address whitelists
Judging by how the whitelist has skewed quite far from the original
error message, I think it's better to just drop these.

If someone wants to revive this check I suggest implementing it on
a per-HV driver basis with PostParse callbacks.
2016-03-18 15:57:36 -04:00
Martin Kletzander
d77ffb6876 nodedev: Expose PCI header type
If we expose this information, which is one byte in every PCI config
file, we let all mgmt apps know whether the device itself is an endpoint
or not so it's easier for them to decide whether such device can be
passed through into a VM (endpoint) or not (*-bridge).

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-18 17:35:06 +01:00
Martin Kletzander
0d8f45246a nodedev: Indent PCI express for future fix
Best viewed with '-w' as this is just an adjustment for future patch to
be readable without that.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-18 17:35:06 +01:00
Michal Privoznik
7dbcb26f7f nss: Implement _nss_libvirt_gethostbyname3_r
The implementation is pretty straightforward. Moreover, because
of the nature of things, gethostbyname_r and gethostbyname2_r can
be implemented at the same time too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-18 17:29:53 +01:00
Michal Privoznik
1ca59d89c6 virsocketaddr: Introduce virSocketAddrSetIPv6Addr
This is a missing counterpart for virSocketAddrSetIPv4Addr()
and is going to be needed later in the tests.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-18 17:29:53 +01:00
Michal Privoznik
4122137871 virLeaseReadCustomLeaseFile: Allow server_duid to be NULL
This function is going to be used later in such context where the
argument makes no sense. Teach this function to cope with that
instead of the caller having to deal with passing some dummy
argument.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-18 17:29:53 +01:00
Michal Privoznik
fd9514f8d2 Export virLease* functions for leases file handling
These functions are going to be reused very shortly. So instead
of duplicating the code, lets move them into utils module.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-18 17:29:53 +01:00
John Ferlan
efb5e46b6c conf: Format disk pool part_separator attribute for running pool
Commit id '4f846170' added printing of a new field 'part_separator';
however, neglected to do so when there was an "freeExtent" defined
for the device (as there would be when the disk pool was started).

This patch adjusts the logic to appropriately format the device path and
if there the part_separator attribute.
2016-03-18 07:04:07 -04:00
John Ferlan
1019bf1445 qemu: Move last error save/restore to qemuBuildNetCommandLine
Commit 'ef2ab8fd' moved just the virDomainConfNWFilterTeardown and left
the logic to save/restore the current error essentially doing nothing
in the error path for qemuBuildCommandLine.  So move it to where it
was meant to be.

Although the original code would reset the filter on command creation
errors after building the network command portion and commit 'ef2ab8fd'
altered that logic, the teardown is called during qemuProcessStop from
virDomainConfVMNWFilterTeardown and that code has the save/restore
last error logic, so just allow that code to handle the teardown rather
than running it twice. The qemuProcessStop would be called in the failure
path of qemuBuildCommandLine.
2016-03-18 06:59:41 -04:00
Michal Privoznik
865764de06 Drop paths.h include
We include the file in plenty of places. This is mostly due to
historical reasons. The only place that needs something from the
header file is storage_backend_fs which opens _PATH_MOUNTED. But
it gets the file included indirectly via mntent.h. At no other
place in our code we need _PATH_.*. Drop the include and
configure check then.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-18 09:43:45 +01:00
Jovanka Gulicoska
9a0c7f5f83 driver: log missing modules as INFO, not WARN
Missing modules is a common expected scenario for most libvirt usage on
RPM distributions like Fedora, so it doesn't really warrant logging at
WARN level. Use INFO instead

https://bugzilla.redhat.com/show_bug.cgi?id=1274849
2016-03-17 16:50:05 -04:00
Martin Kletzander
b9a3ce95ce admin: Add virAdmConnectLookupServer
It does not have a suffix ByName because there are no other means of
looking up the server and since the name is known, this should be the
preferred one.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-17 17:06:22 +01:00
Nikolay Shirokovskiy
cce90a459a qemu: implement setting target disks migration port
Mostly it is just passing new parameter here and there. In case
of zero value we fallback to auto selecting port and thus keep
backward compatibility.

Also we need to fix places of auto selected port managment.
We should bother only when auto selected was done that is
when externally specified port is not 0.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-03-17 16:20:15 +01:00
Mikhail Feoktistov
ad29dbb31c vz: code refactoring
In prlsdkAddNet() Attach/DetachNet() functions
privconn should be the first argument
2016-03-17 15:20:20 +01:00
Cole Robinson
ca0c06f400 rpc: wait longer for session daemon to start up
https://bugzilla.redhat.com/show_bug.cgi?id=1271183

We only wait 0.5 seconds for the session daemon to start up and present
its socket, which isn't sufficient for many users. Bump up the sleep
interval and retry amount so we wait for a total of 5.0 seconds.
2016-03-16 19:21:44 -04:00
Erik Skultety
e6367dd408 virlog: Fix build breaker with "comparison between signed and unsigned"
Refactor series 0b231195 worked with virLogDestination type which, depending
on the compiler, might be (and probably will be) an unsigned data type.
However, virEnumFromString may return -1 in case of an error. So, when enum
happens to be unsigned, some compilers will naturally complain about foo:
    'if (foo < 0)'
2016-03-16 21:33:11 +01:00
Mikhail Feoktistov
bb2f63da79 vz: set default SCSI model
Each version of virtuozzo supports only one type of SCSI controller
So if we add disk on SCSI bus, we should set SCSI controller model.
We can take it from vzCapabilities structure.
2016-03-16 19:34:27 +03:00
Mikhail Feoktistov
97841dd9e6 vz: check supported controllers
Because Vz6 supports SCSI(BUSLOGIC), IDE and SATA controllers only and
Vz7 supports SCSI(VIRTIO_SCSI) and IDE only we add list of supported
controllers and scsi models to vzCapabilities structure.
When a new  connection opens, we select proper capabilities values according
to Virtuozzo version and check them in XMLPostParse.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
2016-03-16 19:34:27 +03:00
Mikhail Feoktistov
1de787b065 vz: report correct disk format in domainGetXMLDesc
We should report correct disk format depending on vz version and domain type.
Since we support only one disk format for each domain type, we can take it
from vzCapabilities structure.
2016-03-16 19:34:27 +03:00
Maxim Nestratov
a9555e202e vz: move prlsdkCheckDiskUnsupportedParams to vz_utils.c
As long as we have another function checking disk parameters correctness,
let's have them in one place. Here we change prefix of the moved function and
start to call it from vzCheckUnsupportedDisks rather than add disk.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
2016-03-16 19:34:27 +03:00
Mikhail Feoktistov
adbe76fb42 vz: check supported disk format and bus
Now we check disk parameters correctness in DomainPostParse.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
2016-03-16 19:34:27 +03:00
Mikhail Feoktistov
19d979edff vz: add vzCapabilities to connection structure
As far as Virtuozzo6 and Virtuozzo7 support different disk types for virtual
machines (ploop and qcow2 respectively) and different buses (vz6: IDE, SCSI,
SATA; vz7: IDE SCSI) we add vzCapabilities structure to help undestand which
disk formats and buses are supported in the context of a current connection.

When a new connection opens, we select proper capabilities in accordance to
current Virtuozzo version.
2016-03-16 19:34:26 +03:00
Mikhail Feoktistov
d10b02b5e5 vz: save vz version in connection structure
Move code from connectGetVersion callback to vzInitVersion function
2016-03-16 19:34:26 +03:00
Erik Skultety
0b231195cb virlog: Refactor virLogParseOutputs
The problem with the original virLogParseOutputs method was that the way it
parsed the input, walking the string char by char and using absolute jumps
depending on the virLogDestination type, was rather complicated to read.
This patch utilizes virStringSplit method twice, first time to filter out any
spaces and split the input to individual log outputs and then for each
individual output to tokenize it by to the parts according to our
PRIORITY:DESTINATION?(:DATA) format. Also, to STREQLEN for matching destination
was replaced with virDestinationTypeFromString call.
2016-03-16 14:28:24 +01:00
Erik Skultety
034337fb85 virlog: Introduce Type{To,From}String for virLogDestination
In order to refactor the ugly virLogParseOutputs method, this is a neat way of
finding out whether the destination type (in the form of a string) user
provided is a valid one. As a bonus, if it turns out it is valid, we get the
actual enum which will later be passed to any of virLogAddOutput methods right
away.
2016-03-16 14:24:15 +01:00
Martin Kletzander
c1276177f8 nodedev: Shorten match condition
Just a cleanup I stumbled upon in one of my older branches I did when
browsing through some code and forgot to send it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-16 10:49:12 +01:00
Martin Kletzander
71fa2eb26c qemu: Don't access uninitialized memory
In qemuConnectDomainXMLToNative() we set up the monitor, but we never
memset() it to zeros.  Thanks to the introduction of the logfile
parameter of chardevs (and the logfile member of the struct), we started
checking whether that's non-NULL and that exposed this old error.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-16 10:49:12 +01:00
Cole Robinson
26f3d9c26c qemu: Don't overwrite DomainSave errors
These functions already report fine grained errors, there's no
benefit to overwriting the error here.
2016-03-15 15:43:34 -04:00
Dmitry Andreev
c5e81090ea qemuDomainRevertToSnapshot: save domain configuration
Reverting to a snapshot may change domain configuration. New
configuration should be saved if domain has persistent flag.

VIR_DOMAIN_EVENT_DEFINED_FROM_SNAPSHOT is emitted in case of
configuration update.
2016-03-15 14:57:26 -04:00
John Ferlan
5b3103e0ad qemu: Introduce qemuBuildPanicCommandLine
Add new function to manage adding the panic device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-15 07:10:22 -04:00
John Ferlan
928d2ffe2a qemu: Introduce qemuBuildNVRAMCommandLine
Add new function to manage adding the NVRAM device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-15 07:10:22 -04:00
John Ferlan
b12acd31af qemu: Introduce qemuBuildRNGCommandLine
Add new function to manage adding the RNG device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Also modify the qemuBuildRNGDevStr to use const virDomainDef instead
of virDomainDefPtr.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-15 07:10:22 -04:00
John Ferlan
00e47796a9 qemu: Introduce qemuBuildMemballoonCommandLine
Add new function to manage adding the memballoon device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Also modify the qemuBuildMemballoonDevStr to use const virDomainDef
instead of virDomainDefPtr.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-15 07:10:22 -04:00
John Ferlan
d2108df57c qemu: Introduce qemuBuildHostdevCommandLine
Add new function to manage adding the host device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Also modify qemuBuildPCIHostdevDevStr, qemuBuildUSBHostdevDevStr,
and qemuBuildSCSIHostdevDevStr to use const virDomainDef instead
of virDomainDefPtr.

Make qemuBuildPCIHostdevPCIDevStr and qemuBuildUSBHostdevUSBDevStr
static to the qemu_command.c.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-15 07:10:22 -04:00
John Ferlan
59e7ef3c1f qemu: Introduce qemuBuildRedirdevCommandLine
Add new function to manage adding the redirdev device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Also move the qemuBuildRedirdevDevStr closer to the new function and
modify to use the const virDomainDef instead of virDomainDefPtr

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-15 07:10:22 -04:00
John Ferlan
4666b762b9 qemu: Introduce qemuBuildWatchdogCommandLine
Add new function to manage adding the watchdog device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Also since qemuBuildWatchdogDevStr was only local here, make it static as
well as modifying the const virDomainDef.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-15 07:10:22 -04:00
John Ferlan
1a91ddb496 qemu: Introduce qemuBuildSoundCommandLine
Add new function to manage adding the sound device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Also since qemuBuildSoundDevStr was only local here, make it static as
well as modifying the const virDomainDef.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-15 07:10:22 -04:00
Andrea Bolognani
5fc68bd4b1 hostdev: Add more comments
These comments explain the difference between a virPCIDevice
instance used for lookups and an actual device instance; some
information is also provided for specific uses.
2016-03-15 10:34:58 +01:00
Andrea Bolognani
800dd16d84 hostdev: Use consistent variable names
This is not just a cosmetic change: the name of the variable now
gives a hint about what it is supposed to be used for.
2016-03-15 10:33:18 +01:00
Andrea Bolognani
4cdbff3d52 hostdev: Remove virHostdevGetActivePCIHostDeviceList()
virHostdevGetPCIHostDeviceList() is similar but does not filter out
devices that are not in the active list; that said, we are looking
up the device in the active list just a few lines after anyway, so
we might as well just keep a single function around.

This also helps stress the fact the objects contained in pcidevs are
only for looking up the actual devices, which is something later
commits will make even more explicit.
2016-03-15 10:33:17 +01:00
Andrea Bolognani
8e3ac3ed73 hostdev: Rename usesVfio -> usesVFIO
Acronyms should be written in all caps.
2016-03-14 14:55:47 +01:00
Andrea Bolognani
95c65ae193 hostdev: Rename hostdev_mgr -> mgr
We're in the hostdev module, so mgr is not an ambiguous name, and
in fact it's already used in some cases. Switch all the code over.

Take the chance to shorten declaration of
virHostdevIsPCINodeDeviceUsedData structures.
2016-03-14 14:55:47 +01:00
Andrea Bolognani
36243a0c62 hostdev: Look up devices using IDs when possible
When we want to look up a device in a device list and we already
have the IDs from another source, we can simply use
virPCIDeviceListFindByIDs() instead of creating a temporary device
object.
2016-03-14 14:55:47 +01:00
Andrea Bolognani
e57e9413ac hostdev: Change argument order for virHostdevReattachPCIDevice()
The new order aligns better with the virHostdev prefix.
2016-03-14 14:55:47 +01:00
Andrea Bolognani
5ce91139da hostdev: virHostdevIsPCINetDevice() should return a bool
The only possible return values are true and false, so the return
type should be bool instead of int.
2016-03-14 14:55:47 +01:00
Andrea Bolognani
2ec4664b1e hostdev: Rework resetvfnetconfig loop condition
If 'last_processed_hostdev_vf != -1' is false then, since the
loop counter 'i' starts at 0, 'i <= last_processed_hostdev_vf'
can't possibly be true and the loop body will never be executed.

However, since 'i' is unsigned and 'last_processed_hostdev_vf'
is signed, we can't just get rid of the check completely; what
we can do is move it outside of the loop to avoid checking its
value on every iteration and cluttering the actual loop
condition.
2016-03-14 14:55:47 +01:00
Maxim Nestratov
8a74498721 vz: fix active domain listing
Since commit 9c14a9ab we have broken active domain listing
because reworked prlsdkLoadDomain doesn't set dom->def->id
propely. It just looses it when a new def structure is set.
Now we make prlsdkConvertDomainState function return void
and move calling it after an old dom->def is replaces with
a new one within prlsdkLoadDomain function.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
2016-03-14 15:12:10 +03:00
Michal Privoznik
2e70af12f2 qemuBuildVideoCommandLine: Don't access def->videos without check
This function can be called over a domain definition that has no
video configured. The
tests/qemuxml2argvdata/qemuxml2argv-minimal.xml file could serve
as an example. Problem is, before the check that domain has some
or none video configured, def->videos is dereferenced causing a
segmentation fault in case there's none video configured.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2016-03-14 09:34:43 +01:00
John Ferlan
95ca4fe2f2 qemu: Introduce qemuBuildVideoCommandLine
Add new function to manage adding the video device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-11 19:23:46 -05:00
John Ferlan
60b1ff52f5 qemu: Introduce qemuBuildInputCommandLine
Add new function to manage adding the input device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Make qemuBuildUSBInputDevStr static since only this module calls it.

Also the change to use const virDomainDef forces other changes.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-11 19:23:46 -05:00
John Ferlan
9de54baf26 qemu: Modify qemuBuildTPMCommandLine
Modify the argument order and types to match other similar helpers.

Also modify called functions to use the def->emulator instead of passing
def->emulator and def.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-11 19:23:46 -05:00
John Ferlan
e6944a529e qemu: Introduce qemuBuildConsoleCommandLine
Add new function to manage adding the console device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-11 19:23:46 -05:00
John Ferlan
3cdcc910a0 qemu: Introduce qemuBuildChannelsCommandLine
Add new function to manage adding the channel device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-11 19:23:46 -05:00
John Ferlan
0e1e7ade29 qemu: Introduce qemuBuildParallelsCommandLine
Add new function to manage adding the parallels device options to the
command line removing that task from the mainline qemuBuildCommandLine.
Alter logic slight to reduce indention level.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-11 19:23:46 -05:00
John Ferlan
5ab86400bf qemu: Introduce qemuBuildSerialCommandLine
Add new function to manage adding the serial device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Using const virDomainDef causes collateral damage in other called APIs
which need to make the similar adjustment

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-11 19:23:46 -05:00
John Ferlan
858bafebbf qemu: Introduce qemuBuildSmartcardCommandLine
Add new function to manage adding the smartcard device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Alter the logic slightly to make !nsmartcards check first so that remainder
of the code is less indented.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-11 19:23:45 -05:00
Martin Kletzander
eeb1e6fe9f gendispatch: Use proper error for limit checking
All other places use VIR_ERR_RPC except this one, let's be consistent,
shall we?

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Martin Kletzander
42b85f173d remote: Generate what's possible
Since gendisplatch can now generate "modern" *ListAll* functions, let
them all be generated.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Martin Kletzander
5b7d09804c gendispatch: Support modern listing of more types
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Martin Kletzander
576c54f9b1 gendispatch: Remember the name of snapshot variable name
Until now, the script assumed that snapshot name is 'snap', but that's
going to change.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Martin Kletzander
1cefc14f69 gendispatch: Accept server as an argument
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Martin Kletzander
d949280c72 admin: Generate ConnectListServers dispatch helpers
Since we have the opportunity now, let's save some precious code lines.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Martin Kletzander
6de2ef5d35 gendispatch: Be able to generate multi-return values
Let's call it modern_ret_as_list as opposed to single_ret_as_list.  The
latter was able to return list of things.  However the new, more modern,
version came and it is used since listAllDomains till nowadays in
ListServers.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Martin Kletzander
30c4931d28 gendispatch: Cluster, don't capture if not needed
We were using parentheses for grouping admin|remote even though we didn't
need to capture what's in it.  That caused some changes to be greater
than needed and, to be honest, some confusion as well.  Let's use it as
it should be used.  It'll also make future changes more consistent.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Martin Kletzander
335bc13cc1 admin: Be consistent when resetting errors
Resetting an error should be the first thing public API does.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Martin Kletzander
8fcb81d2de admin: Don't use priority for admin APIs
There are no priority workers as they don't make sense for now.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Martin Kletzander
d4218ca64f Change virNetDaemonGetServerNames to virNetDaemonGetServers
For now it does not matter which ones we return as the code is similarly
complex, however it will fit in with other constructs in the future,
mainly when we will be able to generate dispatch helpers.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Martin Kletzander
83942e5b6a Expose virNetServerGetName
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Martin Kletzander
6541a2b4ac daemon: Properly check for clients
virHashForEach() returns 0 if everything went nice, so our session
daemon was timing out even when there was a client connected.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Martin Kletzander
cd0a980ee1 daemon: Set error for unknown server name
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Martin Kletzander
62be54861b virerror: Introduce new error type NO_SERVER
This serves the same purpose as VIR_ERR_NO_xxx where xxx is any object
that API can be called upon.  Only this particular one is used for
daemon's servers.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Martin Kletzander
fd4f278e1a daemon: Get server name from the server itself
Since servers know their name, there is no need to supply such
information twice.  Also defeats inconsistencies.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Martin Kletzander
dad3b07814 server: Store server name in server object
At first I did not want to do this, but after trying to implement some
newer feaures in the admin API I realized we need that to make our lives
easier.  On the other hand they are not saved redundantly and the
virNetServer objects are still kept in a hash table.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Martin Kletzander
b04e39ff86 admin: Check for flags properly
Function virAdmConnectListServers() forgot to check for flags at all,
virAdmConnectOpen() on the other hand checked them but did no dispatch
the error.  virCheckFlags() should be used only when there should be no
other thing done after erroring out and since they are used on different
places then just public API, they cannot dispatch errors.  So let's use
virCheckFlagsGoto instead.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
Martin Kletzander
23a646f840 admin: Make virAdmServerFree() handle NULL gracefully
We don't want to end up like with virDomainFree() and other, right?

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2016-03-11 12:58:41 +01:00
John Ferlan
ef2ab8fdc5 qemu: Introduce qemuBuildNetCommandLine
Add new function to manage adding the network device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-11 06:32:20 -05:00
John Ferlan
3dbc2a149f qemu: Introduce qemuBuildFSDevCommandLine
Add new function to manage adding the -fsdev options to the
command line removing that task from the mainline qemuBuildCommandLine.
Alter the code slightly to perform the !caps and fsdev failure check
up front.

Since both qemuBuildFSStr and qemuBuildFSDevStr are local, make them
static and fix their prototypes to use the const virDomainDef as well.
Make some minor formatting changes for long lines.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-11 06:31:05 -05:00
John Ferlan
0ea0f6c496 qemu: Introduce qemuBuildDiskDriveCommandLine
Add new function to manage adding the disk -drive options to the
command line removing that task from the mainline qemuBuildCommandLine.

Also since using const virDomainDef in new function, that means other
functions called needed to change their usage.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-11 06:17:06 -05:00
John Ferlan
f87be33a6f qemu: Introduce qemuBuildHubCommandLine
Add new function to manage adding the hub -device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Also make qemuBuildHubDevStr static to the module since it's only
used here.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-11 06:17:06 -05:00
John Ferlan
4908772e15 qemu: Introduce qemuBuildControllerDevCommandLine
Add new function to manage adding the controller -device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Also adjust to using const virDomainDef instead of virDomainDefPtr.
This causes collateral damage in order to modify called APIs to use
the const virDomainDef instead as well.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-11 06:17:06 -05:00
John Ferlan
73379375c8 qemu: Introduce qemuBuildGlobalControllerCommandLine
Add new function to manage adding the -global controller options to
the command line removing that task from the mainline qemuBuildCommandLine.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-11 06:17:05 -05:00
John Ferlan
44616e3304 qemu: Introduce qemuBuildBootCommandLine
Add new function to manage adding the -boot options to the command
line removing that task from the mainline qemuBuildCommandLine.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-11 06:17:05 -05:00
John Ferlan
d6d31e00eb qemu: Introduce qemuBuildPMCommandLine
Add new function to manage adding the power management options to the
command line removing that task from the mainline qemuBuildCommandLine.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-11 06:17:05 -05:00
John Ferlan
05e9790802 qemu: Introduce qemuBuildClockCommandLine
Add new function to manage adding the '-clock' options to the command
line removing that task from the mainline qemuBuildCommandLine.

Also includes some minor formatting cleanups.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-03-11 06:17:05 -05:00
Marc-André Lureau
1e34a8f919 qemu: enable debug threads
When debug-threads is enabled, individual threads are given a separate
name (on Linux)

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

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-10 22:54:40 +01:00
Marc-André Lureau
0683ffc2ea qemu: check for debug-threads capability
QEMU (somewhere around 2.0) added a new sub-option to the -name flag
-name debug-threads=on.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-10 22:54:40 +01:00
Chunyan Liu
f41e03c63f libxl_conf: reuse virDomainNetGetActualtype in libxlMakeNicList
Reuse existing helper function virDomainNetGetActualtype.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2016-03-10 14:28:52 -07:00
Daniel P. Berrange
fcd3fa385f qemu: support use of virtlogd with file based chardevs
Currently the file based character devices let QEMU write
directly to a file on disk. This allows a malicious QEMU
to inflict a denial of service by consuming all free space.

Switch QEMU to use a pipe to virtlogd, which will enforce
file rollover.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-03-10 15:43:19 +00:00
Daniel P. Berrange
3e12ec4a1e qemu: use virtlogd for character device log files
If use of virtlogd is enabled, then use it for backing the
character device log files too. This avoids the possibility
of a guest denial of service by writing too much data to
the log file.
2016-03-10 15:41:52 +00:00
Daniel P. Berrange
3f68f33c36 logging: support truncation of logfiles when opening
The virtlogd daemon currently opens all files for append, but
in some cases the user may wish to discard existing data. Define
a new flag to indicate that logfiles should be truncated when
opening.
2016-03-10 15:41:52 +00:00
Daniel P. Berrange
4e461228dd qemu: move functions for handling FD passing
The functions for handling FD passing when building command line
arguments need to be used by many different bits of code, so need
to be at the start of the source file

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-03-10 15:41:52 +00:00
Daniel P. Berrange
0192447519 qemu: don't append -chardev arg until after value is formatted
The act of formatting a chardev backend value may need to
append command line arguments for passing FDs. If we append
the -chardev arg before formatting the value, then the
resulting arguments will end up interspersed

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-03-10 15:40:54 +00:00
Daniel P. Berrange
06cb0cf7ce qemu: add support for logging chardev output to a file
Honour the <log file='...'/> element in chardevs to output
data to a file. This requires QEMU >= 2.6

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-03-10 15:33:51 +00:00
Daniel P. Berrange
00ce10c700 conf: allow use of a logfile with chardev backends
Extend the chardev source XML so that there is a new optional
<log/> element, which is applicable to all character device
backend types. For example, to log output of a TCP backed
serial port

    <serial type='tcp'>
      <source mode='connect' host='127.0.0.1' service='9999'/>
      <protocol type='raw'/>
      <log file='/var/log/libvirt/qemu/demo-serial0.log' append='on'/>
      <target port='0'/>
    </serial>

Not all hypervisors will support use of logfiles.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-03-10 15:33:17 +00:00
Daniel P. Berrange
f12bfc5ed5 logging: allow inode/offset params to be NULL
Not all callers of virLogManagerDomainOpenLogFile will
care about getting the current inode/offset, so we should
allow those parameters to be NULL

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2016-03-10 15:33:16 +00:00
Peter Krempa
ab3f1428a6 qemu: cpu: Don't remove pinning of cold-unplugged cpu
After adding support for offline vcpu pinning the code that removes the
pinning for cpu cold-unplug was forgotten. This fixes up commit 02ae21d

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1316371
2016-03-10 15:56:55 +01:00
Peter Krempa
a0143d5242 qemu: Fix memory leak in qemuGetSchedInfo
Memory returned from virStringSplit shall be freed with
virStringFreeList rather than VIR_FREE. Introduced in commit 511e7c5b.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1316433
2016-03-10 13:58:44 +01:00
Peter Krempa
8c7b7c4b0b conf: Fix off-by-one in virDomainDefGetVcpu
Cpus are indexed starting from '0' so the check was invalid.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1316384
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1316420
2016-03-10 13:58:44 +01:00
Peter Krempa
4a39149b69 qemu: Refactor bitmap handling in qemuDomainPinVcpuFlags
Now that the function was extracted we can get rid of some temp
variables. Additionally formatting of the bitmap string for the event
code should be checked.
2016-03-10 13:23:15 +01:00
Peter Krempa
475c530cd3 qemu: vcpupin: Extract live vcpupin setting into a separate function
The function was now beyond maintainability.
2016-03-10 13:23:15 +01:00
Cole Robinson
adefc561cc util: virfile: Only setuid for virFileRemove if on NFS
NFS with root-squash is the only reason we need to do setuid/setgid
crazyness in virFileRemove, so limit that behavior to the NFS case.
2016-03-09 16:07:18 -05:00
Cole Robinson
7cf5343709 util: virfile: Clarify setuid usage for virFileRemove
Break these checks out into their own function, and clearly document
each one. This shouldn't change behavior
2016-03-09 16:06:56 -05:00
Peter Krempa
02ae21deb3 qemu: add support for offline vcpupin
Allow pinning for inactive vcpus. The pinning mask will be automatically
applied as we would apply the default mask in case of a cpu hotplug.

Setting the scheduler settings for a vcpu has the same semantics.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1306556
2016-03-09 10:09:16 +01:00
Peter Krempa
acf521e121 conf: extract ignoring of inactive vcpu pinning information
Introduce VIR_DOMAIN_DEF_FEATURE_OFFLINE_VCPUPIN domain feature flag
whcih will allow to skip ignoring of the pinning information for
hypervisor drivers which will want to implement forward-pinning of
vcpus.
2016-03-09 10:09:16 +01:00
Peter Krempa
185d13b1b0 conf: refactor checking for unsupported memory devices
Introduce a helper to check supported device and domain config and move
the memory hotplug checks to it.

The advantage of this approach is that by default all new features are
considered unsupported by all hypervisors unless specifically changed
rather than the previous approach where every hypervisor would need to
declare that a given feature is unsupported.
2016-03-09 10:09:16 +01:00
Peter Krempa
23eb382128 conf: introduce parser feature flags
To avoid having to forbid new features added to domain XML in post parse
callbacks for individual hypervisor drivers the feature flag mechanism
will allow to add a central check that will be disabled for the drivers
that will add support.

As a first example flag, the 'hasWideSCSIBus' is converted to the new
bitmap.
2016-03-09 10:09:16 +01:00
Peter Krempa
0fe41f1a8a qemu: Report pinning for all vCPUs in qemuDomainGetVcpuPinInfo
The API documentation states that the function is returning pinning for
all vCPUs, so we can actually do so if the user passes a large enough
array.
2016-03-09 10:09:16 +01:00
Peter Krempa
e498e90469 conf: Extract code filling data for virDomainGetVcpuPinInfo
The implementation of the inner guts of the function is similar for all
drivers, so we can add a helper and not have to reimplement it three
times.
2016-03-09 10:09:16 +01:00
Jiri Denemark
cf091094a4 qemu: Add support for job completed event
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-08 16:26:01 +01:00
Jiri Denemark
f289300181 Introduce job completed event
The VIR_DOMAIN_EVENT_ID_JOB_COMPLETED event will be triggered once a job
(such as migration) finishes and it will contain statistics for the job
as one would get by calling virDomainGetJobStats. Thanks to this event
it is now possible to get statistics of a completed migration of a
transient domain on the source host.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-08 16:26:00 +01:00
Jiri Denemark
a2374edf08 qemu: Do not report completed stats until the job finishes
We would happily report and free statistics of a completed migration
even before it actually completed (on the source host while migration is
in the Finish phase).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-08 16:26:00 +01:00
Jiri Denemark
cb483a68fd qemu: Fix a race when computing migration downtime
Computing a total downtime during a migration requires us to store a
time stamp when guest CPUs get stopped. The value (and all other
statistics) is then transferred to the destination to compute the
downtime. Because the stopped time stamp is stored by a STOP event
handler while the statistics which will be sent over to the destination
are copied synchronously within qemuMigrationWaitForCompletion.

Depending on the timing of STOP and MIGRATION events, we may end up
copying (and transferring) statistics without the stopped time stamp
set. Let's make sure we always use the correct time stamp.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-08 16:26:00 +01:00
Jiri Denemark
315808e99e qemu: Don't explicitly stop CPUs after migration
With a very old QEMU which doesn't support events we need to explicitly
call qemuMigrationSetOffline at the end of migration to update our
internal state. On the other hand, if we talk to QEMU using QMP, we
should just wait for the STOP event and let the event handler update the
state and trigger a libvirt event.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-08 16:25:59 +01:00
Jiri Denemark
5d01e8666b qemu: Properly update completed migration stats
We should not overwrite all migration statistics on the source with the
numbers sent by the destination since the source may have an updated
view in some cases (such as post-copy migration). It's safer to update
just the timing info we need to get from the destination and be prepared
for the future. And we should only do all this after a successful
migration.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-08 16:25:59 +01:00
Jiri Denemark
e031560e87 qemu: Store completed stats at the very end of migration
Statistics for a completed migration only make sense if the migration
was successful. Let's not store them in priv->job.completed until we
are sure it was a success.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2016-03-08 16:25:47 +01:00
Andrea Bolognani
12a1631440 hostdev: Remove explicit NULL checks
NULL checks are performed implicitly in the rest of the module,
including other allocations in the very same function.
2016-03-08 10:44:01 +01:00
Andrea Bolognani
a54de18a54 hostdev: Fix indentation 2016-03-08 10:44:01 +01:00