Bootstrap

xen 安全 acm & flask

XEN虚拟化环境搭建


  1. 安装红旗桌面操作系统(RedFlag-6.3-Sys-1.845-201207041041.iso

  2. 安装xen环境

1)卸载系统安装的两个XEN包:

#rpm -qa |grep xen

#rpm -e xen-libs-3.3 xen-devel-3.3 –nodeps

2)卸载系统安装的包qemu-0.9.1-10.i386

#rpm-e qemu-0.9.1-10.i386

3)安装xen包和qemu

#rpm-ivh kernelxen-2.6.32.50-7.i386.rpm

xen-4.1.0-1.i386.rpm

xen-devel-4.1.0-1.i386.rpm

xen-doc-4.1.0-1.i386.rpm

xen-hypervisor-4.1.0-1.i386.rpm

xen-libs-4.1.0-1.i386.rpm

xen-licenses-4.1.0-1.i386.rpm

xen-runtime-4.1.0-1.i386.rpmcheckpolicy-2.0.19-2.fc11.i586.rpm vnc-4.1.2-35.i386.rpm vnc-server-4.1.2-35.i386.rpm vnc-libs-4.1.2-35.i386.rpmxz-libs-4.999.9-0.1.beta.20091007git.i386.rpmxz-devel-4.999.9-0.1.beta.20091007git.i386.rpm

  1. 编辑/etc/grub.conf

添加:

titleRed Flag Desktop 6.0 Desktop with Xen(2.6.32.50)

root(hd0,4)

kernel/boot/xen.gz

module/boot/vmlinuz-2.6.32.50 ro root=/dev/sda5

module/boot/initrd-2.6.32.50.img

  1. 重新启动电脑,进入上面的xen系统

  2. 打开命令终端,配置网络

#ifconfig发现只有lo设备,执行下面的命令

#配置一份ifcfg-eth0

#modprobe-r tg3

#modprobebroadcom(视网卡类型而定)

#modprobe tg3

#brctlshow(查看网桥)

bridgename bridge id STP enabled interfaces

pan0 8000.14feb5e3faea no eth0

#brctldelbr pan0(删除网桥)

如果xend发现有虚拟网桥存在,则不会再启动网桥

  1. 启动xen服务

/etc/init.d/xencommonsstart

