Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
4057725f
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看板
提交
4057725f
编写于
8月 23, 2012
作者:
P
Paolo Bonzini
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
hmp: add NBD server commands
Signed-off-by:
N
Paolo Bonzini
<
pbonzini@redhat.com
>
上级
17b6be4a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
124 addition
and
0 deletion
+124
-0
hmp-commands.hx
hmp-commands.hx
+45
-0
hmp.c
hmp.c
+76
-0
hmp.h
hmp.h
+3
-0
未找到文件。
hmp-commands.hx
浏览文件 @
4057725f
...
...
@@ -1310,6 +1310,51 @@ Remove all matches from the access control list, and set the default
policy back to @code{deny}.
ETEXI
{
.name = "nbd_server_start",
.args_type = "all:-a,writable:-w,uri:s",
.params = "nbd_server_start [-a] [-w] host:port",
.help = "serve block devices on the given host and port",
.mhandler.cmd = hmp_nbd_server_start,
},
STEXI
@item nbd_server_start @var{host}:@var{port}
@findex nbd_server_start
Start an NBD server on the given host and/or port. If the @option{-a}
option is included, all of the virtual machine's block devices that
have an inserted media on them are automatically exported; in this case,
the @option{-w} option makes the devices writable too.
ETEXI
{
.name = "nbd_server_add",
.args_type = "writable:-w,device:B",
.params = "nbd_server_add [-w] device",
.help = "export a block device via NBD",
.mhandler.cmd = hmp_nbd_server_add,
},
STEXI
@item nbd_server_add @var{device}
@findex nbd_server_add
Export a block device through QEMU's NBD server, which must be started
beforehand with @command{nbd_server_start}. The @option{-w} option makes the
exported device writable too.
ETEXI
{
.name = "nbd_server_stop",
.args_type = "",
.params = "nbd_server_stop",
.help = "stop serving block devices using the NBD protocol",
.mhandler.cmd = hmp_nbd_server_stop,
},
STEXI
@item nbd_server_stop
@findex nbd_server_stop
Stop the QEMU embedded NBD server.
ETEXI
#if defined(TARGET_I386)
{
...
...
hmp.c
浏览文件 @
4057725f
...
...
@@ -18,6 +18,7 @@
#include "qemu-option.h"
#include "qemu-timer.h"
#include "qmp-commands.h"
#include "qemu_socket.h"
#include "monitor.h"
#include "console.h"
...
...
@@ -1259,3 +1260,78 @@ void hmp_screen_dump(Monitor *mon, const QDict *qdict)
qmp_screendump
(
filename
,
&
err
);
hmp_handle_error
(
mon
,
&
err
);
}
void
hmp_nbd_server_start
(
Monitor
*
mon
,
const
QDict
*
qdict
)
{
const
char
*
uri
=
qdict_get_str
(
qdict
,
"uri"
);
int
writable
=
qdict_get_try_bool
(
qdict
,
"writable"
,
0
);
int
all
=
qdict_get_try_bool
(
qdict
,
"all"
,
0
);
Error
*
local_err
=
NULL
;
BlockInfoList
*
block_list
,
*
info
;
SocketAddress
*
addr
;
if
(
writable
&&
!
all
)
{
error_setg
(
&
local_err
,
"-w only valid together with -a"
);
goto
exit
;
}
/* First check if the address is valid and start the server. */
addr
=
socket_parse
(
uri
,
&
local_err
);
if
(
local_err
!=
NULL
)
{
goto
exit
;
}
qmp_nbd_server_start
(
addr
,
&
local_err
);
qapi_free_SocketAddress
(
addr
);
if
(
local_err
!=
NULL
)
{
goto
exit
;
}
if
(
!
all
)
{
return
;
}
/* Then try adding all block devices. If one fails, close all and
* exit.
*/
block_list
=
qmp_query_block
(
NULL
);
for
(
info
=
block_list
;
info
;
info
=
info
->
next
)
{
if
(
!
info
->
value
->
has_inserted
)
{
continue
;
}
qmp_nbd_server_add
(
info
->
value
->
device
,
true
,
writable
,
&
local_err
);
if
(
local_err
!=
NULL
)
{
qmp_nbd_server_stop
(
NULL
);
break
;
}
}
qapi_free_BlockInfoList
(
block_list
);
exit:
hmp_handle_error
(
mon
,
&
local_err
);
}
void
hmp_nbd_server_add
(
Monitor
*
mon
,
const
QDict
*
qdict
)
{
const
char
*
device
=
qdict_get_str
(
qdict
,
"device"
);
int
writable
=
qdict_get_try_bool
(
qdict
,
"writable"
,
0
);
Error
*
local_err
=
NULL
;
qmp_nbd_server_add
(
device
,
true
,
writable
,
&
local_err
);
if
(
local_err
!=
NULL
)
{
hmp_handle_error
(
mon
,
&
local_err
);
}
}
void
hmp_nbd_server_stop
(
Monitor
*
mon
,
const
QDict
*
qdict
)
{
Error
*
errp
=
NULL
;
qmp_nbd_server_stop
(
&
errp
);
hmp_handle_error
(
mon
,
&
errp
);
}
hmp.h
浏览文件 @
4057725f
...
...
@@ -77,5 +77,8 @@ void hmp_getfd(Monitor *mon, const QDict *qdict);
void
hmp_closefd
(
Monitor
*
mon
,
const
QDict
*
qdict
);
void
hmp_send_key
(
Monitor
*
mon
,
const
QDict
*
qdict
);
void
hmp_screen_dump
(
Monitor
*
mon
,
const
QDict
*
qdict
);
void
hmp_nbd_server_start
(
Monitor
*
mon
,
const
QDict
*
qdict
);
void
hmp_nbd_server_add
(
Monitor
*
mon
,
const
QDict
*
qdict
);
void
hmp_nbd_server_stop
(
Monitor
*
mon
,
const
QDict
*
qdict
);
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录