{"id":77,"date":"2015-08-28T17:44:52","date_gmt":"2015-08-28T16:44:52","guid":{"rendered":"http:\/\/www.haxed.me.uk\/?p=77"},"modified":"2015-08-28T17:45:33","modified_gmt":"2015-08-28T16:45:33","slug":"playing-with-xenstore","status":"publish","type":"post","link":"https:\/\/haxed.me.uk\/index.php\/2015\/08\/28\/playing-with-xenstore\/","title":{"rendered":"Playing with Xenstore"},"content":{"rendered":"<p>So, I have been playing around with xenstore-ls and xenstore-read commands on my Virtual Machine in the cloud. Basically xenstore-ls and xenstore-read are used to retrieve variable information about the network settings which are passed to a vdi when it is being built. Also if the network configuration breaks there is a way to use xenstore-write to read the vm-data read only network variables and the nova agent will be called to reset it.<\/p>\n<p>I am still familiarizing myself with this so apologies if there are any mistakes. This article will be updated as I learn more about it.<\/p>\n<p><strong>Commands available on Rackspace Virtual Machines<\/strong><\/p>\n<pre>xenstore\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 xenstore-chmod\u00a0\u00a0 xenstore-exists\u00a0 xenstore-list\u00a0\u00a0\u00a0 xenstore-ls\u00a0\u00a0\u00a0\u00a0\u00a0 xenstore-read\u00a0\u00a0\u00a0 xenstore-rm\u00a0\u00a0\u00a0\u00a0\u00a0 xenstore-watch\u00a0\u00a0 xenstore-write<\/pre>\n<p>There are several things we can do<\/p>\n<p>1. Show the Data associated with the VM, including mem_free, mem_total of the instance, the OS version (8), the os_name, distro, and the uname for the kernel.<\/p>\n<pre> root@dingdong:~# xenstore-ls data\r\nhost = \"\"\r\nmeminfo_total = \"1018872\"\r\nmeminfo_free = \"560180\"\r\nos_name = \"Debian GNU\/Linux 8.1 (jessie)\"\r\nos_majorver = \"8\"\r\nos_minorver = \"1\"\r\nos_uname = \"3.16.0-4-amd64\"\r\nos_distro = \"debian\"\r\nupdated = \"Fri Aug 28 17:30:00 BST 2015\"\r\nguest = \"\"\r\n 9cab4aed-0d29-4c7e-be2f-e15f1ed33231 = \"{\"message\": \"1.39.1\", \"returncode\": \"0\"}\"\r\n 6f38e0e1-6606-4245-8c8f-560c0204b419 = \"{\"message\": \"109108621899310233456141728258155\", \"returncode\": \"D0\"}\"\r\n c96d2b6e-31fb-489f-882c-790da25dbe1a = \"{\"message\": \"\", \"returncode\": \"0\"}\"\r\n be73ed2e-5c5a-4183-861b-2b6faaf8b09b = \"{\"message\": \"\", \"returncode\": \"0\"}\"\r\n ad730c7c-3c5e-4ba7-bfcc-8400a2675566 = \"{\"message\": \"75660051671748071924891088737764\", \"returncode\": \"D0\"}\"\r\n d3536286-4447-4f5b-84cc-8b6b1f61989c = \"{\"message\": \"\", \"returncode\": \"0\"}\"\r\n PresentationForAdamOfHowXenstoreWork = \"{\"message\": \"\", \"returncode\": \"0\"}\"\r\n<\/pre>\n<p>As you can see from above my colleague was helping make a presentation for me as to how this actually works!<\/p>\n<p><strong>Listing all of the current vm-data<\/strong><\/p>\n<pre> \r\n\r\nxenstore-ls vm-data\r\n\r\nnetworking = \"\"\r\n BC764E08E370 = \"{\"label\": \"private\", \"broadcast\": \"10.179.255.255\", \"ips\": [{\"ip\": \"10.179.197.101\", \"netmask\": \"255.255.192.0\", \"enabled\": \"1\", \"gateway\": null}], \"mac\": \\...\"\r\n BC764E086A56 = \"{\"ip6s\": [{\"ip\": \"2a00:1a48:7806:115:be76:4eff:fe08:6a56\", \"netmask\": 64, \"enabled\": \"1\", \"gateway\": \"fe80::def\"}], \"label\": \"public\", \"broadcast\": \"162.13\\...\"\r\nmeta = \"{\"rxtx_cap\": 120.0}\"\r\nhostname = \"dingdong\"\r\nauto-disk-config = \"False\"\r\nprovider_data = \"\"\r\n ip_whitelist = \"\"\r\n  54 = \"10.182.5.215\"\r\n  53 = \"134.213.147.236\"\r\n  52 = \"10.182.5.234\"\r\n  51 = \"134.213.148.114\"\r\n  50 = \"10.179.0.222\"\r\n  49 = \"10.179.75.22\"\r\n  48 = \"162.13.1.53\"\r\n  47 = \"95.138.174.55\"\r\n  46 = \"162.13.5.15\"\r\n  45 = \"10.177.132.233\"\r\n  44 = \"31.222.169.12\"\r\n  43 = \"10.179.0.234\"\r\n  42 = \"10.177.199.231\"\r\n  41 = \"10.179.0.159\"\r\n  40 = \"10.176.3.232\"\r\n  39 = \"10.176.3.236\"\r\n  38 = \"10.176.3.239\"\r\n  37 = \"10.176.3.235\"\r\n  36 = \"10.177.5.90\"\r\n  35 = \"10.177.5.89\"\r\n  34 = \"10.177.5.88\"\r\n  33 = \"10.177.1.73\"\r\n  32 = \"10.176.3.158\"\r\n  31 = \"10.177.0.105\"\r\n  30 = \"162.13.5.96\"\r\n  29 = \"5.79.25.90\"\r\n  28 = \"162.209.3.51\"\r\n  27 = \"162.13.22.243\"\r\n  26 = \"162.13.22.242\"\r\n  25 = \"166.78.7.98\"\r\n  24 = \"166.78.17.140\"\r\n  23 = \"166.78.24.91\"\r\n  22 = \"31.222.184.215\"\r\n  21 = \"31.222.184.38\"\r\n  20 = \"46.38.166.180\"\r\n  19 = \"46.38.160.93\"\r\n  18 = \"31.222.157.156\"\r\n  17 = \"31.222.177.183\"\r\n  16 = \"31.222.177.167\"\r\n  15 = \"31.222.164.168\"\r\n  14 = \"31.222.180.84\"\r\n  13 = \"31.222.161.245\"\r\n  12 = \"173.203.157.20\"\r\n  11 = \"119.9.12.98\"\r\n  10 = \"119.9.12.91\"\r\n  9 = \"162.13.1.53\"\r\n  8 = \"95.138.174.55\"\r\n  7 = \"162.209.4.155\"\r\n  6 = \"166.78.107.18\"\r\n  5 = \"50.56.249.239\"\r\n  4 = \"166.78.7.146\"\r\n  3 = \"89.234.21.64\/28\"\r\n  2 = \"67.192.155.96\/27\"\r\n  1 = \"173.203.5.160\/27\"\r\n  0 = \"173.203.32.136\/29\"\r\n roles = \"[\"object-store:default\", \"compute:default\", \"identity:user-admin\"]\"\r\n region = \"lon\"\r\n provider = \"Rackspace\"\r\nuser-metadata = \"\"\r\n build_config = \"\"monitoring_defaults,monitoring_agent_only,auto_updates\"\"\r\n rax_service_level_automation = \"\"Complete\"\"\r\nallowvssprovider = \"false\"\r\n<\/pre>\n<p><strong><br \/>\nIt is possible to retrieve specific information like networking configuration<\/strong><\/p>\n<pre>\r\nxenstore-ls vm-data\/networking\r\nBC764E08E370 = \"{\"label\": \"private\", \"broadcast\": \"10.179.255.255\", \"ips\": [{\"ip\": \"10.179.197.101\", \"netmask\": \"255.255.192.0\", \"enabled\": \"1\", \"gateway\": null}], \"mac\": \"\\...\"\r\nBC764E086A56 = \"{\"ip6s\": [{\"ip\": \"2a00:1a48:7806:115:be76:4eff:fe08:6a56\", \"netmask\": 64, \"enabled\": \"1\", \"gateway\": \"fe80::def\"}], \"label\": \"public\", \"broadcast\": \"162.13.\\...\"\r\n<\/pre>\n<p>The format here is kind of nasty, so there is a tool that we can use called jq<\/p>\n<p><strong> Filtering Network Data for MAC interfaces <\/strong><\/p>\n<pre>\r\n\r\napt-get update\r\napt-get install jq\r\n\r\nxenstore-read vm-data\/networking\/BC764E086A56 | jq .\r\n\r\n{\r\n  \"ip6s\": [\r\n    {\r\n      \"ip\": \"2a00:1a48:7806:115:be76:4eff:fe08:6a56\",\r\n      \"netmask\": 64,\r\n      \"enabled\": \"1\",\r\n      \"gateway\": \"fe80::def\"\r\n    }\r\n  ],\r\n  \"label\": \"public\",\r\n  \"broadcast\": \"162.13.86.255\",\r\n  \"ips\": [\r\n    {\r\n      \"ip\": \"162.13.86.79\",\r\n      \"netmask\": \"255.255.255.0\",\r\n      \"enabled\": \"1\",\r\n      \"gateway\": \"162.13.86.1\"\r\n    }\r\n  ],\r\n  \"mac\": \"BC:76:4E:08:6A:56\",\r\n  \"gateway_v6\": \"fe80::def\",\r\n  \"dns\": [\r\n    \"83.138.151.81\",\r\n    \"83.138.151.80\"\r\n  ],\r\n  \"gateway\": \"162.13.86.1\"\r\n}\r\n\r\n<\/pre>\n<p>Lots of cool stuff there. Including the Rackspace Service Net and Rackspace Public Net configurations. It&#8217;s possible to use jq to filter the JSON output of the xenstore-read command by filtering less.<\/p>\n<p><strong>Filtering ips network data with JQ <\/strong><\/p>\n<pre> \r\n\r\n xenstore-read vm-data\/networking\/BC764E086A56 | jq .ips\r\n[\r\n  {\r\n    \"ip\": \"162.13.86.79\",\r\n    \"netmask\": \"255.255.255.0\",\r\n    \"enabled\": \"1\",\r\n    \"gateway\": \"162.13.86.1\"\r\n  }\r\n]\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>There are a lot more things that can be done, however this is all I have time for , today.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So, I have been playing around with xenstore-ls and xenstore-read commands on my Virtual Machine in the cloud. Basically xenstore-ls and xenstore-read are used to retrieve variable information about the network settings which are passed to a vdi when it &hellip; <a href=\"https:\/\/haxed.me.uk\/index.php\/2015\/08\/28\/playing-with-xenstore\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[6],"class_list":["post-77","post","type-post","status-publish","format-standard","hentry","category-xen","tag-xen"],"_links":{"self":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/77","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/comments?post=77"}],"version-history":[{"count":0,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/posts\/77\/revisions"}],"wp:attachment":[{"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/media?parent=77"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/categories?post=77"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/haxed.me.uk\/index.php\/wp-json\/wp\/v2\/tags?post=77"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}