Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
56965922
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,发现更多精彩内容 >>
提交
56965922
编写于
7月 04, 2013
作者:
M
Michal Privoznik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adapt to VIR_ALLOC and virAsprintf in src/lxc/*
上级
35048f31
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
71 addition
and
208 deletion
+71
-208
src/lxc/lxc_cgroup.c
src/lxc/lxc_cgroup.c
+1
-3
src/lxc/lxc_conf.c
src/lxc/lxc_conf.c
+1
-4
src/lxc/lxc_container.c
src/lxc/lxc_container.c
+19
-58
src/lxc/lxc_controller.c
src/lxc/lxc_controller.c
+11
-36
src/lxc/lxc_driver.c
src/lxc/lxc_driver.c
+23
-69
src/lxc/lxc_fuse.c
src/lxc/lxc_fuse.c
+3
-9
src/lxc/lxc_monitor.c
src/lxc/lxc_monitor.c
+1
-3
src/lxc/lxc_process.c
src/lxc/lxc_process.c
+12
-26
未找到文件。
src/lxc/lxc_cgroup.c
浏览文件 @
56965922
...
...
@@ -547,10 +547,8 @@ virCgroupPtr virLXCCgroupCreate(virDomainDefPtr def, bool startup)
if
(
!
def
->
resource
&&
startup
)
{
virDomainResourceDefPtr
res
;
if
(
VIR_ALLOC
(
res
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
res
)
<
0
)
goto
cleanup
;
}
if
(
VIR_STRDUP
(
res
->
partition
,
"/machine"
)
<
0
)
{
VIR_FREE
(
res
);
...
...
src/lxc/lxc_conf.c
浏览文件 @
56965922
...
...
@@ -117,7 +117,7 @@ virCapsPtr lxcCapsInit(virLXCDriverPtr driver)
if
(
STRNEQ
(
model
,
"none"
))
{
/* Allocate just the primary security driver for LXC. */
if
(
VIR_ALLOC
(
caps
->
host
.
secModels
)
<
0
)
goto
no_memory
;
goto
error
;
caps
->
host
.
nsecModels
=
1
;
if
(
VIR_STRDUP
(
caps
->
host
.
secModels
[
0
].
model
,
model
)
<
0
)
goto
error
;
...
...
@@ -133,9 +133,6 @@ virCapsPtr lxcCapsInit(virLXCDriverPtr driver)
return
caps
;
no_memory:
virReportOOMError
();
error:
virObjectUnref
(
caps
);
return
NULL
;
...
...
src/lxc/lxc_container.c
浏览文件 @
56965922
...
...
@@ -158,10 +158,8 @@ int lxcContainerHasReboot(void)
VIR_FREE
(
buf
);
cmd
=
v
?
LINUX_REBOOT_CMD_CAD_ON
:
LINUX_REBOOT_CMD_CAD_OFF
;
if
(
VIR_ALLOC_N
(
stack
,
getpagesize
()
*
4
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
stack
,
getpagesize
()
*
4
)
<
0
)
return
-
1
;
}
childStack
=
stack
+
(
getpagesize
()
*
4
);
...
...
@@ -383,7 +381,6 @@ static int lxcContainerRenameAndEnableInterfaces(bool privNet,
for
(
i
=
0
;
i
<
nveths
;
i
++
)
{
if
(
virAsprintf
(
&
newname
,
"eth%zu"
,
i
)
<
0
)
{
virReportOOMError
();
rc
=
-
1
;
goto
error_out
;
}
...
...
@@ -467,10 +464,8 @@ static int lxcContainerGetSubtree(const char *prefix,
if
(
!
STRPREFIX
(
mntent
.
mnt_dir
,
prefix
))
continue
;
if
(
VIR_REALLOC_N
(
mounts
,
nmounts
+
1
)
<
0
)
{
virReportOOMError
();
if
(
VIR_REALLOC_N
(
mounts
,
nmounts
+
1
)
<
0
)
goto
cleanup
;
}
if
(
VIR_STRDUP
(
mounts
[
nmounts
],
mntent
.
mnt_dir
)
<
0
)
goto
cleanup
;
nmounts
++
;
...
...
@@ -568,10 +563,8 @@ static int lxcContainerPrepareRoot(virDomainDefPtr def,
}
if
(
virAsprintf
(
&
dst
,
"%s/%s.root"
,
LXC_STATE_DIR
,
def
->
name
)
<
0
)
{
virReportOOMError
();
LXC_STATE_DIR
,
def
->
name
)
<
0
)
return
-
1
;
}
tmp
=
root
->
dst
;
root
->
dst
=
dst
;
...
...
@@ -606,10 +599,8 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root)
goto
err
;
}
if
(
virAsprintf
(
&
oldroot
,
"%s/.oldroot"
,
root
->
src
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
oldroot
,
"%s/.oldroot"
,
root
->
src
)
<
0
)
goto
err
;
}
if
(
virFileMakePath
(
oldroot
)
<
0
)
{
virReportSystemError
(
errno
,
...
...
@@ -628,10 +619,8 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root)
}
/* Create a directory called 'new' in tmpfs */
if
(
virAsprintf
(
&
newroot
,
"%s/new"
,
oldroot
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
newroot
,
"%s/new"
,
oldroot
)
<
0
)
goto
err
;
}
if
(
virFileMakePath
(
newroot
)
<
0
)
{
virReportSystemError
(
errno
,
...
...
@@ -893,10 +882,8 @@ static int lxcContainerSetupDevices(char **ttyPaths, size_t nttyPaths)
for
(
i
=
0
;
i
<
nttyPaths
;
i
++
)
{
char
*
tty
;
if
(
virAsprintf
(
&
tty
,
"/dev/tty%zu"
,
i
+
1
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
tty
,
"/dev/tty%zu"
,
i
+
1
)
<
0
)
return
-
1
;
}
if
(
symlink
(
ttyPaths
[
i
],
tty
)
<
0
)
{
VIR_FREE
(
tty
);
virReportSystemError
(
errno
,
...
...
@@ -924,10 +911,8 @@ static int lxcContainerMountFSBind(virDomainFSDefPtr fs,
int
ret
=
-
1
;
struct
stat
st
;
if
(
virAsprintf
(
&
src
,
"%s%s"
,
srcprefix
,
fs
->
src
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
src
,
"%s%s"
,
srcprefix
,
fs
->
src
)
<
0
)
goto
cleanup
;
}
if
(
stat
(
fs
->
dst
,
&
st
)
<
0
)
{
if
(
errno
!=
ENOENT
)
{
...
...
@@ -1097,10 +1082,8 @@ static int lxcContainerMountFSBlockAuto(virDomainFSDefPtr fs,
/* First time around we use /etc/filesystems */
retry:
if
(
virAsprintf
(
&
fslist
,
"/.oldroot%s"
,
tryProc
?
"/proc/filesystems"
:
"/etc/filesystems"
)
<
0
)
{
virReportOOMError
();
tryProc
?
"/proc/filesystems"
:
"/etc/filesystems"
)
<
0
)
goto
cleanup
;
}
VIR_DEBUG
(
"Open fslist %s"
,
fslist
);
if
(
!
(
fp
=
fopen
(
fslist
,
"r"
)))
{
...
...
@@ -1254,10 +1237,8 @@ static int lxcContainerMountFSBlock(virDomainFSDefPtr fs,
char
*
src
=
NULL
;
int
ret
=
-
1
;
if
(
virAsprintf
(
&
src
,
"%s%s"
,
srcprefix
,
fs
->
src
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
src
,
"%s%s"
,
srcprefix
,
fs
->
src
)
<
0
)
goto
cleanup
;
}
ret
=
lxcContainerMountFSBlockHelper
(
fs
,
src
);
...
...
@@ -1276,10 +1257,8 @@ static int lxcContainerMountFSTmpfs(virDomainFSDefPtr fs,
char
*
data
=
NULL
;
if
(
virAsprintf
(
&
data
,
"size=%lldk%s"
,
fs
->
usage
,
sec_mount_options
)
<
0
)
{
virReportOOMError
();
"size=%lldk%s"
,
fs
->
usage
,
sec_mount_options
)
<
0
)
goto
cleanup
;
}
if
(
virFileMakePath
(
fs
->
dst
)
<
0
)
{
virReportSystemError
(
errno
,
...
...
@@ -1396,15 +1375,11 @@ static int lxcContainerSetupDisk(virDomainDefPtr vmDef,
goto
cleanup
;
}
if
(
virAsprintf
(
&
src
,
"/.oldroot/%s"
,
def
->
src
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
src
,
"/.oldroot/%s"
,
def
->
src
)
<
0
)
goto
cleanup
;
}
if
(
virAsprintf
(
&
dst
,
"/dev/%s"
,
def
->
dst
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
dst
,
"/dev/%s"
,
def
->
dst
)
<
0
)
goto
cleanup
;
}
if
(
stat
(
src
,
&
sb
)
<
0
)
{
virReportSystemError
(
errno
,
...
...
@@ -1484,22 +1459,16 @@ static int lxcContainerSetupHostdevSubsysUSB(virDomainDefPtr vmDef ATTRIBUTE_UNU
mode_t
mode
;
if
(
virAsprintf
(
&
dstdir
,
USB_DEVFS
"/%03d"
,
def
->
source
.
subsys
.
u
.
usb
.
bus
)
<
0
)
{
virReportOOMError
();
def
->
source
.
subsys
.
u
.
usb
.
bus
)
<
0
)
goto
cleanup
;
}
if
(
virAsprintf
(
&
dstfile
,
"%s/%03d"
,
dstdir
,
def
->
source
.
subsys
.
u
.
usb
.
device
)
<
0
)
{
virReportOOMError
();
def
->
source
.
subsys
.
u
.
usb
.
device
)
<
0
)
goto
cleanup
;
}
if
(
virAsprintf
(
&
src
,
"/.oldroot/%s"
,
dstfile
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
src
,
"/.oldroot/%s"
,
dstfile
)
<
0
)
goto
cleanup
;
}
if
(
stat
(
src
,
&
sb
)
<
0
)
{
virReportSystemError
(
errno
,
...
...
@@ -1586,10 +1555,8 @@ static int lxcContainerSetupHostdevCapsStorage(virDomainDefPtr vmDef ATTRIBUTE_U
goto
cleanup
;
}
if
(
virAsprintf
(
&
src
,
"/.oldroot/%s"
,
dev
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
src
,
"/.oldroot/%s"
,
dev
)
<
0
)
goto
cleanup
;
}
if
(
stat
(
src
,
&
sb
)
<
0
)
{
virReportSystemError
(
errno
,
...
...
@@ -1650,10 +1617,8 @@ static int lxcContainerSetupHostdevCapsMisc(virDomainDefPtr vmDef ATTRIBUTE_UNUS
goto
cleanup
;
}
if
(
virAsprintf
(
&
src
,
"/.oldroot/%s"
,
dev
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
src
,
"/.oldroot/%s"
,
dev
)
<
0
)
goto
cleanup
;
}
if
(
stat
(
src
,
&
sb
)
<
0
)
{
virReportSystemError
(
errno
,
...
...
@@ -2002,10 +1967,8 @@ static int lxcContainerChild(void *data)
if
(
STRPREFIX
(
tty
,
"/dev/pts/"
))
tty
+=
strlen
(
"/dev/pts/"
);
if
(
virAsprintf
(
&
ttyPath
,
"%s/%s.devpts/%s"
,
LXC_STATE_DIR
,
vmDef
->
name
,
tty
)
<
0
)
{
virReportOOMError
();
LXC_STATE_DIR
,
vmDef
->
name
,
tty
)
<
0
)
goto
cleanup
;
}
}
else
if
(
VIR_STRDUP
(
ttyPath
,
"/dev/null"
)
<
0
)
{
goto
cleanup
;
}
...
...
@@ -2156,10 +2119,8 @@ int lxcContainerStart(virDomainDefPtr def,
ttyPaths
,
nttyPaths
,
handshakefd
};
/* allocate a stack for the container */
if
(
VIR_ALLOC_N
(
stack
,
stacksize
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
stack
,
stacksize
)
<
0
)
return
-
1
;
}
stacktop
=
stack
+
stacksize
;
cflags
=
CLONE_NEWPID
|
CLONE_NEWNS
|
CLONE_NEWUTS
|
CLONE_NEWIPC
|
SIGCHLD
;
...
...
src/lxc/lxc_controller.c
浏览文件 @
56965922
...
...
@@ -150,10 +150,8 @@ static virLXCControllerPtr virLXCControllerNew(const char *name)
virDomainXMLOptionPtr
xmlopt
=
NULL
;
char
*
configFile
=
NULL
;
if
(
VIR_ALLOC
(
ctrl
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC
(
ctrl
)
<
0
)
goto
error
;
}
ctrl
->
timerShutdown
=
-
1
;
ctrl
->
firstClient
=
true
;
...
...
@@ -279,10 +277,8 @@ static void virLXCControllerFree(virLXCControllerPtr ctrl)
static
int
virLXCControllerAddConsole
(
virLXCControllerPtr
ctrl
,
int
hostFd
)
{
if
(
VIR_EXPAND_N
(
ctrl
->
consoles
,
ctrl
->
nconsoles
,
1
)
<
0
)
{
virReportOOMError
();
if
(
VIR_EXPAND_N
(
ctrl
->
consoles
,
ctrl
->
nconsoles
,
1
)
<
0
)
return
-
1
;
}
ctrl
->
consoles
[
ctrl
->
nconsoles
-
1
].
server
=
ctrl
->
server
;
ctrl
->
consoles
[
ctrl
->
nconsoles
-
1
].
hostFd
=
hostFd
;
ctrl
->
consoles
[
ctrl
->
nconsoles
-
1
].
hostWatch
=
-
1
;
...
...
@@ -473,7 +469,6 @@ static int virLXCControllerSetupLoopDevices(virLXCControllerPtr ctrl)
VIR_DEBUG
(
"Saving loop fd %d"
,
fd
);
if
(
VIR_EXPAND_N
(
ctrl
->
loopDevFds
,
ctrl
->
nloopDevs
,
1
)
<
0
)
{
VIR_FORCE_CLOSE
(
fd
);
virReportOOMError
();
goto
cleanup
;
}
ctrl
->
loopDevFds
[
ctrl
->
nloopDevs
-
1
]
=
fd
;
...
...
@@ -521,7 +516,6 @@ static int virLXCControllerSetupLoopDevices(virLXCControllerPtr ctrl)
VIR_DEBUG
(
"Saving loop fd %d"
,
fd
);
if
(
VIR_EXPAND_N
(
ctrl
->
loopDevFds
,
ctrl
->
nloopDevs
,
1
)
<
0
)
{
VIR_FORCE_CLOSE
(
fd
);
virReportOOMError
();
goto
cleanup
;
}
ctrl
->
loopDevFds
[
ctrl
->
nloopDevs
-
1
]
=
fd
;
...
...
@@ -707,10 +701,8 @@ static int virLXCControllerSetupServer(virLXCControllerPtr ctrl)
char
*
sockpath
;
if
(
virAsprintf
(
&
sockpath
,
"%s/%s.sock"
,
LXC_STATE_DIR
,
ctrl
->
name
)
<
0
)
{
virReportOOMError
();
LXC_STATE_DIR
,
ctrl
->
name
)
<
0
)
return
-
1
;
}
if
(
!
(
ctrl
->
server
=
virNetServerNew
(
0
,
0
,
0
,
1
,
-
1
,
0
,
false
,
...
...
@@ -1228,10 +1220,8 @@ static int virLXCControllerSetupDev(virLXCControllerPtr ctrl)
ctrl
->
def
);
if
(
virAsprintf
(
&
dev
,
"/%s/%s.dev"
,
LXC_STATE_DIR
,
ctrl
->
def
->
name
)
<
0
)
{
virReportOOMError
();
LXC_STATE_DIR
,
ctrl
->
def
->
name
)
<
0
)
goto
cleanup
;
}
if
(
virFileMakePath
(
dev
)
<
0
)
{
virReportSystemError
(
errno
,
...
...
@@ -1245,10 +1235,8 @@ static int virLXCControllerSetupDev(virLXCControllerPtr ctrl)
*/
if
(
virAsprintf
(
&
opts
,
"mode=755,size=65536%s"
,
mount_options
)
<
0
)
{
virReportOOMError
();
"mode=755,size=65536%s"
,
mount_options
)
<
0
)
goto
cleanup
;
}
VIR_DEBUG
(
"Mount devfs on %s type=tmpfs flags=%x, opts=%s"
,
dev
,
MS_NOSUID
,
opts
);
...
...
@@ -1295,10 +1283,8 @@ static int virLXCControllerPopulateDevices(virLXCControllerPtr ctrl)
/* Populate /dev/ with a few important bits */
for
(
i
=
0
;
i
<
ARRAY_CARDINALITY
(
devs
);
i
++
)
{
if
(
virAsprintf
(
&
path
,
"/%s/%s.dev/%s"
,
LXC_STATE_DIR
,
ctrl
->
def
->
name
,
devs
[
i
].
path
)
<
0
)
{
virReportOOMError
();
LXC_STATE_DIR
,
ctrl
->
def
->
name
,
devs
[
i
].
path
)
<
0
)
goto
cleanup
;
}
dev_t
dev
=
makedev
(
devs
[
i
].
maj
,
devs
[
i
].
min
);
if
(
mknod
(
path
,
S_IFCHR
,
dev
)
<
0
||
...
...
@@ -1439,7 +1425,6 @@ lxcCreateTty(virLXCControllerPtr ctrl, int *ttymaster,
if
((
virAsprintf
(
ttyName
,
"/dev/pts/%d"
,
ptyno
)
<
0
)
||
(
virAsprintf
(
ttyHostPath
,
"/%s/%s.devpts/%d"
,
LXC_STATE_DIR
,
ctrl
->
def
->
name
,
ptyno
)
<
0
))
{
virReportOOMError
();
errno
=
ENOMEM
;
goto
cleanup
;
}
...
...
@@ -1516,10 +1501,8 @@ virLXCControllerSetupDevPTS(virLXCControllerPtr ctrl)
if
(
virAsprintf
(
&
devpts
,
"%s/%s.devpts"
,
LXC_STATE_DIR
,
ctrl
->
def
->
name
)
<
0
||
virAsprintf
(
&
ctrl
->
devptmx
,
"%s/%s.devpts/ptmx"
,
LXC_STATE_DIR
,
ctrl
->
def
->
name
)
<
0
)
{
virReportOOMError
();
LXC_STATE_DIR
,
ctrl
->
def
->
name
)
<
0
)
goto
cleanup
;
}
if
(
virFileMakePath
(
devpts
)
<
0
)
{
virReportSystemError
(
errno
,
...
...
@@ -1531,10 +1514,8 @@ virLXCControllerSetupDevPTS(virLXCControllerPtr ctrl)
/* XXX should we support gid=X for X!=5 for distros which use
* a different gid for tty? */
if
(
virAsprintf
(
&
opts
,
"newinstance,ptmxmode=0666,mode=0620,gid=5%s"
,
(
mount_options
?
mount_options
:
""
))
<
0
)
{
virReportOOMError
();
(
mount_options
?
mount_options
:
""
))
<
0
)
goto
cleanup
;
}
VIR_DEBUG
(
"Mount devpts on %s type=tmpfs flags=%x, opts=%s"
,
devpts
,
MS_NOSUID
,
opts
);
...
...
@@ -1709,10 +1690,8 @@ virLXCControllerRun(virLXCControllerPtr ctrl)
size_t
i
;
virCgroupPtr
cgroup
=
NULL
;
if
(
VIR_ALLOC_N
(
containerTTYPaths
,
ctrl
->
nconsoles
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
containerTTYPaths
,
ctrl
->
nconsoles
)
<
0
)
goto
cleanup
;
}
if
(
socketpair
(
PF_UNIX
,
SOCK_STREAM
,
0
,
control
)
<
0
)
{
virReportSystemError
(
errno
,
"%s"
,
...
...
@@ -1872,19 +1851,15 @@ int main(int argc, char *argv[])
break
;
case
'v'
:
if
(
VIR_REALLOC_N
(
veths
,
nveths
+
1
)
<
0
)
{
virReportOOMError
();
if
(
VIR_REALLOC_N
(
veths
,
nveths
+
1
)
<
0
)
goto
cleanup
;
}
if
(
VIR_STRDUP
(
veths
[
nveths
++
],
optarg
)
<
0
)
goto
cleanup
;
break
;
case
'c'
:
if
(
VIR_REALLOC_N
(
ttyFDs
,
nttyFDs
+
1
)
<
0
)
{
virReportOOMError
();
if
(
VIR_REALLOC_N
(
ttyFDs
,
nttyFDs
+
1
)
<
0
)
goto
cleanup
;
}
if
(
virStrToLong_i
(
optarg
,
NULL
,
10
,
&
ttyFDs
[
nttyFDs
++
])
<
0
)
{
fprintf
(
stderr
,
"malformed --console argument '%s'"
,
optarg
);
goto
cleanup
;
...
...
src/lxc/lxc_driver.c
浏览文件 @
56965922
...
...
@@ -2885,10 +2885,8 @@ lxcDomainShutdownFlags(virDomainPtr dom,
}
if
(
virAsprintf
(
&
vroot
,
"/proc/%llu/root"
,
(
unsigned
long
long
)
priv
->
initpid
)
<
0
)
{
virReportOOMError
();
(
unsigned
long
long
)
priv
->
initpid
)
<
0
)
goto
cleanup
;
}
if
(
flags
==
0
||
(
flags
&
VIR_DOMAIN_SHUTDOWN_INITCTL
))
{
...
...
@@ -2977,10 +2975,8 @@ lxcDomainReboot(virDomainPtr dom,
}
if
(
virAsprintf
(
&
vroot
,
"/proc/%llu/root"
,
(
unsigned
long
long
)
priv
->
initpid
)
<
0
)
{
virReportOOMError
();
(
unsigned
long
long
)
priv
->
initpid
)
<
0
)
goto
cleanup
;
}
if
(
flags
==
0
||
(
flags
&
VIR_DOMAIN_REBOOT_INITCTL
))
{
...
...
@@ -3037,10 +3033,8 @@ lxcDomainAttachDeviceConfig(virDomainDefPtr vmdef,
_
(
"target %s already exists."
),
disk
->
dst
);
return
-
1
;
}
if
(
virDomainDiskInsert
(
vmdef
,
disk
))
{
virReportOOMError
();
if
(
virDomainDiskInsert
(
vmdef
,
disk
))
return
-
1
;
}
/* vmdef has the pointer. Generic codes for vmdef will do all jobs */
dev
->
data
.
disk
=
NULL
;
ret
=
0
;
...
...
@@ -3048,10 +3042,8 @@ lxcDomainAttachDeviceConfig(virDomainDefPtr vmdef,
case
VIR_DOMAIN_DEVICE_NET
:
net
=
dev
->
data
.
net
;
if
(
virDomainNetInsert
(
vmdef
,
net
)
<
0
)
{
virReportOOMError
();
if
(
virDomainNetInsert
(
vmdef
,
net
)
<
0
)
goto
cleanup
;
}
dev
->
data
.
net
=
NULL
;
ret
=
0
;
break
;
...
...
@@ -3063,10 +3055,8 @@ lxcDomainAttachDeviceConfig(virDomainDefPtr vmdef,
_
(
"device is already in the domain configuration"
));
return
-
1
;
}
if
(
virDomainHostdevInsert
(
vmdef
,
hostdev
)
<
0
)
{
virReportOOMError
();
if
(
virDomainHostdevInsert
(
vmdef
,
hostdev
)
<
0
)
return
-
1
;
}
dev
->
data
.
hostdev
=
NULL
;
ret
=
0
;
break
;
...
...
@@ -3241,15 +3231,11 @@ lxcDomainAttachDeviceDiskLive(virLXCDriverPtr driver,
}
if
(
virAsprintf
(
&
dst
,
"/proc/%llu/root/dev/%s"
,
(
unsigned
long
long
)
priv
->
initpid
,
def
->
dst
)
<
0
)
{
virReportOOMError
();
(
unsigned
long
long
)
priv
->
initpid
,
def
->
dst
)
<
0
)
goto
cleanup
;
}
if
(
VIR_REALLOC_N
(
vm
->
def
->
disks
,
vm
->
def
->
ndisks
+
1
)
<
0
)
{
virReportOOMError
();
if
(
VIR_REALLOC_N
(
vm
->
def
->
disks
,
vm
->
def
->
ndisks
+
1
)
<
0
)
goto
cleanup
;
}
mode
=
0700
;
if
(
S_ISCHR
(
sb
.
st_mode
))
...
...
@@ -3329,10 +3315,8 @@ lxcDomainAttachDeviceNetLive(virConnectPtr conn,
}
/* preallocate new slot for device */
if
(
VIR_REALLOC_N
(
vm
->
def
->
nets
,
vm
->
def
->
nnets
+
1
)
<
0
)
{
virReportOOMError
();
if
(
VIR_REALLOC_N
(
vm
->
def
->
nets
,
vm
->
def
->
nnets
+
1
)
<
0
)
return
-
1
;
}
/* If appropriate, grab a physical device from the configured
* network's pool of devices, or resolve bridge device name
...
...
@@ -3466,31 +3450,23 @@ lxcDomainAttachDeviceHostdevSubsysUSBLive(virLXCDriverPtr driver,
}
if
(
virAsprintf
(
&
vroot
,
"/proc/%llu/root"
,
(
unsigned
long
long
)
priv
->
initpid
)
<
0
)
{
virReportOOMError
();
(
unsigned
long
long
)
priv
->
initpid
)
<
0
)
goto
cleanup
;
}
if
(
virAsprintf
(
&
dstdir
,
"%s/dev/bus/%03d"
,
vroot
,
def
->
source
.
subsys
.
u
.
usb
.
bus
)
<
0
)
{
virReportOOMError
();
def
->
source
.
subsys
.
u
.
usb
.
bus
)
<
0
)
goto
cleanup
;
}
if
(
virAsprintf
(
&
dstfile
,
"%s/%03d"
,
dstdir
,
def
->
source
.
subsys
.
u
.
usb
.
device
)
<
0
)
{
virReportOOMError
();
def
->
source
.
subsys
.
u
.
usb
.
device
)
<
0
)
goto
cleanup
;
}
if
(
virAsprintf
(
&
src
,
"/dev/bus/usb/%03d/%03d"
,
def
->
source
.
subsys
.
u
.
usb
.
bus
,
def
->
source
.
subsys
.
u
.
usb
.
device
)
<
0
)
{
virReportOOMError
();
def
->
source
.
subsys
.
u
.
usb
.
device
)
<
0
)
goto
cleanup
;
}
if
(
!
virCgroupHasController
(
priv
->
cgroup
,
VIR_CGROUP_CONTROLLER_DEVICES
))
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
...
...
@@ -3599,22 +3575,16 @@ lxcDomainAttachDeviceHostdevStorageLive(virLXCDriverPtr driver,
}
if
(
virAsprintf
(
&
vroot
,
"/proc/%llu/root"
,
(
unsigned
long
long
)
priv
->
initpid
)
<
0
)
{
virReportOOMError
();
(
unsigned
long
long
)
priv
->
initpid
)
<
0
)
goto
cleanup
;
}
if
(
virAsprintf
(
&
dst
,
"%s/%s"
,
vroot
,
def
->
source
.
caps
.
u
.
storage
.
block
)
<
0
)
{
virReportOOMError
();
def
->
source
.
caps
.
u
.
storage
.
block
)
<
0
)
goto
cleanup
;
}
if
(
VIR_REALLOC_N
(
vm
->
def
->
hostdevs
,
vm
->
def
->
nhostdevs
+
1
)
<
0
)
{
virReportOOMError
();
if
(
VIR_REALLOC_N
(
vm
->
def
->
hostdevs
,
vm
->
def
->
nhostdevs
+
1
)
<
0
)
goto
cleanup
;
}
if
(
lxcContainerSetupHostdevCapsMakePath
(
dst
)
<
0
)
{
virReportSystemError
(
errno
,
...
...
@@ -3710,22 +3680,16 @@ lxcDomainAttachDeviceHostdevMiscLive(virLXCDriverPtr driver,
}
if
(
virAsprintf
(
&
vroot
,
"/proc/%llu/root"
,
(
unsigned
long
long
)
priv
->
initpid
)
<
0
)
{
virReportOOMError
();
(
unsigned
long
long
)
priv
->
initpid
)
<
0
)
goto
cleanup
;
}
if
(
virAsprintf
(
&
dst
,
"%s/%s"
,
vroot
,
def
->
source
.
caps
.
u
.
misc
.
chardev
)
<
0
)
{
virReportOOMError
();
def
->
source
.
caps
.
u
.
misc
.
chardev
)
<
0
)
goto
cleanup
;
}
if
(
VIR_REALLOC_N
(
vm
->
def
->
hostdevs
,
vm
->
def
->
nhostdevs
+
1
)
<
0
)
{
virReportOOMError
();
if
(
VIR_REALLOC_N
(
vm
->
def
->
hostdevs
,
vm
->
def
->
nhostdevs
+
1
)
<
0
)
goto
cleanup
;
}
if
(
lxcContainerSetupHostdevCapsMakePath
(
dst
)
<
0
)
{
virReportSystemError
(
errno
,
...
...
@@ -3913,10 +3877,8 @@ lxcDomainDetachDeviceDiskLive(virDomainObjPtr vm,
def
=
vm
->
def
->
disks
[
i
];
if
(
virAsprintf
(
&
dst
,
"/proc/%llu/root/dev/%s"
,
(
unsigned
long
long
)
priv
->
initpid
,
def
->
dst
)
<
0
)
{
virReportOOMError
();
(
unsigned
long
long
)
priv
->
initpid
,
def
->
dst
)
<
0
)
goto
cleanup
;
}
if
(
!
virCgroupHasController
(
priv
->
cgroup
,
VIR_CGROUP_CONTROLLER_DEVICES
))
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
...
...
@@ -4035,18 +3997,14 @@ lxcDomainDetachDeviceHostdevUSBLive(virLXCDriverPtr driver,
}
if
(
virAsprintf
(
&
vroot
,
"/proc/%llu/root"
,
(
unsigned
long
long
)
priv
->
initpid
)
<
0
)
{
virReportOOMError
();
(
unsigned
long
long
)
priv
->
initpid
)
<
0
)
goto
cleanup
;
}
if
(
virAsprintf
(
&
dst
,
"%s/dev/bus/usb/%03d/%03d"
,
vroot
,
def
->
source
.
subsys
.
u
.
usb
.
bus
,
def
->
source
.
subsys
.
u
.
usb
.
device
)
<
0
)
{
virReportOOMError
();
def
->
source
.
subsys
.
u
.
usb
.
device
)
<
0
)
goto
cleanup
;
}
if
(
!
virCgroupHasController
(
priv
->
cgroup
,
VIR_CGROUP_CONTROLLER_DEVICES
))
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
...
...
@@ -4113,10 +4071,8 @@ lxcDomainDetachDeviceHostdevStorageLive(virDomainObjPtr vm,
if
(
virAsprintf
(
&
dst
,
"/proc/%llu/root/%s"
,
(
unsigned
long
long
)
priv
->
initpid
,
def
->
source
.
caps
.
u
.
storage
.
block
)
<
0
)
{
virReportOOMError
();
def
->
source
.
caps
.
u
.
storage
.
block
)
<
0
)
goto
cleanup
;
}
if
(
!
virCgroupHasController
(
priv
->
cgroup
,
VIR_CGROUP_CONTROLLER_DEVICES
))
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
...
...
@@ -4174,10 +4130,8 @@ lxcDomainDetachDeviceHostdevMiscLive(virDomainObjPtr vm,
if
(
virAsprintf
(
&
dst
,
"/proc/%llu/root/%s"
,
(
unsigned
long
long
)
priv
->
initpid
,
def
->
source
.
caps
.
u
.
misc
.
chardev
)
<
0
)
{
virReportOOMError
();
def
->
source
.
caps
.
u
.
misc
.
chardev
)
<
0
)
goto
cleanup
;
}
if
(
!
virCgroupHasController
(
priv
->
cgroup
,
VIR_CGROUP_CONTROLLER_DEVICES
))
{
virReportError
(
VIR_ERR_OPERATION_INVALID
,
"%s"
,
...
...
src/lxc/lxc_fuse.c
浏览文件 @
56965922
...
...
@@ -52,10 +52,8 @@ static int lxcProcGetattr(const char *path, struct stat *stbuf)
virDomainDefPtr
def
=
(
virDomainDefPtr
)
context
->
private_data
;
memset
(
stbuf
,
0
,
sizeof
(
struct
stat
));
if
(
virAsprintf
(
&
mempath
,
"/proc/%s"
,
path
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
mempath
,
"/proc/%s"
,
path
)
<
0
)
return
-
errno
;
}
res
=
0
;
...
...
@@ -238,10 +236,8 @@ static int lxcProcRead(const char *path ATTRIBUTE_UNUSED,
struct
fuse_context
*
context
=
NULL
;
virDomainDefPtr
def
=
NULL
;
if
(
virAsprintf
(
&
hostpath
,
"/proc/%s"
,
path
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
hostpath
,
"/proc/%s"
,
path
)
<
0
)
return
-
errno
;
}
context
=
fuse_get_context
();
def
=
(
virDomainDefPtr
)
context
->
private_data
;
...
...
@@ -297,10 +293,8 @@ int lxcSetupFuse(virLXCFusePtr *f, virDomainDefPtr def)
goto
cleanup2
;
if
(
virAsprintf
(
&
fuse
->
mountpoint
,
"%s/%s.fuse/"
,
LXC_STATE_DIR
,
def
->
name
)
<
0
)
{
virReportOOMError
();
def
->
name
)
<
0
)
goto
cleanup1
;
}
if
(
virFileMakePath
(
fuse
->
mountpoint
)
<
0
)
{
virReportSystemError
(
errno
,
_
(
"Cannot create %s"
),
...
...
src/lxc/lxc_monitor.c
浏览文件 @
56965922
...
...
@@ -155,7 +155,7 @@ virLXCMonitorPtr virLXCMonitorNew(virDomainObjPtr vm,
if
(
virAsprintf
(
&
sockpath
,
"%s/%s.sock"
,
socketdir
,
vm
->
def
->
name
)
<
0
)
goto
no_memory
;
goto
error
;
if
(
!
(
mon
->
client
=
virNetClientNewUNIX
(
sockpath
,
false
,
NULL
)))
goto
error
;
...
...
@@ -185,8 +185,6 @@ cleanup:
VIR_FREE
(
sockpath
);
return
mon
;
no_memory:
virReportOOMError
();
error:
virObjectUnref
(
mon
);
mon
=
NULL
;
...
...
src/lxc/lxc_process.c
浏览文件 @
56965922
...
...
@@ -442,10 +442,8 @@ static int virLXCProcessSetupInterfaces(virConnectPtr conn,
if
(
networkAllocateActualDevice
(
def
->
nets
[
i
])
<
0
)
goto
cleanup
;
if
(
VIR_EXPAND_N
(
*
veths
,
*
nveths
,
1
)
<
0
)
{
virReportOOMError
();
if
(
VIR_EXPAND_N
(
*
veths
,
*
nveths
,
1
)
<
0
)
goto
cleanup
;
}
switch
(
virDomainNetGetActualType
(
def
->
nets
[
i
]))
{
case
VIR_DOMAIN_NET_TYPE_NETWORK
:
{
...
...
@@ -648,10 +646,8 @@ virLXCProcessGetNsInode(pid_t pid,
int
ret
=
-
1
;
if
(
virAsprintf
(
&
path
,
"/proc/%llu/ns/%s"
,
(
unsigned
long
long
)
pid
,
nsname
)
<
0
)
{
virReportOOMError
();
(
unsigned
long
long
)
pid
,
nsname
)
<
0
)
goto
cleanup
;
}
if
(
stat
(
path
,
&
sb
)
<
0
)
{
virReportSystemError
(
errno
,
...
...
@@ -992,7 +988,7 @@ virLXCProcessEnsureRootFS(virDomainObjPtr vm)
return
0
;
if
(
VIR_ALLOC
(
root
)
<
0
)
goto
no_memory
;
goto
error
;
root
->
type
=
VIR_DOMAIN_FS_TYPE_MOUNT
;
...
...
@@ -1000,16 +996,14 @@ virLXCProcessEnsureRootFS(virDomainObjPtr vm)
VIR_STRDUP
(
root
->
dst
,
"/"
)
<
0
)
goto
error
;
if
(
VIR_INSERT_ELEMENT
_QUIET
(
vm
->
def
->
fss
,
if
(
VIR_INSERT_ELEMENT
(
vm
->
def
->
fss
,
0
,
vm
->
def
->
nfss
,
root
)
<
0
)
goto
no_memory
;
goto
error
;
return
0
;
no_memory:
virReportOOMError
();
error:
virDomainFSDefFree
(
root
);
return
-
1
;
...
...
@@ -1084,10 +1078,8 @@ int virLXCProcessStart(virConnectPtr conn,
}
if
(
virAsprintf
(
&
logfile
,
"%s/%s.log"
,
driver
->
logDir
,
vm
->
def
->
name
)
<
0
)
{
virReportOOMError
();
driver
->
logDir
,
vm
->
def
->
name
)
<
0
)
return
-
1
;
}
/* Do this up front, so any part of the startup process can add
* runtime state to vm->def that won't be persisted. This let's us
...
...
@@ -1127,10 +1119,8 @@ int virLXCProcessStart(virConnectPtr conn,
* and forward I/O between them.
*/
nttyFDs
=
vm
->
def
->
nconsoles
;
if
(
VIR_ALLOC_N
(
ttyFDs
,
nttyFDs
)
<
0
)
{
virReportOOMError
();
if
(
VIR_ALLOC_N
(
ttyFDs
,
nttyFDs
)
<
0
)
goto
cleanup
;
}
for
(
i
=
0
;
i
<
vm
->
def
->
nconsoles
;
i
++
)
ttyFDs
[
i
]
=
-
1
;
...
...
@@ -1170,11 +1160,9 @@ int virLXCProcessStart(virConnectPtr conn,
vm
->
def
->
consoles
[
i
]
->
source
.
data
.
file
.
path
=
ttyPath
;
VIR_FREE
(
vm
->
def
->
consoles
[
i
]
->
info
.
alias
);
if
(
virAsprintf
(
&
vm
->
def
->
consoles
[
i
]
->
info
.
alias
,
"console%zu"
,
i
)
<
0
)
{
virReportOOMError
();
if
(
virAsprintf
(
&
vm
->
def
->
consoles
[
i
]
->
info
.
alias
,
"console%zu"
,
i
)
<
0
)
goto
cleanup
;
}
}
if
(
virLXCProcessSetupInterfaces
(
conn
,
vm
->
def
,
&
nveths
,
&
veths
)
<
0
)
goto
cleanup
;
...
...
@@ -1224,10 +1212,8 @@ int virLXCProcessStart(virConnectPtr conn,
}
/* Log timestamp */
if
((
timestamp
=
virTimeStringNow
())
==
NULL
)
{
virReportOOMError
();
if
((
timestamp
=
virTimeStringNow
())
==
NULL
)
goto
cleanup
;
}
if
(
safewrite
(
logfd
,
timestamp
,
strlen
(
timestamp
))
<
0
||
safewrite
(
logfd
,
START_POSTFIX
,
strlen
(
START_POSTFIX
))
<
0
)
{
VIR_WARN
(
"Unable to write timestamp to logfile: %s"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录