Update to qemu 0.13.0. fmt README and sync with reality.

with input and ok sthen@
This commit is contained in:
fgsch 2010-11-22 11:32:01 +00:00
parent 08143c5337
commit dc0e9861c1
12 changed files with 228 additions and 250 deletions

View File

@ -1,12 +1,11 @@
# $OpenBSD: Makefile,v 1.58 2010/11/15 23:22:08 espie Exp $
# $OpenBSD: Makefile,v 1.59 2010/11/22 11:32:01 fgsch Exp $
# no success building on other archs yet
ONLY_FOR_ARCHS = i386 amd64 sparc64
COMMENT = multi system emulator
DISTNAME = qemu-0.12.5
REVISION = 1
DISTNAME = qemu-0.13.0
CATEGORIES = emulators
HOMEPAGE = http://www.qemu.org/
@ -17,23 +16,34 @@ PERMIT_PACKAGE_FTP = Yes
PERMIT_DISTFILES_CDROM = Yes
PERMIT_DISTFILES_FTP = Yes
WANTLIB = c m ossaudio pthread util z
WANTLIB = c jpeg m ossaudio png pthread util z
MASTER_SITES = ${MASTER_SITE_SAVANNAH:=qemu/}
BUILD_DEPENDS = textproc/texi2html
LIB_DEPENDS = graphics/jpeg \
graphics/png
MAKE_ENV += V=1
FAKE_FLAGS = sysconfdir=${PREFIX}/share/examples
USE_GMAKE = Yes
USE_GROFF = Yes
USE_GROFF = Yes
CONFIGURE_STYLE = simple
CONFIGURE_ARGS = --prefix=${PREFIX} \
--sysconfdir=${SYSCONFDIR} \
--mandir=${PREFIX}/man \
--extra-cflags="-I${LOCALBASE}/include \
-I${LOCALBASE}/include/libpng" \
--extra-ldflags=-L${LOCALBASE}/lib \
--disable-vnc-tls \
--disable-vnc-sasl \
--disable-curses \
--disable-curl \
--disable-bsd-user \
--disable-guest-base \
--extra-cflags=-fno-stack-protector
--disable-uuid
FLAVORS = debug no_x11
FLAVOR ?=
@ -41,11 +51,12 @@ FLAVOR ?=
.if ${FLAVOR:L:Mno_x11}
CONFIGURE_ARGS += --disable-sdl
.else
LIB_DEPENDS = devel/sdl
LIB_DEPENDS += devel/sdl
WANTLIB += SDL X11
.endif
.if ${FLAVOR:L:Mdebug}
VMEM_WARNING = yes
CONFIGURE_ARGS += --enable-debug
.endif

View File

