<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: qemu code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Tue, 07 Oct 2008 09:31:41 GMT</pubDate>
    <description>DZone Snippets: qemu code</description>
    <item>
      <title>Launch Windows XP with Qemu</title>
      <link>http://snippets.dzone.com/posts/show/4678</link>
      <description>This code worked under Ubuntu Server 7.4, using Qemu and a Windows XP image file.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;# Starts up QEmu with various options&lt;br /&gt;&lt;br /&gt;# Variables&lt;br /&gt;set -o errexit&lt;br /&gt;SOUND="-soundhw es1370"&lt;br /&gt;MEMORY="-m 330"&lt;br /&gt;TIME="-localtime"&lt;br /&gt;IMGPATH="/mnt/data/virtual/xp"&lt;br /&gt;IMG=$1&lt;br /&gt;USERID=`whoami`&lt;br /&gt;&lt;br /&gt;# need to make sure we have read/write access to the  device at /dev/net/tun&lt;br /&gt;echo "Using sudo too to setup /dev/net/tun..."&lt;br /&gt;sudo chown root:$USERID /dev/net/tun&lt;br /&gt;sudo chmod g+rw /dev/net/tun&lt;br /&gt;# now be sure that IP forwarding and masquerading are good to go&lt;br /&gt;echo "Need root password to setup IP forwarding..."&lt;br /&gt;su -c "echo '1' &gt; /proc/sys/net/ipv4/ip_forward"&lt;br /&gt;echo "Done being root..."&lt;br /&gt;sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE&lt;br /&gt;&lt;br /&gt;# Create tap interface so that the script /etc/qemu-ifup can bridge it&lt;br /&gt;# before qemu starts&lt;br /&gt;echo "Using sudo to setup the tap interface..."&lt;br /&gt;IFACE=`sudo tunctl -b -u $USERID`&lt;br /&gt;&lt;br /&gt;NET="-net nic,vlan=0 -net tap,vlan=0,ifname=$IFACE,script=/etc/qemu-ifup"&lt;br /&gt;&lt;br /&gt;# QEmu start&lt;br /&gt;qemu ${SOUND} ${TIME} ${MEMORY} ${IMG} ${NET} -usb&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;# QEmu has stopped - no longer using tap interface&lt;br /&gt;sudo tunctl -d $IFACE &amp;&gt; /dev/null&lt;br /&gt;&lt;br /&gt;# user no longer needs read/write on /dev/net/tun&lt;br /&gt;sudo chown root:root /dev/net/tun&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;after script execution I run this 'sudo ifconfig tap0 192.168.1.6'&lt;br /&gt;when the script is finished I run this 'sudo tunctl -d tap0'&lt;br /&gt;</description>
      <pubDate>Fri, 19 Oct 2007 14:54:41 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4678</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>use qemu on ubuntu linux</title>
      <link>http://snippets.dzone.com/posts/show/689</link>
      <description>you must install qemu first ... run this :&lt;br /&gt;&lt;code&gt;&lt;br /&gt;sudo apt-get install qemu&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;then create a virtual filesystem (to simulate a hdd) (1000000 = 10go), under your home directory&lt;br /&gt;&lt;code&gt;&lt;br /&gt;dd of=hd.img bs=1024 seek=1000000 count=0&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;put a bootable cd (or an "iso-file") in your cd drive (win2k, xp, linux live-cd, ...), and run&lt;br /&gt;&lt;code&gt;&lt;br /&gt;qemu -hda /home/[your_name]/hd.img -cdrom /dev/hdd -boot d -m 512 -user-net&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;option -hda = the virtual disk to use (~/hd.img)&lt;br /&gt;option -m = memory to use (512 mo).&lt;br /&gt;option -cdrom = cd-drive (/dev/hdd for me) (or an iso file)&lt;br /&gt;option -boot = which drive to boot (d as the cdrom)&lt;br /&gt;option -user-net : net user mode (see http://fabrice.bellard.free.fr/qemu/qemu-doc.html#SEC21)&lt;br /&gt;&lt;br /&gt;and it's run like a charm ...impressive&lt;br /&gt;</description>
      <pubDate>Fri, 09 Sep 2005 15:57:05 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/689</guid>
      <author>manatlan (manatlan)</author>
    </item>
  </channel>
</rss>
