Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Added networking section to manual
[palacios.git] / manual / manual.tex
1
2 \documentclass[11pt]{article}
3
4 \usepackage{calc}
5 \usepackage{graphics}
6 %\usepackage{latex8}
7 \usepackage{times}
8 \usepackage{epsf}
9 \usepackage{epsfig}
10 \usepackage{graphicx}
11 \usepackage{changebar}
12 \usepackage{portland}
13 \usepackage{lscape}
14
15 \setlength{\textheight}{8.50in}
16 \setlength{\textwidth}{6.5in}
17 \setlength{\topmargin}{-0.3in}
18 %\setlength{\leftmargin}{2.9in}
19 %\setlength{\rightmargin}{-2.9in}
20 \setlength{\oddsidemargin}{0in}
21 \setlength{\parindent}{0.5in}
22 \setlength\parindent{0in}
23 \setlength\parskip{0.1in} 
24
25 \newcommand{\note}[1]{{$\rightarrow$ \bf Note: \emph{#1}}}
26
27 \begin{document}
28
29 \title{
30 \includegraphics[height=1.5in]{v3vee.pdf}
31 \includegraphics[height=1.5in]{logo6.png} \\
32 \vspace{0.5in} 
33 Palacios Internal Developer Manual
34 }
35
36
37 \maketitle
38
39
40 This manual is written for Internal Palacios developers. It contains
41 information on how to obtain the palacios code base, how to go about
42 the development process, and how to commit those changes to the
43 mainline source tree.  This assumes that the reader has read {\em An
44 Introduction to the Palacios Virtual Machine Monitor -- Release 1.0}
45 and also has a slight working knowledge of {\em git}.
46
47
48 \section{Overview}
49
50
51 Both Palacios and Kitten follow a hybrid development process that
52 uses both the centralized repository and distributed development
53 models. A central repository exists that holds the master version of
54 the code base. This central repository is cloned by multiple people
55 and in multiple places to support various development efforts. A
56 feature of git is that every developer actually has a fully copy of
57 the entire repository, and so can function independently until such
58 time as they need to resync with the master version. 
59
60 There are typically multiple levels of access to the central
61 repository, that are granted based on the type of developer being
62 granted access. The three basic developer types and their access
63 privileges are:
64
65 \begin{itemize}
66 \item Core Developers: These are the lead developers and are in
67 charge of managing the master repository. They have full read/write
68 access permissions to the central repository.
69
70 \item Internal Developers: Formal members of the development
71 team. These people are capable of pulling directly from the central
72 repository, but lack the ability to write directly to it. 
73
74 \item External Developers: People who are not actual members of the
75 development team. These people can only access the public repository
76 which is only updated to contain the release versions. 
77 \end{itemize}
78
79 Because internal and external developers cannot write directly to the
80 master repository, they need to first submit their changes to a core
81 developer before they can be added to the mainline. We will discuss
82 that process in Section~\ref{sec:submission}.
83
84
85 \section{Checking out Palacios}
86 The central palacios repository is located on {\em
87 newskysaw.cs.northwestern.edu} in {\em /home/palacios/palacios}. All
88 internal developers have read access to the directory. Each developer
89 must create their own local version of the repository, this is done
90 with {\em git clone}.
91
92 \begin{verbatim}
93 git clone /home/palacios/palacios
94 \end{verbatim}
95
96 This creates a local copy of the repository at {\em ./palacios/}.
97
98
99 All development work is done in the {\em devel} branch of the
100 repository. The developer can access this branch via:
101
102 \begin{verbatim}
103 git checkout --track -b devel origin/devel
104 \end{verbatim}
105
106 or 
107
108 \begin{verbatim}
109 /opt/vmm-tools/bin/checkout_branch devel
110 \end{verbatim}
111
112 {\em Important:}
113 Note that palacios is very actively developed so the contents of the
114 {\em devel} branch are frequently changing. In order to keep up to
115 date with the latest version, it is necessary to periodically pull the
116 latest changes from the master repository by running \verb.git pull..
117
118
119
120 \section{Checking out Kitten}
121
122 Kitten is available from Sandia National Labs, and is the main host OS
123 we are targetting with Palacios. Loosely speaking core Palacios
124 developers are internal Kitten developers, and internal Palacios
125 developers are external Kitten developers. Because we have limited
126 access to the Kitten repository, we are maintaining a local mirror
127 copy in {\em /home/palacios/kitten}. 
128
129 Kitten uses Mercurial for their source management, so you will have to
130 make sure the local mercurial version is configured correctly.
131 Specifically you should add the following python path to your shell environment.
132
133 \begin{verbatim}
134 export PYTHONPATH=/usr/local/lib64/python2.4/site-packages/
135 \end{verbatim}
136
137 You can then clone Kitten from the local mirror:
138 \begin{verbatim}
139 hg clone /home/palacios/kitten
140 \end{verbatim}
141
142 Both the Kitten and Palacios clone commands should be run from the
143 same direcotyr. This means that both repositories should be located at
144 the same directory level. The Kitten build process depends on this.
145
146 {\em Important:} Like Palacios, Kitten is very actively developed so
147 source tree is frequently changing. In order to keep up to date with
148 the latest version, it is necessary to periodically pull the latest
149 changes from the mirror repository by running \verb.hg pull. followed
150 by \verb.hg update..
151
152 \section{Compiling Palacios}
153 Palacios is capable of targeting 32 and 64 bit operating systems, and
154 includes a build process that supports both these
155 architectures. Furthermore, Palacios has multiple build locations,
156 with multiple makefiles: a top level build directory and a Palacios
157 specific build directory. The Palacios build process first generates a
158 static library that includes the Palacios VMM. This static library is
159 then linked into a host operating system. Palacios internally supports
160 GeekOS and can generate a complete OS image via a unified build
161 process. To combine Palacios with Kitten, it is necessary to first
162 compile Palacios and then to compile Kitten externally link it with
163 Palacios. The output of the compilation process is a bit more complex
164 and generates multiple binaries, and the specifics can be found in the
165 Makefiles.
166
167 The top level build directory provides a number of high level make
168 targets, and is located in {\em palacios/build/}. It supports building
169 32 and 64 bit versions of the Palacios library independently as well
170 as building an integrated version of GeekOS.   The basic targets are:
171 \begin{itemize}
172 \item \verb.make palacios-full32. -- Generates a 32 bit version of the Palacios static library 
173 \item \verb.make palacios-full64. -- Generates a 64 bit version of the
174 Palacios static library
175 \item \verb.make geekos. -- Compiles the GeekOS kernel, and link it with the
176 Palacios static library 
177 \item \verb.make geekos-iso. -- Generate an ISO boot disk image from the
178 GeekOS kernel that has been compiled
179 \end{itemize}
180
181 The second build directory is located at {\em palacios/palacios/build}
182 and handles only the Palacios compilation process. It supports a
183 differnt set of targets and arguments:
184 \begin{itemize}
185 \item \verb.make ARCH=32. -- iteratively compiles a 32 bit version of Palacios
186 \item \verb.make ARCH=64. -- iteratively compiles a 64 bit version of
187 Palacios
188 \item \verb.make ARCH=32 world. -- fully recompiles a 32 bit version of
189 Palacios
190 \item \verb.make ARCH=64 world. -- fully recompiles a 64 bit version of
191 Palacios
192 \end{itemize}
193
194 Both build levels support compilation directives that control the
195 debugging messages that are generated by Palacios. These are specified
196 by appending a \verb.DEBUG_<COMPONENT>=1. to the end of the
197 \verb.make. command. The components that are currently supported are:
198 \begin{itemize}
199 \item \verb.DEBUG_ALL=1. -- enables debugging for all the VMM components
200 ({\em Warning:} this generates a {\em lot} of debug information.
201 \item \verb.DEBUG_SHADOW_PAGING=1.
202 \item \verb.DEBUG_CTRL_REGS=1.
203 \item \verb.DEBUG_INTERRUPTS=1.
204 \item \verb.DEBUG_IO=1.
205 \item \verb.DEBUG_KEYBOARD=1.
206 \item \verb.DEBUG_PIC=1.
207 \item \verb.DEBUG_PIT=1.
208 \item \verb.DEBUG_NVRAM=1.
209 \item \verb.DEBUG_GENERIC=1.
210 \item \verb.DEBUG_EMULATOR=1.
211 \item \verb.DEBUG_RAMDISK=1.
212 \item \verb.DEBUG_XED=1.
213 \item \verb.DEBUG_HALT=1.
214 \item \verb.DEBUG_DEV_MGR=1.
215 \item \verb.DEBUG_APIC=1.
216 \end{itemize}
217
218
219
220 \section{Compiling Kitten}
221 Kitten requires a 64 bit version of Palacios, so make sure that
222 Palacios has been correctly compiled before compiling Kitten.
223
224 \subsection{Configuration}
225 Kitten borrows a lot of concepts from Linux, including the Linux build
226 process. As such it must be configured before it is actually compiled.
227 The Kitten configuration process is the same as Linux, and can be
228 accessed via any of these make targets.
229 \begin{itemize}
230 \item \verb.make xconfig.
231 \item \verb.make config.
232 \item \verb.make menuconfig.
233 \end{itemize}
234
235 There are some specific configuration options that should be disabled
236 to work with Palacios. Because Palacios is configured by default to
237 provide a guest with direct access to the VGA console, the {\em VGA
238 console} device driver should be disbabled in the Kitten
239 configuration. Similarly the {\em VM console} driver should be
240 disabled as well.
241
242 Furthermore, because the VGA console is not being used the {\em Kernel
243 Command Line Arguments} must be modified to remove the {\em VGA}
244 device from the console list.
245
246 The guest OS that is booted as a VM is included as an ISO image in raw
247 binary format inside Kitten's {\em init\_task}. To change the guest
248 ISO, you must change the makefile for the init\_task. This is located
249 in {\em user/hello\_world/Makefile} and the syntax is well commented.
250 On {\em newskysaw} a collection of guest ISO images are located in
251 {\em /opt/vmm-tools/isos/}. 
252
253
254 \subsection{Compilation}
255 After Kitten has been configured the compilation can be done. The
256 general process is to compile a reference build of Kitten, followed by
257 compiling Palacios support as a kernel module, and then doing a new
258 full recompilation of Kitten.
259
260 The specific compilation steps are run from the top level Kitten directory:
261 \begin{verbatim}
262 make
263 cd palacios
264 make -C .. M=`pwd`
265 cp built-in.o ../modules/palacios-mod.o
266 cd ..
267 make
268 make isoimage
269 \end{verbatim}
270
271 \note{This should probably explain how to change the iso (helloworld,etc)}
272
273 This generates an ISO boot image containing Kitten, Palacios, and the
274 guest that will be run as a VM. The ISO image is located at {\em
275 ./arch/x86\_64/boot/image.iso}.
276
277
278 \section{Running Palacios/Kitten}
279 Kitten and Palacios are capable of running under Qemu, which makes
280 debugging much simpler.
281
282 The basic form of the command to start the Qemu emulator is:
283 \begin{verbatim}
284 /usr/local/qemu/bin/qemu-system-x86_64 -smp 1 -m 1024 \
285         -serial file:./serial.out \
286         -cdrom ./arch/x86_64/boot/image.iso  \
287         < /dev/null
288 \end{verbatim}
289
290 The command starts up a single processor emulated machine, with 1gig
291 of RAM and a cdrom drive loaded with the Kitten ISO image. Furthermore
292 all output to the serial port is written directly to a file called
293 {\em serial.out}. This command can be copied into a shell script for easy access.
294
295 \section{Development Guidelines}
296
297 There are standard requirements we have for code entering the mainline. 
298
299 First and foremost, Palacios is designed to be OS indenpendent and
300 support 32 and 64 bit architectures. This means that developers should
301 not include any external OS specific dependencies in any Palacios
302 component. Also all changes need to be tested on both 32 and 64 bit
303 architectures to make sure that they compile as well as run corrrectly.
304
305 \paragraph*{Coding Style}
306
307 "The use of equal negative space, as a balance to positive space, in a
308 composition is considered by many as good design. This basic and often
309 overlooked principle of design gives the eye a "place to rest,"
310 increasing the appeal of a composition through subtle means."
311 \newline\newline
312 Translation: Use the spacebar, newlines, and parentheses. 
313 \newline\newline
314 {\em Bad}
315 \begin{verbatim}
316 if(a&&b==5||c!=0){return;}
317 \end{verbatim}
318
319
320 {\em Good}
321
322 \begin{verbatim}
323 if (((a) && (b == 5)) || 
324     (c != 0)) {
325        return;
326 }
327 \end{verbatim}
328
329 \paragraph*{Fail Stop}
330 Because booting a basic linux kernel results in over 1 million VM exits
331 catching silent errors is next to impossible. For this reason
332 ANY time your code has an error it should return -1, and expect the
333 execution to halt. 
334
335 This includes unimplemented features and unhandled cases. These cases
336 should ALWAYS return -1. 
337
338
339 \paragraph*{Function names}
340 Externally visible function names should be used rarely and have
341 unique names. Currently we have several techniques for achieving this:
342
343 \begin{enumerate}
344 \item \verb.#ifdefs. in the header file
345 \newline
346 When the V3 Hypervisor is compiled it defines the symbol
347 \verb.__V3VEE__. Any function that is not needed outside the Hypervisor
348 context should be inside an \verb.#ifdef __V3VEE__. block, this will make it
349 invisible to the host environment.
350
351 \item Static Functions
352 \newline
353 Any utility functions that are only needed in the .c file where they
354 are defined should be declared as static and not included in the
355 header file. You should make an effort to use static functions
356 whenever possible. 
357
358 \item \verb.v3_. prefix
359 \newline
360 Major interface functions should be named with the prefix \verb.v3_. This
361 allows easy understanding of how to interact with the subsystems. And
362 in the case that they need to be externally visible to the host os,
363 make them unlikely to collide with other functions. 
364 \end{enumerate}
365
366 \paragraph*{Debugging Output}
367 Debugging output is sent through the host os via functions in the
368 \verb.os_hooks. structure. These functions have various wrappers of the form
369 \verb.Print*., with printf style semantics. 
370
371 Two functions of note are \verb.PrintDebug. and \verb.PrintError..
372
373 \begin{itemize}
374
375 \item PrintDebug:
376 \newline
377 Should be used for debugging output that will often be
378 turned off selectively by the VMM configuration. 
379
380 \item PrintError
381 \newline
382 Should be used when an error occurs, this will never be optimized out
383 and will always print. 
384 \end{itemize}
385
386
387 \section{Code Submission}
388 \label{sec:submission}
389
390 To commit changes to the central repository they need to be exported
391 as a patch set that can be applied directly to a mainline. Both Git
392 and Mercurial contain functionality to allow developers to maintain
393 changes as a patch set. There are also a few options that make dealing
394 with patches easier.
395
396 \subsection{Palacios}
397
398 Git includes support for directly exporting local repository commits
399 as a patch set. The basic operation is for a developer to commit a
400 change to a local repository, and then export that change as a patch
401 that can be applied to another git repository. While this is
402 functionally possible, there are a number of issues. The main problem
403 is that it is difficult to fully encapsulate a new feature in a single
404 commit, and dealing with multiple patches that often overwrite each
405 other is not a viable option either. Furthermore, once a patch is
406 applied to the mainline, it will generate a conflicting commit that
407 will become present when the developer next pulls from the central
408 repository. This can result in both repositories getting out of
409 sync. It is possible to deal with this by manually rebasing the local
410 repository, but it is difficult and error-prone. 
411
412 This approach also does not map well when patches are being revised. A
413 normal patch will go through multiple revisions as it is reviewed and
414 modified by others. This often leads to synchronization issues as well
415 as errors with patch revisions. Ultimately it is the responsibility of
416 the developer to generate a patch that will apply cleanly to the
417 mainline.
418
419 For this reason most internal developers should seriously consider
420 {\em stacked git}. Stacked git is designed to make patch development
421 easier and less of a headache. The basic mode of operation is for a
422 developer to intialize a patch for a new feature and then continuously
423 apply changes to the patch. Stacked Git allows a developer to layer a
424 series of patches on top of a local git repository, without causing
425 the repository to unsync due to local commits. Basically, the
426 developer never commits changes to the repository itself but instead
427 commits the changes to a specific patch. The local patches are managed
428 using stack operations (push/pop) which allows a developer to apply
429 and unapply patches as needed. Stacked git also manages new changes to
430 the underlying git repository as a result of a pull operation and
431 prevents collisions as changes are propagated upstream. For instance
432 if you have a local patch that is applied to the mainline as a commit,
433 when the commit is pulled down the patch becomes empty because it is
434 effectively identical to the mainline. It also makes incorporating
435 external revisions to a patch easier. Stacked git is installed on {\em
436 newskysaw} in \verb./opt/vmm-tools/bin/. 
437
438 Brief command overview:
439 \begin{itemize}
440 \item \verb.stg init. -- Initialize stacked git in a given branch
441 \item \verb.stg new. -- create a new patch set, an editor will open
442 asking for a commit message that will be used when the patch is
443 ultimately committed.
444 \item \verb.stg pop. -- pops a patch off of the source tree.
445 \item \verb.stg push. -- pushes a patch back on to a source tree.
446 \item \verb.stg export. -- exports a patch to a directory as a file
447 that can then be emailed.
448 \item \verb.stg refresh. -- commits local changes to the patch set at
449 the top of the applied stack.
450 \item \verb.stg fold. -- Apply a patch file to the current
451 patch. (This is how you can manage revisions that are made by other developers).
452 \end{itemize}
453
454 You should definately look at the online documentation to better
455 understand how stacked git works. It is not required of course, but if
456 you want your changes to be applied its up to you to generate a patch
457 that is acceptable to a core developer. Ultimately using Stacked git
458 should be easier than going it alone.
459
460
461 All patches should be emailed to Jack for inclusion in the
462 mainline. An overview of the organization is given in
463 Figure~\ref{fig:process}. You should assume that the first revision of
464 a patch will not be accepted, and that you will have to make
465 changes. Furthermore, the final form of the patch most likely will not
466 be exactly what you submitted. 
467
468  
469 \begin{figure}[t]
470 \begin{center}
471 \includegraphics[height=3.5in]{dev_chart.pdf}
472 \end{center}
473 \caption{Development organization}
474 \label{fig:process}
475 \end{figure}
476
477
478 \subsection{Kitten}
479
480 Writing code for Kitten follows essentially the same process as
481 Palacios. The difference is that the patches need to be emailed to the
482 Kitten developers. To send in a patch, you can just email it to the
483 V3Vee development list.
484
485
486 Also, instead of Stacked git you should use Mercurial patch
487 queues. This feature is enabled in your .hgrc file.
488 \begin{verbatim}
489 [extensions]
490 hgext.mq=
491 \end{verbatim}
492
493 Mercurial queues use the same stack operations as stacked git, however
494 does not automatically handle the synchronization with pull
495 operations. Before you update from the central version of Kitten you
496 need to pop all of the patches, and then push them once the update is
497 complete.
498
499 Basically:
500 \begin{verbatim}
501 hg qpop -a
502 hg pull
503 hg update
504 hg qupush -a
505 \end{verbatim}
506
507
508 %Also, remember that Kitten is not a Northwestern project and is being
509 %developed by professional developers at Sandia National Labs. So keep
510 %in mind that you are representing Northwestern and the rest of the
511 %Palacios development group. We are collaborating with them because
512 %Kitten and the resources they have are very important for our research
513 %efforts. They are collaborating with us because they believe that
514 %Palacios might be able to help them. Therefore it is important that we
515 %continue to ensure that they see value in our collaboration. In plain
516 %terms, we need to make sure they think we're smart and know what we're
517 %doing. So please keep that in mind when dealing with the Kitten group.
518
519
520 \section{Networking}
521
522 Both the Kitten and GeekOS substrates on which Palacios can run
523 currently include drivers for two simple network cards, the NE2000,
524 and the RTL8139.  The Kitten substrate is acquiring an ever increasing
525 set of drivers for specialized network systems.   A lightweight
526 networking stack is included so that TCP/IP networking is possible
527 from within the host OS kernel and in Palacios.  
528
529 When debugging Palacios on QEMU, it is very convenient to add an
530 RTL8139 card to your QEMU configuration, and then drive it from within
531 Palacios.  QEMU can be configured to provide local connectivity to the
532 QEMU emulated machine, including bridging the emulated machine with a
533 physical network.  Local connectivity can be done with redirection, or
534 with a TAP interface.  For global connectivity, a TAP interface must
535 be used; it is bridged to a physical interface.
536
537 \section{Configuring the development host's QEMU network}
538
539 To get local connectivity with redirection, no networking changes on
540 the host are needed.  However, people usually want to use TAP-based
541 networking, which does require changes.  For one thing, TAP interfaces
542 can be inspected with tools like wireshark, which makes for much
543 easier debugging of network code.
544
545 In order to get QEMU networking to function, it is necessary to create
546 TAP interfaces, and, optionally, to bridge them to real networks.  A
547 developmet machine typically will have several TAP interfaces, and
548 more can be created.  Generally, each developer should have a TAP
549 interface of his or her own.  In the following, we will use our
550 development machine, newskysaw, as an example.
551
552 To set up a TAP interface on newskysaw, the following comand is used:
553 \begin{verbatim}
554 /root/util/tap_create tapX
555 \end{verbatim}
556
557 When QEMU runs with a tap interface, it will use /etc/qemu-ifup to
558 bring up the interface.  On newskysaw, /etc/qemu-ifup looks like this:
559
560 \begin{verbatim}
561 #!/bin/bash
562 echo "Executing /etc/qemu-ifup - no external bridging"
563 echo "Bringing up $1 for bridged mode..."
564 NET=`echo $1 | cut -dp -f2` 
565 sudo /sbin/ifconfig $1 172.2${NET}.0.1 up
566 sleep 2
567 \end{verbatim}
568
569 The interface tap$N$ is brought up with the IP address 172.2$N$.0.1.
570 ifconfig will also create a routing rule that sends 172.2$N$.0.1/16
571 traffic to tap$N$.  The upshot is that if the code running in QEMU
572 uses an IP address in this network (for example: 172.2$N$.0.2), you
573 will be able to talk to it from newskysaw.  For example, from
574 newskysaw, if you ping 172.21.0.2, the packet (and ARP) will go out via
575 tap1.  The source address will appear to be 172.21.0.1.  The QEMU
576 machine will see these packets on its interface, and the software
577 controling its interface can respond to 172.21.0.1.  
578
579 This form of networking is local to the machine.  You can also bridge
580 a TAP interface with a physical interface.  The result of this is that
581 a packet sent on it will be sent on the physical interface.  To do
582 this requires more effort (and is not set up by default on newskysaw).
583 As an example, consider that on newskysaw, the physical interface eth1
584 is connected to a private network switch to which the lab test
585 computers (v-test-amd, v-test-amd2, etc.) are connected.  To bridge,
586 for example, tap10, to this interface, you would do the following
587 (with root's help):
588 \begin{enumerate}
589 \item You need to bring up eth1 (ifup eth1)
590 \item You would bring up tap10 without an address:  /sbin/ifconfig
591 tap10 up
592 \item You would bridge tap10 and eth1:  /usr/sbin/brctl addif br0
593 tap10; /usr/sbin/brctl addif eth1.  This assumes that br0 was
594 previously created. 
595 \end{enumerate}
596
597 Bridging tap$N$ with eth1 will only work (where ``work'' means sending
598 a packet on the network and making the packet visible on localhost) if
599 the IP address in the code running in QEMU is set correctly.  This
600 means that it needs to be set to correspond to the network of eth1).  
601 For the newskysaw configuration, this is a 10-net address.
602
603
604 \subsection{Configuring Kitten}
605
606 To enable networking in Qemu, networking needs to be enabled in the
607 configuration.
608
609 Make sure turn on the network device driver, networking, and input
610 kernel command 'console=serial net=rtl8139'
611
612 How to set ip address in kitten:
613
614 Kitten ip address setting is in file drivers/net/ne2k/rtl8139.c, in
615 the code below which is located in function rtl8139\_init.
616
617   struct ip\_addr ipaddr = { htonl(0 | 10 << 24 | 0 << 16 | 2 << 8 | 16 << 0) }; 
618   struct ip\_addr netmask = { htonl(0xffffff00) }; 
619   struct ip\_addr gw = { htonl(0 | 10 << 24 | 0 << 16 | 2 << 8 | 2 << 0) };
620
621 This sets the ip address as 10.0.2.16, netmask 255.255.255.0 and gateway address 10.0.2.2, change it as you need.
622
623
624 \subsection{Running with networking}
625
626 \paragraph*{TAP Interface}
627 Running with a TAP interface provides either local or global
628 connectivity (depending on how the TAP interface is configured and/or
629 bridged).  From the perspective of the QEMU command line, both look
630 the same, however.  You simply add something like this to the command
631 line:
632 \begin{verbatim}
633 -net tap,ifname=tap2 -net nic,model=rtl8139
634 \end{verbatim}
635 The first \verb.-net. option indicates that you want to use a tap
636 interface, specifically \verb.tap2..   The second \verb.-net. option
637 specifies that this interface will appear to code in the QEMU machine
638 to be a network interface card of the specific model RTL8139.  Note
639 that this is a model for which we have a driver.  If tap2 were
640 bridged, we'd get global connectivity.  If not, we would just get
641 local connectivity.  
642
643
644 \paragraph*{Redirection}
645 It is also possible to achieve limited local connectivity even if you
646 have no TAP support on your development machine.  In redirection, QEMU
647 essentially acts as a proxy, translating TCP or other connections and
648 low-level packet operations on the network interface in the QEMU
649 machine.  For example, the following options will redirect the host's
650 9555 port to the QEMU machine's 80 port:
651 \begin{verbatim}
652 -net user -net nic,model=rtl8139  -redir tcp:9555:10.10.10.33:80
653 \end{verbatim}
654 The first \verb.-net. option indicates that we are using user-level
655 networking (proxying).  The secod \verb.-net. option indicates that
656 this user-level network will appear in the QEMU machine as an RTL8139
657 network card.   The \verb.-redir. option indicates that connections on
658 localhost:9555 will be translated into equivalent packet exchanges on
659 the RTL8139 card in the QEMU machine.  However, we have to tell QEMU
660 which IP address and port to use on the QEMU machine's side.  This is
661 what the 10.10.10.33 address, and port 80 are.  In the example, if you
662 access port 9555 on localhost, say with:
663 \begin{verbatim}
664 telnet localhost 9555
665 \end{verbatim}
666 The packets that appear in the QEMU machine will be bound for
667 10.10.10.33, port 80.  Within the QEMU machine, your RTL8139 interface
668 had better then be up on that address. 
669
670 Qemu has many options to build up a virtual or real networking. See
671 http://www.h7.dion.ne.jp/$\sim$qemu-win/HowToNetwork-en.html for more
672 information.
673
674
675 For more questions, talk to Jack, Lei, or Peter.
676
677 \end{document}