From: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
We need the session uuid of a connection to destination host on source host to
perform migration. This patch do all the job to pass this uuid from destination
node to source.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
---
daemon/remote.c | 30 ++++++++++++++++++++++++++++++
docs/apibuild.py | 1 +
docs/hvsupport.pl | 1 +
src/driver-hypervisor.h | 4 ++++
src/libvirt-domain.c | 30 ++++++++++++++++++++++++++++++
src/libvirt_internal.h | 2 ++
src/libvirt_private.syms | 1 +
src/remote/remote_driver.c | 26 ++++++++++++++++++++++++++
src/remote/remote_protocol.x | 12 +++++++++++-
src/remote_protocol-structs | 1 +
src/vz/vz_driver.c | 10 ++++++++++
11 files changed, 117 insertions(+), 1 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index e9e2dca..b57c3b5 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -6666,6 +6666,36 @@ remoteDispatchDomainInterfaceAddresses(virNetServerPtr server
ATTRIBUTE_UNUSED,
return rv;
}
+static int
+remoteDispatchConnectVzGetSessionUUID(
+ virNetServerPtr server ATTRIBUTE_UNUSED,
+ virNetServerClientPtr client,
+ virNetMessagePtr msg ATTRIBUTE_UNUSED,
+ virNetMessageErrorPtr rerr,
+ remote_connect_vz_get_session_uuid_ret *ret)
+{
+ int rv = -1;
+ struct daemonClientPrivate *priv =
+ virNetServerClientGetPrivateData(client);
+
+ if (!priv->conn) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not
open"));
+ goto cleanup;
+ }
+
+ /* yes, casting. but why remote_uuid type is signed? */
+ if (virConnectVzGetSessionUUID(priv->conn, (unsigned char*)ret->uuid) < 0)
+ goto cleanup;
+
+ rv = 0;
+
+ cleanup:
+ if (rv < 0)
+ virNetMessageSaveError(rerr);
+
+ return rv;
+}
+
/*----- Helpers. -----*/
diff --git a/docs/apibuild.py b/docs/apibuild.py
index f934fb2..a9d2811 100755
--- a/docs/apibuild.py
+++ b/docs/apibuild.py
@@ -102,6 +102,7 @@ ignored_functions = {
"virDomainMigratePrepare3Params": "private function for
migration",
"virDomainMigrateConfirm3Params": "private function for
migration",
"virDomainMigratePrepareTunnel3Params": "private function for tunnelled
migration",
+ "virConnectVzGetSessionUUID": "private function for vz migration",
"virErrorCopyNew": "private",
}
diff --git a/docs/hvsupport.pl b/docs/hvsupport.pl
index 44a30ce..9a284cd 100755
--- a/docs/hvsupport.pl
+++ b/docs/hvsupport.pl
@@ -199,6 +199,7 @@ $apis{virDomainMigratePrepareTunnel3Params}->{vers} =
"1.1.0";
$apis{virDomainMigratePerform3Params}->{vers} = "1.1.0";
$apis{virDomainMigrateFinish3Params}->{vers} = "1.1.0";
$apis{virDomainMigrateConfirm3Params}->{vers} = "1.1.0";
+$apis{virConnectVzGetSessionUUID}->{vers} = "1.2.18";
diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h
index 3275343..d7604ec 100644
--- a/src/driver-hypervisor.h
+++ b/src/driver-hypervisor.h
@@ -1207,6 +1207,9 @@ typedef int
const char *password,
unsigned int flags);
+typedef int
+(*virDrvConnectVzGetSessionUUID)(virConnectPtr conn, unsigned char* session_uuid);
+
typedef struct _virHypervisorDriver virHypervisorDriver;
typedef virHypervisorDriver *virHypervisorDriverPtr;
@@ -1437,6 +1440,7 @@ struct _virHypervisorDriver {
virDrvDomainGetFSInfo domainGetFSInfo;
virDrvDomainInterfaceAddresses domainInterfaceAddresses;
virDrvDomainSetUserPassword domainSetUserPassword;
+ virDrvConnectVzGetSessionUUID connectVzGetSessionUUID;
};
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 837933f..c398ce2 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -6475,6 +6475,36 @@ virDomainDefineXMLFlags(virConnectPtr conn, const char *xml,
unsigned int flags)
}
+/*
+ * Not for public use. This function is part of the internal
+ * implementation of vz migration
+ */
+int
+virConnectVzGetSessionUUID(virConnectPtr conn, unsigned char* session_uuid)
+{
+ VIR_DEBUG("conn=%p", conn);
+ int ret = -1;
+
+ virResetLastError();
+
+ virCheckConnectReturn(conn, ret);
+ virCheckNonNullArgGoto(session_uuid, cleanup);
+
+ if (!conn->driver->connectVzGetSessionUUID) {
+ virReportUnsupportedError();
+ goto cleanup;
+ }
+
+ ret = conn->driver->connectVzGetSessionUUID(conn, session_uuid);
+
+ cleanup:
+ if (ret < 0)
+ virDispatchError(conn);
+
+ return ret;
+}
+
+
/**
* virDomainUndefine:
* @domain: pointer to a defined domain
diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h
index 1313b58..340c1bb 100644
--- a/src/libvirt_internal.h
+++ b/src/libvirt_internal.h
@@ -289,4 +289,6 @@ virTypedParameterValidateSet(virConnectPtr conn,
virTypedParameterPtr params,
int nparams);
+int virConnectVzGetSessionUUID(virConnectPtr conn, unsigned char* session_uuid);
+
#endif
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index eb7ec76..7998199 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -966,6 +966,7 @@ virStateCleanup;
virStateInitialize;
virStateReload;
virStateStop;
+virConnectVzGetSessionUUID;
# locking/domain_lock.h
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 273799b..b1bacc9 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -8041,6 +8041,31 @@ remoteDomainInterfaceAddresses(virDomainPtr dom,
return rv;
}
+static int
+remoteConnectVzGetSessionUUID(virConnectPtr conn, unsigned char* session_uuid)
+{
+ int rv = -1;
+ struct private_data *priv = conn->privateData;
+ remote_connect_vz_get_session_uuid_ret ret;
+
+ remoteDriverLock(priv);
+
+ memset(&ret, 0, sizeof(ret));
+
+ if (call(conn, priv, 0, REMOTE_PROC_CONNECT_VZ_GET_SESSION_UUID,
+ (xdrproc_t)xdr_void, NULL,
+ (xdrproc_t)xdr_remote_connect_vz_get_session_uuid_ret, (char *)&ret) ==
-1) {
+ goto cleanup;
+ }
+
+ memcpy(session_uuid, ret.uuid, VIR_UUID_BUFLEN);
+ xdr_free((xdrproc_t)xdr_remote_connect_vz_get_session_uuid_ret, (char *)&ret);
+ rv = 0;
+
+ cleanup:
+ remoteDriverUnlock(priv);
+ return rv;
+}
/* get_nonnull_domain and get_nonnull_network turn an on-wire
* (name, uuid) pair into virDomainPtr or virNetworkPtr object.
@@ -8391,6 +8416,7 @@ static virHypervisorDriver hypervisor_driver = {
.domainGetFSInfo = remoteDomainGetFSInfo, /* 1.2.11 */
.domainInterfaceAddresses = remoteDomainInterfaceAddresses, /* 1.2.14 */
.domainSetUserPassword = remoteDomainSetUserPassword, /* 1.2.16 */
+ .connectVzGetSessionUUID = remoteConnectVzGetSessionUUID, /* 1.2.18 */
};
static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 9f1be6b..3555577 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -3230,6 +3230,10 @@ struct remote_domain_set_user_password_args {
unsigned int flags;
};
+struct remote_connect_vz_get_session_uuid_ret {
+ remote_uuid uuid;
+};
+
/*----- Protocol. -----*/
@@ -5696,5 +5700,11 @@ enum remote_procedure {
* @generate:both
* @acl: domain:set_password
*/
- REMOTE_PROC_DOMAIN_SET_USER_PASSWORD = 357
+ REMOTE_PROC_DOMAIN_SET_USER_PASSWORD = 357,
+
+ /**
+ * @generate: none
+ * @acl: none
+ */
+ REMOTE_PROC_CONNECT_VZ_GET_SESSION_UUID = 358
};
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 48c3bd8..7e7cdde 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -3042,4 +3042,5 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_ADD_IOTHREAD = 355,
REMOTE_PROC_DOMAIN_DEL_IOTHREAD = 356,
REMOTE_PROC_DOMAIN_SET_USER_PASSWORD = 357,
+ REMOTE_PROC_CONNECT_VZ_GET_SESSION_UUID = 358,
};
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index 8fa7957..9d23322 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -1343,6 +1343,15 @@ vzDomainMemoryStats(virDomainPtr domain,
return ret;
}
+static int
+vzConnectVzGetSessionUUID(virConnectPtr conn, unsigned char* sessuuid)
+{
+ vzConnPtr privconn = conn->privateData;
+
+ memcpy(sessuuid, privconn->session_uuid, VIR_UUID_BUFLEN);
+ return 0;
+}
+
static virHypervisorDriver vzDriver = {
.name = "vz",
.connectOpen = vzConnectOpen, /* 0.10.0 */
@@ -1396,6 +1405,7 @@ static virHypervisorDriver vzDriver = {
.domainBlockStatsFlags = vzDomainBlockStatsFlags, /* 1.2.17 */
.domainInterfaceStats = vzDomainInterfaceStats, /* 1.2.17 */
.domainMemoryStats = vzDomainMemoryStats, /* 1.2.17 */
+ .connectVzGetSessionUUID = vzConnectVzGetSessionUUID, /* 1.2.18 */
};
static virConnectDriver vzConnectDriver = {
--
1.7.1