Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
6e4c540d
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6e4c540d
编写于
12月 20, 2011
作者:
M
Michal Privoznik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
virsh: Use vshWatchJob in cmdSave
This patch alters saving code, so we can report progress and allow cancel via ^C.
上级
5ccc7f64
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
76 addition
and
18 deletion
+76
-18
tools/virsh.c
tools/virsh.c
+72
-14
tools/virsh.pod
tools/virsh.pod
+4
-4
未找到文件。
tools/virsh.c
浏览文件 @
6e4c540d
...
@@ -2409,25 +2409,35 @@ static const vshCmdOptDef opts_save[] = {
...
@@ -2409,25 +2409,35 @@ static const vshCmdOptDef opts_save[] = {
N_("filename containing updated XML for the target")},
N_("filename containing updated XML for the target")},
{"running", VSH_OT_BOOL, 0, N_("set domain to be running on restore")},
{"running", VSH_OT_BOOL, 0, N_("set domain to be running on restore")},
{"paused", VSH_OT_BOOL, 0, N_("set domain to be paused on restore")},
{"paused", VSH_OT_BOOL, 0, N_("set domain to be paused on restore")},
{"verbose", VSH_OT_BOOL, 0, N_("display the progress of save")},
{NULL, 0, 0, NULL}
{NULL, 0, 0, NULL}
};
};
static
bool
static
void
cmdSave(vshControl *ctl, const vshCmd *cmd
)
doSave(void *opaque
)
{
{
virDomainPtr dom;
vshCtrlData *data = opaque;
vshControl *ctl = data->ctl;
const vshCmd *cmd = data->cmd;
char ret = '1';
virDomainPtr dom = NULL;
const char *name = NULL;
const char *name = NULL;
const char *to = NULL;
const char *to = NULL;
bool ret = false;
unsigned int flags = 0;
unsigned int flags = 0;
const char *xmlfile = NULL;
const char *xmlfile = NULL;
char *xml = NULL;
char *xml = NULL;
sigset_t sigmask, oldsigmask;
sigemptyset(&sigmask);
sigaddset(&sigmask, SIGINT);
if (pthread_sigmask(SIG_BLOCK, &sigmask, &oldsigmask) < 0)
goto out_sig;
if (!vshConnectionUsability(ctl, ctl->conn))
if (!vshConnectionUsability(ctl, ctl->conn))
return false
;
goto out
;
if (vshCommandOptString(cmd, "file", &to) <= 0)
if (vshCommandOptString(cmd, "file", &to) <= 0)
return false
;
goto out
;
if (vshCommandOptBool(cmd, "bypass-cache"))
if (vshCommandOptBool(cmd, "bypass-cache"))
flags |= VIR_DOMAIN_SAVE_BYPASS_CACHE;
flags |= VIR_DOMAIN_SAVE_BYPASS_CACHE;
...
@@ -2438,29 +2448,77 @@ cmdSave(vshControl *ctl, const vshCmd *cmd)
...
@@ -2438,29 +2448,77 @@ cmdSave(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptString(cmd, "xml", &xmlfile) < 0) {
if (vshCommandOptString(cmd, "xml", &xmlfile) < 0) {
vshError(ctl, "%s", _("malformed xml argument"));
vshError(ctl, "%s", _("malformed xml argument"));
return false
;
goto out
;
}
}
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
return false
;
goto out
;
if (xmlfile &&
if (xmlfile &&
virFileReadAll(xmlfile, 8192, &xml) < 0)
virFileReadAll(xmlfile, 8192, &xml) < 0)
goto
cleanup
;
goto
out
;
if (((flags || xml)
if (((flags || xml)
? virDomainSaveFlags(dom, to, xml, flags)
? 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
out
;
}
}
vshPrint(ctl, _("Domain %s saved to %s\n"), name, to);
ret = '0';
ret = true;
cleanup:
out:
pthread_sigmask(SIG_SETMASK, &oldsigmask, NULL);
out_sig:
if (dom) virDomainFree (dom);
VIR_FREE(xml);
VIR_FREE(xml);
virDomainFree(dom);
ignore_value(safewrite(data->writefd, &ret, sizeof(ret)));
}
static bool
cmdSave(vshControl *ctl, const vshCmd *cmd)
{
bool ret = false;
virDomainPtr dom = NULL;
int p[2] = {-1. -1};
virThread workerThread;
bool verbose = false;
vshCtrlData data;
const char *to = NULL;
const char *name = NULL;
if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
return false;
if (vshCommandOptString(cmd, "file", &to) <= 0)
goto cleanup;
if (vshCommandOptBool (cmd, "verbose"))
verbose = true;
if (pipe(p) < 0)
goto cleanup;
data.ctl = ctl;
data.cmd = cmd;
data.writefd = p[1];
if (virThreadCreate(&workerThread,
true,
doSave,
&data) < 0)
goto cleanup;
ret = vshWatchJob(ctl, dom, verbose, p[0], 0, NULL, NULL, _("Save"));
virThreadJoin(&workerThread);
if (ret)
vshPrint(ctl, _("\nDomain %s saved to %s\n"), name, to);
cleanup:
if (dom)
virDomainFree(dom);
return ret;
return ret;
}
}
...
...
tools/virsh.pod
浏览文件 @
6e4c540d
...
@@ -898,7 +898,7 @@ have also reverted all storage volumes back to the same contents as when
...
@@ -898,7 +898,7 @@ 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>] [I<--xml> B<file>]
=item B<save> I<domain-id> I<state-file> [I<--bypass-cache>] [I<--xml> B<file>]
[{I<--running> | I<--paused>}]
[{I<--running> | I<--paused>}]
[I<--verbose>]
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
...
@@ -909,9 +909,9 @@ If I<--bypass-cache> is specified, the save will avoid the file system
...
@@ -909,9 +909,9 @@ If I<--bypass-cache> is specified, the save will avoid the file system
cache, although this may slow down the operation.
cache, although this may slow down the operation.
The progress may be monitored using B<domjobinfo> virsh command and canceled
The progress may be monitored using B<domjobinfo> virsh command and canceled
with B<domjobabort> command (sent by another virsh instance).
Interrupting
with B<domjobabort> command (sent by another virsh instance).
Another option
(usually with C<Ctrl-C>) the virsh process which runs B<save> command is not
is to send SIGINT (usually with C<Ctrl-C>) to the virsh process running
enough to actually cancel the operation
.
B<save> command. I<--verbose> displays the progress of save
.
This is roughly equivalent to doing a hibernate on a running computer,
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
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录