{"action":"created","comment":{"url":"https://api.github.com/repos/kata-containers/runtime/pulls/comments/213520900","pull_request_review_id":150374700,"id":213520900,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMzUyMDkwMA==","diff_hunk":"@@ -27,38 +30,49 @@ func NewGenericDevice(devInfo *config.DeviceInfo) *GenericDevice {\n \n // Attach is standard interface of api.Device\n func (device *GenericDevice) Attach(devReceiver api.DeviceReceiver) error {\n-\tif device.DeviceInfo.Hotplugged {\n-\t\treturn nil\n-\t}\n-\n+\tdevice.AttachCount++\n \treturn nil\n }\n \n // Detach is standard interface of api.Device\n func (device *GenericDevice) Detach(devReceiver api.DeviceReceiver) error {\n-\tif !device.DeviceInfo.Hotplugged {\n-\t\treturn nil\n-\t}\n-\n+\tdevice.AttachCount--\n \treturn nil\n }\n \n-// IsAttached checks if the device is attached\n-func (device *GenericDevice) IsAttached() bool {\n-\treturn device.DeviceInfo.Hotplugged\n+// DeviceType is standard interface of api.Device, it returns device type\n+func (device *GenericDevice) DeviceType() config.DeviceType {\n+\treturn config.DeviceGeneric\n+}\n+\n+// GetDeviceInfo returns device information used for creating\n+func (device *GenericDevice) GetDeviceInfo() interface{} {\n+\treturn device.DeviceInfo\n+}\n+\n+// GetAttachCount returns how many times the device has been attached\n+func (device *GenericDevice) GetAttachCount() int {\n+\treturn device.AttachCount\n }\n \n // DeviceID returns device ID\n func (device *GenericDevice) DeviceID() string {\n \treturn device.ID\n }\n \n-// DeviceType is standard interface of api.Device, it returns device type\n-func (device *GenericDevice) DeviceType() config.DeviceType {\n-\treturn config.DeviceGeneric\n+// HostPath return host path of device\n+func (device *GenericDevice) GetHostPath() string {\n+\treturn device.DeviceInfo.HostPath\n }\n \n-// GetDeviceInfo returns device information used for creating\n-func (device *GenericDevice) GetDeviceInfo() interface{} {\n-\treturn device.DeviceInfo\n+// Reference adds one reference to device","path":"virtcontainers/device/drivers/generic.go","position":66,"original_position":66,"commit_id":"dfc1ae112c6fa5148d12dd990b0565ef357ce31f","original_commit_id":"dfc1ae112c6fa5148d12dd990b0565ef357ce31f","user":{"login":"WeiZhang555","id":1203611,"node_id":"MDQ6VXNlcjEyMDM2MTE=","avatar_url":"https://avatars2.githubusercontent.com/u/1203611?v=4","gravatar_id":"","url":"https://api.github.com/users/WeiZhang555","html_url":"https://github.com/WeiZhang555","followers_url":"https://api.github.com/users/WeiZhang555/followers","following_url":"https://api.github.com/users/WeiZhang555/following{/other_user}","gists_url":"https://api.github.com/users/WeiZhang555/gists{/gist_id}","starred_url":"https://api.github.com/users/WeiZhang555/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WeiZhang555/subscriptions","organizations_url":"https://api.github.com/users/WeiZhang555/orgs","repos_url":"https://api.github.com/users/WeiZhang555/repos","events_url":"https://api.github.com/users/WeiZhang555/events{/privacy}","received_events_url":"https://api.github.com/users/WeiZhang555/received_events","type":"User","site_admin":false},"body":"Let's me check whether lint is OK without this comments","created_at":"2018-08-29T01:31:31Z","updated_at":"2018-08-29T01:31:31Z","html_url":"https://github.com/kata-containers/runtime/pull/655#discussion_r213520900","pull_request_url":"https://api.github.com/repos/kata-containers/runtime/pulls/655","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/kata-containers/runtime/pulls/comments/213520900"},"html":{"href":"https://github.com/kata-containers/runtime/pull/655#discussion_r213520900"},"pull_request":{"href":"https://api.github.com/repos/kata-containers/runtime/pulls/655"}},"in_reply_to_id":213379108},"pull_request":{"url":"https://api.github.com/repos/kata-containers/runtime/pulls/655","id":211473576,"node_id":"MDExOlB1bGxSZXF1ZXN0MjExNDczNTc2","html_url":"https://github.com/kata-containers/runtime/pull/655","diff_url":"https://github.com/kata-containers/runtime/pull/655.diff","patch_url":"https://github.com/kata-containers/runtime/pull/655.patch","issue_url":"https://api.github.com/repos/kata-containers/runtime/issues/655","number":655,"state":"open","locked":false,"title":"[WIP]Add ref counter for devices","user":{"login":"WeiZhang555","id":1203611,"node_id":"MDQ6VXNlcjEyMDM2MTE=","avatar_url":"https://avatars2.githubusercontent.com/u/1203611?v=4","gravatar_id":"","url":"https://api.github.com/users/WeiZhang555","html_url":"https://github.com/WeiZhang555","followers_url":"https://api.github.com/users/WeiZhang555/followers","following_url":"https://api.github.com/users/WeiZhang555/following{/other_user}","gists_url":"https://api.github.com/users/WeiZhang555/gists{/gist_id}","starred_url":"https://api.github.com/users/WeiZhang555/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WeiZhang555/subscriptions","organizations_url":"https://api.github.com/users/WeiZhang555/orgs","repos_url":"https://api.github.com/users/WeiZhang555/repos","events_url":"https://api.github.com/users/WeiZhang555/events{/privacy}","received_events_url":"https://api.github.com/users/WeiZhang555/received_events","type":"User","site_admin":false},"body":"devices: add reference count for devices.\r\n\r\nFixes #635\r\n\r\nRemove `Hotplugged bool` field from device and add two new fields\r\ninstead:\r\n* `RefCount`: how many references to this device. One device can be\r\nreferenced(`NewDevice()`) many times by same/different container(s),\r\ntwo devices are regarded identical if they have same hostPath\r\n* `AttachCount`: how many times this device has been attached. A device\r\ncan only be hotplugged once to the qemu, every new Attach command will\r\nadd the AttachCount, and real `Detach` will be done only when\r\n`AttachCount == 0`\r\n\r\nSigned-off-by: Wei Zhang <zhangwei555@huawei.com>","created_at":"2018-08-28T15:55:53Z","updated_at":"2018-08-29T01:31:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9c3cb47dc8c792b3bc3c7b2a1635dd6d159a6062","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/kata-containers/runtime/pulls/655/commits","review_comments_url":"https://api.github.com/repos/kata-containers/runtime/pulls/655/comments","review_comment_url":"https://api.github.com/repos/kata-containers/runtime/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kata-containers/runtime/issues/655/comments","statuses_url":"https://api.github.com/repos/kata-containers/runtime/statuses/dfc1ae112c6fa5148d12dd990b0565ef357ce31f","head":{"label":"WeiZhang555:add-ref-counter-for-devices","ref":"add-ref-counter-for-devices","sha":"dfc1ae112c6fa5148d12dd990b0565ef357ce31f","user":{"login":"WeiZhang555","id":1203611,"node_id":"MDQ6VXNlcjEyMDM2MTE=","avatar_url":"https://avatars2.githubusercontent.com/u/1203611?v=4","gravatar_id":"","url":"https://api.github.com/users/WeiZhang555","html_url":"https://github.com/WeiZhang555","followers_url":"https://api.github.com/users/WeiZhang555/followers","following_url":"https://api.github.com/users/WeiZhang555/following{/other_user}","gists_url":"https://api.github.com/users/WeiZhang555/gists{/gist_id}","starred_url":"https://api.github.com/users/WeiZhang555/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WeiZhang555/subscriptions","organizations_url":"https://api.github.com/users/WeiZhang555/orgs","repos_url":"https://api.github.com/users/WeiZhang555/repos","events_url":"https://api.github.com/users/WeiZhang555/events{/privacy}","received_events_url":"https://api.github.com/users/WeiZhang555/received_events","type":"User","site_admin":false},"repo":{"id":113016558,"node_id":"MDEwOlJlcG9zaXRvcnkxMTMwMTY1NTg=","name":"runtime","full_name":"WeiZhang555/runtime","owner":{"login":"WeiZhang555","id":1203611,"node_id":"MDQ6VXNlcjEyMDM2MTE=","avatar_url":"https://avatars2.githubusercontent.com/u/1203611?v=4","gravatar_id":"","url":"https://api.github.com/users/WeiZhang555","html_url":"https://github.com/WeiZhang555","followers_url":"https://api.github.com/users/WeiZhang555/followers","following_url":"https://api.github.com/users/WeiZhang555/following{/other_user}","gists_url":"https://api.github.com/users/WeiZhang555/gists{/gist_id}","starred_url":"https://api.github.com/users/WeiZhang555/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WeiZhang555/subscriptions","organizations_url":"https://api.github.com/users/WeiZhang555/orgs","repos_url":"https://api.github.com/users/WeiZhang555/repos","events_url":"https://api.github.com/users/WeiZhang555/events{/privacy}","received_events_url":"https://api.github.com/users/WeiZhang555/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/WeiZhang555/runtime","description":"Kata containers runtimes","fork":true,"url":"https://api.github.com/repos/WeiZhang555/runtime","forks_url":"https://api.github.com/repos/WeiZhang555/runtime/forks","keys_url":"https://api.github.com/repos/WeiZhang555/runtime/keys{/key_id}","collaborators_url":"https://api.github.com/repos/WeiZhang555/runtime/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/WeiZhang555/runtime/teams","hooks_url":"https://api.github.com/repos/WeiZhang555/runtime/hooks","issue_events_url":"https://api.github.com/repos/WeiZhang555/runtime/issues/events{/number}","events_url":"https://api.github.com/repos/WeiZhang555/runtime/events","assignees_url":"https://api.github.com/repos/WeiZhang555/runtime/assignees{/user}","branches_url":"https://api.github.com/repos/WeiZhang555/runtime/branches{/branch}","tags_url":"https://api.github.com/repos/WeiZhang555/runtime/tags","blobs_url":"https://api.github.com/repos/WeiZhang555/runtime/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/WeiZhang555/runtime/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/WeiZhang555/runtime/git/refs{/sha}","trees_url":"https://api.github.com/repos/WeiZhang555/runtime/git/trees{/sha}","statuses_url":"https://api.github.com/repos/WeiZhang555/runtime/statuses/{sha}","languages_url":"https://api.github.com/repos/WeiZhang555/runtime/languages","stargazers_url":"https://api.github.com/repos/WeiZhang555/runtime/stargazers","contributors_url":"https://api.github.com/repos/WeiZhang555/runtime/contributors","subscribers_url":"https://api.github.com/repos/WeiZhang555/runtime/subscribers","subscription_url":"https://api.github.com/repos/WeiZhang555/runtime/subscription","commits_url":"https://api.github.com/repos/WeiZhang555/runtime/commits{/sha}","git_commits_url":"https://api.github.com/repos/WeiZhang555/runtime/git/commits{/sha}","comments_url":"https://api.github.com/repos/WeiZhang555/runtime/comments{/number}","issue_comment_url":"https://api.github.com/repos/WeiZhang555/runtime/issues/comments{/number}","contents_url":"https://api.github.com/repos/WeiZhang555/runtime/contents/{+path}","compare_url":"https://api.github.com/repos/WeiZhang555/runtime/compare/{base}...{head}","merges_url":"https://api.github.com/repos/WeiZhang555/runtime/merges","archive_url":"https://api.github.com/repos/WeiZhang555/runtime/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/WeiZhang555/runtime/downloads","issues_url":"https://api.github.com/repos/WeiZhang555/runtime/issues{/number}","pulls_url":"https://api.github.com/repos/WeiZhang555/runtime/pulls{/number}","milestones_url":"https://api.github.com/repos/WeiZhang555/runtime/milestones{/number}","notifications_url":"https://api.github.com/repos/WeiZhang555/runtime/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/WeiZhang555/runtime/labels{/name}","releases_url":"https://api.github.com/repos/WeiZhang555/runtime/releases{/id}","deployments_url":"https://api.github.com/repos/WeiZhang555/runtime/deployments","created_at":"2017-12-04T08:35:00Z","updated_at":"2018-04-18T02:49:56Z","pushed_at":"2018-08-28T15:54:08Z","git_url":"git://github.com/WeiZhang555/runtime.git","ssh_url":"git@github.com:WeiZhang555/runtime.git","clone_url":"https://github.com/WeiZhang555/runtime.git","svn_url":"https://github.com/WeiZhang555/runtime","homepage":null,"size":4785,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"kata-containers:master","ref":"master","sha":"a3038924fbf93bb59220ab9d33de667d29ffceab","user":{"login":"kata-containers","id":33289952,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMzMjg5OTUy","avatar_url":"https://avatars3.githubusercontent.com/u/33289952?v=4","gravatar_id":"","url":"https://api.github.com/users/kata-containers","html_url":"https://github.com/kata-containers","followers_url":"https://api.github.com/users/kata-containers/followers","following_url":"https://api.github.com/users/kata-containers/following{/other_user}","gists_url":"https://api.github.com/users/kata-containers/gists{/gist_id}","starred_url":"https://api.github.com/users/kata-containers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kata-containers/subscriptions","organizations_url":"https://api.github.com/users/kata-containers/orgs","repos_url":"https://api.github.com/users/kata-containers/repos","events_url":"https://api.github.com/users/kata-containers/events{/privacy}","received_events_url":"https://api.github.com/users/kata-containers/received_events","type":"Organization","site_admin":false},"repo":{"id":110539997,"node_id":"MDEwOlJlcG9zaXRvcnkxMTA1Mzk5OTc=","name":"runtime","full_name":"kata-containers/runtime","owner":{"login":"kata-containers","id":33289952,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMzMjg5OTUy","avatar_url":"https://avatars3.githubusercontent.com/u/33289952?v=4","gravatar_id":"","url":"https://api.github.com/users/kata-containers","html_url":"https://github.com/kata-containers","followers_url":"https://api.github.com/users/kata-containers/followers","following_url":"https://api.github.com/users/kata-containers/following{/other_user}","gists_url":"https://api.github.com/users/kata-containers/gists{/gist_id}","starred_url":"https://api.github.com/users/kata-containers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kata-containers/subscriptions","organizations_url":"https://api.github.com/users/kata-containers/orgs","repos_url":"https://api.github.com/users/kata-containers/repos","events_url":"https://api.github.com/users/kata-containers/events{/privacy}","received_events_url":"https://api.github.com/users/kata-containers/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kata-containers/runtime","description":"Kata Containers runtime","fork":false,"url":"https://api.github.com/repos/kata-containers/runtime","forks_url":"https://api.github.com/repos/kata-containers/runtime/forks","keys_url":"https://api.github.com/repos/kata-containers/runtime/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kata-containers/runtime/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kata-containers/runtime/teams","hooks_url":"https://api.github.com/repos/kata-containers/runtime/hooks","issue_events_url":"https://api.github.com/repos/kata-containers/runtime/issues/events{/number}","events_url":"https://api.github.com/repos/kata-containers/runtime/events","assignees_url":"https://api.github.com/repos/kata-containers/runtime/assignees{/user}","branches_url":"https://api.github.com/repos/kata-containers/runtime/branches{/branch}","tags_url":"https://api.github.com/repos/kata-containers/runtime/tags","blobs_url":"https://api.github.com/repos/kata-containers/runtime/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kata-containers/runtime/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kata-containers/runtime/git/refs{/sha}","trees_url":"https://api.github.com/repos/kata-containers/runtime/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kata-containers/runtime/statuses/{sha}","languages_url":"https://api.github.com/repos/kata-containers/runtime/languages","stargazers_url":"https://api.github.com/repos/kata-containers/runtime/stargazers","contributors_url":"https://api.github.com/repos/kata-containers/runtime/contributors","subscribers_url":"https://api.github.com/repos/kata-containers/runtime/subscribers","subscription_url":"https://api.github.com/repos/kata-containers/runtime/subscription","commits_url":"https://api.github.com/repos/kata-containers/runtime/commits{/sha}","git_commits_url":"https://api.github.com/repos/kata-containers/runtime/git/commits{/sha}","comments_url":"https://api.github.com/repos/kata-containers/runtime/comments{/number}","issue_comment_url":"https://api.github.com/repos/kata-containers/runtime/issues/comments{/number}","contents_url":"https://api.github.com/repos/kata-containers/runtime/contents/{+path}","compare_url":"https://api.github.com/repos/kata-containers/runtime/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kata-containers/runtime/merges","archive_url":"https://api.github.com/repos/kata-containers/runtime/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kata-containers/runtime/downloads","issues_url":"https://api.github.com/repos/kata-containers/runtime/issues{/number}","pulls_url":"https://api.github.com/repos/kata-containers/runtime/pulls{/number}","milestones_url":"https://api.github.com/repos/kata-containers/runtime/milestones{/number}","notifications_url":"https://api.github.com/repos/kata-containers/runtime/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kata-containers/runtime/labels{/name}","releases_url":"https://api.github.com/repos/kata-containers/runtime/releases{/id}","deployments_url":"https://api.github.com/repos/kata-containers/runtime/deployments","created_at":"2017-11-13T11:29:03Z","updated_at":"2018-08-28T14:10:23Z","pushed_at":"2018-08-28T22:37:13Z","git_url":"git://github.com/kata-containers/runtime.git","ssh_url":"git@github.com:kata-containers/runtime.git","clone_url":"https://github.com/kata-containers/runtime.git","svn_url":"https://github.com/kata-containers/runtime","homepage":"","size":4902,"stargazers_count":471,"watchers_count":471,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":104,"mirror_url":null,"archived":false,"open_issues_count":161,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":104,"open_issues":161,"watchers":471,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kata-containers/runtime/pulls/655"},"html":{"href":"https://github.com/kata-containers/runtime/pull/655"},"issue":{"href":"https://api.github.com/repos/kata-containers/runtime/issues/655"},"comments":{"href":"https://api.github.com/repos/kata-containers/runtime/issues/655/comments"},"review_comments":{"href":"https://api.github.com/repos/kata-containers/runtime/pulls/655/comments"},"review_comment":{"href":"https://api.github.com/repos/kata-containers/runtime/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kata-containers/runtime/pulls/655/commits"},"statuses":{"href":"https://api.github.com/repos/kata-containers/runtime/statuses/dfc1ae112c6fa5148d12dd990b0565ef357ce31f"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"WeiZhang555"}}