Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
924f766a
Q
qemu
项目概览
openeuler
/
qemu
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
qemu
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
924f766a
编写于
6月 08, 2011
作者:
A
Anthony Liguori
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'qmp/for-anthony' into staging
上级
93e0597e
37628f11
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
91 addition
and
25 deletion
+91
-25
QMP/qmp.py
QMP/qmp.py
+40
-14
hmp-commands.hx
hmp-commands.hx
+5
-4
monitor.c
monitor.c
+12
-7
qerror.c
qerror.c
+4
-0
qerror.h
qerror.h
+3
-0
qmp-commands.hx
qmp-commands.hx
+27
-0
未找到文件。
QMP/qmp.py
浏览文件 @
924f766a
...
...
@@ -22,19 +22,24 @@ class QMPCapabilitiesError(QMPError):
pass
class
QEMUMonitorProtocol
:
def
__init__
(
self
,
address
):
def
__init__
(
self
,
address
,
server
=
False
):
"""
Create a QEMUMonitorProtocol class.
@param address: QEMU address, can be either a unix socket path (string)
or a tuple in the form ( address, port ) for a TCP
connection
@note No connection is established, this is done by the connect() method
@param server: server mode listens on the socket (bool)
@raise socket.error on socket connection errors
@note No connection is established, this is done by the connect() or
accept() methods
"""
self
.
__events
=
[]
self
.
__address
=
address
self
.
__sock
=
self
.
__get_sock
()
self
.
__sockfile
=
self
.
__sock
.
makefile
()
if
server
:
self
.
__sock
.
bind
(
self
.
__address
)
self
.
__sock
.
listen
(
1
)
def
__get_sock
(
self
):
if
isinstance
(
self
.
__address
,
tuple
):
...
...
@@ -43,7 +48,18 @@ class QEMUMonitorProtocol:
family
=
socket
.
AF_UNIX
return
socket
.
socket
(
family
,
socket
.
SOCK_STREAM
)
def
__json_read
(
self
):
def
__negotiate_capabilities
(
self
):
self
.
__sockfile
=
self
.
__sock
.
makefile
()
greeting
=
self
.
__json_read
()
if
greeting
is
None
or
not
greeting
.
has_key
(
'QMP'
):
raise
QMPConnectError
# Greeting seems ok, negotiate capabilities
resp
=
self
.
cmd
(
'qmp_capabilities'
)
if
"return"
in
resp
:
return
greeting
raise
QMPCapabilitiesError
def
__json_read
(
self
,
only_event
=
False
):
while
True
:
data
=
self
.
__sockfile
.
readline
()
if
not
data
:
...
...
@@ -51,7 +67,8 @@ class QEMUMonitorProtocol:
resp
=
json
.
loads
(
data
)
if
'event'
in
resp
:
self
.
__events
.
append
(
resp
)
continue
if
not
only_event
:
continue
return
resp
error
=
socket
.
error
...
...
@@ -66,14 +83,19 @@ class QEMUMonitorProtocol:
@raise QMPCapabilitiesError if fails to negotiate capabilities
"""
self
.
__sock
.
connect
(
self
.
__address
)
greeting
=
self
.
__json_read
()
if
greeting
is
None
or
not
greeting
.
has_key
(
'QMP'
):
raise
QMPConnectError
# Greeting seems ok, negotiate capabilities
resp
=
self
.
cmd
(
'qmp_capabilities'
)
if
"return"
in
resp
:
return
greeting
raise
QMPCapabilitiesError
return
self
.
__negotiate_capabilities
()
def
accept
(
self
):
"""
Await connection from QMP Monitor and perform capabilities negotiation.
@return QMP greeting dict
@raise socket.error on socket connection errors
@raise QMPConnectError if the greeting is not received
@raise QMPCapabilitiesError if fails to negotiate capabilities
"""
self
.
__sock
,
_
=
self
.
__sock
.
accept
()
return
self
.
__negotiate_capabilities
()
def
cmd_obj
(
self
,
qmp_cmd
):
"""
...
...
@@ -106,9 +128,11 @@ class QEMUMonitorProtocol:
qmp_cmd
[
'id'
]
=
id
return
self
.
cmd_obj
(
qmp_cmd
)
def
get_events
(
self
):
def
get_events
(
self
,
wait
=
False
):
"""
Get a list of available QMP events.
@param wait: block until an event is available (bool)
"""
self
.
__sock
.
setblocking
(
0
)
try
:
...
...
@@ -118,6 +142,8 @@ class QEMUMonitorProtocol:
# No data available
pass
self
.
__sock
.
setblocking
(
1
)
if
not
self
.
__events
and
wait
:
self
.
__json_read
(
only_event
=
True
)
return
self
.
__events
def
clear_events
(
self
):
...
...
hmp-commands.hx
浏览文件 @
924f766a
...
...
@@ -740,10 +740,11 @@ ETEXI
#if defined(TARGET_I386)
{
.name = "nmi",
.args_type = "cpu_index:i",
.params = "cpu",
.help = "inject an NMI on the given CPU",
.mhandler.cmd = do_inject_nmi,
.args_type = "",
.params = "",
.help = "inject an NMI on all guest's CPUs",
.user_print = monitor_user_noop,
.mhandler.cmd_new = do_inject_nmi,
},
#endif
STEXI
...
...
monitor.c
浏览文件 @
924f766a
...
...
@@ -2544,16 +2544,21 @@ static void do_wav_capture(Monitor *mon, const QDict *qdict)
#endif
#if defined(TARGET_I386)
static
void
do_inject_nmi
(
Monitor
*
mon
,
const
QDict
*
qdict
)
static
int
do_inject_nmi
(
Monitor
*
mon
,
const
QDict
*
qdict
,
QObject
**
ret_data
)
{
CPUState
*
env
;
int
cpu_index
=
qdict_get_int
(
qdict
,
"cpu_index"
);
for
(
env
=
first_cpu
;
env
!=
NULL
;
env
=
env
->
next_cpu
)
if
(
env
->
cpu_index
==
cpu_index
)
{
cpu_interrupt
(
env
,
CPU_INTERRUPT_NMI
);
break
;
}
for
(
env
=
first_cpu
;
env
!=
NULL
;
env
=
env
->
next_cpu
)
{
cpu_interrupt
(
env
,
CPU_INTERRUPT_NMI
);
}
return
0
;
}
#else
static
int
do_inject_nmi
(
Monitor
*
mon
,
const
QDict
*
qdict
,
QObject
**
ret_data
)
{
qerror_report
(
QERR_UNSUPPORTED
);
return
-
1
;
}
#endif
...
...
qerror.c
浏览文件 @
924f766a
...
...
@@ -200,6 +200,10 @@ static const QErrorStringTable qerror_table[] = {
.
error_fmt
=
QERR_UNDEFINED_ERROR
,
.
desc
=
"An undefined error has ocurred"
,
},
{
.
error_fmt
=
QERR_UNSUPPORTED
,
.
desc
=
"this feature or command is not currently supported"
,
},
{
.
error_fmt
=
QERR_UNKNOWN_BLOCK_FORMAT_FEATURE
,
.
desc
=
"'%(device)' uses a %(format) feature which is not "
...
...
qerror.h
浏览文件 @
924f766a
...
...
@@ -169,6 +169,9 @@ QError *qobject_to_qerror(const QObject *obj);
#define QERR_UNDEFINED_ERROR \
"{ 'class': 'UndefinedError', 'data': {} }"
#define QERR_UNSUPPORTED \
"{ 'class': 'Unsupported', 'data': {} }"
#define QERR_UNKNOWN_BLOCK_FORMAT_FEATURE \
"{ 'class': 'UnknownBlockFormatFeature', 'data': { 'device': %s, 'format': %s, 'feature': %s } }"
...
...
qmp-commands.hx
浏览文件 @
924f766a
...
...
@@ -427,6 +427,33 @@ Example:
"filename"
:
"/tmp/physical-mem-dump"
}
}
<-
{
"return"
:
{}
}
EQMP
{
.
name
=
"inject-nmi"
,
.
args_type
=
""
,
.
params
=
""
,
.
help
=
""
,
.
user_print
=
monitor_user_noop
,
.
mhandler
.
cmd_new
=
do_inject_nmi
,
},
SQMP
inject
-
nmi
----------
Inject
an
NMI
on
guest
's CPUs.
Arguments: None.
Example:
-> { "execute": "inject-nmi" }
<- { "return": {} }
Note: inject-nmi is only supported for x86 guest currently, it will
returns "Unsupported" error for non-x86 guest.
EQMP
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录