migration: qmp_migrate(): keep working after syntax error

If a user or QMP client enter a bad syntax for the migrate
command in QMP/HMP, then the migrate command will never succeed
from that point on.

For example, if you enter:

(qemu) migrate tcp;0:4444
migrate: Parameter 'uri' expects a valid migration protocol

Then the migrate command will always fail from now on:

(qemu) migrate tcp:0:4444
migrate: There's a migration process in progress

The problem is that qmp_migrate() sets the migration status to
MIG_STATE_SETUP and doesn't reset it on syntax error. This bug
was introduced by commit 29ae8a4133082e16970c9d4be09f4b6a15034617.

Reviewed-by: Michael R. Hines <mrhines@us.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
(cherry picked from commit c950114286ea358a93ce632db0421945e1008395)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
migration: Fix rate limit

The migration thread appears to want to allow writeout to occur at full
speed rather than being rate limited during completion of state saving,
but sets the limit to INT_MAX when xfer_limit is INT64_MAX. This causes
problems if there's more than 2GB of state left to save at this point. It
probably ought to just be INT64_MAX instead.

Signed-off-by: Matthew Garrett <matthew.garrett@nebula.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
(cherry picked from commit 40596834c0d57a223124a956ccbe39dfeadc9f0e)

Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>

Conflicts:
	migration.c
postcopy: properly initialize precopy_count

Fix the bug that the precopy routine may be called even if pure postcopy
migration (not hybrid migration) is requested.
postcopy: fix busy loop with no background copy

If background copy is disabled, it is not necessary to see writefd upon
the select() call.
postcopy: set default forward/backward size to 8

In most cases, a non-zero value should be better than zero in most cases.
postcopy: safely handle cancel request

It is not possible to safely cancel postcopy migration. An ongoing
migration should be completed as soon as possible upon cancel request.
postcopy: ignore -S at the incoming side of postcopy

libvirt starts the incoming side with -S (autostart = 0), and sends
"cont" after completing source-side's "migrate".  For precopy migration,
it works well. But, for postcopy migration, it makes the VM pause during
whole the migration process.