提交 69abc80f 编写于 作者: P Peter Krempa

qemu: migration: Split out setup of the migration target

Separate out allocation of the virStorageSource corresponding to the
target NBD export of the migration.

As part of the splitout we allocate the export name explicitly as that
one must not change regardless whether blockdev is used or not to
provide compatibility.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
上级 0d0b490a
...@@ -776,38 +776,28 @@ qemuMigrationSrcNBDCopyCancel(virQEMUDriverPtr driver, ...@@ -776,38 +776,28 @@ qemuMigrationSrcNBDCopyCancel(virQEMUDriverPtr driver,
} }
static int static virStorageSourcePtr
qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriverPtr driver, qemuMigrationSrcNBDStorageCopyBlockdevPrepareSource(virDomainDiskDefPtr disk,
virDomainObjPtr vm,
virDomainDiskDefPtr disk,
const char *diskAlias,
const char *host, const char *host,
int port, int port,
unsigned long long mirror_speed,
unsigned int mirror_shallow,
const char *tlsAlias) const char *tlsAlias)
{ {
g_autoptr(qemuBlockStorageSourceAttachData) data = NULL;
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
int mon_ret = 0;
g_autoptr(virStorageSource) copysrc = NULL; g_autoptr(virStorageSource) copysrc = NULL;
VIR_DEBUG("starting blockdev mirror for disk=%s to host=%s", diskAlias, host);
if (!(copysrc = virStorageSourceNew())) if (!(copysrc = virStorageSourceNew()))
return -1; return NULL;
copysrc->type = VIR_STORAGE_TYPE_NETWORK; copysrc->type = VIR_STORAGE_TYPE_NETWORK;
copysrc->protocol = VIR_STORAGE_NET_PROTOCOL_NBD; copysrc->protocol = VIR_STORAGE_NET_PROTOCOL_NBD;
copysrc->format = VIR_STORAGE_FILE_RAW; copysrc->format = VIR_STORAGE_FILE_RAW;
if (!(copysrc->backingStore = virStorageSourceNew())) if (!(copysrc->backingStore = virStorageSourceNew()))
return -1; return NULL;
copysrc->path = g_strdup(diskAlias); if (!(copysrc->path = qemuAliasDiskDriveFromDisk(disk)))
return NULL;
if (VIR_ALLOC_N(copysrc->hosts, 1) < 0) copysrc->hosts = g_new0(virStorageNetHostDef, 1);
return -1;
copysrc->nhosts = 1; copysrc->nhosts = 1;
copysrc->hosts->transport = VIR_STORAGE_NET_HOST_TRANS_TCP; copysrc->hosts->transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
...@@ -819,6 +809,31 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriverPtr driver, ...@@ -819,6 +809,31 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriverPtr driver,
copysrc->nodestorage = g_strdup_printf("migration-%s-storage", disk->dst); copysrc->nodestorage = g_strdup_printf("migration-%s-storage", disk->dst);
copysrc->nodeformat = g_strdup_printf("migration-%s-format", disk->dst); copysrc->nodeformat = g_strdup_printf("migration-%s-format", disk->dst);
return g_steal_pointer(&copysrc);
}
static int
qemuMigrationSrcNBDStorageCopyBlockdev(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainDiskDefPtr disk,
const char *diskAlias,
const char *host,
int port,
unsigned long long mirror_speed,
unsigned int mirror_shallow,
const char *tlsAlias)
{
g_autoptr(qemuBlockStorageSourceAttachData) data = NULL;
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
int mon_ret = 0;
g_autoptr(virStorageSource) copysrc = NULL;
VIR_DEBUG("starting blockdev mirror for disk=%s to host=%s", diskAlias, host);
if (!(copysrc = qemuMigrationSrcNBDStorageCopyBlockdevPrepareSource(disk, host, port, tlsAlias)))
return -1;
/* Migration via blockdev-mirror was supported sooner than the auto-read-only /* Migration via blockdev-mirror was supported sooner than the auto-read-only
* feature was added to qemu */ * feature was added to qemu */
if (!(data = qemuBlockStorageSourceAttachPrepareBlockdev(copysrc, if (!(data = qemuBlockStorageSourceAttachPrepareBlockdev(copysrc,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册