Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
9f5f5bd7
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,发现更多精彩内容 >>
提交
9f5f5bd7
编写于
4月 11, 2017
作者:
P
Peter Krempa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
virsh-domain: Use the virsh wrappers for getting XML to simplify code
Reuse virshDomainGetXML and virshDomainGetXMLFromDom.
上级
6bd28890
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
12 addition
and
50 deletion
+12
-50
tools/virsh-domain.c
tools/virsh-domain.c
+12
-50
未找到文件。
tools/virsh-domain.c
浏览文件 @
9f5f5bd7
...
...
@@ -2983,13 +2983,13 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd)
const
char
*
iface
;
const
char
*
state
;
char
*
value
;
char
*
desc
;
virMacAddr
macaddr
;
const
char
*
element
;
const
char
*
attr
;
bool
config
;
bool
ret
=
false
;
unsigned
int
flags
=
0
;
unsigned
int
xmlflags
=
0
;
size_t
i
;
xmlDocPtr
xml
=
NULL
;
xmlXPathContextPtr
ctxt
=
NULL
;
...
...
@@ -3011,28 +3011,18 @@ cmdDomIfSetLink(vshControl *ctl, const vshCmd *cmd)
goto
cleanup
;
}
/* get persistent or live description of network device */
desc
=
virDomainGetXMLDesc
(
dom
,
config
?
VIR_DOMAIN_XML_INACTIVE
:
0
);
if
(
desc
==
NULL
)
{
vshError
(
ctl
,
_
(
"Failed to get domain description xml"
));
goto
cleanup
;
}
if
(
config
)
if
(
config
)
{
flags
=
VIR_DOMAIN_AFFECT_CONFIG
;
else
xmlflags
|=
VIR_DOMAIN_XML_INACTIVE
;
}
else
{
flags
=
VIR_DOMAIN_AFFECT_LIVE
;
}
if
(
virDomainIsActive
(
dom
)
==
0
)
flags
=
VIR_DOMAIN_AFFECT_CONFIG
;
/* extract current network device description */
xml
=
virXMLParseStringCtxt
(
desc
,
_
(
"(domain_definition)"
),
&
ctxt
);
VIR_FREE
(
desc
);
if
(
!
xml
)
{
vshError
(
ctl
,
_
(
"Failed to parse domain description xml"
));
if
(
virshDomainGetXMLFromDom
(
ctl
,
dom
,
xmlflags
,
&
xml
,
&
ctxt
)
<
0
)
goto
cleanup
;
}
obj
=
xmlXPathEval
(
BAD_CAST
"/domain/devices/interface"
,
ctxt
);
if
(
obj
==
NULL
||
obj
->
type
!=
XPATH_NODESET
||
...
...
@@ -3575,7 +3565,6 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
int
nvol_list
=
0
;
virshUndefineVolume
*
vols
=
NULL
;
/* info about the volumes to delete*/
size_t
nvols
=
0
;
char
*
def
=
NULL
;
/* domain def */
xmlDocPtr
doc
=
NULL
;
xmlXPathContextPtr
ctxt
=
NULL
;
xmlNodePtr
*
vol_nodes
=
NULL
;
/* XML nodes of volumes of the guest */
...
...
@@ -3685,14 +3674,8 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
goto
cleanup
;
}
if
(
!
(
def
=
virDomainGetXMLDesc
(
dom
,
0
)))
{
vshError
(
ctl
,
_
(
"Could not retrieve domain XML description"
));
if
(
virshDomainGetXMLFromDom
(
ctl
,
dom
,
0
,
&
doc
,
&
ctxt
)
<
0
)
goto
cleanup
;
}
if
(
!
(
doc
=
virXMLParseStringCtxt
(
def
,
_
(
"(domain_definition)"
),
&
ctxt
)))
goto
error
;
/* tokenize the string from user and save its parts into an array */
if
(
vol_string
&&
...
...
@@ -3897,7 +3880,6 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd)
VIR_FREE
(
vol_list
[
i
]);
VIR_FREE
(
vol_list
);
VIR_FREE
(
def
);
VIR_FREE
(
vol_nodes
);
xmlFreeDoc
(
doc
);
xmlXPathFreeContext
(
ctxt
);
...
...
@@ -6029,7 +6011,6 @@ virshCPUCountCollect(vshControl *ctl,
int
ret
=
-
2
;
virDomainInfo
info
;
int
count
;
char
*
def
=
NULL
;
xmlDocPtr
xml
=
NULL
;
xmlXPathContextPtr
ctxt
=
NULL
;
...
...
@@ -6071,10 +6052,8 @@ virshCPUCountCollect(vshControl *ctl,
count
=
info
.
nrVirtCpu
;
}
}
else
{
if
(
!
(
def
=
virDomainGetXMLDesc
(
dom
,
VIR_DOMAIN_XML_INACTIVE
)))
goto
cleanup
;
if
(
!
(
xml
=
virXMLParseStringCtxt
(
def
,
_
(
"(domain_definition)"
),
&
ctxt
)))
if
(
virshDomainGetXMLFromDom
(
ctl
,
dom
,
VIR_DOMAIN_XML_INACTIVE
,
&
xml
,
&
ctxt
)
<
0
)
goto
cleanup
;
if
(
flags
&
VIR_DOMAIN_VCPU_MAXIMUM
)
{
...
...
@@ -6092,7 +6071,6 @@ virshCPUCountCollect(vshControl *ctl,
ret
=
count
;
cleanup:
VIR_FREE
(
def
);
xmlXPathFreeContext
(
ctxt
);
xmlFreeDoc
(
xml
);
...
...
@@ -6237,7 +6215,6 @@ virshDomainGetVcpuBitmap(vshControl *ctl,
bool
inactive
)
{
unsigned
int
flags
=
0
;
char
*
def
=
NULL
;
virBitmapPtr
ret
=
NULL
;
xmlDocPtr
xml
=
NULL
;
xmlXPathContextPtr
ctxt
=
NULL
;
...
...
@@ -6253,10 +6230,7 @@ virshDomainGetVcpuBitmap(vshControl *ctl,
if
(
inactive
)
flags
|=
VIR_DOMAIN_XML_INACTIVE
;
if
(
!
(
def
=
virDomainGetXMLDesc
(
dom
,
flags
)))
goto
cleanup
;
if
(
!
(
xml
=
virXMLParseStringCtxt
(
def
,
_
(
"(domain_definition)"
),
&
ctxt
)))
if
(
virshDomainGetXMLFromDom
(
ctl
,
dom
,
flags
,
&
xml
,
&
ctxt
)
<
0
)
goto
cleanup
;
if
(
virXPathUInt
(
"string(/domain/vcpu)"
,
ctxt
,
&
maxvcpus
)
<
0
)
{
...
...
@@ -6308,7 +6282,6 @@ virshDomainGetVcpuBitmap(vshControl *ctl,
VIR_FREE
(
nodes
);
xmlXPathFreeContext
(
ctxt
);
xmlFreeDoc
(
xml
);
VIR_FREE
(
def
);
return
ret
;
}
...
...
@@ -10902,7 +10875,6 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
virDomainPtr
dom
;
virBuffer
buf
=
VIR_BUFFER_INITIALIZER
;
bool
ret
=
false
;
char
*
doc
=
NULL
;
char
*
xpath
=
NULL
;
char
*
listen_addr
=
NULL
;
int
port
,
tls_port
=
0
;
...
...
@@ -10932,10 +10904,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
if
(
vshCommandOptStringReq
(
ctl
,
cmd
,
"type"
,
&
type
)
<
0
)
goto
cleanup
;
if
(
!
(
doc
=
virDomainGetXMLDesc
(
dom
,
flags
)))
goto
cleanup
;
if
(
!
(
xml
=
virXMLParseStringCtxt
(
doc
,
_
(
"(domain_definition)"
),
&
ctxt
)))
if
(
virshDomainGetXMLFromDom
(
ctl
,
dom
,
flags
,
&
xml
,
&
ctxt
)
<
0
)
goto
cleanup
;
/* Attempt to grab our display info */
...
...
@@ -11108,14 +11077,12 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
}
cleanup:
VIR_FREE
(
doc
);
VIR_FREE
(
xpath
);
VIR_FREE
(
passwd
);
VIR_FREE
(
listen_addr
);
VIR_FREE
(
output
);
xmlXPathFreeContext
(
ctxt
);
xmlFreeDoc
(
xml
);
virshDomainFree
(
dom
);
return
ret
;
}
...
...
@@ -11145,7 +11112,6 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd)
virDomainPtr
dom
;
bool
ret
=
false
;
int
port
=
0
;
char
*
doc
=
NULL
;
char
*
listen_addr
=
NULL
;
if
(
!
(
dom
=
virshCommandOptDomain
(
ctl
,
cmd
,
NULL
)))
...
...
@@ -11157,10 +11123,7 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd)
goto
cleanup
;
}
if
(
!
(
doc
=
virDomainGetXMLDesc
(
dom
,
0
)))
goto
cleanup
;
if
(
!
(
xml
=
virXMLParseStringCtxt
(
doc
,
_
(
"(domain_definition)"
),
&
ctxt
)))
if
(
virshDomainGetXMLFromDom
(
ctl
,
dom
,
0
,
&
xml
,
&
ctxt
)
<
0
)
goto
cleanup
;
/* Get the VNC port */
...
...
@@ -11192,7 +11155,6 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd)
ret
=
true
;
cleanup:
VIR_FREE
(
doc
);
VIR_FREE
(
listen_addr
);
xmlXPathFreeContext
(
ctxt
);
xmlFreeDoc
(
xml
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录