Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
b384e2b4
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,发现更多精彩内容 >>
提交
b384e2b4
编写于
11月 18, 2013
作者:
P
Peter Krempa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
qemu: Unify formatting of RBD sources
上级
d94fd0c9
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
61 addition
and
94 deletion
+61
-94
src/qemu/qemu_command.c
src/qemu/qemu_command.c
+61
-94
未找到文件。
src/qemu/qemu_command.c
浏览文件 @
b384e2b4
...
...
@@ -3253,72 +3253,6 @@ cleanup:
return
secret
;
}
static
int
qemuBuildRBDString
(
virConnectPtr
conn
,
virDomainDiskDefPtr
disk
,
virBufferPtr
opt
)
{
size_t
i
;
int
ret
=
0
;
char
*
secret
=
NULL
;
if
(
strchr
(
disk
->
src
,
':'
))
{
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
_
(
"':' not allowed in RBD source volume name '%s'"
),
disk
->
src
);
return
-
1
;
}
virBufferEscape
(
opt
,
','
,
","
,
"rbd:%s"
,
disk
->
src
);
if
(
disk
->
auth
.
username
)
{
virBufferEscape
(
opt
,
'\\'
,
":"
,
":id=%s"
,
disk
->
auth
.
username
);
/* Get the secret string using the virDomainDiskDef
* NOTE: qemu/librbd wants it base64 encoded
*/
if
(
!
(
secret
=
qemuGetSecretString
(
conn
,
"rbd"
,
true
,
disk
->
auth
.
secretType
,
disk
->
auth
.
username
,
disk
->
auth
.
secret
.
uuid
,
disk
->
auth
.
secret
.
usage
,
VIR_SECRET_USAGE_TYPE_CEPH
)))
goto
error
;
virBufferEscape
(
opt
,
'\\'
,
":"
,
":key=%s:auth_supported=cephx
\\
;none"
,
secret
);
}
else
{
virBufferAddLit
(
opt
,
":auth_supported=none"
);
}
if
(
disk
->
nhosts
>
0
)
{
virBufferAddLit
(
opt
,
":mon_host="
);
for
(
i
=
0
;
i
<
disk
->
nhosts
;
++
i
)
{
if
(
i
)
{
virBufferAddLit
(
opt
,
"
\\
;"
);
}
/* assume host containing : is ipv6 */
if
(
strchr
(
disk
->
hosts
[
i
].
name
,
':'
))
{
virBufferEscape
(
opt
,
'\\'
,
":"
,
"[%s]"
,
disk
->
hosts
[
i
].
name
);
}
else
{
virBufferAsprintf
(
opt
,
"%s"
,
disk
->
hosts
[
i
].
name
);
}
if
(
disk
->
hosts
[
i
].
port
)
{
virBufferAsprintf
(
opt
,
"
\\
:%s"
,
disk
->
hosts
[
i
].
port
);
}
}
}
cleanup:
VIR_FREE
(
secret
);
return
ret
;
error:
ret
=
-
1
;
goto
cleanup
;
}
static
int
qemuAddRBDHost
(
virDomainDiskDefPtr
disk
,
char
*
hostport
)
{
...
...
@@ -3693,6 +3627,7 @@ qemuBuildNetworkDriveURI(int protocol,
char
*
ret
=
NULL
;
virBuffer
buf
=
VIR_BUFFER_INITIALIZER
;
virURIPtr
uri
=
NULL
;
size_t
i
;
switch
((
enum
virDomainDiskProtocol
)
protocol
)
{
case
VIR_DOMAIN_DISK_PROTOCOL_NBD
:
...
...
@@ -3835,10 +3770,51 @@ qemuBuildNetworkDriveURI(int protocol,
break
;
case
VIR_DOMAIN_DISK_PROTOCOL_RBD
:
if
(
strchr
(
src
,
':'
))
{
virReportError
(
VIR_ERR_CONFIG_UNSUPPORTED
,
_
(
"':' not allowed in RBD source volume name '%s'"
),
src
);
goto
cleanup
;
}
virBufferStrcat
(
&
buf
,
"rbd:"
,
src
,
NULL
);
if
(
username
)
{
virBufferEscape
(
&
buf
,
'\\'
,
":"
,
":id=%s"
,
username
);
virBufferEscape
(
&
buf
,
'\\'
,
":"
,
":key=%s:auth_supported=cephx
\\
;none"
,
secret
);
}
else
{
virBufferAddLit
(
&
buf
,
":auth_supported=none"
);
}
if
(
nhosts
>
0
)
{
virBufferAddLit
(
&
buf
,
":mon_host="
);
for
(
i
=
0
;
i
<
nhosts
;
i
++
)
{
if
(
i
)
virBufferAddLit
(
&
buf
,
"
\\
;"
);
/* assume host containing : is ipv6 */
if
(
strchr
(
hosts
[
i
].
name
,
':'
))
virBufferEscape
(
&
buf
,
'\\'
,
":"
,
"[%s]"
,
hosts
[
i
].
name
);
else
virBufferAsprintf
(
&
buf
,
"%s"
,
hosts
[
i
].
name
);
if
(
hosts
[
i
].
port
)
virBufferAsprintf
(
&
buf
,
"
\\
:%s"
,
hosts
[
i
].
port
);
}
}
if
(
virBufferError
(
&
buf
)
<
0
)
{
virReportOOMError
();
goto
cleanup
;
}
ret
=
virBufferContentAndReset
(
&
buf
);
break
;
case
VIR_DOMAIN_DISK_PROTOCOL_LAST
:
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"network disk protocol '%s' not supported"
),
virDomainDiskProtocolTypeToString
(
protocol
));
goto
cleanup
;
}
...
...
@@ -3861,17 +3837,26 @@ qemuBuildDriveURIString(virConnectPtr conn,
virBufferAddLit
(
opt
,
"file="
);
if
(
disk
->
protocol
==
VIR_DOMAIN_DISK_PROTOCOL_ISCSI
&&
if
((
disk
->
protocol
==
VIR_DOMAIN_DISK_PROTOCOL_ISCSI
||
disk
->
protocol
==
VIR_DOMAIN_DISK_PROTOCOL_RBD
)
&&
disk
->
auth
.
username
)
{
/* Get the secret string using the virDomainDiskDef */
bool
encode
=
false
;
int
secretType
=
VIR_SECRET_USAGE_TYPE_ISCSI
;
if
(
disk
->
protocol
==
VIR_DOMAIN_DISK_PROTOCOL_RBD
)
{
/* qemu requires the secret to be encoded for RBD */
encode
=
true
;
secretType
=
VIR_SECRET_USAGE_TYPE_CEPH
;
}
if
(
!
(
secret
=
qemuGetSecretString
(
conn
,
virDomainDiskProtocolTypeToString
(
disk
->
protocol
),
fals
e
,
encod
e
,
disk
->
auth
.
secretType
,
disk
->
auth
.
username
,
disk
->
auth
.
secret
.
uuid
,
disk
->
auth
.
secret
.
usage
,
VIR_SECRET_USAGE_TYPE_ISCSI
)))
secretType
)))
goto
cleanup
;
}
...
...
@@ -4019,28 +4004,10 @@ qemuBuildDriveStr(virConnectPtr conn ATTRIBUTE_UNUSED,
disk
->
src
);
else
virBufferEscape
(
&
opt
,
','
,
","
,
"file=fat:%s,"
,
disk
->
src
);
}
else
if
(
actualType
==
VIR_DOMAIN_DISK_TYPE_NETWORK
)
{
switch
(
disk
->
protocol
)
{
case
VIR_DOMAIN_DISK_PROTOCOL_RBD
:
virBufferAddLit
(
&
opt
,
"file="
);
if
(
qemuBuildRBDString
(
conn
,
disk
,
&
opt
)
<
0
)
goto
error
;
virBufferAddChar
(
&
opt
,
','
);
break
;
case
VIR_DOMAIN_DISK_PROTOCOL_NBD
:
case
VIR_DOMAIN_DISK_PROTOCOL_SHEEPDOG
:
case
VIR_DOMAIN_DISK_PROTOCOL_TFTP
:
case
VIR_DOMAIN_DISK_PROTOCOL_FTPS
:
case
VIR_DOMAIN_DISK_PROTOCOL_FTP
:
case
VIR_DOMAIN_DISK_PROTOCOL_HTTPS
:
case
VIR_DOMAIN_DISK_PROTOCOL_HTTP
:
case
VIR_DOMAIN_DISK_PROTOCOL_GLUSTER
:
case
VIR_DOMAIN_DISK_PROTOCOL_ISCSI
:
}
else
if
(
actualType
==
VIR_DOMAIN_DISK_TYPE_NETWORK
)
{
if
(
qemuBuildDriveURIString
(
conn
,
disk
,
&
opt
)
<
0
)
goto
error
;
break
;
}
}
else
{
if
((
actualType
==
VIR_DOMAIN_DISK_TYPE_BLOCK
)
&&
(
disk
->
tray_status
==
VIR_DOMAIN_DISK_TRAY_OPEN
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录