/etc/init.d/xendstart

  1. 创建安装虚拟机配置文件(fedora.cfg

kernel= "hvmloader"

builder='hvm'

memory= 512

name= "fedora"

vif= [ 'type=ioemu, mac=00:c0:9f:78:35:a7, bridge=eth0' ]

disk= ['file:/root/domU.img,xvda,w','file:/root/Fedora-14-i386-DVD.iso,xvdc:cdrom,r']

device_model= 'qemu-dm'

boot="cd"

vnc=1

vnclisten="127.0.0.1"

vncconsole=1

vncpasswd=''

serial='pty'

usb=1

usbdevice='tablet'

  1. 启动虚拟机并且执行安装程序

#xm create fedora.cfg

可以在vnc中看到虚拟机安装界面,执行下一步开始安装虚拟机

  1. 当虚拟机安装完毕,启动虚拟机,采用配置文件

kernel= "hvmloader"

builder='hvm'

memory= 512

name= "fedora"

vif= [ 'type=ioemu, mac=00:c0:9f:78:35:a7, bridge=eth0' ]

disk= [ 'file:/root/domU.img,xvda,w' ]

device_model= 'qemu-dm'

boot="cd"

vnc=1

vnclisten="127.0.0.1"

vncconsole=1

vncpasswd=''

serial='pty'

usb=1

usbdevice='tablet'




FLASK环境配置:

  1. 删除安装的7xen

#rpm-e xen-4.1.0-1.i386.rpm

xen-devel-4.1.0-1.i386.rpm

xen-doc-4.1.0-1.i386.rpm

xen-hypervisor-4.1.0-1.i386.rpm

xen-libs-4.1.0-1.i386.rpm

xen-licenses-4.1.0-1.i386.rpm

xen-runtime-4.1.0-1.i386.rpm

#cdxen_flask

#rpm-ivh *.rpm

  1. 修改/etc/xen/xend-config.sxp

#(xsm_module_namedummy)

(xsm_module_nameflask)

  1. 进入xen源码包

#cdxen-4.1.0/tools/flask/policy/

#makepolicy

#makeinstall

#编辑/etc/grub.conf

修改启动项为:

titleRed Flag Desktop 6.0 Desktop with Xen(2.6.32.50)

root(hd0,4)

kernel/boot/xen.gz

module/boot/vmlinuz-2.6.32.50 ro root=/dev/sda5

module/boot/initrd-2.6.32.50.img

module/boot/xenpolicy.24

  1. 重启电脑

  2. 按照上面第5项重新设置网络

  3. 修改虚拟机启动配置文件fedora.cfg

kernel= "hvmloader"

builder='hvm'

memory= 512

name= "fedora"

vif= [ 'type=ioemu, mac=00:c0:9f:78:35:a7, bridge=eth0' ]

disk= [ 'file:/root/domU.img,xvda,w' ]

access_control= ["policy=,label=system_u:system_r:domHU_t"]

device_model= 'qemu-dm'

boot="cd"

vnc=1

vnclisten="127.0.0.1"

vncconsole=1

vncpasswd=''

serial='pty'

usb=1

usbdevice='tablet'

  1. 启动虚拟机

#xmcreate fedora.cfg

查看是否起作用

#xm dmesg | grep avc

(XEN)avc: denied { setparam } for domid=0scontext=system_u:system_r:dom0_t tcontext=system_u:system_r:domU_ttclass=hvm

(XEN)avc: denied { getparam } for domid=0scontext=system_u:system_r:dom0_t tcontext=system_u:system_r:domU_ttclass=hvm

(XEN)avc: denied { irqlevel } for domid=0scontext=system_u:system_r:dom0_t tcontext=system_u:system_r:domU_ttclass=hvm

(XEN)avc: denied { pciroute } for domid=0scontext=system_u:system_r:dom0_t tcontext=system_u:system_r:domU_ttclass=hvm

(XEN)avc: denied { setparam } for domid=4scontext=system_u:system_r:domU_t tcontext=system_u:system_r:domU_ttclass=hvm

(XEN)avc: denied { cacheattr } for domid=0scontext=system_u:system_r:dom0_t tcontext=system_u:system_r:domU_ttclass=hvm

(XEN)avc: denied { pcilevel } for domid=0scontext=system_u:system_r:dom0_t tcontext=system_u:system_r:domU_ttclass=hvm




ACM环境配置

  1. 删除安装的7xen

#rpm-e xen-4.1.0-1.i386.rpm

xen-devel-4.1.0-1.i386.rpm

xen-doc-4.1.0-1.i386.rpm

xen-hypervisor-4.1.0-1.i386.rpm

xen-libs-4.1.0-1.i386.rpm

xen-licenses-4.1.0-1.i386.rpm

xen-runtime-4.1.0-1.i386.rpm

#cdxen_acm

#rpm-ivh *.rpm

  1. 修改/etc/xen/xend-config.sxp

#(xsm_module_namedummy)

(xsm_module_nameacm)

  1. 重启电脑

  2. 按照上面第5项重新设置网络

  3. 启动xen服务

#/etc/init.d/xencommonsstart

#/etc/init.d/xendstart

  1. 设置acmpolicy

#xmsetpolicy ACMclient_v1(配置文件为/etc/xen/acm-security/policies/client_v1-security_policy.xml)

#xmdumppolicy

#reboot(重启电脑)

#xmlist --label

Name ID Mem VCPUs State Time(s) Label

Domain-0 0 1862 2 r----- 2469.3ACM:example.client_v1:SystemManagement

7.vim /etc/grub.conf可以看到新增了module/boot/example.client_v1.bin

titleRed Flag Desktop 6.0 Desktop with Xen(2.6.31-4_17)

root(hd0,4)

kernel/boot/xen.gzssidref=0x00010001:ACM:example.client_v1:SystemManagement

module/boot/vmlinuz-2.6.32.50 ro root=/dev/sda5

module/boot/initrd-2.6.32.50.img

module/boot/example.client_v1.bin


;