summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaulo Alcantara <paulo@paulo.ac>2018-05-20 00:32:19 -0300
committerPaulo Alcantara <paulo@paulo.ac>2018-05-20 00:32:19 -0300
commite7f334561892953de94c946b32f6cbbec383af7d (patch)
tree366092a67f95382129df4e114aa2daf522365799
parent8b71240ff9b2f5600a660b94f72f013026c313cc (diff)
downloadvmhtool-e7f334561892953de94c946b32f6cbbec383af7d.tar.gz
vmhtool-e7f334561892953de94c946b32f6cbbec383af7d.tar.xz
vmhtool-e7f334561892953de94c946b32f6cbbec383af7d.zip
Provide the user with QEMU monitor after starting up vm.
Signed-off-by: Paulo Alcantara <paulo@paulo.ac>
-rwxr-xr-xvmhelper24
1 files changed, 12 insertions, 12 deletions
diff --git a/vmhelper b/vmhelper
index d62d934..b42187d 100755
--- a/vmhelper
+++ b/vmhelper
@@ -301,7 +301,8 @@ my %qemu_linux_opts = (
kernel => "-kernel %s",
cmdline => "-append \"root=%s rw console=ttyS0\"",
initrd => "-initrd %s",
- share => ''
+ share => '',
+ mon => "-device virtio-serial-pci -monitor stdio"
);
my %qemu_win_opts = (
@@ -315,7 +316,8 @@ my %qemu_win_opts = (
usb => "-device usb-tablet",
time => "-localtime",
net => "-device virtio-net-pci,netdev=net0,mac=%s -netdev type=tap,id=net0,ifname=%s,script=no,downscript=no",
- gfx => "-vga qxl"
+ gfx => "-vga qxl",
+ mon => "-device virtio-serial-pci -monitor stdio"
);
my $default_img_size = "128G";
@@ -416,16 +418,16 @@ if ($cmd_opts{install_iso_path}) {
$qemu_cmd .= " " . sprintf $qemu_win_opts{'net'}, $macaddr, $tap_iface;
$qemu_cmd .= " $qemu_win_opts{'time'} $qemu_win_opts{'usb'}" .
" $qemu_win_opts{'gfx'}";
+ $qemu_cmd .= " $qemu_win_opts{'mon'}";
} else {
$qemu_cmd .= " $qemu_linux_opts{'mach'} $qemu_linux_opts{'cpu'}";
$qemu_cmd .= " $qemu_linux_opts{'mem'} $qemu_linux_opts{'bus'}";
$qemu_cmd .= " " . sprintf $qemu_linux_opts{'hdd'}, $vm_img_path;
$qemu_cmd .= " " . sprintf $qemu_linux_opts{'cdrom'}, $cmd_opts{install_iso_path};
$qemu_cmd .= " " . sprintf $qemu_linux_opts{'net'}, $macaddr, $tap_iface;
+ $qemu_cmd .= " $qemu_linux_opts{'mon'}";
}
- $qemu_cmd .= " 2>/dev/null";
-
print "[*] install $vm_name vm\n";
print "[*] macaddr: $macaddr\n";
print "[*] cmd: $qemu_cmd\n";
@@ -470,8 +472,7 @@ if ($cmd_opts{windows_guest}) {
sprintf $qemu_win_opts{'net'}, get_vm_macaddr(), $tap_iface;
$qemu_cmd .= " $qemu_win_opts{'time'} $qemu_win_opts{'usb'}" .
" $qemu_win_opts{'gfx'}";
-
- $qemu_cmd .= " 2>/dev/null";
+ $qemu_cmd .= " $qemu_win_opts{'mon'}";
print "[*] $vm_name is up and running\n";
print "[*] ipaddr: " . resolve_name($vm_name) . "\n";
@@ -481,7 +482,7 @@ if ($cmd_opts{windows_guest}) {
destroy_vm_net();
die "failed to exec cmd: $qemu_cmd";
}
- print "[*] terminated\n";
+ print "\n[*] done\n";
destroy_vm_net();
exit 0;
@@ -612,7 +613,7 @@ if ($cmd_opts{kernel_path}) {
}
if ($cmd_opts{config_path}) {
- unless (-e $cmd_opts{config_path} or -f $cmd_opts{config_path}) {
+ if (! -e $cmd_opts{config_path} || ! -d $cmd_opts{config_path}) {
$err = "$cmd_opts{config_path} does not exist";
goto OUT;
}
@@ -656,11 +657,10 @@ if ($cmd_opts{kernel_path}) {
$qemu_cmd .= " " . sprintf $qemu_linux_opts{'initrd'}, $cmd_opts{initrd_img};
}
} else {
- $qemu_cmd .= " -nographic -device virtio-serial-pci -serial mon:stdio" if $cmd_opts{nographic};
+ $qemu_cmd .= " $qemu_linux_opts{'mon'}";
+ $qemu_cmd .= " -display none" if $cmd_opts{nographic};
}
-$qemu_cmd .= " 2>/dev/null";
-
print "[*] $vm_name vm is up and running\n";
print "[*] ipaddr: " . resolve_name($vm_name) . "\n";
print "[*] macaddr: " . get_vm_macaddr() . "\n";
@@ -669,7 +669,7 @@ if (system($qemu_cmd)) {
$err = "failed to exec cmd: $qemu_cmd";
goto OUT;
}
-print "[*] terminated\n";
+print "\n[*] done\n";
OUT:
rem_shared_dirs();