lxc容器下的视频驱动程序?

lur*_*her 5 virtualization graphics chroot 12.04 lxc

自从LXC(Linux 容器)是内核级超级 chroot,我一直想知道容器具有什么样的视频驱动程序:

我的主机是带有 ATI gpu 的Ubuntu 12.04 64 位机器。LXC 容器可以访问相同的驱动程序吗?还是需要将它们安装在每个容器上?

Osc*_*cia 4

请看一下这个脚本来创建一个 LXC 容器,该容器运行带有声音和视频加速的 steam:

http://bazaar.launchpad.net/~ubuntu-lxc/lxc/steam-lxc/view/head:/steam-lxc

魔法就在这里:

LXC 以外:

    # Add the bind mounts to the container's fstab
    self.container.set_config_item("lxc.mount.entry",
                                   "/tmp/.X11-unix tmp/.X11-unix "
                                   "none bind,ro")
    self.container.set_config_item("lxc.mount.entry",
                                   "/dev/dri dev/dri none bind,ro")
    self.container.set_config_item("lxc.mount.entry",
                                   "%s/pulse.socket home/%s/.pulse_socket "
                                   "none bind,ro" % (self.config_path,
                                                     self.user.pw_name))
Run Code Online (Sandbox Code Playgroud)

我们通过绑定挂载目录导出 X11 /tmp/.X11-unix,以允许容器使用主机 X11。对目录和音频套接字执行相同的操作/dev/dri

LXC内部:

    # Get pulseaudio to listen on the socket
    with self.user_privileges():
        subprocess.call(['pactl', 'load-module',
                        'module-native-protocol-unix',
                        'socket=%s' % self.pulse_socket,
                        'auth-cookie-enabled=0'])

    # Start steam
    self.run_command(
        ["steam"], {'DISPLAY': os.environ['DISPLAY'],
                    'PULSE_SERVER': "/home/%s/.pulse_socket" %
                                    self.user.pw_name})
Run Code Online (Sandbox Code Playgroud)

用于pactl使用unix套接字与主机脉冲音频服务器进行通信,然后导出套接字和DISPLAY环境变量以允许steam使用本地X11服务器和音频服务器的套接字。

看看脚本并享受它:)

通过 LXC 内的环境变量,您可以(理论上)玩几乎所有游戏。

此致!