{"id":5,"date":"2005-10-26T19:19:07","date_gmt":"2005-10-26T19:17:23","guid":{"rendered":""},"modified":"2017-03-07T15:55:50","modified_gmt":"2017-03-07T15:55:50","slug":"qemu_notes","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/agriffis\/2005\/10\/26\/qemu_notes\/","title":{"rendered":"qemu notes"},"content":{"rendered":"<p>I&#8217;ve been using <a href=\"http:\/\/fabrice.bellard.free.fr\/qemu\/index.html\">qemu<\/a> lately to test kernel changes.  In particular I&#8217;m using qemu-0.7.2 running x86 virtual machines on an amd64.  This configuration seems to work really well, particularly once I remembered to &#8220;echo 1 >\/proc\/sys\/kernel\/sysrq&#8221; in the host OS&#8217;s rc.local (doh!)<\/p>\n<p>Today I switched from using qemu&#8217;s <a href=\"http:\/\/fabrice.bellard.free.fr\/qemu\/qemu-doc.html#TOC21\">user mode network stack<\/a> to using the <a href=\"http:\/\/fabrice.bellard.free.fr\/qemu\/qemu-doc.html#TOC20\">tun\/tap interface<\/a> with masquerading.  To that end, my qemu startup script now looks like this:<\/p>\n<blockquote>\n<pre>#!\/bin\/bash\r\n# qemu.sh\r\nsudo bash -c 'echo 1024 > \/proc\/sys\/dev\/rtc\/max-user-freq'\r\n#sudo modprobe kqemu\r\nqemu \\\r\n    -kernel linux-2.6-qemu\/arch\/i386\/boot\/bzImage \\\r\n    -append 'console=ttyS0 root=\/dev\/hda ro clock=pit' \\\r\n    -hda root_fs.fc-4-base.pristine.20051026 \\\r\n    -nographic \\\r\n    -n $PWD\/qemu-ifup \\\r\n    \"$@\"\r\n<\/pre>\n<\/blockquote>\n<p>and qemu-ifup looks like this:<\/p>\n<blockquote>\n<pre>#!\/usr\/bin\/sudo bash\r\n\/sbin\/ifconfig $1 172.20.0.1\r\niptables --table nat --flush\r\niptables --table nat --append POSTROUTING \\\r\n    --source 172.20.0.0\/16 --destination ! 172.20.0.0\/16 \\\r\n    --jump MASQUERADE\r\n[[ -e \/proc\/sys\/net\/ipv4\/ip_forward ]] &amp;&amp; \\\r\n    echo 1 > \/proc\/sys\/net\/ipv4\/ip_forward\r\n<\/pre>\n<\/blockquote>\n<p>This gives me outgoing networking from the virtual machine, plus incoming networking from the host OS.  The virtual OS uses 172.20.0.2 on its virtual adapter.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been using qemu lately to test kernel changes. In particular I&#8217;m using qemu-0.7.2 running x86 virtual machines on an amd64. This configuration seems to work really well, particularly once I remembered to &#8220;echo 1 >\/proc\/sys\/kernel\/sysrq&#8221; in the host OS&#8217;s rc.local (doh!) Today I switched from using qemu&#8217;s user mode network stack to using the &hellip; <a href=\"https:\/\/blogs.gentoo.org\/agriffis\/2005\/10\/26\/qemu_notes\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">qemu notes<\/span><\/a><\/p>\n","protected":false},"author":25,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/agriffis\/wp-json\/wp\/v2\/posts\/5"}],"collection":[{"href":"https:\/\/blogs.gentoo.org\/agriffis\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.gentoo.org\/agriffis\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/agriffis\/wp-json\/wp\/v2\/users\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/agriffis\/wp-json\/wp\/v2\/comments?post=5"}],"version-history":[{"count":1,"href":"https:\/\/blogs.gentoo.org\/agriffis\/wp-json\/wp\/v2\/posts\/5\/revisions"}],"predecessor-version":[{"id":17,"href":"https:\/\/blogs.gentoo.org\/agriffis\/wp-json\/wp\/v2\/posts\/5\/revisions\/17"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/agriffis\/wp-json\/wp\/v2\/media?parent=5"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/agriffis\/wp-json\/wp\/v2\/categories?post=5"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/agriffis\/wp-json\/wp\/v2\/tags?post=5"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}