On Fri, Sep 18, 2015 at 18:05:45 +0300, Nikolay Shirokovskiy wrote:
Let's put main functionality into params version of
virDomainMigrateUnmanaged
as a preparation step for merging it with virDomainMigratePeer2PeerParams.
virDomainMigrateUnmanaged then does nothing more then just adapting arguments.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)virtuozzo.com>
---
src/libvirt-domain.c | 92 +++++++++++++++++++++++++++++++++-----------------
1 files changed, 61 insertions(+), 31 deletions(-)
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index f52c3bf..330ccab 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
...
+static int
+virDomainMigrateUnmanaged(virDomainPtr domain,
+ const char *xmlin,
+ unsigned int flags,
+ const char *dname,
+ const char *dconnuri,
+ const char *miguri,
+ unsigned long long bandwidth)
+{
+ int ret = -1;
+ virTypedParameterPtr params = NULL;
+ int nparams = 0;
+ int maxparams = 0;
+
+ if (virTypedParamsAddString(¶ms, &nparams, &maxparams,
+ VIR_MIGRATE_PARAM_URI, miguri) < 0 ||
+ virTypedParamsAddString(¶ms, &nparams, &maxparams,
+ VIR_MIGRATE_PARAM_DEST_NAME, dname) < 0 ||
+ virTypedParamsAddString(¶ms, &nparams, &maxparams,
+ VIR_MIGRATE_PARAM_DEST_XML, xmlin) < 0 ||
+ virTypedParamsAddULLong(¶ms, &nparams, &maxparams,
+ VIR_MIGRATE_PARAM_BANDWIDTH, bandwidth) < 0)
+ goto cleanup;
All the *AddString calls should only be done when the appropriate value
is not NULL, otherwise *AddString will actually add "" into params and
thus you will get "" rather than NULL in virDomainMigrateUnmanagedParams.
In other words, something like
if (miguri &&
virTypedParamsAddString(¶ms, &nparams, &maxparams,
VIR_MIGRATE_PARAM_URI, miguri) < 0)
goto cleanup;
...
Jirka