Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
b73aafd6
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看板
提交
b73aafd6
编写于
6月 17, 2014
作者:
C
Cédric Bosdonnat
提交者:
Eric Blake
6月 17, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added example script on how to convert LXC container config
上级
49ce28d6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
148 addition
and
1 deletion
+148
-1
Makefile.am
Makefile.am
+2
-1
configure.ac
configure.ac
+1
-0
examples/lxcconvert/Makefile.am
examples/lxcconvert/Makefile.am
+18
-0
examples/lxcconvert/virt-lxc-convert
examples/lxcconvert/virt-lxc-convert
+127
-0
未找到文件。
Makefile.am
浏览文件 @
b73aafd6
...
@@ -23,7 +23,8 @@ SUBDIRS = . gnulib/lib include src daemon tools docs gnulib/tests \
...
@@ -23,7 +23,8 @@ SUBDIRS = . gnulib/lib include src daemon tools docs gnulib/tests \
tests po examples/object-events examples/hellolibvirt
\
tests po examples/object-events examples/hellolibvirt
\
examples/dominfo examples/domsuspend examples/apparmor
\
examples/dominfo examples/domsuspend examples/apparmor
\
examples/xml/nwfilter examples/openauth examples/systemtap
\
examples/xml/nwfilter examples/openauth examples/systemtap
\
tools/wireshark examples/dommigrate
tools/wireshark examples/dommigrate
\
examples/lxcconvert
ACLOCAL_AMFLAGS
=
-I
m4
ACLOCAL_AMFLAGS
=
-I
m4
...
...
configure.ac
浏览文件 @
b73aafd6
...
@@ -2742,6 +2742,7 @@ AC_CONFIG_FILES([\
...
@@ -2742,6 +2742,7 @@ AC_CONFIG_FILES([\
examples/hellolibvirt/Makefile \
examples/hellolibvirt/Makefile \
examples/systemtap/Makefile \
examples/systemtap/Makefile \
examples/xml/nwfilter/Makefile \
examples/xml/nwfilter/Makefile \
examples/lxcconvert/Makefile \
tools/wireshark/Makefile \
tools/wireshark/Makefile \
tools/wireshark/src/Makefile])
tools/wireshark/src/Makefile])
AC_OUTPUT
AC_OUTPUT
...
...
examples/lxcconvert/Makefile.am
0 → 100644
浏览文件 @
b73aafd6
## Copyright (C) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
##
## This library is free software; you can redistribute it and/or
## modify it under the terms of the GNU Lesser General Public
## License as published by the Free Software Foundation; either
## version 2.1 of the License, or (at your option) any later version.
##
## This library is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## Lesser General Public License for more details.
##
## You should have received a copy of the GNU Lesser General Public
## License along with this library. If not, see
## <http://www.gnu.org/licenses/>.
EXTRA_DIST
=
\
virt-lxc-convert
examples/lxcconvert/virt-lxc-convert
0 → 100644
浏览文件 @
b73aafd6
#!/bin/sh
# lxc_native.c: LXC native configuration import
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library. If not, see
# <http://www.gnu.org/licenses/>.
#
# Author: Cedric Bosdonnat <cbosdonnat@suse.com>
handler_cleanup
()
{
if
test
"
$conf_dir
"
;
then
# Remove the temporary config
rm
-r
"
$conf_dir
"
fi
}
trap
handler_cleanup INT EXIT
show_help
()
{
cat
<<
EOF
$0
/path/to/lxc/config/file
Wrapper around virsh domxml-from-native to ease conversion of LXC
containers configuration to libvirt domain XML.
EOF
}
if
test
$#
!=
1
;
then
show_help
exit
1
fi
if
test
"
$1
"
=
"--help"
||
test
"
$1
"
=
"-h"
;
then
show_help
exit
$?
fi
conf
=
$1
conf_dir
=
$(
mktemp
--tmpdir
-d
virt-lxc-convert-XXX
)
conf_new
=
$conf_dir
/config
cp
"
$conf
"
"
$conf_new
"
# Do we have lxc.mount, and is it pointing to a readable file?
fstab
=
$(
sed
-n
'/lxc.mount[[:space:]]*=/ s/[[:space:]]*=[[:space:]]*/=/p'
\
"
$conf_new
"
|
cut
-f
2
-d
'='
)
if
test
-r
"
$fstab
"
;
then
sed
's/^lxc.mount[[:space:]]*=.*$//'
"
$conf_new
"
>
"
${
conf_new
}
.tmp"
mv
"
${
conf_new
}
.tmp"
"
${
conf_new
}
"
sed
's/^\([^#]\)/lxc.mount.entry = \1/'
"
$fstab
"
>>
"
${
conf_new
}
"
fi
memory
=
$(
free |
sed
-n
'/Mem:/s/ \+/ /gp'
|
cut
-f
2
-d
' '
)
default_tmpfs
=
"size=
$((
memory/2
))
"
# Do we have tmpfs without size param?
lineno
=
0
while
read
line
;
do
lineno
=
$(
expr
$lineno
+ 1
)
has_rel_size
=
false
case
$line
in
lxc.mount.entry[[:space:]]
*
=[[
:space:]]
*
tmpfs[[:space:]]
*
)
is_tmpfs
=
true
;;
*
)
is_tmpfs
=
false
;;
esac
# We only care about tmpfs mount entries here
if
!
$is_tmpfs
;
then
continue
fi
case
$line
in
*
size
=[
0-9][0-9]
*
%
*
)
has_rel_size
=
true
has_size
=
true
;;
*
size
=
*
)
has_size
=
true
;;
*
)
has_size
=
false
;;
esac
# Add the default size here (50%) if no size is given
if
!
$has_size
;
then
last_option_match
=
"
\(
[[:space:]]*[0-9][[:space:]]*[0-9][::space::]*
$\
)"
sed
"
${
lineno
}
s/
$last_option_match
/,
$default_tmpfs
\1
/"
\
"
$conf_new
"
>
"
${
conf_new
}
.tmp"
mv
"
${
conf_new
}
.tmp"
"
${
conf_new
}
"
fi
# Convert relative sizes
if
$has_rel_size
;
then
percent
=
$(
echo
"
$line
"
|
sed
's/.*size=\([0-9][0-9]*\)%.*/\1/'
)
size
=
"
$((
memory
*
percent/100
))
"
sed
"
${
lineno
}
s/size=[0-9]*%/size=
${
size
}
/"
\
"
$conf_new
"
>
"
${
conf_new
}
.tmp"
mv
"
${
conf_new
}
.tmp"
"
${
conf_new
}
"
fi
done
<
"
$conf_new
"
# Do we have any memory limit set?
mem_limit
=
$(
grep
'lxc.cgroup.memory.limit_in_bytes[[:space:]]*='
$conf_new
)
if
test
-z
"
$mem_limit
"
;
then
echo
"lxc.cgroup.memory.limit_in_bytes =
$memory
"
>>
"
$conf_new
"
fi
virsh
-c
lxc:/// domxml-from-native lxc-tools
$conf_new
exit
$?
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录