提交 9b6a636d 编写于 作者: P Peter Krempa

qemu: domain: don't loop through images in qemuDomainPrepareDiskSourceChain

Convert the function to just prepare data for the disk. Callers need to
do the looping since there's more to do than just copy the data around.

The code path in qemuDomainPrepareDiskSource doesn't need to loop over
the chain yet, since there currently is no chain at this point. This
will be addressed later in the blockdev series where we will setup much
more stuff.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 a522c304
...@@ -8034,6 +8034,7 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver, ...@@ -8034,6 +8034,7 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
{ {
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
virStorageSourcePtr src = disk->src; virStorageSourcePtr src = disk->src;
virStorageSourcePtr n;
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
int ret = -1; int ret = -1;
uid_t uid; uid_t uid;
...@@ -8116,9 +8117,10 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver, ...@@ -8116,9 +8117,10 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
report_broken) < 0) report_broken) < 0)
goto cleanup; goto cleanup;
/* fill in data for the rest of the chain */ for (n = src; virStorageSourceIsBacking(n); n = n->backingStore) {
if (qemuDomainPrepareDiskSourceChain(disk, src, cfg, priv->qemuCaps) < 0) if (qemuDomainPrepareDiskSourceData(disk, n, cfg, priv->qemuCaps) < 0)
goto cleanup; goto cleanup;
}
ret = 0; ret = 0;
...@@ -12399,51 +12401,44 @@ qemuDomainCheckCCWS390AddressSupport(const virDomainDef *def, ...@@ -12399,51 +12401,44 @@ qemuDomainCheckCCWS390AddressSupport(const virDomainDef *def,
/** /**
* qemuDomainPrepareDiskSourceChain: * qemuDomainPrepareDiskSourceData:
* *
* @disk: Disk config object * @disk: Disk config object
* @src: source to start from * @src: source to start from
* @cfg: qemu driver config object * @cfg: qemu driver config object
* *
* Prepares various aspects of the disk source and it's backing chain. This * Prepares various aspects of a storage source belonging to a disk backing
* function should be also called for detected backing chains. If @src is NULL * chain. This function should be also called for detected backing chain
* the root source is used. * members.
*/ */
int int
qemuDomainPrepareDiskSourceChain(virDomainDiskDefPtr disk, qemuDomainPrepareDiskSourceData(virDomainDiskDefPtr disk,
virStorageSourcePtr src, virStorageSourcePtr src,
virQEMUDriverConfigPtr cfg, virQEMUDriverConfigPtr cfg,
virQEMUCapsPtr qemuCaps) virQEMUCapsPtr qemuCaps)
{ {
virStorageSourcePtr n;
if (!src)
src = disk->src;
/* transfer properties valid only for the top level image */ /* transfer properties valid only for the top level image */
if (src == disk->src) if (src == disk->src)
src->detect_zeroes = disk->detect_zeroes; src->detect_zeroes = disk->detect_zeroes;
for (n = src; virStorageSourceIsBacking(n); n = n->backingStore) { if (cfg &&
if (cfg && src->type == VIR_STORAGE_TYPE_NETWORK &&
n->type == VIR_STORAGE_TYPE_NETWORK && src->protocol == VIR_STORAGE_NET_PROTOCOL_GLUSTER &&
n->protocol == VIR_STORAGE_NET_PROTOCOL_GLUSTER && virQEMUCapsGet(qemuCaps, QEMU_CAPS_GLUSTER_DEBUG_LEVEL)) {
virQEMUCapsGet(qemuCaps, QEMU_CAPS_GLUSTER_DEBUG_LEVEL)) { src->debug = true;
n->debug = true; src->debugLevel = cfg->glusterDebugLevel;
n->debugLevel = cfg->glusterDebugLevel; }
}
if (qemuDomainValidateStorageSource(n, qemuCaps) < 0) if (qemuDomainValidateStorageSource(src, qemuCaps) < 0)
return -1; return -1;
/* transfer properties valid for the full chain */ /* transfer properties valid for the full chain */
n->iomode = disk->iomode; src->iomode = disk->iomode;
n->cachemode = disk->cachemode; src->cachemode = disk->cachemode;
n->discard = disk->discard; src->discard = disk->discard;
if (disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) if (disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY)
n->floppyimg = true; src->floppyimg = true;
}
return 0; return 0;
} }
...@@ -12493,7 +12488,7 @@ qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk, ...@@ -12493,7 +12488,7 @@ qemuDomainPrepareDiskSource(virDomainDiskDefPtr disk,
if (qemuDomainSecretDiskPrepare(priv, disk) < 0) if (qemuDomainSecretDiskPrepare(priv, disk) < 0)
return -1; return -1;
if (qemuDomainPrepareDiskSourceChain(disk, NULL, cfg, priv->qemuCaps) < 0) if (qemuDomainPrepareDiskSourceData(disk, disk->src, cfg, priv->qemuCaps) < 0)
return -1; return -1;
if (qemuDomainPrepareStorageSourcePR(disk->src, priv, disk->info.alias) < 0) if (qemuDomainPrepareStorageSourcePR(disk->src, priv, disk->info.alias) < 0)
......
...@@ -1003,10 +1003,10 @@ bool qemuDomainCheckCCWS390AddressSupport(const virDomainDef *def, ...@@ -1003,10 +1003,10 @@ bool qemuDomainCheckCCWS390AddressSupport(const virDomainDef *def,
const char *devicename); const char *devicename);
int int
qemuDomainPrepareDiskSourceChain(virDomainDiskDefPtr disk, qemuDomainPrepareDiskSourceData(virDomainDiskDefPtr disk,
virStorageSourcePtr src, virStorageSourcePtr src,
virQEMUDriverConfigPtr cfg, virQEMUDriverConfigPtr cfg,
virQEMUCapsPtr qemuCaps) virQEMUCapsPtr qemuCaps)
ATTRIBUTE_RETURN_CHECK; ATTRIBUTE_RETURN_CHECK;
int int
......
...@@ -215,13 +215,13 @@ testQemuDiskXMLToProps(const void *opaque) ...@@ -215,13 +215,13 @@ testQemuDiskXMLToProps(const void *opaque)
goto cleanup; goto cleanup;
} }
if (qemuDomainPrepareDiskSourceChain(disk, NULL, NULL, data->qemuCaps) < 0)
goto cleanup;
for (n = disk->src; virStorageSourceIsBacking(n); n = n->backingStore) { for (n = disk->src; virStorageSourceIsBacking(n); n = n->backingStore) {
if (testQemuDiskXMLToJSONFakeSecrets(n) < 0) if (testQemuDiskXMLToJSONFakeSecrets(n) < 0)
goto cleanup; goto cleanup;
if (qemuDomainPrepareDiskSourceData(disk, n, NULL, data->qemuCaps) < 0)
goto cleanup;
if (!(formatProps = qemuBlockStorageSourceGetBlockdevProps(n)) || if (!(formatProps = qemuBlockStorageSourceGetBlockdevProps(n)) ||
!(storageProps = qemuBlockStorageSourceGetBackendProps(n, false))) { !(storageProps = qemuBlockStorageSourceGetBackendProps(n, false))) {
if (!data->fail) { if (!data->fail) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册