{"bypass-cache", VSH_OT_BOOL, 0, N_("avoid file system cache when saving")},
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
{"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("where to save the data")},
+ {"xml", VSH_OT_STRING, 0,
+ N_("filename containing updated XML for the target")},
{NULL, 0, 0, NULL}
};
const char *to = NULL;
bool ret = false;
int flags = 0;
+ const char *xmlfile = NULL;
+ char *xml = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptBool(cmd, "bypass-cache"))
flags |= VIR_DOMAIN_SAVE_BYPASS_CACHE;
+ if (vshCommandOptString(cmd, "xml", &xmlfile) < 0) {
+ vshError(ctl, "%s", _("malformed xml argument"));
+ return false;
+ }
+
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
return false;
- if ((flags ? virDomainSaveFlags(dom, to, NULL, flags)
+ if (xmlfile &&
+ virFileReadAll(xmlfile, 8192, &xml) < 0)
+ goto cleanup;
+
+ if (((flags || xml)
+ ? virDomainSaveFlags(dom, to, xml, flags)
: virDomainSave(dom, to)) < 0) {
vshError(ctl, _("Failed to save domain %s to %s"), name, to);
goto cleanup;
ret = true;
cleanup:
+ VIR_FREE(xml);
virDomainFree(dom);
return ret;
}
{"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("the state to restore")},
{"bypass-cache", VSH_OT_BOOL, 0,
N_("avoid file system cache when restoring")},
+ {"xml", VSH_OT_STRING, 0,
+ N_("filename containing updated XML for the target")},
{NULL, 0, 0, NULL}
};
const char *from = NULL;
bool ret = false;
int flags = 0;
+ const char *xmlfile = NULL;
+ char *xml = NULL;
if (!vshConnectionUsability(ctl, ctl->conn))
return false;
if (vshCommandOptBool(cmd, "bypass-cache"))
flags |= VIR_DOMAIN_SAVE_BYPASS_CACHE;
- if ((flags ? virDomainRestoreFlags(ctl->conn, from, NULL, flags)
+ if (vshCommandOptString(cmd, "xml", &xmlfile) < 0) {
+ vshError(ctl, "%s", _("malformed xml argument"));
+ return false;
+ }
+
+ if (xmlfile &&
+ virFileReadAll(xmlfile, 8192, &xml) < 0)
+ goto cleanup;
+
+ if (((flags || xml)
+ ? virDomainRestoreFlags(ctl->conn, from, xml, flags)
: virDomainRestore(ctl->conn, from)) < 0) {
vshError(ctl, _("Failed to restore domain from %s"), from);
goto cleanup;
ret = true;
cleanup:
+ VIR_FREE(xml);
return ret;
}
=item B<migrate> [I<--live>] [I<--direct>] [I<--p2p> [I<--tunnelled>]]
[I<--persistent>] [I<--undefinesource>] [I<--suspend>] [I<--copy-storage-all>]
[I<--copy-storage-inc>] [I<--verbose>] I<domain-id> I<desturi> [I<migrateuri>]
-[I<dname>] [I<--timeout> B<seconds>]
+[I<dname>] [I<--timeout> B<seconds>] [I<--xml> B<file>]
Migrate domain to another host. Add I<--live> for live migration; I<--p2p>
for peer-2-peer migration; I<--direct> for direct migration; or I<--tunnelled>
The I<desturi> is the connection URI of the destination host, and
I<migrateuri> is the migration URI, which usually can be omitted.
I<dname> is used for renaming the domain to new name during migration, which
-also usually can be omitted.
+also usually can be omitted. Likewise, I<--xml> B<file> is usually
+omitted, but can be used to supply an alternative XML file for use on
+the destination to supply a larger set of changes to any host-specific
+portions of the domain XML, such as accounting for naming differences
+between source and destination in accessing underlying storage.
I<--timeout> B<seconds> forces guest to suspend when live migration exceeds
that many seconds, and
The exact behavior of a domain when it reboots is set by the
I<on_reboot> parameter in the domain's XML definition.
-=item B<restore> I<state-file> [I<--bypass-cache>]
+=item B<restore> I<state-file> [I<--bypass-cache>] [I<--xml> B<file>]
Restores a domain from a B<virsh save> state file. See I<save> for more info.
If I<--bypass-cache> is specified, the restore will avoid the file system
cache, although this may slow down the operation.
+I<--xml> B<file> is usually omitted, but can be used to supply an
+alternative XML file for use on the restored guest with changes only
+in the host-specific portions of the domain XML. For example, it can
+be used to account for file naming differences in underlying storage
+due to disk snapshots taken after the guest was saved.
+
B<Note>: To avoid corrupting file system contents within the domain, you
should not reuse the saved state file for a second B<restore> unless you
have also reverted all storage volumes back to the same contents as when
the state file was created.
-=item B<save> I<domain-id> I<state-file> [I<--bypass-cache>]
+=item B<save> I<domain-id> I<state-file> [I<--bypass-cache>] [I<--xml> B<file>]
Saves a running domain (RAM, but not disk state) to a state file so that
it can be restored
with all the same limitations. Open network connections may be
severed upon restore, as TCP timeouts may have expired.
+I<--xml> B<file> is usually omitted, but can be used to supply an
+alternative XML file for use on the restored guest with changes only
+in the host-specific portions of the domain XML. For example, it can
+be used to account for file naming differences that are planned to
+be made via disk snapshots of underlying storage after the guest is saved.
+
Domain saved state files assume that disk images will be unchanged
between the creation and restore point. For a more complete system
restore point, where the disk state is saved alongside the memory