It will be more future proof if we just pass a pointer to a single NBD
disk representation to the qemuMigrationPrecreateDisk() instead of
copying every single item onto the stack.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_migration.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 3a05346..d4757e4 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -139,16 +139,20 @@ struct _qemuMigrationCookieNetwork {
qemuMigrationCookieNetDataPtr net;
};
+typedef struct _qemuMigrationCookieNBDDisk qemuMigrationCookieNBDDisk;
+typedef qemuMigrationCookieNBDDisk *qemuMigrationCookieNBDDiskPtr;
+struct _qemuMigrationCookieNBDDisk {
+ char *target; /* Disk target */
+ unsigned long long capacity; /* And its capacity */
+};
+
typedef struct _qemuMigrationCookieNBD qemuMigrationCookieNBD;
typedef qemuMigrationCookieNBD *qemuMigrationCookieNBDPtr;
struct _qemuMigrationCookieNBD {
int port; /* on which port does NBD server listen for incoming data */
size_t ndisks; /* Number of items in @disk array */
- struct {
- char *target; /* Disk target */
- unsigned long long capacity; /* And its capacity */
- } *disks;
+ qemuMigrationCookieNBDDiskPtr disks;
};
typedef struct _qemuMigrationCookie qemuMigrationCookie;
@@ -1460,7 +1464,7 @@ qemuMigrationRestoreDomainState(virConnectPtr conn, virDomainObjPtr
vm)
static int
qemuMigrationPrecreateDisk(virConnectPtr conn,
virDomainDiskDefPtr disk,
- unsigned long long capacity)
+ qemuMigrationCookieNBDDiskPtr nbd)
{
int ret = -1;
virStoragePoolPtr pool = NULL;
@@ -1536,7 +1540,7 @@ qemuMigrationPrecreateDisk(virConnectPtr conn,
virBufferAddLit(&buf, "<volume>\n");
virBufferAdjustIndent(&buf, 2);
virBufferEscapeString(&buf, "<name>%s</name>\n", volName);
- virBufferAsprintf(&buf, "<capacity>%llu</capacity>\n",
capacity);
+ virBufferAsprintf(&buf, "<capacity>%llu</capacity>\n",
nbd->capacity);
virBufferAddLit(&buf, "<target>\n");
virBufferAdjustIndent(&buf, 2);
virBufferAsprintf(&buf, "<format type='%s'/>\n",
format);
@@ -1603,7 +1607,7 @@ qemuMigrationPrecreateStorage(virConnectPtr conn,
VIR_DEBUG("Proceeding with disk source %s", NULLSTR(diskSrcPath));
- if (qemuMigrationPrecreateDisk(conn, disk, nbd->disks[i].capacity) < 0)
+ if (qemuMigrationPrecreateDisk(conn, disk, nbd->disks + i) < 0)
goto cleanup;
}
--
2.0.5