From: Pavel Hrdina <phrdina(a)redhat.com>
We should use the newest API only when user sets parallel-channels.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
tools/virsh-domain.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 56ddf4d701..c21cf847c8 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -5707,10 +5707,6 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptString(ctl, cmd, "file", &from) < 0)
return false;
- if (from &&
- virTypedParamsAddString(¶ms, &nparams, &maxparams,
- VIR_DOMAIN_SAVE_PARAM_FILE, from) < 0)
- return false;
if (vshCommandOptString(ctl, cmd, "xml", &xmlfile) < 0)
return false;
@@ -5718,10 +5714,6 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd)
if (xmlfile &&
virFileReadAll(xmlfile, VSH_MAX_XML_FILE, &xml) < 0)
return false;
- if (xml &&
- virTypedParamsAddString(¶ms, &nparams, &maxparams,
- VIR_DOMAIN_SAVE_PARAM_DXML, xml) < 0)
- return false;
if ((rc = vshCommandOptInt(ctl, cmd, "parallel-channels", &nchannels))
< 0)
return false;
@@ -5730,8 +5722,20 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd)
VIR_DOMAIN_SAVE_PARAM_PARALLEL_CHANNELS, nchannels) < 0)
return false;
- if (flags || xml) {
+ if (nparams > 0) {
+ if (from &&
+ virTypedParamsAddString(¶ms, &nparams, &maxparams,
+ VIR_DOMAIN_SAVE_PARAM_FILE, from) < 0)
+ return false;
+
+ if (xml &&
+ virTypedParamsAddString(¶ms, &nparams, &maxparams,
+ VIR_DOMAIN_SAVE_PARAM_DXML, xml) < 0)
+ return false;
+
rc = virDomainRestoreParams(priv->conn, params, nparams, flags);
+ } else if (flags || xml) {
+ rc = virDomainRestoreFlags(priv->conn, from, xml, flags);
} else {
rc = virDomainRestore(priv->conn, from);
}
--
2.48.1