{"id":1289,"date":"2011-06-19T22:54:22","date_gmt":"2011-06-20T02:54:22","guid":{"rendered":"http:\/\/www.braindeadprojects.com\/blog\/?p=1289"},"modified":"2011-06-19T22:54:22","modified_gmt":"2011-06-20T02:54:22","slug":"gns3-and-gentoo-fixing-qemu-networking","status":"publish","type":"post","link":"http:\/\/www.braindeadprojects.com\/blog\/what\/gns3-and-gentoo-fixing-qemu-networking\/","title":{"rendered":"GNS3 and Gentoo &#8211; fixing QEMU networking"},"content":{"rendered":"<p>I was hoping to have time to further familiarize myself with <a title=\"IPv6\" href=\"http:\/\/en.wikipedia.org\/wiki\/IPv6\" target=\"_blank\">IPv6<\/a> this weekend &#8211;\u00a0 but workplace emergencies, sleep, and a technical glitch slowed me down. Here&#8217;s the story of the technical glitch.<\/p>\n<figure id=\"attachment_1320\" aria-describedby=\"caption-attachment-1320\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/GNS3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1320\" title=\"GNS3\" src=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/GNS3-300x88.png\" alt=\"\" width=\"300\" height=\"88\" srcset=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/GNS3-300x88.png 300w, http:\/\/www.braindeadprojects.com\/blog\/wp-content\/GNS3.png 469w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-1320\" class=\"wp-caption-text\">GNS3 - this thing rocks.<\/figcaption><\/figure>\n<p><a title=\"GNS3\" href=\"http:\/\/www.gns3.net\/\" target=\"_blank\">GNS3<\/a>\/<a title=\"Dynamips\" href=\"http:\/\/www.ipflow.utc.fr\/index.php\/Cisco_7200_Simulator\" target=\"_blank\">dynamips<\/a> can handle emulation of a number of routers, and I was happy to see that it can emulate host PCs as well. Unfortunately networking in GNS3\u00a0 is done via <em>UDP tunnels<\/em> &#8211; something that requires a <a title=\"Qemu\" href=\"http:\/\/wiki.qemu.org\/Main_Page\" target=\"_blank\">Qemu<\/a> patch to implement.<\/p>\n<figure id=\"attachment_1306\" aria-describedby=\"caption-attachment-1306\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/GNS3-IPv6-test.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1306\" title=\"GNS3-IPv6-test\" src=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/GNS3-IPv6-test-300x209.png\" alt=\"\" width=\"300\" height=\"209\" srcset=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/GNS3-IPv6-test-300x209.png 300w, http:\/\/www.braindeadprojects.com\/blog\/wp-content\/GNS3-IPv6-test.png 1024w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-1306\" class=\"wp-caption-text\">For some reason QEMU won&#39;t really start if it&#39;s networked.<\/figcaption><\/figure>\n<p>In <a title=\"Gentoo\" href=\"http:\/\/www.gentoo.org\/\">Gentoo<\/a>, simply building GNS3 from the <a title=\"Sunrise Overlay\" href=\"http:\/\/overlays.gentoo.org\/proj\/sunrise\" target=\"_blank\">Sunrise Overlay<\/a> doesn&#8217;t provide sufficient support for this requirement. Emulated routers (and I&#8217;m assuming switches) work fine when networked together. Emulated host machines work fine when NOT connected to anything. But once you network things together you&#8217;ll discover that your Qemu host won&#8217;t start.<\/p>\n<p>Here&#8217;s why &#8211; when you start a Qemu host, this is essentially what GNS3 runs:<\/p>\n<blockquote><p>\/usr\/bin\/qemu -name QEMU1 -m 256  \/mnt\/virtualmachines\/dynips\/IPv6-tc\/working\/QEMU1\/FLASH -hdb  \/mnt\/virtualmachines\/dynamips\/IPv6-tc\/working\/QEMU1\/SWAP -enable-kvm  -net nic,vlan=0,macaddr=00:aa:00:8f:e4:00,model=rtl8139 <strong>-net  udp,vlan=0,sport=20000,dport=10006,daddr=127.0.0.1 <\/strong>-net  nic,vlan=1,macaddr=00:00:ab:fa:72:01,model=rtl8139 -serial  telnet:127.0.0.1:3000,server,nowait -no-acpi -vnc :0<\/p><\/blockquote>\n<p>GNS3 attempts to use the <strong>-net udp<\/strong> option, something not offered in the default QEMU-KVM distribution. With no Gentoo <a title=\"USE flags\" href=\"http:\/\/www.gentoo.org\/doc\/en\/handbook\/handbook-x86.xml?part=2&amp;chap=2#doc_chap1\" target=\"_blank\">USE flags<\/a> to add the patch in either 0.13.0 or 0.14.50, I decided to simply upgrade to 0.14.50 and see if it was part of the default build:<\/p>\n<blockquote><p># kvm &#8211;version<br \/>\nQEMU emulator version 0.14.50 (qemu-kvm-devel), Copyright (c) 2003-2008 Fabrice Bellard<br \/>\n# kvm &#8211;help | grep &#8220;net udp&#8221;<br \/>\n#<\/p><\/blockquote>\n<p>Nope, it&#8217;s not. So the next step is to remove app-emulation\/qemu-kvm from your system and build it by hand.<\/p>\n<p>First, remove kvm and download the source from kernel.org:<\/p>\n<blockquote><p># emerge -C app-emulation\/qemu-kvm<\/p>\n<p># cd \/usr\/src\/<\/p>\n<p># wget http:\/\/mirrors.kernel.org\/gentoo\/distfiles\/qemu-kvm-0.13.0.tar.gz<\/p><\/blockquote>\n<p>Unpack and patch it, using the <a title=\"Patch\" href=\"http:\/\/sourceforge.net\/projects\/gns-3\/files\/Qemu\/qemu-0.13.0.patched.win32.zip\/download\" target=\"_blank\">patch provided by the gns-3 team <\/a>.<\/p>\n<blockquote><p># tar zxvpf qemu-kvm-0.13.0.tar.gz<\/p>\n<p># cd qemu-kvm-0.13.0\/<\/p><\/blockquote>\n<p>Testing the patch, I ran into a handful of issues:<\/p>\n<blockquote><p># patch &#8211;dry-run -p1 &lt; \/mnt\/nas\/downloads\/qemu-0.13.0-<br \/>\nmcast-udp.patch<br \/>\npatching file Makefile.objs<br \/>\nHunk #1 FAILED at 25.<br \/>\n1 out of 1 hunk FAILED &#8212; saving rejects to file Makefile.objs.rej<br \/>\npatching file block\/raw-win32.c<br \/>\nHunk #1 FAILED at 93.<br \/>\nHunk #2 FAILED at 347.<br \/>\n2 out of 2 hunks FAILED &#8212; saving rejects to file block\/raw-win32.c.rej<br \/>\npatching file hw\/e1000.c<br \/>\nHunk #1 FAILED at 567.<br \/>\n1 out of 1 hunk FAILED &#8212; saving rejects to file hw\/e1000.c.rej<br \/>\npatching file net\/udp.c<br \/>\npatching file net\/udp.h<br \/>\npatching file net.c<br \/>\nHunk #1 FAILED at 30.<br \/>\nHunk #2 FAILED at 1075.<br \/>\n2 out of 2 hunks FAILED &#8212; saving rejects to file net.c.rej<br \/>\npatching file net.h<br \/>\nHunk #1 FAILED at 33.<br \/>\n1 out of 1 hunk FAILED &#8212; saving rejects to file net.h.rej<br \/>\npatching file qemu-options.hx<br \/>\nHunk #1 FAILED at 996.<br \/>\n1 out of 1 hunk FAILED &#8212; saving rejects to file qemu-options.hx.rej<\/p><\/blockquote>\n<p>A quick modification and we&#8217;ve got <a title=\"Update Patch File\" href=\"http:\/\/www.braindeadprojects.com\/src\/gentoo-qemu-0.13.0.gns3.patch\" target=\"_blank\">a new patch file<\/a>. This one applies nicely:<\/p>\n<blockquote><p># patch &#8211;dry-run -p1 &lt; \/mnt\/nas\/downloads\/gentoo-qemu-0.13.0.gns3.patch<br \/>\npatching file Makefile.objs<br \/>\npatching file QMP\/qmp-commands.txt<br \/>\npatching file block\/raw-win32.c<br \/>\npatching file config-all-devices.mak<br \/>\npatching file config-host.h<br \/>\npatching file config-host.h-timestamp<br \/>\npatching file config-host.ld<br \/>\npatching file config-host.mak<br \/>\npatching file hw\/e1000.c<br \/>\npatching file libdis\/config.mak<br \/>\npatching file libdis-user\/config.mak<br \/>\npatching file libhw32\/config.mak<br \/>\npatching file libhw64\/config.mak<br \/>\npatching file net\/udp.c<br \/>\npatching file net\/udp.h<br \/>\npatching file net.c<br \/>\npatching file net.h<br \/>\npatching file qemu-doc.html<br \/>\npatching file qemu-img-cmds.texi<br \/>\npatching file qemu-img.1<br \/>\npatching file qemu-monitor.texi<br \/>\npatching file qemu-nbd.8<br \/>\npatching file qemu-options.hx<br \/>\npatching file qemu-options.texi<br \/>\npatching file qemu-tech.html<br \/>\npatching file qemu.1<br \/>\npatching file roms\/seabios\/config.mak<br \/>\npatching file roms\/vgabios\/config.mak<br \/>\npatching file x86_64-softmmu\/config-devices.mak<br \/>\npatching file x86_64-softmmu\/config-devices.mak.old<br \/>\npatching file x86_64-softmmu\/config-target.mak<br \/>\nvonnegut qemu-kvm-0.13.0 #<\/p><\/blockquote>\n<p>So let&#8217;s apply it for real and then configure, build, and install our new Qemu:<\/p>\n<blockquote><p># patch -p1 &lt; \/mnt\/nas\/downloads\/gentoo-qemu-0.13.0.gns3.patch<\/p>\n<p>&#8230;<\/p>\n<p># .\/configure &#8211;prefix=\/usr &#8211;target-list=i386-softmmu &#8211;enable-sdl<\/p>\n<p># make &amp;&amp; make install<\/p><\/blockquote>\n<p>A quick check to ensure UDP tunneling is compiled in:<\/p>\n<blockquote><p># \/usr\/bin\/qemu &#8211;version<br \/>\nQEMU emulator version 0.13.0 (qemu-kvm-0.13.0), Copyright (c) 2003-2008 Fabrice Bellard<br \/>\n# \/usr\/bin\/qemu &#8211;help | grep &#8220;net udp&#8221;<br \/>\n-net udp[,vlan=n]sport=sport,dport=dport,daddr=host<br \/>\n#<\/p><\/blockquote>\n<p>And voila &#8211; now not only does my host machine start when networked into my layout, it also has connectivity:<\/p>\n<figure id=\"attachment_1308\" aria-describedby=\"caption-attachment-1308\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/QEMU-working-host.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-1308\" title=\"QEMU-working-host\" src=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/QEMU-working-host-300x177.png\" alt=\"\" width=\"300\" height=\"177\" srcset=\"http:\/\/www.braindeadprojects.com\/blog\/wp-content\/QEMU-working-host-300x177.png 300w, http:\/\/www.braindeadprojects.com\/blog\/wp-content\/QEMU-working-host.png 722w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><figcaption id=\"caption-attachment-1308\" class=\"wp-caption-text\">Yes, it finally works.<\/figcaption><\/figure>\n<p>Next up &#8211; continue lab work with IPv6, and begin studying for my <a title=\"CCNP\" href=\"http:\/\/www.cisco.com\/web\/learning\/le3\/le2\/le37\/le10\/learning_certification_type_home.html\" target=\"_blank\">CCNP<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was hoping to have time to further familiarize myself with IPv6 this weekend &#8211;\u00a0 but workplace emergencies, sleep, and a technical glitch slowed me down. Here&#8217;s the story of the technical glitch. GNS3\/dynamips can handle emulation of a number of routers, and I was happy to see that it can emulate host PCs as &hellip; <a href=\"http:\/\/www.braindeadprojects.com\/blog\/what\/gns3-and-gentoo-fixing-qemu-networking\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">GNS3 and Gentoo &#8211; fixing QEMU networking<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,20,35,34,36,29,28,1],"tags":[],"class_list":["post-1289","post","type-post","status-publish","format-standard","hentry","category-braindeadtip","category-cisco","category-gns3","category-ipv6","category-kvm","category-linux","category-virtualization","category-what"],"_links":{"self":[{"href":"http:\/\/www.braindeadprojects.com\/blog\/wp-json\/wp\/v2\/posts\/1289"}],"collection":[{"href":"http:\/\/www.braindeadprojects.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.braindeadprojects.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.braindeadprojects.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.braindeadprojects.com\/blog\/wp-json\/wp\/v2\/comments?post=1289"}],"version-history":[{"count":53,"href":"http:\/\/www.braindeadprojects.com\/blog\/wp-json\/wp\/v2\/posts\/1289\/revisions"}],"predecessor-version":[{"id":1346,"href":"http:\/\/www.braindeadprojects.com\/blog\/wp-json\/wp\/v2\/posts\/1289\/revisions\/1346"}],"wp:attachment":[{"href":"http:\/\/www.braindeadprojects.com\/blog\/wp-json\/wp\/v2\/media?parent=1289"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.braindeadprojects.com\/blog\/wp-json\/wp\/v2\/categories?post=1289"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.braindeadprojects.com\/blog\/wp-json\/wp\/v2\/tags?post=1289"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}