{"action":"created","comment":{"url":"https://api.github.com/repos/OpenXT/cdrom-daemon/pulls/comments/85583129","pull_request_review_id":6293229,"id":85583129,"diff_hunk":"@@ -0,0 +1,328 @@\n+/*\n+ * Copyright (c) 2016 Assured Information Security, Inc.\n+ *\n+ * This program is free software; you can redistribute it and/or modify\n+ * it under the terms of the GNU General Public License as published by\n+ * the Free Software Foundation; either version 2 of the License, or\n+ * (at your option) any later version.\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ * GNU General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU General Public License\n+ * along with this program; if not, write to the Free Software\n+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\n+ */\n+\n+/**\n+ * @file   blktap.c\n+ * @author Jed Lejosne <lejosnej@ainfosec.com>\n+ * @date   20 Oct 2016\n+ *\n+ * @brief  blktap-related functions\n+ *\n+ * This file implements all the code for handling the emulated CDROMs\n+ * exposed to the guests. (the \"iso\" drive)\n+ */\n+\n+#include \"project.h\"\n+\n+static int cdrom_vdev_of_domid(int domid)\n+{\n+  char xpath[256], **devs, *type;\n+  unsigned int i, count;\n+  int vdev, res = -1;\n+\n+  /* Find the CDROM virtual device for the given domid */\n+  snprintf(xpath, sizeof(xpath), \"/local/domain/0/backend/vbd/%d\", domid);\n+  devs = xs_directory(xs_handle, XBT_NULL, xpath, &count);\n+  if (devs) {\n+    for (i = 0; i < count; ++i) {\n+      vdev = strtol(devs[i], NULL, 10);\n+      type = xenstore_be_read(XBT_NULL, domid, vdev, \"device-type\");\n+      if (type != NULL && !strcmp(type, \"cdrom\")) {\n+\t/* CDROM found! */\n+\tres = vdev;\n+\tbreak;\n+      }\n+    }\n+    free(devs);\n+  }\n+\n+  return res;\n+}\n+\n+static int cdrom_tap_minor_of_vdev(int domid, int vdev)\n+{\n+  char *tmp;\n+  int tap_minor = -1;\n+\n+  if (vdev < 0)\n+    return -1;\n+\n+  tmp = xenstore_be_read(XBT_NULL, domid, vdev, \"params\");","path":"src/blktap.c","position":65,"original_position":65,"commit_id":"33079ce7f8c99fc3e92e1a067b908c85ba9166a1","original_commit_id":"33079ce7f8c99fc3e92e1a067b908c85ba9166a1","user":{"login":"rossphilipson","id":5481112,"avatar_url":"https://avatars.githubusercontent.com/u/5481112?v=3","gravatar_id":"","url":"https://api.github.com/users/rossphilipson","html_url":"https://github.com/rossphilipson","followers_url":"https://api.github.com/users/rossphilipson/followers","following_url":"https://api.github.com/users/rossphilipson/following{/other_user}","gists_url":"https://api.github.com/users/rossphilipson/gists{/gist_id}","starred_url":"https://api.github.com/users/rossphilipson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rossphilipson/subscriptions","organizations_url":"https://api.github.com/users/rossphilipson/orgs","repos_url":"https://api.github.com/users/rossphilipson/repos","events_url":"https://api.github.com/users/rossphilipson/events{/privacy}","received_events_url":"https://api.github.com/users/rossphilipson/received_events","type":"User","site_admin":false},"body":"tmp leaked?","created_at":"2016-10-28T18:17:25Z","updated_at":"2016-10-28T18:17:25Z","html_url":"https://github.com/OpenXT/cdrom-daemon/pull/1#discussion_r85583129","pull_request_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/OpenXT/cdrom-daemon/pulls/comments/85583129"},"html":{"href":"https://github.com/OpenXT/cdrom-daemon/pull/1#discussion_r85583129"},"pull_request":{"href":"https://api.github.com/repos/OpenXT/cdrom-daemon/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/OpenXT/cdrom-daemon/pulls/1","id":90390295,"html_url":"https://github.com/OpenXT/cdrom-daemon/pull/1","diff_url":"https://github.com/OpenXT/cdrom-daemon/pull/1.diff","patch_url":"https://github.com/OpenXT/cdrom-daemon/pull/1.patch","issue_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/issues/1","number":1,"state":"open","locked":false,"title":"Initial commit","user":{"login":"jean-edouard","id":7863904,"avatar_url":"https://avatars.githubusercontent.com/u/7863904?v=3","gravatar_id":"","url":"https://api.github.com/users/jean-edouard","html_url":"https://github.com/jean-edouard","followers_url":"https://api.github.com/users/jean-edouard/followers","following_url":"https://api.github.com/users/jean-edouard/following{/other_user}","gists_url":"https://api.github.com/users/jean-edouard/gists{/gist_id}","starred_url":"https://api.github.com/users/jean-edouard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jean-edouard/subscriptions","organizations_url":"https://api.github.com/users/jean-edouard/orgs","repos_url":"https://api.github.com/users/jean-edouard/repos","events_url":"https://api.github.com/users/jean-edouard/events{/privacy}","received_events_url":"https://api.github.com/users/jean-edouard/received_events","type":"User","site_admin":false},"body":"This is the cdrom daemon.\r\n\r\nFor now all it does is change the iso on a blktap-based virtual drive.\r\n\r\nIn the future, this daemon will replace atapi-pt-passthourgh and handle CDROM arbitration.\r\n\r\nThis won't be included in the build for now.\r\n\r\nSigned-off-by: Jed <lejosnej@ainfosec.com>","created_at":"2016-10-21T14:11:10Z","updated_at":"2016-10-28T18:17:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d12d9cd8376d1d95ff9fb31e51e34996bdef1144","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/pulls/1/commits","review_comments_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/pulls/1/comments","review_comment_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/issues/1/comments","statuses_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/statuses/33079ce7f8c99fc3e92e1a067b908c85ba9166a1","head":{"label":"jean-edouard:master","ref":"master","sha":"33079ce7f8c99fc3e92e1a067b908c85ba9166a1","user":{"login":"jean-edouard","id":7863904,"avatar_url":"https://avatars.githubusercontent.com/u/7863904?v=3","gravatar_id":"","url":"https://api.github.com/users/jean-edouard","html_url":"https://github.com/jean-edouard","followers_url":"https://api.github.com/users/jean-edouard/followers","following_url":"https://api.github.com/users/jean-edouard/following{/other_user}","gists_url":"https://api.github.com/users/jean-edouard/gists{/gist_id}","starred_url":"https://api.github.com/users/jean-edouard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jean-edouard/subscriptions","organizations_url":"https://api.github.com/users/jean-edouard/orgs","repos_url":"https://api.github.com/users/jean-edouard/repos","events_url":"https://api.github.com/users/jean-edouard/events{/privacy}","received_events_url":"https://api.github.com/users/jean-edouard/received_events","type":"User","site_admin":false},"repo":{"id":71570293,"name":"cdrom-daemon","full_name":"jean-edouard/cdrom-daemon","owner":{"login":"jean-edouard","id":7863904,"avatar_url":"https://avatars.githubusercontent.com/u/7863904?v=3","gravatar_id":"","url":"https://api.github.com/users/jean-edouard","html_url":"https://github.com/jean-edouard","followers_url":"https://api.github.com/users/jean-edouard/followers","following_url":"https://api.github.com/users/jean-edouard/following{/other_user}","gists_url":"https://api.github.com/users/jean-edouard/gists{/gist_id}","starred_url":"https://api.github.com/users/jean-edouard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jean-edouard/subscriptions","organizations_url":"https://api.github.com/users/jean-edouard/orgs","repos_url":"https://api.github.com/users/jean-edouard/repos","events_url":"https://api.github.com/users/jean-edouard/events{/privacy}","received_events_url":"https://api.github.com/users/jean-edouard/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jean-edouard/cdrom-daemon","description":"The OpenXT daemon that handles guest CDROM operations","fork":true,"url":"https://api.github.com/repos/jean-edouard/cdrom-daemon","forks_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/forks","keys_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/teams","hooks_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/hooks","issue_events_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/issues/events{/number}","events_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/events","assignees_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/assignees{/user}","branches_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/branches{/branch}","tags_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/tags","blobs_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/git/refs{/sha}","trees_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/statuses/{sha}","languages_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/languages","stargazers_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/stargazers","contributors_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/contributors","subscribers_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/subscribers","subscription_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/subscription","commits_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/commits{/sha}","git_commits_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/git/commits{/sha}","comments_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/comments{/number}","issue_comment_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/issues/comments{/number}","contents_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/contents/{+path}","compare_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/merges","archive_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/downloads","issues_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/issues{/number}","pulls_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/pulls{/number}","milestones_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/milestones{/number}","notifications_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/labels{/name}","releases_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/releases{/id}","deployments_url":"https://api.github.com/repos/jean-edouard/cdrom-daemon/deployments","created_at":"2016-10-21T14:04:44Z","updated_at":"2016-10-21T14:08:57Z","pushed_at":"2016-10-21T14:08:56Z","git_url":"git://github.com/jean-edouard/cdrom-daemon.git","ssh_url":"git@github.com:jean-edouard/cdrom-daemon.git","clone_url":"https://github.com/jean-edouard/cdrom-daemon.git","svn_url":"https://github.com/jean-edouard/cdrom-daemon","homepage":null,"size":18,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"OpenXT:master","ref":"master","sha":"4e904fb1758d2cca0fd4beb22d4133630c514ba1","user":{"login":"OpenXT","id":7283187,"avatar_url":"https://avatars.githubusercontent.com/u/7283187?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenXT","html_url":"https://github.com/OpenXT","followers_url":"https://api.github.com/users/OpenXT/followers","following_url":"https://api.github.com/users/OpenXT/following{/other_user}","gists_url":"https://api.github.com/users/OpenXT/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenXT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenXT/subscriptions","organizations_url":"https://api.github.com/users/OpenXT/orgs","repos_url":"https://api.github.com/users/OpenXT/repos","events_url":"https://api.github.com/users/OpenXT/events{/privacy}","received_events_url":"https://api.github.com/users/OpenXT/received_events","type":"Organization","site_admin":false},"repo":{"id":71570274,"name":"cdrom-daemon","full_name":"OpenXT/cdrom-daemon","owner":{"login":"OpenXT","id":7283187,"avatar_url":"https://avatars.githubusercontent.com/u/7283187?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenXT","html_url":"https://github.com/OpenXT","followers_url":"https://api.github.com/users/OpenXT/followers","following_url":"https://api.github.com/users/OpenXT/following{/other_user}","gists_url":"https://api.github.com/users/OpenXT/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenXT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenXT/subscriptions","organizations_url":"https://api.github.com/users/OpenXT/orgs","repos_url":"https://api.github.com/users/OpenXT/repos","events_url":"https://api.github.com/users/OpenXT/events{/privacy}","received_events_url":"https://api.github.com/users/OpenXT/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OpenXT/cdrom-daemon","description":"The OpenXT daemon that handles guest CDROM operations","fork":false,"url":"https://api.github.com/repos/OpenXT/cdrom-daemon","forks_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/forks","keys_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/teams","hooks_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/hooks","issue_events_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/issues/events{/number}","events_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/events","assignees_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/assignees{/user}","branches_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/branches{/branch}","tags_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/tags","blobs_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/git/refs{/sha}","trees_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/statuses/{sha}","languages_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/languages","stargazers_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/stargazers","contributors_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/contributors","subscribers_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/subscribers","subscription_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/subscription","commits_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/commits{/sha}","git_commits_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/git/commits{/sha}","comments_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/comments{/number}","issue_comment_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/issues/comments{/number}","contents_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/contents/{+path}","compare_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/merges","archive_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/downloads","issues_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/issues{/number}","pulls_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/pulls{/number}","milestones_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/milestones{/number}","notifications_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/labels{/name}","releases_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/releases{/id}","deployments_url":"https://api.github.com/repos/OpenXT/cdrom-daemon/deployments","created_at":"2016-10-21T14:04:36Z","updated_at":"2016-10-21T14:08:15Z","pushed_at":"2016-10-21T14:11:10Z","git_url":"git://github.com/OpenXT/cdrom-daemon.git","ssh_url":"git@github.com:OpenXT/cdrom-daemon.git","clone_url":"https://github.com/OpenXT/cdrom-daemon.git","svn_url":"https://github.com/OpenXT/cdrom-daemon","homepage":null,"size":19,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OpenXT/cdrom-daemon/pulls/1"},"html":{"href":"https://github.com/OpenXT/cdrom-daemon/pull/1"},"issue":{"href":"https://api.github.com/repos/OpenXT/cdrom-daemon/issues/1"},"comments":{"href":"https://api.github.com/repos/OpenXT/cdrom-daemon/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/OpenXT/cdrom-daemon/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/OpenXT/cdrom-daemon/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OpenXT/cdrom-daemon/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/OpenXT/cdrom-daemon/statuses/33079ce7f8c99fc3e92e1a067b908c85ba9166a1"}}}}
{"actor":{"display_login":"rossphilipson"}}