Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
4d099bc0
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看板
提交
4d099bc0
编写于
1月 10, 2011
作者:
M
Marc-André Lureau
提交者:
Eric Blake
1月 14, 2011
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
qemu: add set_password and expire_password monitor commands
上级
094c6f4a
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
224 addition
and
0 deletion
+224
-0
AUTHORS
AUTHORS
+1
-0
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.c
+77
-0
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor.h
+7
-0
src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_json.c
+56
-0
src/qemu/qemu_monitor_json.h
src/qemu/qemu_monitor_json.h
+7
-0
src/qemu/qemu_monitor_text.c
src/qemu/qemu_monitor_text.c
+69
-0
src/qemu/qemu_monitor_text.h
src/qemu/qemu_monitor_text.h
+7
-0
未找到文件。
AUTHORS
浏览文件 @
4d099bc0
...
...
@@ -143,6 +143,7 @@ Patches have also been contributed by:
Roopa Prabhu <roprabhu@cisco.com>
Paweł Krześniak <pawel.krzesniak@gmail.com>
Kay Schubert <kayegypt@web.de>
Marc-André Lureau <marcandre.lureau@redhat.com>
[....send patches to get your name here....]
...
...
src/qemu/qemu_monitor.c
浏览文件 @
4d099bc0
...
...
@@ -1097,6 +1097,83 @@ int qemuMonitorSetVNCPassword(qemuMonitorPtr mon,
return
ret
;
}
static
const
char
*
qemuMonitorTypeToProtocol
(
int
type
)
{
switch
(
type
)
{
case
VIR_DOMAIN_GRAPHICS_TYPE_VNC
:
return
"vnc"
;
case
VIR_DOMAIN_GRAPHICS_TYPE_SPICE
:
return
"spice"
;
default:
qemuReportError
(
VIR_ERR_INVALID_ARG
,
_
(
"unsupported protocol type %s"
),
virDomainGraphicsTypeToString
(
type
));
return
NULL
;
}
}
/* Returns -2 if not supported with this monitor connection */
int
qemuMonitorSetPassword
(
qemuMonitorPtr
mon
,
int
type
,
const
char
*
password
,
const
char
*
action_if_connected
)
{
const
char
*
protocol
=
qemuMonitorTypeToProtocol
(
type
);
int
ret
;
if
(
!
protocol
)
return
-
1
;
DEBUG
(
"mon=%p, protocol=%s, password=%p, action_if_connected=%s"
,
mon
,
protocol
,
password
,
action_if_connected
);
if
(
!
mon
)
{
qemuReportError
(
VIR_ERR_INVALID_ARG
,
"%s"
,
_
(
"monitor must not be NULL"
));
return
-
1
;
}
if
(
!
password
)
password
=
""
;
if
(
!
action_if_connected
)
action_if_connected
=
"keep"
;
if
(
mon
->
json
)
ret
=
qemuMonitorJSONSetPassword
(
mon
,
protocol
,
password
,
action_if_connected
);
else
ret
=
qemuMonitorTextSetPassword
(
mon
,
protocol
,
password
,
action_if_connected
);
return
ret
;
}
int
qemuMonitorExpirePassword
(
qemuMonitorPtr
mon
,
int
type
,
const
char
*
expire_time
)
{
const
char
*
protocol
=
qemuMonitorTypeToProtocol
(
type
);
int
ret
;
if
(
!
protocol
)
return
-
1
;
DEBUG
(
"mon=%p, protocol=%s, expire_time=%s"
,
mon
,
protocol
,
expire_time
);
if
(
!
mon
)
{
qemuReportError
(
VIR_ERR_INVALID_ARG
,
"%s"
,
_
(
"monitor must not be NULL"
));
return
-
1
;
}
if
(
!
expire_time
)
expire_time
=
"now"
;
if
(
mon
->
json
)
ret
=
qemuMonitorJSONExpirePassword
(
mon
,
protocol
,
expire_time
);
else
ret
=
qemuMonitorTextExpirePassword
(
mon
,
protocol
,
expire_time
);
return
ret
;
}
int
qemuMonitorSetBalloon
(
qemuMonitorPtr
mon
,
unsigned
long
newmem
)
...
...
src/qemu/qemu_monitor.h
浏览文件 @
4d099bc0
...
...
@@ -195,6 +195,13 @@ int qemuMonitorGetBlockExtent(qemuMonitorPtr mon,
int
qemuMonitorSetVNCPassword
(
qemuMonitorPtr
mon
,
const
char
*
password
);
int
qemuMonitorSetPassword
(
qemuMonitorPtr
mon
,
int
type
,
const
char
*
password
,
const
char
*
action_if_connected
);
int
qemuMonitorExpirePassword
(
qemuMonitorPtr
mon
,
int
type
,
const
char
*
expire_time
);
int
qemuMonitorSetBalloon
(
qemuMonitorPtr
mon
,
unsigned
long
newmem
);
int
qemuMonitorSetCPU
(
qemuMonitorPtr
mon
,
int
cpu
,
int
online
);
...
...
src/qemu/qemu_monitor_json.c
浏览文件 @
4d099bc0
...
...
@@ -1265,6 +1265,62 @@ int qemuMonitorJSONSetVNCPassword(qemuMonitorPtr mon,
return
ret
;
}
/* Returns -1 on error, -2 if not supported */
int
qemuMonitorJSONSetPassword
(
qemuMonitorPtr
mon
,
const
char
*
protocol
,
const
char
*
password
,
const
char
*
action_if_connected
)
{
int
ret
;
virJSONValuePtr
cmd
=
qemuMonitorJSONMakeCommand
(
"set_password"
,
"s:protocol"
,
protocol
,
"s:password"
,
password
,
"s:connected"
,
action_if_connected
,
NULL
);
virJSONValuePtr
reply
=
NULL
;
if
(
!
cmd
)
return
-
1
;
ret
=
qemuMonitorJSONCommand
(
mon
,
cmd
,
&
reply
);
if
(
ret
==
0
)
{
if
(
qemuMonitorJSONHasError
(
reply
,
"CommandNotFound"
))
{
ret
=
-
2
;
goto
cleanup
;
}
ret
=
qemuMonitorJSONCheckError
(
cmd
,
reply
);
}
cleanup:
virJSONValueFree
(
cmd
);
virJSONValueFree
(
reply
);
return
ret
;
}
int
qemuMonitorJSONExpirePassword
(
qemuMonitorPtr
mon
,
const
char
*
protocol
,
const
char
*
expire_time
)
{
int
ret
;
virJSONValuePtr
cmd
=
qemuMonitorJSONMakeCommand
(
"expire_password"
,
"s:protocol"
,
protocol
,
"s:time"
,
expire_time
,
NULL
);
virJSONValuePtr
reply
=
NULL
;
if
(
!
cmd
)
return
-
1
;
ret
=
qemuMonitorJSONCommand
(
mon
,
cmd
,
&
reply
);
if
(
ret
==
0
)
ret
=
qemuMonitorJSONCheckError
(
cmd
,
reply
);
virJSONValueFree
(
cmd
);
virJSONValueFree
(
reply
);
return
ret
;
}
/*
* Returns: 0 if balloon not supported, +1 if balloon adjust worked
* or -1 on failure
...
...
src/qemu/qemu_monitor_json.h
浏览文件 @
4d099bc0
...
...
@@ -63,6 +63,13 @@ int qemuMonitorJSONGetBlockExtent(qemuMonitorPtr mon,
int
qemuMonitorJSONSetVNCPassword
(
qemuMonitorPtr
mon
,
const
char
*
password
);
int
qemuMonitorJSONSetPassword
(
qemuMonitorPtr
mon
,
const
char
*
protocol
,
const
char
*
password
,
const
char
*
action_if_connected
);
int
qemuMonitorJSONExpirePassword
(
qemuMonitorPtr
mon
,
const
char
*
protocol
,
const
char
*
expire_time
);
int
qemuMonitorJSONSetBalloon
(
qemuMonitorPtr
mon
,
unsigned
long
newmem
);
int
qemuMonitorJSONSetCPU
(
qemuMonitorPtr
mon
,
int
cpu
,
int
online
);
...
...
src/qemu/qemu_monitor_text.c
浏览文件 @
4d099bc0
...
...
@@ -768,6 +768,75 @@ int qemuMonitorTextSetVNCPassword(qemuMonitorPtr mon,
return
0
;
}
/* Returns -1 on error, -2 if not supported */
int
qemuMonitorTextSetPassword
(
qemuMonitorPtr
mon
,
const
char
*
protocol
,
const
char
*
password
,
const
char
*
action_if_connected
)
{
char
*
cmd
=
NULL
;
char
*
reply
=
NULL
;
int
ret
=
-
1
;
if
(
virAsprintf
(
&
cmd
,
"set_password %s
\"
%s
\"
%s"
,
protocol
,
password
,
action_if_connected
)
<
0
)
{
virReportOOMError
();
goto
cleanup
;
}
if
(
qemuMonitorCommand
(
mon
,
cmd
,
&
reply
)
<
0
)
{
qemuReportError
(
VIR_ERR_OPERATION_FAILED
,
"%s"
,
_
(
"setting password failed"
));
goto
cleanup
;
}
if
(
strstr
(
reply
,
"unknown command:"
))
{
ret
=
-
2
;
goto
cleanup
;
}
ret
=
0
;
cleanup:
VIR_FREE
(
reply
);
VIR_FREE
(
cmd
);
return
ret
;
}
int
qemuMonitorTextExpirePassword
(
qemuMonitorPtr
mon
,
const
char
*
protocol
,
const
char
*
expire_time
)
{
char
*
cmd
=
NULL
;
char
*
reply
=
NULL
;
int
ret
=
-
1
;
if
(
virAsprintf
(
&
cmd
,
"expire_password %s %s"
,
protocol
,
expire_time
)
<
0
)
{
virReportOOMError
();
goto
cleanup
;
}
if
(
qemuMonitorCommand
(
mon
,
cmd
,
&
reply
)
<
0
)
{
qemuReportError
(
VIR_ERR_OPERATION_FAILED
,
"%s"
,
_
(
"expiring password failed"
));
goto
cleanup
;
}
if
(
strstr
(
reply
,
"unknown command:"
))
{
qemuReportError
(
VIR_ERR_NO_SUPPORT
,
_
(
"expiring password not supported by this qemu: %s"
),
reply
);
goto
cleanup
;
}
ret
=
0
;
cleanup:
VIR_FREE
(
reply
);
VIR_FREE
(
cmd
);
return
ret
;
}
/*
* Returns: 0 if balloon not supported, +1 if balloon adjust worked
* or -1 on failure
...
...
src/qemu/qemu_monitor_text.h
浏览文件 @
4d099bc0
...
...
@@ -61,6 +61,13 @@ int qemuMonitorTextGetBlockExtent(qemuMonitorPtr mon,
int
qemuMonitorTextSetVNCPassword
(
qemuMonitorPtr
mon
,
const
char
*
password
);
int
qemuMonitorTextSetPassword
(
qemuMonitorPtr
mon
,
const
char
*
protocol
,
const
char
*
password
,
const
char
*
action_if_connected
);
int
qemuMonitorTextExpirePassword
(
qemuMonitorPtr
mon
,
const
char
*
protocol
,
const
char
*
expire_time
);
int
qemuMonitorTextSetBalloon
(
qemuMonitorPtr
mon
,
unsigned
long
newmem
);
int
qemuMonitorTextSetCPU
(
qemuMonitorPtr
mon
,
int
cpu
,
int
online
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录