`
javasee
  • 浏览: 993379 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

XEN passthrough NIC on SuSE

阅读更多

The idea is to bind the pci device (in your case a nic) to the pciback module in the dom0 guest and then assign it to the target domU.

There are two main ways to achieve that, depending on how long you want the change to last:

a) If you want to assign the pci device to the target domU on a transient basis, do a manual allocation.
The allocation will only last until you reboot the system or the domU guest.

b) If you want the assigment to remain persistent among system reboots, stick to the automatic approach, that basically consists on editing the modprobe conf file, building a new initrd file system and changing the affected domU guest configuration file so that it includes the PCI device id in the pci parameter.

I'll only cover here the transient one.

For illustration purposes I'll use my wireless nic. Adapt the procedure to your system.

a) Manual allocation

Having your system started in Xen mode, from a dom0 bash root session do the following:

-Step 1: Find if your dom0 have support for the pciback module. If you are using open Suse 11, and are using the stock kernel, it should have it:

Code:
lustmord:~ # uname -r

2.6.25.18-0.2-xen

lustmord:~ # lsmod | grep pciback

lustmord:~ # modprobe pciback

lustmord:~ # lsmod | grep pciback

pciback 33940 0

xenbus_be 8192 4 pciback,netbk,blkbk,blktap

lustmord:~ #


Check that the directory /sys/bus/pci/drivers/pciback exists and looks like this:

Code:
lustmord:/sys/bus/pci/drivers/pciback # ls -l

total 0

--w------- 1 root root 4096 Dec 4 23:19 bind

lrwxrwxrwx 1 root root 0 Dec 4 22:58 module -> ../../../../module/pciback

--w------- 1 root root 4096 Dec 4 23:19 new_id

--w------- 1 root root 4096 Dec 4 23:19 new_slot

-rw------- 1 root root 4096 Dec 4 23:19 permissive

-rw------- 1 root root 4096 Dec 4 23:19 quirks

--w------- 1 root root 4096 Dec 4 23:19 remove_slot

-r-------- 1 root root 4096 Dec 4 23:19 slots

--w------- 1 root root 4096 Dec 4 23:19 uevent

--w------- 1 root root 4096 Dec 4 23:19 unbind

lustmord:/sys/bus/pci/drivers/pciback #


If it does, pciback was loaded correctly.


-Step 2: Find out the PCI device id corresponding to the device you want to allocate to the target domU:

Code:
lustmord:~ # lspci | grep [Ww]ireless

03:00.0 Network controller: Intel Corporation PRO/Wireless 4965 AG or AGN Network Connection (rev 61)

lustmord:~ #

The long format for the PCI Id is then : 0000:03:00.0


Step 3: Find out the driver (module) to which this PCI device is currently bound:

Code:
lustmord:~ # find /sys/bus/pci/drivers -name "0000:03:00.0"

/sys/bus/pci/drivers/iwl4965/0000:03:00.0

lustmord:~ #


Good, iwl4965 is bound to it. Double check that the directory content looks like this

Code:
lustmord:/sys/bus/pci/drivers/iwl4965 # ls -lrt

total 0

--w------- 1 root root 4096 Dec 4 21:44 unbind

--w------- 1 root root 4096 Dec 4 21:44 uevent

--w------- 1 root root 4096 Dec 4 21:44 new_id

lrwxrwxrwx 1 root root 0 Dec 4 21:44 module -> ../../../../module/iwl4965

--w------- 1 root root 4096 Dec 4 21:44 bind

lrwxrwxrwx 1 root root 0 Dec 4 21:44 0000:03:00.0 -> ../../../../devices/pci0000:00/0000:00:1c.1/0000:03:00.0

lustmord:/sys/bus/pci/drivers/iwl4965 #


Step 4: Unbind the PCI device from the iwl4965 driver:

Code:
lustmord:~ # echo -n "0000:03:00.0" > /sys/bus/pci/drivers/iwl4965/unbind 

lustmord:~ #

We can verify that, in fact, the driver iwl4965 has been unbound from the PCI device located at 0000:03:00.0 by doing this:

Code:
lustmord:~ # cd /sys/bus/pci/drivers/iwl4965/

lustmord:/sys/bus/pci/drivers/iwl4965 # ls

bind module new_id uevent unbind

lustmord:/sys/bus/pci/drivers/iwl4965 # ls -lrt

total 0

--w------- 1 root root 4096 Dec 4 21:44 uevent

--w------- 1 root root 4096 Dec 4 21:44 new_id

lrwxrwxrwx 1 root root 0 Dec 4 21:44 module -> ../../../../module/iwl4965

--w------- 1 root root 4096 Dec 4 21:44 bind


--w------- 1 root root 0 Dec 4 23:10 unbind

lustmord:/sys/bus/pci/drivers/iwl4965 #

You will notice that the link to the PCI id vanished. That's what we want.


Step 5: Bound the PCI id 0000:03:00.0 to the pciback module

Code:
lustmord:~ # echo -n "0000:03:00.0" > /sys/bus/pci/drivers/pciback/new_slot 

lustmord:~ # echo -n "0000:03:00.0" > /sys/bus/pci/drivers/pciback/bind


Good. Now, verify that the module pciback is seeing the PCI 0000:03:00.0 device:

Code:
lustmord:~ # cd /sys/bus/pci/drivers/pciback/

lustmord:/sys/bus/pci/drivers/pciback # ls -l

total 0

lrwxrwxrwx 1 root root 0 Dec 4 23:25 0000:03:00.0 -> ../../../../devices/pci0000:00/0000:00:1c.1/0000:03:00.0

--w------- 1 root root 0 Dec 4 23:23 bind

lrwxrwxrwx 1 root root 0 Dec 4 22:58 module -> ../../../../module/pciback

--w------- 1 root root 4096 Dec 4 23:19 new_id

--w------- 1 root root 0 Dec 4 23:23 new_slot

-rw------- 1 root root 4096 Dec 4 23:19 permissive

-rw------- 1 root root 4096 Dec 4 23:19 quirks

--w------- 1 root root 4096 Dec 4 23:19 remove_slot

-r-------- 1 root root 4096 Dec 4 23:19 slots

--w------- 1 root root 4096 Dec 4 23:19 uevent

--w------- 1 root root 4096 Dec 4 23:19 unbind

lustmord:/sys/bus/pci/drivers/pciback #


Right, just as we wanted.


Step 6: Allocate the PCI 0000:03:00.0 device to the target domU:

Now, we are in conditions to attach the device to the xen guest which is going to use it. Having the target domU stopped, run the following command to start it with the new device:

Code:
lustmord:~ # xm list

Name ID Mem VCPUs State Time(s)

Domain-0 0 1857 2 r----- 217.7

vm1-sles10 512 1 0.0

vm2-sles10 512 1 0.0

vm3-opensuse11 384 1 0.0

Now, we launch the domU:

Code:
lustmord:~ # xm create pci=0000:03:00.0 /etc/xen/vm/vm3-opensuse11

Using config file "/etc/xen/vm/vm3-opensuse11".

Started domain vm3-opensuse11

lustmord:~ #


Wait until the target domU is running, connect to it and verify that the device was attached correctly using lspci. Once you have done that, proceed like always. Configure the module manually or using yast:

Code:
lustmord:~ # xm list

Name ID Mem VCPUs State Time(s)

Domain-0 0 1592 2 r----- 321.6

vm1-sles10 512 1 0.0

vm2-sles10 512 1 0.0

vm3-opensuse11 1 384 1 -b---- 20.2

lustmord:~ #


Now, connect to the domU:

Code:
lustmord:~ # xm console 1

Security Framework initialized

AppArmor: AppArmor initialized <NULL>

AppArmor: Registered secondary security module capability

Capability LSM initialized as secondary

Mount-cache hash table entries: 512

CPU: L1 I cache: 32K, L1 D cache: 32K

....
...
...
EXT3 FS on xvda2, internal journal

EXT3-fs: mounted filesystem with ordered data mode.

iwl4965: Intel(R) Wireless WiFi Link 4965AGN driver for Linux, 1.2.23ks

iwl4965: Copyright(c) 2003-2007 Intel Corporation

PCI: Enabling device 0000:00:00.0 (0000 -> 0002)

iwl4965: Detected Intel Wireless WiFi Link 4965AGN

iwl4965: Tunable channels: 13 802.11bg, 19 802.11a channels

....
....
....
ip_tables: (C) 2000-2006 Netfilter Core Team

nf_conntrack version 0.5.0 (7168 buckets, 28672 max)




Welcome to openSUSE 11.0 (i586) - Kernel 2.6.25.5-1.1-xen (xvc0).




linux-i8s4 login:

Now you log in and run lspci:

Code:
linux-i8s4 login: root 

password:

Have a lot of fun...

linux-i8s4:~ # lspci

00:00.0 Network controller: Intel Corporation PRO/Wireless 4965 AG or AGN Network Connection (rev 61)

linux-i8s4:~ #


There you have it. That is good. Now you run yast and do all the other things....And that's all there is to it.

分享到:
评论

相关推荐

    How to passthrough your integrated device to a VM on ARM

    本文将详细介绍如何在ARM架构的设备上,使用Xen虚拟化技术实现设备的直通(passthrough)。 首先,需要了解什么是设备直通。设备直通是指将物理硬件设备直接分配给虚拟机,让虚拟机能够直接访问该硬件,而不需要...

    suse xen网桥设置

    在SUSE Linux操作系统中,Xen是一个流行的开源虚拟化平台,它允许你在单一的物理主机上运行多个独立的虚拟机(称为DOMU或Guest VMs)。网桥设置是确保这些虚拟机能够通过主机网络接口与外界通信的关键步骤。在本文中...

    SUSELinux10整合XEN虚拟化技术

    SUSE Linux Enterprise 10 是开放式、灵活安全的企业平台,可安装对于你企业运营的重要应用程式软件和资料库—个桌面系统到资料中心,满足您的各种业务需求。SUSE Linux Enterprise 平台紧密结合了 Novell 系统管理...

    Running Xen A Hands-On Guide to the Art of Virtualization

    ### Xen虚拟化技术详解——《Running Xen:A Hands-On Guide to the Art of Virtualization》精读 #### 一、概述 《Running Xen:A Hands-On Guide to the Art of Virtualization》是一本关于Xen虚拟化技术的专业...

    SUSE工程技术副总裁Ralf Flaxa演讲:SUSE的技术未来

    SUSE的云产品包括SUSE Cloud 2,这是一个零影响的云安装程序,支持多种虚拟化技术,如Hyper-V、VMware、Xen、KVM等。SUSE Cloud 2还提供了灵活的插件模型,以及对Cisco、OpenvSwitch等网络解决方案的支持,以及对EMC...

    xen虚拟机调用usb设备

    ### Xen虚拟机USB Pass-through详解 #### 一、引言 在使用Xen虚拟化平台时,有时我们需要在虚拟机内部使用外部物理机上的USB设备,例如加密狗、U盘等。这种需求在企业环境中非常常见,尤其是在进行开发或部署特定...

    KVM上安装Xen

    在标签部分,列出了"Suse11", "Xen", 和 "KVM",表明这个文档可能特别适用于使用Suse Linux Enterprise Server(SLES)版本11的用户。 文档内容部分涉及了虚拟化技术的历史回顾,包括LXC/Docker、KVM hypervisor、...

    Xen on Arm

    文章《Xen on Arm》深入探讨了在ARM处理器架构上实现Xen虚拟化技术的细节。作者Joo-Young Hwang, Sang-Bum Suh, Sung-Kwan Heo, Chan-Ju Park, Jae-Min Ryu, Seong-Yeol Park, Chul-Ryun Kim均来自韩国三星电子公司...

    xen虚拟化实战

    《Xen虚拟化实战》是一本深入探讨Xen虚拟化技术的专业书籍,旨在帮助读者掌握在实际环境中运用Xen的技巧。Xen是一款开源的全虚拟化解决方案,它允许在一个物理服务器上运行多个独立的操作系统实例,提高了硬件资源的...

    xen 4.0 最新源码 xen 4.0 最新源码

    Xen 4.0 是一个重要的虚拟化技术版本,它为用户提供了一种高效且可靠的基础设施,用于在单个物理服务器上运行多个独立的操作系统实例,称为虚拟机(VMs)。这款开源软件允许资源共享,提高了硬件利用率,并简化了...

    xen相关的资料

    该文档主要介绍了使用SUSE Linux Enterprise Server 11 SP3进行Xen虚拟化的设置与管理。 ##### 1.1 基本组件 Xen虚拟化平台包括以下基本组件: - **Xen Hypervisor**:这是Xen的核心部分,负责在物理服务器上创建...

    xen配置必备,xen开源虚拟机配置文档xl_cfg 中文

    * vcpus=N:虚拟机启动时,处于工作状态(online)的vcpu个数。 * maxvcpus=M:虚拟机允许使用的最大vcpu个数。 * cpus="CPU-LIST":虚拟机允许使用的物理cpu列表。 * cpu_weight=WEIGHT:在同一主机上,比重值为512...

    XEN V1.0.7 [CyberNation]_rat_V|XEN.com_

    从标题来看,"XEN"可能是指一个特定的软件版本或平台,而"V1.0.7"表示这是其发展的第1.0.7个迭代。"[CyberNation]"可能是一个团队、组织或社区的名称,这通常与黑客、安全研究人员或者网络安全社区有关。"rat"通常在...

    Xen3.0虚拟机入门

    ### Xen 3.0 虚拟机入门详解 #### Xen简介 Xen是一款由剑桥大学开发并开源的虚拟机软件,首次发布版本为Xen Release 1.0,时间为2003年10月。Xen以其卓越的性能和广泛的适用性而在虚拟化领域占据了一席之地。它...

    c语言监控xen虚拟机

    在IT行业中,Xen是一种流行的开源虚拟化技术,它允许在一个物理服务器上运行多个独立的操作系统实例,称为虚拟机(VMs)。C语言是系统级编程的常用工具,因此使用C语言来监控Xen虚拟机可以实现高效且灵活的监控解决...

    ubuntu10.04安装xen虚拟机

    Ubuntu 10.04 安装 Xen 虚拟机 Xen 是一个开源的虚拟机监视器,可以在多种操作系统上运行。安装 Xen 虚拟机可以让我们在 Ubuntu 10.04 上运行多个虚拟机,从而提高系统的灵活性和可靠性。本文将指导您如何在 ...

    suse_linux.rar_linux_suse

    - 支持广泛的硬件和虚拟化平台,包括VMware、KVM、Xen等。 5. SUSE Linux的学习路径: - 基础知识:熟悉Linux命令行操作,理解文件系统结构,学会使用YaST和ZYpper。 - 系统管理:掌握网络配置、用户权限管理、...

    xen 安装配置与运维

    **Xen 安装配置与运维详解** Xen 是一款开源的虚拟化平台,它允许在一个物理服务器上创建和运行多个虚拟机(称为 Domains,或 Dom0 和 DomU),从而实现硬件资源的有效利用和隔离。Xen 主要应用于云计算环境,提供...

Global site tag (gtag.js) - Google Analytics