This refactoring will simplify next changes.
Signed-off-by: Nikolai Barybin <nikolai.barybin(a)virtuozzo.com>
---
src/qemu/qemu_domain.c | 40 +++++++++++++++++++++++++++-------------
1 file changed, 27 insertions(+), 13 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index ed305d9427..86362393e2 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -7974,6 +7974,32 @@ qemuDomainPrepareStorageSourceConfig(virStorageSource *src,
}
+static int
+qemuDomainPrepareStorageSource(virStorageSource *src,
+ virDomainObj *vm,
+ virDomainDiskDef *disk,
+ virQEMUDriverConfig *cfg)
+{
+ qemuDomainObjPrivate *priv = vm->privateData;
+
+ /* convert detected ISO format to 'raw' as qemu would not understand it */
+ if (src->format == VIR_STORAGE_FILE_ISO)
+ src->format = VIR_STORAGE_FILE_RAW;
+
+ if (qemuDomainValidateStorageSource(src, priv->qemuCaps) < 0)
+ return -1;
+
+ qemuDomainPrepareStorageSourceConfig(src, cfg);
+ qemuDomainPrepareDiskSourceData(disk, src);
+
+ if (!qemuDiskBusIsSD(disk->bus) &&
+ qemuDomainPrepareStorageSourceBlockdev(disk, src, priv, cfg) < 0)
+ return -1;
+
+ return 0;
+}
+
+
/**
* qemuDomainDetermineDiskChain:
* @driver: qemu driver object
@@ -7994,7 +8020,6 @@ qemuDomainDetermineDiskChain(virQEMUDriver *driver,
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
virStorageSource *src; /* iterator for the backing chain declared in XML */
virStorageSource *n; /* iterator for the backing chain detected from disk */
- qemuDomainObjPrivate *priv = vm->privateData;
uid_t uid;
gid_t gid;
@@ -8078,18 +8103,7 @@ qemuDomainDetermineDiskChain(virQEMUDriver *driver,
return -1;
for (n = src->backingStore; virStorageSourceIsBacking(n); n = n->backingStore)
{
- /* convert detected ISO format to 'raw' as qemu would not understand it
*/
- if (n->format == VIR_STORAGE_FILE_ISO)
- n->format = VIR_STORAGE_FILE_RAW;
-
- if (qemuDomainValidateStorageSource(n, priv->qemuCaps) < 0)
- return -1;
-
- qemuDomainPrepareStorageSourceConfig(n, cfg);
- qemuDomainPrepareDiskSourceData(disk, n);
-
- if (!qemuDiskBusIsSD(disk->bus) &&
- qemuDomainPrepareStorageSourceBlockdev(disk, n, priv, cfg) < 0)
+ if (qemuDomainPrepareStorageSource(n, vm, disk, cfg) < 0)
return -1;
}
--
2.43.5