{"action":"created","issue":{"url":"https://api.github.com/repos/lxc/lxd/issues/2535","repository_url":"https://api.github.com/repos/lxc/lxd","labels_url":"https://api.github.com/repos/lxc/lxd/issues/2535/labels{/name}","comments_url":"https://api.github.com/repos/lxc/lxd/issues/2535/comments","events_url":"https://api.github.com/repos/lxc/lxd/issues/2535/events","html_url":"https://github.com/lxc/lxd/pull/2535","id":184193189,"number":2535,"title":"add gpu device type","user":{"login":"brauner","id":7353573,"avatar_url":"https://avatars.githubusercontent.com/u/7353573?v=3","gravatar_id":"","url":"https://api.github.com/users/brauner","html_url":"https://github.com/brauner","followers_url":"https://api.github.com/users/brauner/followers","following_url":"https://api.github.com/users/brauner/following{/other_user}","gists_url":"https://api.github.com/users/brauner/gists{/gist_id}","starred_url":"https://api.github.com/users/brauner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brauner/subscriptions","organizations_url":"https://api.github.com/users/brauner/orgs","repos_url":"https://api.github.com/users/brauner/repos","events_url":"https://api.github.com/users/brauner/events{/privacy}","received_events_url":"https://api.github.com/users/brauner/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":12,"created_at":"2016-10-20T10:35:02Z","updated_at":"2016-10-22T00:49:39Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/lxc/lxd/pulls/2535","html_url":"https://github.com/lxc/lxd/pull/2535","diff_url":"https://github.com/lxc/lxd/pull/2535.diff","patch_url":"https://github.com/lxc/lxd/pull/2535.patch"},"body":"- lxc config device add c1 gpu0 gpu => Pass everything we have\r\n- lxc config device add c1 gpu0 gpu vendor=10de => Pass whatever we have from nvidia\r\n- lxc config device add c1 gpu0 gpu vendor=10de id=1 => Pass the second nvidia GPU\r\n- lxc config device add c1 gpu0 gpu pci=0000:02:08.0 => Pass whatever GPU is at that PCI address\r\n\r\nThis parses /sys/bus/pci/devices/* and looks for the drm subfolder. All\r\nsubfolders under that, e.g.\r\n\r\n\tcard0\r\n\tcontrolD64\r\n\trenderD128\r\n\r\nbelong to the same PCI address and probably all need to be handed to the\r\ncontainer when the user somehow selects card0.\r\nWe then retrieve the vendor ID, and if available the device ID from\r\n\r\n\t/sys/bus/pci/devices/*/vendor\r\n\t/sys/bus/pci/devices/*/device\r\n\r\nThe major and minor number for each device can be gathered from the\r\n\r\n\tcard0/dev\r\n\tcontrolD64/dev\r\n\trenderD128/dev\r\n\r\nfiles.\r\n\r\nIf we detect that the vendor ID is Nvidia, we also parse /dev and look for\r\n\r\n\t/dev/nvidia[0-9]+\r\n\r\nentries. We thereby associate the correct /dev/nvidia* entry with the correct\r\n/dev/card* entry, e.g. we correlate\r\n\r\n\t/dev/card0\r\nand\r\n\r\n    /dev/nvidia0.\r\n\r\nFinally, we store any residual /dev/nvidia[^0-9]+ mounts that are not cards\r\nbecause we need to assume that if /dev/nvidia[0-9]+ is requested then the other\r\nfiles are necessary for correct functionality of that card and need to be\r\nmounted into every container that also mounts that card.\r\n\r\nSigned-off-by: Christian Brauner <christian.brauner@canonical.com>"},"comment":{"url":"https://api.github.com/repos/lxc/lxd/issues/comments/255496448","html_url":"https://github.com/lxc/lxd/pull/2535#issuecomment-255496448","issue_url":"https://api.github.com/repos/lxc/lxd/issues/2535","id":255496448,"user":{"login":"stgraber","id":2230599,"avatar_url":"https://avatars.githubusercontent.com/u/2230599?v=3","gravatar_id":"","url":"https://api.github.com/users/stgraber","html_url":"https://github.com/stgraber","followers_url":"https://api.github.com/users/stgraber/followers","following_url":"https://api.github.com/users/stgraber/following{/other_user}","gists_url":"https://api.github.com/users/stgraber/gists{/gist_id}","starred_url":"https://api.github.com/users/stgraber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stgraber/subscriptions","organizations_url":"https://api.github.com/users/stgraber/orgs","repos_url":"https://api.github.com/users/stgraber/repos","events_url":"https://api.github.com/users/stgraber/events{/privacy}","received_events_url":"https://api.github.com/users/stgraber/received_events","type":"User","site_admin":false},"created_at":"2016-10-22T00:49:39Z","updated_at":"2016-10-22T00:49:39Z","body":"jenkins: test this please"}}
{"actor":{"display_login":"stgraber"}}