mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
qemu: Add support for networked disks for block pull/block rebase
Now that we are able to select images from the backing chain via indexed access we should also convert possible network sources to qemu-compatible strings before passing them to qemu.
This commit is contained in:
parent
60244b56af
commit
c6bf2f0ffc
@ -15046,6 +15046,8 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
|
|||||||
virDomainDiskDefPtr disk;
|
virDomainDiskDefPtr disk;
|
||||||
virStorageSourcePtr baseSource = NULL;
|
virStorageSourcePtr baseSource = NULL;
|
||||||
unsigned int baseIndex = 0;
|
unsigned int baseIndex = 0;
|
||||||
|
char *basePath = NULL;
|
||||||
|
char *backingPath = NULL;
|
||||||
|
|
||||||
if (!virDomainObjIsActive(vm)) {
|
if (!virDomainObjIsActive(vm)) {
|
||||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
@ -15053,6 +15055,13 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flags & VIR_DOMAIN_BLOCK_REBASE_RELATIVE && !base) {
|
||||||
|
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||||
|
_("flag VIR_DOMAIN_BLOCK_REBASE_RELATIVE is valid only "
|
||||||
|
"with non-null base"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
priv = vm->privateData;
|
priv = vm->privateData;
|
||||||
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKJOB_ASYNC)) {
|
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKJOB_ASYNC)) {
|
||||||
async = true;
|
async = true;
|
||||||
@ -15113,10 +15122,35 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
|
|||||||
base, baseIndex, NULL))))
|
base, baseIndex, NULL))))
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
|
if (baseSource) {
|
||||||
|
if (qemuGetDriveSourceString(baseSource, NULL, &basePath) < 0)
|
||||||
|
goto endjob;
|
||||||
|
|
||||||
|
if (flags & VIR_DOMAIN_BLOCK_REBASE_RELATIVE) {
|
||||||
|
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_CHANGE_BACKING_FILE)) {
|
||||||
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||||
|
_("this QEMU binary doesn't support relative "
|
||||||
|
"block pull/rebase"));
|
||||||
|
goto endjob;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (virStorageFileGetRelativeBackingPath(disk->src->backingStore,
|
||||||
|
baseSource,
|
||||||
|
&backingPath) < 0)
|
||||||
|
goto endjob;
|
||||||
|
|
||||||
|
|
||||||
|
if (!backingPath) {
|
||||||
|
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||||
|
_("can't keep relative backing relationship"));
|
||||||
|
goto endjob;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
ret = qemuMonitorBlockJob(priv->mon, device,
|
ret = qemuMonitorBlockJob(priv->mon, device, basePath, backingPath,
|
||||||
baseIndex ? baseSource->path : base,
|
bandwidth, info, mode, async);
|
||||||
NULL, bandwidth, info, mode, async);
|
|
||||||
qemuDomainObjExitMonitor(driver, vm);
|
qemuDomainObjExitMonitor(driver, vm);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
@ -15191,6 +15225,8 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
VIR_FREE(basePath);
|
||||||
|
VIR_FREE(backingPath);
|
||||||
VIR_FREE(device);
|
VIR_FREE(device);
|
||||||
if (vm)
|
if (vm)
|
||||||
virObjectUnlock(vm);
|
virObjectUnlock(vm);
|
||||||
@ -15441,7 +15477,8 @@ qemuDomainBlockRebase(virDomainPtr dom, const char *path, const char *base,
|
|||||||
virCheckFlags(VIR_DOMAIN_BLOCK_REBASE_SHALLOW |
|
virCheckFlags(VIR_DOMAIN_BLOCK_REBASE_SHALLOW |
|
||||||
VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT |
|
VIR_DOMAIN_BLOCK_REBASE_REUSE_EXT |
|
||||||
VIR_DOMAIN_BLOCK_REBASE_COPY |
|
VIR_DOMAIN_BLOCK_REBASE_COPY |
|
||||||
VIR_DOMAIN_BLOCK_REBASE_COPY_RAW, -1);
|
VIR_DOMAIN_BLOCK_REBASE_COPY_RAW |
|
||||||
|
VIR_DOMAIN_BLOCK_REBASE_RELATIVE, -1);
|
||||||
|
|
||||||
if (!(vm = qemuDomObjFromDomain(dom)))
|
if (!(vm = qemuDomObjFromDomain(dom)))
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user