This is not really what I sent you.  This is again all kinds of magic
that most people don't need.  The thing I sent you was a quick cut and
paste this and it works; you are adding all kinds of decision points
which implies a whole lot of reading and again getting stuck in the same
places that we get stuck now.  Not everyone uses qemu in complex setups;
I just use it to reboot a lot and all the fancy stuff is just a waste of
time.  In fact I think this README is equally useful as the man page;
have to read it all and then consult man for it to make sense.

FWIW

On Wed, Feb 11, 2009 at 04:56:05PM -0600, Todd T. Fries wrote:
> Could anyone explain why one would want to do '-no-fd-bootchk' ?  I mean
> it is there, but what reason would one want to put it on the cmdline?
> 
> In any event, here's my integration of your suggestions below with
> what exists already.
> 
> Index: README.OpenBSD
> ===================================================================
> RCS file: /cvs/ports/emulators/qemu/files/README.OpenBSD,v
> retrieving revision 1.3
> diff -u -r1.3 README.OpenBSD
> --- README.OpenBSD    11 Dec 2008 09:17:33 -0000      1.3
> +++ README.OpenBSD    11 Feb 2009 22:55:31 -0000
> @@ -3,15 +3,37 @@
>  
>  ==> Quick Start
>  
> -1. get a bootable floppy image
> -2. qemu-img create -f qcow2 virtual.hd 10G
> -3. qemu -m 32 -fda floppy.fs -boot a -monitor stdio virtual.hd
> -     (initial install to hard drive)
> -4. qemu-img convert -c -O qcow2 virtual.hd tmp && mv tmp virtual.hd
> -     (compress hard drive while qemu is not running)
> -5. qemu -m 32 -monitor stdio virtual.hd
> -     (normal boot from hard drive)
> +NOTE: amd64 cannot use '-net user' without SEGV'ing, to work around
> +      this, either run qemu as root by replacing
> +     qemu -m 32 ..
> +      in this quick start section with
> +         sudo env ETHER=em0 qemu -net nic,model=rtl8139 -net tap -m 32 ..
> +      or by reading the 'tap mode' section below.
>  
> +1. Get a bootable CDROM image
> +
> +    $ ftp ftp://ftp.openbsd.org/pub/OpenBSD/snapshots/i386/cd45.iso
> +
> +2. Create a virtual disk image:
> +
> +    $ qemu-img create -f qcow2 virtual.img 10G
> +
> +3. Install the os:
> +
> +    $ qemu -m 32 -monitor stdio -hda virtual.img -cdrom cd45.iso -boot d
> +
> +   NOTE: start this inside an xterm or equivalent
> +   NOTE: be sure to choose serial console during install
> +
> +4. Compress the virtual disk:
> +
> +    $ qemu-img convert -c -O qcow2 virtual.img v.tmp && mv v.tmp virtual.img
> +
> +   NOTE: do not do this while qemu is running / using this virtual disk
> +
> +5. Boot normally from the virtual disk:
> +
> +    $ qemu -m 32 -nographic -hda virtual.img 
>  
>  ==> Networking
>  
> @@ -34,13 +56,12 @@
>    makes userland network calls for tcp/udp operations. icmp and other things
>    are not possible in this mode.
>  
> -  Note: If you use one '-net' cmdline argument, qemu assumes you know what 
> you
> -  want and clears defaults for the rest of the -net defaults.
> -
> -  Note: The guest mode networking does not currently support IPv6, and
> -  qemu will complain that it cannot find a dns server if /etc/resolv.conf
> -  contains only IPv6 dns servers.
> +  NOTE: If you use one '-net' cmdline argument, qemu assumes you know what 
> you
> +     want and clears defaults for the rest of the -net defaults.
>  
> +  NOTE: The guest mode networking does not currently support IPv6, and
> +     qemu will complain that it cannot find a dns server if
> +     /etc/resolv.conf contains only IPv6 dns servers.
>  
>  2.  tap mode
>  
> @@ -66,7 +87,15 @@
>    tunnel device and then use sudo again to drop privileges and start qemu:
>  
>         $ sudo sh -c "sudo -u $USER qemu -nographic -net nic -net tap,fd=3 \
> -             virtual.hd 3<>/dev/tun0"
> +             virtual.img 3<>/dev/tun0"
> +
> +  NOTE: sudo calls closefrom(2).  In order to have more than one fd passed
> +     tap interface, a line to sudoers akin to:
> +
> +             Defaults closefrom_override
> +
> +        then calling sudo via 'sudo -C 5 -u $USER qemu ..' is required.
> +     See sudoers(5) and sudo(8) for details.
>  
>    An alternative to the procedure described above is to have qemu set up the
>    network via ${SYSCONFDIR}/qemu-ifup. This is not recommended however, since
> @@ -76,7 +105,7 @@
>    ${SYSCONFDIR}/qemu-ifup contains some default settings that permit one to 
> do
>    the following:
>  
> -     # qemu -net nic -net tap virtual.hd
> +     # qemu -net nic -net tap virtual.img
>  
>    It presumes you have a 'trunk0' interface you wish the tun(4) interface to
>    talk to.  It presumes you want 'bridge0' to be used to bridge the two.
> @@ -100,7 +129,7 @@
>     # export BRIDGE=bridge101
>     # qemu -net nic,vlan=0,model=rtl8139,macaddr=52:54:00:12:35:00 \
>       -net tap,vlan=0 -vnc :0 -localtime -usb -usbdevice tablet \
> -     -m 256 -hda virtual.hd -monitor stdio
> +     -m 256 -hda virtual.img -monitor stdio
>     {tun0 (bridge101 <-> trunk101)brconfig: bridge101: No such process
>     brconfig: bridge101: No such process
>     }
> @@ -119,15 +148,16 @@
>                  port 6 ifpriority 0 ifcost 0
>          Addresses (max cache: 100, timeout: 240):
>  
> -  Note: when running multiple qemu sessions simultaneously on the same 
> bridge,
> -  care must be taken because the network mac address defaults
> -  to 52:54:00:12:34:56 for every qemu instance.  To change this, observe
> -  the macaddr= syntax in the above example.
> +  NOTE: When running multiple qemu sessions simultaneously on the same 
> bridge,
> +     care must be taken because the network mac address defaults to
> +     52:54:00:12:34:56 for every qemu instance.  To change this, observe
> +     the macaddr= syntax in the above example and choose a unique lladdr
> +     per qemu nic.
>  
>  ==> Mice
>  
> -  Note: Certain m$ os's work so much better with the tablet usb device than
> -  the normal ps2 mouse handling.  See the above example for usage.
> +  NOTE: Certain OS's work much better with the tablet usb device than
> +     the normal ps2 mouse handling.  See the above example for usage.
>  
>  ==> Serial Console
>  
> @@ -135,14 +165,14 @@
>       be available, and so on.  There are two ways to accomplish this, both in
>       effect the same solution:
>  
> -    a. qemu -vnc :0 -serial stdio .. virtual.hd -cdrom install43.iso -boot d
> +    a. qemu -vnc :0 -serial stdio .. virtual.img -cdrom install43.iso -boot d
>  
>       - this option permits you to use vnc from some system to connect to
>         the qemu instance and 'set tty com0' at the 'boot>' prompt.
>       - you may then disconnect vnc and use the terminal from which you
>         started qemu to do the install
>  
> -    b. qemu -nographic .. virtual.hd -fda floppy43.fs -boot a
> +    b. qemu -nographic .. virtual.img -fda floppy45.fs -boot a
>  
>       - this maps both the serial port and the (qemu) monitor prompt to
>         the terminal qemu was started on
> @@ -151,7 +181,7 @@
>       - preparation of the floppy image to force serial console mode is
>         straightforward:
>  
> -             vnconfig svnd0 floppy43.fs
> +             vnconfig svnd0 floppy45.fs
>               mount /dev/svnd0c /mnt
>               mkdir /mnt/etc
>               echo set tty com0 > /mnt/etc/boot.conf
> @@ -160,12 +190,13 @@
>  
>       .. be sure to choose 'yes' for setting com0 to be the serial console.
>  
> -   Note: OpenBSD poweroff does work with qemu, which actually causes qemu
> -   itself to exit.  This is a good thing, as it is currently not possible to
> -   set what block device is booted from at runtime from qemu.  So if you 
> start
> -   an installation booting from a cdrom, you will always boot off a cdrom
> -   every time you reboot that qemu session until you exit and start qemu
> -   again booting off the virtual hard drive.
> +  NOTE: OpenBSD poweroff does work with qemu, which actually causes qemu
> +     itself to exit.  This is a good thing, as it is currently not
> +     possible to set what block device is booted from at runtime from
> +     qemu.  So if you start an installation booting from a cdrom, you
> +     will always boot off a cdrom every time you reboot that qemu session
> +     until you exit and start qemu again booting off the virtual hard
> +     drive.
>  
>  ==> daemonized qemu
>  
> @@ -176,22 +207,29 @@
>     is a complete example that may be cut-and-pasted into rc.local:
>  
>      hddir=/var/vm
> +    USER=qemu
>      if [ -x ${TRUEPREFIX}/bin/qemu ]; then
>          echo -n 'Qemu: vmi386'
>          (
> -            export ETHER=trunk101
> -            export BRIDGE=bridge101
> +         ifconfig tun0 link0
> +         ifconfig bridge101 create
> +         brconfig bridge101 add trunk101 add tun0 up
>  
> -            ${TRUEPREFIX}/bin/qemu \
> +            sh -c "sudo -u $USER \
> +             ${TRUEPREFIX}/bin/qemu \
>                  -daemonize \
>                  -nographic \
>                  -net nic,vlan=0,model=rtl8139,macaddr=52:54:00:4e:62:8f \
> -                -net tap,vlan=0 \
> +                -net tap,vlan=0,fd=3 \
>                  -m 128 \
> -                -hda $hddir/vmi386.hd \
> +                -hda $hddir/virtual.img \
>                  -serial telnet:127.0.0.1:1010,server,nowait \
> -                -monitor telnet:127.0.0.1:1011,server,nowait
> +                -monitor telnet:127.0.0.1:1011,server,nowait \
> +             3<>/dev/tun0"
>          )
>          echo "."
>      fi
> +
> +    NOTE: this presumes the user `qemu' exists, create it or set USER= to an
> +          existing user to use this example.
>  
> -- 
> Todd Fries .. t...@fries.net
> 
>  _____________________________________________
> |                                             \  1.636.410.0632 (voice)
> | Free Daemon Consulting, LLC                 \  1.405.227.9094 (voice)
> | http://FreeDaemonConsulting.com             \  1.866.792.3418 (FAX)
> | "..in support of free software solutions."  \          250797 (FWD)
> |                                             \
>  \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
>                                                  
>               37E7 D3EB 74D0 8D66 A68D  B866 0326 204E 3F42 004A
>                         http://todd.fries.net/pgp.txt
> 
> Penned by Todd T. Fries on 20090210 16:08.05, we have:
> | Honestly, I have two problems with this.
> | 
> | 1) nowhere do you mention you require root privs
> | 
> | 2) this does not drop to a non root user
> | 
> | Unfortunately, we almost need to mention somewhere that
> | amd64 sucks wrt 'user' aka 'slirp' mode net.
> | 
> | Let me get back with a better solution tomorrow.
> | 
> | Thanks,
> | -- 
> | Todd Fries .. t...@fries.net
> | 
> |  _____________________________________________
> | |                                             \  1.636.410.0632 (voice)
> | | Free Daemon Consulting, LLC                 \  1.405.227.9094 (voice)
> | | http://FreeDaemonConsulting.com             \  1.866.792.3418 (FAX)
> | | "..in support of free software solutions."  \          250797 (FWD)
> | |                                             \
> |  \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
> |                                                  
> |               37E7 D3EB 74D0 8D66 A68D  B866 0326 204E 3F42 004A
> |                         http://todd.fries.net/pgp.txt
> | 
> | Penned by Antoine Jacoutot on 20090210 22:18.01, we have:
> | | On Tue, 10 Feb 2009, Marco Peereboom wrote:
> | | 
> | | > Never got a reply on this.
> | | > 
> | | 
> | | As I'm dumb too, I'm all for it.
> | | However, I wonder if it wouln't be a better idea to merge the "Quick 
> | | start" and your "Even quicker start...".
> | | Also, I would use /bin/sh instead of /bin/ksh for the scripts.
> | | While here, could you add RCS Id to the README.OpenBSD file.
> | | 
> | | If this eventually gets commited, it also needs a package bump.
> | | 
> | | Anyway, I like the idea :)
> | | 
> | | Cheers!
> | | 
> | | > On Wed, Dec 24, 2008 at 11:47:23AM -0600, Marco Peereboom wrote:
> | | > > I always spend 30 minutes re-figuring out how to get qemu running.  I
> | | > > know folks like thib and some others have the same issue.  We simply
> | | > > aren't smart enough to understand the rest of the README.  Here is a
> | | > > diff to the README to make it useful for people who don't know how to
> | | > > get this working quickly.
> | | > > 
> | | > > ok
> | | > > 
> | | > > --- /usr/ports/emulators/qemu/files/README.OpenBSD    Thu Dec 11 
> 03:17:33 2008
> | | > > +++ /usr/local/share/doc/qemu/README.OpenBSD  Wed Dec 24 11:40:58 2008
> | | > > @@ -12,7 +12,35 @@ README for OpenBSD users
> | | > >  5. qemu -m 32 -monitor stdio virtual.hd
> | | > >       (normal boot from hard drive)
> | | > >  
> | | > > +==> Even quicker start with access to the outside world
> | | > >  
> | | > > +1. Get a CDROM image:
> | | > > +     ftp ftp://ftp.openbsd.org/pub/OpenBSD/snapshots/i386/cd44.iso
> | | > > +2. Create a virtual disk image:
> | | > > +     qemu-img create boot.img 1G
> | | > > +3. First run with network access (replace nfe0 with the nic that is 
> attached
> | | > > +   to the physical network):
> | | > > +     ETHER=nfe0 BRIDGE=bridge0 qemu -no-fd-bootchk -hda boot.img \
> | | > > +     -cdrom cd44.iso -net nic,model=rtl8139 -net tap
> | | > > +4. Install OS as usual and use re0 for external network access; 
> optionally
> | | > > +   select serial console.
> | | > > +5. Create runqemu script with the following:
> | | > > +     #!/bin/ksh
> | | > > +     export ETHER=nfe0
> | | > > +     export BRIDGE=bridge0
> | | > > +     qemu -no-fd-bootchk -hda boot.img -net nic,model=rtl8139 -net 
> tap
> | | > > +
> | | > > +   In serial console mode do this:
> | | > > +     #!/bin/ksh
> | | > > +     export ETHER=nfe0
> | | > > +     export BRIDGE=bridge0
> | | > > +     qemu -no-fd-bootchk -nographic -serial stdio -hda boot.img \
> | | > > +     -net nic,model=rtl8139 -net tap
> | | > > + 6. Make the script runable:
> | | > > +     chmod +x runqemu
> | | > > + 7. Run it!
> | | > > +     ./runqemu
> | | > > +
> | | > >  ==> Networking
> | | > >  
> | | > >  1.  Default Settings
> | | > > 
> | | > 
> | | > 
> | | 
> | | -- 
> | | Antoine
> 

Reply via email to