{"action":"created","comment":{"url":"https://api.github.com/repos/01org/ciao/pulls/comments/90993116","pull_request_review_id":11505336,"id":90993116,"diff_hunk":"@@ -0,0 +1,198 @@\n+//\n+// Copyright (c) 2016 Intel Corporation\n+//\n+// Licensed under the Apache License, Version 2.0 (the \"License\");\n+// you may not use this file except in compliance with the License.\n+// You may obtain a copy of the License at\n+//\n+//      http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing, software\n+// distributed under the License is distributed on an \"AS IS\" BASIS,\n+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+// See the License for the specific language governing permissions and\n+// limitations under the License.\n+//\n+\n+package main\n+\n+import (\n+\t\"bytes\"\n+\t\"context\"\n+\t\"fmt\"\n+\t\"io\"\n+\t\"net\"\n+\t\"net/http\"\n+\t\"os\"\n+\t\"path\"\n+\t\"text/tabwriter\"\n+\t\"time\"\n+\n+\t\"github.com/01org/ciao/qemu\"\n+)\n+\n+func bootVM(ctx context.Context, ws *workspace) error {\n+\tdisconnectedCh := make(chan struct{})\n+\tsocket := path.Join(ws.instanceDir, \"socket\")\n+\tqmp, _, err := qemu.QMPStart(ctx, socket, qemu.QMPConfig{}, disconnectedCh)\n+\tif err == nil {\n+\t\tqmp.Shutdown()\n+\t\treturn fmt.Errorf(\"VM is already running\")\n+\t}\n+\n+\tvmImage := path.Join(ws.instanceDir, \"image.qcow2\")\n+\tisoPath := path.Join(ws.instanceDir, \"config.iso\")\n+\tfsdevParam := fmt.Sprintf(\"local,security_model=passthrough,id=fsdev0,path=%s\",\n+\t\tws.GoPath)\n+\targs := []string{\n+\t\t\"-qmp\", fmt.Sprintf(\"unix:%s,server,nowait\", socket), \"-m\", \"8G\", \"-smp\", \"cpus=2\",\n+\t\t\"-drive\", fmt.Sprintf(\"file=%s,if=virtio,aio=threads,format=qcow2\", vmImage),\n+\t\t\"-drive\", fmt.Sprintf(\"file=%s,if=virtio,media=cdrom\", isoPath),\n+\t\t\"-daemonize\", \"-enable-kvm\", \"-cpu\", \"host\",\n+\t\t\"-net\", \"user,hostfwd=tcp::10022-:22\", \"-net\", \"nic,model=virtio\",\n+\t\t\"-fsdev\", fsdevParam,\n+\t\t\"-device\", \"virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=hostgo\",\n+\t\t\"-display\", \"none\", \"-vga\", \"none\",\n+\t}\n+\toutput, err := qemu.LaunchCustomQemu(ctx, \"\", args, nil, nil)\n+\tif err != nil {\n+\t\treturn fmt.Errorf(\"Failed to launch qemu : %v, %s\", err, output)\n+\t}\n+\treturn nil\n+}\n+\n+func executeQMPCommand(ctx context.Context, instanceDir string,\n+\tcmd func(ctx context.Context, q *qemu.QMP) error) error {\n+\tsocket := path.Join(instanceDir, \"socket\")\n+\tdisconnectedCh := make(chan struct{})\n+\tqmp, _, err := qemu.QMPStart(ctx, socket, qemu.QMPConfig{}, disconnectedCh)\n+\tif err != nil {\n+\t\treturn fmt.Errorf(\"Failed to connect to VM : %v\", err)\n+\t}\n+\tdefer qmp.Shutdown()\n+\n+\terr = qmp.ExecuteQMPCapabilities(ctx)\n+\tif err != nil {\n+\t\treturn fmt.Errorf(\"Unable to query QEMU caps : %v\", err)\n+\t}\n+\n+\terr = cmd(ctx, qmp)\n+\tif err != nil {\n+\t\treturn fmt.Errorf(\"Unable to execute vm command : %v\", err)\n+\t}\n+\n+\treturn nil\n+}\n+\n+func stopVM(ctx context.Context, instanceDir string) error {\n+\treturn executeQMPCommand(ctx, instanceDir, func(ctx context.Context, q *qemu.QMP) error {\n+\t\treturn q.ExecuteSystemPowerdown(ctx)\n+\t})\n+}\n+\n+func quitVM(ctx context.Context, instanceDir string) error {\n+\treturn executeQMPCommand(ctx, instanceDir, func(ctx context.Context, q *qemu.QMP) error {\n+\t\treturn q.ExecuteQuit(ctx)\n+\t})\n+}\n+\n+func statusVM(ctx context.Context, instanceDir string) {\n+\tstatus := \"ciao down\"\n+\tssh := \"N/A\"\n+\tsocket := path.Join(instanceDir, \"socket\")\n+\tdisconnectedCh := make(chan struct{})\n+\tqmp, _, err := qemu.QMPStart(ctx, socket, qemu.QMPConfig{}, disconnectedCh)\n+\tif err == nil {\n+\t\tstatus = \"ciao up\"\n+\t\tssh = fmt.Sprintf(\"ssh 127.0.0.1 -p %d\", 10022)","path":"testutil/ciao-down/vm.go","position":110,"original_position":107,"commit_id":"26b8416d4006819ec87c1cf74aeb4c30d75a1e15","original_commit_id":"0f1b8851dfe684849ba39380e97dbc2206c46f41","user":{"login":"tpepper","id":2745300,"avatar_url":"https://avatars.githubusercontent.com/u/2745300?v=3","gravatar_id":"","url":"https://api.github.com/users/tpepper","html_url":"https://github.com/tpepper","followers_url":"https://api.github.com/users/tpepper/followers","following_url":"https://api.github.com/users/tpepper/following{/other_user}","gists_url":"https://api.github.com/users/tpepper/gists{/gist_id}","starred_url":"https://api.github.com/users/tpepper/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tpepper/subscriptions","organizations_url":"https://api.github.com/users/tpepper/orgs","repos_url":"https://api.github.com/users/tpepper/repos","events_url":"https://api.github.com/users/tpepper/events{/privacy}","received_events_url":"https://api.github.com/users/tpepper/received_events","type":"User","site_admin":false},"body":"same comments throughout, as before the movement between files","created_at":"2016-12-06T01:07:09Z","updated_at":"2016-12-06T01:07:14Z","html_url":"https://github.com/01org/ciao/pull/835#discussion_r90993116","pull_request_url":"https://api.github.com/repos/01org/ciao/pulls/835","_links":{"self":{"href":"https://api.github.com/repos/01org/ciao/pulls/comments/90993116"},"html":{"href":"https://github.com/01org/ciao/pull/835#discussion_r90993116"},"pull_request":{"href":"https://api.github.com/repos/01org/ciao/pulls/835"}}},"pull_request":{"url":"https://api.github.com/repos/01org/ciao/pulls/835","id":94020823,"html_url":"https://github.com/01org/ciao/pull/835","diff_url":"https://github.com/01org/ciao/pull/835.diff","patch_url":"https://github.com/01org/ciao/pull/835.patch","issue_url":"https://api.github.com/repos/01org/ciao/issues/835","number":835,"state":"open","locked":false,"title":"ciao-down: Add ciao-down, a utility for building VMs for Single VM","user":{"login":"markdryan","id":984073,"avatar_url":"https://avatars.githubusercontent.com/u/984073?v=3","gravatar_id":"","url":"https://api.github.com/users/markdryan","html_url":"https://github.com/markdryan","followers_url":"https://api.github.com/users/markdryan/followers","following_url":"https://api.github.com/users/markdryan/following{/other_user}","gists_url":"https://api.github.com/users/markdryan/gists{/gist_id}","starred_url":"https://api.github.com/users/markdryan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markdryan/subscriptions","organizations_url":"https://api.github.com/users/markdryan/orgs","repos_url":"https://api.github.com/users/markdryan/repos","events_url":"https://api.github.com/users/markdryan/events{/privacy}","received_events_url":"https://api.github.com/users/markdryan/received_events","type":"User","site_admin":false},"body":"ciao-down is a small utility for setting up a VM that contains everything\r\nyou need to run ciao's Single VM.  All you need to have installed on your\r\nmachine is:\r\n\r\n1. Go 1.7 or greater\r\n2. An ssh key\r\n\r\nThen simply type\r\n\r\ngo get github.com/01org/ciao/testutil/ciao-down\r\n$GOPATH/bin/ciao-down prepare\r\n\r\nciao-down will install some needed dependencies on your local PC such\r\nas qemu and xorriso.  It will then download an Ubuntu Cloud Image and\r\ncreate a VM based on this image.  It will boot the VM and install in that\r\nVM everything you need to run ciao Single VM, including docker, ceph,\r\ngo, gcc, etc.  When ciao-down prepare has finished you can connect to the\r\nnewly created VM with\r\n\r\n$GOPATH/bin/ciao-down connect\r\n\r\nYour host's GOPATH is mounted inside the VM.  Thus you can edit your\r\nthe ciao code on your host machine and test in Single VM.\r\n\r\nFollow the instructions at the prompt to start Single VM.\r\n\r\nThe nice thing about ciao-down is that it is built using existing ciao\r\npackages.  It uses osprepare to install dependencies on the host, some\r\nlauncher code to create the images needed by the VMs, and the qemu\r\npackage to launch and manage the VMs.  All the rest is done via cloud-init.\r\n\r\nSigned-off-by: Mark Ryan <mark.d.ryan@intel.com>","created_at":"2016-11-16T18:16:22Z","updated_at":"2016-12-06T01:07:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9bc4ac5561b3130d926200b516c3d26c37d16da5","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/01org/ciao/pulls/835/commits","review_comments_url":"https://api.github.com/repos/01org/ciao/pulls/835/comments","review_comment_url":"https://api.github.com/repos/01org/ciao/pulls/comments{/number}","comments_url":"https://api.github.com/repos/01org/ciao/issues/835/comments","statuses_url":"https://api.github.com/repos/01org/ciao/statuses/26b8416d4006819ec87c1cf74aeb4c30d75a1e15","head":{"label":"markdryan:ciao-dev","ref":"ciao-dev","sha":"26b8416d4006819ec87c1cf74aeb4c30d75a1e15","user":{"login":"markdryan","id":984073,"avatar_url":"https://avatars.githubusercontent.com/u/984073?v=3","gravatar_id":"","url":"https://api.github.com/users/markdryan","html_url":"https://github.com/markdryan","followers_url":"https://api.github.com/users/markdryan/followers","following_url":"https://api.github.com/users/markdryan/following{/other_user}","gists_url":"https://api.github.com/users/markdryan/gists{/gist_id}","starred_url":"https://api.github.com/users/markdryan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markdryan/subscriptions","organizations_url":"https://api.github.com/users/markdryan/orgs","repos_url":"https://api.github.com/users/markdryan/repos","events_url":"https://api.github.com/users/markdryan/events{/privacy}","received_events_url":"https://api.github.com/users/markdryan/received_events","type":"User","site_admin":false},"repo":{"id":57375648,"name":"ciao","full_name":"markdryan/ciao","owner":{"login":"markdryan","id":984073,"avatar_url":"https://avatars.githubusercontent.com/u/984073?v=3","gravatar_id":"","url":"https://api.github.com/users/markdryan","html_url":"https://github.com/markdryan","followers_url":"https://api.github.com/users/markdryan/followers","following_url":"https://api.github.com/users/markdryan/following{/other_user}","gists_url":"https://api.github.com/users/markdryan/gists{/gist_id}","starred_url":"https://api.github.com/users/markdryan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markdryan/subscriptions","organizations_url":"https://api.github.com/users/markdryan/orgs","repos_url":"https://api.github.com/users/markdryan/repos","events_url":"https://api.github.com/users/markdryan/events{/privacy}","received_events_url":"https://api.github.com/users/markdryan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/markdryan/ciao","description":"Ciao - Cloud Integrated Advanced Orchestrator","fork":true,"url":"https://api.github.com/repos/markdryan/ciao","forks_url":"https://api.github.com/repos/markdryan/ciao/forks","keys_url":"https://api.github.com/repos/markdryan/ciao/keys{/key_id}","collaborators_url":"https://api.github.com/repos/markdryan/ciao/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/markdryan/ciao/teams","hooks_url":"https://api.github.com/repos/markdryan/ciao/hooks","issue_events_url":"https://api.github.com/repos/markdryan/ciao/issues/events{/number}","events_url":"https://api.github.com/repos/markdryan/ciao/events","assignees_url":"https://api.github.com/repos/markdryan/ciao/assignees{/user}","branches_url":"https://api.github.com/repos/markdryan/ciao/branches{/branch}","tags_url":"https://api.github.com/repos/markdryan/ciao/tags","blobs_url":"https://api.github.com/repos/markdryan/ciao/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/markdryan/ciao/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/markdryan/ciao/git/refs{/sha}","trees_url":"https://api.github.com/repos/markdryan/ciao/git/trees{/sha}","statuses_url":"https://api.github.com/repos/markdryan/ciao/statuses/{sha}","languages_url":"https://api.github.com/repos/markdryan/ciao/languages","stargazers_url":"https://api.github.com/repos/markdryan/ciao/stargazers","contributors_url":"https://api.github.com/repos/markdryan/ciao/contributors","subscribers_url":"https://api.github.com/repos/markdryan/ciao/subscribers","subscription_url":"https://api.github.com/repos/markdryan/ciao/subscription","commits_url":"https://api.github.com/repos/markdryan/ciao/commits{/sha}","git_commits_url":"https://api.github.com/repos/markdryan/ciao/git/commits{/sha}","comments_url":"https://api.github.com/repos/markdryan/ciao/comments{/number}","issue_comment_url":"https://api.github.com/repos/markdryan/ciao/issues/comments{/number}","contents_url":"https://api.github.com/repos/markdryan/ciao/contents/{+path}","compare_url":"https://api.github.com/repos/markdryan/ciao/compare/{base}...{head}","merges_url":"https://api.github.com/repos/markdryan/ciao/merges","archive_url":"https://api.github.com/repos/markdryan/ciao/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/markdryan/ciao/downloads","issues_url":"https://api.github.com/repos/markdryan/ciao/issues{/number}","pulls_url":"https://api.github.com/repos/markdryan/ciao/pulls{/number}","milestones_url":"https://api.github.com/repos/markdryan/ciao/milestones{/number}","notifications_url":"https://api.github.com/repos/markdryan/ciao/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/markdryan/ciao/labels{/name}","releases_url":"https://api.github.com/repos/markdryan/ciao/releases{/id}","deployments_url":"https://api.github.com/repos/markdryan/ciao/deployments","created_at":"2016-04-29T10:06:50Z","updated_at":"2016-04-29T10:06:51Z","pushed_at":"2016-12-05T15:32:27Z","git_url":"git://github.com/markdryan/ciao.git","ssh_url":"git@github.com:markdryan/ciao.git","clone_url":"https://github.com/markdryan/ciao.git","svn_url":"https://github.com/markdryan/ciao","homepage":"","size":9422,"stargazers_count":0,"watchers_count":0,"language":"Go","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":"01org:master","ref":"master","sha":"d940dcc3edf3b6a4ea99b69ea2afd30d9bb3da6f","user":{"login":"01org","id":1635439,"avatar_url":"https://avatars.githubusercontent.com/u/1635439?v=3","gravatar_id":"","url":"https://api.github.com/users/01org","html_url":"https://github.com/01org","followers_url":"https://api.github.com/users/01org/followers","following_url":"https://api.github.com/users/01org/following{/other_user}","gists_url":"https://api.github.com/users/01org/gists{/gist_id}","starred_url":"https://api.github.com/users/01org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/01org/subscriptions","organizations_url":"https://api.github.com/users/01org/orgs","repos_url":"https://api.github.com/users/01org/repos","events_url":"https://api.github.com/users/01org/events{/privacy}","received_events_url":"https://api.github.com/users/01org/received_events","type":"Organization","site_admin":false},"repo":{"id":54660486,"name":"ciao","full_name":"01org/ciao","owner":{"login":"01org","id":1635439,"avatar_url":"https://avatars.githubusercontent.com/u/1635439?v=3","gravatar_id":"","url":"https://api.github.com/users/01org","html_url":"https://github.com/01org","followers_url":"https://api.github.com/users/01org/followers","following_url":"https://api.github.com/users/01org/following{/other_user}","gists_url":"https://api.github.com/users/01org/gists{/gist_id}","starred_url":"https://api.github.com/users/01org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/01org/subscriptions","organizations_url":"https://api.github.com/users/01org/orgs","repos_url":"https://api.github.com/users/01org/repos","events_url":"https://api.github.com/users/01org/events{/privacy}","received_events_url":"https://api.github.com/users/01org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/01org/ciao","description":"Ciao - Cloud Integrated Advanced Orchestrator","fork":false,"url":"https://api.github.com/repos/01org/ciao","forks_url":"https://api.github.com/repos/01org/ciao/forks","keys_url":"https://api.github.com/repos/01org/ciao/keys{/key_id}","collaborators_url":"https://api.github.com/repos/01org/ciao/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/01org/ciao/teams","hooks_url":"https://api.github.com/repos/01org/ciao/hooks","issue_events_url":"https://api.github.com/repos/01org/ciao/issues/events{/number}","events_url":"https://api.github.com/repos/01org/ciao/events","assignees_url":"https://api.github.com/repos/01org/ciao/assignees{/user}","branches_url":"https://api.github.com/repos/01org/ciao/branches{/branch}","tags_url":"https://api.github.com/repos/01org/ciao/tags","blobs_url":"https://api.github.com/repos/01org/ciao/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/01org/ciao/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/01org/ciao/git/refs{/sha}","trees_url":"https://api.github.com/repos/01org/ciao/git/trees{/sha}","statuses_url":"https://api.github.com/repos/01org/ciao/statuses/{sha}","languages_url":"https://api.github.com/repos/01org/ciao/languages","stargazers_url":"https://api.github.com/repos/01org/ciao/stargazers","contributors_url":"https://api.github.com/repos/01org/ciao/contributors","subscribers_url":"https://api.github.com/repos/01org/ciao/subscribers","subscription_url":"https://api.github.com/repos/01org/ciao/subscription","commits_url":"https://api.github.com/repos/01org/ciao/commits{/sha}","git_commits_url":"https://api.github.com/repos/01org/ciao/git/commits{/sha}","comments_url":"https://api.github.com/repos/01org/ciao/comments{/number}","issue_comment_url":"https://api.github.com/repos/01org/ciao/issues/comments{/number}","contents_url":"https://api.github.com/repos/01org/ciao/contents/{+path}","compare_url":"https://api.github.com/repos/01org/ciao/compare/{base}...{head}","merges_url":"https://api.github.com/repos/01org/ciao/merges","archive_url":"https://api.github.com/repos/01org/ciao/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/01org/ciao/downloads","issues_url":"https://api.github.com/repos/01org/ciao/issues{/number}","pulls_url":"https://api.github.com/repos/01org/ciao/pulls{/number}","milestones_url":"https://api.github.com/repos/01org/ciao/milestones{/number}","notifications_url":"https://api.github.com/repos/01org/ciao/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/01org/ciao/labels{/name}","releases_url":"https://api.github.com/repos/01org/ciao/releases{/id}","deployments_url":"https://api.github.com/repos/01org/ciao/deployments","created_at":"2016-03-24T17:19:34Z","updated_at":"2016-11-28T21:28:29Z","pushed_at":"2016-12-06T00:13:31Z","git_url":"git://github.com/01org/ciao.git","ssh_url":"git@github.com:01org/ciao.git","clone_url":"https://github.com/01org/ciao.git","svn_url":"https://github.com/01org/ciao","homepage":"","size":9861,"stargazers_count":141,"watchers_count":141,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":36,"mirror_url":null,"open_issues_count":238,"forks":36,"open_issues":238,"watchers":141,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/01org/ciao/pulls/835"},"html":{"href":"https://github.com/01org/ciao/pull/835"},"issue":{"href":"https://api.github.com/repos/01org/ciao/issues/835"},"comments":{"href":"https://api.github.com/repos/01org/ciao/issues/835/comments"},"review_comments":{"href":"https://api.github.com/repos/01org/ciao/pulls/835/comments"},"review_comment":{"href":"https://api.github.com/repos/01org/ciao/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/01org/ciao/pulls/835/commits"},"statuses":{"href":"https://api.github.com/repos/01org/ciao/statuses/26b8416d4006819ec87c1cf74aeb4c30d75a1e15"}}}}
{"actor":{"display_login":"tpepper"}}