public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/kvm-tools:ferringb commit in: app-emulation/qemu-init-scripts/files/
@ 2012-04-14 23:01 Brian Harring
  0 siblings, 0 replies; 7+ messages in thread
From: Brian Harring @ 2012-04-14 23:01 UTC (permalink / raw
  To: gentoo-commits

commit:     d3291abf0e2d0b3bd07cffe8a2ac2e052e7d4dae
Author:     Brian Harring <ferringb <AT> chromium <DOT> org>
AuthorDate: Sat Apr 14 22:54:32 2012 +0000
Commit:     Brian Harring <ferringb <AT> gentoo <DOT> org>
CommitDate: Sat Apr 14 23:01:17 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/kvm-tools.git;a=commit;h=d3291abf

Make foreground controllable.

This deprecates the VNC option in favour of `FOREGROUND=vnc=:1`; in the
process it makes turning off the display (none mode), and sdl mode
possible.

For sdl mode, it tries to rely on DISPLAY and XAUTHORITY to work.  In
my local usage, this *does* work, but wouldn't surprise me if there are
other configurations where this doesn't (patches welcome).

---
 .../qemu-init-scripts/files/qemu-init-script       |   68 ++++++++++++++++++--
 1 files changed, 62 insertions(+), 6 deletions(-)

diff --git a/app-emulation/qemu-init-scripts/files/qemu-init-script b/app-emulation/qemu-init-scripts/files/qemu-init-script
index e12658c..13dacfe 100644
--- a/app-emulation/qemu-init-scripts/files/qemu-init-script
+++ b/app-emulation/qemu-init-scripts/files/qemu-init-script
@@ -16,6 +16,8 @@ PIDFILE=/var/run/vm/${SVCNAME}.pid
 MONITOR=/var/run/vm/${SVCNAME}.monitor
 QTAP_FILE=/var/run/vm/${SVCNAME}.qtap
 
+ENABLE_SDL=
+
 discern_vm_binary() {
 	case "$VMTYPE" in
 		kvm)
@@ -32,6 +34,35 @@ discern_vm_binary() {
 	return 0
 }
 
+discern_foreground() {
+	if [ -n "$VNC" ]; then
+		ewarn "VNC option is going away; set FOREGROUND=vnc${VNC} instead"
+		FOREGROUND="vnc=${VNC}"
+	fi
+	case "${FOREGROUND:-none}" in
+		vnc*)
+			VNC=${VNC#*=}
+			if [ -z "$VNC" ]; then
+				eerror "FOREGROUND vnc is incorrectly set; must specify an address (:1 for example)"
+				return 1
+			fi
+			;;
+		sdl*)
+			ENABLE_SDL=${FOREGROUND#*=}
+			if [ -z "${ENABLE_SDL}" ]; then
+				eerror "FOREGROUND sdl is incorrectly set; must specify a DISPLAY address"
+				return 1
+			fi
+			;;
+		none)
+			;;
+		*)
+			eerror "Unknown FOREGROUND setting: $FOREGROUND"
+			return 1
+			;;
+	esac
+	return 0
+}
 
 DROP_USER=${DROP_USER:-nobody}
 MEMORY=${MEMORY:-512M}
