2011-01-31 10:47:03 +00:00
|
|
|
/*
|
|
|
|
* qemu_migration.h: QEMU migration handling
|
|
|
|
*
|
qemu: completely rework reference counting
There is one problem that causes various errors in the daemon. When
domain is waiting for a job, it is unlocked while waiting on the
condition. However, if that domain is for example transient and being
removed in another API (e.g. cancelling incoming migration), it get's
unref'd. If the first call, that was waiting, fails to get the job, it
unref's the domain object, and because it was the last reference, it
causes clearing of the whole domain object. However, when finishing the
call, the domain must be unlocked, but there is no way for the API to
know whether it was cleaned or not (unless there is some ugly temporary
variable, but let's scratch that).
The root cause is that our APIs don't ref the objects they are using and
all use the implicit reference that the object has when it is in the
domain list. That reference can be removed when the API is waiting for
a job. And because each domain doesn't do its ref'ing, it results in
the ugly checking of the return value of virObjectUnref() that we have
everywhere.
This patch changes qemuDomObjFromDomain() to ref the domain (using
virDomainObjListFindByUUIDRef()) and adds qemuDomObjEndAPI() which
should be the only function in which the return value of
virObjectUnref() is checked. This makes all reference counting
deterministic and makes the code a bit clearer.
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2014-12-04 13:41:36 +00:00
|
|
|
* Copyright (C) 2006-2011, 2014 Red Hat, Inc.
|
2011-01-31 10:47:03 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-07-21 10:06:23 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2011-01-31 10:47:03 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-06-18 16:12:37 +00:00
|
|
|
#pragma once
|
2011-01-31 10:47:03 +00:00
|
|
|
|
2019-06-18 16:12:37 +00:00
|
|
|
#include "qemu_conf.h"
|
|
|
|
#include "qemu_domain.h"
|
|
|
|
#include "qemu_migration_params.h"
|
|
|
|
#include "virenum.h"
|
2011-01-31 10:47:03 +00:00
|
|
|
|
2018-02-12 17:11:41 +00:00
|
|
|
/*
|
|
|
|
* General function naming conventions:
|
|
|
|
*
|
|
|
|
* - qemuMigrationSrcXXX - only runs on source host
|
|
|
|
* - qemuMigrationDstXXX - only runs on dest host
|
|
|
|
* - qemuMigrationAnyXXX - runs on source or dest host
|
|
|
|
*
|
|
|
|
* Exceptions:
|
|
|
|
*
|
|
|
|
* - qemuMigrationOptionXXX - runs on source or dest host
|
|
|
|
* - qemuMigrationJobXXX - runs on source or dest host
|
|
|
|
*/
|
|
|
|
|
2011-07-14 21:46:49 +00:00
|
|
|
/* All supported qemu migration flags. */
|
2019-06-18 16:12:37 +00:00
|
|
|
#define QEMU_MIGRATION_FLAGS \
|
2017-11-03 12:09:47 +00:00
|
|
|
(VIR_MIGRATE_LIVE | \
|
|
|
|
VIR_MIGRATE_PEER2PEER | \
|
|
|
|
VIR_MIGRATE_TUNNELLED | \
|
|
|
|
VIR_MIGRATE_PERSIST_DEST | \
|
|
|
|
VIR_MIGRATE_UNDEFINE_SOURCE | \
|
|
|
|
VIR_MIGRATE_PAUSED | \
|
|
|
|
VIR_MIGRATE_NON_SHARED_DISK | \
|
|
|
|
VIR_MIGRATE_NON_SHARED_INC | \
|
|
|
|
VIR_MIGRATE_CHANGE_PROTECTION | \
|
|
|
|
VIR_MIGRATE_UNSAFE | \
|
|
|
|
VIR_MIGRATE_OFFLINE | \
|
|
|
|
VIR_MIGRATE_COMPRESSED | \
|
|
|
|
VIR_MIGRATE_ABORT_ON_ERROR | \
|
|
|
|
VIR_MIGRATE_AUTO_CONVERGE | \
|
|
|
|
VIR_MIGRATE_RDMA_PIN_ALL | \
|
|
|
|
VIR_MIGRATE_POSTCOPY | \
|
2019-02-06 10:53:19 +00:00
|
|
|
VIR_MIGRATE_TLS | \
|
|
|
|
VIR_MIGRATE_PARALLEL | \
|
|
|
|
0)
|
2011-01-31 10:47:03 +00:00
|
|
|
|
2013-06-25 13:49:21 +00:00
|
|
|
/* All supported migration parameters and their types. */
|
2019-06-18 16:12:37 +00:00
|
|
|
#define QEMU_MIGRATION_PARAMETERS \
|
2017-11-03 12:09:47 +00:00
|
|
|
VIR_MIGRATE_PARAM_URI, VIR_TYPED_PARAM_STRING, \
|
|
|
|
VIR_MIGRATE_PARAM_DEST_NAME, VIR_TYPED_PARAM_STRING, \
|
|
|
|
VIR_MIGRATE_PARAM_DEST_XML, VIR_TYPED_PARAM_STRING, \
|
|
|
|
VIR_MIGRATE_PARAM_BANDWIDTH, VIR_TYPED_PARAM_ULLONG, \
|
|
|
|
VIR_MIGRATE_PARAM_GRAPHICS_URI, VIR_TYPED_PARAM_STRING, \
|
|
|
|
VIR_MIGRATE_PARAM_LISTEN_ADDRESS, VIR_TYPED_PARAM_STRING, \
|
|
|
|
VIR_MIGRATE_PARAM_MIGRATE_DISKS, VIR_TYPED_PARAM_STRING | \
|
2015-06-15 22:42:10 +00:00
|
|
|
VIR_TYPED_PARAM_MULTIPLE, \
|
2017-11-03 12:09:47 +00:00
|
|
|
VIR_MIGRATE_PARAM_DISKS_PORT, VIR_TYPED_PARAM_INT, \
|
|
|
|
VIR_MIGRATE_PARAM_COMPRESSION, VIR_TYPED_PARAM_STRING | \
|
2016-04-14 10:33:48 +00:00
|
|
|
VIR_TYPED_PARAM_MULTIPLE, \
|
2017-11-03 12:09:47 +00:00
|
|
|
VIR_MIGRATE_PARAM_COMPRESSION_MT_LEVEL, VIR_TYPED_PARAM_INT, \
|
|
|
|
VIR_MIGRATE_PARAM_COMPRESSION_MT_THREADS, VIR_TYPED_PARAM_INT, \
|
|
|
|
VIR_MIGRATE_PARAM_COMPRESSION_MT_DTHREADS, VIR_TYPED_PARAM_INT, \
|
2016-04-14 10:33:51 +00:00
|
|
|
VIR_MIGRATE_PARAM_COMPRESSION_XBZRLE_CACHE, VIR_TYPED_PARAM_ULLONG, \
|
2017-11-03 12:09:47 +00:00
|
|
|
VIR_MIGRATE_PARAM_PERSIST_XML, VIR_TYPED_PARAM_STRING, \
|
|
|
|
VIR_MIGRATE_PARAM_AUTO_CONVERGE_INITIAL, VIR_TYPED_PARAM_INT, \
|
|
|
|
VIR_MIGRATE_PARAM_AUTO_CONVERGE_INCREMENT, VIR_TYPED_PARAM_INT, \
|
2019-01-31 09:25:11 +00:00
|
|
|
VIR_MIGRATE_PARAM_BANDWIDTH_POSTCOPY, VIR_TYPED_PARAM_ULLONG, \
|
2019-02-06 10:53:19 +00:00
|
|
|
VIR_MIGRATE_PARAM_PARALLEL_CONNECTIONS, VIR_TYPED_PARAM_INT, \
|
2019-12-03 15:20:35 +00:00
|
|
|
VIR_MIGRATE_PARAM_TLS_DESTINATION, VIR_TYPED_PARAM_STRING, \
|
2013-06-25 13:49:21 +00:00
|
|
|
NULL
|
|
|
|
|
|
|
|
|
2014-06-15 16:32:56 +00:00
|
|
|
typedef enum {
|
2011-07-19 00:27:30 +00:00
|
|
|
QEMU_MIGRATION_PHASE_NONE = 0,
|
|
|
|
QEMU_MIGRATION_PHASE_PERFORM2,
|
|
|
|
QEMU_MIGRATION_PHASE_BEGIN3,
|
|
|
|
QEMU_MIGRATION_PHASE_PERFORM3,
|
|
|
|
QEMU_MIGRATION_PHASE_PERFORM3_DONE,
|
|
|
|
QEMU_MIGRATION_PHASE_CONFIRM3_CANCELLED,
|
|
|
|
QEMU_MIGRATION_PHASE_CONFIRM3,
|
|
|
|
QEMU_MIGRATION_PHASE_PREPARE,
|
|
|
|
QEMU_MIGRATION_PHASE_FINISH2,
|
|
|
|
QEMU_MIGRATION_PHASE_FINISH3,
|
|
|
|
|
|
|
|
QEMU_MIGRATION_PHASE_LAST
|
2014-06-15 16:32:56 +00:00
|
|
|
} qemuMigrationJobPhase;
|
2019-01-20 16:04:56 +00:00
|
|
|
VIR_ENUM_DECL(qemuMigrationJobPhase);
|
2011-07-19 00:27:30 +00:00
|
|
|
|
2017-04-07 10:12:30 +00:00
|
|
|
char *
|
2018-02-12 17:11:41 +00:00
|
|
|
qemuMigrationSrcBegin(virConnectPtr conn,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
const char *xmlin,
|
|
|
|
const char *dname,
|
|
|
|
char **cookieout,
|
|
|
|
int *cookieoutlen,
|
|
|
|
size_t nmigrate_disks,
|
|
|
|
const char **migrate_disks,
|
|
|
|
unsigned long flags);
|
2017-04-07 10:12:30 +00:00
|
|
|
|
|
|
|
virDomainDefPtr
|
2018-02-12 17:11:41 +00:00
|
|
|
qemuMigrationAnyPrepareDef(virQEMUDriverPtr driver,
|
2019-08-05 15:31:10 +00:00
|
|
|
virQEMUCapsPtr qemuCaps,
|
2018-02-12 17:11:41 +00:00
|
|
|
const char *dom_xml,
|
|
|
|
const char *dname,
|
|
|
|
char **origname);
|
2017-04-07 10:12:30 +00:00
|
|
|
|
|
|
|
int
|
2018-02-12 17:11:41 +00:00
|
|
|
qemuMigrationDstPrepareTunnel(virQEMUDriverPtr driver,
|
2018-02-26 09:20:06 +00:00
|
|
|
virConnectPtr dconn,
|
2018-02-12 17:11:41 +00:00
|
|
|
const char *cookiein,
|
|
|
|
int cookieinlen,
|
|
|
|
char **cookieout,
|
|
|
|
int *cookieoutlen,
|
|
|
|
virStreamPtr st,
|
|
|
|
virDomainDefPtr *def,
|
|
|
|
const char *origname,
|
2018-03-07 14:32:26 +00:00
|
|
|
qemuMigrationParamsPtr migParams,
|
2018-02-12 17:11:41 +00:00
|
|
|
unsigned long flags);
|
2017-04-07 10:12:30 +00:00
|
|
|
|
|
|
|
int
|
2018-02-12 17:11:41 +00:00
|
|
|
qemuMigrationDstPrepareDirect(virQEMUDriverPtr driver,
|
2018-02-26 09:20:06 +00:00
|
|
|
virConnectPtr dconn,
|
2018-02-12 17:11:41 +00:00
|
|
|
const char *cookiein,
|
|
|
|
int cookieinlen,
|
|
|
|
char **cookieout,
|
|
|
|
int *cookieoutlen,
|
|
|
|
const char *uri_in,
|
|
|
|
char **uri_out,
|
|
|
|
virDomainDefPtr *def,
|
|
|
|
const char *origname,
|
|
|
|
const char *listenAddress,
|
|
|
|
size_t nmigrate_disks,
|
|
|
|
const char **migrate_disks,
|
|
|
|
int nbdPort,
|
2018-03-07 14:32:26 +00:00
|
|
|
qemuMigrationParamsPtr migParams,
|
2018-02-12 17:11:41 +00:00
|
|
|
unsigned long flags);
|
2017-04-07 10:12:30 +00:00
|
|
|
|
|
|
|
int
|
2018-02-12 17:11:41 +00:00
|
|
|
qemuMigrationSrcPerform(virQEMUDriverPtr driver,
|
|
|
|
virConnectPtr conn,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
const char *xmlin,
|
|
|
|
const char *persist_xml,
|
|
|
|
const char *dconnuri,
|
|
|
|
const char *uri,
|
|
|
|
const char *graphicsuri,
|
|
|
|
const char *listenAddress,
|
|
|
|
size_t nmigrate_disks,
|
|
|
|
const char **migrate_disks,
|
|
|
|
int nbdPort,
|
2018-02-21 16:22:29 +00:00
|
|
|
qemuMigrationParamsPtr migParams,
|
2018-02-12 17:11:41 +00:00
|
|
|
const char *cookiein,
|
|
|
|
int cookieinlen,
|
|
|
|
char **cookieout,
|
|
|
|
int *cookieoutlen,
|
|
|
|
unsigned long flags,
|
|
|
|
const char *dname,
|
|
|
|
unsigned long resource,
|
|
|
|
bool v3proto);
|
2017-04-07 10:12:30 +00:00
|
|
|
|
|
|
|
virDomainPtr
|
2018-02-12 17:11:41 +00:00
|
|
|
qemuMigrationDstFinish(virQEMUDriverPtr driver,
|
|
|
|
virConnectPtr dconn,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
const char *cookiein,
|
|
|
|
int cookieinlen,
|
|
|
|
char **cookieout,
|
|
|
|
int *cookieoutlen,
|
|
|
|
unsigned long flags,
|
|
|
|
int retcode,
|
|
|
|
bool v3proto);
|
2017-04-07 10:12:30 +00:00
|
|
|
|
|
|
|
int
|
2018-02-12 17:11:41 +00:00
|
|
|
qemuMigrationSrcConfirm(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
const char *cookiein,
|
|
|
|
int cookieinlen,
|
|
|
|
unsigned int flags,
|
|
|
|
int cancelled);
|
2017-04-07 10:12:30 +00:00
|
|
|
|
|
|
|
bool
|
2018-02-12 17:11:41 +00:00
|
|
|
qemuMigrationSrcIsAllowed(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
bool remote,
|
|
|
|
unsigned int flags);
|
2017-04-07 10:12:30 +00:00
|
|
|
|
|
|
|
int
|
2018-02-12 17:11:41 +00:00
|
|
|
qemuMigrationSrcToFile(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
int fd,
|
2019-11-28 12:07:04 +00:00
|
|
|
virCommandPtr compressor,
|
2018-02-12 17:11:41 +00:00
|
|
|
qemuDomainAsyncJob asyncJob)
|
2019-10-14 12:25:14 +00:00
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT;
|
2011-03-10 00:35:13 +00:00
|
|
|
|
2017-04-07 10:12:30 +00:00
|
|
|
int
|
2018-02-12 17:11:41 +00:00
|
|
|
qemuMigrationSrcCancel(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm);
|
2017-04-07 10:12:30 +00:00
|
|
|
|
|
|
|
int
|
2018-02-12 17:11:41 +00:00
|
|
|
qemuMigrationAnyFetchStats(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
qemuDomainAsyncJob asyncJob,
|
|
|
|
qemuDomainJobInfoPtr jobInfo,
|
|
|
|
char **error);
|
2015-05-19 15:28:25 +00:00
|
|
|
|
2017-04-07 10:12:30 +00:00
|
|
|
int
|
2018-02-12 17:11:41 +00:00
|
|
|
qemuMigrationDstErrorInit(virQEMUDriverPtr driver);
|
2015-05-26 12:37:30 +00:00
|
|
|
|
2017-04-07 10:12:30 +00:00
|
|
|
void
|
2018-02-12 17:11:41 +00:00
|
|
|
qemuMigrationDstErrorSave(virQEMUDriverPtr driver,
|
|
|
|
const char *name,
|
|
|
|
virErrorPtr err);
|
2015-07-02 06:26:48 +00:00
|
|
|
|
2017-04-07 10:12:30 +00:00
|
|
|
void
|
2018-02-12 17:11:41 +00:00
|
|
|
qemuMigrationDstErrorReport(virQEMUDriverPtr driver,
|
|
|
|
const char *name);
|
2015-10-20 13:48:33 +00:00
|
|
|
|
2017-04-07 10:12:30 +00:00
|
|
|
int
|
2018-02-12 17:11:41 +00:00
|
|
|
qemuMigrationDstCheckProtocol(virQEMUCapsPtr qemuCaps,
|
|
|
|
const char *migrateFrom);
|
2015-10-20 13:48:33 +00:00
|
|
|
|
2017-04-07 10:12:30 +00:00
|
|
|
char *
|
2018-02-12 17:11:41 +00:00
|
|
|
qemuMigrationDstGetURI(const char *migrateFrom,
|
|
|
|
int migrateFd);
|
2015-11-11 17:02:23 +00:00
|
|
|
|
2017-04-07 10:12:30 +00:00
|
|
|
int
|
2018-02-12 17:11:41 +00:00
|
|
|
qemuMigrationDstRun(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
const char *uri,
|
|
|
|
qemuDomainAsyncJob asyncJob);
|
2017-04-07 10:12:30 +00:00
|
|
|
|
|
|
|
void
|
2018-02-12 17:11:41 +00:00
|
|
|
qemuMigrationAnyPostcopyFailed(virQEMUDriverPtr driver,
|
2017-04-07 10:12:30 +00:00
|
|
|
virDomainObjPtr vm);
|
2016-01-13 15:29:58 +00:00
|
|
|
|
2017-09-01 06:49:30 +00:00
|
|
|
int
|
2018-02-12 17:11:41 +00:00
|
|
|
qemuMigrationSrcFetchMirrorStats(virQEMUDriverPtr driver,
|
|
|
|
virDomainObjPtr vm,
|
|
|
|
qemuDomainAsyncJob asyncJob,
|
|
|
|
qemuDomainJobInfoPtr jobInfo);
|