Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
bfdd20c5
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bfdd20c5
编写于
9月 21, 2018
作者:
S
Simon Kobyda
提交者:
Michal Privoznik
9月 24, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
virt-admin: Implement vshTable API to server-list and client-list
Signed-off-by:
N
Simon Kobyda
<
skobyda@redhat.com
>
上级
95b29fc2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
35 addition
and
12 deletion
+35
-12
tools/virt-admin.c
tools/virt-admin.c
+35
-12
未找到文件。
tools/virt-admin.c
浏览文件 @
bfdd20c5
...
...
@@ -39,6 +39,7 @@
#include "virgettext.h"
#include "virtime.h"
#include "virt-admin-completer.h"
#include "vsh-table.h"
/* Gnulib doesn't guarantee SA_SIGINFO support. */
#ifndef SA_SIGINFO
...
...
@@ -381,6 +382,7 @@ cmdSrvList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
char
*
uri
=
NULL
;
virAdmServerPtr
*
srvs
=
NULL
;
vshAdmControlPtr
priv
=
ctl
->
privData
;
vshTablePtr
table
=
NULL
;
/* Obtain a list of available servers on the daemon */
if
((
nsrvs
=
virAdmConnectListServers
(
priv
->
conn
,
&
srvs
,
0
))
<
0
)
{
...
...
@@ -390,13 +392,27 @@ cmdSrvList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
goto
cleanup
;
}
vshPrintExtra
(
ctl
,
" %-5s %-15s
\n
"
,
"Id"
,
"Name"
);
vshPrintExtra
(
ctl
,
"---------------
\n
"
);
for
(
i
=
0
;
i
<
nsrvs
;
i
++
)
vshPrint
(
ctl
,
" %-5zu %-15s
\n
"
,
i
,
virAdmServerGetName
(
srvs
[
i
]));
table
=
vshTableNew
(
_
(
"Id"
),
_
(
"Name"
),
NULL
);
if
(
!
table
)
goto
cleanup
;
for
(
i
=
0
;
i
<
nsrvs
;
i
++
)
{
VIR_AUTOFREE
(
char
*
)
idStr
=
NULL
;
if
(
virAsprintf
(
&
idStr
,
"%lu"
,
i
)
<
0
)
goto
cleanup
;
if
(
vshTableRowAppend
(
table
,
idStr
,
virAdmServerGetName
(
srvs
[
i
]),
NULL
)
<
0
)
goto
cleanup
;
}
vshTablePrintToStdout
(
table
,
ctl
);
ret
=
true
;
cleanup:
vshTableFree
(
table
);
if
(
srvs
)
{
for
(
i
=
0
;
i
<
nsrvs
;
i
++
)
virAdmServerFree
(
srvs
[
i
]);
...
...
@@ -612,10 +628,10 @@ cmdSrvClientsList(vshControl *ctl, const vshCmd *cmd)
const
char
*
srvname
=
NULL
;
unsigned
long
long
id
;
virClientTransport
transport
;
char
*
timestr
=
NULL
;
virAdmServerPtr
srv
=
NULL
;
virAdmClientPtr
*
clts
=
NULL
;
vshAdmControlPtr
priv
=
ctl
->
privData
;
vshTablePtr
table
=
NULL
;
if
(
vshCommandOptStringReq
(
ctl
,
cmd
,
"server"
,
&
srvname
)
<
0
)
return
false
;
...
...
@@ -630,12 +646,13 @@ cmdSrvClientsList(vshControl *ctl, const vshCmd *cmd)
goto
cleanup
;
}
vshPrintExtra
(
ctl
,
" %-5s %-15s %-15s
\n
%s
\n
"
,
_
(
"Id"
),
_
(
"Transport"
),
_
(
"Connected since"
),
"-------------------------"
"-------------------------"
);
table
=
vshTableNew
(
_
(
"Id"
),
_
(
"Transport"
),
_
(
"Connected sice"
),
NULL
);
if
(
!
table
)
goto
cleanup
;
for
(
i
=
0
;
i
<
nclts
;
i
++
)
{
VIR_AUTOFREE
(
char
*
)
timestr
=
NULL
;
VIR_AUTOFREE
(
char
*
)
idStr
=
NULL
;
virAdmClientPtr
client
=
clts
[
i
];
id
=
virAdmClientGetID
(
client
);
transport
=
virAdmClientGetTransport
(
client
);
...
...
@@ -643,14 +660,20 @@ cmdSrvClientsList(vshControl *ctl, const vshCmd *cmd)
&
timestr
)
<
0
)
goto
cleanup
;
vshPrint
(
ctl
,
" %-5llu %-15s %-15s
\n
"
,
id
,
vshAdmClientTransportToString
(
transport
),
timestr
);
VIR_FREE
(
timestr
);
if
(
virAsprintf
(
&
idStr
,
"%llu"
,
id
)
<
0
)
goto
cleanup
;
if
(
vshTableRowAppend
(
table
,
idStr
,
vshAdmClientTransportToString
(
transport
),
timestr
,
NULL
)
<
0
)
goto
cleanup
;
}
vshTablePrintToStdout
(
table
,
ctl
);
ret
=
true
;
cleanup:
vshTableFree
(
table
);
if
(
clts
)
{
for
(
i
=
0
;
i
<
nclts
;
i
++
)
virAdmClientFree
(
clts
[
i
]);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录