Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
c0d9dfe2
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看板
提交
c0d9dfe2
编写于
10月 27, 2011
作者:
J
Jiri Denemark
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use virXMLSaveFile when writing XML config
上级
fef8127c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
14 addition
and
176 deletion
+14
-176
src/conf/domain_conf.c
src/conf/domain_conf.c
+2
-30
src/conf/network_conf.c
src/conf/network_conf.c
+2
-32
src/conf/nwfilter_conf.c
src/conf/nwfilter_conf.c
+4
-64
src/conf/storage_conf.c
src/conf/storage_conf.c
+4
-33
src/qemu/qemu_domain.c
src/qemu/qemu_domain.c
+2
-17
未找到文件。
src/conf/domain_conf.c
浏览文件 @
c0d9dfe2
...
...
@@ -11105,8 +11105,7 @@ int virDomainSaveXML(const char *configDir,
const
char
*
xml
)
{
char
*
configFile
=
NULL
;
int
fd
=
-
1
,
ret
=
-
1
;
size_t
towrite
;
int
ret
=
-
1
;
if
((
configFile
=
virDomainConfigFile
(
configDir
,
def
->
name
))
==
NULL
)
goto
cleanup
;
...
...
@@ -11118,36 +11117,9 @@ int virDomainSaveXML(const char *configDir,
goto
cleanup
;
}
if
((
fd
=
open
(
configFile
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
S_IRUSR
|
S_IWUSR
))
<
0
)
{
virReportSystemError
(
errno
,
_
(
"cannot create config file '%s'"
),
configFile
);
goto
cleanup
;
}
virEmitXMLWarning
(
fd
,
def
->
name
,
"edit"
);
towrite
=
strlen
(
xml
);
if
(
safewrite
(
fd
,
xml
,
towrite
)
<
0
)
{
virReportSystemError
(
errno
,
_
(
"cannot write config file '%s'"
),
configFile
);
goto
cleanup
;
}
if
(
VIR_CLOSE
(
fd
)
<
0
)
{
virReportSystemError
(
errno
,
_
(
"cannot save config file '%s'"
),
configFile
);
goto
cleanup
;
}
ret
=
virXMLSaveFile
(
configFile
,
def
->
name
,
"edit"
,
xml
);
ret
=
0
;
cleanup:
VIR_FORCE_CLOSE
(
fd
);
VIR_FREE
(
configFile
);
return
ret
;
}
...
...
src/conf/network_conf.c
浏览文件 @
c0d9dfe2
...
...
@@ -1395,8 +1395,7 @@ int virNetworkSaveXML(const char *configDir,
const
char
*
xml
)
{
char
*
configFile
=
NULL
;
int
fd
=
-
1
,
ret
=
-
1
;
size_t
towrite
;
int
ret
=
-
1
;
if
((
configFile
=
virNetworkConfigFile
(
configDir
,
def
->
name
))
==
NULL
)
goto
cleanup
;
...
...
@@ -1408,39 +1407,10 @@ int virNetworkSaveXML(const char *configDir,
goto
cleanup
;
}
if
((
fd
=
open
(
configFile
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
S_IRUSR
|
S_IWUSR
))
<
0
)
{
virReportSystemError
(
errno
,
_
(
"cannot create config file '%s'"
),
configFile
);
goto
cleanup
;
}
virEmitXMLWarning
(
fd
,
def
->
name
,
"net-edit"
);
towrite
=
strlen
(
xml
);
if
(
safewrite
(
fd
,
xml
,
towrite
)
<
0
)
{
virReportSystemError
(
errno
,
_
(
"cannot write config file '%s'"
),
configFile
);
goto
cleanup
;
}
if
(
VIR_CLOSE
(
fd
)
<
0
)
{
virReportSystemError
(
errno
,
_
(
"cannot save config file '%s'"
),
configFile
);
goto
cleanup
;
}
ret
=
0
;
ret
=
virXMLSaveFile
(
configFile
,
def
->
name
,
"net-edit"
,
xml
);
cleanup:
VIR_FORCE_CLOSE
(
fd
);
VIR_FREE
(
configFile
);
return
ret
;
}
...
...
src/conf/nwfilter_conf.c
浏览文件 @
c0d9dfe2
...
...
@@ -2186,8 +2186,7 @@ int virNWFilterSaveXML(const char *configDir,
const
char
*
xml
)
{
char
*
configFile
=
NULL
;
int
fd
=
-
1
,
ret
=
-
1
;
size_t
towrite
;
int
ret
=
-
1
;
if
((
configFile
=
virNWFilterConfigFile
(
configDir
,
def
->
name
))
==
NULL
)
goto
cleanup
;
...
...
@@ -2199,38 +2198,10 @@ int virNWFilterSaveXML(const char *configDir,
goto
cleanup
;
}
if
((
fd
=
open
(
configFile
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
S_IRUSR
|
S_IWUSR
))
<
0
)
{
virReportSystemError
(
errno
,
_
(
"cannot create config file '%s'"
),
configFile
);
goto
cleanup
;
}
virEmitXMLWarning
(
fd
,
def
->
name
,
"nwfilter-edit"
);
towrite
=
strlen
(
xml
);
if
(
safewrite
(
fd
,
xml
,
towrite
)
<
0
)
{
virReportSystemError
(
errno
,
_
(
"cannot write config file '%s'"
),
configFile
);
goto
cleanup
;
}
if
(
VIR_CLOSE
(
fd
)
<
0
)
{
virReportSystemError
(
errno
,
_
(
"cannot save config file '%s'"
),
configFile
);
goto
cleanup
;
}
ret
=
0
;
ret
=
virXMLSaveFile
(
configFile
,
def
->
name
,
"nwfilter-edit"
,
xml
);
cleanup:
VIR_FORCE_CLOSE
(
fd
);
VIR_FREE
(
configFile
);
return
ret
;
}
...
...
@@ -2573,8 +2544,7 @@ virNWFilterObjSaveDef(virNWFilterDriverStatePtr driver,
virNWFilterDefPtr
def
)
{
char
*
xml
;
int
fd
=
-
1
,
ret
=
-
1
;
ssize_t
towrite
;
int
ret
;
if
(
!
nwfilter
->
configFile
)
{
if
(
virFileMakePath
(
driver
->
configDir
)
<
0
)
{
...
...
@@ -2596,37 +2566,7 @@ virNWFilterObjSaveDef(virNWFilterDriverStatePtr driver,
return
-
1
;
}
if
((
fd
=
open
(
nwfilter
->
configFile
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
S_IRUSR
|
S_IWUSR
))
<
0
)
{
virReportSystemError
(
errno
,
_
(
"cannot create config file %s"
),
nwfilter
->
configFile
);
goto
cleanup
;
}
virEmitXMLWarning
(
fd
,
def
->
name
,
"nwfilter-edit"
);
towrite
=
strlen
(
xml
);
if
(
safewrite
(
fd
,
xml
,
towrite
)
!=
towrite
)
{
virReportSystemError
(
errno
,
_
(
"cannot write config file %s"
),
nwfilter
->
configFile
);
goto
cleanup
;
}
if
(
VIR_CLOSE
(
fd
)
<
0
)
{
virReportSystemError
(
errno
,
_
(
"cannot save config file %s"
),
nwfilter
->
configFile
);
goto
cleanup
;
}
ret
=
0
;
cleanup:
VIR_FORCE_CLOSE
(
fd
);
ret
=
virXMLSaveFile
(
nwfilter
->
configFile
,
def
->
name
,
"nwfilter-edit"
,
xml
);
VIR_FREE
(
xml
);
return
ret
;
...
...
src/conf/storage_conf.c
浏览文件 @
c0d9dfe2
...
...
@@ -1525,10 +1525,10 @@ virStoragePoolLoadAllConfigs(virStoragePoolObjListPtr pools,
int
virStoragePoolObjSaveDef
(
virStorageDriverStatePtr
driver
,
virStoragePoolObjPtr
pool
,
virStoragePoolDefPtr
def
)
{
virStoragePoolDefPtr
def
)
{
char
*
xml
;
int
fd
=
-
1
,
ret
=
-
1
;
ssize_t
towrite
;
int
ret
=
-
1
;
if
(
!
pool
->
configFile
)
{
if
(
virFileMakePath
(
driver
->
configDir
)
<
0
)
{
...
...
@@ -1556,36 +1556,7 @@ virStoragePoolObjSaveDef(virStorageDriverStatePtr driver,
return
-
1
;
}
if
((
fd
=
open
(
pool
->
configFile
,
O_WRONLY
|
O_CREAT
|
O_TRUNC
,
S_IRUSR
|
S_IWUSR
))
<
0
)
{
virReportSystemError
(
errno
,
_
(
"cannot create config file %s"
),
pool
->
configFile
);
goto
cleanup
;
}
virEmitXMLWarning
(
fd
,
def
->
name
,
"pool-edit"
);
towrite
=
strlen
(
xml
);
if
(
safewrite
(
fd
,
xml
,
towrite
)
!=
towrite
)
{
virReportSystemError
(
errno
,
_
(
"cannot write config file %s"
),
pool
->
configFile
);
goto
cleanup
;
}
if
(
VIR_CLOSE
(
fd
)
<
0
)
{
virReportSystemError
(
errno
,
_
(
"cannot save config file %s"
),
pool
->
configFile
);
goto
cleanup
;
}
ret
=
0
;
cleanup:
VIR_FORCE_CLOSE
(
fd
);
ret
=
virXMLSaveFile
(
pool
->
configFile
,
def
->
name
,
"pool-edit"
,
xml
);
VIR_FREE
(
xml
);
return
ret
;
...
...
src/qemu/qemu_domain.c
浏览文件 @
c0d9dfe2
...
...
@@ -1337,7 +1337,6 @@ qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
virDomainSnapshotObjPtr
snapshot
,
char
*
snapshotDir
)
{
int
fd
=
-
1
;
char
*
newxml
=
NULL
;
int
ret
=
-
1
;
char
*
snapDir
=
NULL
;
...
...
@@ -1367,33 +1366,19 @@ qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm,
virReportOOMError
();
goto
cleanup
;
}
fd
=
open
(
snapFile
,
O_CREAT
|
O_TRUNC
|
O_WRONLY
,
S_IRUSR
|
S_IWUSR
);
if
(
fd
<
0
)
{
qemuReportError
(
VIR_ERR_OPERATION_FAILED
,
_
(
"failed to create snapshot file '%s'"
),
snapFile
);
goto
cleanup
;
}
if
(
virAsprintf
(
&
tmp
,
"snapshot-edit %s"
,
vm
->
def
->
name
)
<
0
)
{
virReportOOMError
();
goto
cleanup
;
}
virEmitXMLWarning
(
fd
,
snapshot
->
def
->
name
,
tmp
);
VIR_FREE
(
tmp
);
if
(
safewrite
(
fd
,
newxml
,
strlen
(
newxml
))
!=
strlen
(
newxml
))
{
virReportSystemError
(
errno
,
_
(
"Failed to write snapshot data to %s"
),
snapFile
);
goto
cleanup
;
}
ret
=
0
;
ret
=
virXMLSaveFile
(
snapFile
,
snapshot
->
def
->
name
,
tmp
,
newxml
);
VIR_FREE
(
tmp
);
cleanup:
VIR_FREE
(
snapFile
);
VIR_FREE
(
snapDir
);
VIR_FREE
(
newxml
);
VIR_FORCE_CLOSE
(
fd
);
return
ret
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录