mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
save: support --xml to virsh save/restore
Also, migrate was missing documentation for the --xml option added in commit ec5301cb. * tools/virsh.c (cmdSave, cmdRestore): Add xml argument. * tools/virsh.pod (save, restore, migrate): Document it.
This commit is contained in:
parent
a779d2ff2d
commit
38149ec145
@ -1606,6 +1606,8 @@ static const vshCmdOptDef opts_save[] = {
|
|||||||
{"bypass-cache", VSH_OT_BOOL, 0, N_("avoid file system cache when saving")},
|
{"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")},
|
{"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")},
|
{"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}
|
{NULL, 0, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1617,6 +1619,8 @@ cmdSave(vshControl *ctl, const vshCmd *cmd)
|
|||||||
const char *to = NULL;
|
const char *to = NULL;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
const char *xmlfile = NULL;
|
||||||
|
char *xml = NULL;
|
||||||
|
|
||||||
if (!vshConnectionUsability(ctl, ctl->conn))
|
if (!vshConnectionUsability(ctl, ctl->conn))
|
||||||
return false;
|
return false;
|
||||||
@ -1627,10 +1631,20 @@ cmdSave(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (vshCommandOptBool(cmd, "bypass-cache"))
|
if (vshCommandOptBool(cmd, "bypass-cache"))
|
||||||
flags |= VIR_DOMAIN_SAVE_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)))
|
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
|
||||||
return false;
|
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) {
|
: virDomainSave(dom, to)) < 0) {
|
||||||
vshError(ctl, _("Failed to save domain %s to %s"), name, to);
|
vshError(ctl, _("Failed to save domain %s to %s"), name, to);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1640,6 +1654,7 @@ cmdSave(vshControl *ctl, const vshCmd *cmd)
|
|||||||
ret = true;
|
ret = true;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
VIR_FREE(xml);
|
||||||
virDomainFree(dom);
|
virDomainFree(dom);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -2016,6 +2031,8 @@ static const vshCmdOptDef opts_restore[] = {
|
|||||||
{"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("the state to restore")},
|
{"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("the state to restore")},
|
||||||
{"bypass-cache", VSH_OT_BOOL, 0,
|
{"bypass-cache", VSH_OT_BOOL, 0,
|
||||||
N_("avoid file system cache when restoring")},
|
N_("avoid file system cache when restoring")},
|
||||||
|
{"xml", VSH_OT_STRING, 0,
|
||||||
|
N_("filename containing updated XML for the target")},
|
||||||
{NULL, 0, 0, NULL}
|
{NULL, 0, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2025,6 +2042,8 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd)
|
|||||||
const char *from = NULL;
|
const char *from = NULL;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
const char *xmlfile = NULL;
|
||||||
|
char *xml = NULL;
|
||||||
|
|
||||||
if (!vshConnectionUsability(ctl, ctl->conn))
|
if (!vshConnectionUsability(ctl, ctl->conn))
|
||||||
return false;
|
return false;
|
||||||
@ -2035,7 +2054,17 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (vshCommandOptBool(cmd, "bypass-cache"))
|
if (vshCommandOptBool(cmd, "bypass-cache"))
|
||||||
flags |= VIR_DOMAIN_SAVE_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) {
|
: virDomainRestore(ctl->conn, from)) < 0) {
|
||||||
vshError(ctl, _("Failed to restore domain from %s"), from);
|
vshError(ctl, _("Failed to restore domain from %s"), from);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2045,6 +2074,7 @@ cmdRestore(vshControl *ctl, const vshCmd *cmd)
|
|||||||
ret = true;
|
ret = true;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
VIR_FREE(xml);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -544,7 +544,7 @@ type attribute for the <domain> element of XML.
|
|||||||
=item B<migrate> [I<--live>] [I<--direct>] [I<--p2p> [I<--tunnelled>]]
|
=item B<migrate> [I<--live>] [I<--direct>] [I<--p2p> [I<--tunnelled>]]
|
||||||
[I<--persistent>] [I<--undefinesource>] [I<--suspend>] [I<--copy-storage-all>]
|
[I<--persistent>] [I<--undefinesource>] [I<--suspend>] [I<--copy-storage-all>]
|
||||||
[I<--copy-storage-inc>] [I<--verbose>] I<domain-id> I<desturi> [I<migrateuri>]
|
[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>
|
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>
|
for peer-2-peer migration; I<--direct> for direct migration; or I<--tunnelled>
|
||||||
@ -559,7 +559,11 @@ I<--verbose> displays the progress of migration.
|
|||||||
The I<desturi> is the connection URI of the destination host, and
|
The I<desturi> is the connection URI of the destination host, and
|
||||||
I<migrateuri> is the migration URI, which usually can be omitted.
|
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
|
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
|
I<--timeout> B<seconds> forces guest to suspend when live migration exceeds
|
||||||
that many seconds, and
|
that many seconds, and
|
||||||
@ -599,19 +603,25 @@ domain actually reboots.
|
|||||||
The exact behavior of a domain when it reboots is set by the
|
The exact behavior of a domain when it reboots is set by the
|
||||||
I<on_reboot> parameter in the domain's XML definition.
|
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.
|
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
|
If I<--bypass-cache> is specified, the restore will avoid the file system
|
||||||
cache, although this may slow down the operation.
|
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
|
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
|
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
|
have also reverted all storage volumes back to the same contents as when
|
||||||
the state file was created.
|
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
|
Saves a running domain (RAM, but not disk state) to a state file so that
|
||||||
it can be restored
|
it can be restored
|
||||||
@ -625,6 +635,12 @@ This is roughly equivalent to doing a hibernate on a running computer,
|
|||||||
with all the same limitations. Open network connections may be
|
with all the same limitations. Open network connections may be
|
||||||
severed upon restore, as TCP timeouts may have expired.
|
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
|
Domain saved state files assume that disk images will be unchanged
|
||||||
between the creation and restore point. For a more complete system
|
between the creation and restore point. For a more complete system
|
||||||
restore point, where the disk state is saved alongside the memory
|
restore point, where the disk state is saved alongside the memory
|
||||||
|
Loading…
x
Reference in New Issue
Block a user