Re: [libvirt] PCI devices passthough to LXC containers using libvirt

Hi Thanks for the reply. I think the links that you provided show how to deal with pci devices in case the hypervisor is kvm. Please correct me if I am wrong. But I am using LXC containers.I have skimmed through the libvirt lxc driver code and found no functionality of allowing specified devices into a container exists other than currently where only hard coded devices are allowed which can be seen in the file lxc_controller.c struct cgroup_device_policy devices[] = { {'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_NULL}, {'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_ZERO}, {'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_FULL}, {'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_RANDOM}, {'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_URANDOM}, {'c', LXC_DEV_MAJ_TTY, LXC_DEV_MIN_TTY}, {'c', LXC_DEV_MAJ_TTY, LXC_DEV_MIN_PTMX}, {0, 0, 0}}; Please confirm this or let me know if there is any other interface libvirt_lxc provides to allow specific pci/other devices into container. Thanks in advance Regards Devendra ----- Original Message ----- From: "Alex Jia" <ajia@redhat.com> To: "Devendra K. Modium" <dmodium@isi.edu> Sent: Thursday, July 28, 2011 3:22:36 AM Subject: Re: [libvirt] PCI devices passthough to LXC containers using libvirt On 07/28/2011 05:13 AM, Devendra K. Modium wrote:
Hi All
Please let me know if anyone have given access to PCI devices for a LXC container.
I have tried getting the xml from "virsh nodedev-dumpxml pci_device" and added to the libvirt xml file as shown below
<device> <name>pci_0000_03_00_0</name> <parent>pci_0000_00_03_0</parent> <driver> <name>nvidia</name> </driver> <capability type='pci'> <domain>0</domain> <bus>3</bus> <slot>0</slot> <function>0</function> <product id='0x06fd' /> <vendor id='0x10de'>nVidia Corporation</vendor> </capability> </device> You shouldn't directly add the above xml to guest xml configuration, here is a usage, it should be helpful for you:
http://libvirt.org/formatdomain.html#elementsUSB http://fedoraproject.org/wiki/Category:Virtualization_KVM_PCI_Device_Assignm... Good Luck! Alex
But it didn't work. I see the logs and it says couldn't get physical and virtual functions of these devices with error
get_physical_function_linux:323 : Attempting to get SR IOV physical function for device with sysfs path '/sys/devices/pci0000:00/0000:00:00.0' 16:48:34.033: 13802: debug : get_sriov_function:270 : Attempting to resolve device path from device link '/sys/devices/pci0000:00/0000:00:00.0/physfn' 16:48:34.033: 13802: debug : get_sriov_function:274 : SR IOV function link '/sys/devices/pci0000:00/0000:00:00.0/physfn' does not exist 16:48:34.033: 13802: debug : get_virtual_functions_linux:348 : Attempting to get SR IOV virtual functions for devicewith sysfs path '/sys/devices/pci0000:00/0000:00:00.0'
If anyone got some guidelines how to debug, please let me know.
Thanks in advance
Regards Devendra
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

Quoting Devendra K. Modium (dmodium@isi.edu):
Hi
Thanks for the reply.
I think the links that you provided show how to deal with pci devices in case the hypervisor is kvm. Please correct me if I am wrong.
But I am using LXC containers.I have skimmed through the libvirt lxc driver code and found no functionality of allowing specified devices into a container exists other than currently where only hard coded devices are allowed which can be seen in the file lxc_controller.c
struct cgroup_device_policy devices[] = { {'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_NULL}, {'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_ZERO}, {'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_FULL}, {'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_RANDOM}, {'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_URANDOM}, {'c', LXC_DEV_MAJ_TTY, LXC_DEV_MIN_TTY}, {'c', LXC_DEV_MAJ_TTY, LXC_DEV_MIN_PTMX}, {0, 0, 0}};
Please confirm this or let me know if there is any other interface libvirt_lxc provides to allow specific pci/other devices into container.
The qemu driver allows for this list to be specified in the config file. You could send a patch for the lxc driver to do the same. You also could go further and add xml format to add extra entries. But as this is implemented using cgroups, the other thing you can do is to manually, after you start the container, add the devices whitelist entries yourself. Depending on how you're using it this might suffice... -serge
participants (2)
-
Devendra K. Modium
-
Serge Hallyn