{"action":"created","comment":{"url":"https://api.github.com/repos/autotest/tp-libvirt/pulls/comments/128456365","pull_request_review_id":51134682,"id":128456365,"diff_hunk":"@@ -0,0 +1,105 @@\n+import os\n+import aexpect\n+from autotest.client import utils\n+from autotest.client.shared import error\n+from virttest import virsh\n+from virttest import utils_test\n+from virttest.libvirt_xml.vm_xml import VMXML\n+from virttest.libvirt_xml.nodedev_xml import NodedevXML\n+from virttest.staging import service\n+from virttest.test_setup import PciAssignable\n+from virttest import utils_misc\n+\n+\n+def run(test, params, env):\n+    \"\"\"\n+    Test for PCI multifunction device passthrough to libvirt guest.\n+\n+    a). NIC:\n+        1. Get params.\n+        2. Get the pci device function.\n+        3. Attach each pci device function to guest.\n+        4. Start guest and set the ip to all the functions.\n+        5. Ping to server_ip from ecah function\n+           to verify the new network device.\n+    \"\"\"\n+    # get the params from params\n+    vm_name = params.get(\"main_vm\")\n+    vm = env.get_vm(vm_name)\n+\n+    device_type = params.get(\"libvirt_pci_device_type\", \"NIC\")\n+    device_name = params.get(\"libvirt_pci_net_dev_name\", \"\")\n+\n+    if device_type == \"NIC\":\n+        pci_id = params.get(\"libvirt_pci_net_dev_label\")\n+\n+    net_ip = params.get(\"libvirt_pci_net_ip\", \"ENTER.YOUR.IP\")\n+    server_ip = params.get(\"libvirt_pci_server_ip\",\n+                           \"ENTER.YOUR.SERVER.IP\")\n+    netmask = params.get(\"libvirt_pci_net_mask\", \"ENTER.YOUR.Mask\")\n+\n+    # Check the parameters from configuration file.\n+    if (pci_id.count(\"ENTER\")):\n+        raise error.TestNAError(\"Please enter your device name for test.\")\n+\n+    if (device_type == \"NIC\" and (net_ip.count(\"ENTER\") or\n+                                  server_ip.count(\"ENTER\") or\n+                                  netmask.count(\"ENTER\"))):\n+        raise error.TestNAError(\"Please enter the ips for NIC test.\")\n+    vmxml = VMXML.new_from_inactive_dumpxml(vm_name)\n+    backup_xml = vmxml.copy()\n+    bus_info = []\n+    if device_type == \"NIC\":\n+        if not vm.is_alive():\n+            vm.start()\n+        session = vm.wait_for_login()\n+        output = session.cmd_output(\"ifconfig -a|grep Ethernet\")\n+        nic_list_before = output.splitlines()\n+    obj = PciAssignable()\n+    # get all functions id's\n+    pci_ids = obj.get_same_group_devs(pci_id)\n+    pci_devs = []\n+    for val in pci_ids:\n+        temp = val.replace(\":\", \"_\")\n+        pci_devs.extend([\"pci_\"+temp])\n+    for val in pci_devs:\n+        val = val.replace(\".\", \"_\")\n+        pci_xml = NodedevXML.new_from_dumpxml(val)\n+        pci_address = pci_xml.cap.get_address_dict()\n+        vmxml.add_hostdev(pci_address)\n+\n+    try:\n+        vmxml.sync()\n+        vm.start()\n+        session = vm.wait_for_login()\n+        if device_type == \"NIC\":\n+            output = session.cmd_output(\"ifconfig -a|grep Ethernet\")\n+            nic_list_after = output.splitlines()\n+            if nic_list_after == nic_list_before:\n+                raise error.TestFail(\n+                    \"No Ethernet found for the pci device in guest.\")\n+        # check all functions get same bus and slot\n+        output = session.cmd_output(\"lspci -nn | grep %s\" % device_name)\n+        nic_list = output.splitlines()\n+        for i in range(len(nic_list)):\n+            bus_info.append(str(nic_list[i]).split(' ', 1)[0])\n+            nic_list[i] = str(nic_list[i]).split(' ', 1)[0][:-2]\n+        if len(set(nic_list)) != 1:\n+            raise error.TestFail(\n+                \"allocates different slots for same adapter\")","path":"libvirt/tests/src/libvirt_pci_passthrough_multifunction.py","position":89,"original_position":89,"commit_id":"a23edb169b2c1a2c60872c09f053b082dca9dd33","original_commit_id":"a23edb169b2c1a2c60872c09f053b082dca9dd33","user":{"login":"nasastry","id":18656514,"avatar_url":"https://avatars3.githubusercontent.com/u/18656514?v=4","gravatar_id":"","url":"https://api.github.com/users/nasastry","html_url":"https://github.com/nasastry","followers_url":"https://api.github.com/users/nasastry/followers","following_url":"https://api.github.com/users/nasastry/following{/other_user}","gists_url":"https://api.github.com/users/nasastry/gists{/gist_id}","starred_url":"https://api.github.com/users/nasastry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nasastry/subscriptions","organizations_url":"https://api.github.com/users/nasastry/orgs","repos_url":"https://api.github.com/users/nasastry/repos","events_url":"https://api.github.com/users/nasastry/events{/privacy}","received_events_url":"https://api.github.com/users/nasastry/received_events","type":"User","site_admin":false},"body":"Please re-phrase the above sentence.","created_at":"2017-07-20T08:41:16Z","updated_at":"2017-07-20T08:41:47Z","html_url":"https://github.com/autotest/tp-libvirt/pull/1136#discussion_r128456365","pull_request_url":"https://api.github.com/repos/autotest/tp-libvirt/pulls/1136","_links":{"self":{"href":"https://api.github.com/repos/autotest/tp-libvirt/pulls/comments/128456365"},"html":{"href":"https://github.com/autotest/tp-libvirt/pull/1136#discussion_r128456365"},"pull_request":{"href":"https://api.github.com/repos/autotest/tp-libvirt/pulls/1136"}}},"pull_request":{"url":"https://api.github.com/repos/autotest/tp-libvirt/pulls/1136","id":131484656,"html_url":"https://github.com/autotest/tp-libvirt/pull/1136","diff_url":"https://github.com/autotest/tp-libvirt/pull/1136.diff","patch_url":"https://github.com/autotest/tp-libvirt/pull/1136.patch","issue_url":"https://api.github.com/repos/autotest/tp-libvirt/issues/1136","number":1136,"state":"open","locked":false,"title":"Adding testcase to passthrough the multifunction adaptor to guest","user":{"login":"prudmirya","id":23046961,"avatar_url":"https://avatars3.githubusercontent.com/u/23046961?v=4","gravatar_id":"","url":"https://api.github.com/users/prudmirya","html_url":"https://github.com/prudmirya","followers_url":"https://api.github.com/users/prudmirya/followers","following_url":"https://api.github.com/users/prudmirya/following{/other_user}","gists_url":"https://api.github.com/users/prudmirya/gists{/gist_id}","starred_url":"https://api.github.com/users/prudmirya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prudmirya/subscriptions","organizations_url":"https://api.github.com/users/prudmirya/orgs","repos_url":"https://api.github.com/users/prudmirya/repos","events_url":"https://api.github.com/users/prudmirya/events{/privacy}","received_events_url":"https://api.github.com/users/prudmirya/received_events","type":"User","site_admin":false},"body":"This script is for pass through the multifunction adaptor to the guest and guest can directly use it.   \r\nSigned-off-by: prudhvi <mprudhvi@linux.vnet.ibm.com>","created_at":"2017-07-20T07:16:48Z","updated_at":"2017-07-20T08:41:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fef069d53fc9d41e04335d563a91e1407f1dcbd9","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/autotest/tp-libvirt/pulls/1136/commits","review_comments_url":"https://api.github.com/repos/autotest/tp-libvirt/pulls/1136/comments","review_comment_url":"https://api.github.com/repos/autotest/tp-libvirt/pulls/comments{/number}","comments_url":"https://api.github.com/repos/autotest/tp-libvirt/issues/1136/comments","statuses_url":"https://api.github.com/repos/autotest/tp-libvirt/statuses/a23edb169b2c1a2c60872c09f053b082dca9dd33","head":{"label":"prudmirya:multifunction","ref":"multifunction","sha":"a23edb169b2c1a2c60872c09f053b082dca9dd33","user":{"login":"prudmirya","id":23046961,"avatar_url":"https://avatars3.githubusercontent.com/u/23046961?v=4","gravatar_id":"","url":"https://api.github.com/users/prudmirya","html_url":"https://github.com/prudmirya","followers_url":"https://api.github.com/users/prudmirya/followers","following_url":"https://api.github.com/users/prudmirya/following{/other_user}","gists_url":"https://api.github.com/users/prudmirya/gists{/gist_id}","starred_url":"https://api.github.com/users/prudmirya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prudmirya/subscriptions","organizations_url":"https://api.github.com/users/prudmirya/orgs","repos_url":"https://api.github.com/users/prudmirya/repos","events_url":"https://api.github.com/users/prudmirya/events{/privacy}","received_events_url":"https://api.github.com/users/prudmirya/received_events","type":"User","site_admin":false},"repo":{"id":76557186,"name":"tp-libvirt","full_name":"prudmirya/tp-libvirt","owner":{"login":"prudmirya","id":23046961,"avatar_url":"https://avatars3.githubusercontent.com/u/23046961?v=4","gravatar_id":"","url":"https://api.github.com/users/prudmirya","html_url":"https://github.com/prudmirya","followers_url":"https://api.github.com/users/prudmirya/followers","following_url":"https://api.github.com/users/prudmirya/following{/other_user}","gists_url":"https://api.github.com/users/prudmirya/gists{/gist_id}","starred_url":"https://api.github.com/users/prudmirya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/prudmirya/subscriptions","organizations_url":"https://api.github.com/users/prudmirya/orgs","repos_url":"https://api.github.com/users/prudmirya/repos","events_url":"https://api.github.com/users/prudmirya/events{/privacy}","received_events_url":"https://api.github.com/users/prudmirya/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/prudmirya/tp-libvirt","description":"Test Provider for Libvirt and related virtualization backends","fork":true,"url":"https://api.github.com/repos/prudmirya/tp-libvirt","forks_url":"https://api.github.com/repos/prudmirya/tp-libvirt/forks","keys_url":"https://api.github.com/repos/prudmirya/tp-libvirt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/prudmirya/tp-libvirt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/prudmirya/tp-libvirt/teams","hooks_url":"https://api.github.com/repos/prudmirya/tp-libvirt/hooks","issue_events_url":"https://api.github.com/repos/prudmirya/tp-libvirt/issues/events{/number}","events_url":"https://api.github.com/repos/prudmirya/tp-libvirt/events","assignees_url":"https://api.github.com/repos/prudmirya/tp-libvirt/assignees{/user}","branches_url":"https://api.github.com/repos/prudmirya/tp-libvirt/branches{/branch}","tags_url":"https://api.github.com/repos/prudmirya/tp-libvirt/tags","blobs_url":"https://api.github.com/repos/prudmirya/tp-libvirt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/prudmirya/tp-libvirt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/prudmirya/tp-libvirt/git/refs{/sha}","trees_url":"https://api.github.com/repos/prudmirya/tp-libvirt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/prudmirya/tp-libvirt/statuses/{sha}","languages_url":"https://api.github.com/repos/prudmirya/tp-libvirt/languages","stargazers_url":"https://api.github.com/repos/prudmirya/tp-libvirt/stargazers","contributors_url":"https://api.github.com/repos/prudmirya/tp-libvirt/contributors","subscribers_url":"https://api.github.com/repos/prudmirya/tp-libvirt/subscribers","subscription_url":"https://api.github.com/repos/prudmirya/tp-libvirt/subscription","commits_url":"https://api.github.com/repos/prudmirya/tp-libvirt/commits{/sha}","git_commits_url":"https://api.github.com/repos/prudmirya/tp-libvirt/git/commits{/sha}","comments_url":"https://api.github.com/repos/prudmirya/tp-libvirt/comments{/number}","issue_comment_url":"https://api.github.com/repos/prudmirya/tp-libvirt/issues/comments{/number}","contents_url":"https://api.github.com/repos/prudmirya/tp-libvirt/contents/{+path}","compare_url":"https://api.github.com/repos/prudmirya/tp-libvirt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/prudmirya/tp-libvirt/merges","archive_url":"https://api.github.com/repos/prudmirya/tp-libvirt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/prudmirya/tp-libvirt/downloads","issues_url":"https://api.github.com/repos/prudmirya/tp-libvirt/issues{/number}","pulls_url":"https://api.github.com/repos/prudmirya/tp-libvirt/pulls{/number}","milestones_url":"https://api.github.com/repos/prudmirya/tp-libvirt/milestones{/number}","notifications_url":"https://api.github.com/repos/prudmirya/tp-libvirt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/prudmirya/tp-libvirt/labels{/name}","releases_url":"https://api.github.com/repos/prudmirya/tp-libvirt/releases{/id}","deployments_url":"https://api.github.com/repos/prudmirya/tp-libvirt/deployments","created_at":"2016-12-15T12:18:50Z","updated_at":"2016-12-15T12:18:53Z","pushed_at":"2017-07-20T07:14:30Z","git_url":"git://github.com/prudmirya/tp-libvirt.git","ssh_url":"git@github.com:prudmirya/tp-libvirt.git","clone_url":"https://github.com/prudmirya/tp-libvirt.git","svn_url":"https://github.com/prudmirya/tp-libvirt","homepage":null,"size":11310,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"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":"autotest:master","ref":"master","sha":"8f633e111197082ebe0f07389ef045e227664649","user":{"login":"autotest","id":472856,"avatar_url":"https://avatars1.githubusercontent.com/u/472856?v=4","gravatar_id":"","url":"https://api.github.com/users/autotest","html_url":"https://github.com/autotest","followers_url":"https://api.github.com/users/autotest/followers","following_url":"https://api.github.com/users/autotest/following{/other_user}","gists_url":"https://api.github.com/users/autotest/gists{/gist_id}","starred_url":"https://api.github.com/users/autotest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/autotest/subscriptions","organizations_url":"https://api.github.com/users/autotest/orgs","repos_url":"https://api.github.com/users/autotest/repos","events_url":"https://api.github.com/users/autotest/events{/privacy}","received_events_url":"https://api.github.com/users/autotest/received_events","type":"Organization","site_admin":false},"repo":{"id":16180517,"name":"tp-libvirt","full_name":"autotest/tp-libvirt","owner":{"login":"autotest","id":472856,"avatar_url":"https://avatars1.githubusercontent.com/u/472856?v=4","gravatar_id":"","url":"https://api.github.com/users/autotest","html_url":"https://github.com/autotest","followers_url":"https://api.github.com/users/autotest/followers","following_url":"https://api.github.com/users/autotest/following{/other_user}","gists_url":"https://api.github.com/users/autotest/gists{/gist_id}","starred_url":"https://api.github.com/users/autotest/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/autotest/subscriptions","organizations_url":"https://api.github.com/users/autotest/orgs","repos_url":"https://api.github.com/users/autotest/repos","events_url":"https://api.github.com/users/autotest/events{/privacy}","received_events_url":"https://api.github.com/users/autotest/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/autotest/tp-libvirt","description":"Test Provider for Libvirt and related virtualization backends","fork":false,"url":"https://api.github.com/repos/autotest/tp-libvirt","forks_url":"https://api.github.com/repos/autotest/tp-libvirt/forks","keys_url":"https://api.github.com/repos/autotest/tp-libvirt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/autotest/tp-libvirt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/autotest/tp-libvirt/teams","hooks_url":"https://api.github.com/repos/autotest/tp-libvirt/hooks","issue_events_url":"https://api.github.com/repos/autotest/tp-libvirt/issues/events{/number}","events_url":"https://api.github.com/repos/autotest/tp-libvirt/events","assignees_url":"https://api.github.com/repos/autotest/tp-libvirt/assignees{/user}","branches_url":"https://api.github.com/repos/autotest/tp-libvirt/branches{/branch}","tags_url":"https://api.github.com/repos/autotest/tp-libvirt/tags","blobs_url":"https://api.github.com/repos/autotest/tp-libvirt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/autotest/tp-libvirt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/autotest/tp-libvirt/git/refs{/sha}","trees_url":"https://api.github.com/repos/autotest/tp-libvirt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/autotest/tp-libvirt/statuses/{sha}","languages_url":"https://api.github.com/repos/autotest/tp-libvirt/languages","stargazers_url":"https://api.github.com/repos/autotest/tp-libvirt/stargazers","contributors_url":"https://api.github.com/repos/autotest/tp-libvirt/contributors","subscribers_url":"https://api.github.com/repos/autotest/tp-libvirt/subscribers","subscription_url":"https://api.github.com/repos/autotest/tp-libvirt/subscription","commits_url":"https://api.github.com/repos/autotest/tp-libvirt/commits{/sha}","git_commits_url":"https://api.github.com/repos/autotest/tp-libvirt/git/commits{/sha}","comments_url":"https://api.github.com/repos/autotest/tp-libvirt/comments{/number}","issue_comment_url":"https://api.github.com/repos/autotest/tp-libvirt/issues/comments{/number}","contents_url":"https://api.github.com/repos/autotest/tp-libvirt/contents/{+path}","compare_url":"https://api.github.com/repos/autotest/tp-libvirt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/autotest/tp-libvirt/merges","archive_url":"https://api.github.com/repos/autotest/tp-libvirt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/autotest/tp-libvirt/downloads","issues_url":"https://api.github.com/repos/autotest/tp-libvirt/issues{/number}","pulls_url":"https://api.github.com/repos/autotest/tp-libvirt/pulls{/number}","milestones_url":"https://api.github.com/repos/autotest/tp-libvirt/milestones{/number}","notifications_url":"https://api.github.com/repos/autotest/tp-libvirt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/autotest/tp-libvirt/labels{/name}","releases_url":"https://api.github.com/repos/autotest/tp-libvirt/releases{/id}","deployments_url":"https://api.github.com/repos/autotest/tp-libvirt/deployments","created_at":"2014-01-23T17:58:18Z","updated_at":"2017-06-30T06:41:20Z","pushed_at":"2017-07-20T07:53:54Z","git_url":"git://github.com/autotest/tp-libvirt.git","ssh_url":"git@github.com:autotest/tp-libvirt.git","clone_url":"https://github.com/autotest/tp-libvirt.git","svn_url":"https://github.com/autotest/tp-libvirt","homepage":null,"size":11306,"stargazers_count":12,"watchers_count":12,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":92,"mirror_url":null,"open_issues_count":54,"forks":92,"open_issues":54,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/autotest/tp-libvirt/pulls/1136"},"html":{"href":"https://github.com/autotest/tp-libvirt/pull/1136"},"issue":{"href":"https://api.github.com/repos/autotest/tp-libvirt/issues/1136"},"comments":{"href":"https://api.github.com/repos/autotest/tp-libvirt/issues/1136/comments"},"review_comments":{"href":"https://api.github.com/repos/autotest/tp-libvirt/pulls/1136/comments"},"review_comment":{"href":"https://api.github.com/repos/autotest/tp-libvirt/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/autotest/tp-libvirt/pulls/1136/commits"},"statuses":{"href":"https://api.github.com/repos/autotest/tp-libvirt/statuses/a23edb169b2c1a2c60872c09f053b082dca9dd33"}}}}
{"actor":{"display_login":"nasastry"}}