@ -1,5 +1,5 @@
MD5 (qemu-0.12.5.tar.gz) = HQLuCgTfriiUNAJzNywd5A==
RMD160 (qemu-0.12.5.tar.gz) = xOui5km0KOjdQycYRD6YYFfmktc=
SHA1 (qemu-0.12.5.tar.gz) = WWpnPzpml+qP2Q9PI5gSQcwTvcM=
SHA256 (qemu-0.12.5.tar.gz) = pqezC1NZHhYLXH/ZMZmFZzF06epHsYLb5jvJk1d0H1g=
SIZE (qemu-0.12.5.tar.gz) = 4291741
MD5 (qemu-0.13.0.tar.gz) = OXoNZl2oup07lYNinz1kIQ==
RMD160 (qemu-0.13.0.tar.gz) = Sm+q841WFvt77cGmQI3h27PsNgw=
SHA1 (qemu-0.13.0.tar.gz) = JQu6H9tQWnh8SDMbawL1QoLt/HY=
SHA256 (qemu-0.13.0.tar.gz) = Hm9YUbBc6m43fINfRmhAjUEkz7hF+ZSNkigIdDxf2Hc=
SIZE (qemu-0.13.0.tar.gz) = 5184531

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-configure,v 1.14 2010/06/17 09:57:55 fgsch Exp $
--- configure.orig Tue May 4 16:27:48 2010
+++ configure Wed Jun 16 21:24:04 2010
@@ -34,12 +34,12 @@ interp_prefix="/usr/gnemul/qemu-%M"
$OpenBSD: patch-configure,v 1.15 2010/11/22 11:32:01 fgsch Exp $
--- configure.orig Fri Oct 15 21:56:09 2010
+++ configure Thu Nov 18 21:05:53 2010
@@ -69,12 +69,12 @@ interp_prefix="/usr/gnemul/qemu-%M"
static="no"
sparc_cpu=""
cross_prefix=""
@ -16,37 +16,56 @@ $OpenBSD: patch-configure,v 1.14 2010/06/17 09:57:55 fgsch Exp $
ar="ar"
make="make"
install="install"
@@ -93,7 +93,7 @@ ld="${cross_prefix}${ld}"
@@ -128,15 +128,15 @@ ld="${cross_prefix}${ld}"
# default flags for all hosts
QEMU_CFLAGS="-fno-strict-aliasing $QEMU_CFLAGS"
-CFLAGS="-g $CFLAGS"
+CFLAGS="$CFLAGS"
QEMU_CFLAGS="-Wall -Wundef -Wendif-labels -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
-QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
+QEMU_CFLAGS="-Wstrict-prototypes $QEMU_CFLAGS"
QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
@@ -1788,7 +1788,9 @@ fi
QEMU_CFLAGS="-D_FORTIFY_SOURCE=2 $QEMU_CFLAGS"
QEMU_CFLAGS="-I. -I\$(SRC_PATH) $QEMU_CFLAGS"
LDFLAGS="-g $LDFLAGS"
-gcc_flags="-Wold-style-declaration -Wold-style-definition -fstack-protector-all"
+gcc_flags="-Wold-style-definition"
cat > $TMPC << EOF
int main(void) { return 0; }
EOF
@@ -1300,7 +1300,7 @@ int main(void) {
}
EOF
vnc_png_cflags=""
- vnc_png_libs="-lpng"
+ vnc_png_libs="-lpng -lz -lm"
if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then
vnc_png=yes
libs_softmmu="$vnc_png_libs $libs_softmmu"
@@ -1677,7 +1677,7 @@ fi
##########################################
# pthread probe
-PTHREADLIBS_LIST="-lpthread -lpthreadGC2"
+PTHREADLIBS_LIST="-pthread"
pthread=no
cat > $TMPC << EOF
@@ -2061,7 +2061,9 @@ fi
# After here, no more $cc or $ld runs
if test "$debug" = "no" ; then
- CFLAGS="-O2 $CFLAGS"
+ CFLAGS="$CFLAGS"
+else
+ CFLAGS="-g $CFLAGS"
+ CFLAGS="-O0 -g $CFLAGS"
fi
# Consult white-list to determine whether to enable werror
@@ -1836,7 +1838,7 @@ else
if test -z "$prefix" ; then
prefix="/usr/local"
fi
- mansuffix="/share/man"
+ mansuffix="/man"
datasuffix="/share/qemu"
docsuffix="/share/doc/qemu"
binsuffix="/bin"
@@ -2167,7 +2169,7 @@ echo "datadir=\${prefix}$datasuffix" >> $config_host_m
echo "docdir=\${prefix}$docsuffix" >> $config_host_mak
@@ -2452,7 +2454,7 @@ echo "TOOLS=$tools" >> $config_host_mak
echo "ROMS=$roms" >> $config_host_mak
echo "MAKE=$make" >> $config_host_mak
echo "INSTALL=$install" >> $config_host_mak
-echo "INSTALL_DIR=$install -d -m0755 -p" >> $config_host_mak
@ -54,7 +73,7 @@ $OpenBSD: patch-configure,v 1.14 2010/06/17 09:57:55 fgsch Exp $
echo "INSTALL_DATA=$install -m0644 -p" >> $config_host_mak
echo "INSTALL_PROG=$install -m0755 -p" >> $config_host_mak
echo "CC=$cc" >> $config_host_mak
@@ -2575,7 +2577,11 @@ if test "$gprof" = "yes" ; then
@@ -2889,7 +2891,11 @@ if test "$gprof" = "yes" ; then
fi
fi

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-exec_c,v 1.8 2010/06/08 01:08:20 fgsch Exp $
--- exec.c.orig Sun May 9 23:33:36 2010
+++ exec.c Sun May 9 23:34:16 2010
@@ -463,7 +463,8 @@ static void code_gen_alloc(unsigned long tb_size)
$OpenBSD: patch-exec_c,v 1.9 2010/11/22 11:32:01 fgsch Exp $
--- exec.c.orig Fri Oct 15 21:56:09 2010
+++ exec.c Thu Nov 18 09:21:58 2010
@@ -524,7 +524,8 @@ static void code_gen_alloc(unsigned long tb_size)
exit(1);
}
}

