<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Phithak Thaenkaew</title>
	<atom:link href="http://phithak.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://phithak.wordpress.com</link>
	<description></description>
	<lastBuildDate>Tue, 17 Jan 2012 08:26:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='phithak.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Phithak Thaenkaew</title>
		<link>http://phithak.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://phithak.wordpress.com/osd.xml" title="Phithak Thaenkaew" />
	<atom:link rel='hub' href='http://phithak.wordpress.com/?pushpress=hub'/>
		<item>
		<title>ANSCSE 16</title>
		<link>http://phithak.wordpress.com/2012/01/17/anscse-16/</link>
		<comments>http://phithak.wordpress.com/2012/01/17/anscse-16/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 04:26:51 +0000</pubDate>
		<dc:creator>phithak</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://phithak.wordpress.com/?p=355</guid>
		<description><![CDATA[The 16th International Annual Symposium on Computational Science and Engineering (ANSCSE 16) Date: 23-25 May 2012 Venue: Chiang Mai University, Chiang Mai, Thailand ANSCSE (Annual Symposium on Computational Science and Engineering) is an international forum for computational scientist and engineer held annually. The goal is to foster the collaboration among researchers in the field of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phithak.wordpress.com&amp;blog=10487570&amp;post=355&amp;subd=phithak&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The 16th International Annual Symposium on<br />
Computational Science and Engineering (ANSCSE 16) </p>
<p>Date: 23-25 May 2012</p>
<p>Venue: Chiang Mai University, Chiang Mai, Thailand </p>
<p>ANSCSE (Annual Symposium on Computational Science and Engineering) is an international forum for computational scientist and engineer held annually. The goal is to foster the collaboration among researchers in the field of computational science and engineering. ANSCSE also acts as a forum for researchers in Thailand and international partners to exchange new ideas, findings, and best practices.</p>
<p>ANSCSE 16 scientific program covers the most recent and advanced research on areas of computational science, computational engineering, and related disciplines. Authors are invited to submit extended abstracts or manuscripts that present original unpublished research in all areas of computational science and engineering. Topics of interest include, but are not limited to<br />
Computational Biology<br />
Computational Chemistry<br />
Computational Mathematics<br />
Computational Physics including Crystallographic computing and modeling<br />
Computational Fluid Dynamics and Solid Mechanics<br />
High Performance Computing and Grid computing, Computer Science and Engineering: Neuron Network, Artificial Intelligence, Data Mining, Digital Signal Processing, Image Processing and Algorithm for CSE</p>
<p>Official Site<br />
<a href="http://anscse.lsr.nectec.or.th" title="ANSCSE 16" target="_blank">http://anscse.lsr.nectec.or.th</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phithak.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phithak.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phithak.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phithak.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phithak.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phithak.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phithak.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phithak.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phithak.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phithak.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phithak.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phithak.wordpress.com/355/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phithak.wordpress.com/355/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phithak.wordpress.com/355/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phithak.wordpress.com&amp;blog=10487570&amp;post=355&amp;subd=phithak&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phithak.wordpress.com/2012/01/17/anscse-16/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b8a8e09c8ce315fc2e6f6e5dfa7f45c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phithak</media:title>
		</media:content>
	</item>
		<item>
		<title>Study KVM internal 4</title>
		<link>http://phithak.wordpress.com/2010/10/05/study-kvm-internal-4/</link>
		<comments>http://phithak.wordpress.com/2010/10/05/study-kvm-internal-4/#comments</comments>
		<pubDate>Mon, 04 Oct 2010 17:17:41 +0000</pubDate>
		<dc:creator>phithak</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://phithak.wordpress.com/?p=346</guid>
		<description><![CDATA[KVM Live Migration - ในตัวอย่างนี้จะทำการ Migrate จาก Source VM ไปยัง Destination VM บนเครื่องเดียวกัน โดยแต่ละ VM จะทำงานอยู่คนละ Directory - Source VM อยู่ที่ ~/Homework/CS797/src มีไฟล์ Base Image ชื่อ centos_base.img - Destination VM อยู่ที่ ~/Homework/CS797/dst สร้างไฟล์ Image ชื่อ centos_migrate.img Destination VM - เริ่มจากส่วนของ Destination VM โดยทำการสร้าง Disk Image เปล่า ๆ แบบ QCOW2 ให้มีขนาดเท่ากับ Image ของ Source VM $ [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phithak.wordpress.com&amp;blog=10487570&amp;post=346&amp;subd=phithak&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>KVM Live Migration</h2>
<p>- ในตัวอย่างนี้จะทำการ Migrate จาก Source VM ไปยัง Destination VM บนเครื่องเดียวกัน โดยแต่ละ VM จะทำงานอยู่คนละ Directory<br />
- Source VM อยู่ที่ ~/Homework/CS797/src มีไฟล์ Base Image ชื่อ centos_base.img<br />
- Destination VM อยู่ที่ ~/Homework/CS797/dst สร้างไฟล์ Image ชื่อ centos_migrate.img</p>
<h3>Destination VM</h3>
<p>- เริ่มจากส่วนของ Destination VM โดยทำการสร้าง Disk Image เปล่า ๆ แบบ QCOW2 ให้มีขนาดเท่ากับ Image ของ Source VM<br />
<code><strong>$</strong> <em>qemu-img create -f qcow2 centos_migrate.img 8G</em><br />
Formatting 'centos_migrate.img', fmt=qcow2 size=8589934592 encryption=off cluster_size=0 </code></p>
<p>- ตรวจสอบขนาดของ Disk Image<br />
<code><strong>$</strong> <em>ls -lh</em><br />
total 512<br />
-rw-r--r--  1 phithak  staff   256K Oct  5 21:28 centos_migrate.img</code></p>
<p>- รอการเชื่อมต่อที่พอร์ต 4444 เพื่อแสดงให้เห็นว่าเป็น Destination VM จึงเพิ่ม -name &#8220;CS797 Destination VM&#8221;<br />
<code><strong>$</strong> <em>qemu -hda centos_migrate.img -boot c -m 256 -name "CS797 Destination VM" -incoming tcp:0:4444</em></code></p>
<p>- ภาพประกอบ (คำสั่งที่ใช้)<br />
<img src="http://img442.imageshack.us/img442/8918/screenshot20101005at103.png" alt="Destination VM" /></p>
<p><span id="more-346"></span><br />
- ภาพประกอบ (Destination VM แสดงหน้าจอว่างเปล่า)<br />
<img src="http://img215.imageshack.us/img215/8755/screenshot20101005at932.png" alt="Destination VM" /></p>
<p>- เปิด Terminal ขึ้นมาใหม่ ทำการตรวจสอบพอร์ตที่เปิดรอ ด้วยคำสั่ง <code><em>lsof -i:4444</em></code><br />
<img src="http://img228.imageshack.us/img228/4964/screenshot20101005at930.png" alt="Incoming Port" /></p>
<h3>Source VM</h3>
<p>- เปิด VM ตามปกติ โดยเพิ่ม -name &#8220;CS797 Source VM&#8221; เพื่อแสดงให้เห็นว่าเป็น Source VM<br />
<code><strong>$</strong> <em>qemu -hda centos_base.img -boot c -m 256 -name "CS797 Source VM"</em></code><br />
<img src="http://img217.imageshack.us/img217/3971/screenshot20101006at144z.png" alt="Source VM" /></p>
<p>- หน้า Source VM<br />
<img src="http://img201.imageshack.us/img201/3807/screenshot20101005at919.png" alt="Source VM" /></p>
<p>- กด ctrl+alt+2 เพื่อเข้า monitor console</p>
<p>- เริ่มทำการ Migrate<br />
<code><strong>(qemu)</strong> <em>migrate -d -b tcp:127.0.0.1:4444</em></code></p>
<p>- ตรวจสอบสถานะการ Migrate<br />
<code><strong>(qemu)</strong> <em>info migrate</em></code><br />
<img src="http://img148.imageshack.us/img148/421/screenshot20101006at120.png" alt="Source VM" /></p>
<h3>Destination VM</h3>
<p>- หลังจากเริ่ม Migrate แล้ว สังเกตที่ Destination VM จะแสดงเปอร์เซ็นต์ของการ Copy Disk Image จาก Source VM<br />
<img src="http://img411.imageshack.us/img411/421/screenshot20101006at120.png" alt="Destination VM" /></p>
<p>- รอจนครบ 100% จากนั้นหน้า Destination VM จะเหมือนกับ Source VM<br />
<img src="http://img7.imageshack.us/img7/5869/screenshot20101005at948.png" alt="Destination VM" /></p>
<p>- ตรวจสอบ ขนาด Disk Image ของ Destination VM<br />
<code><strong>$</strong> <em>ls -lh</em><br />
<strong>$</strong> <em>qemu-img info centos_migrate.img</em></code><br />
<img src="http://img819.imageshack.us/img819/6888/screenshot20101006at110.png" alt="Destination VM Disk Image" /></p>
<h3>Source VM</h3>
<p>- ตรวจสอบสถานะของ Source VM อีกครั้ง หลังจาก Migrate เสร็จแล้ว พบว่า Source VM หยุดทำงาน<br />
<code><strong>(qemu)</strong> <em>info migrate</em><br />
<strong>(qemu)</strong> <em>info status</em></code><br />
<img src="http://img227.imageshack.us/img227/3509/screenshot20101006at122.png" alt="Source VM" /></p>
<p></p>
<h2>References</h2>
<p>- <a href="http://wiki.qemu.org/download/qemu-doc.html#pcsys_005fmonitor">http://wiki.qemu.org/download/qemu-doc.html</a><br />
- <a href="http://www.linux-kvm.org/page/Migration">http://www.linux-kvm.org/page/Migration</a></p>
<h2>Laboratory</h2>
<p>- <a href="http://vasabilab.cs.tu.ac.th">http://vasabilab.cs.tu.ac.th</a></p>
<h2>Mirror Site</h2>
<p>- <a href="http://phithak.com/study-kvm-internal-4">http://phithak.com/study-kvm-internal-4</a><br />
- <a href="http://phithak.wordpress.com/2010/10/05/study-kvm-internal-4/">http://phithak.wordpress.com/2010/10/05/study-kvm-internal-4/</a></p>
<p>(ที่มา: การบ้าน หัวข้อ CS797 Exercise 8 &#8211; Study KVM internal 4 วิชา CS797 Advanced Topics in Computer Science &#8211; Introduction to Computer Virtualization ภาคเรียนที่ 1/2553 อาจารย์ผู้สอน <a style="text-decoration:none;" title="Dr.Kasidit Chanchio" href="http://kasiditchanchio.blogspot.com" target="_blank">ดร.กษิดิศ ชาญเชี่ยว</a> ภาควิชาวิทยาการคอมพิวเตอร์ คณะวิทยาศาสตร์และเทคโนโลยี มหาวิทยาลัยธรรมศาสตร์)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phithak.wordpress.com/346/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phithak.wordpress.com/346/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phithak.wordpress.com/346/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phithak.wordpress.com/346/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phithak.wordpress.com/346/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phithak.wordpress.com/346/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phithak.wordpress.com/346/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phithak.wordpress.com/346/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phithak.wordpress.com/346/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phithak.wordpress.com/346/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phithak.wordpress.com/346/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phithak.wordpress.com/346/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phithak.wordpress.com/346/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phithak.wordpress.com/346/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phithak.wordpress.com&amp;blog=10487570&amp;post=346&amp;subd=phithak&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phithak.wordpress.com/2010/10/05/study-kvm-internal-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b8a8e09c8ce315fc2e6f6e5dfa7f45c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phithak</media:title>
		</media:content>

		<media:content url="http://img442.imageshack.us/img442/8918/screenshot20101005at103.png" medium="image">
			<media:title type="html">Destination VM</media:title>
		</media:content>

		<media:content url="http://img215.imageshack.us/img215/8755/screenshot20101005at932.png" medium="image">
			<media:title type="html">Destination VM</media:title>
		</media:content>

		<media:content url="http://img228.imageshack.us/img228/4964/screenshot20101005at930.png" medium="image">
			<media:title type="html">Incoming Port</media:title>
		</media:content>

		<media:content url="http://img217.imageshack.us/img217/3971/screenshot20101006at144z.png" medium="image">
			<media:title type="html">Source VM</media:title>
		</media:content>

		<media:content url="http://img201.imageshack.us/img201/3807/screenshot20101005at919.png" medium="image">
			<media:title type="html">Source VM</media:title>
		</media:content>

		<media:content url="http://img148.imageshack.us/img148/421/screenshot20101006at120.png" medium="image">
			<media:title type="html">Source VM</media:title>
		</media:content>

		<media:content url="http://img411.imageshack.us/img411/421/screenshot20101006at120.png" medium="image">
			<media:title type="html">Destination VM</media:title>
		</media:content>

		<media:content url="http://img7.imageshack.us/img7/5869/screenshot20101005at948.png" medium="image">
			<media:title type="html">Destination VM</media:title>
		</media:content>

		<media:content url="http://img819.imageshack.us/img819/6888/screenshot20101006at110.png" medium="image">
			<media:title type="html">Destination VM Disk Image</media:title>
		</media:content>

		<media:content url="http://img227.imageshack.us/img227/3509/screenshot20101006at122.png" medium="image">
			<media:title type="html">Source VM</media:title>
		</media:content>
	</item>
		<item>
		<title>Study KVM internal 3</title>
		<link>http://phithak.wordpress.com/2010/09/05/study-kvm-internal-3/</link>
		<comments>http://phithak.wordpress.com/2010/09/05/study-kvm-internal-3/#comments</comments>
		<pubDate>Sun, 05 Sep 2010 14:25:57 +0000</pubDate>
		<dc:creator>phithak</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://phithak.wordpress.com/?p=328</guid>
		<description><![CDATA[Trace bdrv_open() _______________________________ ( ) ( !!! Coming Soon !!! ) (_______________________________) o o \_\_ _/_/ o \__/ (oo)\_______ (__)\ )\/\ &#124;&#124;----w &#124; &#124;&#124; &#124;&#124; Edited by _____ _ _ _____ _______ _ _ _ __ &#124; __ \&#124; &#124; &#124; &#124;_ _&#124;__ __&#124; &#124; &#124; &#124; /\ &#124; &#124;/ / &#124; &#124;__) &#124; &#124;__&#124; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phithak.wordpress.com&amp;blog=10487570&amp;post=328&amp;subd=phithak&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>Trace bdrv_open()</h2>
<p><code>
<pre> _______________________________
(                               )
(     !!! Coming Soon !!!       )
(_______________________________)
  o
   o   \_\_    _/_/
    o      \__/
           (oo)\_______
           (__)\       )\/\
               ||----w |
               ||     ||</pre>
<p></code></p>
<h2>Edited by</h2>
<p><code>
<pre> _____  _    _ _____ _______ _    _          _  __
|  __ \| |  | |_   _|__   __| |  | |   /\   | |/ /
| |__) | |__| | | |    | |  | |__| |  /  \  | ' /
|  ___/|  __  | | |    | |  |  __  | / /\ \ |  &lt;
| |    | |  | |_| |_   | |  | |  | |/ ____ \| . \
|_|    |_|  |_|_____|  |_|  |_|  |_/_/    \_\_|\_\
</pre>
<p></code></p>
<h2>Laboratory</h2>
<p>- <a href="http://vasabilab.cs.tu.ac.th/index.html">http://vasabilab.cs.tu.ac.th</a></p>
<h2>Mirror Site</h2>
<p>- <a href="http://phithak.com/study-kvm-internal-3">http://phithak.com/study-kvm-internal-3</a><br />
- <a href="http://phithak.wordpress.com/2010/09/05/study-kvm-internal-3/">http://phithak.wordpress.com/2010/09/05/study-kvm-internal-3/</a></p>
<p>(ที่มา: การบ้าน หัวข้อ CS797 Exercise 7 &#8211; Study KVM internal 3 วิชา CS797 Advanced Topics in Computer Science &#8211; Introduction to Computer Virtualization ภาคเรียนที่ 1/2553 อาจารย์ผู้สอน <a style="text-decoration:none;" title="Dr.Kasidit Chanchio" href="http://kasiditchanchio.blogspot.com" target="_blank">ดร.กษิดิศ ชาญเชี่ยว</a> ภาควิชาวิทยาการคอมพิวเตอร์ คณะวิทยาศาสตร์และเทคโนโลยี มหาวิทยาลัยธรรมศาสตร์)<br />
<span id="more-328"></span></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phithak.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phithak.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phithak.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phithak.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phithak.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phithak.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phithak.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phithak.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phithak.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phithak.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phithak.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phithak.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phithak.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phithak.wordpress.com/328/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phithak.wordpress.com&amp;blog=10487570&amp;post=328&amp;subd=phithak&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phithak.wordpress.com/2010/09/05/study-kvm-internal-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b8a8e09c8ce315fc2e6f6e5dfa7f45c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phithak</media:title>
		</media:content>
	</item>
		<item>
		<title>Study KVM internal 2</title>
		<link>http://phithak.wordpress.com/2010/08/26/study-kvm-internal-2/</link>
		<comments>http://phithak.wordpress.com/2010/08/26/study-kvm-internal-2/#comments</comments>
		<pubDate>Thu, 26 Aug 2010 11:48:59 +0000</pubDate>
		<dc:creator>phithak</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://phithak.wordpress.com/?p=278</guid>
		<description><![CDATA[The C Preprocessor - เพื่อให้ทำความเข้าใจ Code ของ KVM ได้ดียิ่งขึ้น จึงศึกษาเกี่ยวกับ Preprocessor เพิ่มเติม ที่ The C Preprocessor ยกตัวอย่างบางส่วนที่น่าสนใจและมีอยู่ใน Code ของ KVM คือ Macros ซึ่งมีสัญลักษณ์แปลก ๆ เช่น ## ที่ปรากฏอยู่ในหัวข้อ Concatenation - เพื่อให้เข้าใจถึงกลไกของ Compiler ในการจัดการกับ Preprocessor ให้มากขึ้น จึงทดลองเขียนโปรแกรมที่มี Preprocessor อยู่ใน Code และทดลองใช้ Compiler ทำการ Compile แล้วดูผลลัพธ์ที่ได้จาก Preprocessor - เขียนโปรแกรมภาษา C ง่าย ๆ - ทำการ Compile โดยใช้คำสั่ง gcc -E [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phithak.wordpress.com&amp;blog=10487570&amp;post=278&amp;subd=phithak&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h2>The C Preprocessor</h2>
<p>- เพื่อให้ทำความเข้าใจ Code ของ KVM ได้ดียิ่งขึ้น จึงศึกษาเกี่ยวกับ Preprocessor เพิ่มเติม ที่ <a href="http://gcc.gnu.org/onlinedocs/gcc-2.95.3/cpp_1.html">The C Preprocessor</a> ยกตัวอย่างบางส่วนที่น่าสนใจและมีอยู่ใน Code ของ KVM คือ <a href="http://gcc.gnu.org/onlinedocs/gcc-2.95.3/cpp_1.html#SEC10">Macros</a> ซึ่งมีสัญลักษณ์แปลก ๆ เช่น ## ที่ปรากฏอยู่ในหัวข้อ <a href="http://gcc.gnu.org/onlinedocs/gcc-2.95.3/cpp_1.html#SEC17">Concatenation</a></p>
<p>- เพื่อให้เข้าใจถึงกลไกของ Compiler ในการจัดการกับ Preprocessor ให้มากขึ้น จึงทดลองเขียนโปรแกรมที่มี Preprocessor อยู่ใน Code และทดลองใช้ Compiler ทำการ Compile แล้วดูผลลัพธ์ที่ได้จาก Preprocessor</p>
<p>- เขียนโปรแกรมภาษา C ง่าย ๆ<br />
<img alt="" src="http://a.imageshack.us/img251/4725/screenshotterminal6.png" title="#define CONSTANT 99" class="alignnone" width="671" height="192" /></p>
<p><span id="more-278"></span>- ทำการ Compile โดยใช้คำสั่ง gcc -E เพื่อให้ Compiler ทำงานเฉพาะในส่วนของ Preprocessor ได้ผลดังภาพ<br />
<img alt="" src="http://a.imageshack.us/img825/9696/screenshotterminal4.png" title="gcc -E preprocessor.c" class="alignnone" width="671" height="277" /></p>
<p>- สังเกตผลที่ได้ และ นำความรู้ในส่วนนี้ ไปประยุกต์ใช้ในการศึกษา Code ของ KVM ในหัวข้อต่อ ๆ ไป</p>
<h2>Study block_init()</h2>
<p>- ศึกษา block_init() จากไฟล์ module.h<br />
<code>
<pre> 16 ...
 17 /* This should not be used directly.  Use block_init etc. instead.  */
 18 #define module_init(function, type)
 19 static void __attribute__((constructor)) do_qemu_init_ ## function(void) {
 20     register_module_init(function, type);
 21 }
 22
 23 typedef enum {
 24     MODULE_INIT_BLOCK,
 25     MODULE_INIT_DEVICE,
 26     MODULE_INIT_MACHINE,
 27     MODULE_INIT_MAX
 28 } module_init_type;
 29
 30 #define block_init(function) module_init(function, MODULE_INIT_BLOCK)
 31 #define device_init(function) module_init(function, MODULE_INIT_DEVICE)
 32 #define machine_init(function) module_init(function, MODULE_INIT_MACHINE)
 33
 34 void register_module_init(void (*fn)(void), module_init_type type);
 35 ...</pre>
<p></code></p>
<p>- เขียนโปรแกรมอย่างง่าย โดยทำการ #include &#8220;module.h&#8221; เข้าไปด้วย บันทึกชื่อ block_init.c<br />
- เรียกใช้ block_init(bdrv_qcow2_init) และ block_init(bdrv_raw_init)<br />
<img alt="" src="http://a.imageshack.us/img155/3153/screenshotterminal8.png" title="block_init()" class="alignnone" width="671" height="192" /></p>
<p>- ใช้ Compiler ตรวจสอบการทำงานของ Preprocessor ด้วยคำสั่ง gcc -E block_init.c<br />
<img alt="" src="http://a.imageshack.us/img810/4584/screenshotterminal10.png" title="block_init() with Preprocessor" class="alignnone" width="671" height="209" /></p>
<p>- ผลที่ได้พบว่าเมื่อเรียกใช้ block_init(bdrv_qcow2_init) จะถูกเปลี่ยนเป็น<br />
<code>
<pre>static void __attribute__((constructor)) do_qemu_init_bdrv_qcow2_init(void) {
    register_module_init(bdrv_qcow2_init, MODULE_INIT_BLOCK);
};</pre>
<p></code></p>
<p>- และ block_init(bdrv_raw_init) ก็เช่นกัน<br />
<code>
<pre>static void __attribute__((constructor)) do_qemu_init_bdrv_raw_init(void) {
    register_module_init(bdrv_raw_init, MODULE_INIT_BLOCK);
};</pre>
<p></code></p>
<p>- ศึกษาเกี่ยวกับ <a href="http://www.faqs.org/docs/Linux-HOWTO/Program-Library-HOWTO.html#INIT-AND-CLEANUP">Program Library Howto</a> ในส่วนของ ((constructor)) พบว่า ฟังก์ชันที่ได้จาก Preprocessor ดังกล่าว อันได้แก่ do_qemu_init_bdrv_qcow2_init() และ do_qemu_init_bdrv_raw_init() จะทำงานในขณะโปรแกรมกำลังโหลดเข้าสู่ระบบ นั่นคือ ก่อนที่ dlopen() จะ return หรือก่อนเข้าฟังก์ชัน main()</p>
<p>- เพื่อให้เข้าใจมากขึ้นจึงเขียนโปรแกรม ที่มีการเรียกใช้ ((constructor))<br />
<img alt="" src="http://a.imageshack.us/img225/7133/screenshotterminal11.png" title="constructor" class="alignnone" width="671" height="243" /></p>
<p>- ทำการ Compile และ Run พบว่า ฟังก์ชัน hello() ทำงานก่อน main()<br />
<img alt="" src="http://a.imageshack.us/img443/7616/screenshotterminal12.png" title="constructor result" class="alignnone" width="671" height="141" /></p>
<h2>Study bdrv_open() and bdrv_close()</h2>
<p>- ศึกษา Data Structure ที่เกี่ยวข้องกับฟังก์ชัน bdrv_open() และ bdrv_close() มีดังนี้<br />
<code>
<pre> ...
 356 int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
 357                BlockDriver *drv)
 ...
 ...
 507 void bdrv_close(BlockDriverState *bs)
 ...</pre>
<p></code></p>
<p>- มี 4 ตัว แต่ที่โครงสร้างค่อนข้างซับซ้อนมี 2 ตัว ได้แก่ BlockDriverState และ BlockDriver</p>
<p>- ศึกษา BlockDriverState จาก block_int.h<br />
<img alt="" src="http://a.imageshack.us/img230/3418/screenshotterminal13.png" title="BlockDriverState" class="alignnone" width="671" height="141" /><code>
<pre>125
126 struct BlockDriverState {
127     int64_t total_sectors; /* if we are reading a disk image, give its
128                               size in sectors */
129     int read_only; /* if true, the media is read only */
130     int removable; /* if true, the media can be removed */
131     int locked;    /* if true, the media cannot temporarily be ejected */
132     int encrypted; /* if true, the media is encrypted */
133     int valid_key; /* if true, a valid encryption key has been set */
134     int sg;        /* if true, the device is a /dev/sg* */
135     /* event callback when inserting/removing */
136     void (*change_cb)(void *opaque);
137     void *change_opaque;
138
139     <u>BlockDriver *drv</u>; /* NULL means no media */
140     void *opaque;
141
142     char filename[1024];
143     char backing_file[1024]; /* if non zero, the image is a diff of
144                                 this file image */
145     char backing_format[16]; /* if non-zero and backing_file exists */
146     int is_temporary;
147     int media_changed;
148
149     <u>BlockDriverState *backing_hd</u>;
150     /* async read/write emulation */
151
152     void *sync_aiocb;
153
154     /* I/O stats (display with "info blockstats"). */
155     uint64_t rd_bytes;
156     uint64_t wr_bytes;
157     uint64_t rd_ops;
158     uint64_t wr_ops;
159
160     /* Whether the disk can expand beyond total_sectors */
161     int growable;
162
163     /* the memory alignment required for the buffers handled by this driver
164     int buffer_alignment;
165
166     /* do we need to tell the quest if we have a volatile write cache? */
167     int enable_write_cache;
168
169     /* NOTE: the following infos are only hints for real hardware
170        drivers. They are not used by the block driver */
171     int cyls, heads, secs, translation;
172     int type;
173     char device_name[32];
174     unsigned long *dirty_bitmap;
175     <u>BlockDriverState *next</u>;
176     void *private;
177 };
178
</pre>
<p></code></p>
<p>- และศึกษา BlockDriver<br />
<code>
<pre> 47
 48 struct BlockDriver {
 49     const char *format_name;
 50     int instance_size;
 51     int (*bdrv_probe)(const uint8_t *buf, int buf_size, const char *filename
 52     int (*bdrv_probe_device)(const char *filename);
 53     int (*bdrv_open)(BlockDriverState *bs, const char *filename, int flags);
 54     int (*bdrv_read)(BlockDriverState *bs, int64_t sector_num,
 55                      uint8_t *buf, int nb_sectors);
 56     int (*bdrv_write)(BlockDriverState *bs, int64_t sector_num,
 57                       const uint8_t *buf, int nb_sectors);
 58     void (*bdrv_close)(BlockDriverState *bs);
 59     int (*bdrv_create)(const char *filename, QEMUOptionParameter *options);
 60     void (*bdrv_flush)(BlockDriverState *bs);
 61     int (*bdrv_is_allocated)(BlockDriverState *bs, int64_t sector_num,
 62                              int nb_sectors, int *pnum);
 63     int (*bdrv_set_key)(BlockDriverState *bs, const char *key);
 64     int (*bdrv_make_empty)(BlockDriverState *bs);
 65     /* aio */
 66     BlockDriverAIOCB *(*bdrv_aio_readv)(BlockDriverState *bs,
 67         int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
 68         BlockDriverCompletionFunc *cb, void *opaque);
 69     BlockDriverAIOCB *(*bdrv_aio_writev)(BlockDriverState *bs,
 70         int64_t sector_num, QEMUIOVector *qiov, int nb_sectors,
 71         BlockDriverCompletionFunc *cb, void *opaque);
 72     BlockDriverAIOCB *(*bdrv_aio_flush)(BlockDriverState *bs,
 73         BlockDriverCompletionFunc *cb, void *opaque);
 74
 75     int (*bdrv_aio_multiwrite)(BlockDriverState *bs, BlockRequest *reqs,
 76         int num_reqs);
 77     int (*bdrv_merge_requests)(BlockDriverState *bs, BlockRequest* a,
 78         BlockRequest *b);
 79
 80
 81     const char *protocol_name;
 82     int (*bdrv_truncate)(BlockDriverState *bs, int64_t offset);
 83     int64_t (*bdrv_getlength)(BlockDriverState *bs);
 84     int (*bdrv_write_compressed)(BlockDriverState *bs, int64_t sector_num,
 85                                  const uint8_t *buf, int nb_sectors);
 86
 87     int (*bdrv_snapshot_create)(BlockDriverState *bs,
 88                                 QEMUSnapshotInfo *sn_info);
 89     int (*bdrv_snapshot_goto)(BlockDriverState *bs,
 90                               const char *snapshot_id);
 91     int (*bdrv_snapshot_delete)(BlockDriverState *bs, const char *snapshot_i
 92     int (*bdrv_snapshot_list)(BlockDriverState *bs,
 93                               QEMUSnapshotInfo **psn_info);
 94     int (*bdrv_get_info)(BlockDriverState *bs, BlockDriverInfo *bdi);
 95
 96     int (*bdrv_save_vmstate)(BlockDriverState *bs, const uint8_t *buf,
 97                              int64_t pos, int size);
 98     int (*bdrv_load_vmstate)(BlockDriverState *bs, uint8_t *buf,
 99                              int64_t pos, int size);
100
101     /* removable device specific */
102     int (*bdrv_is_inserted)(BlockDriverState *bs);
103     int (*bdrv_media_changed)(BlockDriverState *bs);
104     int (*bdrv_eject)(BlockDriverState *bs, int eject_flag);
105     int (*bdrv_set_locked)(BlockDriverState *bs, int locked);
106
107     /* to control generic scsi devices */
108     int (*bdrv_ioctl)(BlockDriverState *bs, unsigned long int req, void *buf
109     BlockDriverAIOCB *(*bdrv_aio_ioctl)(BlockDriverState *bs,
110         unsigned long int req, void *buf,
111         BlockDriverCompletionFunc *cb, void *opaque);
112
113     /* List of options for creating images, terminated by name == NULL */
114     QEMUOptionParameter *create_options;
115
116
117     /* Returns number of errors in image, -errno for internal errors */
118     int (*bdrv_check)(BlockDriverState* bs);
119
120     /* Set if newly created images are not guaranteed to contain only zeros
121     int no_zero_init;
122
123     <u>struct BlockDriver *next</u>;
124 };
125
</pre>
<p></code></p>
<p>- สังเกต ตัวแปรที่ขีดเส้นใต้ จะเห็นได้ว่าเป็น Pointer และส่วนใหญ่เป็น Pointer ที่ชี้หา Data Type ชนิดเดียวกัน ดังนั้น Data Structure จึงเป็นไปในลักษณะ Linked List โดย BlockDriver และ BlockDriverState มีความสัมพันธ์กันดังนี้<br />
<code>
<pre>                     +----+----------------------+----+
                     |    |                      |    |
         *backing_hd |    |                      |    | *next
 ... &lt;-----------------o  |   BlockDriverState   |  o-----------------&gt; ...
                     |    |                      |    |
                     +----+----------------------+----+
                     |                o               |
                     +----------------|---------------+
                                      | *drv
                                      |
                                      V
                          +----------------------+----+
                          |                      |    |
                          |      BlockDriver     |    | *next
                          |                      |  o-----------------&gt; ...
                          |                      |    |
                          +----------------------+----+</pre>
<p></code></p>
<p>- Find out &#8216;WHEN” and “WHERE” the bdrv_open() function is called (!!! กำลังดำเนินการ ยังไม่แล้วเสร็จ !!!)<br />
- Draw the function call graph for the bdrv_open() function  (!!! กำลังดำเนินการ ยังไม่แล้วเสร็จ !!!)<br />
- Describe what happen to the data structure in 2) when the bdrv_open() function is called to open an overlay hard disk image (!!! กำลังดำเนินการ ยังไม่แล้วเสร็จ !!!)</p>
<p>- ศึกษา bdrv_open() โดยเพิ่ม Code ในฟังก์ชัน bdrv_open2() ดังนี้<br />
<code>
<pre> 356 int bdrv_open2(BlockDriverState *bs, const char *filename, int flags,
 357                BlockDriver *drv)
 358 {
 359     // Add by Phithak Thaenkaew
 360     int phithak_seq = rand() % 10000;   // Sequence number
 361     printf("Enter bdrv_open2(), Seq %04d, Flag %2d, Filename: %s\n",
 362         phithak_seq, flags, filename);
 363
 364     printf(" Before --\n");
 365     printf("  filename: %s\n", bs-&gt;filename);
 366     printf("  backing_file: %s\n", bs-&gt;backing_file);
 367     printf("  backing_format: %s\n", bs-&gt;backing_format);
 368     printf("  read_only: %d\n", bs-&gt;read_only);
 369     printf("  removable: %d\n", bs-&gt;removable);
 370
 371     printf("  *drv: %s\n", (bs-&gt;drv==NULL)?"NULL":"NOT NULL");
 372     if (!(bs-&gt;drv==NULL)) {
 373         printf("   -&gt;format_name: %s\n", bs-&gt;drv-&gt;format_name);
 374         printf("   -&gt;protocol_name: %s\n", bs-&gt;drv-&gt;protocol_name);
 375     }
 376
 377     printf("  *backing_hd: %s\n", (bs-&gt;backing_hd==NULL)?"NULL":"NOT NULL");
 378     if (!(bs-&gt;backing_hd==NULL)) {
 379         printf("   -&gt;filename: %s\n", bs-&gt;backing_hd-&gt;filename);
 380         printf("   -&gt;backing_file: %s\n", bs-&gt;backing_hd-&gt;backing_file);
 381         printf("   -&gt;backing_format: %s\n", bs-&gt;backing_hd-&gt;backing_format);
 382         printf("   -&gt;read_only: %d\n", bs-&gt;backing_hd-&gt;read_only);
 383         printf("   -&gt;removable: %d\n", bs-&gt;backing_hd-&gt;removable);
 384     }
 385
 386     printf("  *next: %s\n", (bs-&gt;next==NULL)?"NULL":"NOT NULL");
 387     if (!(bs-&gt;next==NULL)) {
 388         printf("   -&gt;filename: %s\n", bs-&gt;next-&gt;filename);
 389         printf("   -&gt;backing_file: %s\n", bs-&gt;next-&gt;backing_file);
 390         printf("   -&gt;backing_format: %s\n", bs-&gt;next-&gt;backing_format);
 391         printf("   -&gt;read_only: %d\n", bs-&gt;next-&gt;read_only);
 392         printf("   -&gt;removable: %d\n", bs-&gt;next-&gt;removable);
 393     }
 ...
 ...
 ...
 540     printf(" After -- \n");
 541     printf("  filename: %s\n", bs-&gt;filename);
 542     printf("  backing_file: %s\n", bs-&gt;backing_file);
 543     printf("  backing_format: %s\n", bs-&gt;backing_format);
 544     printf("  read_only: %d\n", bs-&gt;read_only);
 545     printf("  removable: %d\n", bs-&gt;removable);
 546
 547     printf("  *drv: %s\n", (bs-&gt;drv==NULL)?"NULL":"NOT NULL");
 548     if (!(bs-&gt;drv==NULL)) {
 549         printf("   -&gt;format_name: %s\n", bs-&gt;drv-&gt;format_name);
 550         printf("   -&gt;protocol_name: %s\n", bs-&gt;drv-&gt;protocol_name);
 551     }
 552
 553     printf("  *backing_hd: %s\n", (bs-&gt;backing_hd==NULL)?"NULL":"NOT NULL");
 554     if (!(bs-&gt;backing_hd==NULL)) {
 555         printf("   -&gt;filename: %s\n", bs-&gt;backing_hd-&gt;filename);
 556         printf("   -&gt;backing_file: %s\n", bs-&gt;backing_hd-&gt;backing_file);
 557         printf("   -&gt;backing_format: %s\n", bs-&gt;backing_hd-&gt;backing_format);
 558         printf("   -&gt;read_only: %d\n", bs-&gt;backing_hd-&gt;read_only);
 559         printf("   -&gt;removable: %d\n", bs-&gt;backing_hd-&gt;removable);
 560     }
 561
 562     printf("  *next: %s\n", (bs-&gt;next==NULL)?"NULL":"NOT NULL");
 563     if (!(bs-&gt;next==NULL)) {
 564         printf("   -&gt;filename: %s\n", bs-&gt;next-&gt;filename);
 565         printf("   -&gt;backing_file: %s\n", bs-&gt;next-&gt;backing_file);
 566         printf("   -&gt;backing_format: %s\n", bs-&gt;next-&gt;backing_format);
 567         printf("   -&gt;read_only: %d\n", bs-&gt;next-&gt;read_only);
 568         printf("   -&gt;removable: %d\n", bs-&gt;next-&gt;removable);
 569     }
 570     // Add by Phithak
 571     printf(" Exit bdrv_open2(), Seq %04d, Flag %2d, Filename: %s\n",
 572         phithak_seq, flags, filename);
 573     printf("----------------------------------------------------------\n");
 574
 575     return 0;
 576 }
</pre>
<p></code></p>
<p>- ผลที่ได้จากจากเรียกใช้โปรแกรมที่ทำการแก้ไข โดยกำหนดให้ใช้ centos_ovl2.img คือ<br />
<code>
<pre><strong>phithak@phithak-laptop hw04 $</strong> <em>qemu-system-x86_64 -hda centos_ovl2.img -boot c -m 256</em>
Enter bdrv_open2(), Seq 9383, Flag  0, Filename: centos_ovl2.img
 Before --
  filename:
  backing_file:
  backing_format:
  read_only: 0
  removable: 0
  *drv: NULL
  *backing_hd: NULL
  *next: NULL
Enter bdrv_open2(), Seq 0886, Flag 16, Filename: centos_ovl2.img
 Before --
  filename:
  backing_file:
  backing_format:
  read_only: 0
  removable: 0
  *drv: NULL
  *backing_hd: NULL
  *next: NULL
 After --
  filename: centos_ovl2.img
  backing_file:
  backing_format:
  read_only: 1
  removable: 0
  *drv: NOT NULL
   -&gt;format_name: raw
   -&gt;protocol_name: (null)
  *backing_hd: NULL
  *next: NULL
 Exit bdrv_open2(), Seq 0886, Flag 16, Filename: centos_ovl2.img
----------------------------------------------------------
Enter bdrv_open2(), Seq 2777, Flag 18, Filename: centos_ovl2.img
 Before --
  filename:
  backing_file:
  backing_format:
  read_only: 0
  removable: 0
  *drv: NULL
  *backing_hd: NULL
  *next: NULL
 After --
  filename: centos_ovl2.img
  backing_file:
  backing_format:
  read_only: 0
  removable: 0
  *drv: NOT NULL
   -&gt;format_name: raw
   -&gt;protocol_name: (null)
  *backing_hd: NULL
  *next: NULL
 Exit bdrv_open2(), Seq 2777, Flag 18, Filename: centos_ovl2.img
----------------------------------------------------------
Enter bdrv_open2(), Seq 6915, Flag  2, Filename: centos_base.img
 Before --
  filename:
  backing_file:
  backing_format:
  read_only: 0
  removable: 0
  *drv: NULL
  *backing_hd: NULL
  *next: NULL
Enter bdrv_open2(), Seq 7793, Flag 16, Filename: centos_base.img
 Before --
  filename:
  backing_file:
  backing_format:
  read_only: 0
  removable: 0
  *drv: NULL
  *backing_hd: NULL
  *next: NULL
 After --
  filename: centos_base.img
  backing_file:
  backing_format:
  read_only: 1
  removable: 0
  *drv: NOT NULL
   -&gt;format_name: raw
   -&gt;protocol_name: (null)
  *backing_hd: NULL
  *next: NULL
 Exit bdrv_open2(), Seq 7793, Flag 16, Filename: centos_base.img
----------------------------------------------------------
Enter bdrv_open2(), Seq 8335, Flag 18, Filename: centos_base.img
 Before --
  filename:
  backing_file:
  backing_format:
  read_only: 0
  removable: 0
  *drv: NULL
  *backing_hd: NULL
  *next: NULL
 After --
  filename: centos_base.img
  backing_file:
  backing_format:
  read_only: 0
  removable: 0
  *drv: NOT NULL
   -&gt;format_name: raw
   -&gt;protocol_name: (null)
  *backing_hd: NULL
  *next: NULL
 Exit bdrv_open2(), Seq 8335, Flag 18, Filename: centos_base.img
----------------------------------------------------------
 After --
  filename: centos_base.img
  backing_file:
  backing_format:
  read_only: 0
  removable: 0
  *drv: NOT NULL
   -&gt;format_name: qcow2
   -&gt;protocol_name: (null)
  *backing_hd: NULL
  *next: NULL
 Exit bdrv_open2(), Seq 6915, Flag  2, Filename: centos_base.img
----------------------------------------------------------
 After --
  filename: centos_ovl2.img
  backing_file: centos_base.img
  backing_format:
  read_only: 0
  removable: 0
  *drv: NOT NULL
   -&gt;format_name: qcow2
   -&gt;protocol_name: (null)
  *backing_hd: NOT NULL
   -&gt;filename: centos_base.img
   -&gt;backing_file:
   -&gt;backing_format:
   -&gt;read_only: 0
   -&gt;removable: 0
  *next: NULL
 Exit bdrv_open2(), Seq 9383, Flag  0, Filename: centos_ovl2.img
----------------------------------------------------------</pre>
<p></code></p>
<h2>Tools</h2>
<p> &#8211; <a href="http://www.gnu.org/software/grep/">grep</a>, <a href="http://www.vim.org">vi editor</a>, <a href="http://gcc.gnu.org/">gcc</a></p>
<h2>References</h2>
<p> &#8211; <a href="http://gcc.gnu.org/onlinedocs/gcc-2.95.3/cpp_1.html">http://gcc.gnu.org/onlinedocs/gcc-2.95.3/cpp_1.html</a><br />
 &#8211; <a href="http://www.faqs.org/docs/Linux-HOWTO/Program-Library-HOWTO.html#INIT-AND-CLEANUP">http://www.faqs.org/docs/Linux-HOWTO/Program-Library-HOWTO.html#INIT-AND-CLEANUP</a></p>
<h2>Mirror Site</h2>
<p>- <a href="http://phithak.com/study-kvm-internal-2">http://phithak.com/study-kvm-internal-2</a><br />
- <a href="http://phithak.wordpress.com/2010/08/26/study-kvm-internal-2/">http://phithak.wordpress.com/2010/08/26/study-kvm-internal-2/</a></p>
<p>(ที่มา: การบ้าน หัวข้อ CS797 Exercise 6 &#8211; Study KVM internal 2 วิชา CS797 Advanced Topics in Computer Science &#8211; Introduction to Computer Virtualization ภาคเรียนที่ 1/2553 อาจารย์ผู้สอน <a style="text-decoration:none;" title="Dr.Kasidit Chanchio" href="http://kasiditchanchio.blogspot.com" target="_blank">ดร.กษิดิศ ชาญเชี่ยว</a> ภาควิชาวิทยาการคอมพิวเตอร์ คณะวิทยาศาสตร์และเทคโนโลยี มหาวิทยาลัยธรรมศาสตร์)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phithak.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phithak.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phithak.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phithak.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phithak.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phithak.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phithak.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phithak.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phithak.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phithak.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phithak.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phithak.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phithak.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phithak.wordpress.com/278/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phithak.wordpress.com&amp;blog=10487570&amp;post=278&amp;subd=phithak&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phithak.wordpress.com/2010/08/26/study-kvm-internal-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b8a8e09c8ce315fc2e6f6e5dfa7f45c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phithak</media:title>
		</media:content>

		<media:content url="http://a.imageshack.us/img251/4725/screenshotterminal6.png" medium="image">
			<media:title type="html">#define CONSTANT 99</media:title>
		</media:content>

		<media:content url="http://a.imageshack.us/img825/9696/screenshotterminal4.png" medium="image">
			<media:title type="html">gcc -E preprocessor.c</media:title>
		</media:content>

		<media:content url="http://a.imageshack.us/img155/3153/screenshotterminal8.png" medium="image">
			<media:title type="html">block_init()</media:title>
		</media:content>

		<media:content url="http://a.imageshack.us/img810/4584/screenshotterminal10.png" medium="image">
			<media:title type="html">block_init() with Preprocessor</media:title>
		</media:content>

		<media:content url="http://a.imageshack.us/img225/7133/screenshotterminal11.png" medium="image">
			<media:title type="html">constructor</media:title>
		</media:content>

		<media:content url="http://a.imageshack.us/img443/7616/screenshotterminal12.png" medium="image">
			<media:title type="html">constructor result</media:title>
		</media:content>

		<media:content url="http://a.imageshack.us/img230/3418/screenshotterminal13.png" medium="image">
			<media:title type="html">BlockDriverState</media:title>
		</media:content>
	</item>
		<item>
		<title>Study KVM internal 1</title>
		<link>http://phithak.wordpress.com/2010/08/21/study-kvm-internal-1/</link>
		<comments>http://phithak.wordpress.com/2010/08/21/study-kvm-internal-1/#comments</comments>
		<pubDate>Sat, 21 Aug 2010 16:58:21 +0000</pubDate>
		<dc:creator>phithak</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://phithak.wordpress.com/?p=216</guid>
		<description><![CDATA[ในตัวอย่างนี้ใช้ qemu-kvm-0.12.4 Study the file &#8220;vl.c&#8221; - ศึกษาไฟล์ vl.c เมื่อมีการเรียก -hda - ตัวแปรที่เกี่ยวกับ -hda option คือ hda_opts เป็น pointer to QemuOpts (ประกาศบรรทัดที่ 4921) 4921 QemuOpts *hda_opts = NULL, *opts; - QemuOpts เป็น struct มีการประกาศในไฟล์ qemu-option.c 483 struct QemuOpts { 484 char *id; 485 QemuOptsList *list; 486 QTAILQ_HEAD(QemuOptHead, QemuOpt) head; 487 QTAILQ_ENTRY(QemuOpts) next; 488 }; - [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phithak.wordpress.com&amp;blog=10487570&amp;post=216&amp;subd=phithak&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>ในตัวอย่างนี้ใช้ <a href="http://sourceforge.net/projects/kvm/files/qemu-kvm/0.12.4/">qemu-kvm-0.12.4</a></p>
<h2>Study the file &#8220;vl.c&#8221;</h2>
<p>- ศึกษาไฟล์ vl.c เมื่อมีการเรียก -hda<br />
- ตัวแปรที่เกี่ยวกับ -hda option คือ hda_opts เป็น pointer to QemuOpts (ประกาศบรรทัดที่ 4921)<br />
<code>
<pre>4921     QemuOpts *hda_opts = NULL, *opts;</pre>
<p></code></p>
<p>- QemuOpts เป็น struct มีการประกาศในไฟล์ qemu-option.c<br />
<code>
<pre>483 struct QemuOpts {
484     char *id;
485     QemuOptsList *list;
486     QTAILQ_HEAD(QemuOptHead, QemuOpt) head;
487     QTAILQ_ENTRY(QemuOpts) next;
488 };
</pre>
<p></code><span id="more-216"></span><br />
- QemuOptsList ศึกษาเพิ่มเติมได้ที่ qemu-option.h<br />
- QTAILQ_HEAD และ QTAILQ_ENTRY ศึกษาเพิ่มเติมได้ที่ qemu-queue.h</p>
<p>- เมื่อมีการเรียก -hda จะมีการเรียกใช้ฟังก์ชัน drive_add() ในไฟล์ vl.c<br />
<code>
<pre>1985 QemuOpts *drive_add(const char *file, const char *fmt, ...)
1986 {
1987     va_list ap;
1988     char optstr[1024];
1989     QemuOpts *opts;
1990
1991     va_start(ap, fmt);
1992     vsnprintf(optstr, sizeof(optstr), fmt, ap);
1993     va_end(ap);
1994
1995     opts = qemu_opts_parse(&amp;qemu_drive_opts, optstr, NULL);
1996     if (!opts) {
1997         fprintf(stderr, "%s: huh? duplicate? (%s)\n",
1998                 __FUNCTION__, optstr);
1999         return NULL;
2000     }
2001     if (file)
2002         qemu_opt_set(opts, "file", file);
2003     return opts;
2004 }
</pre>
<p></code></p>
<p>- ศึกษา main(), main_loop(), main_loop_wait()<br />
<code>
<pre>
...
4207 static void main_loop(void)
4208 {
4209     int r;
4210
4211     if (kvm_enabled()) {
4212         kvm_main_loop();
4213         cpu_disable_ticks();
4214         return;
4215     }
4216
...

...
3954 void main_loop_wait(int timeout)
3955 {
3956     IOHandlerRecord *ioh;
3957     fd_set rfds, wfds, xfds;
3958     int ret, nfds;
3959     struct timeval tv;
3960
...
</pre>
<p></code></p>
<p>- main() เรียกใช้งาน main_loop()<br />
- main_loop() เรียกใช้งาน main_loop_wait()<br />
- ข้อสังเกต หาก Hardware รองรับ KVM ฟังก์ชัน main_loop() จะไปเรียก kvm_main_loop()</p>
<h2>Study the &#8220;bdrv_open()&#8221;</h2>
<p>- เปิดไฟล์ block.c<br />
- ทำการตรวจสอบฟังก์ชัน bdrv_open() แล้ว พบว่า มีการเรียกใช้ bdrv_open2()<br />
- ทำการแก้ไข bdrv_open2() โดยเพิ่ม printf เข้าไปในส่วนต้นและท้ายของฟังก์ชัน โดยแสดงค่า Sequence และ Filename สำหรับแยกแยะความแตกต่าง<br />
- ในภาพเป็นการแทรก printf ในส่วนต้นของฟังก์ชัน (บรรทัดที่ 359-362)<br />
<img alt="" src="http://a.imageshack.us/img693/4584/screenshotterminal10.png" title="Top of Function" class="alignnone" width="671" height="447" /></p>
<p>- ในภาพเป็นการแทรก printf ในส่วนท้ายของฟังก์ชัน (บรรทัดที่ 509-511)<br />
<img alt="" src="http://a.imageshack.us/img90/7133/screenshotterminal11.png" title="Bottom of Function" class="alignnone" width="671" height="447" /></p>
<p>- จากนั้นทำการ Compile และติดตั้ง เหมือนกับการบ้านที่ผ่านมา<br />
<code><strong>$</strong> <em>./configure --prefix=/opt/kvm-ex5</em><br />
<strong>$</strong> <em>make</em><br />
<strong>$</strong> <em>sudo make install</em></code></p>
<p>- เมื่อเรียกใช้ KVM โดยใช้ Disk centos_base.img พบว่ามีการเรียกฟังก์ชัน bdrv_open2() จำนวน 3 ครั้ง เป็นการอ่าน centos_base.img ทั้ง 3 ครั้ง<br />
- เมื่อเรียกใช้ KVM โดยใช้ Disk centos_ovl2.img พบว่ามีการเรียกฟังก์ชัน bdrv_open2() จำนวน 6 ครั้ง โดยอ่าน centos_base.img และ centos_ovl2.img อย่างละ 3 ครั้ง<br />
<img alt="" src="http://a.imageshack.us/img267/2747/screenshotterminal14.png" title="Call function" class="alignnone" width="671" height="447" /></p>
<p>- จากภาพ สังเกตเลข Sequence พบว่าเมื่อใช้ centos_base.img มีลำดับการเรียกฟังก์ชันดังนี้<br />
<code>
<pre>bdrv_open2(centos_base.img)
  `-bdrv_open2(centos_base.img)
  `-bdrv_open2(centos_base.img)
</pre>
<p></code></p>
<p>- และเมื่อใช้ centos_ovl2.img มีลำดับการเรียกใช้ฟังก์ชันดังนี้<br />
<code>
<pre>bdrv_open2(centos_ovl2.img)
  `-bdrv_open2(centos_ovl2.img)
  `-bdrv_open2(centos_ovl2.img)
  `-bdrv_open2(centos_base.img)
      `-bdrv_open2(centos_base.img)
      `-bdrv_open2(centos_base.img)
</pre>
<p></code></p>
<h2>Mirror Site</h2>
<p>- <a href="http://phithak.com/study-kvm-internal-1">http://phithak.com/study-kvm-internal-1</a><br />
- <a href="http://phithak.wordpress.com/2010/08/21/study-kvm-internal-1/">http://phithak.wordpress.com/2010/08/21/study-kvm-internal-1/</a></p>
<p>(ที่มา: การบ้าน หัวข้อ CS797 Exercise 5 &#8211; Study KVM internal 1 วิชา CS797 Advanced Topics in Computer Science &#8211; Introduction to Computer Virtualization ภาคเรียนที่ 1/2553 อาจารย์ผู้สอน <a style="text-decoration:none;" title="Dr.Kasidit Chanchio" href="http://kasiditchanchio.blogspot.com" target="_blank">ดร.กษิดิศ ชาญเชี่ยว</a> ภาควิชาวิทยาการคอมพิวเตอร์ คณะวิทยาศาสตร์และเทคโนโลยี มหาวิทยาลัยธรรมศาสตร์)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phithak.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phithak.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phithak.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phithak.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phithak.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phithak.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phithak.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phithak.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phithak.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phithak.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phithak.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phithak.wordpress.com/216/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phithak.wordpress.com/216/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phithak.wordpress.com/216/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phithak.wordpress.com&amp;blog=10487570&amp;post=216&amp;subd=phithak&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phithak.wordpress.com/2010/08/21/study-kvm-internal-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b8a8e09c8ce315fc2e6f6e5dfa7f45c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phithak</media:title>
		</media:content>

		<media:content url="http://a.imageshack.us/img693/4584/screenshotterminal10.png" medium="image">
			<media:title type="html">Top of Function</media:title>
		</media:content>

		<media:content url="http://a.imageshack.us/img90/7133/screenshotterminal11.png" medium="image">
			<media:title type="html">Bottom of Function</media:title>
		</media:content>

		<media:content url="http://a.imageshack.us/img267/2747/screenshotterminal14.png" medium="image">
			<media:title type="html">Call function</media:title>
		</media:content>
	</item>
		<item>
		<title>Cloud Computing using EUCALYPTUS and KVM on CentOS 5.4 (1)</title>
		<link>http://phithak.wordpress.com/2010/08/19/eucalyptus-and-kvm-on-centos-1/</link>
		<comments>http://phithak.wordpress.com/2010/08/19/eucalyptus-and-kvm-on-centos-1/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 10:55:30 +0000</pubDate>
		<dc:creator>phithak</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://phithak.wordpress.com/?p=235</guid>
		<description><![CDATA[__________________________ ( ) ( INTERNET ) (__________________________) &#124; &#124; &#124; &#124; &#124; eth0 172.22.5.20 +---+--------------------+ &#124; Front-end &#124; &#124; `- Cloud Controller &#124; &#124; - Cluster Controller &#124; +---+--------------------+ &#124; eth1 192.168.40.1 &#124; &#124; &#124; eth1,br1 192.168.40.2 +---+--------------------+ &#124; Compute node &#124; &#124; `- Node Controller &#124; &#124; &#124; +------------------------+ Problem - พบปัญหาเกี่ยวกับ VM ที่กำหนด [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phithak.wordpress.com&amp;blog=10487570&amp;post=235&amp;subd=phithak&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><code>
<pre> __________________________
(                          )
(        INTERNET          )
(__________________________)
    |
    |
    |
    |
    | eth0 172.22.5.20
+---+--------------------+
| Front-end              |
| `- Cloud Controller    |
|  - Cluster Controller  |
+---+--------------------+
    | eth1 192.168.40.1
    |
    |
    | eth1,br1 192.168.40.2
+---+--------------------+
| Compute node           |
| `- Node Controller     |
|                        |
+------------------------+</pre>
<p></code></p>
<h2>Problem</h2>
<p>- พบปัญหาเกี่ยวกับ VM ที่กำหนด Harddisk ให้เป็นแบบ SCSI<br />
- จะทำการทดลองอีกครั้ง กับ Linux ที่มี Kernel เวอร์ชันใหม่ ๆ (Ubuntu 10.04, Fedora 13, etc.)</p>
<h2>Mirror Site</h2>
<p>- <a href="http://phithak.com/eucalyptus-and-kvm-on-centos-1">http://phithak.com/eucalyptus-and-kvm-on-centos-1</a><br />
- <a href="http://phithak.wordpress.com/2010/08/19/eucalyptus-and-kvm-on-centos-1/">http://phithak.wordpress.com/2010/08/19/eucalyptus-and-kvm-on-centos-1/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phithak.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phithak.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phithak.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phithak.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phithak.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phithak.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phithak.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phithak.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phithak.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phithak.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phithak.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phithak.wordpress.com/235/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phithak.wordpress.com/235/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phithak.wordpress.com/235/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phithak.wordpress.com&amp;blog=10487570&amp;post=235&amp;subd=phithak&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phithak.wordpress.com/2010/08/19/eucalyptus-and-kvm-on-centos-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b8a8e09c8ce315fc2e6f6e5dfa7f45c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phithak</media:title>
		</media:content>
	</item>
		<item>
		<title>Compile and Install KVM on Linux (Improved)</title>
		<link>http://phithak.wordpress.com/2010/08/01/compile-and-install-kvm-on-linux-improve/</link>
		<comments>http://phithak.wordpress.com/2010/08/01/compile-and-install-kvm-on-linux-improve/#comments</comments>
		<pubDate>Sun, 01 Aug 2010 15:22:06 +0000</pubDate>
		<dc:creator>phithak</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://phithak.wordpress.com/?p=219</guid>
		<description><![CDATA[เนื่องจากการบ้าน CS797 Exercise 3 – Compile and Install KVM on your Ubuntu System เป็นการ Compile บน Linux ที่ติดตั้งใน VMware พบว่ามีข้อความ Error เกี่ยวกับ Hardware ที่ไม่รองรับ จึงทดลอง Compile อีกครั้ง โดย Compile บน Linux ที่ติดตั้งบน Laptop (BenQ S32W) พบว่าไม่มีข้อความ Error แล้ว รายละเอียด ดังนี้ Prerequisites - ทำเหมือน Compile and Install KVM on Linux หรือ Compile and Install KVM on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phithak.wordpress.com&amp;blog=10487570&amp;post=219&amp;subd=phithak&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>เนื่องจากการบ้าน CS797 Exercise 3 – Compile and Install KVM on your Ubuntu System เป็นการ Compile บน Linux ที่ติดตั้งใน VMware พบว่ามีข้อความ Error เกี่ยวกับ Hardware ที่ไม่รองรับ</p>
<p>จึงทดลอง Compile อีกครั้ง โดย Compile บน Linux ที่ติดตั้งบน Laptop (BenQ S32W) พบว่าไม่มีข้อความ Error แล้ว รายละเอียด ดังนี้<br />
<span id="more-219"></span></p>
<h3>Prerequisites</h3>
<p>- ทำเหมือน <a href="http://phithak.com/compile-and-install-kvm-on-linux">Compile and Install KVM on Linux</a> หรือ <a href="http://phithak.wordpress.com/2010/07/08/compile-and-install-kvm-on-linux/">Compile and Install KVM on Linux</a></p>
<p>- สิ่งที่ติดตั้งเพิ่มเติม<br />
<code><strong>$</strong> <em>sudo apt-get install uuid uuid-dev curl libcurl4-dev libaio-dev libbluetooth-dev libvdeplug2-dev texi2html perl</em></code></p>
<h3>Unpacking and Configuring</h3>
<h4>kvm-kmod</h4>
<p>- ดาวน์โหลดและติดตั้งเหมือนเดิม จนกระทั่งถึงขั้นตอน add module ให้กับ kernel<br />
<code><strong>$</strong> <em>sudo /sbin/modprobe kvm-intel</em></code> </p>
<p>- ผลที่ได้คือ ไม่มีข้อความ Error แล้ว<br />
<a href="http://a.imageshack.us/img837/1853/screenshotterminal1.png"><img class="alignnone" title="kvm-intel" src="http://a.imageshack.us/img837/1853/screenshotterminal1.png" alt="" width="671" height="209" /></a></p>
<h4>qemu-kvm</h4>
<p>- ดาวน์โหลดไฟล์เดิม &#8211; แก้ไขส่วนของ configure โดยเพิ่มให้ enable หลาย ๆ อย่าง<br />
<code><strong>$</strong> <em>./configure --prefix=/opt/kvm --enable-debug --enable-sdl --enable-curses --enable-kvm --enable-system --enable-system --enable-linux-user --enable-guest-base --with-kvm-trace --enable-uuid --enable-curl --enable-linux-aio <strong>--target-list=x86_64-softmmu,i386-softmmu</strong> --audio-drv-list=oss,alsa,sdl,esd,pa --audio-card-list=ac97,es1370,sb16,cs4231a,adlib,gus --enable-mixemu --enable-bluez --enable-vde</em></code></p>
<h3>Using KVM</h3>
<p>- ใช้งาน kvm ที่ได้จากการ Compile พบว่า ไม่มีข้อความ Error</p>
<h3><a href="http://a.imageshack.us/img837/1402/screenshotwv.png"><img class="alignnone" title="qemu" src="http://a.imageshack.us/img837/1617/screenshotez.png" alt="" width="640" height="400" /></a></h3>
<h3>Mirror Site</h3>
<p>- <a href="http://phithak.com/compile-and-install-kvm-on-linux-improve" target="_blank">http://phithak.com/compile-and-install-kvm-on-linux-improve</a><br />
- <a href="http://phithak.wordpress.com/2010/08/01/compile-and-install-kvm-on-linux-improve/" target="_blank">http://phithak.wordpress.com/2010/08/01/compile-and-install-kvm-on-linux-improve/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phithak.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phithak.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phithak.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phithak.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phithak.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phithak.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phithak.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phithak.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phithak.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phithak.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phithak.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phithak.wordpress.com/219/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phithak.wordpress.com/219/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phithak.wordpress.com/219/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phithak.wordpress.com&amp;blog=10487570&amp;post=219&amp;subd=phithak&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phithak.wordpress.com/2010/08/01/compile-and-install-kvm-on-linux-improve/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b8a8e09c8ce315fc2e6f6e5dfa7f45c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phithak</media:title>
		</media:content>

		<media:content url="http://a.imageshack.us/img837/1853/screenshotterminal1.png" medium="image">
			<media:title type="html">kvm-intel</media:title>
		</media:content>

		<media:content url="http://a.imageshack.us/img837/1617/screenshotez.png" medium="image">
			<media:title type="html">qemu</media:title>
		</media:content>
	</item>
		<item>
		<title>KVM Overlay Disk Image</title>
		<link>http://phithak.wordpress.com/2010/07/18/kvm-overlay-disk-image/</link>
		<comments>http://phithak.wordpress.com/2010/07/18/kvm-overlay-disk-image/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 17:47:01 +0000</pubDate>
		<dc:creator>phithak</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://phithak.wordpress.com/?p=187</guid>
		<description><![CDATA[+-------------------------+ &#124; Overlay Image 1 &#124; &#124; &#124; &#124; - Update to CentOS 5.5 &#124; +-------------------------+ &#124; - Update kernel &#124; &#124; Overlay Image 2 &#124; &#124; - Install web server &#124; &#124; &#124; &#124; - Add new user &#124; &#124; - Do nothing &#124; &#124; &#124; &#124; &#124; &#124; 167 MB after commit &#124; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phithak.wordpress.com&amp;blog=10487570&amp;post=187&amp;subd=phithak&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><code>
<pre>+-------------------------+
|     Overlay Image 1     |
|                         |
| - Update to CentOS 5.5  |     +-------------------------+
| - Update kernel         |     |     Overlay Image 2     |
| - Install web server    |     |                         |
| - Add new user          |     | - Do nothing            |
|                         |     |                         |
|   167 MB after commit   |     |         256 kB          |
+-------------------------+     +-------------------------+
                    ^                  ^
                    |                  |
                    |                  |
             +---------------------------------+
             |                                 |
             |           Base Image            |
             |                                 |
             |       (CentOS 5.4 i386)         |
             |                                 |
             |             680 MB              |
             |                                 |
             +---------------------------------+</pre>
<p></code><br />
ในตัวอย่างนี้ เป็นการทดลองสร้าง Overlay Disk Image 2 ตัว บน Base Image ที่ติดตั้ง CentOS 5.4 โดยที่ตัวที่ 1 มีการเปลี่ยนแปลงข้อมูลใน Disk (Update/Install Software, Add User) หลังจากทำการ Commit แล้วพบว่า Overlay Disk มีขนาดเพิ่มขึ้น ในขณะที่ตัวที่ 2 ไม่มีการเปลี่ยนแปลงข้อมูลใด ๆ พบว่ามีขนาดเท่าเดิม รายละเอียดการทดลองมีดังนี้<br />
<span id="more-187"></span></p>
<h2>PATH</h2>
<p>เพื่อความสะดวกในการพิมพ์คำสั่ง kvm ที่ได้จากการ compile ในการบ้านที่ 3 (cs797-ex3) จึงมีการกำหนดตัวแปร PATH โดยใช้คำสั่ง export</p>
<p><code><strong>$</strong> <em>export PATH=/opt/kvm/bin:$PATH</em></code></p>
<p><em><a href="http://img341.imageshack.us/img341/2930/screenshotphithakubuntu.png"><img class="alignnone" title="PATH" src="http://img341.imageshack.us/img341/2930/screenshotphithakubuntu.png" alt="" width="674" height="177" /></a><br />
</em></p>
<h2>Create Base Image</h2>
<p>สร้าง Disk Image สำหรับติดตั้ง Guest OS โดยกำหนดให้มีขนาด 2GB ในรูปแบบ qcow2</p>
<p><code><strong>$</strong> <em>qemu-img create -f qcow2 centos_base.img 2G</em></code></p>
<h2>Install Guest OS on Base Image</h2>
<p>ทำการติดตั้ง CentOS 5.4 ลงบน Base Image โดยมีขั้นตอนดังนี้</p>
<p>- ดาวน์โหลดไฟล์สำหรับติดตั้ง ในตัวอย่างนี้เป็นการติดตั้งผ่าน http<br />
<code><strong>$</strong> <em>wget http://mirror.issp.co.th/centos/5.4/isos/i386/CentOS-5.4-i386-netinstall.iso</em></code></p>
<p>- ทำการติดตั้ง OS โดยเรียกใช้คำสั่ง qemu-system-x86_64 (ติดตั้งแบบ Text Mode โดยการพิมพ์ linux text ที่ boot prompt)<br />
<code><strong>$</strong> <em>qemu-system-x86_64 -hda centos_base.img -cdrom CentOS-5.4-i386-netinstall.iso -boot d -m 256</em></code></p>
<p><em><a href="http://img832.imageshack.us/img832/7562/screenshotx.png"><img class="alignnone" title="Install Guest OS" src="http://img832.imageshack.us/img832/8664/screenshot.png" alt="" width="640" height="429" /></a></em></p>
<p>- ติดตั้งโดยไม่เลือกกลุ่มของซอฟต์แวร์ใด ๆ เลย เพื่อให้ Guest มีขนาดเล็ก</p>
<p><a href="http://img832.imageshack.us/img832/4860/screenshotqemu28.png"><img class="alignnone" title="Install Guest OS" src="http://img832.imageshack.us/img832/4860/screenshotqemu28.png" alt="" width="736" height="446" /></a></p>
<p>- ดำเนินการติดตั้งจนแล้วเสร็จ</p>
<p><a href="http://img827.imageshack.us/img827/4631/screenshotqemu35.png"><img class="alignnone" title="Install Guest OS" src="http://img827.imageshack.us/img827/4631/screenshotqemu35.png" alt="" width="736" height="446" /></a></p>
<p>- ทำการ Reboot</p>
<p><a href="http://img411.imageshack.us/img411/1840/screenshotqemu38.png"><img class="alignnone" title="Reboot Guest" src="http://img411.imageshack.us/img411/1840/screenshotqemu38.png" alt="" width="736" height="446" /></a></p>
<p>- ทำการตรวจสอบข้อมูลของ Guest (Release, Kernel Version, Disk Usage, etc.)</p>
<p><a href="http://img84.imageshack.us/img84/2629/screenshotqemu41.png"><img class="alignnone" title="Check Guest" src="http://img84.imageshack.us/img84/2629/screenshotqemu41.png" alt="" width="736" height="446" /></a></p>
<h2>Create Overlay Disk Image</h2>
<p>- สร้าง Overlay Disk Image ขึ้นมา 2 ตัว<br />
<code><strong>$</strong> <em>qemu-img create -f qcow2 -b centos_base.img centos_ovl1.img</em></code><br />
<code><strong>$</strong> <em>qemu-img create -f qcow2 -b centos_base.img centos_ovl2.img</em></code></p>
<p><em><a href="http://img837.imageshack.us/img837/2930/screenshotphithakubuntu.png"><img class="alignnone" title="Create Overlay Image" src="http://img837.imageshack.us/img837/2930/screenshotphithakubuntu.png" alt="" width="674" height="483" /></a><br />
</em></p>
<h2>Modify Guest OS on Overlay 1</h2>
<p>- เปิด Guest ขึ้นมาโดยใช้ Overalay 1 (Disk Image) ในคำสั่งเพิ่ม Option -snapshot ด้วย<br />
<code><strong>$</strong> <em>qemu-system-x86_64 -hda centos_ovl1.img -boot c -m 256 -snapshot</em></code></p>
<p><em><a href="http://img710.imageshack.us/img710/6007/screenshot1gy.png"><img class="alignnone" title="Overlay 1" src="http://img843.imageshack.us/img843/8027/screenshot1.png" alt="" width="640" height="429" /></a><br />
</em></p>
<p>- Install/Update ซอฟต์แวร์บน Guest<br />
<code><strong>$</strong> <em>yum update centos-release</em></code><br />
<code><strong>$</strong> <em>yum update kernel</em></code><br />
<code><strong>$</strong> <em>yum install httpd</em></code><br />
<code><strong>$</strong> <em>yum install finger</em></code></p>
<p><em><a href="http://img16.imageshack.us/img16/5553/screenshotqemu1b.png"><img class="alignnone" title="Update Release" src="http://img16.imageshack.us/img16/5553/screenshotqemu1b.png" alt="" width="736" height="446" /></a><br />
</em></p>
<p>- Add user ชื่อ phithak<br />
<code><strong>$</strong> <em>mkdir -p /home/users</em></code><br />
<code><strong>$</strong> <em>useradd -g users -c "Phithak Thaenkaew" -d /home/users/phithak phithak</em></code><br />
<code><strong>$</strong> <em>passwd phithak</em></code><br />
<code><strong>$</strong> <em>finger phithak</em></code></p>
<p><a href="http://img16.imageshack.us/img16/3981/screenshotqemu14.png"><img class="alignnone" title="Finger" src="http://img16.imageshack.us/img16/3981/screenshotqemu14.png" alt="" width="736" height="446" /></a></p>
<p>- เข้าสู่ Command Mode ด้วยการกดปุ่ม Ctrl + Alt + 2</p>
<p>- ทำการ Commit ด้วยคำสั่ง commit all เพื่อบันทึกความเปลี่ยนแปลงลงบน Overlay 1</p>
<p><a href="http://img687.imageshack.us/img687/7627/screenshotqemu17.png"><img class="alignnone" title="Commit" src="http://img687.imageshack.us/img687/7627/screenshotqemu17.png" alt="" width="656" height="430" /></a></p>
<p>- ปิด Guest ด้วยคำสั่ง quit ในหน้า Command Mode<br />
<code><strong>(qemu)</strong> <em>quit</em></code></p>
<h2>Guest OS on Overlay 2</h2>
<p>- เปิด Guest ขึ้นมาโดยใช้ Overalay 2 (Disk Image)<br />
<code><strong>$</strong> <em>qemu-system-x86_64 -hda centos_ovl2.img -boot c -m 256 -snapshot</em></code></p>
<p><em><a href="http://img594.imageshack.us/img594/421/screenshot5b.png"><img class="alignnone" title="Overlay 2" src="http://img594.imageshack.us/img594/8513/screenshot5q.png" alt="" width="640" height="429" /></a><br />
</em></p>
<p>- ตรวจสอบข้อมูลของ Guest พบว่า เหมือนกับที่ติดตั้งให้ Base Image โดยไม่ได้มีการ Update ใด ๆ ทั้งสิ้น</p>
<p><a href="http://img80.imageshack.us/img80/3084/screenshotqemu20.png"><img class="alignnone" title="Overlay 2" src="http://img80.imageshack.us/img80/3084/screenshotqemu20.png" alt="" width="736" height="446" /></a></p>
<p>- จากนั้น Shutdown</p>
<h2>Guest OS on Overlay 1 (Again)</h2>
<p>- เปิด Guest ขึ้นมา โดยใช้ Overlay 1 อีกครั้ง พบว่า Version ตอน Boot เป็น 5.5</p>
<p>- ตรวจสอบ Guest แล้วพบว่า ข้อมูลที่ได้ทำการ Update/Install ไว้ ยังอยู่ครบถ้วน</p>
<p><a href="http://img834.imageshack.us/img834/7587/screenshotqemu22.png"><img class="alignnone" title="Overlay 1 Again" src="http://img834.imageshack.us/img834/7587/screenshotqemu22.png" alt="" width="736" height="446" /></a></p>
<h2>Image Size</h2>
<p>- เปรียบเทียบขนาดของ Image ทั้งสาม (ก่อนและหลัง Commit) พบว่า Base Image มีขนาด 680 MB, Overlay 1 มีขนาดเพิ่มขึ้นเป็น 167 MB, Overlay 2 มีขนาด 256 KB เท่ากับตอนที่สร้าง</p>
<p><a href="http://img824.imageshack.us/img824/2930/screenshotphithakubuntu.png"><img class="alignnone" title="Image Size" src="http://img824.imageshack.us/img824/2930/screenshotphithakubuntu.png" alt="" width="674" height="483" /></a></p>
<p>(ที่มา: การบ้าน หัวข้อ CS797 Exercise 4 &#8211; Create a COW Overlay Disk and use QEMU&#8217;s commit command วิชา CS797 Advanced Topics in Computer Science &#8211; Introduction to Computer Virtualization ภาคเรียนที่ 1/2553 อาจารย์ผู้สอน <a style="text-decoration:none;" title="Dr.Kasidit Chanchio" href="http://kasiditchanchio.blogspot.com" target="_blank">ดร.กษิดิศ ชาญเชี่ยว</a> ภาควิชาวิทยาการคอมพิวเตอร์ คณะวิทยาศาสตร์และเทคโนโลยี มหาวิทยาลัยธรรมศาสตร์)</p>
<h2>References</h2>
<p>- <a href="http://wiki.qemu.org/download/qemu-doc.html" target="_blank">http://wiki.qemu.org/download/qemu-doc.html</a><br />
- <a href="http://www.h7.dion.ne.jp/~qemu-win/HowToFloppyCdrom-en.html" target="_blank">http://www.h7.dion.ne.jp/~qemu-win/HowToFloppyCdrom-en.html</a></p>
<h2>Mirror Site</h2>
<p>- <a href="http://phithak.com/kvm-overlay-disk-image" target="_blank">http://phithak.com/kvm-overlay-disk-image</a><br />
- <a href="http://phithak.wordpress.com/2010/07/18/kvm-overlay-disk-image/" target="_blank">http://phithak.wordpress.com/2010/07/18/kvm-overlay-disk-image/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phithak.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phithak.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phithak.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phithak.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phithak.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phithak.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phithak.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phithak.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phithak.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phithak.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phithak.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phithak.wordpress.com/187/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phithak.wordpress.com/187/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phithak.wordpress.com/187/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phithak.wordpress.com&amp;blog=10487570&amp;post=187&amp;subd=phithak&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phithak.wordpress.com/2010/07/18/kvm-overlay-disk-image/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b8a8e09c8ce315fc2e6f6e5dfa7f45c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phithak</media:title>
		</media:content>

		<media:content url="http://img341.imageshack.us/img341/2930/screenshotphithakubuntu.png" medium="image">
			<media:title type="html">PATH</media:title>
		</media:content>

		<media:content url="http://img832.imageshack.us/img832/8664/screenshot.png" medium="image">
			<media:title type="html">Install Guest OS</media:title>
		</media:content>

		<media:content url="http://img832.imageshack.us/img832/4860/screenshotqemu28.png" medium="image">
			<media:title type="html">Install Guest OS</media:title>
		</media:content>

		<media:content url="http://img827.imageshack.us/img827/4631/screenshotqemu35.png" medium="image">
			<media:title type="html">Install Guest OS</media:title>
		</media:content>

		<media:content url="http://img411.imageshack.us/img411/1840/screenshotqemu38.png" medium="image">
			<media:title type="html">Reboot Guest</media:title>
		</media:content>

		<media:content url="http://img84.imageshack.us/img84/2629/screenshotqemu41.png" medium="image">
			<media:title type="html">Check Guest</media:title>
		</media:content>

		<media:content url="http://img837.imageshack.us/img837/2930/screenshotphithakubuntu.png" medium="image">
			<media:title type="html">Create Overlay Image</media:title>
		</media:content>

		<media:content url="http://img843.imageshack.us/img843/8027/screenshot1.png" medium="image">
			<media:title type="html">Overlay 1</media:title>
		</media:content>

		<media:content url="http://img16.imageshack.us/img16/5553/screenshotqemu1b.png" medium="image">
			<media:title type="html">Update Release</media:title>
		</media:content>

		<media:content url="http://img16.imageshack.us/img16/3981/screenshotqemu14.png" medium="image">
			<media:title type="html">Finger</media:title>
		</media:content>

		<media:content url="http://img687.imageshack.us/img687/7627/screenshotqemu17.png" medium="image">
			<media:title type="html">Commit</media:title>
		</media:content>

		<media:content url="http://img594.imageshack.us/img594/8513/screenshot5q.png" medium="image">
			<media:title type="html">Overlay 2</media:title>
		</media:content>

		<media:content url="http://img80.imageshack.us/img80/3084/screenshotqemu20.png" medium="image">
			<media:title type="html">Overlay 2</media:title>
		</media:content>

		<media:content url="http://img834.imageshack.us/img834/7587/screenshotqemu22.png" medium="image">
			<media:title type="html">Overlay 1 Again</media:title>
		</media:content>

		<media:content url="http://img824.imageshack.us/img824/2930/screenshotphithakubuntu.png" medium="image">
			<media:title type="html">Image Size</media:title>
		</media:content>
	</item>
		<item>
		<title>Compile and Install KVM on Linux</title>
		<link>http://phithak.wordpress.com/2010/07/08/compile-and-install-kvm-on-linux/</link>
		<comments>http://phithak.wordpress.com/2010/07/08/compile-and-install-kvm-on-linux/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 10:11:36 +0000</pubDate>
		<dc:creator>phithak</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Compile]]></category>
		<category><![CDATA[CS797]]></category>
		<category><![CDATA[Damn Small Linux]]></category>
		<category><![CDATA[DSL]]></category>
		<category><![CDATA[KVM]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Thammasat]]></category>
		<category><![CDATA[Virtual Machine]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[VM]]></category>

		<guid isPermaLink="false">http://phithak.wordpress.com/?p=161</guid>
		<description><![CDATA[การ Compile และ Install KVM ลงบน Linux Ubuntu 10.04 มีขั้นตอนดังนี้ Prerequisites - ทำการ remove โปรแกรม kvm ที่เคยติดตั้งไปแล้ว (จากการบ้าน cs797-ex1) $ sudo apt-get remove qemu-kvm Reading package lists... Done Building dependency tree Reading state information... Done ... - ติดตั้งโปรแกรมที่จำเป็นสำหรับการ Compile $ sudo apt-get install gcc libsdl1.2-dev zlib1g-dev libasound2-dev linux-kernel-headers pkg-config libgnutls-dev libpci-dev - ตรวจสอบ Kernel Version [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phithak.wordpress.com&amp;blog=10487570&amp;post=161&amp;subd=phithak&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>การ Compile และ Install KVM ลงบน Linux Ubuntu 10.04 มีขั้นตอนดังนี้</p>
<h3>Prerequisites</h3>
<p>- ทำการ remove โปรแกรม kvm ที่เคยติดตั้งไปแล้ว (จากการบ้าน cs797-ex1)</p>
<p><code><strong>$</strong> <em>sudo apt-get remove qemu-kvm</em><br />
Reading package lists... Done<br />
Building dependency tree<br />
Reading state information... Done<br />
...</code></p>
<p>- ติดตั้งโปรแกรมที่จำเป็นสำหรับการ Compile</p>
<p><code><strong>$</strong> <em>sudo apt-get install gcc libsdl1.2-dev zlib1g-dev libasound2-dev linux-kernel-headers pkg-config libgnutls-dev libpci-dev</em></code><br />
<span id="more-161"></span><br />
- ตรวจสอบ Kernel Version ของ Ubuntu (พบ 2.6.32-23) เป็นข้อมูลไว้สำหรับเลือกดาวน์โหลด KVM ให้ตรงกับ Kernel</p>
<p><code><strong>$</strong> <em>uname -a</em><br />
Linux ubuntu 2.6.32-23-generic #37-Ubuntu SMP Fri Jun 11 07:54:58 UTC 2010 i686 GNU/Linux</code></p>
<h3>Unpacking and Configuring</h3>
<h4>kvm-kmod</h4>
<p>- ดาวน์โหลด kvm-kmod-2.6.32.12 จาก <a href="http://sourceforge.net/projects/kvm/files/" target="_blank">http://sourceforge.net/projects/kvm/files/</a> และทำการ extract</p>
<p><code><br />
<strong>$</strong> <em>bunzip2 kvm-kmod-2.6.32.12.tar.bz2</em><br />
<strong>$</strong> <em>tar xvf kvm-kmod-2.6.32.12.tar</em><br />
<strong>$</strong> <em>cd kvm-kmod-2.6.32.12</em><br />
</code></p>
<p>- Compile และ Install<br />
<code><strong>$</strong> <em>./configure</em><br />
<strong>$</strong> <em>make</em><br />
<strong>$</strong> <em>sudo make install</em></code></p>
<p>- ภาพตัวอย่าง</p>
<p><a href="http://img194.imageshack.us/img194/2930/screenshotphithakubuntu.png"><img class="alignnone" title="compile kvm-kmod" src="http://img194.imageshack.us/img194/2930/screenshotphithakubuntu.png" alt="" width="674" height="483" /></a></p>
<p>- ทำการ Reboot เครื่อง</p>
<p>- เปิด Terminal แล้วพิมพ์คำสั่ง เพื่อ add module ให้กับ kernel</p>
<pre><strong>$</strong> <em>sudo /sbin/modprobe kvm-intel</em></pre>
<p>- ปรากฏว่าพบ Error เกี่ยวกับ Hardware ที่ไม่รองรับ ซึ่งจะมองข้ามตรงนี้ไปก่อน</p>
<h4>qemu-kvm</h4>
<p>- ดาวน์โหลด qemu-kvm-0.12.4 จาก <a href="http://sourceforge.net/projects/kvm/files/" target="_blank">http://sourceforge.net/projects/kvm/files/</a> และทำการ extract</p>
<p><code><strong>$</strong> <em>tar xvfz qemu-kvm-0.12.4.tar.gz</em><br />
<strong>$</strong> <em>cd qemu-kvm-0.12.4</em></code></p>
<p>- Compile และ Install (ติดตั้งไว้ที่ /opt/kvm)<br />
<code><strong>$</strong> <em>./configure --prefix=/opt/kvm</em><br />
<strong>$</strong> <em>make</em><br />
<strong>$</strong> <em>sudo make install</em><br />
</code></p>
<p>- ภาพประกอบ<br />
<a href="http://img293.imageshack.us/img293/2930/screenshotphithakubuntu.png"><img class="alignnone" title="Compile Qemu-Kvm" src="http://img293.imageshack.us/img293/2930/screenshotphithakubuntu.png" alt="" width="674" height="483" /></a></p>
<h3>Creating a disk image for the guest</h3>
<p>- สร้าง disk image ด้วยคำสั่ง qemu-img ที่ได้จากการ compile โดยสร้างให้มีขนาด 3 GB ในรูปแบบของ qcow2<br />
<code><strong>$</strong> <em>/opt/kvm/bin/qemu-img create -f qcow2 hda.img 3G</em></code></p>
<p>- ภาพประกอบ</p>
<p><a href="http://img80.imageshack.us/img80/2930/screenshotphithakubuntu.png"><img class="alignnone" title="Create Disk Image" src="http://img80.imageshack.us/img80/2930/screenshotphithakubuntu.png" alt="" width="674" height="211" /></a></p>
<h3>Installing DSL (Damn Small Linux)</h3>
<p>- ดาวน์โหลด DSL จาก http://www.damnsmalllinux.org/download.html</p>
<p>- ติดตั้งลงบน disk image ที่สร้างไว้ (hda.img) โดยใช้ตัวติดตั้งจาก DSL iso ที่ดาวน์โหลดมา ใช้คำสั่งดังนี้<br />
<code><strong>$</strong> <em>/opt/kvm/bin/qemu-system-x86_64 -hda hda.img -cdrom dsl-4.4.10.iso -boot d -m 256</em></code></p>
<p>- ขั้นตอนการติดตั้ง สามารถดูได้ที่ <a href="http://phithak.com/install-damn-small-linux-dsl-in-qemu-vm" target="_blank">Install Damn Small Linux (DSL) in QEMU VM</a> หรือ <a href="http://phithak.wordpress.com/2010/01/23/install-damn-small-linux-dsl-in-qemu-vm/" target="_blank">Install Damn Small Linux (DSL) in QEMU VM</a><br />
- ภาพประกอบ (คลิกเพื่อดูภาพใหญ่)</p>
<p><a href="http://img149.imageshack.us/img149/5569/screenshotia.png"><img class="alignnone" title="Installing DSL" src="http://img149.imageshack.us/img149/930/screenshotwu.png" alt="" width="640" height="429" /></a></p>
<h3>Running DSL (Damn Small Linux)</h3>
<p>- หลังจากติดตั้งเสร็จแล้ว พิมพ์คำสั่งเพื่อใช้งาน DSL โดยกำหนดให้ boot จาก harddisk</p>
<p><code><strong>$</strong> <em>/opt/kvm/bin/qemu-system-x86_64 -hda hda.img -boot c -m 256</em></code></p>
<p>- ภาพประกอบ (คลิกเพื่อดูภาพใหญ่)</p>
<p><a href="http://img84.imageshack.us/img84/7985/screenshot7i.png"><img class="alignnone" title="Running DSL" src="http://img84.imageshack.us/img84/5641/screenshot7d.png" alt="" width="640" height="429" /></a></p>
<h3>References</h3>
<p>- <a title="KVM Howto" href="http://www.linux-kvm.org/page/HOWTO1" target="_blank">http://www.linux-kvm.org/page/HOWTO1</a></p>
<h3>Mirror Site</h3>
<p>- <a href="http://phithak.com/compile-and-install-kvm-on-linux" target="_blank">http://phithak.com/compile-and-install-kvm-on-linux</a></p>
<p>- <a href="http://phithak.wordpress.com/2010/07/08/compile-and-install-kvm-on-linux/" target="_blank">http://phithak.wordpress.com/2010/07/08/compile-and-install-kvm-on-linux/</a></p>
<p>(ที่มา: การบ้าน หัวข้อ CS797 Exercise 3 &#8211; Compile and Install KVM on your Ubuntu System วิชา CS797 Advanced Topics in Computer Science &#8211; Introduction to Computer Virtualization ภาคเรียนที่ 1/2553 อาจารย์ผู้สอน <a style="text-decoration:none;" title="Dr.Kasidit Chanchio" href="http://kasiditchanchio.blogspot.com" target="_blank">ดร.กษิดิศ ชาญเชี่ยว</a> ภาควิชาวิทยาการคอมพิวเตอร์ คณะวิทยาศาสตร์และเทคโนโลยี มหาวิทยาลัยธรรมศาสตร์)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phithak.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phithak.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phithak.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phithak.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phithak.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phithak.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phithak.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phithak.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phithak.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phithak.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phithak.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phithak.wordpress.com/161/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phithak.wordpress.com/161/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phithak.wordpress.com/161/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phithak.wordpress.com&amp;blog=10487570&amp;post=161&amp;subd=phithak&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phithak.wordpress.com/2010/07/08/compile-and-install-kvm-on-linux/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b8a8e09c8ce315fc2e6f6e5dfa7f45c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phithak</media:title>
		</media:content>

		<media:content url="http://img194.imageshack.us/img194/2930/screenshotphithakubuntu.png" medium="image">
			<media:title type="html">compile kvm-kmod</media:title>
		</media:content>

		<media:content url="http://img293.imageshack.us/img293/2930/screenshotphithakubuntu.png" medium="image">
			<media:title type="html">Compile Qemu-Kvm</media:title>
		</media:content>

		<media:content url="http://img80.imageshack.us/img80/2930/screenshotphithakubuntu.png" medium="image">
			<media:title type="html">Create Disk Image</media:title>
		</media:content>

		<media:content url="http://img149.imageshack.us/img149/930/screenshotwu.png" medium="image">
			<media:title type="html">Installing DSL</media:title>
		</media:content>

		<media:content url="http://img84.imageshack.us/img84/5641/screenshot7d.png" medium="image">
			<media:title type="html">Running DSL</media:title>
		</media:content>
	</item>
		<item>
		<title>Virtualization Concepts</title>
		<link>http://phithak.wordpress.com/2010/07/08/virtualization-concepts/</link>
		<comments>http://phithak.wordpress.com/2010/07/08/virtualization-concepts/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 09:08:14 +0000</pubDate>
		<dc:creator>phithak</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Virtual Machine]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[VM]]></category>

		<guid isPermaLink="false">http://phithak.wordpress.com/?p=150</guid>
		<description><![CDATA[1. Computer Virtualization คืออะไร ตามความเข้าใจของคุณ +------------------------+ &#124; &#124; &#124; Application A &#124; &#124; &#124; +------------------------+ +------------------------+ &#124; &#124; &#124; &#124; &#124; Application A &#124; &#124; Something Layer &#124; &#124; &#124; &#124; &#124; +------------------------+ +------------------------+ &#124; &#124; &#124; &#124; &#124; Architecture A &#124; &#124; Other Architecture &#124; &#124; &#124; &#124; &#124; +------------------------+ +------------------------+ Computer Virtualization คืออะไรบางอย่างที่ทำให้สามารถนำซอฟต์แวร์หนึ่ง [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phithak.wordpress.com&amp;blog=10487570&amp;post=150&amp;subd=phithak&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>1. Computer Virtualization คืออะไร ตามความเข้าใจของคุณ<br />
<code>
<pre>
                                  +------------------------+
                                  |                        |
                                  |     Application A      |
                                  |                        |
+------------------------+        +------------------------+
|                        |        |                        |
|     Application A      |        |     Something Layer    |
|                        |        |                        |
+------------------------+        +------------------------+
|                        |        |                        |
|     Architecture A     |        |   Other Architecture   |
|                        |        |                        |
+------------------------+        +------------------------+
</pre>
<p></code><br />
<span id="more-150"></span><br />
Computer Virtualization คืออะไรบางอย่างที่ทำให้สามารถนำซอฟต์แวร์หนึ่ง (ที่ไม่ได้ดัดแปลง) ไปใช้งานบนสถาปัตยกรรมต่าง ๆ ได้ โดยผู้ใช้ไม่รู้สึกถึงความแตกต่างของการทำงาน</p>
<p>
2. จงอธิบายประโยชน์และข้อเสียของ Virtualization ว่ามีอะไรบ้าง<br />
ข้อดี<br />
 &#8211; เพิ่ม Utilization<br />
 &#8211; มีคุณสมบัติ Sandboxing<br />
 &#8211; Multiple execution environments<br />
 &#8211; Virtual hardware<br />
 &#8211; Debugging/Testing<br />
 &#8211; Software migration (Mobility)<br />
ข้อเสีย<br />
 &#8211; Reduced Speed เนื่องจากเกิด Overhead<br />
 &#8211; Security เพิ่มเครื่อง = เพิ่มช่องโหว่<br />
 &#8211; ปัญหาลิขสิทธิ์</p>
<p>
3. Process Virtual Machine มีลักษณะอย่างไร<br />
เป็น Virtual Machine ในระดับ ABI เรียกอีกชื่อว่า Runtime System/Environment</p>
<p>
4. System Virtual Machine มีลักษณะอย่างไร<br />
เป็น Virtual Machine ในระดับ ISA สามารถจำลอง Hardware ต่าง ๆ ได้ สามารถจำลองเครื่องคอมพิวเตอร์หลาย ๆ เครื่องแยกกันได้</p>
<p>
5. Classic Virtual Machine Monitor (VMM) แตกต่างจาก Hosted Virtual Machine อย่างไร<br />
VMM คล้าย ๆ จะเป็น HostOS เอง จัดการทรัพยากรของเครื่องโดยตรง สำหรับ Hosted Virtual Machine จะเป็น Virtualization Software ที่รันอยู่บน HostOS</p>
<p>
6. จงอธิบายว่า Vitrualization Software ต่อไปนี้มีลักษณะอย่างไรและสร้าง Virtual Machine แบบไหน<br />
 &#8211; Xen เป็น System VM → VMM (Paravirtualization &amp; HW-assisted Virtualization)<br />
 &#8211; Hyper-V เป็น System VM → VMM (ของ Microsoft เดิมคือ Windows Server Virtualization)<br />
 &#8211; Vmware-ESX เป็น System VM → VMM<br />
 &#8211; Kernel-based Virtual Machine เป็น System VM → Hosted VM (ติดตั้งบน HostOS)<br />
 &#8211; OpenVZ เป็น System VM → Hosted VM (OS-level virtualization) Host &amp; Guest เป็น Linux</p>
<p></p>
<p>
(ที่มา: การบ้าน หัวข้อ CS797 Exercise 2 &#8211; Virtualization Concepts วิชา CS797 Advanced Topics in Computer Science &#8211; Introduction to Computer Virtualization ภาคเรียนที่ 1/2553 อาจารย์ผู้สอน <a style="text-decoration:none;" title="Dr.Kasidit Chanchio" href="http://kasiditchanchio.blogspot.com" target="_blank">ดร.กษิดิศ ชาญเชี่ยว</a> ภาควิชาวิทยาการคอมพิวเตอร์ คณะวิทยาศาสตร์และเทคโนโลยี มหาวิทยาลัยธรรมศาสตร์)
</p>
<p><h3>Mirror Site</h3>
<p>- <a href="http://phithak.com/virtualization-concepts" target="_blank">http://phithak.com/virtualization-concepts</a><br />
- <a href="http://phithak.wordpress.com/2010/07/08/virtualization-concepts/" target="_blank">http://phithak.wordpress.com/2010/07/08/virtualization-concepts/</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/phithak.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/phithak.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/phithak.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/phithak.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/phithak.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/phithak.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/phithak.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/phithak.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/phithak.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/phithak.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/phithak.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/phithak.wordpress.com/150/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/phithak.wordpress.com/150/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/phithak.wordpress.com/150/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=phithak.wordpress.com&amp;blog=10487570&amp;post=150&amp;subd=phithak&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://phithak.wordpress.com/2010/07/08/virtualization-concepts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b8a8e09c8ce315fc2e6f6e5dfa7f45c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">phithak</media:title>
		</media:content>
	</item>
	</channel>
</rss>
