Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
7677f8a7
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,发现更多精彩内容 >>
提交
7677f8a7
编写于
7月 07, 2017
作者:
P
Peter Krempa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
qemu: Move qemuGetDriveSourceProps to qemu_block
Pure code movement except for the tweaks necessary for cross-usage.
上级
f96e9773
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
133 addition
and
126 deletion
+133
-126
po/POTFILES.in
po/POTFILES.in
+1
-0
src/qemu/qemu_block.c
src/qemu/qemu_block.c
+126
-0
src/qemu/qemu_block.h
src/qemu/qemu_block.h
+5
-0
src/qemu/qemu_command.c
src/qemu/qemu_command.c
+1
-126
未找到文件。
po/POTFILES.in
浏览文件 @
7677f8a7
...
...
@@ -129,6 +129,7 @@ src/openvz/openvz_util.c
src/phyp/phyp_driver.c
src/qemu/qemu_agent.c
src/qemu/qemu_alias.c
src/qemu/qemu_block.c
src/qemu/qemu_capabilities.c
src/qemu/qemu_cgroup.c
src/qemu/qemu_command.c
...
...
src/qemu/qemu_block.c
浏览文件 @
7677f8a7
...
...
@@ -428,3 +428,129 @@ qemuBlockGetNodeData(virJSONValuePtr data)
virHashFree
(
ret
);
return
NULL
;
}
/* builds the hosts array */
static
virJSONValuePtr
qemuBuildGlusterDriveJSONHosts
(
virStorageSourcePtr
src
)
{
virJSONValuePtr
servers
=
NULL
;
virJSONValuePtr
server
=
NULL
;
virJSONValuePtr
ret
=
NULL
;
virStorageNetHostDefPtr
host
;
const
char
*
transport
;
size_t
i
;
if
(
!
(
servers
=
virJSONValueNewArray
()))
goto
cleanup
;
for
(
i
=
0
;
i
<
src
->
nhosts
;
i
++
)
{
host
=
src
->
hosts
+
i
;
transport
=
virStorageNetHostTransportTypeToString
(
host
->
transport
);
if
(
virJSONValueObjectCreate
(
&
server
,
"s:type"
,
transport
,
NULL
)
<
0
)
goto
cleanup
;
switch
((
virStorageNetHostTransport
)
host
->
transport
)
{
case
VIR_STORAGE_NET_HOST_TRANS_TCP
:
if
(
virJSONValueObjectAdd
(
server
,
"s:host"
,
host
->
name
,
"s:port"
,
host
->
port
,
NULL
)
<
0
)
goto
cleanup
;
break
;
case
VIR_STORAGE_NET_HOST_TRANS_UNIX
:
if
(
virJSONValueObjectAdd
(
server
,
"s:socket"
,
host
->
socket
,
NULL
)
<
0
)
goto
cleanup
;
break
;
case
VIR_STORAGE_NET_HOST_TRANS_RDMA
:
case
VIR_STORAGE_NET_HOST_TRANS_LAST
:
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"transport protocol '%s' is not yet supported"
),
transport
);
goto
cleanup
;
}
if
(
virJSONValueArrayAppend
(
servers
,
server
)
<
0
)
goto
cleanup
;
server
=
NULL
;
}
ret
=
servers
;
servers
=
NULL
;
cleanup:
virJSONValueFree
(
servers
);
virJSONValueFree
(
server
);
return
ret
;
}
static
virJSONValuePtr
qemuBuildGlusterDriveJSON
(
virStorageSourcePtr
src
)
{
const
char
*
protocol
=
virStorageNetProtocolTypeToString
(
src
->
protocol
);
virJSONValuePtr
servers
=
NULL
;
virJSONValuePtr
ret
=
NULL
;
if
(
!
(
servers
=
qemuBuildGlusterDriveJSONHosts
(
src
)))
return
NULL
;
/* { driver:"gluster",
* volume:"testvol",
* path:"/a.img",
* server :[{type:"tcp", host:"1.2.3.4", port:24007},
* {type:"unix", socket:"/tmp/glusterd.socket"}, ...]}
*/
if
(
virJSONValueObjectCreate
(
&
ret
,
"s:driver"
,
protocol
,
"s:volume"
,
src
->
volume
,
"s:path"
,
src
->
path
,
"a:server"
,
servers
,
NULL
)
<
0
)
virJSONValueFree
(
servers
);
return
ret
;
}
int
qemuGetDriveSourceProps
(
virStorageSourcePtr
src
,
virJSONValuePtr
*
props
)
{
int
actualType
=
virStorageSourceGetActualType
(
src
);
virJSONValuePtr
fileprops
=
NULL
;
*
props
=
NULL
;
switch
((
virStorageType
)
actualType
)
{
case
VIR_STORAGE_TYPE_BLOCK
:
case
VIR_STORAGE_TYPE_FILE
:
case
VIR_STORAGE_TYPE_DIR
:
case
VIR_STORAGE_TYPE_VOLUME
:
case
VIR_STORAGE_TYPE_NONE
:
case
VIR_STORAGE_TYPE_LAST
:
break
;
case
VIR_STORAGE_TYPE_NETWORK
:
if
(
src
->
protocol
==
VIR_STORAGE_NET_PROTOCOL_GLUSTER
&&
src
->
nhosts
>
1
)
{
if
(
!
(
fileprops
=
qemuBuildGlusterDriveJSON
(
src
)))
return
-
1
;
}
break
;
}
if
(
fileprops
&&
virJSONValueObjectCreate
(
props
,
"a:file"
,
fileprops
,
NULL
)
<
0
)
{
virJSONValueFree
(
fileprops
);
return
-
1
;
}
return
0
;
}
src/qemu/qemu_block.h
浏览文件 @
7677f8a7
...
...
@@ -53,4 +53,9 @@ qemuBlockNodeNamesDetect(virQEMUDriverPtr driver,
virHashTablePtr
qemuBlockGetNodeData
(
virJSONValuePtr
data
);
int
qemuGetDriveSourceProps
(
virStorageSourcePtr
src
,
virJSONValuePtr
*
props
);
#endif
/* __QEMU_BLOCK_H__ */
src/qemu/qemu_command.c
浏览文件 @
7677f8a7
...
...
@@ -29,6 +29,7 @@
#include "qemu_interface.h"
#include "qemu_alias.h"
#include "qemu_security.h"
#include "qemu_block.h"
#include "cpu/cpu.h"
#include "dirname.h"
#include "viralloc.h"
...
...
@@ -792,95 +793,6 @@ qemuBuildTLSx509CommandLine(virCommandPtr cmd,
}
/* builds the hosts array */
static
virJSONValuePtr
qemuBuildGlusterDriveJSONHosts
(
virStorageSourcePtr
src
)
{
virJSONValuePtr
servers
=
NULL
;
virJSONValuePtr
server
=
NULL
;
virJSONValuePtr
ret
=
NULL
;
virStorageNetHostDefPtr
host
;
const
char
*
transport
;
size_t
i
;
if
(
!
(
servers
=
virJSONValueNewArray
()))
goto
cleanup
;
for
(
i
=
0
;
i
<
src
->
nhosts
;
i
++
)
{
host
=
src
->
hosts
+
i
;
transport
=
virStorageNetHostTransportTypeToString
(
host
->
transport
);
if
(
virJSONValueObjectCreate
(
&
server
,
"s:type"
,
transport
,
NULL
)
<
0
)
goto
cleanup
;
switch
((
virStorageNetHostTransport
)
host
->
transport
)
{
case
VIR_STORAGE_NET_HOST_TRANS_TCP
:
if
(
virJSONValueObjectAdd
(
server
,
"s:host"
,
host
->
name
,
"s:port"
,
host
->
port
,
NULL
)
<
0
)
goto
cleanup
;
break
;
case
VIR_STORAGE_NET_HOST_TRANS_UNIX
:
if
(
virJSONValueObjectAdd
(
server
,
"s:socket"
,
host
->
socket
,
NULL
)
<
0
)
goto
cleanup
;
break
;
case
VIR_STORAGE_NET_HOST_TRANS_RDMA
:
case
VIR_STORAGE_NET_HOST_TRANS_LAST
:
virReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"transport protocol '%s' is not yet supported"
),
transport
);
goto
cleanup
;
}
if
(
virJSONValueArrayAppend
(
servers
,
server
)
<
0
)
goto
cleanup
;
server
=
NULL
;
}
ret
=
servers
;
servers
=
NULL
;
cleanup:
virJSONValueFree
(
servers
);
virJSONValueFree
(
server
);
return
ret
;
}
static
virJSONValuePtr
qemuBuildGlusterDriveJSON
(
virStorageSourcePtr
src
)
{
const
char
*
protocol
=
virStorageNetProtocolTypeToString
(
src
->
protocol
);
virJSONValuePtr
servers
=
NULL
;
virJSONValuePtr
ret
=
NULL
;
if
(
!
(
servers
=
qemuBuildGlusterDriveJSONHosts
(
src
)))
return
NULL
;
/* { driver:"gluster",
* volume:"testvol",
* path:"/a.img",
* server :[{type:"tcp", host:"1.2.3.4", port:24007},
* {type:"unix", socket:"/tmp/glusterd.socket"}, ...]}
*/
if
(
virJSONValueObjectCreate
(
&
ret
,
"s:driver"
,
protocol
,
"s:volume"
,
src
->
volume
,
"s:path"
,
src
->
path
,
"a:server"
,
servers
,
NULL
)
<
0
)
virJSONValueFree
(
servers
);
return
ret
;
}
static
char
*
qemuBuildNetworkDriveURI
(
virStorageSourcePtr
src
,
qemuDomainSecretInfoPtr
secinfo
)
...
...
@@ -1103,43 +1015,6 @@ qemuBuildNetworkDriveStr(virStorageSourcePtr src,
}
static
int
qemuGetDriveSourceProps
(
virStorageSourcePtr
src
,
virJSONValuePtr
*
props
)
{
int
actualType
=
virStorageSourceGetActualType
(
src
);
virJSONValuePtr
fileprops
=
NULL
;
*
props
=
NULL
;
switch
((
virStorageType
)
actualType
)
{
case
VIR_STORAGE_TYPE_BLOCK
:
case
VIR_STORAGE_TYPE_FILE
:
case
VIR_STORAGE_TYPE_DIR
:
case
VIR_STORAGE_TYPE_VOLUME
:
case
VIR_STORAGE_TYPE_NONE
:
case
VIR_STORAGE_TYPE_LAST
:
break
;
case
VIR_STORAGE_TYPE_NETWORK
:
if
(
src
->
protocol
==
VIR_STORAGE_NET_PROTOCOL_GLUSTER
&&
src
->
nhosts
>
1
)
{
if
(
!
(
fileprops
=
qemuBuildGlusterDriveJSON
(
src
)))
return
-
1
;
}
break
;
}
if
(
fileprops
&&
virJSONValueObjectCreate
(
props
,
"a:file"
,
fileprops
,
NULL
)
<
0
)
{
virJSONValueFree
(
fileprops
);
return
-
1
;
}
return
0
;
}
int
qemuGetDriveSourceString
(
virStorageSourcePtr
src
,
qemuDomainSecretInfoPtr
secinfo
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录