View File

@ -1,12 +0,0 @@
$OpenBSD: patch-hw_rtl8139_c,v 1.5 2010/05/27 17:55:05 fgsch Exp $
--- hw/rtl8139.c.orig Mon Mar 8 15:01:40 2010
+++ hw/rtl8139.c Mon Mar 8 15:01:46 2010
@@ -61,7 +61,7 @@
#define RTL8139_CALCULATE_RXCRC 1
/* Uncomment to enable on-board timer interrupts */
-//#define RTL8139_ONBOARD_TIMER 1
+#define RTL8139_ONBOARD_TIMER 1
#if defined(RTL8139_CALCULATE_RXCRC)
/* For crc32 */

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-net_tap-bsd_c,v 1.1 2010/05/27 17:55:05 fgsch Exp $
--- net/tap-bsd.c.orig Mon Mar 22 23:29:35 2010
+++ net/tap-bsd.c Mon Mar 22 23:30:23 2010
@@ -46,7 +46,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_
$OpenBSD: patch-net_tap-bsd_c,v 1.2 2010/11/22 11:32:01 fgsch Exp $
--- net/tap-bsd.c.orig Fri Oct 15 21:56:09 2010
+++ net/tap-bsd.c Thu Nov 18 09:21:58 2010
@@ -47,7 +47,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_
char *dev;
struct stat s;
@ -10,7 +10,7 @@ $OpenBSD: patch-net_tap-bsd_c,v 1.1 2010/05/27 17:55:05 fgsch Exp $
/* if no ifname is given, always start the search from tap0. */
int i;
char dname[100];
@@ -55,7 +55,11 @@ int tap_open(char *ifname, int ifname_size, int *vnet_
@@ -56,7 +56,11 @@ int tap_open(char *ifname, int ifname_size, int *vnet_
if (*ifname) {
snprintf(dname, sizeof dname, "/dev/%s", ifname);
} else {

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-vl_c,v 1.22 2010/05/28 00:02:52 fgsch Exp $
--- vl.c.orig Tue Feb 23 13:54:38 2010
+++ vl.c Thu May 27 17:04:47 2010
@@ -652,7 +652,8 @@ static void init_get_clock(void)
$OpenBSD: patch-qemu-timer_c,v 1.1 2010/11/22 11:32:01 fgsch Exp $
--- qemu-timer.c.orig Thu Nov 18 09:27:07 2010
+++ qemu-timer.c Thu Nov 18 09:27:26 2010
@@ -108,7 +108,8 @@ static void init_get_clock(void)
{
use_rt_clock = 0;
#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \
@ -11,7 +11,7 @@ $OpenBSD: patch-vl_c,v 1.22 2010/05/28 00:02:52 fgsch Exp $
{
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
@@ -665,7 +666,8 @@ static void init_get_clock(void)
@@ -121,7 +122,8 @@ static void init_get_clock(void)
static int64_t get_clock(void)
{
#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \

View File

@ -1,12 +0,0 @@
$OpenBSD: patch-rules_mak,v 1.1 2010/05/27 17:55:05 fgsch Exp $
--- rules.mak.orig Mon Mar 8 22:53:58 2010
+++ rules.mak Mon Mar 8 22:54:18 2010
@@ -31,7 +31,7 @@ LINK = $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFL
%.a:
$(call quiet-command,rm -f $@ && $(AR) rcs $@ $^," AR $(TARGET_DIR)$@")
-quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1))
+quiet-command = $1
# cc-option
# Usage: CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-slirp_slirp_config_h,v 1.5 2010/05/27 17:55:05 fgsch Exp $
--- slirp/slirp_config.h.orig Mon Mar 8 15:02:00 2010
+++ slirp/slirp_config.h Mon Mar 8 15:00:19 2010
$OpenBSD: patch-slirp_slirp_config_h,v 1.6 2010/11/22 11:32:01 fgsch Exp $
--- slirp/slirp_config.h.orig Fri Oct 15 21:56:09 2010
+++ slirp/slirp_config.h Thu Nov 18 09:21:58 2010
@@ -89,7 +89,7 @@
#undef BAD_SPRINTF
@ -28,7 +28,7 @@ $OpenBSD: patch-slirp_slirp_config_h,v 1.5 2010/05/27 17:55:05 fgsch Exp $
/* Define if you have sys/stropts.h */
#undef HAVE_SYS_STROPTS_H
@@ -194,7 +194,7 @@
@@ -188,7 +188,7 @@
#undef HAVE_GRANTPT
/* Define if you have fchmod */

View File

@ -1,42 +0,0 @@
$OpenBSD: patch-target-sparc_translate_c,v 1.1 2010/06/17 09:57:55 fgsch Exp $
--- target-sparc/translate.c.orig Tue May 4 16:27:48 2010
+++ target-sparc/translate.c Wed Jun 16 23:36:33 2010
@@ -1663,27 +1663,27 @@ static inline TCGv get_src2(unsigned int insn, TCGv de
#ifdef TARGET_SPARC64
static inline void gen_load_trap_state_at_tl(TCGv_ptr r_tsptr, TCGv_ptr cpu_env)
{
- TCGv r_tl = tcg_temp_new();
+ TCGv_i32 r_tl = tcg_temp_new_i32();
/* load env->tl into r_tl */
- {
- TCGv_i32 r_tl_tmp = tcg_temp_new_i32();
- tcg_gen_ld_i32(r_tl_tmp, cpu_env, offsetof(CPUSPARCState, tl));
- tcg_gen_ext_i32_tl(r_tl, r_tl_tmp);
- tcg_temp_free_i32(r_tl_tmp);
- }
+ tcg_gen_ld_i32(r_tl, cpu_env, offsetof(CPUSPARCState, tl));
/* tl = [0 ... MAXTL_MASK] where MAXTL_MASK must be power of 2 */
- tcg_gen_andi_tl(r_tl, r_tl, MAXTL_MASK);
+ tcg_gen_andi_i32(r_tl, r_tl, MAXTL_MASK);
/* calculate offset to current trap state from env->ts, reuse r_tl */
- tcg_gen_muli_tl(r_tl, r_tl, sizeof (trap_state));
+ tcg_gen_muli_i32(r_tl, r_tl, sizeof (trap_state));
tcg_gen_addi_ptr(r_tsptr, cpu_env, offsetof(CPUState, ts));
/* tsptr = env->ts[env->tl & MAXTL_MASK] */
- tcg_gen_add_ptr(r_tsptr, r_tsptr, r_tl);
+ {
+ TCGv_ptr r_tl_tmp = tcg_temp_new_ptr();
+ tcg_gen_ext_i32_ptr(r_tl_tmp, r_tl);
+ tcg_gen_add_ptr(r_tsptr, r_tsptr, r_tl_tmp);
+ tcg_temp_free_ptr(r_tl_tmp);
+ }
- tcg_temp_free(r_tl);
+ tcg_temp_free_i32(r_tl);
}
#endif

View File

@ -1,8 +1,10 @@
@comment $OpenBSD: PLIST,v 1.15 2010/11/12 14:43:13 jasper Exp $
@comment $OpenBSD: PLIST,v 1.16 2010/11/22 11:32:01 fgsch Exp $
@conflict qemu-*
@pkgpath emulators/qemu,kqemu
@bin bin/qemu
@bin bin/qemu-img
@bin bin/qemu-io
@bin bin/qemu-nbd
@bin bin/qemu-system-arm
@bin bin/qemu-system-cris
@bin bin/qemu-system-m68k
@ -35,9 +37,14 @@ share/examples/qemu/qemu-ifup
@mode 755
@sample ${SYSCONFDIR}/qemu-ifup
@mode
share/examples/qemu/target-x86_64.conf
@sample ${SYSCONFDIR}/qemu/
@sample ${SYSCONFDIR}/qemu/target-x86_64.conf
share/qemu/
share/qemu/bamboo.dtb
share/qemu/bios.bin
share/qemu/gpxe-eepro100-80861209.rom
share/qemu/gpxe-eepro100-80861229.rom
share/qemu/keymaps/
share/qemu/keymaps/ar
share/qemu/keymaps/common
@ -82,11 +89,11 @@ share/qemu/openbios-sparc64
share/qemu/petalogix-s3adsp1800.dtb
share/qemu/ppc_rom.bin
share/qemu/pxe-e1000.bin
share/qemu/pxe-i82559er.bin
share/qemu/pxe-ne2k_pci.bin
share/qemu/pxe-pcnet.bin
share/qemu/pxe-rtl8139.bin
share/qemu/pxe-virtio.bin
share/qemu/s390-zipl.rom
share/qemu/vgabios-cirrus.bin
share/qemu/vgabios.bin
share/qemu/video.x

View File

@ -1,18 +1,11 @@
$OpenBSD: README,v 1.1 2010/11/12 14:43:13 jasper Exp $
$OpenBSD: README,v 1.2 2010/11/22 11:32:01 fgsch Exp $
README for OpenBSD users
------------------------
==> Quick Start
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
1. Get a bootable CDROM image:
$ ftp ftp://ftp.openbsd.org/pub/OpenBSD/snapshots/i386/cd48.iso
@ -20,171 +13,184 @@ NOTE: amd64 cannot use '-net user' without SEGV'ing, to work around
$ qemu-img create -f qcow2 virtual.img 10G
3. Install the os:
3. Install the OS:
$ qemu -m 32 -monitor stdio -no-fd-bootchk -hda virtual.img \
-cdrom cd48.iso -boot d
NOTE: start this inside an xterm or equivalent
NOTE: be sure to choose serial console during install
NOTE: -no-fd-bootchk permits booting faster when no floppy is in use
NOTE: start this inside an xterm or equivalent.
NOTE: be sure to choose serial console during install.
NOTE: -no-fd-bootchk permits booting faster when no floppy is
in use.
4. Compress the virtual disk:
$ qemu-img convert -c -O qcow2 virtual.img v.tmp && mv v.tmp virtual.img
$ 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
NOTE: do not do this while qemu is running / using this virtual
disk.
5. Boot normally from the virtual disk:
$ qemu -m 32 -nographic -no-fd-bootchk -hda virtual.img
$ qemu -m 32 -nographic -no-fd-bootchk -hda virtual.img
==> Networking
1. Default Settings
1. Default Settings
By default, qemu sets up the equivalent of the following networking:
By default, qemu sets up the equivalent of the following networking:
-net nic,vlan=0,model=rtl8139,macaddr=52:54:00:12:34:56
-net nic,vlan=0,model=e1000,macaddr=52:54:00:12:34:56
-net user,vlan=0
Also, inside this virtual usermode network, it uses the 10.0.2.0/24 and
serves dhcp from inside this virtual network. Static address can be used
if one cannot or does not want to do dhcp in the guest os:
Also, inside this virtual usermode network, it uses the 10.0.2.0/24
and serves dhcp from inside this virtual network. Static address
can be used if one cannot or does not want to do dhcp in the
guest OS:
Guest OS IP : 10.0.2.15
Default Gateway : 10.0.2.2
Nameserver : 10.0.2.3
It is sufficient for most operations, qemu itself performs NAT and then
makes userland network calls for tcp/udp operations. icmp and other things
are not possible in this mode.
It is sufficient for most operations, qemu itself performs NAT
and then 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: 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: 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
2. tap mode
Sometimes it is desirable to configure qemu to access a network via layer2
directly. One way of doing this without having to run qemu as root is to
let root open /dev/tunN and pass the file descriptor to qemu. The tun(4)
interface should preferrably be configured before starting qemu:
Sometimes it is desirable to configure qemu to access a network
via layer2 directly. One way of doing this without having to run
qemu as root is to let root open /dev/tunN and pass the file
descriptor to qemu. The tun(4) interface should preferrably be
configured before starting qemu:
$ sudo ifconfig tun0 192.168.0.254 link0
$ sudo ifconfig tun0 192.168.0.254 link0
The interface can also be configured as part of a bridge(4), in which case
the ip address can be omitted:
The interface can also be configured as part of a bridge(4), in
which case the ip address can be omitted:
$ sudo ifconfig tun0 link0
$ sudo ifconfig bridge0 create
$ sudo ifconfig bridge0 add tun0 add em0 up
$ sudo ifconfig tun0 link0
$ sudo ifconfig bridge0 add tun0 add em0 up
The tunnel and bridge interfaces can also be configured at system startup by
editing /etc/hostname.tunN and /etc/bridgename.bridgeN,
respectively (see hostname.if(5)).
The tunnel and bridge interfaces can also be configured at system
startup by editing /etc/hostname.tunN and /etc/hostname.bridgeN,
respectively (see hostname.if(5)).
After configuring the virtual network we can use sudo to let root open the
tunnel device and then use sudo again to drop privileges and start qemu:
After configuring the virtual network we can use sudo to let
root open the 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 \
-no-fd-bootchk -hda virtual.img 3<>/dev/tun0"
$ sudo sh -c "sudo -u $USER qemu -nographic -net nic \
-net tap,fd=3 -no-fd-bootchk -hda 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:
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.
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
you would have to run qemu as root, and there is no way to drop from root
privileges at this point.
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 you would have to run qemu as root,
and there is no way to drop from root privileges at this point.
${SYSCONFDIR}/qemu-ifup contains some default settings that permit one to do
the following:
${SYSCONFDIR}/qemu-ifup contains some default settings that
permit one to do the following:
# qemu -net nic -net tap -no-fd-bootchk -hda virtual.img
# qemu -net nic -net tap -no-fd-bootchk -hda virtual.img
It presumes you wish the tun(4) interface to talk to the interface
holding the default IPv4 route (falling back to trunk0 if no route is
found), and that you want 'bridge0' to be used to bridge the two.
It presumes you wish the tun(4) interface to talk to the interface
holding the default IPv4 route (falling back to trunk0 if no
route is found), and that you want 'bridge0' to be used to bridge
the two.
If you wish to over-ride these settings, setting the environment variables
ETHER and BRIDGE will over-ride these settings, respectively.
Setting the environment variables ETHER and BRIDGE will override
these settings, respectively.
When starting qemu, the script attempts to output useful information, but
there are also error messages that occur as well. On my laptop, I want to
route / nat natively using pf and also have layer2 access to the qemu
networks. I thus have this as /etc/hostname.trunk101:
When starting qemu, the script attempts to output useful
information, but there are also error messages that occur as
well. On my laptop, I want to route / nat natively using pf and
also have layer2 access to the qemu networks. I thus have this
as /etc/hostname.trunk101:
inet6 fe80::1c 64 lladdr 00:03:25:0d:7a:2c
inet 10.7.255.1 255.255.255.0
inet6 alias 2001:240:58a:45::1c
I have dhcpd configured to run on trunk101, and also run rtadvd. For qemu,
the startup looks like this:
I have dhcpd configured to run on trunk101, and also run rtadvd.
For qemu, the startup looks like this:
# export ETHER=trunk101
# export BRIDGE=bridge101
# qemu -net nic,vlan=0,model=rtl8139,macaddr=52:54:00:12:35:00 \
# export ETHER=trunk101
# export BRIDGE=bridge101
# qemu -net nic,vlan=0,model=e1000,macaddr=52:54:00:12:35:00 \
-net tap,vlan=0 -vnc :0 -localtime -usb -usbdevice tablet \
-m 256 -no-fd-bootchk -hda virtual.img -monitor stdio
{tun0 (bridge101 <-> trunk101)ifconfig: bridge101: No such process
ifconfig: bridge101: No such process
}
(qemu)
{tun0 (bridge101 <-> trunk101)ifconfig: bridge101: No such process
ifconfig: bridge101: No such process
}
(qemu)
The errors are normal and should be ignored. One can verify the networking
is properly configured by verifying the bridge interface:
The errors are normal and should be ignored. One can verify the
networking is properly configured by verifying the bridge
interface:
$ ifconfig bridge101
bridge101: flags=41<UP,RUNNING>
priority 32768 hellotime 2 fwddelay 15 maxage 20 holdcnt 6 proto rstp
designated: id 00:00:00:00:00:00 priority 0
tun0 flags=3<LEARNING,DISCOVER>
port 16 ifpriority 0 ifcost 0
trunk101 flags=3<LEARNING,DISCOVER>
port 6 ifpriority 0 ifcost 0
Addresses (max cache: 100, timeout: 240):
$ ifconfig bridge101
bridge101: flags=41<UP,RUNNING>
groups: bridge
priority 32768 hellotime 2 fwddelay 15 maxage 20 holdcnt 6 proto rstp
designated: id 00:00:00:00:00:00 priority 0
tun0 flags=3<LEARNING,DISCOVER>
port 16 ifpriority 0 ifcost 0
trunk101 flags=3<LEARNING,DISCOVER>
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 and choose a unique lladdr
per qemu nic.
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 OS's work 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
1. Installing OpenBSD via serial console is sometimes desirable. X may not
be available, and so on. There are two ways to accomplish this, both in
effect the same solution:
Installing OpenBSD via serial console is sometimes desirable.
X may not 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.img -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
- 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.img -fda floppy48.fs -boot a
- this maps both the serial port and the (qemu) monitor prompt to
the terminal qemu was started on
- to flip between them, Ctrl-a c; see the qemu man page for other
commands that work in -nographic mode.
- preparation of the floppy image to force serial console mode is
straightforward:
- this maps both the serial port and the (qemu) monitor
prompt to the terminal qemu was started on.
- to flip between them, Ctrl-a c; see the qemu man page for
other commands that work in -nographic mode.
- preparation of the floppy image to force serial console
mode is straightforward:
vnconfig svnd0 floppy48.fs
mount /dev/svnd0c /mnt
@ -193,47 +199,48 @@ NOTE: amd64 cannot use '-net user' without SEGV'ing, to work around
umount /mnt
vnconfig -u svnd0
.. be sure to choose 'yes' for setting com0 to be the serial console.
.. 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
Sometimes you want qemu to start as part of a system script.
Adding to some of the above, the -daemonize option comes in handy,
as well as the telnet: designator for -serial and monitor. This
is a complete example that may be cut-and-pasted into rc.local:
Adding to some of the above, the -daemonize option comes in
handy, as well as the telnet: designator for -serial and monitor.
This 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'
(
ifconfig tun0 link0
ifconfig bridge101 create
ifconfig bridge101 add trunk101 add tun0 up
echo -n 'Qemu: vmi386'
(
ifconfig tun0 link0
ifconfig bridge101 add trunk101 add tun0 up
sh -c "sudo -u $USER \
${TRUEPREFIX}/bin/qemu \
${TRUEPREFIX}/bin/qemu \
-daemonize \
-nographic \
-net nic,vlan=0,model=rtl8139,macaddr=52:54:00:4e:62:8f \
-net nic,vlan=0,model=e1000,macaddr=52:54:00:4e:62:8f \
-net tap,vlan=0,fd=3 \
-m 128 \
-hda $hddir/virtual.img \
-serial telnet:127.0.0.1:1080,server,nowait \
-monitor telnet:127.0.0.1:1081,server,nowait \
-no-fd-bootchk 3<>/dev/tun0"
)
echo "."
-no-fd-bootchk 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.
NOTE: this presumes the user `qemu' exists, create it or set
USER= to an existing user to use this example.