Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
314ced39
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看板
提交
314ced39
编写于
2月 05, 2010
作者:
M
Matthias Bolte
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove conn parameter from USB functions
It was used for error reporting only.
上级
46ef4631
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
30 addition
and
40 deletion
+30
-40
src/qemu/qemu_security_dac.c
src/qemu/qemu_security_dac.c
+4
-6
src/security/security_selinux.c
src/security/security_selinux.c
+4
-6
src/security/virt-aa-helper.c
src/security/virt-aa-helper.c
+7
-8
src/util/hostusb.c
src/util/hostusb.c
+13
-16
src/util/hostusb.h
src/util/hostusb.h
+2
-4
未找到文件。
src/qemu/qemu_security_dac.c
浏览文件 @
314ced39
...
...
@@ -210,8 +210,7 @@ qemuSecurityDACSetSecurityHostdevLabel(virConnectPtr conn,
switch
(
dev
->
source
.
subsys
.
type
)
{
case
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB
:
{
usbDevice
*
usb
=
usbGetDevice
(
conn
,
dev
->
source
.
subsys
.
u
.
usb
.
bus
,
usbDevice
*
usb
=
usbGetDevice
(
dev
->
source
.
subsys
.
u
.
usb
.
bus
,
dev
->
source
.
subsys
.
u
.
usb
.
device
,
dev
->
source
.
subsys
.
u
.
usb
.
vendor
,
dev
->
source
.
subsys
.
u
.
usb
.
product
);
...
...
@@ -220,7 +219,7 @@ qemuSecurityDACSetSecurityHostdevLabel(virConnectPtr conn,
goto
done
;
ret
=
usbDeviceFileIterate
(
conn
,
usb
,
qemuSecurityDACSetSecurityUSBLabel
,
vm
);
usbFreeDevice
(
conn
,
usb
);
usbFreeDevice
(
usb
);
break
;
}
...
...
@@ -285,8 +284,7 @@ qemuSecurityDACRestoreSecurityHostdevLabel(virConnectPtr conn,
switch
(
dev
->
source
.
subsys
.
type
)
{
case
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB
:
{
usbDevice
*
usb
=
usbGetDevice
(
conn
,
dev
->
source
.
subsys
.
u
.
usb
.
bus
,
usbDevice
*
usb
=
usbGetDevice
(
dev
->
source
.
subsys
.
u
.
usb
.
bus
,
dev
->
source
.
subsys
.
u
.
usb
.
device
,
dev
->
source
.
subsys
.
u
.
usb
.
vendor
,
dev
->
source
.
subsys
.
u
.
usb
.
product
);
...
...
@@ -295,7 +293,7 @@ qemuSecurityDACRestoreSecurityHostdevLabel(virConnectPtr conn,
goto
done
;
ret
=
usbDeviceFileIterate
(
conn
,
usb
,
qemuSecurityDACRestoreSecurityUSBLabel
,
NULL
);
usbFreeDevice
(
conn
,
usb
);
usbFreeDevice
(
usb
);
break
;
}
...
...
src/security/security_selinux.c
浏览文件 @
314ced39
...
...
@@ -498,8 +498,7 @@ SELinuxSetSecurityHostdevLabel(virConnectPtr conn,
switch
(
dev
->
source
.
subsys
.
type
)
{
case
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB
:
{
usbDevice
*
usb
=
usbGetDevice
(
conn
,
dev
->
source
.
subsys
.
u
.
usb
.
bus
,
usbDevice
*
usb
=
usbGetDevice
(
dev
->
source
.
subsys
.
u
.
usb
.
bus
,
dev
->
source
.
subsys
.
u
.
usb
.
device
,
dev
->
source
.
subsys
.
u
.
usb
.
vendor
,
dev
->
source
.
subsys
.
u
.
usb
.
product
);
...
...
@@ -508,7 +507,7 @@ SELinuxSetSecurityHostdevLabel(virConnectPtr conn,
goto
done
;
ret
=
usbDeviceFileIterate
(
conn
,
usb
,
SELinuxSetSecurityUSBLabel
,
vm
);
usbFreeDevice
(
conn
,
usb
);
usbFreeDevice
(
usb
);
break
;
}
...
...
@@ -572,8 +571,7 @@ SELinuxRestoreSecurityHostdevLabel(virConnectPtr conn,
switch
(
dev
->
source
.
subsys
.
type
)
{
case
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB
:
{
usbDevice
*
usb
=
usbGetDevice
(
conn
,
dev
->
source
.
subsys
.
u
.
usb
.
bus
,
usbDevice
*
usb
=
usbGetDevice
(
dev
->
source
.
subsys
.
u
.
usb
.
bus
,
dev
->
source
.
subsys
.
u
.
usb
.
device
,
dev
->
source
.
subsys
.
u
.
usb
.
vendor
,
dev
->
source
.
subsys
.
u
.
usb
.
product
);
...
...
@@ -582,7 +580,7 @@ SELinuxRestoreSecurityHostdevLabel(virConnectPtr conn,
goto
done
;
ret
=
usbDeviceFileIterate
(
conn
,
usb
,
SELinuxRestoreSecurityUSBLabel
,
NULL
);
usbFreeDevice
(
conn
,
usb
);
usbFreeDevice
(
usb
);
break
;
}
...
...
src/security/virt-aa-helper.c
浏览文件 @
314ced39
...
...
@@ -836,25 +836,24 @@ get_files(vahControl * ctl)
virDomainHostdevDefPtr
dev
=
ctl
->
def
->
hostdevs
[
i
];
switch
(
dev
->
source
.
subsys
.
type
)
{
case
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB
:
{
usbDevice
*
usb
=
usbGetDevice
(
NULL
,
dev
->
source
.
subsys
.
u
.
usb
.
bus
,
dev
->
source
.
subsys
.
u
.
usb
.
device
,
dev
->
source
.
subsys
.
u
.
usb
.
vendor
,
dev
->
source
.
subsys
.
u
.
usb
.
product
);
usbDevice
*
usb
=
usbGetDevice
(
dev
->
source
.
subsys
.
u
.
usb
.
bus
,
dev
->
source
.
subsys
.
u
.
usb
.
device
,
dev
->
source
.
subsys
.
u
.
usb
.
vendor
,
dev
->
source
.
subsys
.
u
.
usb
.
product
);
if
(
usb
==
NULL
)
continue
;
rc
=
usbDeviceFileIterate
(
NULL
,
usb
,
file_iterate_cb
,
&
buf
);
usbFreeDevice
(
NULL
,
usb
);
usbFreeDevice
(
usb
);
if
(
rc
!=
0
)
goto
clean
;
break
;
}
/* TODO: update so files in /sys are readonly
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI: {
pciDevice *pci = pciGetDevice(
NULL,
pciDevice *pci = pciGetDevice(
dev->source.subsys.u.pci.domain,
dev->source.subsys.u.pci.bus,
dev->source.subsys.u.pci.slot,
...
...
@@ -864,7 +863,7 @@ get_files(vahControl * ctl)
continue;
rc = pciDeviceFileIterate(NULL, pci, file_iterate_cb, &buf);
pciFreeDevice(
NULL,
pci);
pciFreeDevice(pci);
break;
}
...
...
src/util/hostusb.c
浏览文件 @
314ced39
...
...
@@ -54,12 +54,11 @@ struct _usbDevice {
/* For virReportOOMError() and virReportSystemError() */
#define VIR_FROM_THIS VIR_FROM_NONE
#define usbReportError(co
nn, code, fmt...)
\
virReportErrorHelper(
conn
, VIR_FROM_NONE, code, __FILE__, \
#define usbReportError(co
de, fmt...)
\
virReportErrorHelper(
NULL
, VIR_FROM_NONE, code, __FILE__, \
__FUNCTION__, __LINE__, fmt)
static
int
usbSysReadFile
(
virConnectPtr
conn
,
const
char
*
f_name
,
const
char
*
d_name
,
static
int
usbSysReadFile
(
const
char
*
f_name
,
const
char
*
d_name
,
int
base
,
unsigned
*
value
)
{
int
ret
=
-
1
,
tmp
;
...
...
@@ -77,7 +76,7 @@ static int usbSysReadFile(virConnectPtr conn,
goto
cleanup
;
if
(
virStrToLong_ui
(
buf
,
&
ignore
,
base
,
value
)
<
0
)
{
usbReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
usbReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Could not parse usb file %s"
),
filename
);
goto
cleanup
;
}
...
...
@@ -89,8 +88,7 @@ cleanup:
return
ret
;
}
static
int
usbFindBusByVendor
(
virConnectPtr
conn
,
unsigned
vendor
,
unsigned
product
,
static
int
usbFindBusByVendor
(
unsigned
vendor
,
unsigned
product
,
unsigned
*
bus
,
unsigned
*
devno
)
{
DIR
*
dir
=
NULL
;
...
...
@@ -111,10 +109,10 @@ static int usbFindBusByVendor(virConnectPtr conn,
if
(
de
->
d_name
[
0
]
==
'.'
||
strchr
(
de
->
d_name
,
':'
))
continue
;
if
(
usbSysReadFile
(
conn
,
"idVendor"
,
de
->
d_name
,
if
(
usbSysReadFile
(
"idVendor"
,
de
->
d_name
,
16
,
&
found_vend
)
<
0
)
goto
cleanup
;
if
(
usbSysReadFile
(
conn
,
"idProduct"
,
de
->
d_name
,
if
(
usbSysReadFile
(
"idProduct"
,
de
->
d_name
,
16
,
&
found_prod
)
<
0
)
goto
cleanup
;
...
...
@@ -127,13 +125,13 @@ static int usbFindBusByVendor(virConnectPtr conn,
tmpstr
+=
3
;
if
(
virStrToLong_ui
(
tmpstr
,
&
ignore
,
10
,
&
found_bus
)
<
0
)
{
usbReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
usbReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Failed to parse dir name '%s'"
),
de
->
d_name
);
goto
cleanup
;
}
if
(
usbSysReadFile
(
conn
,
"devnum"
,
de
->
d_name
,
if
(
usbSysReadFile
(
"devnum"
,
de
->
d_name
,
10
,
&
found_addr
)
<
0
)
goto
cleanup
;
...
...
@@ -145,7 +143,7 @@ static int usbFindBusByVendor(virConnectPtr conn,
}
if
(
!
found
)
usbReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
usbReportError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Did not find USB device %x:%x"
),
vendor
,
product
);
else
ret
=
0
;
...
...
@@ -160,8 +158,7 @@ cleanup:
}
usbDevice
*
usbGetDevice
(
virConnectPtr
conn
,
unsigned
bus
,
usbGetDevice
(
unsigned
bus
,
unsigned
devno
,
unsigned
vendor
,
unsigned
product
)
...
...
@@ -175,7 +172,7 @@ usbGetDevice(virConnectPtr conn,
if
(
vendor
)
{
/* Look up bus.dev by vendor:product */
if
(
usbFindBusByVendor
(
conn
,
vendor
,
product
,
&
bus
,
&
devno
)
<
0
)
{
if
(
usbFindBusByVendor
(
vendor
,
product
,
&
bus
,
&
devno
)
<
0
)
{
VIR_FREE
(
dev
);
return
NULL
;
}
...
...
@@ -198,7 +195,7 @@ usbGetDevice(virConnectPtr conn,
}
void
usbFreeDevice
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
usbDevice
*
dev
)
usbFreeDevice
(
usbDevice
*
dev
)
{
VIR_DEBUG
(
"%s %s: freeing"
,
dev
->
id
,
dev
->
name
);
VIR_FREE
(
dev
);
...
...
src/util/hostusb.h
浏览文件 @
314ced39
...
...
@@ -26,13 +26,11 @@
typedef
struct
_usbDevice
usbDevice
;
usbDevice
*
usbGetDevice
(
virConnectPtr
conn
,
unsigned
bus
,
usbDevice
*
usbGetDevice
(
unsigned
bus
,
unsigned
devno
,
unsigned
vendor
,
unsigned
product
);
void
usbFreeDevice
(
virConnectPtr
conn
,
usbDevice
*
dev
);
void
usbFreeDevice
(
usbDevice
*
dev
);
/*
* Callback that will be invoked once for each file
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录