mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu: driver: Remove pre-blockdev code paths from qemuDomainBlockCopyCommon
Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
4bcff43bc7
commit
1cbc128895
@ -14886,8 +14886,7 @@ qemuDomainBlockCopyValidateMirror(virStorageSource *mirror,
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
qemuDomainBlockCopyCommonValidateUserMirrorBackingStore(virStorageSource *mirror,
|
qemuDomainBlockCopyCommonValidateUserMirrorBackingStore(virStorageSource *mirror,
|
||||||
bool shallow,
|
bool shallow)
|
||||||
bool blockdev)
|
|
||||||
{
|
{
|
||||||
if (!virStorageSourceHasBacking(mirror)) {
|
if (!virStorageSourceHasBacking(mirror)) {
|
||||||
/* for deep copy there won't be backing chain so we can terminate it */
|
/* for deep copy there won't be backing chain so we can terminate it */
|
||||||
@ -14903,12 +14902,6 @@ qemuDomainBlockCopyCommonValidateUserMirrorBackingStore(virStorageSource *mirror
|
|||||||
* For a copy when we are not reusing external image requesting shallow
|
* For a copy when we are not reusing external image requesting shallow
|
||||||
* is okay and will inherit the original backing chain */
|
* is okay and will inherit the original backing chain */
|
||||||
} else {
|
} else {
|
||||||
if (!blockdev) {
|
|
||||||
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
|
||||||
_("backingStore of mirror target is not supported by this qemu"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!shallow) {
|
if (!shallow) {
|
||||||
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
_("backingStore of mirror without VIR_DOMAIN_BLOCK_COPY_SHALLOW doesn't make sense"));
|
_("backingStore of mirror without VIR_DOMAIN_BLOCK_COPY_SHALLOW doesn't make sense"));
|
||||||
@ -14943,13 +14936,11 @@ qemuDomainBlockCopyCommon(virDomainObj *vm,
|
|||||||
bool need_unlink = false;
|
bool need_unlink = false;
|
||||||
bool need_revoke = false;
|
bool need_revoke = false;
|
||||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
||||||
const char *format = NULL;
|
|
||||||
bool mirror_reuse = !!(flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT);
|
bool mirror_reuse = !!(flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT);
|
||||||
bool mirror_shallow = !!(flags & VIR_DOMAIN_BLOCK_COPY_SHALLOW);
|
bool mirror_shallow = !!(flags & VIR_DOMAIN_BLOCK_COPY_SHALLOW);
|
||||||
bool existing = mirror_reuse;
|
bool existing = mirror_reuse;
|
||||||
qemuBlockJobData *job = NULL;
|
qemuBlockJobData *job = NULL;
|
||||||
g_autoptr(virStorageSource) mirror = mirrorsrc;
|
g_autoptr(virStorageSource) mirror = mirrorsrc;
|
||||||
bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
|
|
||||||
bool supports_create = false;
|
bool supports_create = false;
|
||||||
bool supports_access = false;
|
bool supports_access = false;
|
||||||
bool supports_detect = false;
|
bool supports_detect = false;
|
||||||
@ -15003,12 +14994,6 @@ qemuDomainBlockCopyCommon(virDomainObj *vm,
|
|||||||
virDomainDiskDefSourceLUNValidate(mirror) < 0)
|
virDomainDiskDefSourceLUNValidate(mirror) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (syncWrites && !blockdev) {
|
|
||||||
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
|
|
||||||
_("VIR_DOMAIN_BLOCK_COPY_SYNCHRONOUS_WRITES is not supported by this VM"));
|
|
||||||
goto endjob;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(flags & VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB) &&
|
if (!(flags & VIR_DOMAIN_BLOCK_COPY_TRANSIENT_JOB) &&
|
||||||
vm->persistent) {
|
vm->persistent) {
|
||||||
/* XXX if qemu ever lets us start a new domain with mirroring
|
/* XXX if qemu ever lets us start a new domain with mirroring
|
||||||
@ -15027,8 +15012,7 @@ qemuDomainBlockCopyCommon(virDomainObj *vm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (qemuDomainBlockCopyCommonValidateUserMirrorBackingStore(mirror,
|
if (qemuDomainBlockCopyCommonValidateUserMirrorBackingStore(mirror,
|
||||||
mirror_shallow,
|
mirror_shallow) < 0)
|
||||||
blockdev) < 0)
|
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
/* unless the user provides a pre-created file, shallow copy into a raw
|
/* unless the user provides a pre-created file, shallow copy into a raw
|
||||||
@ -15041,14 +15025,6 @@ qemuDomainBlockCopyCommon(virDomainObj *vm,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prepare the destination file. */
|
|
||||||
if (!blockdev &&
|
|
||||||
!virStorageSourceIsLocalStorage(mirror)) {
|
|
||||||
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
|
|
||||||
_("non-file destination not supported yet"));
|
|
||||||
goto endjob;
|
|
||||||
}
|
|
||||||
|
|
||||||
supports_access = virStorageSourceSupportsAccess(mirror) == 1;
|
supports_access = virStorageSourceSupportsAccess(mirror) == 1;
|
||||||
supports_create = virStorageSourceSupportsCreate(mirror) == 1;
|
supports_create = virStorageSourceSupportsCreate(mirror) == 1;
|
||||||
supports_detect = virStorageSourceSupportsBackingChainTraversal(mirror) == 1;
|
supports_detect = virStorageSourceSupportsBackingChainTraversal(mirror) == 1;
|
||||||
@ -15091,8 +15067,8 @@ qemuDomainBlockCopyCommon(virDomainObj *vm,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pre-create the image file. In case when 'blockdev' is used this is
|
/* pre-create the image file. This is required so that libvirt can properly
|
||||||
* required so that libvirt can properly label the image for access by qemu */
|
* label the image for access by qemu */
|
||||||
if (!existing) {
|
if (!existing) {
|
||||||
if (supports_create) {
|
if (supports_create) {
|
||||||
if (virStorageSourceCreate(mirror) < 0) {
|
if (virStorageSourceCreate(mirror) < 0) {
|
||||||
@ -15104,9 +15080,6 @@ qemuDomainBlockCopyCommon(virDomainObj *vm,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mirror->format > 0)
|
|
||||||
format = virStorageFileFormatTypeToString(mirror->format);
|
|
||||||
|
|
||||||
if (virStorageSourceInitChainElement(mirror, disk->src,
|
if (virStorageSourceInitChainElement(mirror, disk->src,
|
||||||
keepParentLabel) < 0)
|
keepParentLabel) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
@ -15122,7 +15095,6 @@ qemuDomainBlockCopyCommon(virDomainObj *vm,
|
|||||||
|
|
||||||
/* we must initialize XML-provided chain prior to detecting to keep semantics
|
/* we must initialize XML-provided chain prior to detecting to keep semantics
|
||||||
* with VM startup */
|
* with VM startup */
|
||||||
if (blockdev) {
|
|
||||||
for (n = mirror; virStorageSourceIsBacking(n); n = n->backingStore) {
|
for (n = mirror; virStorageSourceIsBacking(n); n = n->backingStore) {
|
||||||
if (qemuDomainPrepareStorageSourceBlockdev(disk, n, priv, cfg) < 0)
|
if (qemuDomainPrepareStorageSourceBlockdev(disk, n, priv, cfg) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
@ -15135,7 +15107,6 @@ qemuDomainBlockCopyCommon(virDomainObj *vm,
|
|||||||
* it into the mirror too. We do it directly as otherwise we'd need
|
* it into the mirror too. We do it directly as otherwise we'd need
|
||||||
* to modify all callers of 'qemuDomainPrepareStorageSourceBlockdev' */
|
* to modify all callers of 'qemuDomainPrepareStorageSourceBlockdev' */
|
||||||
mirror->detect_zeroes = disk->detect_zeroes;
|
mirror->detect_zeroes = disk->detect_zeroes;
|
||||||
}
|
|
||||||
|
|
||||||
/* If reusing an external image that includes a backing file but the user
|
/* If reusing an external image that includes a backing file but the user
|
||||||
* did not enumerate the chain in the XML we need to detect the chain */
|
* did not enumerate the chain in the XML we need to detect the chain */
|
||||||
@ -15149,7 +15120,6 @@ qemuDomainBlockCopyCommon(virDomainObj *vm,
|
|||||||
goto endjob;
|
goto endjob;
|
||||||
need_revoke = true;
|
need_revoke = true;
|
||||||
|
|
||||||
if (blockdev) {
|
|
||||||
if (mirror_reuse) {
|
if (mirror_reuse) {
|
||||||
/* oVirt depended on late-backing-chain-opening semantics the old
|
/* oVirt depended on late-backing-chain-opening semantics the old
|
||||||
* qemu command had to copy the backing chain data while the top
|
* qemu command had to copy the backing chain data while the top
|
||||||
@ -15208,7 +15178,6 @@ qemuDomainBlockCopyCommon(virDomainObj *vm,
|
|||||||
qemuBlockStorageSourceCreate(vm, mirror, mirrorBacking, mirror->backingStore,
|
qemuBlockStorageSourceCreate(vm, mirror, mirrorBacking, mirror->backingStore,
|
||||||
crdata->srcdata[0], VIR_ASYNC_JOB_NONE) < 0)
|
crdata->srcdata[0], VIR_ASYNC_JOB_NONE) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
|
||||||
|
|
||||||
if (!(job = qemuBlockJobDiskNewCopy(vm, disk, mirror, mirror_shallow, mirror_reuse, flags)))
|
if (!(job = qemuBlockJobDiskNewCopy(vm, disk, mirror, mirror_shallow, mirror_reuse, flags)))
|
||||||
goto endjob;
|
goto endjob;
|
||||||
@ -15218,19 +15187,11 @@ qemuDomainBlockCopyCommon(virDomainObj *vm,
|
|||||||
/* Actually start the mirroring */
|
/* Actually start the mirroring */
|
||||||
qemuDomainObjEnterMonitor(vm);
|
qemuDomainObjEnterMonitor(vm);
|
||||||
|
|
||||||
if (blockdev) {
|
|
||||||
ret = qemuMonitorBlockdevMirror(priv->mon, job->name, true,
|
ret = qemuMonitorBlockdevMirror(priv->mon, job->name, true,
|
||||||
qemuDomainDiskGetTopNodename(disk),
|
qemuDomainDiskGetTopNodename(disk),
|
||||||
mirror->nodeformat, bandwidth,
|
mirror->nodeformat, bandwidth,
|
||||||
granularity, buf_size, mirror_shallow,
|
granularity, buf_size, mirror_shallow,
|
||||||
syncWrites);
|
syncWrites);
|
||||||
} else {
|
|
||||||
/* qemuMonitorDriveMirror needs to honor the REUSE_EXT flag as specified
|
|
||||||
* by the user */
|
|
||||||
ret = qemuMonitorDriveMirror(priv->mon, job->name, mirror->path, format,
|
|
||||||
bandwidth, granularity, buf_size,
|
|
||||||
mirror_shallow, mirror_reuse);
|
|
||||||
}
|
|
||||||
|
|
||||||
virDomainAuditDisk(vm, NULL, mirror, "mirror", ret >= 0);
|
virDomainAuditDisk(vm, NULL, mirror, "mirror", ret >= 0);
|
||||||
qemuDomainObjExitMonitor(vm);
|
qemuDomainObjExitMonitor(vm);
|
||||||
|
Loading…
Reference in New Issue
Block a user