Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
5f845437
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,发现更多精彩内容 >>
提交
5f845437
编写于
3月 06, 2014
作者:
L
Laine Stump
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
conf: eliminate hardcoded indent in volume/pool xml
Again completely mechanical, but a lot of lines.
上级
f728155f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
105 addition
and
75 deletion
+105
-75
src/conf/storage_conf.c
src/conf/storage_conf.c
+101
-73
src/conf/storage_encryption_conf.c
src/conf/storage_encryption_conf.c
+4
-2
未找到文件。
src/conf/storage_conf.c
浏览文件 @
5f845437
/*
/*
* storage_conf.c: config handling for storage driver
* storage_conf.c: config handling for storage driver
*
*
* Copyright (C) 2006-201
3
Red Hat, Inc.
* Copyright (C) 2006-201
4
Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange
* Copyright (C) 2006-2008 Daniel P. Berrange
*
*
* This library is free software; you can redistribute it and/or
* This library is free software; you can redistribute it and/or
...
@@ -1068,10 +1068,12 @@ virStoragePoolSourceFormat(virBufferPtr buf,
...
@@ -1068,10 +1068,12 @@ virStoragePoolSourceFormat(virBufferPtr buf,
size_t
i
,
j
;
size_t
i
,
j
;
char
uuid
[
VIR_UUID_STRING_BUFLEN
];
char
uuid
[
VIR_UUID_STRING_BUFLEN
];
virBufferAddLit
(
buf
,
" <source>
\n
"
);
virBufferAddLit
(
buf
,
"<source>
\n
"
);
virBufferAdjustIndent
(
buf
,
2
);
if
((
options
->
flags
&
VIR_STORAGE_POOL_SOURCE_HOST
)
&&
src
->
nhost
)
{
if
((
options
->
flags
&
VIR_STORAGE_POOL_SOURCE_HOST
)
&&
src
->
nhost
)
{
for
(
i
=
0
;
i
<
src
->
nhost
;
i
++
)
{
for
(
i
=
0
;
i
<
src
->
nhost
;
i
++
)
{
virBufferEscapeString
(
buf
,
"
<host name='%s'"
,
virBufferEscapeString
(
buf
,
"<host name='%s'"
,
src
->
hosts
[
i
].
name
);
src
->
hosts
[
i
].
name
);
if
(
src
->
hosts
[
i
].
port
)
if
(
src
->
hosts
[
i
].
port
)
virBufferAsprintf
(
buf
,
" port='%d'"
,
src
->
hosts
[
i
].
port
);
virBufferAsprintf
(
buf
,
" port='%d'"
,
src
->
hosts
[
i
].
port
);
...
@@ -1083,28 +1085,30 @@ virStoragePoolSourceFormat(virBufferPtr buf,
...
@@ -1083,28 +1085,30 @@ virStoragePoolSourceFormat(virBufferPtr buf,
src
->
ndevice
)
{
src
->
ndevice
)
{
for
(
i
=
0
;
i
<
src
->
ndevice
;
i
++
)
{
for
(
i
=
0
;
i
<
src
->
ndevice
;
i
++
)
{
if
(
src
->
devices
[
i
].
nfreeExtent
)
{
if
(
src
->
devices
[
i
].
nfreeExtent
)
{
virBufferEscapeString
(
buf
,
"
<device path='%s'>
\n
"
,
virBufferEscapeString
(
buf
,
"<device path='%s'>
\n
"
,
src
->
devices
[
i
].
path
);
src
->
devices
[
i
].
path
);
virBufferAdjustIndent
(
buf
,
2
);
for
(
j
=
0
;
j
<
src
->
devices
[
i
].
nfreeExtent
;
j
++
)
{
for
(
j
=
0
;
j
<
src
->
devices
[
i
].
nfreeExtent
;
j
++
)
{
virBufferAsprintf
(
buf
,
"
<freeExtent start='%llu' end='%llu'/>
\n
"
,
virBufferAsprintf
(
buf
,
"<freeExtent start='%llu' end='%llu'/>
\n
"
,
src
->
devices
[
i
].
freeExtents
[
j
].
start
,
src
->
devices
[
i
].
freeExtents
[
j
].
start
,
src
->
devices
[
i
].
freeExtents
[
j
].
end
);
src
->
devices
[
i
].
freeExtents
[
j
].
end
);
}
}
virBufferAddLit
(
buf
,
" </device>
\n
"
);
virBufferAdjustIndent
(
buf
,
-
2
);
virBufferAddLit
(
buf
,
"</device>
\n
"
);
}
else
{
}
else
{
virBufferEscapeString
(
buf
,
"
<device path='%s'/>
\n
"
,
virBufferEscapeString
(
buf
,
"<device path='%s'/>
\n
"
,
src
->
devices
[
i
].
path
);
src
->
devices
[
i
].
path
);
}
}
}
}
}
}
if
(
options
->
flags
&
VIR_STORAGE_POOL_SOURCE_DIR
)
if
(
options
->
flags
&
VIR_STORAGE_POOL_SOURCE_DIR
)
virBufferEscapeString
(
buf
,
"
<dir path='%s'/>
\n
"
,
src
->
dir
);
virBufferEscapeString
(
buf
,
"<dir path='%s'/>
\n
"
,
src
->
dir
);
if
((
options
->
flags
&
VIR_STORAGE_POOL_SOURCE_ADAPTER
))
{
if
((
options
->
flags
&
VIR_STORAGE_POOL_SOURCE_ADAPTER
))
{
if
(
src
->
adapter
.
type
==
VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST
||
if
(
src
->
adapter
.
type
==
VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST
||
src
->
adapter
.
type
==
VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST
)
src
->
adapter
.
type
==
VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_SCSI_HOST
)
virBufferAsprintf
(
buf
,
"
<adapter type='%s'"
,
virBufferAsprintf
(
buf
,
"<adapter type='%s'"
,
virStoragePoolSourceAdapterTypeTypeToString
(
src
->
adapter
.
type
));
virStoragePoolSourceAdapterTypeTypeToString
(
src
->
adapter
.
type
));
if
(
src
->
adapter
.
type
==
VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST
)
{
if
(
src
->
adapter
.
type
==
VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_FC_HOST
)
{
...
@@ -1120,14 +1124,16 @@ virStoragePoolSourceFormat(virBufferPtr buf,
...
@@ -1120,14 +1124,16 @@ virStoragePoolSourceFormat(virBufferPtr buf,
}
}
if
(
options
->
flags
&
VIR_STORAGE_POOL_SOURCE_NAME
)
if
(
options
->
flags
&
VIR_STORAGE_POOL_SOURCE_NAME
)
virBufferEscapeString
(
buf
,
"
<name>%s</name>
\n
"
,
src
->
name
);
virBufferEscapeString
(
buf
,
"<name>%s</name>
\n
"
,
src
->
name
);
if
((
options
->
flags
&
VIR_STORAGE_POOL_SOURCE_INITIATOR_IQN
)
&&
if
((
options
->
flags
&
VIR_STORAGE_POOL_SOURCE_INITIATOR_IQN
)
&&
src
->
initiator
.
iqn
)
{
src
->
initiator
.
iqn
)
{
virBufferAddLit
(
buf
,
" <initiator>
\n
"
);
virBufferAddLit
(
buf
,
"<initiator>
\n
"
);
virBufferEscapeString
(
buf
,
" <iqn name='%s'/>
\n
"
,
virBufferAdjustIndent
(
buf
,
2
);
virBufferEscapeString
(
buf
,
"<iqn name='%s'/>
\n
"
,
src
->
initiator
.
iqn
);
src
->
initiator
.
iqn
);
virBufferAddLit
(
buf
,
" </initiator>
\n
"
);
virBufferAdjustIndent
(
buf
,
-
2
);
virBufferAddLit
(
buf
,
"</initiator>
\n
"
);
}
}
if
(
options
->
formatToString
)
{
if
(
options
->
formatToString
)
{
...
@@ -1138,19 +1144,20 @@ virStoragePoolSourceFormat(virBufferPtr buf,
...
@@ -1138,19 +1144,20 @@ virStoragePoolSourceFormat(virBufferPtr buf,
src
->
format
);
src
->
format
);
return
-
1
;
return
-
1
;
}
}
virBufferAsprintf
(
buf
,
"
<format type='%s'/>
\n
"
,
format
);
virBufferAsprintf
(
buf
,
"<format type='%s'/>
\n
"
,
format
);
}
}
if
(
src
->
authType
==
VIR_STORAGE_POOL_AUTH_CHAP
||
if
(
src
->
authType
==
VIR_STORAGE_POOL_AUTH_CHAP
||
src
->
authType
==
VIR_STORAGE_POOL_AUTH_CEPHX
)
{
src
->
authType
==
VIR_STORAGE_POOL_AUTH_CEPHX
)
{
virBufferAsprintf
(
buf
,
"
<auth type='%s' "
,
virBufferAsprintf
(
buf
,
"<auth type='%s' "
,
virStoragePoolAuthTypeTypeToString
(
src
->
authType
));
virStoragePoolAuthTypeTypeToString
(
src
->
authType
));
virBufferEscapeString
(
buf
,
"username='%s'>
\n
"
,
virBufferEscapeString
(
buf
,
"username='%s'>
\n
"
,
(
src
->
authType
==
VIR_STORAGE_POOL_AUTH_CHAP
?
(
src
->
authType
==
VIR_STORAGE_POOL_AUTH_CHAP
?
src
->
auth
.
chap
.
username
:
src
->
auth
.
chap
.
username
:
src
->
auth
.
cephx
.
username
));
src
->
auth
.
cephx
.
username
));
virBufferAdjustIndent
(
buf
,
2
);
virBufferAddLit
(
buf
,
"
<secret"
);
virBufferAddLit
(
buf
,
"<secret"
);
if
(
src
->
auth
.
cephx
.
secret
.
uuidUsable
)
{
if
(
src
->
auth
.
cephx
.
secret
.
uuidUsable
)
{
virUUIDFormat
(
src
->
auth
.
cephx
.
secret
.
uuid
,
uuid
);
virUUIDFormat
(
src
->
auth
.
cephx
.
secret
.
uuid
,
uuid
);
virBufferAsprintf
(
buf
,
" uuid='%s'"
,
uuid
);
virBufferAsprintf
(
buf
,
" uuid='%s'"
,
uuid
);
...
@@ -1161,14 +1168,15 @@ virStoragePoolSourceFormat(virBufferPtr buf,
...
@@ -1161,14 +1168,15 @@ virStoragePoolSourceFormat(virBufferPtr buf,
}
}
virBufferAddLit
(
buf
,
"/>
\n
"
);
virBufferAddLit
(
buf
,
"/>
\n
"
);
virBufferAddLit
(
buf
,
" </auth>
\n
"
);
virBufferAdjustIndent
(
buf
,
-
2
);
virBufferAddLit
(
buf
,
"</auth>
\n
"
);
}
}
virBufferEscapeString
(
buf
,
" <vendor name='%s'/>
\n
"
,
src
->
vendor
);
virBufferEscapeString
(
buf
,
"<vendor name='%s'/>
\n
"
,
src
->
vendor
);
virBufferEscapeString
(
buf
,
" <product name='%s'/>
\n
"
,
src
->
product
);
virBufferEscapeString
(
buf
,
"<product name='%s'/>
\n
"
,
src
->
product
);
virBufferAddLit
(
buf
,
" </source>
\n
"
);
virBufferAdjustIndent
(
buf
,
-
2
);
virBufferAddLit
(
buf
,
"</source>
\n
"
);
return
0
;
return
0
;
}
}
...
@@ -1192,16 +1200,17 @@ virStoragePoolDefFormat(virStoragePoolDefPtr def)
...
@@ -1192,16 +1200,17 @@ virStoragePoolDefFormat(virStoragePoolDefPtr def)
goto
cleanup
;
goto
cleanup
;
}
}
virBufferAsprintf
(
&
buf
,
"<pool type='%s'>
\n
"
,
type
);
virBufferAsprintf
(
&
buf
,
"<pool type='%s'>
\n
"
,
type
);
virBufferEscapeString
(
&
buf
,
" <name>%s</name>
\n
"
,
def
->
name
);
virBufferAdjustIndent
(
&
buf
,
2
);
virBufferEscapeString
(
&
buf
,
"<name>%s</name>
\n
"
,
def
->
name
);
virUUIDFormat
(
def
->
uuid
,
uuid
);
virUUIDFormat
(
def
->
uuid
,
uuid
);
virBufferAsprintf
(
&
buf
,
"
<uuid>%s</uuid>
\n
"
,
uuid
);
virBufferAsprintf
(
&
buf
,
"<uuid>%s</uuid>
\n
"
,
uuid
);
virBufferAsprintf
(
&
buf
,
"
<capacity unit='bytes'>%llu</capacity>
\n
"
,
virBufferAsprintf
(
&
buf
,
"<capacity unit='bytes'>%llu</capacity>
\n
"
,
def
->
capacity
);
def
->
capacity
);
virBufferAsprintf
(
&
buf
,
"
<allocation unit='bytes'>%llu</allocation>
\n
"
,
virBufferAsprintf
(
&
buf
,
"<allocation unit='bytes'>%llu</allocation>
\n
"
,
def
->
allocation
);
def
->
allocation
);
virBufferAsprintf
(
&
buf
,
"
<available unit='bytes'>%llu</available>
\n
"
,
virBufferAsprintf
(
&
buf
,
"<available unit='bytes'>%llu</available>
\n
"
,
def
->
available
);
def
->
available
);
if
(
virStoragePoolSourceFormat
(
&
buf
,
options
,
&
def
->
source
)
<
0
)
if
(
virStoragePoolSourceFormat
(
&
buf
,
options
,
&
def
->
source
)
<
0
)
...
@@ -1212,24 +1221,29 @@ virStoragePoolDefFormat(virStoragePoolDefPtr def)
...
@@ -1212,24 +1221,29 @@ virStoragePoolDefFormat(virStoragePoolDefPtr def)
if
(
def
->
type
!=
VIR_STORAGE_POOL_RBD
&&
if
(
def
->
type
!=
VIR_STORAGE_POOL_RBD
&&
def
->
type
!=
VIR_STORAGE_POOL_SHEEPDOG
&&
def
->
type
!=
VIR_STORAGE_POOL_SHEEPDOG
&&
def
->
type
!=
VIR_STORAGE_POOL_GLUSTER
)
{
def
->
type
!=
VIR_STORAGE_POOL_GLUSTER
)
{
virBufferAddLit
(
&
buf
,
" <target>
\n
"
);
virBufferAddLit
(
&
buf
,
"<target>
\n
"
);
virBufferAdjustIndent
(
&
buf
,
2
);
virBufferEscapeString
(
&
buf
,
"
<path>%s</path>
\n
"
,
def
->
target
.
path
);
virBufferEscapeString
(
&
buf
,
"<path>%s</path>
\n
"
,
def
->
target
.
path
);
virBufferAddLit
(
&
buf
,
" <permissions>
\n
"
);
virBufferAddLit
(
&
buf
,
"<permissions>
\n
"
);
virBufferAsprintf
(
&
buf
,
" <mode>0%o</mode>
\n
"
,
virBufferAdjustIndent
(
&
buf
,
2
);
virBufferAsprintf
(
&
buf
,
"<mode>0%o</mode>
\n
"
,
def
->
target
.
perms
.
mode
);
def
->
target
.
perms
.
mode
);
virBufferAsprintf
(
&
buf
,
"
<owner>%d</owner>
\n
"
,
virBufferAsprintf
(
&
buf
,
"<owner>%d</owner>
\n
"
,
(
int
)
def
->
target
.
perms
.
uid
);
(
int
)
def
->
target
.
perms
.
uid
);
virBufferAsprintf
(
&
buf
,
"
<group>%d</group>
\n
"
,
virBufferAsprintf
(
&
buf
,
"<group>%d</group>
\n
"
,
(
int
)
def
->
target
.
perms
.
gid
);
(
int
)
def
->
target
.
perms
.
gid
);
virBufferEscapeString
(
&
buf
,
"
<label>%s</label>
\n
"
,
virBufferEscapeString
(
&
buf
,
"<label>%s</label>
\n
"
,
def
->
target
.
perms
.
label
);
def
->
target
.
perms
.
label
);
virBufferAddLit
(
&
buf
,
" </permissions>
\n
"
);
virBufferAdjustIndent
(
&
buf
,
-
2
);
virBufferAddLit
(
&
buf
,
" </target>
\n
"
);
virBufferAddLit
(
&
buf
,
"</permissions>
\n
"
);
virBufferAdjustIndent
(
&
buf
,
-
2
);
virBufferAddLit
(
&
buf
,
"</target>
\n
"
);
}
}
virBufferAdjustIndent
(
&
buf
,
-
2
);
virBufferAddLit
(
&
buf
,
"</pool>
\n
"
);
virBufferAddLit
(
&
buf
,
"</pool>
\n
"
);
if
(
virBufferError
(
&
buf
))
if
(
virBufferError
(
&
buf
))
...
@@ -1495,7 +1509,7 @@ virStorageVolTimestampFormat(virBufferPtr buf, const char *name,
...
@@ -1495,7 +1509,7 @@ virStorageVolTimestampFormat(virBufferPtr buf, const char *name,
{
{
if
(
ts
->
tv_nsec
<
0
)
if
(
ts
->
tv_nsec
<
0
)
return
;
return
;
virBufferAsprintf
(
buf
,
"
<%s>%llu"
,
name
,
virBufferAsprintf
(
buf
,
"<%s>%llu"
,
name
,
(
unsigned
long
long
)
ts
->
tv_sec
);
(
unsigned
long
long
)
ts
->
tv_sec
);
if
(
ts
->
tv_nsec
)
if
(
ts
->
tv_nsec
)
virBufferAsprintf
(
buf
,
".%09ld"
,
ts
->
tv_nsec
);
virBufferAsprintf
(
buf
,
".%09ld"
,
ts
->
tv_nsec
);
...
@@ -1508,9 +1522,10 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
...
@@ -1508,9 +1522,10 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
virStorageVolTargetPtr
def
,
virStorageVolTargetPtr
def
,
const
char
*
type
)
const
char
*
type
)
{
{
virBufferAsprintf
(
buf
,
" <%s>
\n
"
,
type
);
virBufferAsprintf
(
buf
,
"<%s>
\n
"
,
type
);
virBufferAdjustIndent
(
buf
,
2
);
virBufferEscapeString
(
buf
,
"
<path>%s</path>
\n
"
,
def
->
path
);
virBufferEscapeString
(
buf
,
"<path>%s</path>
\n
"
,
def
->
path
);
if
(
options
->
formatToString
)
{
if
(
options
->
formatToString
)
{
const
char
*
format
=
(
options
->
formatToString
)(
def
->
format
);
const
char
*
format
=
(
options
->
formatToString
)(
def
->
format
);
...
@@ -1520,63 +1535,69 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
...
@@ -1520,63 +1535,69 @@ virStorageVolTargetDefFormat(virStorageVolOptionsPtr options,
def
->
format
);
def
->
format
);
return
-
1
;
return
-
1
;
}
}
virBufferAsprintf
(
buf
,
"
<format type='%s'/>
\n
"
,
format
);
virBufferAsprintf
(
buf
,
"<format type='%s'/>
\n
"
,
format
);
}
}
virBufferAddLit
(
buf
,
" <permissions>
\n
"
);
virBufferAddLit
(
buf
,
"<permissions>
\n
"
);
virBufferAsprintf
(
buf
,
" <mode>0%o</mode>
\n
"
,
virBufferAdjustIndent
(
buf
,
2
);
virBufferAsprintf
(
buf
,
"<mode>0%o</mode>
\n
"
,
def
->
perms
.
mode
);
def
->
perms
.
mode
);
virBufferAsprintf
(
buf
,
"
<owner>%u</owner>
\n
"
,
virBufferAsprintf
(
buf
,
"<owner>%u</owner>
\n
"
,
(
unsigned
int
)
def
->
perms
.
uid
);
(
unsigned
int
)
def
->
perms
.
uid
);
virBufferAsprintf
(
buf
,
"
<group>%u</group>
\n
"
,
virBufferAsprintf
(
buf
,
"<group>%u</group>
\n
"
,
(
unsigned
int
)
def
->
perms
.
gid
);
(
unsigned
int
)
def
->
perms
.
gid
);
virBufferEscapeString
(
buf
,
"
<label>%s</label>
\n
"
,
virBufferEscapeString
(
buf
,
"<label>%s</label>
\n
"
,
def
->
perms
.
label
);
def
->
perms
.
label
);
virBufferAddLit
(
buf
,
" </permissions>
\n
"
);
virBufferAdjustIndent
(
buf
,
-
2
);
virBufferAddLit
(
buf
,
"</permissions>
\n
"
);
if
(
def
->
timestamps
)
{
if
(
def
->
timestamps
)
{
virBufferAddLit
(
buf
,
" <timestamps>
\n
"
);
virBufferAddLit
(
buf
,
"<timestamps>
\n
"
);
virBufferAdjustIndent
(
buf
,
2
);
virStorageVolTimestampFormat
(
buf
,
"atime"
,
&
def
->
timestamps
->
atime
);
virStorageVolTimestampFormat
(
buf
,
"atime"
,
&
def
->
timestamps
->
atime
);
virStorageVolTimestampFormat
(
buf
,
"mtime"
,
&
def
->
timestamps
->
mtime
);
virStorageVolTimestampFormat
(
buf
,
"mtime"
,
&
def
->
timestamps
->
mtime
);
virStorageVolTimestampFormat
(
buf
,
"ctime"
,
&
def
->
timestamps
->
ctime
);
virStorageVolTimestampFormat
(
buf
,
"ctime"
,
&
def
->
timestamps
->
ctime
);
virStorageVolTimestampFormat
(
buf
,
"btime"
,
&
def
->
timestamps
->
btime
);
virStorageVolTimestampFormat
(
buf
,
"btime"
,
&
def
->
timestamps
->
btime
);
virBufferAddLit
(
buf
,
" </timestamps>
\n
"
);
virBufferAdjustIndent
(
buf
,
-
2
);
virBufferAddLit
(
buf
,
"</timestamps>
\n
"
);
}
}
if
(
def
->
encryption
)
{
if
(
def
->
encryption
&&
virBufferAdjustIndent
(
buf
,
4
);
virStorageEncryptionFormat
(
buf
,
def
->
encryption
)
<
0
)
if
(
virStorageEncryptionFormat
(
buf
,
def
->
encryption
)
<
0
)
return
-
1
;
return
-
1
;
virBufferAdjustIndent
(
buf
,
-
4
);
}
virBufferEscapeString
(
buf
,
"
<compat>%s</compat>
\n
"
,
def
->
compat
);
virBufferEscapeString
(
buf
,
"<compat>%s</compat>
\n
"
,
def
->
compat
);
if
(
options
->
featureToString
&&
def
->
features
)
{
if
(
options
->
featureToString
&&
def
->
features
)
{
size_t
i
;
size_t
i
;
bool
b
;
bool
b
;
bool
empty
=
virBitmapIsAllClear
(
def
->
features
);
bool
empty
=
virBitmapIsAllClear
(
def
->
features
);
if
(
empty
)
if
(
empty
)
{
virBufferAddLit
(
buf
,
" <features/>
\n
"
);
virBufferAddLit
(
buf
,
"<features/>
\n
"
);
else
}
else
{
virBufferAddLit
(
buf
,
" <features>
\n
"
);
virBufferAddLit
(
buf
,
"<features>
\n
"
);
virBufferAdjustIndent
(
buf
,
2
);
}
for
(
i
=
0
;
i
<
VIR_STORAGE_FILE_FEATURE_LAST
;
i
++
)
{
for
(
i
=
0
;
i
<
VIR_STORAGE_FILE_FEATURE_LAST
;
i
++
)
{
ignore_value
(
virBitmapGetBit
(
def
->
features
,
i
,
&
b
));
ignore_value
(
virBitmapGetBit
(
def
->
features
,
i
,
&
b
));
if
(
b
)
if
(
b
)
virBufferAsprintf
(
buf
,
"
<%s/>
\n
"
,
virBufferAsprintf
(
buf
,
"<%s/>
\n
"
,
options
->
featureToString
(
i
));
options
->
featureToString
(
i
));
}
}
if
(
!
empty
)
if
(
!
empty
)
{
virBufferAddLit
(
buf
,
" </features>
\n
"
);
virBufferAdjustIndent
(
buf
,
-
2
);
virBufferAddLit
(
buf
,
"</features>
\n
"
);
}
}
}
virBufferA
sprintf
(
buf
,
" </%s>
\n
"
,
type
);
virBufferA
djustIndent
(
buf
,
-
2
);
virBufferAsprintf
(
buf
,
"</%s>
\n
"
,
type
);
return
0
;
return
0
;
}
}
...
@@ -1593,9 +1614,12 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
...
@@ -1593,9 +1614,12 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
virBufferAsprintf
(
&
buf
,
"<volume type='%s'>
\n
"
,
virBufferAsprintf
(
&
buf
,
"<volume type='%s'>
\n
"
,
virStorageVolTypeToString
(
def
->
type
));
virStorageVolTypeToString
(
def
->
type
));
virBufferEscapeString
(
&
buf
,
" <name>%s</name>
\n
"
,
def
->
name
);
virBufferAdjustIndent
(
&
buf
,
2
);
virBufferEscapeString
(
&
buf
,
" <key>%s</key>
\n
"
,
def
->
key
);
virBufferAddLit
(
&
buf
,
" <source>
\n
"
);
virBufferEscapeString
(
&
buf
,
"<name>%s</name>
\n
"
,
def
->
name
);
virBufferEscapeString
(
&
buf
,
"<key>%s</key>
\n
"
,
def
->
key
);
virBufferAddLit
(
&
buf
,
"<source>
\n
"
);
virBufferAdjustIndent
(
&
buf
,
2
);
if
(
def
->
source
.
nextent
)
{
if
(
def
->
source
.
nextent
)
{
size_t
i
;
size_t
i
;
...
@@ -1604,26 +1628,29 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
...
@@ -1604,26 +1628,29 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
if
(
thispath
==
NULL
||
if
(
thispath
==
NULL
||
STRNEQ
(
thispath
,
def
->
source
.
extents
[
i
].
path
))
{
STRNEQ
(
thispath
,
def
->
source
.
extents
[
i
].
path
))
{
if
(
thispath
!=
NULL
)
if
(
thispath
!=
NULL
)
virBufferAddLit
(
&
buf
,
"
</device>
\n
"
);
virBufferAddLit
(
&
buf
,
"</device>
\n
"
);
virBufferEscapeString
(
&
buf
,
"
<device path='%s'>
\n
"
,
virBufferEscapeString
(
&
buf
,
"<device path='%s'>
\n
"
,
def
->
source
.
extents
[
i
].
path
);
def
->
source
.
extents
[
i
].
path
);
}
}
virBufferA
sprintf
(
&
buf
,
virBufferA
djustIndent
(
&
buf
,
2
);
"
<extent start='%llu' end='%llu'/>
\n
"
,
virBufferAsprintf
(
&
buf
,
"
<extent start='%llu' end='%llu'/>
\n
"
,
def
->
source
.
extents
[
i
].
start
,
def
->
source
.
extents
[
i
].
start
,
def
->
source
.
extents
[
i
].
end
);
def
->
source
.
extents
[
i
].
end
);
virBufferAdjustIndent
(
&
buf
,
-
2
);
thispath
=
def
->
source
.
extents
[
i
].
path
;
thispath
=
def
->
source
.
extents
[
i
].
path
;
}
}
if
(
thispath
!=
NULL
)
if
(
thispath
!=
NULL
)
virBufferAddLit
(
&
buf
,
"
</device>
\n
"
);
virBufferAddLit
(
&
buf
,
"</device>
\n
"
);
}
}
virBufferAddLit
(
&
buf
,
" </source>
\n
"
);
virBufferAsprintf
(
&
buf
,
" <capacity unit='bytes'>%llu</capacity>
\n
"
,
virBufferAdjustIndent
(
&
buf
,
-
2
);
virBufferAddLit
(
&
buf
,
"</source>
\n
"
);
virBufferAsprintf
(
&
buf
,
"<capacity unit='bytes'>%llu</capacity>
\n
"
,
def
->
capacity
);
def
->
capacity
);
virBufferAsprintf
(
&
buf
,
"
<allocation unit='bytes'>%llu</allocation>
\n
"
,
virBufferAsprintf
(
&
buf
,
"<allocation unit='bytes'>%llu</allocation>
\n
"
,
def
->
allocation
);
def
->
allocation
);
if
(
virStorageVolTargetDefFormat
(
options
,
&
buf
,
if
(
virStorageVolTargetDefFormat
(
options
,
&
buf
,
...
@@ -1635,6 +1662,7 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
...
@@ -1635,6 +1662,7 @@ virStorageVolDefFormat(virStoragePoolDefPtr pool,
&
def
->
backingStore
,
"backingStore"
)
<
0
)
&
def
->
backingStore
,
"backingStore"
)
<
0
)
goto
cleanup
;
goto
cleanup
;
virBufferAdjustIndent
(
&
buf
,
-
2
);
virBufferAddLit
(
&
buf
,
"</volume>
\n
"
);
virBufferAddLit
(
&
buf
,
"</volume>
\n
"
);
if
(
virBufferError
(
&
buf
))
if
(
virBufferError
(
&
buf
))
...
...
src/conf/storage_encryption_conf.c
浏览文件 @
5f845437
/*
/*
* storage_encryption_conf.c: volume encryption information
* storage_encryption_conf.c: volume encryption information
*
*
* Copyright (C) 2009-201
1
Red Hat, Inc.
* Copyright (C) 2009-201
4
Red Hat, Inc.
*
*
* This library is free software; you can redistribute it and/or
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* modify it under the terms of the GNU Lesser General Public
...
@@ -218,7 +218,7 @@ virStorageEncryptionSecretFormat(virBufferPtr buf,
...
@@ -218,7 +218,7 @@ virStorageEncryptionSecretFormat(virBufferPtr buf,
}
}
virUUIDFormat
(
secret
->
uuid
,
uuidstr
);
virUUIDFormat
(
secret
->
uuid
,
uuidstr
);
virBufferAsprintf
(
buf
,
"
<secret type='%s' uuid='%s'/>
\n
"
,
virBufferAsprintf
(
buf
,
"<secret type='%s' uuid='%s'/>
\n
"
,
type
,
uuidstr
);
type
,
uuidstr
);
return
0
;
return
0
;
}
}
...
@@ -237,12 +237,14 @@ virStorageEncryptionFormat(virBufferPtr buf,
...
@@ -237,12 +237,14 @@ virStorageEncryptionFormat(virBufferPtr buf,
return
-
1
;
return
-
1
;
}
}
virBufferAsprintf
(
buf
,
"<encryption format='%s'>
\n
"
,
format
);
virBufferAsprintf
(
buf
,
"<encryption format='%s'>
\n
"
,
format
);
virBufferAdjustIndent
(
buf
,
2
);
for
(
i
=
0
;
i
<
enc
->
nsecrets
;
i
++
)
{
for
(
i
=
0
;
i
<
enc
->
nsecrets
;
i
++
)
{
if
(
virStorageEncryptionSecretFormat
(
buf
,
enc
->
secrets
[
i
])
<
0
)
if
(
virStorageEncryptionSecretFormat
(
buf
,
enc
->
secrets
[
i
])
<
0
)
return
-
1
;
return
-
1
;
}
}
virBufferAdjustIndent
(
buf
,
-
2
);
virBufferAddLit
(
buf
,
"</encryption>
\n
"
);
virBufferAddLit
(
buf
,
"</encryption>
\n
"
);
return
0
;
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录