Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
df6c14e6
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,发现更多精彩内容 >>
提交
df6c14e6
编写于
11月 13, 2014
作者:
M
Martin Kletzander
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove unnecessary curly brackets in src/node_device/
Signed-off-by:
N
Martin Kletzander
<
mkletzan@redhat.com
>
上级
f9674bf2
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
38 addition
and
76 deletion
+38
-76
src/node_device/node_device_driver.c
src/node_device/node_device_driver.c
+7
-14
src/node_device/node_device_hal.c
src/node_device/node_device_hal.c
+2
-4
src/node_device/node_device_udev.c
src/node_device/node_device_udev.c
+29
-58
未找到文件。
src/node_device/node_device_driver.c
浏览文件 @
df6c14e6
...
...
@@ -48,9 +48,8 @@ static int update_caps(virNodeDeviceObjPtr dev)
virNodeDevCapsDefPtr
cap
=
dev
->
def
->
caps
;
while
(
cap
)
{
if
(
cap
->
type
==
VIR_NODE_DEV_CAP_SCSI_HOST
)
{
if
(
cap
->
type
==
VIR_NODE_DEV_CAP_SCSI_HOST
)
detect_scsi_host_caps
(
&
dev
->
def
->
caps
->
data
);
}
if
(
cap
->
type
==
VIR_NODE_DEV_CAP_NET
&&
virNetDevGetLinkInfo
(
cap
->
data
.
net
.
ifname
,
&
cap
->
data
.
net
.
lnk
)
<
0
)
return
-
1
;
...
...
@@ -494,14 +493,12 @@ find_new_device(virConnectPtr conn, const char *wwnn, const char *wwpn)
dev
=
nodeDeviceLookupSCSIHostByWWN
(
conn
,
wwnn
,
wwpn
,
0
);
if
(
dev
!=
NULL
)
{
if
(
dev
!=
NULL
)
break
;
}
sleep
(
5
);
if
(
get_time
(
&
now
)
==
-
1
)
{
if
(
get_time
(
&
now
)
==
-
1
)
break
;
}
}
nodeDeviceLock
(
driver
);
...
...
@@ -527,16 +524,14 @@ nodeDeviceCreateXML(virConnectPtr conn,
nodeDeviceLock
(
driver
);
def
=
virNodeDeviceDefParseString
(
xmlDesc
,
CREATE_DEVICE
,
virt_type
);
if
(
def
==
NULL
)
{
if
(
def
==
NULL
)
goto
cleanup
;
}
if
(
virNodeDeviceCreateXMLEnsureACL
(
conn
,
def
)
<
0
)
goto
cleanup
;
if
(
virNodeDeviceGetWWNs
(
def
,
&
wwnn
,
&
wwpn
)
==
-
1
)
{
if
(
virNodeDeviceGetWWNs
(
def
,
&
wwnn
,
&
wwpn
)
==
-
1
)
goto
cleanup
;
}
if
(
virNodeDeviceGetParentHost
(
&
driver
->
devs
,
def
->
name
,
...
...
@@ -556,9 +551,8 @@ nodeDeviceCreateXML(virConnectPtr conn,
/* We don't check the return value, because one way or another,
* we're returning what we get... */
if
(
dev
==
NULL
)
{
if
(
dev
==
NULL
)
virReportError
(
VIR_ERR_NO_NODE_DEVICE
,
NULL
);
}
cleanup:
nodeDeviceUnlock
(
driver
);
...
...
@@ -590,9 +584,8 @@ nodeDeviceDestroy(virNodeDevicePtr dev)
if
(
virNodeDeviceDestroyEnsureACL
(
dev
->
conn
,
obj
->
def
)
<
0
)
goto
out
;
if
(
virNodeDeviceGetWWNs
(
obj
->
def
,
&
wwnn
,
&
wwpn
)
==
-
1
)
{
if
(
virNodeDeviceGetWWNs
(
obj
->
def
,
&
wwnn
,
&
wwpn
)
==
-
1
)
goto
out
;
}
/* virNodeDeviceGetParentHost will cause the device object's lock to be
...
...
src/node_device/node_device_hal.c
浏览文件 @
df6c14e6
...
...
@@ -255,9 +255,8 @@ gather_scsi_host_cap(LibHalContext *ctx, const char *udi,
retval
=
detect_scsi_host_caps
(
d
);
if
(
retval
==
-
1
)
{
if
(
retval
==
-
1
)
goto
out
;
}
out:
return
retval
;
...
...
@@ -551,9 +550,8 @@ dev_refresh(const char *udi)
}
nodeDeviceUnlock
(
driverState
);
if
(
dev
)
{
if
(
dev
)
dev_create
(
udi
);
}
}
static
void
...
...
src/node_device/node_device_udev.c
浏览文件 @
df6c14e6
...
...
@@ -166,9 +166,8 @@ static int udevGetIntProperty(struct udev_device *udev_device,
ret
=
udevGetDeviceProperty
(
udev_device
,
property_key
,
&
udev_value
);
if
(
ret
==
PROPERTY_FOUND
)
{
if
(
udevStrToLong_i
(
udev_value
,
NULL
,
base
,
value
)
!=
0
)
{
if
(
udevStrToLong_i
(
udev_value
,
NULL
,
base
,
value
)
!=
0
)
ret
=
PROPERTY_ERROR
;
}
}
VIR_FREE
(
udev_value
);
...
...
@@ -187,9 +186,8 @@ static int udevGetUintProperty(struct udev_device *udev_device,
ret
=
udevGetDeviceProperty
(
udev_device
,
property_key
,
&
udev_value
);
if
(
ret
==
PROPERTY_FOUND
)
{
if
(
udevStrToLong_ui
(
udev_value
,
NULL
,
base
,
value
)
!=
0
)
{
if
(
udevStrToLong_ui
(
udev_value
,
NULL
,
base
,
value
)
!=
0
)
ret
=
PROPERTY_ERROR
;
}
}
VIR_FREE
(
udev_value
);
...
...
@@ -266,9 +264,8 @@ static int udevGetIntSysfsAttr(struct udev_device *udev_device,
ret
=
udevGetDeviceSysfsAttr
(
udev_device
,
attr_name
,
&
udev_value
);
if
(
ret
==
PROPERTY_FOUND
)
{
if
(
udevStrToLong_i
(
udev_value
,
NULL
,
base
,
value
)
!=
0
)
{
if
(
udevStrToLong_i
(
udev_value
,
NULL
,
base
,
value
)
!=
0
)
ret
=
PROPERTY_ERROR
;
}
}
VIR_FREE
(
udev_value
);
...
...
@@ -287,9 +284,8 @@ static int udevGetUintSysfsAttr(struct udev_device *udev_device,
ret
=
udevGetDeviceSysfsAttr
(
udev_device
,
attr_name
,
&
udev_value
);
if
(
ret
==
PROPERTY_FOUND
)
{
if
(
udevStrToLong_ui
(
udev_value
,
NULL
,
base
,
value
)
!=
0
)
{
if
(
udevStrToLong_ui
(
udev_value
,
NULL
,
base
,
value
)
!=
0
)
ret
=
PROPERTY_ERROR
;
}
}
VIR_FREE
(
udev_value
);
...
...
@@ -307,9 +303,8 @@ static int udevGetUint64SysfsAttr(struct udev_device *udev_device,
ret
=
udevGetDeviceSysfsAttr
(
udev_device
,
attr_name
,
&
udev_value
);
if
(
ret
==
PROPERTY_FOUND
)
{
if
(
udevStrToLong_ull
(
udev_value
,
NULL
,
0
,
value
)
!=
0
)
{
if
(
udevStrToLong_ull
(
udev_value
,
NULL
,
0
,
value
)
!=
0
)
ret
=
PROPERTY_ERROR
;
}
}
VIR_FREE
(
udev_value
);
...
...
@@ -329,9 +324,8 @@ static int udevGenerateDeviceName(struct udev_device *device,
udev_device_get_subsystem
(
device
),
udev_device_get_sysname
(
device
));
if
(
s
!=
NULL
)
{
if
(
s
!=
NULL
)
virBufferAsprintf
(
&
buf
,
"_%s"
,
s
);
}
if
(
virBufferCheckError
(
&
buf
)
<
0
)
return
-
1
;
...
...
@@ -339,9 +333,8 @@ static int udevGenerateDeviceName(struct udev_device *device,
def
->
name
=
virBufferContentAndReset
(
&
buf
);
for
(
i
=
0
;
i
<
strlen
(
def
->
name
);
i
++
)
{
if
(
!
(
c_isalnum
(
*
(
def
->
name
+
i
))))
{
if
(
!
(
c_isalnum
(
*
(
def
->
name
+
i
))))
*
(
def
->
name
+
i
)
=
'_'
;
}
}
return
ret
;
...
...
@@ -490,9 +483,8 @@ static int udevProcessPCI(struct udev_device *device,
goto
out
;
}
if
(
udevGenerateDeviceName
(
device
,
def
,
NULL
)
!=
0
)
{
if
(
udevGenerateDeviceName
(
device
,
def
,
NULL
)
!=
0
)
goto
out
;
}
rc
=
udevGetIntSysfsAttr
(
device
,
"numa_node"
,
...
...
@@ -636,9 +628,8 @@ static int udevProcessUSBDevice(struct udev_device *device,
}
}
if
(
udevGenerateDeviceName
(
device
,
def
,
NULL
)
!=
0
)
{
if
(
udevGenerateDeviceName
(
device
,
def
,
NULL
)
!=
0
)
goto
out
;
}
ret
=
0
;
...
...
@@ -681,9 +672,8 @@ static int udevProcessUSBInterface(struct udev_device *device,
goto
out
;
}
if
(
udevGenerateDeviceName
(
device
,
def
,
NULL
)
!=
0
)
{
if
(
udevGenerateDeviceName
(
device
,
def
,
NULL
)
!=
0
)
goto
out
;
}
ret
=
0
;
...
...
@@ -724,9 +714,8 @@ static int udevProcessNetworkInterface(struct udev_device *device,
goto
out
;
}
if
(
udevGenerateDeviceName
(
device
,
def
,
data
->
net
.
address
)
!=
0
)
{
if
(
udevGenerateDeviceName
(
device
,
def
,
data
->
net
.
address
)
!=
0
)
goto
out
;
}
if
(
virNetDevGetLinkInfo
(
data
->
net
.
ifname
,
&
data
->
net
.
lnk
)
<
0
)
goto
out
;
...
...
@@ -762,9 +751,8 @@ static int udevProcessSCSIHost(struct udev_device *device ATTRIBUTE_UNUSED,
detect_scsi_host_caps
(
&
def
->
caps
->
data
);
if
(
udevGenerateDeviceName
(
device
,
def
,
NULL
)
!=
0
)
{
if
(
udevGenerateDeviceName
(
device
,
def
,
NULL
)
!=
0
)
goto
out
;
}
ret
=
0
;
...
...
@@ -785,9 +773,8 @@ static int udevProcessSCSITarget(struct udev_device *device ATTRIBUTE_UNUSED,
if
(
VIR_STRDUP
(
data
->
scsi_target
.
name
,
sysname
)
<
0
)
goto
out
;
if
(
udevGenerateDeviceName
(
device
,
def
,
NULL
)
!=
0
)
{
if
(
udevGenerateDeviceName
(
device
,
def
,
NULL
)
!=
0
)
goto
out
;
}
ret
=
0
;
...
...
@@ -864,9 +851,8 @@ static int udevProcessSCSIDevice(struct udev_device *device ATTRIBUTE_UNUSED,
filename
=
last_component
(
def
->
sysfs_path
);
if
(
udevStrToLong_ui
(
filename
,
&
p
,
10
,
&
data
->
scsi
.
host
)
==
-
1
)
{
if
(
udevStrToLong_ui
(
filename
,
&
p
,
10
,
&
data
->
scsi
.
host
)
==
-
1
)
goto
out
;
}
if
((
p
==
NULL
)
||
(
udevStrToLong_ui
(
p
+
1
,
&
p
,
...
...
@@ -891,9 +877,8 @@ static int udevProcessSCSIDevice(struct udev_device *device ATTRIBUTE_UNUSED,
switch
(
udevGetUintSysfsAttr
(
device
,
"type"
,
&
tmp
,
0
))
{
case
PROPERTY_FOUND
:
if
(
udevGetSCSIType
(
def
,
tmp
,
&
data
->
scsi
.
type
)
==
-
1
)
{
if
(
udevGetSCSIType
(
def
,
tmp
,
&
data
->
scsi
.
type
)
==
-
1
)
goto
out
;
}
break
;
case
PROPERTY_MISSING
:
break
;
/* No type is not an error */
...
...
@@ -903,9 +888,8 @@ static int udevProcessSCSIDevice(struct udev_device *device ATTRIBUTE_UNUSED,
break
;
}
if
(
udevGenerateDeviceName
(
device
,
def
,
NULL
)
!=
0
)
{
if
(
udevGenerateDeviceName
(
device
,
def
,
NULL
)
!=
0
)
goto
out
;
}
ret
=
0
;
...
...
@@ -1099,9 +1083,8 @@ static int udevKludgeStorageType(virNodeDeviceDefPtr def)
static
void
udevStripSpaces
(
char
*
s
)
{
if
(
s
==
NULL
)
{
if
(
s
==
NULL
)
return
;
}
while
(
virFileStripSuffix
(
s
,
" "
))
{
/* do nothing */
...
...
@@ -1184,9 +1167,8 @@ static int udevProcessStorage(struct udev_device *device,
}
else
{
/* If udev doesn't have it, perhaps we can guess it. */
if
(
udevKludgeStorageType
(
def
)
!=
0
)
{
if
(
udevKludgeStorageType
(
def
)
!=
0
)
goto
out
;
}
}
}
...
...
@@ -1204,9 +1186,8 @@ static int udevProcessStorage(struct udev_device *device,
goto
out
;
}
if
(
udevGenerateDeviceName
(
device
,
def
,
data
->
storage
.
serial
)
!=
0
)
{
if
(
udevGenerateDeviceName
(
device
,
def
,
data
->
storage
.
serial
)
!=
0
)
goto
out
;
}
out:
VIR_DEBUG
(
"Storage ret=%d"
,
ret
);
...
...
@@ -1376,9 +1357,8 @@ static int udevSetParent(struct udev_device *device,
do
{
parent_device
=
udev_device_get_parent
(
parent_device
);
if
(
parent_device
==
NULL
)
{
if
(
parent_device
==
NULL
)
break
;
}
parent_sysfs_path
=
udev_device_get_syspath
(
parent_device
);
if
(
parent_sysfs_path
==
NULL
)
{
...
...
@@ -1434,17 +1414,14 @@ static int udevAddOneDevice(struct udev_device *device)
if
(
VIR_ALLOC
(
def
->
caps
)
!=
0
)
goto
out
;
if
(
udevGetDeviceType
(
device
,
&
def
->
caps
->
type
)
!=
0
)
{
if
(
udevGetDeviceType
(
device
,
&
def
->
caps
->
type
)
!=
0
)
goto
out
;
}
if
(
udevGetDeviceDetails
(
device
,
def
)
!=
0
)
{
if
(
udevGetDeviceDetails
(
device
,
def
)
!=
0
)
goto
out
;
}
if
(
udevSetParent
(
device
,
def
)
!=
0
)
{
if
(
udevSetParent
(
device
,
def
)
!=
0
)
goto
out
;
}
/* If this is a device change, the old definition will be freed
* and the current definition will take its place. */
...
...
@@ -1544,9 +1521,8 @@ static int nodeStateCleanup(void)
udev_monitor_unref
(
udev_monitor
);
}
if
(
udev
!=
NULL
)
{
if
(
udev
!=
NULL
)
udev_unref
(
udev
);
}
virNodeDeviceObjListFree
(
&
driverState
->
devs
);
nodeDeviceUnlock
(
driverState
);
...
...
@@ -1681,9 +1657,8 @@ udevGetDMIData(union _virNodeDevCapData *data)
out:
VIR_FREE
(
tmp
);
if
(
device
!=
NULL
)
{
if
(
device
!=
NULL
)
udev_device_unref
(
device
);
}
return
;
}
#endif
...
...
@@ -1719,9 +1694,8 @@ static int udevSetupSystemDev(void)
ret
=
0
;
out:
if
(
ret
==
-
1
)
{
if
(
ret
==
-
1
)
virNodeDeviceDefFree
(
def
);
}
return
ret
;
}
...
...
@@ -1834,9 +1808,8 @@ static int nodeStateInitialize(bool privileged,
nodeDeviceUnlock
(
driverState
);
out:
if
(
ret
==
-
1
)
{
if
(
ret
==
-
1
)
nodeStateCleanup
();
}
return
ret
;
}
...
...
@@ -1853,9 +1826,8 @@ static virDrvOpenStatus nodeDeviceOpen(virConnectPtr conn,
{
virCheckFlags
(
VIR_CONNECT_RO
,
VIR_DRV_OPEN_ERROR
);
if
(
driverState
==
NULL
)
{
if
(
driverState
==
NULL
)
return
VIR_DRV_OPEN_DECLINED
;
}
conn
->
nodeDevicePrivateData
=
driverState
;
...
...
@@ -1896,9 +1868,8 @@ int udevNodeRegister(void)
{
VIR_DEBUG
(
"Registering udev node device backend"
);
if
(
virRegisterNodeDeviceDriver
(
&
udevNodeDeviceDriver
)
<
0
)
{
if
(
virRegisterNodeDeviceDriver
(
&
udevNodeDeviceDriver
)
<
0
)
return
-
1
;
}
return
virRegisterStateDriver
(
&
udevStateDriver
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录