@@ -73,8 +104,10 @@ sanity_check() {
 		eerror "couldn't find \$DISKIMAGE '$DISKIMAGE'"
 		return 1;
 	fi
-	discern_vm_binary
+	discern_vm_binary || return 1
 	NIC_TYPE=${NIC_TYPE:-nat}
+
+	discern_foreground || return 1
 }
 
 start_pre() {
@@ -107,17 +140,40 @@ start() {
 		NIC_COMMAND[${#NIC_COMMAND[@]}]=user
 	fi
 
-	ebegin "Starting ${VM_BINARY##*/} for ${VMNAME} at VNC port${VNC}"
-	start-stop-daemon --start "${VM_BINARY}" \
+	local ss_args=( )
+	local vm_args=( -daemonize )
+
+	if [ -n "${ENABLE_SDL}" ]; then
+		ss_args[${#ss_args[@]}]=--env
+		ss_args[${#ss_args[@]}]="DISPLAY=${ENABLE_SDL}"
+		ss_args[${#ss_args[@]}]=--env
+		local user_home=`getent passwd ${DROP_USER:-root} | cut -d: -f6`
+		ss_args[${#ss_args[@]}]="XAUTHORITY=$user_home/.Xauthority"
+		vm_args[${#vm_args[@]}]=-display
+		vm_args[${#vm_args[@]}]=sdl
+	elif [ -n "$VNC" ]; then
+		vm_args[${#vm_args[@]}]=-display
+		vm_args[${#vm_args[@]}]=vnc
+		vm_args[${#vm_args[@]}]="${VNC}"
+	else
+		vm_args[${#vm_args[@]}]=-display
+		vm_args[${#vm_args[@]}]=none
+	fi
+
+	ebegin "Starting ${VM_BINARY##*/} for ${VMNAME} ${FOREGROUND:+at ${FOREGROUND}}"
+	start-stop-daemon \
+		--start "${VM_BINARY}" \
 		--pidfile ${PIDFILE} \
-		-- -daemonize -pidfile ${PIDFILE} -monitor unix:${MONITOR},server,nowait \
+		"${ss_args[@]}" \
+		-- \
+		"${vm_args[@]}" \
+		-pidfile ${PIDFILE} -monitor unix:${MONITOR},server,nowait \
 		-runas ${DROP_USER} -name ${VMNAME} \
 		-drive file="${DISKIMAGE//,/,,}",if=${DRIVE_MODEL:-virtio},cache=${DRIVE_CACHE:-none} \
 		"${NIC_COMMAND[@]}" \
 		${DISABLE_KVM:---enable-kvm}  \
-		${MEMORY:+-m ${MEMORY}} ${SMP:+-smp ${SMP}} ${VNC:+-vnc ${VNC}} ${OTHER_ARGS}
+		${MEMORY:+-m ${MEMORY}} ${SMP:+-smp ${SMP}} ${OTHER_ARGS}
 	ret=$?
-
 	if [ "0" != "${ret}" -a -n "${QTAP}" ]; then
 		qtap-manipulate destroy ${QTAP}
 	fi



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/kvm-tools:ferringb commit in: app-emulation/qemu-init-scripts/files/
@ 2012-04-14 23:01 Brian Harring
  0 siblings, 0 replies; 7+ messages in thread
From: Brian Harring @ 2012-04-14 23:01 UTC (permalink / raw
  To: gentoo-commits

commit:     19d4bb7cc1e7acfbb05c80a2eb244af73bed64ed
Author:     Brian Harring <ferringb <AT> chromium <DOT> org>
AuthorDate: Sat Apr 14 23:01:14 2012 +0000
Commit:     Brian Harring <ferringb <AT> gentoo <DOT> org>
CommitDate: Sat Apr 14 23:01:17 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/kvm-tools.git;a=commit;h=19d4bb7c

output the start-stop-daemon command to make debugging easier

---
 .../qemu-init-scripts/files/qemu-init-script       |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/app-emulation/qemu-init-scripts/files/qemu-init-script b/app-emulation/qemu-init-scripts/files/qemu-init-script
index 13dacfe..a7c4a63 100644
--- a/app-emulation/qemu-init-scripts/files/qemu-init-script
+++ b/app-emulation/qemu-init-scripts/files/qemu-init-script
@@ -161,7 +161,7 @@ start() {
 	fi
 
 	ebegin "Starting ${VM_BINARY##*/} for ${VMNAME} ${FOREGROUND:+at ${FOREGROUND}}"
-	start-stop-daemon \
+	set -- start-stop-daemon \
 		--start "${VM_BINARY}" \
 		--pidfile ${PIDFILE} \
 		"${ss_args[@]}" \
@@ -173,6 +173,8 @@ start() {
 		"${NIC_COMMAND[@]}" \
 		${DISABLE_KVM:---enable-kvm}  \
 		${MEMORY:+-m ${MEMORY}} ${SMP:+-smp ${SMP}} ${OTHER_ARGS}
+	einfo "invoking ${@}"
+	"${@}"
 	ret=$?
 	if [ "0" != "${ret}" -a -n "${QTAP}" ]; then
 		qtap-manipulate destroy ${QTAP}



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/kvm-tools:ferringb commit in: app-emulation/qemu-init-scripts/files/
  2012-08-24  4:18 [gentoo-commits] proj/kvm-tools:master commit in: app-emulation/qemu-init-scripts/files/ Brian Harring
@ 2012-04-14 23:48 ` Brian Harring
  0 siblings, 0 replies; 7+ messages in thread
From: Brian Harring @ 2012-04-14 23:48 UTC (permalink / raw
  To: gentoo-commits

commit:     31456f30cea2efd5246da9185cbce28e15024cd4
Author:     Brian Harring <ferringb <AT> chromium <DOT> org>
AuthorDate: Sat Apr 14 20:58:08 2012 +0000
Commit:     Brian Harring <ferringb <AT> gentoo <DOT> org>
CommitDate: Sat Apr 14 23:47:58 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/kvm-tools.git;a=commit;h=31456f30

Make networking a bit more configurable via NIC_TYPE.

This can be:

None
 No networking at all.

br
  bridge mode; NIC_NET_DEPS if set is the networking needed.

nat
  Qemu user stack; NIC model is honored, but qemu itself spins up
  a dhcp server and nats connections out on it's own.  For most users
  this is likely what they'll be using- thus this is now the default.

---
 .../qemu-init-scripts/files/qemu-init-script       |   50 ++++++++++++++------
 1 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/app-emulation/qemu-init-scripts/files/qemu-init-script b/app-emulation/qemu-init-scripts/files/qemu-init-script
index 0fbfec4..23b12ef 100644
--- a/app-emulation/qemu-init-scripts/files/qemu-init-script
+++ b/app-emulation/qemu-init-scripts/files/qemu-init-script
@@ -42,7 +42,17 @@ export KVM_USER=${KVM_USER:-"root"}
 extra_commands="reboot"
 
 depend() {
-	need net.br0
+	if [ "$VMNAME" = "$SVCNAME" ]; then
+		return 0
+	fi
+
+	sanity_check || return 1
+
+	case "$NIC_TYPE" in
+		br)
+			need ${NIC_NET_DEPS-net.br0}
+			;;
+	esac
 }
 
 send_command() {
@@ -57,12 +67,14 @@ sanity_check() {
 		eerror " ln -s vm /etc/init.d/vm.vmname"
 		return 1
 	fi
+
 	DISKIMAGE=$(readlink -f "${DISKIMAGE}")
 	if [ ! -f "${DISKIMAGE}" -a ! -b "${DISKIMAGE}" ]; then
 		eerror "couldn't find \$DISKIMAGE '$DISKIMAGE'"
 		return 1;
 	fi
 	discern_vm_binary
+	NIC_TYPE=${NIC_TYPE:-nat}
 }
 
 start_pre() {
@@ -70,22 +82,30 @@ start_pre() {
 		"${MONITOR%/*}"
 }
 
-
 start() {
 	sanity_check || return 1
 
-	ebegin "creating qtap ${QTAP:-(auto allocating one)}"
-	if [ -n "$QTAP" ]; then
-		qtap-manipulate create_specific "${QTAP}" -u "${DROP_USER}"
-	else
-		QTAP=$(qtap-manipulate create -u "${DROP_USER}")
-		if [ 0 != $? ]; then
-			eerror "failed to create qtap interface"
-			return 1
+	local NIC_COMMAND=(	-net "nic,model=${NIC_MODEL:-virtio},macaddr=${MACADDR}" -net )
+
+	if [ "${NIC_TYPE}" = "br" ]; then
+		ebegin "creating qtap ${QTAP:-(auto allocating one)}"
+		if [ -n "$QTAP" ]; then
+			qtap-manipulate create_specific "${QTAP}" -u "${DROP_USER}"
+		else
+			QTAP=$(qtap-manipulate create -u "${DROP_USER}")
+			if [ 0 != $? ]; then
+				eerror "failed to create qtap interface"
+				return 1
+			fi
 		fi
+		echo "${QTAP}" > ${QTAP_FILE}
+		eend $?
+		NIC_COMMAND[${#NIC_COMMAND[@]}]="tap,ifname=${QTAP},script=no"
+	elif [ "${NIC_TYPE}" = "none" ]; then
+		NIC_COMMAND=( -net none )
+	else
+		NIC_COMMAND[${#NIC_COMMAND[@]}]=user
 	fi
-	echo "${QTAP}" > ${QTAP_FILE}
-	eend $?
 
 	ebegin "Starting ${VM_BINARY##*/} for ${VMNAME} at VNC port${VNC}"
 	start-stop-daemon --start "${VM_BINARY}" \
@@ -93,13 +113,15 @@ start() {
 		-- -daemonize -pidfile ${PIDFILE} -monitor unix:${MONITOR},server,nowait \
 		-runas ${DROP_USER} -name ${VMNAME} \
 		-drive file="$DISKIMAGE",if=${DRIVE_MODEL:-virtio},cache=${DRIVE_CACHE:-none} \
-		-net nic,model=${NIC_MODEL:-virtio},macaddr=${MACADDR} -net tap,ifname=${QTAP},script=no \
+		"${NIC_COMMAND[@]}" \
 		${DISABLE_KVM:---enable-kvm}  \
 		${MEMORY:+-m ${MEMORY}} ${SMP:+-smp ${SMP}} ${VNC:+-vnc ${VNC}} ${OTHER_ARGS}
 	ret=$?
-	if [ "0" != "${ret}" ]; then
+
+	if [ "0" != "${ret}" -a -n "${QTAP}" ]; then
 		qtap-manipulate destroy ${QTAP}
 	fi
+
 	eend ${ret}
 }
 



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/kvm-tools:ferringb commit in: app-emulation/qemu-init-scripts/files/
@ 2012-04-14 23:48 Brian Harring
  0 siblings, 0 replies; 7+ messages in thread
From: Brian Harring @ 2012-04-14 23:48 UTC (permalink / raw
  To: gentoo-commits

commit:     1798441957485d5243aa4968ef183d28461b5093
Author:     Brian Harring <ferringb <AT> chromium <DOT> org>
AuthorDate: Sat Apr 14 22:54:32 2012 +0000
Commit:     Brian Harring <ferringb <AT> gentoo <DOT> org>
CommitDate: Sat Apr 14 23:47:58 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/kvm-tools.git;a=commit;h=17984419

Make foreground controllable.

This deprecates the VNC option in favour of `FOREGROUND=vnc=:1`; in the
process it makes turning off the display (none mode), and sdl mode
possible.

For sdl mode, it tries to rely on DISPLAY and XAUTHORITY to work.  In
my local usage, this *does* work, but wouldn't surprise me if there are
other configurations where this doesn't (patches welcome).

---
 .../qemu-init-scripts/files/qemu-init-script       |   68 ++++++++++++++++++--
 1 files changed, 62 insertions(+), 6 deletions(-)

diff --git a/app-emulation/qemu-init-scripts/files/qemu-init-script b/app-emulation/qemu-init-scripts/files/qemu-init-script
index a42e866..9880a7b 100644
--- a/app-emulation/qemu-init-scripts/files/qemu-init-script
+++ b/app-emulation/qemu-init-scripts/files/qemu-init-script
@@ -16,6 +16,8 @@ PIDFILE=/var/run/vm/${SVCNAME}.pid
 MONITOR=/var/run/vm/${SVCNAME}.monitor
 QTAP_FILE=/var/run/vm/${SVCNAME}.qtap
 
+ENABLE_SDL=
+
 discern_vm_binary() {
 	case "$VMTYPE" in
 		kvm)
@@ -32,6 +34,35 @@ discern_vm_binary() {
 	return 0
 }
 
+discern_foreground() {
+	if [ -n "$VNC" ]; then
+		ewarn "VNC option is going away; set FOREGROUND=vnc${VNC} instead"
+		FOREGROUND="vnc=${VNC}"
+	fi
+	case "${FOREGROUND:-none}" in
+		vnc*)
+			VNC=${VNC#*=}
+			if [ -z "$VNC" ]; then
+				eerror "FOREGROUND vnc is incorrectly set; must specify an address (:1 for example)"
+				return 1
+			fi
+			;;
+		sdl*)
+			ENABLE_SDL=${FOREGROUND#*=}
+			if [ -z "${ENABLE_SDL}" ]; then
+				eerror "FOREGROUND sdl is incorrectly set; must specify a DISPLAY address"
+				return 1
+			fi
+			;;
+		none)
+			;;
+		*)
+			eerror "Unknown FOREGROUND setting: $FOREGROUND"
+			return 1
+			;;
+	esac
+	return 0
+}
 
 DROP_USER=${DROP_USER:-nobody}
 MEMORY=${MEMORY:-512M}
@@ -73,8 +104,10 @@ sanity_check() {
 		eerror "couldn't find \$DISKIMAGE '$DISKIMAGE'"
 		return 1;
 	fi
-	discern_vm_binary
+	discern_vm_binary || return 1
 	NIC_TYPE=${NIC_TYPE:-nat}
+
+	discern_foreground || return 1
 }
 
 start_pre() {
@@ -107,17 +140,40 @@ start() {
 		NIC_COMMAND[${#NIC_COMMAND[@]}]=user
 	fi
 
-	ebegin "Starting ${VM_BINARY##*/} for ${VMNAME} at VNC port${VNC}"
-	start-stop-daemon --start "${VM_BINARY}" \
+	local ss_args=( )
+	local vm_args=( -daemonize )
+
+	if [ -n "${ENABLE_SDL}" ]; then
+		ss_args[${#ss_args[@]}]=--env
+		ss_args[${#ss_args[@]}]="DISPLAY=${ENABLE_SDL}"
+		ss_args[${#ss_args[@]}]=--env
+		local user_home=`getent passwd ${DROP_USER:-root} | cut -d: -f6`
+		ss_args[${#ss_args[@]}]="XAUTHORITY=$user_home/.Xauthority"
+		vm_args[${#vm_args[@]}]=-display
+		vm_args[${#vm_args[@]}]=sdl
+	elif [ -n "$VNC" ]; then
+		vm_args[${#vm_args[@]}]=-display
+		vm_args[${#vm_args[@]}]=vnc
+		vm_args[${#vm_args[@]}]="${VNC}"
+	else
+		vm_args[${#vm_args[@]}]=-display
+		vm_args[${#vm_args[@]}]=none
+	fi
+
+	ebegin "Starting ${VM_BINARY##*/} for ${VMNAME} ${FOREGROUND:+at ${FOREGROUND}}"
+	start-stop-daemon \
+		--start "${VM_BINARY}" \
 		--pidfile ${PIDFILE} \
-		-- -daemonize -pidfile ${PIDFILE} -monitor unix:${MONITOR},server,nowait \
+		"${ss_args[@]}" \
+		-- \
+		"${vm_args[@]}" \
+		-pidfile ${PIDFILE} -monitor unix:${MONITOR},server,nowait \
 		-runas ${DROP_USER} -name ${VMNAME} \
 		-drive file="${DISKIMAGE//,/,,}",if=${DRIVE_MODEL:-virtio},cache=${DRIVE_CACHE:-none} \
 		"${NIC_COMMAND[@]}" \
 		${DISABLE_KVM:---enable-kvm}  \
-		${MEMORY:+-m ${MEMORY}} ${SMP:+-smp ${SMP}} ${VNC:+-vnc ${VNC}} ${OTHER_ARGS}
+		${MEMORY:+-m ${MEMORY}} ${SMP:+-smp ${SMP}} ${OTHER_ARGS}
 	ret=$?
-
 	if [ "0" != "${ret}" -a -n "${QTAP}" ]; then
 		qtap-manipulate destroy ${QTAP}
 	fi



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/kvm-tools:ferringb commit in: app-emulation/qemu-init-scripts/files/
  2012-08-24  4:18 [gentoo-commits] proj/kvm-tools:master " Brian Harring
@ 2012-04-14 23:48 ` Brian Harring
  0 siblings, 0 replies; 7+ messages in thread
From: Brian Harring @ 2012-04-14 23:48 UTC (permalink / raw
  To: gentoo-commits

commit:     a17438dd07a0d237ce9763f1a6c5a37de3ba0c2b
Author:     Brian Harring <ferringb <AT> chromium <DOT> org>
AuthorDate: Sat Apr 14 23:01:14 2012 +0000
Commit:     Brian Harring <ferringb <AT> gentoo <DOT> org>
CommitDate: Sat Apr 14 23:47:58 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/kvm-tools.git;a=commit;h=a17438dd

output the start-stop-daemon command to make debugging easier

---
 .../qemu-init-scripts/files/qemu-init-script       |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/app-emulation/qemu-init-scripts/files/qemu-init-script b/app-emulation/qemu-init-scripts/files/qemu-init-script
index 9880a7b..63c662c 100644
--- a/app-emulation/qemu-init-scripts/files/qemu-init-script
+++ b/app-emulation/qemu-init-scripts/files/qemu-init-script
@@ -161,7 +161,7 @@ start() {
 	fi
 
 	ebegin "Starting ${VM_BINARY##*/} for ${VMNAME} ${FOREGROUND:+at ${FOREGROUND}}"
-	start-stop-daemon \
+	set -- start-stop-daemon \
 		--start "${VM_BINARY}" \
 		--pidfile ${PIDFILE} \
 		"${ss_args[@]}" \
@@ -173,6 +173,8 @@ start() {
 		"${NIC_COMMAND[@]}" \
 		${DISABLE_KVM:---enable-kvm}  \
 		${MEMORY:+-m ${MEMORY}} ${SMP:+-smp ${SMP}} ${OTHER_ARGS}
+	einfo "invoking ${@}"
+	"${@}"
 	ret=$?
 	if [ "0" != "${ret}" -a -n "${QTAP}" ]; then
 		qtap-manipulate destroy ${QTAP}



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/kvm-tools:ferringb commit in: app-emulation/qemu-init-scripts/files/
  2012-08-24  4:18 [gentoo-commits] proj/kvm-tools:master " Brian Harring
@ 2012-04-14 23:48 ` Brian Harring
  0 siblings, 0 replies; 7+ messages in thread
From: Brian Harring @ 2012-04-14 23:48 UTC (permalink / raw
  To: gentoo-commits

commit:     471f96ec4b93b9b303e2b7c7eee388c8a0e8ab72
Author:     Brian Harring <ferringb <AT> chromium <DOT> org>
AuthorDate: Sat Apr 14 21:02:22 2012 +0000
Commit:     Brian Harring <ferringb <AT> gentoo <DOT> org>
CommitDate: Sat Apr 14 23:47:58 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/kvm-tools.git;a=commit;h=471f96ec

Protect against ',' in DISKIMAGE pathways.

---
 .../qemu-init-scripts/files/qemu-init-script       |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/app-emulation/qemu-init-scripts/files/qemu-init-script b/app-emulation/qemu-init-scripts/files/qemu-init-script
index 23b12ef..a42e866 100644
--- a/app-emulation/qemu-init-scripts/files/qemu-init-script
+++ b/app-emulation/qemu-init-scripts/files/qemu-init-script
@@ -112,7 +112,7 @@ start() {
 		--pidfile ${PIDFILE} \
 		-- -daemonize -pidfile ${PIDFILE} -monitor unix:${MONITOR},server,nowait \
 		-runas ${DROP_USER} -name ${VMNAME} \
-		-drive file="$DISKIMAGE",if=${DRIVE_MODEL:-virtio},cache=${DRIVE_CACHE:-none} \
+		-drive file="${DISKIMAGE//,/,,}",if=${DRIVE_MODEL:-virtio},cache=${DRIVE_CACHE:-none} \
 		"${NIC_COMMAND[@]}" \
 		${DISABLE_KVM:---enable-kvm}  \
 		${MEMORY:+-m ${MEMORY}} ${SMP:+-smp ${SMP}} ${VNC:+-vnc ${VNC}} ${OTHER_ARGS}



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/kvm-tools:master commit in: app-emulation/qemu-init-scripts/files/
@ 2012-08-24  4:18 Brian Harring
  2012-04-14 23:48 ` [gentoo-commits] proj/kvm-tools:ferringb " Brian Harring
  0 siblings, 1 reply; 7+ messages in thread
From: Brian Harring @ 2012-08-24  4:18 UTC (permalink / raw
  To: gentoo-commits

commit:     31456f30cea2efd5246da9185cbce28e15024cd4
Author:     Brian Harring <ferringb <AT> chromium <DOT> org>
AuthorDate: Sat Apr 14 20:58:08 2012 +0000
Commit:     Brian Harring <ferringb <AT> gentoo <DOT> org>
CommitDate: Sat Apr 14 23:47:58 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/kvm-tools.git;a=commit;h=31456f30

Make networking a bit more configurable via NIC_TYPE.

This can be:

None
 No networking at all.

br
  bridge mode; NIC_NET_DEPS if set is the networking needed.

nat
  Qemu user stack; NIC model is honored, but qemu itself spins up
  a dhcp server and nats connections out on it's own.  For most users
  this is likely what they'll be using- thus this is now the default.

---
 .../qemu-init-scripts/files/qemu-init-script       |   50 ++++++++++++++------
 1 files changed, 36 insertions(+), 14 deletions(-)

diff --git a/app-emulation/qemu-init-scripts/files/qemu-init-script b/app-emulation/qemu-init-scripts/files/qemu-init-script
index 0fbfec4..23b12ef 100644
--- a/app-emulation/qemu-init-scripts/files/qemu-init-script
+++ b/app-emulation/qemu-init-scripts/files/qemu-init-script
@@ -42,7 +42,17 @@ export KVM_USER=${KVM_USER:-"root"}
 extra_commands="reboot"
 
 depend() {
-	need net.br0
+	if [ "$VMNAME" = "$SVCNAME" ]; then
+		return 0
+	fi
+
+	sanity_check || return 1
+
+	case "$NIC_TYPE" in
+		br)
+			need ${NIC_NET_DEPS-net.br0}
+			;;
+	esac
 }
 
 send_command() {
@@ -57,12 +67,14 @@ sanity_check() {
 		eerror " ln -s vm /etc/init.d/vm.vmname"
 		return 1
 	fi
+
 	DISKIMAGE=$(readlink -f "${DISKIMAGE}")
 	if [ ! -f "${DISKIMAGE}" -a ! -b "${DISKIMAGE}" ]; then
 		eerror "couldn't find \$DISKIMAGE '$DISKIMAGE'"
 		return 1;
 	fi
 	discern_vm_binary
+	NIC_TYPE=${NIC_TYPE:-nat}
 }
 
 start_pre() {
@@ -70,22 +82,30 @@ start_pre() {
 		"${MONITOR%/*}"
 }
 
-
 start() {
 	sanity_check || return 1
 
-	ebegin "creating qtap ${QTAP:-(auto allocating one)}"
-	if [ -n "$QTAP" ]; then
-		qtap-manipulate create_specific "${QTAP}" -u "${DROP_USER}"
-	else
-		QTAP=$(qtap-manipulate create -u "${DROP_USER}")
-		if [ 0 != $? ]; then
-			eerror "failed to create qtap interface"
-			return 1
+	local NIC_COMMAND=(	-net "nic,model=${NIC_MODEL:-virtio},macaddr=${MACADDR}" -net )
+
+	if [ "${NIC_TYPE}" = "br" ]; then
+		ebegin "creating qtap ${QTAP:-(auto allocating one)}"
+		if [ -n "$QTAP" ]; then
+			qtap-manipulate create_specific "${QTAP}" -u "${DROP_USER}"
+		else
+			QTAP=$(qtap-manipulate create -u "${DROP_USER}")
+			if [ 0 != $? ]; then
+				eerror "failed to create qtap interface"
+				return 1
+			fi
 		fi
+		echo "${QTAP}" > ${QTAP_FILE}
+		eend $?
+		NIC_COMMAND[${#NIC_COMMAND[@]}]="tap,ifname=${QTAP},script=no"
+	elif [ "${NIC_TYPE}" = "none" ]; then
+		NIC_COMMAND=( -net none )
+	else
+		NIC_COMMAND[${#NIC_COMMAND[@]}]=user
 	fi
-	echo "${QTAP}" > ${QTAP_FILE}
-	eend $?
 
 	ebegin "Starting ${VM_BINARY##*/} for ${VMNAME} at VNC port${VNC}"
 	start-stop-daemon --start "${VM_BINARY}" \
@@ -93,13 +113,15 @@ start() {
 		-- -daemonize -pidfile ${PIDFILE} -monitor unix:${MONITOR},server,nowait \
 		-runas ${DROP_USER} -name ${VMNAME} \
 		-drive file="$DISKIMAGE",if=${DRIVE_MODEL:-virtio},cache=${DRIVE_CACHE:-none} \
-		-net nic,model=${NIC_MODEL:-virtio},macaddr=${MACADDR} -net tap,ifname=${QTAP},script=no \
+		"${NIC_COMMAND[@]}" \
 		${DISABLE_KVM:---enable-kvm}  \
 		${MEMORY:+-m ${MEMORY}} ${SMP:+-smp ${SMP}} ${VNC:+-vnc ${VNC}} ${OTHER_ARGS}
 	ret=$?
-	if [ "0" != "${ret}" ]; then
+
+	if [ "0" != "${ret}" -a -n "${QTAP}" ]; then
 		qtap-manipulate destroy ${QTAP}
 	fi
+
 	eend ${ret}
 }
 


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-08-24  4:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-24  4:18 [gentoo-commits] proj/kvm-tools:master commit in: app-emulation/qemu-init-scripts/files/ Brian Harring
2012-04-14 23:48 ` [gentoo-commits] proj/kvm-tools:ferringb " Brian Harring
  -- strict thread matches above, loose matches on Subject: below --
2012-08-24  4:18 [gentoo-commits] proj/kvm-tools:master " Brian Harring
2012-04-14 23:48 ` [gentoo-commits] proj/kvm-tools:ferringb " Brian Harring
2012-08-24  4:18 [gentoo-commits] proj/kvm-tools:master " Brian Harring
2012-04-14 23:48 ` [gentoo-commits] proj/kvm-tools:ferringb " Brian Harring
2012-04-14 23:48 Brian Harring
2012-04-14 23:01 Brian Harring
2012-04-14 23:01 Brian Harring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox