提交 912bc720 编写于 作者: K Kothapally Madhu Pavan 提交者: Peter Krempa

virsh: Implement managedsave-edit command

Add a simple virsh command handler which makes use of the new API.
Signed-off-by: NKothapally Madhu Pavan <kmp@linux.vnet.ibm.com>
上级 c79697bb
...@@ -4704,6 +4704,72 @@ cmdManagedSaveRemove(vshControl *ctl, const vshCmd *cmd) ...@@ -4704,6 +4704,72 @@ cmdManagedSaveRemove(vshControl *ctl, const vshCmd *cmd)
return ret; return ret;
} }
/*
* "managedsave-edit" command
*/
static const vshCmdInfo info_managed_save_edit[] = {
{.name = "help",
.data = N_("edit XML for a domain's managed save state file")
},
{.name = "desc",
.data = N_("Edit the domain XML associated with the managed save state file")
},
{.name = NULL}
};
static const vshCmdOptDef opts_managed_save_edit[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL,
{.name = "running",
.type = VSH_OT_BOOL,
.help = N_("set domain to be running on start")
},
{.name = "paused",
.type = VSH_OT_BOOL,
.help = N_("set domain to be paused on start")
},
{.name = NULL}
};
static bool
cmdManagedSaveEdit(vshControl *ctl, const vshCmd *cmd)
{
bool ret = false;
virDomainPtr dom = NULL;
unsigned int getxml_flags = VIR_DOMAIN_XML_SECURE;
unsigned int define_flags = 0;
if (vshCommandOptBool(cmd, "running"))
define_flags |= VIR_DOMAIN_SAVE_RUNNING;
if (vshCommandOptBool(cmd, "paused"))
define_flags |= VIR_DOMAIN_SAVE_PAUSED;
VSH_EXCLUSIVE_OPTIONS("running", "paused");
dom = virshCommandOptDomain(ctl, cmd, NULL);
if (dom == NULL)
goto cleanup;
#define EDIT_GET_XML virDomainManagedSaveGetXMLDesc(dom, getxml_flags)
#define EDIT_NOT_CHANGED \
do { \
vshPrintExtra(ctl, _("Managed save image of domain %s XML configuration " \
"not changed.\n"), virDomainGetName(dom)); \
ret = true; \
goto edit_cleanup; \
} while (0)
#define EDIT_DEFINE \
(virDomainManagedSaveDefineXML(dom, doc_edited, define_flags) == 0)
#include "virsh-edit.c"
vshPrintExtra(ctl, _("Managed save image of Domain %s XML configuration edited.\n"),
virDomainGetName(dom));
ret = true;
cleanup:
virshDomainFree(dom);
return ret;
}
/* /*
* "managedsave-dumpxml" command * "managedsave-dumpxml" command
*/ */
...@@ -14006,6 +14072,12 @@ const vshCmdDef domManagementCmds[] = { ...@@ -14006,6 +14072,12 @@ const vshCmdDef domManagementCmds[] = {
.info = info_managedsaveremove, .info = info_managedsaveremove,
.flags = 0 .flags = 0
}, },
{.name = "managedsave-edit",
.handler = cmdManagedSaveEdit,
.opts = opts_managed_save_edit,
.info = info_managed_save_edit,
.flags = 0
},
{.name = "managedsave-dumpxml", {.name = "managedsave-dumpxml",
.handler = cmdManagedSaveDumpxml, .handler = cmdManagedSaveDumpxml,
.opts = opts_managed_save_dumpxml, .opts = opts_managed_save_dumpxml,
......
...@@ -1648,6 +1648,27 @@ Extract the domain XML that was in effect at the time the saved state ...@@ -1648,6 +1648,27 @@ Extract the domain XML that was in effect at the time the saved state
file I<file> was created with the B<managedsave> command. Using file I<file> was created with the B<managedsave> command. Using
I<--security-info> will also include security sensitive information. I<--security-info> will also include security sensitive information.
=item B<managedsave-edit> I<domain> [{I<--running> | I<--paused>}]
Edit the XML configuration associated with a saved state file of a
I<domain> was created by the B<managedsave> command.
The managed save image records whether the domain should be started to a
running or paused state. Normally, this command does not alter the
recorded state; passing either the I<--running> or I<--paused> flag
will allow overriding which state the B<restore> should use.
This is equivalent to:
virsh managedsave-dumpxml domain-name > state-file.xml
vi state-file.xml (or make changes with your other text editor)
virsh managedsave-define domain-name state-file-xml
except that it does some error checking.
The editor used can be supplied by the C<$VISUAL> or C<$EDITOR> environment
variables, and defaults to C<vi>.
=item B<maxvcpus> [I<type>] =item B<maxvcpus> [I<type>]
Provide the maximum number of virtual CPUs supported for a guest VM on Provide the maximum number of virtual CPUs supported for a guest VM on
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册