Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
f972dc2d
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看板
提交
f972dc2d
编写于
2月 04, 2010
作者:
M
Matthias Bolte
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove conn parameter from util functions
It was used for error reporting only.
上级
d5c6183d
变更
35
隐藏空白更改
内联
并排
Showing
35 changed file
with
166 addition
and
194 deletion
+166
-194
daemon/libvirtd.c
daemon/libvirtd.c
+1
-1
daemon/remote.c
daemon/remote.c
+1
-1
docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch
...nsion/0007-Step-7-of-8-Implement-the-driver-methods.patch
+2
-2
src/lxc/lxc_driver.c
src/lxc/lxc_driver.c
+2
-2
src/lxc/veth.c
src/lxc/veth.c
+6
-6
src/network/bridge_driver.c
src/network/bridge_driver.c
+2
-2
src/node_device/node_device_driver.c
src/node_device/node_device_driver.c
+1
-1
src/openvz/openvz_conf.c
src/openvz/openvz_conf.c
+1
-1
src/openvz/openvz_driver.c
src/openvz/openvz_driver.c
+12
-12
src/phyp/phyp_driver.c
src/phyp/phyp_driver.c
+1
-1
src/qemu/qemu_conf.c
src/qemu/qemu_conf.c
+5
-5
src/qemu/qemu_driver.c
src/qemu/qemu_driver.c
+3
-3
src/remote/remote_driver.c
src/remote/remote_driver.c
+3
-3
src/secret/secret_driver.c
src/secret/secret_driver.c
+1
-1
src/security/security_apparmor.c
src/security/security_apparmor.c
+4
-4
src/security/virt-aa-helper.c
src/security/virt-aa-helper.c
+1
-1
src/storage/storage_backend.c
src/storage/storage_backend.c
+7
-8
src/storage/storage_backend_disk.c
src/storage/storage_backend_disk.c
+6
-6
src/storage/storage_backend_fs.c
src/storage/storage_backend_fs.c
+2
-2
src/storage/storage_backend_iscsi.c
src/storage/storage_backend_iscsi.c
+10
-10
src/storage/storage_backend_logical.c
src/storage/storage_backend_logical.c
+17
-18
src/storage/storage_backend_mpath.c
src/storage/storage_backend_mpath.c
+1
-1
src/storage/storage_backend_scsi.c
src/storage/storage_backend_scsi.c
+3
-4
src/storage/storage_backend_scsi.h
src/storage/storage_backend_scsi.h
+1
-2
src/storage/storage_driver.c
src/storage/storage_driver.c
+1
-1
src/uml/uml_driver.c
src/uml/uml_driver.c
+2
-2
src/util/bridge.c
src/util/bridge.c
+2
-2
src/util/cgroup.c
src/util/cgroup.c
+1
-1
src/util/ebtables.c
src/util/ebtables.c
+1
-1
src/util/iptables.c
src/util/iptables.c
+1
-1
src/util/pci.c
src/util/pci.c
+5
-5
src/util/util.c
src/util/util.c
+47
-64
src/util/util.h
src/util/util.h
+10
-17
src/xen/proxy_internal.c
src/xen/proxy_internal.c
+1
-1
tools/virsh.c
tools/virsh.c
+2
-2
未找到文件。
daemon/libvirtd.c
浏览文件 @
f972dc2d
...
@@ -755,7 +755,7 @@ static int qemudInitPaths(struct qemud_server *server,
...
@@ -755,7 +755,7 @@ static int qemudInitPaths(struct qemud_server *server,
goto
snprintf_error
;
goto
snprintf_error
;
}
else
{
}
else
{
uid_t
uid
=
geteuid
();
uid_t
uid
=
geteuid
();
dir_prefix
=
virGetUserDirectory
(
NULL
,
uid
);
dir_prefix
=
virGetUserDirectory
(
uid
);
if
(
dir_prefix
==
NULL
)
{
if
(
dir_prefix
==
NULL
)
{
/* Do not diagnose here; virGetUserDirectory does that. */
/* Do not diagnose here; virGetUserDirectory does that. */
goto
snprintf_error
;
goto
snprintf_error
;
...
...
daemon/remote.c
浏览文件 @
f972dc2d
...
@@ -3423,7 +3423,7 @@ remoteDispatchAuthPolkit (struct qemud_server *server,
...
@@ -3423,7 +3423,7 @@ remoteDispatchAuthPolkit (struct qemud_server *server,
goto
authfail
;
goto
authfail
;
}
}
if
(
virRun
(
NULL
,
pkcheck
,
&
status
)
<
0
)
{
if
(
virRun
(
pkcheck
,
&
status
)
<
0
)
{
VIR_ERROR
(
_
(
"Cannot invoke %s"
),
PKCHECK_PATH
);
VIR_ERROR
(
_
(
"Cannot invoke %s"
),
PKCHECK_PATH
);
goto
authfail
;
goto
authfail
;
}
}
...
...
docs/api_extension/0007-Step-7-of-8-Implement-the-driver-methods.patch
浏览文件 @
f972dc2d
...
@@ -478,7 +478,7 @@ index b84729f..4f73baf 100644
...
@@ -478,7 +478,7 @@ index b84729f..4f73baf 100644
+ * If this fails for any reason, we still have the backup of polling for
+ * If this fails for any reason, we still have the backup of polling for
+ * 5 seconds for device nodes.
+ * 5 seconds for device nodes.
+ */
+ */
+ virRun(
conn,
settleprog, &exitstatus);
+ virRun(settleprog, &exitstatus);
+}
+}
+#else
+#else
+void virNodeDeviceWaitForDevices(virConnectPtr conn ATTRIBUTE_UNUSED) {}
+void virNodeDeviceWaitForDevices(virConnectPtr conn ATTRIBUTE_UNUSED) {}
...
@@ -1131,7 +1131,7 @@ index b154140..74759cf 100644
...
@@ -1131,7 +1131,7 @@ index b154140..74759cf 100644
- * If this fails for any reason, we still have the backup of polling for
- * If this fails for any reason, we still have the backup of polling for
- * 5 seconds for device nodes.
- * 5 seconds for device nodes.
- */
- */
- virRun(
conn,
settleprog, &exitstatus);
- virRun(settleprog, &exitstatus);
+ virNodeDeviceWaitForDevices(conn);
+ virNodeDeviceWaitForDevices(conn);
+ return;
+ return;
}
}
...
...
src/lxc/lxc_driver.c
浏览文件 @
f972dc2d
...
@@ -1120,7 +1120,7 @@ static int lxcControllerStart(virConnectPtr conn,
...
@@ -1120,7 +1120,7 @@ static int lxcControllerStart(virConnectPtr conn,
FD_SET
(
appPty
,
&
keepfd
);
FD_SET
(
appPty
,
&
keepfd
);
if
(
virExec
(
conn
,
largv
,
lenv
,
&
keepfd
,
&
child
,
if
(
virExec
(
largv
,
lenv
,
&
keepfd
,
&
child
,
-
1
,
&
logfd
,
&
logfd
,
-
1
,
&
logfd
,
&
logfd
,
VIR_EXEC_NONE
)
<
0
)
VIR_EXEC_NONE
)
<
0
)
goto
cleanup
;
goto
cleanup
;
...
@@ -1575,7 +1575,7 @@ static int lxcCheckNetNsSupport(void)
...
@@ -1575,7 +1575,7 @@ static int lxcCheckNetNsSupport(void)
const
char
*
argv
[]
=
{
"ip"
,
"link"
,
"set"
,
"lo"
,
"netns"
,
"-1"
,
NULL
};
const
char
*
argv
[]
=
{
"ip"
,
"link"
,
"set"
,
"lo"
,
"netns"
,
"-1"
,
NULL
};
int
ip_rc
;
int
ip_rc
;
if
(
virRun
(
NULL
,
argv
,
&
ip_rc
)
<
0
||
if
(
virRun
(
argv
,
&
ip_rc
)
<
0
||
!
(
WIFEXITED
(
ip_rc
)
&&
(
WEXITSTATUS
(
ip_rc
)
!=
255
)))
!
(
WIFEXITED
(
ip_rc
)
&&
(
WEXITSTATUS
(
ip_rc
)
!=
255
)))
return
0
;
return
0
;
...
...
src/lxc/veth.c
浏览文件 @
f972dc2d
...
@@ -102,7 +102,7 @@ int vethCreate(char* veth1, int veth1MaxLen,
...
@@ -102,7 +102,7 @@ int vethCreate(char* veth1, int veth1MaxLen,
}
}
DEBUG
(
"veth1: %s veth2: %s"
,
veth1
,
veth2
);
DEBUG
(
"veth1: %s veth2: %s"
,
veth1
,
veth2
);
rc
=
virRun
(
NULL
,
argv
,
&
cmdResult
);
rc
=
virRun
(
argv
,
&
cmdResult
);
if
(
0
==
rc
)
{
if
(
0
==
rc
)
{
rc
=
cmdResult
;
rc
=
cmdResult
;
...
@@ -135,7 +135,7 @@ int vethDelete(const char *veth)
...
@@ -135,7 +135,7 @@ int vethDelete(const char *veth)
DEBUG
(
"veth: %s"
,
veth
);
DEBUG
(
"veth: %s"
,
veth
);
rc
=
virRun
(
NULL
,
argv
,
&
cmdResult
);
rc
=
virRun
(
argv
,
&
cmdResult
);
if
(
0
==
rc
)
{
if
(
0
==
rc
)
{
rc
=
cmdResult
;
rc
=
cmdResult
;
...
@@ -170,7 +170,7 @@ int vethInterfaceUpOrDown(const char* veth, int upOrDown)
...
@@ -170,7 +170,7 @@ int vethInterfaceUpOrDown(const char* veth, int upOrDown)
else
else
argv
[
2
]
=
"up"
;
argv
[
2
]
=
"up"
;
rc
=
virRun
(
NULL
,
argv
,
&
cmdResult
);
rc
=
virRun
(
argv
,
&
cmdResult
);
if
(
0
==
rc
)
{
if
(
0
==
rc
)
{
rc
=
cmdResult
;
rc
=
cmdResult
;
...
@@ -208,7 +208,7 @@ int moveInterfaceToNetNs(const char* iface, int pidInNs)
...
@@ -208,7 +208,7 @@ int moveInterfaceToNetNs(const char* iface, int pidInNs)
goto
error_out
;
goto
error_out
;
argv
[
5
]
=
pid
;
argv
[
5
]
=
pid
;
rc
=
virRun
(
NULL
,
argv
,
&
cmdResult
);
rc
=
virRun
(
argv
,
&
cmdResult
);
if
(
0
==
rc
)
if
(
0
==
rc
)
rc
=
cmdResult
;
rc
=
cmdResult
;
...
@@ -240,7 +240,7 @@ int setMacAddr(const char* iface, const char* macaddr)
...
@@ -240,7 +240,7 @@ int setMacAddr(const char* iface, const char* macaddr)
goto
error_out
;
goto
error_out
;
}
}
rc
=
virRun
(
NULL
,
argv
,
&
cmdResult
);
rc
=
virRun
(
argv
,
&
cmdResult
);
if
(
0
==
rc
)
if
(
0
==
rc
)
rc
=
cmdResult
;
rc
=
cmdResult
;
...
@@ -271,7 +271,7 @@ int setInterfaceName(const char* iface, const char* new)
...
@@ -271,7 +271,7 @@ int setInterfaceName(const char* iface, const char* new)
goto
error_out
;
goto
error_out
;
}
}
rc
=
virRun
(
NULL
,
argv
,
&
cmdResult
);
rc
=
virRun
(
argv
,
&
cmdResult
);
if
(
0
==
rc
)
if
(
0
==
rc
)
rc
=
cmdResult
;
rc
=
cmdResult
;
...
...
src/network/bridge_driver.c
浏览文件 @
f972dc2d
...
@@ -211,7 +211,7 @@ networkStartup(int privileged) {
...
@@ -211,7 +211,7 @@ networkStartup(int privileged) {
if
((
base
=
strdup
(
SYSCONF_DIR
"/libvirt"
))
==
NULL
)
if
((
base
=
strdup
(
SYSCONF_DIR
"/libvirt"
))
==
NULL
)
goto
out_of_memory
;
goto
out_of_memory
;
}
else
{
}
else
{
char
*
userdir
=
virGetUserDirectory
(
NULL
,
uid
);
char
*
userdir
=
virGetUserDirectory
(
uid
);
if
(
!
userdir
)
if
(
!
userdir
)
goto
error
;
goto
error
;
...
@@ -562,7 +562,7 @@ dhcpStartDhcpDaemon(virConnectPtr conn,
...
@@ -562,7 +562,7 @@ dhcpStartDhcpDaemon(virConnectPtr conn,
return
-
1
;
return
-
1
;
}
}
if
(
virRun
(
conn
,
argv
,
NULL
)
<
0
)
if
(
virRun
(
argv
,
NULL
)
<
0
)
goto
cleanup
;
goto
cleanup
;
/*
/*
...
...
src/node_device/node_device_driver.c
浏览文件 @
f972dc2d
...
@@ -510,7 +510,7 @@ find_new_device(virConnectPtr conn, const char *wwnn, const char *wwpn)
...
@@ -510,7 +510,7 @@ find_new_device(virConnectPtr conn, const char *wwnn, const char *wwpn)
while
((
now
-
start
)
<
LINUX_NEW_DEVICE_WAIT_TIME
)
{
while
((
now
-
start
)
<
LINUX_NEW_DEVICE_WAIT_TIME
)
{
virFileWaitForDevices
(
conn
);
virFileWaitForDevices
();
dev
=
nodeDeviceLookupByWWN
(
conn
,
wwnn
,
wwpn
);
dev
=
nodeDeviceLookupByWWN
(
conn
,
wwnn
,
wwpn
);
...
...
src/openvz/openvz_conf.c
浏览文件 @
f972dc2d
...
@@ -84,7 +84,7 @@ openvzExtractVersionInfo(const char *cmd, int *retversion)
...
@@ -84,7 +84,7 @@ openvzExtractVersionInfo(const char *cmd, int *retversion)
if
(
retversion
)
if
(
retversion
)
*
retversion
=
0
;
*
retversion
=
0
;
if
(
virExec
(
NULL
,
vzarg
,
vzenv
,
NULL
,
if
(
virExec
(
vzarg
,
vzenv
,
NULL
,
&
child
,
-
1
,
&
newstdout
,
NULL
,
VIR_EXEC_NONE
)
<
0
)
&
child
,
-
1
,
&
newstdout
,
NULL
,
VIR_EXEC_NONE
)
<
0
)
return
-
1
;
return
-
1
;
...
...
src/openvz/openvz_driver.c
浏览文件 @
f972dc2d
...
@@ -256,7 +256,7 @@ static int openvzSetInitialConfig(virConnectPtr conn,
...
@@ -256,7 +256,7 @@ static int openvzSetInitialConfig(virConnectPtr conn,
goto
cleanup
;
goto
cleanup
;
}
}
if
(
virRun
(
conn
,
prog
,
NULL
)
<
0
)
{
if
(
virRun
(
prog
,
NULL
)
<
0
)
{
openvzError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
openvzError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"Could not exec %s"
),
VZCTL
);
_
(
"Could not exec %s"
),
VZCTL
);
goto
cleanup
;
goto
cleanup
;
...
@@ -530,7 +530,7 @@ static int openvzDomainShutdown(virDomainPtr dom) {
...
@@ -530,7 +530,7 @@ static int openvzDomainShutdown(virDomainPtr dom) {
goto
cleanup
;
goto
cleanup
;
}
}
if
(
virRun
(
dom
->
conn
,
prog
,
NULL
)
<
0
)
if
(
virRun
(
prog
,
NULL
)
<
0
)
goto
cleanup
;
goto
cleanup
;
vm
->
def
->
id
=
-
1
;
vm
->
def
->
id
=
-
1
;
...
@@ -567,7 +567,7 @@ static int openvzDomainReboot(virDomainPtr dom,
...
@@ -567,7 +567,7 @@ static int openvzDomainReboot(virDomainPtr dom,
goto
cleanup
;
goto
cleanup
;
}
}
if
(
virRun
(
dom
->
conn
,
prog
,
NULL
)
<
0
)
if
(
virRun
(
prog
,
NULL
)
<
0
)
goto
cleanup
;
goto
cleanup
;
ret
=
0
;
ret
=
0
;
...
@@ -727,7 +727,7 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
...
@@ -727,7 +727,7 @@ openvzDomainSetNetwork(virConnectPtr conn, const char *vpsid,
if
(
prog
[
0
]
!=
NULL
){
if
(
prog
[
0
]
!=
NULL
){
ADD_ARG_LIT
(
"--save"
);
ADD_ARG_LIT
(
"--save"
);
if
(
virRun
(
conn
,
prog
,
NULL
)
<
0
)
{
if
(
virRun
(
prog
,
NULL
)
<
0
)
{
openvzError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
openvzError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"Could not exec %s"
),
VZCTL
);
_
(
"Could not exec %s"
),
VZCTL
);
rc
=
-
1
;
rc
=
-
1
;
...
@@ -929,7 +929,7 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
...
@@ -929,7 +929,7 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml,
openvzSetProgramSentinal
(
progstart
,
vm
->
def
->
name
);
openvzSetProgramSentinal
(
progstart
,
vm
->
def
->
name
);
if
(
virRun
(
conn
,
progstart
,
NULL
)
<
0
)
{
if
(
virRun
(
progstart
,
NULL
)
<
0
)
{
openvzError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
openvzError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"Could not exec %s"
),
VZCTL
);
_
(
"Could not exec %s"
),
VZCTL
);
goto
cleanup
;
goto
cleanup
;
...
@@ -984,7 +984,7 @@ openvzDomainCreate(virDomainPtr dom)
...
@@ -984,7 +984,7 @@ openvzDomainCreate(virDomainPtr dom)
}
}
openvzSetProgramSentinal
(
prog
,
vm
->
def
->
name
);
openvzSetProgramSentinal
(
prog
,
vm
->
def
->
name
);
if
(
virRun
(
dom
->
conn
,
prog
,
NULL
)
<
0
)
{
if
(
virRun
(
prog
,
NULL
)
<
0
)
{
openvzError
(
dom
->
conn
,
VIR_ERR_INTERNAL_ERROR
,
openvzError
(
dom
->
conn
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"Could not exec %s"
),
VZCTL
);
_
(
"Could not exec %s"
),
VZCTL
);
goto
cleanup
;
goto
cleanup
;
...
@@ -1022,7 +1022,7 @@ openvzDomainUndefine(virDomainPtr dom)
...
@@ -1022,7 +1022,7 @@ openvzDomainUndefine(virDomainPtr dom)
}
}
openvzSetProgramSentinal
(
prog
,
vm
->
def
->
name
);
openvzSetProgramSentinal
(
prog
,
vm
->
def
->
name
);
if
(
virRun
(
dom
->
conn
,
prog
,
NULL
)
<
0
)
{
if
(
virRun
(
prog
,
NULL
)
<
0
)
{
openvzError
(
dom
->
conn
,
VIR_ERR_INTERNAL_ERROR
,
openvzError
(
dom
->
conn
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"Could not exec %s"
),
VZCTL
);
_
(
"Could not exec %s"
),
VZCTL
);
goto
cleanup
;
goto
cleanup
;
...
@@ -1059,7 +1059,7 @@ openvzDomainSetAutostart(virDomainPtr dom, int autostart)
...
@@ -1059,7 +1059,7 @@ openvzDomainSetAutostart(virDomainPtr dom, int autostart)
}
}
openvzSetProgramSentinal
(
prog
,
vm
->
def
->
name
);
openvzSetProgramSentinal
(
prog
,
vm
->
def
->
name
);
if
(
virRun
(
dom
->
conn
,
prog
,
NULL
)
<
0
)
{
if
(
virRun
(
prog
,
NULL
)
<
0
)
{
openvzError
(
dom
->
conn
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"Could not exec %s"
),
VZCTL
);
openvzError
(
dom
->
conn
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"Could not exec %s"
),
VZCTL
);
goto
cleanup
;
goto
cleanup
;
}
}
...
@@ -1136,7 +1136,7 @@ static int openvzDomainSetVcpusInternal(virConnectPtr conn, virDomainObjPtr vm,
...
@@ -1136,7 +1136,7 @@ static int openvzDomainSetVcpusInternal(virConnectPtr conn, virDomainObjPtr vm,
str_vcpus
[
31
]
=
'\0'
;
str_vcpus
[
31
]
=
'\0'
;
openvzSetProgramSentinal
(
prog
,
vm
->
def
->
name
);
openvzSetProgramSentinal
(
prog
,
vm
->
def
->
name
);
if
(
virRun
(
conn
,
prog
,
NULL
)
<
0
)
{
if
(
virRun
(
prog
,
NULL
)
<
0
)
{
openvzError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
openvzError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"Could not exec %s"
),
VZCTL
);
_
(
"Could not exec %s"
),
VZCTL
);
return
-
1
;
return
-
1
;
...
@@ -1301,7 +1301,7 @@ static int openvzListDomains(virConnectPtr conn, int *ids, int nids) {
...
@@ -1301,7 +1301,7 @@ static int openvzListDomains(virConnectPtr conn, int *ids, int nids) {
char
*
endptr
;
char
*
endptr
;
const
char
*
cmd
[]
=
{
VZLIST
,
"-ovpsid"
,
"-H"
,
NULL
};
const
char
*
cmd
[]
=
{
VZLIST
,
"-ovpsid"
,
"-H"
,
NULL
};
ret
=
virExec
(
c
onn
,
c
md
,
NULL
,
NULL
,
ret
=
virExec
(
cmd
,
NULL
,
NULL
,
&
pid
,
-
1
,
&
outfd
,
&
errfd
,
VIR_EXEC_NONE
);
&
pid
,
-
1
,
&
outfd
,
&
errfd
,
VIR_EXEC_NONE
);
if
(
ret
==
-
1
)
{
if
(
ret
==
-
1
)
{
openvzError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
openvzError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
...
@@ -1347,7 +1347,7 @@ static int openvzListDefinedDomains(virConnectPtr conn,
...
@@ -1347,7 +1347,7 @@ static int openvzListDefinedDomains(virConnectPtr conn,
const
char
*
cmd
[]
=
{
VZLIST
,
"-ovpsid"
,
"-H"
,
"-S"
,
NULL
};
const
char
*
cmd
[]
=
{
VZLIST
,
"-ovpsid"
,
"-H"
,
"-S"
,
NULL
};
/* the -S options lists only stopped domains */
/* the -S options lists only stopped domains */
ret
=
virExec
(
c
onn
,
c
md
,
NULL
,
NULL
,
ret
=
virExec
(
cmd
,
NULL
,
NULL
,
&
pid
,
-
1
,
&
outfd
,
&
errfd
,
VIR_EXEC_NONE
);
&
pid
,
-
1
,
&
outfd
,
&
errfd
,
VIR_EXEC_NONE
);
if
(
ret
==
-
1
)
{
if
(
ret
==
-
1
)
{
openvzError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
openvzError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
...
@@ -1447,7 +1447,7 @@ openvzDomainSetMemoryInternal(virConnectPtr conn, virDomainObjPtr vm,
...
@@ -1447,7 +1447,7 @@ openvzDomainSetMemoryInternal(virConnectPtr conn, virDomainObjPtr vm,
snprintf
(
str_mem
,
sizeof
(
str_mem
),
"%lu"
,
mem
*
1024
);
snprintf
(
str_mem
,
sizeof
(
str_mem
),
"%lu"
,
mem
*
1024
);
openvzSetProgramSentinal
(
prog
,
vm
->
def
->
name
);
openvzSetProgramSentinal
(
prog
,
vm
->
def
->
name
);
if
(
virRun
(
conn
,
prog
,
NULL
)
<
0
)
{
if
(
virRun
(
prog
,
NULL
)
<
0
)
{
openvzError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
openvzError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"Could not exec %s"
),
VZCTL
);
_
(
"Could not exec %s"
),
VZCTL
);
goto
cleanup
;
goto
cleanup
;
...
...
src/phyp/phyp_driver.c
浏览文件 @
f972dc2d
...
@@ -253,7 +253,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
...
@@ -253,7 +253,7 @@ openSSHSession(virConnectPtr conn, virConnectAuthPtr auth,
int
ret
;
int
ret
;
char
*
pubkey
=
NULL
;
char
*
pubkey
=
NULL
;
char
*
pvtkey
=
NULL
;
char
*
pvtkey
=
NULL
;
char
*
userhome
=
virGetUserDirectory
(
NULL
,
geteuid
());
char
*
userhome
=
virGetUserDirectory
(
geteuid
());
struct
stat
pvt_stat
,
pub_stat
;
struct
stat
pvt_stat
,
pub_stat
;
if
(
userhome
==
NULL
)
if
(
userhome
==
NULL
)
...
...
src/qemu/qemu_conf.c
浏览文件 @
f972dc2d
...
@@ -217,7 +217,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
...
@@ -217,7 +217,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
virConfFree
(
conf
);
virConfFree
(
conf
);
return
-
1
;
return
-
1
;
}
}
if
(
virGetUserID
(
NULL
,
user
,
&
driver
->
user
)
<
0
)
{
if
(
virGetUserID
(
user
,
&
driver
->
user
)
<
0
)
{
VIR_FREE
(
user
);
VIR_FREE
(
user
);
virConfFree
(
conf
);
virConfFree
(
conf
);
return
-
1
;
return
-
1
;
...
@@ -232,7 +232,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
...
@@ -232,7 +232,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
virConfFree
(
conf
);
virConfFree
(
conf
);
return
-
1
;
return
-
1
;
}
}
if
(
virGetGroupID
(
NULL
,
group
,
&
driver
->
group
)
<
0
)
{
if
(
virGetGroupID
(
group
,
&
driver
->
group
)
<
0
)
{
VIR_FREE
(
group
);
VIR_FREE
(
group
);
virConfFree
(
conf
);
virConfFree
(
conf
);
return
-
1
;
return
-
1
;
...
@@ -485,7 +485,7 @@ qemudProbeMachineTypes(const char *binary,
...
@@ -485,7 +485,7 @@ qemudProbeMachineTypes(const char *binary,
int
newstdout
=
-
1
,
len
;
int
newstdout
=
-
1
,
len
;
int
ret
=
-
1
,
status
;
int
ret
=
-
1
,
status
;
if
(
virExec
(
NULL
,
qemuarg
,
qemuenv
,
NULL
,
if
(
virExec
(
qemuarg
,
qemuenv
,
NULL
,
&
child
,
-
1
,
&
newstdout
,
NULL
,
VIR_EXEC_CLEAR_CAPS
)
<
0
)
&
child
,
-
1
,
&
newstdout
,
NULL
,
VIR_EXEC_CLEAR_CAPS
)
<
0
)
return
-
1
;
return
-
1
;
...
@@ -719,7 +719,7 @@ qemudProbeCPUModels(const char *qemu,
...
@@ -719,7 +719,7 @@ qemudProbeCPUModels(const char *qemu,
return
0
;
return
0
;
}
}
if
(
virExec
(
NULL
,
qemuarg
,
qemuenv
,
NULL
,
if
(
virExec
(
qemuarg
,
qemuenv
,
NULL
,
&
child
,
-
1
,
&
newstdout
,
NULL
,
VIR_EXEC_CLEAR_CAPS
)
<
0
)
&
child
,
-
1
,
&
newstdout
,
NULL
,
VIR_EXEC_CLEAR_CAPS
)
<
0
)
return
-
1
;
return
-
1
;
...
@@ -1330,7 +1330,7 @@ int qemudExtractVersionInfo(const char *qemu,
...
@@ -1330,7 +1330,7 @@ int qemudExtractVersionInfo(const char *qemu,
if
(
retversion
)
if
(
retversion
)
*
retversion
=
0
;
*
retversion
=
0
;
if
(
virExec
(
NULL
,
qemuarg
,
qemuenv
,
NULL
,
if
(
virExec
(
qemuarg
,
qemuenv
,
NULL
,
&
child
,
-
1
,
&
newstdout
,
NULL
,
VIR_EXEC_CLEAR_CAPS
)
<
0
)
&
child
,
-
1
,
&
newstdout
,
NULL
,
VIR_EXEC_CLEAR_CAPS
)
<
0
)
return
-
1
;
return
-
1
;
...
...
src/qemu/qemu_driver.c
浏览文件 @
f972dc2d
...
@@ -1033,7 +1033,7 @@ qemudStartup(int privileged) {
...
@@ -1033,7 +1033,7 @@ qemudStartup(int privileged) {
goto
out_of_memory
;
goto
out_of_memory
;
}
else
{
}
else
{
uid_t
uid
=
geteuid
();
uid_t
uid
=
geteuid
();
char
*
userdir
=
virGetUserDirectory
(
NULL
,
uid
);
char
*
userdir
=
virGetUserDirectory
(
uid
);
if
(
!
userdir
)
if
(
!
userdir
)
goto
error
;
goto
error
;
...
@@ -2691,7 +2691,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
...
@@ -2691,7 +2691,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
for
(
i
=
0
;
i
<
ntapfds
;
i
++
)
for
(
i
=
0
;
i
<
ntapfds
;
i
++
)
FD_SET
(
tapfds
[
i
],
&
keepfd
);
FD_SET
(
tapfds
[
i
],
&
keepfd
);
ret
=
virExecDaemonize
(
conn
,
argv
,
progenv
,
&
keepfd
,
&
child
,
ret
=
virExecDaemonize
(
argv
,
progenv
,
&
keepfd
,
&
child
,
stdin_fd
,
&
logfile
,
&
logfile
,
stdin_fd
,
&
logfile
,
&
logfile
,
VIR_EXEC_NONBLOCK
|
VIR_EXEC_CLEAR_CAPS
,
VIR_EXEC_NONBLOCK
|
VIR_EXEC_CLEAR_CAPS
,
qemudSecurityHook
,
&
hookData
,
qemudSecurityHook
,
&
hookData
,
...
@@ -4556,7 +4556,7 @@ static int qemudDomainRestore(virConnectPtr conn,
...
@@ -4556,7 +4556,7 @@ static int qemudDomainRestore(virConnectPtr conn,
intermediate_argv
[
0
]
=
prog
;
intermediate_argv
[
0
]
=
prog
;
intermediatefd
=
fd
;
intermediatefd
=
fd
;
fd
=
-
1
;
fd
=
-
1
;
if
(
virExec
(
conn
,
intermediate_argv
,
NULL
,
NULL
,
if
(
virExec
(
intermediate_argv
,
NULL
,
NULL
,
&
intermediate_pid
,
intermediatefd
,
&
fd
,
NULL
,
0
)
<
0
)
{
&
intermediate_pid
,
intermediatefd
,
&
fd
,
NULL
,
0
)
<
0
)
{
qemudReportError
(
conn
,
NULL
,
NULL
,
VIR_ERR_INTERNAL_ERROR
,
qemudReportError
(
conn
,
NULL
,
NULL
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"Failed to start decompression binary %s"
),
_
(
"Failed to start decompression binary %s"
),
...
...
src/remote/remote_driver.c
浏览文件 @
f972dc2d
...
@@ -330,7 +330,7 @@ remoteForkDaemon(virConnectPtr conn)
...
@@ -330,7 +330,7 @@ remoteForkDaemon(virConnectPtr conn)
return
-
1
;
return
-
1
;
}
}
if
(
virExecDaemonize
(
NULL
,
daemonargs
,
NULL
,
NULL
,
if
(
virExecDaemonize
(
daemonargs
,
NULL
,
NULL
,
&
pid
,
-
1
,
NULL
,
NULL
,
&
pid
,
-
1
,
NULL
,
NULL
,
VIR_EXEC_CLEAR_CAPS
,
VIR_EXEC_CLEAR_CAPS
,
NULL
,
NULL
,
NULL
)
<
0
)
NULL
,
NULL
,
NULL
)
<
0
)
...
@@ -656,7 +656,7 @@ doRemoteOpen (virConnectPtr conn,
...
@@ -656,7 +656,7 @@ doRemoteOpen (virConnectPtr conn,
case
trans_unix
:
{
case
trans_unix
:
{
if
(
!
sockname
)
{
if
(
!
sockname
)
{
if
(
flags
&
VIR_DRV_OPEN_REMOTE_USER
)
{
if
(
flags
&
VIR_DRV_OPEN_REMOTE_USER
)
{
char
*
userdir
=
virGetUserDirectory
(
conn
,
getuid
());
char
*
userdir
=
virGetUserDirectory
(
getuid
());
if
(
!
userdir
)
if
(
!
userdir
)
goto
failed
;
goto
failed
;
...
@@ -793,7 +793,7 @@ doRemoteOpen (virConnectPtr conn,
...
@@ -793,7 +793,7 @@ doRemoteOpen (virConnectPtr conn,
goto
failed
;
goto
failed
;
}
}
if
(
virExec
(
conn
,
(
const
char
**
)
cmd_argv
,
NULL
,
NULL
,
if
(
virExec
((
const
char
**
)
cmd_argv
,
NULL
,
NULL
,
&
pid
,
sv
[
1
],
&
(
sv
[
1
]),
NULL
,
&
pid
,
sv
[
1
],
&
(
sv
[
1
]),
NULL
,
VIR_EXEC_CLEAR_CAPS
)
<
0
)
VIR_EXEC_CLEAR_CAPS
)
<
0
)
goto
failed
;
goto
failed
;
...
...
src/secret/secret_driver.c
浏览文件 @
f972dc2d
...
@@ -1003,7 +1003,7 @@ secretDriverStartup(int privileged)
...
@@ -1003,7 +1003,7 @@ secretDriverStartup(int privileged)
goto
out_of_memory
;
goto
out_of_memory
;
}
else
{
}
else
{
uid_t
uid
=
geteuid
();
uid_t
uid
=
geteuid
();
char
*
userdir
=
virGetUserDirectory
(
NULL
,
uid
);
char
*
userdir
=
virGetUserDirectory
(
uid
);
if
(
!
userdir
)
if
(
!
userdir
)
goto
error
;
goto
error
;
...
...
src/security/security_apparmor.c
浏览文件 @
f972dc2d
...
@@ -173,19 +173,19 @@ load_profile(virConnectPtr conn, const char *profile, virDomainObjPtr vm,
...
@@ -173,19 +173,19 @@ load_profile(virConnectPtr conn, const char *profile, virDomainObjPtr vm,
const
char
*
const
argv
[]
=
{
const
char
*
const
argv
[]
=
{
VIRT_AA_HELPER
,
"-c"
,
"-u"
,
profile
,
NULL
VIRT_AA_HELPER
,
"-c"
,
"-u"
,
profile
,
NULL
};
};
ret
=
virExec
(
conn
,
argv
,
NULL
,
NULL
,
&
child
,
ret
=
virExec
(
argv
,
NULL
,
NULL
,
&
child
,
pipefd
[
0
],
NULL
,
NULL
,
VIR_EXEC_CLEAR_CAPS
);
pipefd
[
0
],
NULL
,
NULL
,
VIR_EXEC_CLEAR_CAPS
);
}
else
if
(
disk
&&
disk
->
src
)
{
}
else
if
(
disk
&&
disk
->
src
)
{
const
char
*
const
argv
[]
=
{
const
char
*
const
argv
[]
=
{
VIRT_AA_HELPER
,
"-r"
,
"-u"
,
profile
,
"-f"
,
disk
->
src
,
NULL
VIRT_AA_HELPER
,
"-r"
,
"-u"
,
profile
,
"-f"
,
disk
->
src
,
NULL
};
};
ret
=
virExec
(
conn
,
argv
,
NULL
,
NULL
,
&
child
,
ret
=
virExec
(
argv
,
NULL
,
NULL
,
&
child
,
pipefd
[
0
],
NULL
,
NULL
,
VIR_EXEC_CLEAR_CAPS
);
pipefd
[
0
],
NULL
,
NULL
,
VIR_EXEC_CLEAR_CAPS
);
}
else
{
}
else
{
const
char
*
const
argv
[]
=
{
const
char
*
const
argv
[]
=
{
VIRT_AA_HELPER
,
"-r"
,
"-u"
,
profile
,
NULL
VIRT_AA_HELPER
,
"-r"
,
"-u"
,
profile
,
NULL
};
};
ret
=
virExec
(
conn
,
argv
,
NULL
,
NULL
,
&
child
,
ret
=
virExec
(
argv
,
NULL
,
NULL
,
&
child
,
pipefd
[
0
],
NULL
,
NULL
,
VIR_EXEC_CLEAR_CAPS
);
pipefd
[
0
],
NULL
,
NULL
,
VIR_EXEC_CLEAR_CAPS
);
}
}
if
(
ret
<
0
)
if
(
ret
<
0
)
...
@@ -230,7 +230,7 @@ remove_profile(const char *profile)
...
@@ -230,7 +230,7 @@ remove_profile(const char *profile)
VIRT_AA_HELPER
,
"-R"
,
"-u"
,
profile
,
NULL
VIRT_AA_HELPER
,
"-R"
,
"-u"
,
profile
,
NULL
};
};
if
(
virRun
(
NULL
,
argv
,
NULL
)
==
0
)
if
(
virRun
(
argv
,
NULL
)
==
0
)
rc
=
0
;
rc
=
0
;
return
rc
;
return
rc
;
...
...
src/security/virt-aa-helper.c
浏览文件 @
f972dc2d
...
@@ -203,7 +203,7 @@ parserCommand(const char *profile_name, const char cmd)
...
@@ -203,7 +203,7 @@ parserCommand(const char *profile_name, const char cmd)
const
char
*
const
argv
[]
=
{
const
char
*
const
argv
[]
=
{
"/sbin/apparmor_parser"
,
flag
,
profile
,
NULL
"/sbin/apparmor_parser"
,
flag
,
profile
,
NULL
};
};
if
(
virRun
(
NULL
,
argv
,
NULL
)
!=
0
)
{
if
(
virRun
(
argv
,
NULL
)
!=
0
)
{
vah_error
(
NULL
,
0
,
"failed to run apparmor_parser"
);
vah_error
(
NULL
,
0
,
"failed to run apparmor_parser"
);
return
-
1
;
return
-
1
;
}
}
...
...
src/storage/storage_backend.c
浏览文件 @
f972dc2d
...
@@ -509,8 +509,7 @@ static int virStorageBuildSetUIDHook(void *data) {
...
@@ -509,8 +509,7 @@ static int virStorageBuildSetUIDHook(void *data) {
return
0
;
return
0
;
}
}
static
int
virStorageBackendCreateExecCommand
(
virConnectPtr
conn
,
static
int
virStorageBackendCreateExecCommand
(
virStoragePoolObjPtr
pool
,
virStoragePoolObjPtr
pool
,
virStorageVolDefPtr
vol
,
virStorageVolDefPtr
vol
,
const
char
**
cmdargv
)
{
const
char
**
cmdargv
)
{
struct
stat
st
;
struct
stat
st
;
...
@@ -521,7 +520,7 @@ static int virStorageBackendCreateExecCommand(virConnectPtr conn,
...
@@ -521,7 +520,7 @@ static int virStorageBackendCreateExecCommand(virConnectPtr conn,
if
((
pool
->
def
->
type
==
VIR_STORAGE_POOL_NETFS
)
if
((
pool
->
def
->
type
==
VIR_STORAGE_POOL_NETFS
)
&&
(
getuid
()
==
0
)
&&
(
getuid
()
==
0
)
&&
((
vol
->
target
.
perms
.
uid
!=
0
)
||
(
vol
->
target
.
perms
.
gid
!=
0
)))
{
&&
((
vol
->
target
.
perms
.
uid
!=
0
)
||
(
vol
->
target
.
perms
.
gid
!=
0
)))
{
if
(
virRunWithHook
(
c
onn
,
c
mdargv
,
if
(
virRunWithHook
(
cmdargv
,
virStorageBuildSetUIDHook
,
vol
,
NULL
)
==
0
)
{
virStorageBuildSetUIDHook
,
vol
,
NULL
)
==
0
)
{
/* command was successfully run, check if the file was created */
/* command was successfully run, check if the file was created */
if
(
stat
(
vol
->
target
.
path
,
&
st
)
>=
0
)
if
(
stat
(
vol
->
target
.
path
,
&
st
)
>=
0
)
...
@@ -529,7 +528,7 @@ static int virStorageBackendCreateExecCommand(virConnectPtr conn,
...
@@ -529,7 +528,7 @@ static int virStorageBackendCreateExecCommand(virConnectPtr conn,
}
}
}
}
if
(
!
filecreated
)
{
if
(
!
filecreated
)
{
if
(
virRun
(
c
onn
,
c
mdargv
,
NULL
)
<
0
)
{
if
(
virRun
(
cmdargv
,
NULL
)
<
0
)
{
virReportSystemError
(
errno
,
virReportSystemError
(
errno
,
_
(
"Cannot run %s to create %s"
),
_
(
"Cannot run %s to create %s"
),
cmdargv
[
0
],
vol
->
target
.
path
);
cmdargv
[
0
],
vol
->
target
.
path
);
...
@@ -727,7 +726,7 @@ virStorageBackendCreateQemuImg(virConnectPtr conn,
...
@@ -727,7 +726,7 @@ virStorageBackendCreateQemuImg(virConnectPtr conn,
/* Size in KB */
/* Size in KB */
snprintf
(
size
,
sizeof
(
size
),
"%lluK"
,
vol
->
capacity
/
1024
);
snprintf
(
size
,
sizeof
(
size
),
"%lluK"
,
vol
->
capacity
/
1024
);
ret
=
virStorageBackendCreateExecCommand
(
conn
,
pool
,
vol
,
imgargv
);
ret
=
virStorageBackendCreateExecCommand
(
pool
,
vol
,
imgargv
);
VIR_FREE
(
imgargv
[
0
]);
VIR_FREE
(
imgargv
[
0
]);
return
ret
;
return
ret
;
...
@@ -781,7 +780,7 @@ virStorageBackendCreateQcowCreate(virConnectPtr conn,
...
@@ -781,7 +780,7 @@ virStorageBackendCreateQcowCreate(virConnectPtr conn,
imgargv
[
2
]
=
vol
->
target
.
path
;
imgargv
[
2
]
=
vol
->
target
.
path
;
imgargv
[
3
]
=
NULL
;
imgargv
[
3
]
=
NULL
;
ret
=
virStorageBackendCreateExecCommand
(
conn
,
pool
,
vol
,
imgargv
);
ret
=
virStorageBackendCreateExecCommand
(
pool
,
vol
,
imgargv
);
VIR_FREE
(
imgargv
[
0
]);
VIR_FREE
(
imgargv
[
0
]);
return
ret
;
return
ret
;
...
@@ -1250,7 +1249,7 @@ virStorageBackendRunProgRegex(virConnectPtr conn,
...
@@ -1250,7 +1249,7 @@ virStorageBackendRunProgRegex(virConnectPtr conn,
/* Run the program and capture its output */
/* Run the program and capture its output */
if
(
virExec
(
conn
,
prog
,
NULL
,
NULL
,
if
(
virExec
(
prog
,
NULL
,
NULL
,
&
child
,
-
1
,
&
fd
,
NULL
,
VIR_EXEC_NONE
)
<
0
)
{
&
child
,
-
1
,
&
fd
,
NULL
,
VIR_EXEC_NONE
)
<
0
)
{
goto
cleanup
;
goto
cleanup
;
}
}
...
@@ -1386,7 +1385,7 @@ virStorageBackendRunProgNul(virConnectPtr conn,
...
@@ -1386,7 +1385,7 @@ virStorageBackendRunProgNul(virConnectPtr conn,
v
[
i
]
=
NULL
;
v
[
i
]
=
NULL
;
/* Run the program and capture its output */
/* Run the program and capture its output */
if
(
virExec
(
conn
,
prog
,
NULL
,
NULL
,
if
(
virExec
(
prog
,
NULL
,
NULL
,
&
child
,
-
1
,
&
fd
,
NULL
,
VIR_EXEC_NONE
)
<
0
)
{
&
child
,
-
1
,
&
fd
,
NULL
,
VIR_EXEC_NONE
)
<
0
)
{
goto
cleanup
;
goto
cleanup
;
}
}
...
...
src/storage/storage_backend_disk.c
浏览文件 @
f972dc2d
...
@@ -323,7 +323,7 @@ virStorageBackendDiskRefreshPool(virConnectPtr conn,
...
@@ -323,7 +323,7 @@ virStorageBackendDiskRefreshPool(virConnectPtr conn,
VIR_FREE
(
pool
->
def
->
source
.
devices
[
0
].
freeExtents
);
VIR_FREE
(
pool
->
def
->
source
.
devices
[
0
].
freeExtents
);
pool
->
def
->
source
.
devices
[
0
].
nfreeExtent
=
0
;
pool
->
def
->
source
.
devices
[
0
].
nfreeExtent
=
0
;
virFileWaitForDevices
(
conn
);
virFileWaitForDevices
();
if
(
virStorageBackendDiskReadGeometry
(
conn
,
pool
)
!=
0
)
{
if
(
virStorageBackendDiskReadGeometry
(
conn
,
pool
)
!=
0
)
{
return
-
1
;
return
-
1
;
...
@@ -337,7 +337,7 @@ virStorageBackendDiskRefreshPool(virConnectPtr conn,
...
@@ -337,7 +337,7 @@ virStorageBackendDiskRefreshPool(virConnectPtr conn,
* Write a new partition table header
* Write a new partition table header
*/
*/
static
int
static
int
virStorageBackendDiskBuildPool
(
virConnectPtr
conn
,
virStorageBackendDiskBuildPool
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
virStoragePoolObjPtr
pool
,
virStoragePoolObjPtr
pool
,
unsigned
int
flags
ATTRIBUTE_UNUSED
)
unsigned
int
flags
ATTRIBUTE_UNUSED
)
{
{
...
@@ -352,7 +352,7 @@ virStorageBackendDiskBuildPool(virConnectPtr conn,
...
@@ -352,7 +352,7 @@ virStorageBackendDiskBuildPool(virConnectPtr conn,
NULL
,
NULL
,
};
};
if
(
virRun
(
conn
,
prog
,
NULL
)
<
0
)
if
(
virRun
(
prog
,
NULL
)
<
0
)
return
-
1
;
return
-
1
;
return
0
;
return
0
;
...
@@ -577,11 +577,11 @@ virStorageBackendDiskCreateVol(virConnectPtr conn,
...
@@ -577,11 +577,11 @@ virStorageBackendDiskCreateVol(virConnectPtr conn,
snprintf
(
end
,
sizeof
(
end
)
-
1
,
"%lluB"
,
endOffset
);
snprintf
(
end
,
sizeof
(
end
)
-
1
,
"%lluB"
,
endOffset
);
end
[
sizeof
(
end
)
-
1
]
=
'\0'
;
end
[
sizeof
(
end
)
-
1
]
=
'\0'
;
if
(
virRun
(
c
onn
,
c
mdargv
,
NULL
)
<
0
)
if
(
virRun
(
cmdargv
,
NULL
)
<
0
)
return
-
1
;
return
-
1
;
/* wait for device node to show up */
/* wait for device node to show up */
virFileWaitForDevices
(
conn
);
virFileWaitForDevices
();
/* Blow away free extent info, as we're about to re-populate it */
/* Blow away free extent info, as we're about to re-populate it */
VIR_FREE
(
pool
->
def
->
source
.
devices
[
0
].
freeExtents
);
VIR_FREE
(
pool
->
def
->
source
.
devices
[
0
].
freeExtents
);
...
@@ -662,7 +662,7 @@ virStorageBackendDiskDeleteVol(virConnectPtr conn,
...
@@ -662,7 +662,7 @@ virStorageBackendDiskDeleteVol(virConnectPtr conn,
NULL
,
NULL
,
};
};
if
(
virRun
(
conn
,
prog
,
NULL
)
<
0
)
if
(
virRun
(
prog
,
NULL
)
<
0
)
goto
cleanup
;
goto
cleanup
;
rc
=
0
;
rc
=
0
;
...
...
src/storage/storage_backend_fs.c
浏览文件 @
f972dc2d
...
@@ -403,7 +403,7 @@ virStorageBackendFileSystemMount(virConnectPtr conn,
...
@@ -403,7 +403,7 @@ virStorageBackendFileSystemMount(virConnectPtr conn,
mntargv
[
option_index
]
=
options
;
mntargv
[
option_index
]
=
options
;
}
}
if
(
virRun
(
conn
,
mntargv
,
NULL
)
<
0
)
{
if
(
virRun
(
mntargv
,
NULL
)
<
0
)
{
VIR_FREE
(
src
);
VIR_FREE
(
src
);
return
-
1
;
return
-
1
;
}
}
...
@@ -457,7 +457,7 @@ virStorageBackendFileSystemUnmount(virConnectPtr conn,
...
@@ -457,7 +457,7 @@ virStorageBackendFileSystemUnmount(virConnectPtr conn,
mntargv
[
1
]
=
pool
->
def
->
target
.
path
;
mntargv
[
1
]
=
pool
->
def
->
target
.
path
;
mntargv
[
2
]
=
NULL
;
mntargv
[
2
]
=
NULL
;
if
(
virRun
(
conn
,
mntargv
,
NULL
)
<
0
)
{
if
(
virRun
(
mntargv
,
NULL
)
<
0
)
{
return
-
1
;
return
-
1
;
}
}
return
0
;
return
0
;
...
...
src/storage/storage_backend_iscsi.c
浏览文件 @
f972dc2d
...
@@ -182,7 +182,7 @@ virStorageBackendIQNFound(virConnectPtr conn,
...
@@ -182,7 +182,7 @@ virStorageBackendIQNFound(virConnectPtr conn,
memset
(
line
,
0
,
LINE_SIZE
);
memset
(
line
,
0
,
LINE_SIZE
);
if
(
virExec
(
conn
,
prog
,
NULL
,
NULL
,
&
child
,
-
1
,
&
fd
,
NULL
,
VIR_EXEC_NONE
)
<
0
)
{
if
(
virExec
(
prog
,
NULL
,
NULL
,
&
child
,
-
1
,
&
fd
,
NULL
,
VIR_EXEC_NONE
)
<
0
)
{
virStorageReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
virStorageReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"Failed to run '%s' when looking for existing interface with IQN '%s'"
),
_
(
"Failed to run '%s' when looking for existing interface with IQN '%s'"
),
prog
[
0
],
pool
->
def
->
source
.
initiator
.
iqn
);
prog
[
0
],
pool
->
def
->
source
.
initiator
.
iqn
);
...
@@ -279,7 +279,7 @@ virStorageBackendCreateIfaceIQN(virConnectPtr conn,
...
@@ -279,7 +279,7 @@ virStorageBackendCreateIfaceIQN(virConnectPtr conn,
* tools returned an exit status of > 0, even if they succeeded.
* tools returned an exit status of > 0, even if they succeeded.
* We will just rely on whether the interface got created
* We will just rely on whether the interface got created
* properly. */
* properly. */
if
(
virRun
(
c
onn
,
c
mdargv1
,
&
exitstatus
)
<
0
)
{
if
(
virRun
(
cmdargv1
,
&
exitstatus
)
<
0
)
{
virStorageReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
virStorageReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"Failed to run command '%s' to create new iscsi interface"
),
_
(
"Failed to run command '%s' to create new iscsi interface"
),
cmdargv1
[
0
]);
cmdargv1
[
0
]);
...
@@ -295,7 +295,7 @@ virStorageBackendCreateIfaceIQN(virConnectPtr conn,
...
@@ -295,7 +295,7 @@ virStorageBackendCreateIfaceIQN(virConnectPtr conn,
/* Note that we ignore the exitstatus. Older versions of iscsiadm tools
/* Note that we ignore the exitstatus. Older versions of iscsiadm tools
* returned an exit status of > 0, even if they succeeded. We will just
* returned an exit status of > 0, even if they succeeded. We will just
* rely on whether iface file got updated properly. */
* rely on whether iface file got updated properly. */
if
(
virRun
(
c
onn
,
c
mdargv2
,
&
exitstatus
)
<
0
)
{
if
(
virRun
(
cmdargv2
,
&
exitstatus
)
<
0
)
{
virStorageReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
virStorageReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"Failed to run command '%s' to update iscsi interface with IQN '%s'"
),
_
(
"Failed to run command '%s' to update iscsi interface with IQN '%s'"
),
cmdargv1
[
0
],
pool
->
def
->
source
.
initiator
.
iqn
);
cmdargv1
[
0
],
pool
->
def
->
source
.
initiator
.
iqn
);
...
@@ -348,7 +348,7 @@ virStorageBackendISCSIConnectionIQN(virConnectPtr conn,
...
@@ -348,7 +348,7 @@ virStorageBackendISCSIConnectionIQN(virConnectPtr conn,
const
char
*
const
sendtargets
[]
=
{
const
char
*
const
sendtargets
[]
=
{
ISCSIADM
,
"--mode"
,
"discovery"
,
"--type"
,
"sendtargets"
,
"--portal"
,
portal
,
NULL
ISCSIADM
,
"--mode"
,
"discovery"
,
"--type"
,
"sendtargets"
,
"--portal"
,
portal
,
NULL
};
};
if
(
virRun
(
conn
,
sendtargets
,
NULL
)
<
0
)
{
if
(
virRun
(
sendtargets
,
NULL
)
<
0
)
{
virStorageReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
virStorageReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"Failed to run %s to get target list"
),
_
(
"Failed to run %s to get target list"
),
sendtargets
[
0
]);
sendtargets
[
0
]);
...
@@ -361,7 +361,7 @@ virStorageBackendISCSIConnectionIQN(virConnectPtr conn,
...
@@ -361,7 +361,7 @@ virStorageBackendISCSIConnectionIQN(virConnectPtr conn,
ifacename
,
action
,
NULL
ifacename
,
action
,
NULL
};
};
if
(
virRun
(
c
onn
,
c
mdargv
,
NULL
)
<
0
)
{
if
(
virRun
(
cmdargv
,
NULL
)
<
0
)
{
virStorageReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
virStorageReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
_
(
"Failed to run command '%s' with action '%s'"
),
_
(
"Failed to run command '%s' with action '%s'"
),
cmdargv
[
0
],
action
);
cmdargv
[
0
],
action
);
...
@@ -395,7 +395,7 @@ virStorageBackendISCSIConnection(virConnectPtr conn,
...
@@ -395,7 +395,7 @@ virStorageBackendISCSIConnection(virConnectPtr conn,
"--targetname"
,
pool
->
def
->
source
.
devices
[
0
].
path
,
action
,
NULL
"--targetname"
,
pool
->
def
->
source
.
devices
[
0
].
path
,
action
,
NULL
};
};
if
(
virRun
(
c
onn
,
c
mdargv
,
NULL
)
<
0
)
{
if
(
virRun
(
cmdargv
,
NULL
)
<
0
)
{
ret
=
-
1
;
ret
=
-
1
;
}
}
...
@@ -417,7 +417,7 @@ virStorageBackendISCSIFindLUs(virConnectPtr conn,
...
@@ -417,7 +417,7 @@ virStorageBackendISCSIFindLUs(virConnectPtr conn,
snprintf
(
sysfs_path
,
PATH_MAX
,
snprintf
(
sysfs_path
,
PATH_MAX
,
"/sys/class/iscsi_session/session%s/device"
,
session
);
"/sys/class/iscsi_session/session%s/device"
,
session
);
if
(
virStorageBackendSCSIGetHostNumber
(
conn
,
sysfs_path
,
&
host
)
<
0
)
{
if
(
virStorageBackendSCSIGetHostNumber
(
sysfs_path
,
&
host
)
<
0
)
{
virReportSystemError
(
errno
,
virReportSystemError
(
errno
,
_
(
"Failed to get host number for iSCSI session "
_
(
"Failed to get host number for iSCSI session "
"with path '%s'"
),
"with path '%s'"
),
...
@@ -435,7 +435,7 @@ virStorageBackendISCSIFindLUs(virConnectPtr conn,
...
@@ -435,7 +435,7 @@ virStorageBackendISCSIFindLUs(virConnectPtr conn,
}
}
static
int
static
int
virStorageBackendISCSIRescanLUNs
(
virConnectPtr
conn
,
virStorageBackendISCSIRescanLUNs
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
virStoragePoolObjPtr
pool
ATTRIBUTE_UNUSED
,
virStoragePoolObjPtr
pool
ATTRIBUTE_UNUSED
,
const
char
*
session
)
const
char
*
session
)
{
{
...
@@ -443,7 +443,7 @@ virStorageBackendISCSIRescanLUNs(virConnectPtr conn,
...
@@ -443,7 +443,7 @@ virStorageBackendISCSIRescanLUNs(virConnectPtr conn,
ISCSIADM
,
"--mode"
,
"session"
,
"-r"
,
session
,
"-R"
,
NULL
,
ISCSIADM
,
"--mode"
,
"session"
,
"-r"
,
session
,
"-R"
,
NULL
,
};
};
if
(
virRun
(
c
onn
,
c
mdargv
,
NULL
)
<
0
)
if
(
virRun
(
cmdargv
,
NULL
)
<
0
)
return
-
1
;
return
-
1
;
return
0
;
return
0
;
...
@@ -460,7 +460,7 @@ virStorageBackendISCSILogin(virConnectPtr conn,
...
@@ -460,7 +460,7 @@ virStorageBackendISCSILogin(virConnectPtr conn,
"--portal"
,
portal
,
NULL
"--portal"
,
portal
,
NULL
};
};
if
(
virRun
(
c
onn
,
c
mdsendtarget
,
NULL
)
<
0
)
if
(
virRun
(
cmdsendtarget
,
NULL
)
<
0
)
return
-
1
;
return
-
1
;
return
virStorageBackendISCSIConnection
(
conn
,
pool
,
portal
,
"--login"
);
return
virStorageBackendISCSIConnection
(
conn
,
pool
,
portal
,
"--login"
);
...
...
src/storage/storage_backend_logical.c
浏览文件 @
f972dc2d
...
@@ -44,8 +44,7 @@
...
@@ -44,8 +44,7 @@
static
int
static
int
virStorageBackendLogicalSetActive
(
virConnectPtr
conn
,
virStorageBackendLogicalSetActive
(
virStoragePoolObjPtr
pool
,
virStoragePoolObjPtr
pool
,
int
on
)
int
on
)
{
{
const
char
*
cmdargv
[
4
];
const
char
*
cmdargv
[
4
];
...
@@ -55,7 +54,7 @@ virStorageBackendLogicalSetActive(virConnectPtr conn,
...
@@ -55,7 +54,7 @@ virStorageBackendLogicalSetActive(virConnectPtr conn,
cmdargv
[
2
]
=
pool
->
def
->
source
.
name
;
cmdargv
[
2
]
=
pool
->
def
->
source
.
name
;
cmdargv
[
3
]
=
NULL
;
cmdargv
[
3
]
=
NULL
;
if
(
virRun
(
c
onn
,
c
mdargv
,
NULL
)
<
0
)
if
(
virRun
(
cmdargv
,
NULL
)
<
0
)
return
-
1
;
return
-
1
;
return
0
;
return
0
;
...
@@ -337,7 +336,7 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr conn,
...
@@ -337,7 +336,7 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr conn,
* that might be hanging around, so if this fails for some reason, the
* that might be hanging around, so if this fails for some reason, the
* worst that happens is that scanning doesn't pick everything up
* worst that happens is that scanning doesn't pick everything up
*/
*/
if
(
virRun
(
conn
,
scanprog
,
&
exitstatus
)
<
0
)
{
if
(
virRun
(
scanprog
,
&
exitstatus
)
<
0
)
{
VIR_WARN0
(
"Failure when running vgscan to refresh physical volumes"
);
VIR_WARN0
(
"Failure when running vgscan to refresh physical volumes"
);
}
}
...
@@ -367,10 +366,10 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr conn,
...
@@ -367,10 +366,10 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr conn,
static
int
static
int
virStorageBackendLogicalStartPool
(
virConnectPtr
conn
,
virStorageBackendLogicalStartPool
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
virStoragePoolObjPtr
pool
)
virStoragePoolObjPtr
pool
)
{
{
if
(
virStorageBackendLogicalSetActive
(
conn
,
pool
,
1
)
<
0
)
if
(
virStorageBackendLogicalSetActive
(
pool
,
1
)
<
0
)
return
-
1
;
return
-
1
;
return
0
;
return
0
;
...
@@ -378,7 +377,7 @@ virStorageBackendLogicalStartPool(virConnectPtr conn,
...
@@ -378,7 +377,7 @@ virStorageBackendLogicalStartPool(virConnectPtr conn,
static
int
static
int
virStorageBackendLogicalBuildPool
(
virConnectPtr
conn
,
virStorageBackendLogicalBuildPool
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
virStoragePoolObjPtr
pool
,
virStoragePoolObjPtr
pool
,
unsigned
int
flags
ATTRIBUTE_UNUSED
)
unsigned
int
flags
ATTRIBUTE_UNUSED
)
{
{
...
@@ -431,14 +430,14 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn,
...
@@ -431,14 +430,14 @@ virStorageBackendLogicalBuildPool(virConnectPtr conn,
*/
*/
vgargv
[
n
++
]
=
pool
->
def
->
source
.
devices
[
i
].
path
;
vgargv
[
n
++
]
=
pool
->
def
->
source
.
devices
[
i
].
path
;
pvargv
[
1
]
=
pool
->
def
->
source
.
devices
[
i
].
path
;
pvargv
[
1
]
=
pool
->
def
->
source
.
devices
[
i
].
path
;
if
(
virRun
(
conn
,
pvargv
,
NULL
)
<
0
)
if
(
virRun
(
pvargv
,
NULL
)
<
0
)
goto
cleanup
;
goto
cleanup
;
}
}
vgargv
[
n
]
=
NULL
;
vgargv
[
n
]
=
NULL
;
/* Now create the volume group itself */
/* Now create the volume group itself */
if
(
virRun
(
conn
,
vgargv
,
NULL
)
<
0
)
if
(
virRun
(
vgargv
,
NULL
)
<
0
)
goto
cleanup
;
goto
cleanup
;
VIR_FREE
(
vgargv
);
VIR_FREE
(
vgargv
);
...
@@ -476,7 +475,7 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn,
...
@@ -476,7 +475,7 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn,
};
};
int
exitstatus
;
int
exitstatus
;
virFileWaitForDevices
(
conn
);
virFileWaitForDevices
();
/* Get list of all logical volumes */
/* Get list of all logical volumes */
if
(
virStorageBackendLogicalFindLVs
(
conn
,
pool
,
NULL
)
<
0
)
{
if
(
virStorageBackendLogicalFindLVs
(
conn
,
pool
,
NULL
)
<
0
)
{
...
@@ -512,17 +511,17 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn,
...
@@ -512,17 +511,17 @@ virStorageBackendLogicalRefreshPool(virConnectPtr conn,
* "Can't deactivate volume group "VolGroup00" with 3 open logical volume(s)"
* "Can't deactivate volume group "VolGroup00" with 3 open logical volume(s)"
*/
*/
static
int
static
int
virStorageBackendLogicalStopPool
(
virConnectPtr
conn
,
virStorageBackendLogicalStopPool
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
virStoragePoolObjPtr
pool
)
virStoragePoolObjPtr
pool
)
{
{
if
(
virStorageBackendLogicalSetActive
(
conn
,
pool
,
0
)
<
0
)
if
(
virStorageBackendLogicalSetActive
(
pool
,
0
)
<
0
)
return
-
1
;
return
-
1
;
return
0
;
return
0
;
}
}
static
int
static
int
virStorageBackendLogicalDeletePool
(
virConnectPtr
conn
,
virStorageBackendLogicalDeletePool
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
virStoragePoolObjPtr
pool
,
virStoragePoolObjPtr
pool
,
unsigned
int
flags
ATTRIBUTE_UNUSED
)
unsigned
int
flags
ATTRIBUTE_UNUSED
)
{
{
...
@@ -533,7 +532,7 @@ virStorageBackendLogicalDeletePool(virConnectPtr conn,
...
@@ -533,7 +532,7 @@ virStorageBackendLogicalDeletePool(virConnectPtr conn,
int
i
,
error
;
int
i
,
error
;
/* first remove the volume group */
/* first remove the volume group */
if
(
virRun
(
c
onn
,
c
mdargv
,
NULL
)
<
0
)
if
(
virRun
(
cmdargv
,
NULL
)
<
0
)
return
-
1
;
return
-
1
;
/* now remove the pv devices and clear them out */
/* now remove the pv devices and clear them out */
...
@@ -542,7 +541,7 @@ virStorageBackendLogicalDeletePool(virConnectPtr conn,
...
@@ -542,7 +541,7 @@ virStorageBackendLogicalDeletePool(virConnectPtr conn,
pvargv
[
2
]
=
NULL
;
pvargv
[
2
]
=
NULL
;
for
(
i
=
0
;
i
<
pool
->
def
->
source
.
ndevice
;
i
++
)
{
for
(
i
=
0
;
i
<
pool
->
def
->
source
.
ndevice
;
i
++
)
{
pvargv
[
1
]
=
pool
->
def
->
source
.
devices
[
i
].
path
;
pvargv
[
1
]
=
pool
->
def
->
source
.
devices
[
i
].
path
;
if
(
virRun
(
conn
,
pvargv
,
NULL
)
<
0
)
{
if
(
virRun
(
pvargv
,
NULL
)
<
0
)
{
error
=
-
1
;
error
=
-
1
;
virReportSystemError
(
errno
,
virReportSystemError
(
errno
,
_
(
"cannot remove PV device '%s'"
),
_
(
"cannot remove PV device '%s'"
),
...
@@ -607,7 +606,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn,
...
@@ -607,7 +606,7 @@ virStorageBackendLogicalCreateVol(virConnectPtr conn,
return
-
1
;
return
-
1
;
}
}
if
(
virRun
(
c
onn
,
c
mdargv
,
NULL
)
<
0
)
if
(
virRun
(
cmdargv
,
NULL
)
<
0
)
return
-
1
;
return
-
1
;
if
((
fd
=
open
(
vol
->
target
.
path
,
O_RDONLY
))
<
0
)
{
if
((
fd
=
open
(
vol
->
target
.
path
,
O_RDONLY
))
<
0
)
{
...
@@ -675,7 +674,7 @@ virStorageBackendLogicalBuildVolFrom(virConnectPtr conn,
...
@@ -675,7 +674,7 @@ virStorageBackendLogicalBuildVolFrom(virConnectPtr conn,
}
}
static
int
static
int
virStorageBackendLogicalDeleteVol
(
virConnectPtr
conn
,
virStorageBackendLogicalDeleteVol
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
,
virStoragePoolObjPtr
pool
ATTRIBUTE_UNUSED
,
virStoragePoolObjPtr
pool
ATTRIBUTE_UNUSED
,
virStorageVolDefPtr
vol
,
virStorageVolDefPtr
vol
,
unsigned
int
flags
ATTRIBUTE_UNUSED
)
unsigned
int
flags
ATTRIBUTE_UNUSED
)
...
@@ -684,7 +683,7 @@ virStorageBackendLogicalDeleteVol(virConnectPtr conn,
...
@@ -684,7 +683,7 @@ virStorageBackendLogicalDeleteVol(virConnectPtr conn,
LVREMOVE
,
"-f"
,
vol
->
target
.
path
,
NULL
LVREMOVE
,
"-f"
,
vol
->
target
.
path
,
NULL
};
};
if
(
virRun
(
c
onn
,
c
mdargv
,
NULL
)
<
0
)
if
(
virRun
(
cmdargv
,
NULL
)
<
0
)
return
-
1
;
return
-
1
;
return
0
;
return
0
;
...
...
src/storage/storage_backend_mpath.c
浏览文件 @
f972dc2d
...
@@ -329,7 +329,7 @@ virStorageBackendMpathRefreshPool(virConnectPtr conn,
...
@@ -329,7 +329,7 @@ virStorageBackendMpathRefreshPool(virConnectPtr conn,
pool
->
def
->
allocation
=
pool
->
def
->
capacity
=
pool
->
def
->
available
=
0
;
pool
->
def
->
allocation
=
pool
->
def
->
capacity
=
pool
->
def
->
available
=
0
;
virFileWaitForDevices
(
conn
);
virFileWaitForDevices
();
virStorageBackendGetMaps
(
conn
,
pool
);
virStorageBackendGetMaps
(
conn
,
pool
);
...
...
src/storage/storage_backend_scsi.c
浏览文件 @
f972dc2d
...
@@ -505,7 +505,7 @@ virStorageBackendSCSIFindLUs(virConnectPtr conn,
...
@@ -505,7 +505,7 @@ virStorageBackendSCSIFindLUs(virConnectPtr conn,
VIR_DEBUG
(
_
(
"Discovering LUs on host %u"
),
scanhost
);
VIR_DEBUG
(
_
(
"Discovering LUs on host %u"
),
scanhost
);
virFileWaitForDevices
(
conn
);
virFileWaitForDevices
();
if
(
virAsprintf
(
&
device_path
,
"/sys/bus/scsi/devices"
)
<
0
)
{
if
(
virAsprintf
(
&
device_path
,
"/sys/bus/scsi/devices"
)
<
0
)
{
virReportOOMError
();
virReportOOMError
();
...
@@ -543,8 +543,7 @@ out:
...
@@ -543,8 +543,7 @@ out:
int
int
virStorageBackendSCSIGetHostNumber
(
virConnectPtr
conn
,
virStorageBackendSCSIGetHostNumber
(
const
char
*
sysfs_path
,
const
char
*
sysfs_path
,
uint32_t
*
host
)
uint32_t
*
host
)
{
{
int
retval
=
0
;
int
retval
=
0
;
...
@@ -553,7 +552,7 @@ virStorageBackendSCSIGetHostNumber(virConnectPtr conn,
...
@@ -553,7 +552,7 @@ virStorageBackendSCSIGetHostNumber(virConnectPtr conn,
VIR_DEBUG
(
_
(
"Finding host number from '%s'"
),
sysfs_path
);
VIR_DEBUG
(
_
(
"Finding host number from '%s'"
),
sysfs_path
);
virFileWaitForDevices
(
conn
);
virFileWaitForDevices
();
sysdir
=
opendir
(
sysfs_path
);
sysdir
=
opendir
(
sysfs_path
);
...
...
src/storage/storage_backend_scsi.h
浏览文件 @
f972dc2d
...
@@ -33,8 +33,7 @@
...
@@ -33,8 +33,7 @@
extern
virStorageBackend
virStorageBackendSCSI
;
extern
virStorageBackend
virStorageBackendSCSI
;
int
int
virStorageBackendSCSIGetHostNumber
(
virConnectPtr
conn
,
virStorageBackendSCSIGetHostNumber
(
const
char
*
sysfs_path
,
const
char
*
sysfs_path
,
uint32_t
*
host
);
uint32_t
*
host
);
int
int
virStorageBackendSCSIFindLUs
(
virConnectPtr
conn
,
virStorageBackendSCSIFindLUs
(
virConnectPtr
conn
,
...
...
src/storage/storage_driver.c
浏览文件 @
f972dc2d
...
@@ -124,7 +124,7 @@ storageDriverStartup(int privileged) {
...
@@ -124,7 +124,7 @@ storageDriverStartup(int privileged) {
goto
out_of_memory
;
goto
out_of_memory
;
}
else
{
}
else
{
uid_t
uid
=
geteuid
();
uid_t
uid
=
geteuid
();
char
*
userdir
=
virGetUserDirectory
(
NULL
,
uid
);
char
*
userdir
=
virGetUserDirectory
(
uid
);
if
(
!
userdir
)
if
(
!
userdir
)
goto
error
;
goto
error
;
...
...
src/uml/uml_driver.c
浏览文件 @
f972dc2d
...
@@ -365,7 +365,7 @@ umlStartup(int privileged) {
...
@@ -365,7 +365,7 @@ umlStartup(int privileged) {
if
(
virDomainObjListInit
(
&
uml_driver
->
domains
)
<
0
)
if
(
virDomainObjListInit
(
&
uml_driver
->
domains
)
<
0
)
goto
error
;
goto
error
;
userdir
=
virGetUserDirectory
(
NULL
,
uid
);
userdir
=
virGetUserDirectory
(
uid
);
if
(
!
userdir
)
if
(
!
userdir
)
goto
error
;
goto
error
;
...
@@ -899,7 +899,7 @@ static int umlStartVMDaemon(virConnectPtr conn,
...
@@ -899,7 +899,7 @@ static int umlStartVMDaemon(virConnectPtr conn,
priv
->
monitor
=
-
1
;
priv
->
monitor
=
-
1
;
ret
=
virExecDaemonize
(
conn
,
argv
,
progenv
,
&
keepfd
,
&
pid
,
ret
=
virExecDaemonize
(
argv
,
progenv
,
&
keepfd
,
&
pid
,
-
1
,
&
logfd
,
&
logfd
,
-
1
,
&
logfd
,
&
logfd
,
VIR_EXEC_CLEAR_CAPS
,
VIR_EXEC_CLEAR_CAPS
,
NULL
,
NULL
,
NULL
);
NULL
,
NULL
,
NULL
);
...
...
src/util/bridge.c
浏览文件 @
f972dc2d
...
@@ -792,7 +792,7 @@ brSetForwardDelay(brControl *ctl ATTRIBUTE_UNUSED,
...
@@ -792,7 +792,7 @@ brSetForwardDelay(brControl *ctl ATTRIBUTE_UNUSED,
snprintf
(
delayStr
,
sizeof
(
delayStr
),
"%d"
,
delay
);
snprintf
(
delayStr
,
sizeof
(
delayStr
),
"%d"
,
delay
);
if
(
virRun
(
NULL
,
progargv
,
NULL
)
<
0
)
if
(
virRun
(
progargv
,
NULL
)
<
0
)
return
-
1
;
return
-
1
;
return
0
;
return
0
;
...
@@ -819,7 +819,7 @@ brSetEnableSTP(brControl *ctl ATTRIBUTE_UNUSED,
...
@@ -819,7 +819,7 @@ brSetEnableSTP(brControl *ctl ATTRIBUTE_UNUSED,
BRCTL
,
"stp"
,
bridge
,
setting
,
NULL
BRCTL
,
"stp"
,
bridge
,
setting
,
NULL
};
};
if
(
virRun
(
NULL
,
progargv
,
NULL
)
<
0
)
if
(
virRun
(
progargv
,
NULL
)
<
0
)
return
-
1
;
return
-
1
;
return
0
;
return
0
;
...
...
src/util/cgroup.c
浏览文件 @
f972dc2d
...
@@ -533,7 +533,7 @@ static int virCgroupAppRoot(int privileged,
...
@@ -533,7 +533,7 @@ static int virCgroupAppRoot(int privileged,
}
else
{
}
else
{
char
*
rootname
;
char
*
rootname
;
char
*
username
;
char
*
username
;
username
=
virGetUserName
(
NULL
,
getuid
());
username
=
virGetUserName
(
getuid
());
if
(
!
username
)
{
if
(
!
username
)
{
rc
=
-
ENOMEM
;
rc
=
-
ENOMEM
;
goto
cleanup
;
goto
cleanup
;
...
...
src/util/ebtables.c
浏览文件 @
f972dc2d
...
@@ -228,7 +228,7 @@ ebtablesAddRemoveRule(ebtRules *rules, int action, const char *arg, ...)
...
@@ -228,7 +228,7 @@ ebtablesAddRemoveRule(ebtRules *rules, int action, const char *arg, ...)
goto
error
;
goto
error
;
}
}
if
(
virRun
(
NULL
,
argv
,
NULL
)
<
0
)
{
if
(
virRun
(
argv
,
NULL
)
<
0
)
{
retval
=
errno
;
retval
=
errno
;
goto
error
;
goto
error
;
}
}
...
...
src/util/iptables.c
浏览文件 @
f972dc2d
...
@@ -146,7 +146,7 @@ iptablesAddRemoveRule(iptRules *rules, int action, const char *arg, ...)
...
@@ -146,7 +146,7 @@ iptablesAddRemoveRule(iptRules *rules, int action, const char *arg, ...)
va_end
(
args
);
va_end
(
args
);
if
(
virRun
(
NULL
,
argv
,
NULL
)
<
0
)
{
if
(
virRun
(
argv
,
NULL
)
<
0
)
{
retval
=
errno
;
retval
=
errno
;
goto
error
;
goto
error
;
}
}
...
...
src/util/pci.c
浏览文件 @
f972dc2d
...
@@ -699,7 +699,7 @@ pciDeviceFile(char *buf, size_t buflen, const char *device, const char *file)
...
@@ -699,7 +699,7 @@ pciDeviceFile(char *buf, size_t buflen, const char *device, const char *file)
static
const
char
*
static
const
char
*
pciFindStubDriver
(
v
irConnectPtr
conn
)
pciFindStubDriver
(
v
oid
)
{
{
char
drvpath
[
PATH_MAX
];
char
drvpath
[
PATH_MAX
];
int
probed
=
0
;
int
probed
=
0
;
...
@@ -723,8 +723,8 @@ recheck:
...
@@ -723,8 +723,8 @@ recheck:
* On Xen though, we want to prefer pciback, so probe
* On Xen though, we want to prefer pciback, so probe
* for that first, because that will only work on Xen
* for that first, because that will only work on Xen
*/
*/
if
(
virRun
(
conn
,
backprobe
,
NULL
)
<
0
&&
if
(
virRun
(
backprobe
,
NULL
)
<
0
&&
virRun
(
conn
,
stubprobe
,
NULL
)
<
0
)
{
virRun
(
stubprobe
,
NULL
)
<
0
)
{
char
ebuf
[
1024
];
char
ebuf
[
1024
];
VIR_WARN
(
_
(
"failed to load pci-stub or pciback drivers: %s"
),
VIR_WARN
(
_
(
"failed to load pci-stub or pciback drivers: %s"
),
virStrerror
(
errno
,
ebuf
,
sizeof
ebuf
));
virStrerror
(
errno
,
ebuf
,
sizeof
ebuf
));
...
@@ -812,7 +812,7 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver)
...
@@ -812,7 +812,7 @@ pciBindDeviceToStub(pciDevice *dev, const char *driver)
int
int
pciDettachDevice
(
virConnectPtr
conn
,
pciDevice
*
dev
)
pciDettachDevice
(
virConnectPtr
conn
,
pciDevice
*
dev
)
{
{
const
char
*
driver
=
pciFindStubDriver
(
conn
);
const
char
*
driver
=
pciFindStubDriver
();
if
(
!
driver
)
{
if
(
!
driver
)
{
pciReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
pciReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"cannot find any PCI stub module"
));
_
(
"cannot find any PCI stub module"
));
...
@@ -873,7 +873,7 @@ pciUnBindDeviceFromStub(pciDevice *dev, const char *driver)
...
@@ -873,7 +873,7 @@ pciUnBindDeviceFromStub(pciDevice *dev, const char *driver)
int
int
pciReAttachDevice
(
virConnectPtr
conn
,
pciDevice
*
dev
)
pciReAttachDevice
(
virConnectPtr
conn
,
pciDevice
*
dev
)
{
{
const
char
*
driver
=
pciFindStubDriver
(
conn
);
const
char
*
driver
=
pciFindStubDriver
();
if
(
!
driver
)
{
if
(
!
driver
)
{
pciReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
pciReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"cannot find any PCI stub module"
));
_
(
"cannot find any PCI stub module"
));
...
...
src/util/util.c
浏览文件 @
f972dc2d
...
@@ -84,9 +84,9 @@
...
@@ -84,9 +84,9 @@
#define VIR_FROM_THIS VIR_FROM_NONE
#define VIR_FROM_THIS VIR_FROM_NONE
#define
ReportError(conn, code, fmt...)
\
#define
virUtilError(code, fmt...)
\
virReportErrorHelper(
conn
, VIR_FROM_NONE, code, __FILE__, \
virReportErrorHelper(
NULL
, VIR_FROM_NONE, code, __FILE__, \
__FUNCTION__, __LINE__, fmt)
__FUNCTION__, __LINE__, fmt)
/* Like read(), but restarts after EINTR */
/* Like read(), but restarts after EINTR */
int
saferead
(
int
fd
,
void
*
buf
,
size_t
count
)
int
saferead
(
int
fd
,
void
*
buf
,
size_t
count
)
...
@@ -297,7 +297,6 @@ static int virClearCapabilities(void)
...
@@ -297,7 +297,6 @@ static int virClearCapabilities(void)
#endif
#endif
/*
/*
* @conn Connection to report errors against
* @argv argv to exec
* @argv argv to exec
* @envp optional environment to use for exec
* @envp optional environment to use for exec
* @keepfd options fd_ret to keep open for child process
* @keepfd options fd_ret to keep open for child process
...
@@ -318,8 +317,7 @@ static int virClearCapabilities(void)
...
@@ -318,8 +317,7 @@ static int virClearCapabilities(void)
* @pidfile path to use as pidfile for daemonized process (needs DAEMON flag)
* @pidfile path to use as pidfile for daemonized process (needs DAEMON flag)
*/
*/
static
int
static
int
__virExec
(
virConnectPtr
conn
,
__virExec
(
const
char
*
const
*
argv
,
const
char
*
const
*
argv
,
const
char
*
const
*
envp
,
const
char
*
const
*
envp
,
const
fd_set
*
keepfd
,
const
fd_set
*
keepfd
,
pid_t
*
retpid
,
pid_t
*
retpid
,
...
@@ -454,9 +452,6 @@ __virExec(virConnectPtr conn,
...
@@ -454,9 +452,6 @@ __virExec(virConnectPtr conn,
/* child */
/* child */
/* Don't want to report errors against this accidentally, so
just discard it */
conn
=
NULL
;
/* Remove any error callback too, so errors in child now
/* Remove any error callback too, so errors in child now
get sent to stderr where they stand a fighting chance
get sent to stderr where they stand a fighting chance
of being seen / logged */
of being seen / logged */
...
@@ -593,7 +588,7 @@ __virExec(virConnectPtr conn,
...
@@ -593,7 +588,7 @@ __virExec(virConnectPtr conn,
/* This is cleanup of parent process only - child
/* This is cleanup of parent process only - child
should never jump here on error */
should never jump here on error */
/* NB we don't
Report
Error() on any failures here
/* NB we don't
virUtil
Error() on any failures here
because the code which jumped hre already raised
because the code which jumped hre already raised
an error condition which we must not overwrite */
an error condition which we must not overwrite */
if
(
pipeerr
[
0
]
>
0
)
if
(
pipeerr
[
0
]
>
0
)
...
@@ -610,8 +605,7 @@ __virExec(virConnectPtr conn,
...
@@ -610,8 +605,7 @@ __virExec(virConnectPtr conn,
}
}
int
int
virExecWithHook
(
virConnectPtr
conn
,
virExecWithHook
(
const
char
*
const
*
argv
,
const
char
*
const
*
argv
,
const
char
*
const
*
envp
,
const
char
*
const
*
envp
,
const
fd_set
*
keepfd
,
const
fd_set
*
keepfd
,
pid_t
*
retpid
,
pid_t
*
retpid
,
...
@@ -642,7 +636,7 @@ virExecWithHook(virConnectPtr conn,
...
@@ -642,7 +636,7 @@ virExecWithHook(virConnectPtr conn,
}
}
VIR_FREE
(
argv_str
);
VIR_FREE
(
argv_str
);
return
__virExec
(
conn
,
argv
,
envp
,
keepfd
,
retpid
,
infd
,
outfd
,
errfd
,
return
__virExec
(
argv
,
envp
,
keepfd
,
retpid
,
infd
,
outfd
,
errfd
,
flags
,
hook
,
data
,
pidfile
);
flags
,
hook
,
data
,
pidfile
);
}
}
...
@@ -654,15 +648,14 @@ virExecWithHook(virConnectPtr conn,
...
@@ -654,15 +648,14 @@ virExecWithHook(virConnectPtr conn,
* list.
* list.
*/
*/
int
int
virExec
(
virConnectPtr
conn
,
virExec
(
const
char
*
const
*
argv
,
const
char
*
const
*
argv
,
const
char
*
const
*
envp
,
const
char
*
const
*
envp
,
const
fd_set
*
keepfd
,
const
fd_set
*
keepfd
,
pid_t
*
retpid
,
pid_t
*
retpid
,
int
infd
,
int
*
outfd
,
int
*
errfd
,
int
infd
,
int
*
outfd
,
int
*
errfd
,
int
flags
)
int
flags
)
{
{
return
virExecWithHook
(
conn
,
argv
,
envp
,
keepfd
,
retpid
,
return
virExecWithHook
(
argv
,
envp
,
keepfd
,
retpid
,
infd
,
outfd
,
errfd
,
infd
,
outfd
,
errfd
,
flags
,
NULL
,
NULL
,
NULL
);
flags
,
NULL
,
NULL
,
NULL
);
}
}
...
@@ -681,8 +674,7 @@ virExec(virConnectPtr conn,
...
@@ -681,8 +674,7 @@ virExec(virConnectPtr conn,
* occured and when in the process occured, the error output
* occured and when in the process occured, the error output
* could have gone to stderr or the passed errfd).
* could have gone to stderr or the passed errfd).
*/
*/
int
virExecDaemonize
(
virConnectPtr
conn
,
int
virExecDaemonize
(
const
char
*
const
*
argv
,
const
char
*
const
*
argv
,
const
char
*
const
*
envp
,
const
char
*
const
*
envp
,
const
fd_set
*
keepfd
,
const
fd_set
*
keepfd
,
pid_t
*
retpid
,
pid_t
*
retpid
,
...
@@ -694,7 +686,7 @@ int virExecDaemonize(virConnectPtr conn,
...
@@ -694,7 +686,7 @@ int virExecDaemonize(virConnectPtr conn,
int
ret
;
int
ret
;
int
childstat
=
0
;
int
childstat
=
0
;
ret
=
virExecWithHook
(
conn
,
argv
,
envp
,
keepfd
,
retpid
,
ret
=
virExecWithHook
(
argv
,
envp
,
keepfd
,
retpid
,
infd
,
outfd
,
errfd
,
infd
,
outfd
,
errfd
,
flags
|
VIR_EXEC_DAEMON
,
flags
|
VIR_EXEC_DAEMON
,
hook
,
data
,
pidfile
);
hook
,
data
,
pidfile
);
...
@@ -708,9 +700,9 @@ int virExecDaemonize(virConnectPtr conn,
...
@@ -708,9 +700,9 @@ int virExecDaemonize(virConnectPtr conn,
errno
==
EINTR
);
errno
==
EINTR
);
if
(
childstat
!=
0
)
{
if
(
childstat
!=
0
)
{
ReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
virUtilError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Intermediate daemon process exited with status %d."
),
_
(
"Intermediate daemon process exited with status %d."
),
WEXITSTATUS
(
childstat
));
WEXITSTATUS
(
childstat
));
ret
=
-
2
;
ret
=
-
2
;
}
}
...
@@ -718,7 +710,7 @@ int virExecDaemonize(virConnectPtr conn,
...
@@ -718,7 +710,7 @@ int virExecDaemonize(virConnectPtr conn,
}
}
static
int
static
int
virPipeReadUntilEOF
(
virConnectPtr
conn
,
int
outfd
,
int
errfd
,
virPipeReadUntilEOF
(
int
outfd
,
int
errfd
,
char
**
outbuf
,
char
**
errbuf
)
{
char
**
outbuf
,
char
**
errbuf
)
{
struct
pollfd
fds
[
2
];
struct
pollfd
fds
[
2
];
...
@@ -753,8 +745,8 @@ virPipeReadUntilEOF(virConnectPtr conn, int outfd, int errfd,
...
@@ -753,8 +745,8 @@ virPipeReadUntilEOF(virConnectPtr conn, int outfd, int errfd,
if
(
fds
[
i
].
revents
&
POLLHUP
)
if
(
fds
[
i
].
revents
&
POLLHUP
)
continue
;
continue
;
ReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
virUtilError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"Unknown poll response."
));
"%s"
,
_
(
"Unknown poll response."
));
goto
error
;
goto
error
;
}
}
...
@@ -798,7 +790,6 @@ error:
...
@@ -798,7 +790,6 @@ error:
}
}
/**
/**
* @conn connection to report errors against
* @argv NULL terminated argv to run
* @argv NULL terminated argv to run
* @status optional variable to return exit status in
* @status optional variable to return exit status in
*
*
...
@@ -813,8 +804,7 @@ error:
...
@@ -813,8 +804,7 @@ error:
* only if the command could not be run.
* only if the command could not be run.
*/
*/
int
int
virRunWithHook
(
virConnectPtr
conn
,
virRunWithHook
(
const
char
*
const
*
argv
,
const
char
*
const
*
argv
,
virExecHook
hook
,
virExecHook
hook
,
void
*
data
,
void
*
data
,
int
*
status
)
{
int
*
status
)
{
...
@@ -832,14 +822,14 @@ virRunWithHook(virConnectPtr conn,
...
@@ -832,14 +822,14 @@ virRunWithHook(virConnectPtr conn,
}
}
DEBUG0
(
argv_str
);
DEBUG0
(
argv_str
);
if
((
execret
=
__virExec
(
conn
,
argv
,
NULL
,
NULL
,
if
((
execret
=
__virExec
(
argv
,
NULL
,
NULL
,
&
childpid
,
-
1
,
&
outfd
,
&
errfd
,
&
childpid
,
-
1
,
&
outfd
,
&
errfd
,
VIR_EXEC_NONE
,
hook
,
data
,
NULL
))
<
0
)
{
VIR_EXEC_NONE
,
hook
,
data
,
NULL
))
<
0
)
{
ret
=
execret
;
ret
=
execret
;
goto
error
;
goto
error
;
}
}
if
(
virPipeReadUntilEOF
(
conn
,
outfd
,
errfd
,
&
outbuf
,
&
errbuf
)
<
0
)
{
if
(
virPipeReadUntilEOF
(
outfd
,
errfd
,
&
outbuf
,
&
errbuf
)
<
0
)
{
while
(
waitpid
(
childpid
,
&
exitstatus
,
0
)
==
-
1
&&
errno
==
EINTR
)
while
(
waitpid
(
childpid
,
&
exitstatus
,
0
)
==
-
1
&&
errno
==
EINTR
)
;
;
goto
error
;
goto
error
;
...
@@ -862,12 +852,12 @@ virRunWithHook(virConnectPtr conn,
...
@@ -862,12 +852,12 @@ virRunWithHook(virConnectPtr conn,
if
(
status
==
NULL
)
{
if
(
status
==
NULL
)
{
errno
=
EINVAL
;
errno
=
EINVAL
;
if
(
WIFEXITED
(
exitstatus
)
&&
WEXITSTATUS
(
exitstatus
)
!=
0
)
{
if
(
WIFEXITED
(
exitstatus
)
&&
WEXITSTATUS
(
exitstatus
)
!=
0
)
{
ReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
virUtilError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"'%s' exited with non-zero status %d and "
_
(
"'%s' exited with non-zero status %d and "
"signal %d: %s"
),
argv_str
,
"signal %d: %s"
),
argv_str
,
WIFEXITED
(
exitstatus
)
?
WEXITSTATUS
(
exitstatus
)
:
0
,
WIFEXITED
(
exitstatus
)
?
WEXITSTATUS
(
exitstatus
)
:
0
,
WIFSIGNALED
(
exitstatus
)
?
WTERMSIG
(
exitstatus
)
:
0
,
WIFSIGNALED
(
exitstatus
)
?
WTERMSIG
(
exitstatus
)
:
0
,
(
errbuf
?
errbuf
:
""
));
(
errbuf
?
errbuf
:
""
));
goto
error
;
goto
error
;
}
}
}
else
{
}
else
{
...
@@ -890,8 +880,7 @@ virRunWithHook(virConnectPtr conn,
...
@@ -890,8 +880,7 @@ virRunWithHook(virConnectPtr conn,
#else
/* __MINGW32__ */
#else
/* __MINGW32__ */
int
int
virRunWithHook
(
virConnectPtr
conn
,
virRunWithHook
(
const
char
*
const
*
argv
ATTRIBUTE_UNUSED
,
const
char
*
const
*
argv
ATTRIBUTE_UNUSED
,
virExecHook
hook
ATTRIBUTE_UNUSED
,
virExecHook
hook
ATTRIBUTE_UNUSED
,
void
*
data
ATTRIBUTE_UNUSED
,
void
*
data
ATTRIBUTE_UNUSED
,
int
*
status
)
int
*
status
)
...
@@ -899,13 +888,12 @@ virRunWithHook(virConnectPtr conn,
...
@@ -899,13 +888,12 @@ virRunWithHook(virConnectPtr conn,
if
(
status
)
if
(
status
)
*
status
=
ENOTSUP
;
*
status
=
ENOTSUP
;
else
else
ReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
__FUNCTION__
);
virUtilError
(
VIR_ERR_INTERNAL_ERROR
,
__FUNCTION__
);
return
-
1
;
return
-
1
;
}
}
int
int
virExec
(
virConnectPtr
conn
,
virExec
(
const
char
*
const
*
argv
ATTRIBUTE_UNUSED
,
const
char
*
const
*
argv
ATTRIBUTE_UNUSED
,
const
char
*
const
*
envp
ATTRIBUTE_UNUSED
,
const
char
*
const
*
envp
ATTRIBUTE_UNUSED
,
const
fd_set
*
keepfd
ATTRIBUTE_UNUSED
,
const
fd_set
*
keepfd
ATTRIBUTE_UNUSED
,
int
*
retpid
ATTRIBUTE_UNUSED
,
int
*
retpid
ATTRIBUTE_UNUSED
,
...
@@ -914,17 +902,16 @@ virExec(virConnectPtr conn,
...
@@ -914,17 +902,16 @@ virExec(virConnectPtr conn,
int
*
errfd
ATTRIBUTE_UNUSED
,
int
*
errfd
ATTRIBUTE_UNUSED
,
int
flags
ATTRIBUTE_UNUSED
)
int
flags
ATTRIBUTE_UNUSED
)
{
{
ReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
__FUNCTION__
);
virUtilError
(
VIR_ERR_INTERNAL_ERROR
,
__FUNCTION__
);
return
-
1
;
return
-
1
;
}
}
#endif
/* __MINGW32__ */
#endif
/* __MINGW32__ */
int
int
virRun
(
virConnectPtr
conn
,
virRun
(
const
char
*
const
*
argv
,
const
char
*
const
*
argv
,
int
*
status
)
{
int
*
status
)
{
return
virRunWithHook
(
conn
,
argv
,
NULL
,
NULL
,
status
);
return
virRunWithHook
(
argv
,
NULL
,
NULL
,
status
);
}
}
/* Like gnulib's fread_file, but read no more than the specified maximum
/* Like gnulib's fread_file, but read no more than the specified maximum
...
@@ -2178,8 +2165,8 @@ char *virIndexToDiskName(int idx, const char *prefix)
...
@@ -2178,8 +2165,8 @@ char *virIndexToDiskName(int idx, const char *prefix)
int
i
,
k
,
offset
;
int
i
,
k
,
offset
;
if
(
idx
<
0
)
{
if
(
idx
<
0
)
{
ReportError
(
NULL
,
VIR_ERR_INTERNAL_ERROR
,
virUtilError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"Disk index %d is negative"
),
idx
);
_
(
"Disk index %d is negative"
),
idx
);
return
NULL
;
return
NULL
;
}
}
...
@@ -2206,7 +2193,7 @@ char *virIndexToDiskName(int idx, const char *prefix)
...
@@ -2206,7 +2193,7 @@ char *virIndexToDiskName(int idx, const char *prefix)
#define AI_CANONIDN 0
#define AI_CANONIDN 0
#endif
#endif
char
*
virGetHostname
(
virConnectPtr
conn
)
char
*
virGetHostname
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
)
{
{
int
r
;
int
r
;
char
hostname
[
HOST_NAME_MAX
+
1
],
*
result
;
char
hostname
[
HOST_NAME_MAX
+
1
],
*
result
;
...
@@ -2225,14 +2212,14 @@ char *virGetHostname(virConnectPtr conn)
...
@@ -2225,14 +2212,14 @@ char *virGetHostname(virConnectPtr conn)
hints
.
ai_family
=
AF_UNSPEC
;
hints
.
ai_family
=
AF_UNSPEC
;
r
=
getaddrinfo
(
hostname
,
NULL
,
&
hints
,
&
info
);
r
=
getaddrinfo
(
hostname
,
NULL
,
&
hints
,
&
info
);
if
(
r
!=
0
)
{
if
(
r
!=
0
)
{
ReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
virUtilError
(
VIR_ERR_INTERNAL_ERROR
,
_
(
"getaddrinfo failed for '%s': %s"
),
_
(
"getaddrinfo failed for '%s': %s"
),
hostname
,
gai_strerror
(
r
));
hostname
,
gai_strerror
(
r
));
return
NULL
;
return
NULL
;
}
}
if
(
info
->
ai_canonname
==
NULL
)
{
if
(
info
->
ai_canonname
==
NULL
)
{
ReportError
(
conn
,
VIR_ERR_INTERNAL_ERROR
,
virUtilError
(
VIR_ERR_INTERNAL_ERROR
,
"%s"
,
_
(
"could not determine canonical host name"
));
"%s"
,
_
(
"could not determine canonical host name"
));
freeaddrinfo
(
info
);
freeaddrinfo
(
info
);
return
NULL
;
return
NULL
;
}
}
...
@@ -2386,21 +2373,18 @@ static char *virGetUserEnt(uid_t uid,
...
@@ -2386,21 +2373,18 @@ static char *virGetUserEnt(uid_t uid,
return
ret
;
return
ret
;
}
}
char
*
virGetUserDirectory
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
/*TEMPORARY*/
,
char
*
virGetUserDirectory
(
uid_t
uid
)
uid_t
uid
)
{
{
return
virGetUserEnt
(
uid
,
VIR_USER_ENT_DIRECTORY
);
return
virGetUserEnt
(
uid
,
VIR_USER_ENT_DIRECTORY
);
}
}
char
*
virGetUserName
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
/*TEMPORARY*/
,
char
*
virGetUserName
(
uid_t
uid
)
uid_t
uid
)
{
{
return
virGetUserEnt
(
uid
,
VIR_USER_ENT_NAME
);
return
virGetUserEnt
(
uid
,
VIR_USER_ENT_NAME
);
}
}
int
virGetUserID
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
/*TEMPORARY*/
,
int
virGetUserID
(
const
char
*
name
,
const
char
*
name
,
uid_t
*
uid
)
uid_t
*
uid
)
{
{
char
*
strbuf
;
char
*
strbuf
;
...
@@ -2442,8 +2426,7 @@ int virGetUserID(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/,
...
@@ -2442,8 +2426,7 @@ int virGetUserID(virConnectPtr conn ATTRIBUTE_UNUSED /*TEMPORARY*/,
}
}
int
virGetGroupID
(
virConnectPtr
conn
ATTRIBUTE_UNUSED
/*TEMPORARY*/
,
int
virGetGroupID
(
const
char
*
name
,
const
char
*
name
,
gid_t
*
gid
)
gid_t
*
gid
)
{
{
char
*
strbuf
;
char
*
strbuf
;
...
@@ -2521,7 +2504,7 @@ cleanup:
...
@@ -2521,7 +2504,7 @@ cleanup:
#ifndef PROXY
#ifndef PROXY
#if defined(UDEVADM) || defined(UDEVSETTLE)
#if defined(UDEVADM) || defined(UDEVSETTLE)
void
virFileWaitForDevices
(
v
irConnectPtr
conn
)
void
virFileWaitForDevices
(
v
oid
)
{
{
#ifdef UDEVADM
#ifdef UDEVADM
const
char
*
const
settleprog
[]
=
{
UDEVADM
,
"settle"
,
NULL
};
const
char
*
const
settleprog
[]
=
{
UDEVADM
,
"settle"
,
NULL
};
...
@@ -2539,11 +2522,11 @@ void virFileWaitForDevices(virConnectPtr conn)
...
@@ -2539,11 +2522,11 @@ void virFileWaitForDevices(virConnectPtr conn)
* If this fails for any reason, we still have the backup of polling for
* If this fails for any reason, we still have the backup of polling for
* 5 seconds for device nodes.
* 5 seconds for device nodes.
*/
*/
if
(
virRun
(
conn
,
settleprog
,
&
exitstatus
)
<
0
)
if
(
virRun
(
settleprog
,
&
exitstatus
)
<
0
)
{}
{}
}
}
#else
#else
void
virFileWaitForDevices
(
v
irConnectPtr
conn
ATTRIBUTE_UNUSED
)
{}
void
virFileWaitForDevices
(
v
oid
)
{}
#endif
#endif
#endif
#endif
...
...
src/util/util.h
浏览文件 @
f972dc2d
...
@@ -49,8 +49,7 @@ int virSetCloseExec(int fd) ATTRIBUTE_RETURN_CHECK;
...
@@ -49,8 +49,7 @@ int virSetCloseExec(int fd) ATTRIBUTE_RETURN_CHECK;
* after fork() but before execve() */
* after fork() but before execve() */
typedef
int
(
*
virExecHook
)(
void
*
data
);
typedef
int
(
*
virExecHook
)(
void
*
data
);
int
virExecDaemonize
(
virConnectPtr
conn
,
int
virExecDaemonize
(
const
char
*
const
*
argv
,
const
char
*
const
*
argv
,
const
char
*
const
*
envp
,
const
char
*
const
*
envp
,
const
fd_set
*
keepfd
,
const
fd_set
*
keepfd
,
pid_t
*
retpid
,
pid_t
*
retpid
,
...
@@ -59,8 +58,7 @@ int virExecDaemonize(virConnectPtr conn,
...
@@ -59,8 +58,7 @@ int virExecDaemonize(virConnectPtr conn,
virExecHook
hook
,
virExecHook
hook
,
void
*
data
,
void
*
data
,
char
*
pidfile
)
ATTRIBUTE_RETURN_CHECK
;
char
*
pidfile
)
ATTRIBUTE_RETURN_CHECK
;
int
virExecWithHook
(
virConnectPtr
conn
,
int
virExecWithHook
(
const
char
*
const
*
argv
,
const
char
*
const
*
argv
,
const
char
*
const
*
envp
,
const
char
*
const
*
envp
,
const
fd_set
*
keepfd
,
const
fd_set
*
keepfd
,
int
*
retpid
,
int
*
retpid
,
...
@@ -71,8 +69,7 @@ int virExecWithHook(virConnectPtr conn,
...
@@ -71,8 +69,7 @@ int virExecWithHook(virConnectPtr conn,
virExecHook
hook
,
virExecHook
hook
,
void
*
data
,
void
*
data
,
char
*
pidfile
)
ATTRIBUTE_RETURN_CHECK
;
char
*
pidfile
)
ATTRIBUTE_RETURN_CHECK
;
int
virExec
(
virConnectPtr
conn
,
int
virExec
(
const
char
*
const
*
argv
,
const
char
*
const
*
argv
,
const
char
*
const
*
envp
,
const
char
*
const
*
envp
,
const
fd_set
*
keepfd
,
const
fd_set
*
keepfd
,
pid_t
*
retpid
,
pid_t
*
retpid
,
...
@@ -80,8 +77,8 @@ int virExec(virConnectPtr conn,
...
@@ -80,8 +77,8 @@ int virExec(virConnectPtr conn,
int
*
outfd
,
int
*
outfd
,
int
*
errfd
,
int
*
errfd
,
int
flags
)
ATTRIBUTE_RETURN_CHECK
;
int
flags
)
ATTRIBUTE_RETURN_CHECK
;
int
virRun
(
virConnectPtr
conn
,
const
char
*
const
*
argv
,
int
*
status
)
ATTRIBUTE_RETURN_CHECK
;
int
virRun
(
const
char
*
const
*
argv
,
int
*
status
)
ATTRIBUTE_RETURN_CHECK
;
int
virRunWithHook
(
virConnectPtr
conn
,
const
char
*
const
*
argv
,
int
virRunWithHook
(
const
char
*
const
*
argv
,
virExecHook
hook
,
void
*
data
,
virExecHook
hook
,
void
*
data
,
int
*
status
)
ATTRIBUTE_RETURN_CHECK
;
int
*
status
)
ATTRIBUTE_RETURN_CHECK
;
...
@@ -241,15 +238,11 @@ char *virGetHostname(virConnectPtr conn);
...
@@ -241,15 +238,11 @@ char *virGetHostname(virConnectPtr conn);
int
virKillProcess
(
pid_t
pid
,
int
sig
);
int
virKillProcess
(
pid_t
pid
,
int
sig
);
#ifdef HAVE_GETPWUID_R
#ifdef HAVE_GETPWUID_R
char
*
virGetUserDirectory
(
virConnectPtr
conn
,
char
*
virGetUserDirectory
(
uid_t
uid
);
uid_t
uid
);
char
*
virGetUserName
(
uid_t
uid
);
char
*
virGetUserName
(
virConnectPtr
conn
,
int
virGetUserID
(
const
char
*
name
,
uid_t
uid
);
int
virGetUserID
(
virConnectPtr
conn
,
const
char
*
name
,
uid_t
*
uid
)
ATTRIBUTE_RETURN_CHECK
;
uid_t
*
uid
)
ATTRIBUTE_RETURN_CHECK
;
int
virGetGroupID
(
virConnectPtr
conn
,
int
virGetGroupID
(
const
char
*
name
,
const
char
*
name
,
gid_t
*
gid
)
ATTRIBUTE_RETURN_CHECK
;
gid_t
*
gid
)
ATTRIBUTE_RETURN_CHECK
;
#endif
#endif
...
@@ -260,7 +253,7 @@ int virRandom(int max);
...
@@ -260,7 +253,7 @@ int virRandom(int max);
char
*
virFileFindMountPoint
(
const
char
*
type
);
char
*
virFileFindMountPoint
(
const
char
*
type
);
#endif
#endif
void
virFileWaitForDevices
(
v
irConnectPtr
conn
);
void
virFileWaitForDevices
(
v
oid
);
#define virBuildPath(path, ...) virBuildPathInternal(path, __VA_ARGS__, NULL)
#define virBuildPath(path, ...) virBuildPathInternal(path, __VA_ARGS__, NULL)
int
virBuildPathInternal
(
char
**
path
,
...)
ATTRIBUTE_SENTINEL
;
int
virBuildPathInternal
(
char
**
path
,
...)
ATTRIBUTE_SENTINEL
;
...
...
src/xen/proxy_internal.c
浏览文件 @
f972dc2d
...
@@ -155,7 +155,7 @@ virProxyForkServer(void)
...
@@ -155,7 +155,7 @@ virProxyForkServer(void)
proxyarg
[
0
]
=
proxyPath
;
proxyarg
[
0
]
=
proxyPath
;
proxyarg
[
1
]
=
NULL
;
proxyarg
[
1
]
=
NULL
;
if
(
virExecDaemonize
(
NULL
,
proxyarg
,
NULL
,
NULL
,
if
(
virExecDaemonize
(
proxyarg
,
NULL
,
NULL
,
&
pid
,
-
1
,
NULL
,
NULL
,
0
,
&
pid
,
-
1
,
NULL
,
NULL
,
0
,
NULL
,
NULL
,
NULL
)
<
0
)
NULL
,
NULL
,
NULL
)
<
0
)
VIR_ERROR0
(
"Failed to fork libvirt_proxy"
);
VIR_ERROR0
(
"Failed to fork libvirt_proxy"
);
...
...
tools/virsh.c
浏览文件 @
f972dc2d
...
@@ -7172,7 +7172,7 @@ cmdCd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
...
@@ -7172,7 +7172,7 @@ cmdCd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
dir
=
vshCommandOptString
(
cmd
,
"dir"
,
&
found
);
dir
=
vshCommandOptString
(
cmd
,
"dir"
,
&
found
);
if
(
!
found
)
{
if
(
!
found
)
{
uid_t
uid
=
geteuid
();
uid_t
uid
=
geteuid
();
dir
=
virGetUserDirectory
(
NULL
,
uid
);
dir
=
virGetUserDirectory
(
uid
);
}
}
if
(
!
dir
)
if
(
!
dir
)
dir
=
"/"
;
dir
=
"/"
;
...
@@ -8773,7 +8773,7 @@ vshReadlineInit(vshControl *ctl)
...
@@ -8773,7 +8773,7 @@ vshReadlineInit(vshControl *ctl)
stifle_history
(
500
);
stifle_history
(
500
);
/* Prepare to read/write history from/to the ~/.virsh/history file */
/* Prepare to read/write history from/to the ~/.virsh/history file */
userdir
=
virGetUserDirectory
(
NULL
,
getuid
());
userdir
=
virGetUserDirectory
(
getuid
());
if
(
userdir
==
NULL
)
if
(
userdir
==
NULL
)
return
-
1
;
return
-
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录