--- /usr/bin/pb	2010-09-07 17:08:24.676170160 +0200
+++ /tmp/pb.nogui	2010-09-07 17:07:50.000000000 +0200
@@ -467,7 +467,8 @@ if ($action =~ /^cms2build$/) {
 	pb_cms2build();
 	pb_build2v("vm","build");
 } elsif ($action =~ /^launchvm$/) {
-	pb_launchv("vm",$ENV{'PBV'},0);
+	# launch vm with disabled default no gui
+	pb_launchv("vm",$ENV{'PBV'},0,1);
 } elsif ($action =~ /^launchve$/) {
 	pb_launchv("ve",$ENV{'PBV'},0);
 } elsif ($action =~ /^script2vm$/) {
@@ -479,7 +480,8 @@ if ($action =~ /^cms2build$/) {
 } elsif ($action =~ /^newve$/) {
 	pb_launchv("ve",$ENV{'PBV'},1);
 } elsif ($action =~ /^newvm$/) {
-	pb_launchv("vm",$ENV{'PBV'},1);
+	# launch vm with disabled default no gui
+	pb_launchv("vm",$ENV{'PBV'},1,1);
 	pb_log(0, "Please ensure that sshd is running in your VM by default\n");
 	pb_log(0, "and that it allows remote root login (PermitRootLogin yes in /etc/ssh/sshd_config)\n");
 	pb_log(0, "Also ensure that network is up, firewalling correctly configured, and perl and scp/ssh installed\n");
@@ -1596,6 +1598,7 @@ sub pb_launchv {
 	my $vtype = shift;
 	my $v = shift;
 	my $create = shift || 0;		# By default do not create a VM/VE
+	my $enablegui = shift || 0;		# By default, append -nogrpahic to vmcmd ($enablegui = 0)
 	my $snapme = shift || 0;		# By default do not snap a VM/VE
 	my $usesnap = shift || 1;		# By default study the usage of the snapshot feature of VM/VE
 
@@ -1604,7 +1607,7 @@ sub pb_launchv {
 		$usesnap = 0;
 	}
 
-	pb_log(2,"DEBUG: pb_launchv($vtype,$v,$create,$snapme,$usesnap)\n");
+	pb_log(2,"DEBUG: pb_launchv($vtype,$v,$create,$enablegui,$snapme,$usesnap)\n");
 	die "No VM/VE defined, unable to launch" if (not defined $v);
 	# Keep only the first VM in case many were given
 	$v =~ s/,.*//;
@@ -1636,6 +1639,13 @@ sub pb_launchv {
 			$ENV{'PBVMOPT'} .= " $vmopt->{$ENV{'PBPROJ'}}" if ($ENV{'PBVMOPT'} !~ / $vmopt->{$ENV{'PBPROJ'}}/);
 		}
 
+		# disable defaultNoGui
+		if ($enablegui == 0) {
+			if (($vmtype eq "kvm") || ($vmtype eq "qemu")) {
+				$ENV{'PBVMOPT'} .= " -nographic ";
+			}
+		}
+
 		# Are we allowed to use snapshot feature 
 		if ($usesnap == 1) {
 			if ((defined $vmsnap->{$v}) && ($vmsnap->{$v} =~ /true/i)) {
