summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaulo Alcantara <paulo@paulo.ac>2018-08-28 16:12:01 -0300
committerPaulo Alcantara <paulo@paulo.ac>2018-08-28 16:13:21 -0300
commit172ad6853da6795c3cedec5a549cb2becaa8f102 (patch)
tree19decfab34b97d0ca6decd87a7ec1876c30dc16c
parentf345fa2544e95089513ff3e8e101e6979312ba3f (diff)
downloadvmhtool-172ad6853da6795c3cedec5a549cb2becaa8f102.tar.gz
vmhtool-172ad6853da6795c3cedec5a549cb2becaa8f102.tar.xz
vmhtool-172ad6853da6795c3cedec5a549cb2becaa8f102.zip
Allow to override default QEMU binary patch with env vars.
Signed-off-by: Paulo Alcantara <paulo@paulo.ac>
-rwxr-xr-xvmhelper22
1 files changed, 18 insertions, 4 deletions
diff --git a/vmhelper b/vmhelper
index cf04467..dc64f0f 100755
--- a/vmhelper
+++ b/vmhelper
@@ -89,6 +89,20 @@ my $vm_conf = $vm_path . '/.vmconf';
my $vm_gdb_port = $cmd_opts{gdb_conn} ? empty_port() : -1;
+my $qemu_bin_path;
+my $qemu_img_bin_path;
+
+unless ($ENV{'VMHELPER_QEMU_BIN_PATH'}) {
+ $qemu_bin_path = "/usr/bin/qemu-system-x86_64";
+} else {
+ $qemu_bin_path = $ENV{'VMHELPER_QEMU_BIN_PATH'};
+}
+unless ($ENV{'VMHELPER_QEMU_IMG_BIN_PATH'}) {
+ $qemu_img_bin_path = "/usr/bin/qemu-img";
+} else {
+ $qemu_img_bin_path = $ENV{'VMHELPER_QEMU_IMG_BIN_PATH'};
+}
+
sub parse_user_hdds {
return '' unless $cmd_opts{vm_hdds};
my $args = '';
@@ -348,7 +362,7 @@ my $default_img_size = "128G";
sub create_guest_img {
my $img = $_[0];
unless (-f $img) {
- my $cmd = "/usr/bin/qemu-img create";
+ my $cmd = "$qemu_img_bin_path create";
$cmd .= " -f qcow2 -o compat=1.1 -o cluster_size=65536 -o preallocation=metadata -o lazy_refcounts=on ";
$cmd .= $img . " $default_img_size";
system("$cmd >/dev/null 2>&1") == 0 or die "failed to create vm image: $?";
@@ -442,7 +456,7 @@ if ($cmd_opts{install_iso_path}) {
unless ($macaddr) {
$macaddr = get_random_macaddr();
}
- my $qemu_cmd = "/usr/bin/qemu-system-x86_64";
+ my $qemu_cmd = $qemu_bin_path;
if ($cmd_opts{windows_guest}) {
$qemu_cmd .= " $qemu_win_opts{'mach'} $qemu_win_opts{'cpu'}";
@@ -493,7 +507,7 @@ if ($cmd_opts{windows_guest}) {
setup_vm_net();
my $macaddr = get_random_macaddr();
- my $qemu_cmd = "/usr/bin/qemu-system-x86_64";
+ my $qemu_cmd = $qemu_bin_path;
$qemu_cmd .= " $qemu_win_opts{'mach'} $qemu_win_opts{'cpu'}";
$qemu_cmd .= " $qemu_win_opts{'mem'} $qemu_win_opts{'bus'}";
@@ -609,7 +623,7 @@ sub setup_shared_dirs {
umount_rootfs();
}
-my $qemu_cmd = "/usr/bin/qemu-system-x86_64";
+my $qemu_cmd = $qemu_bin_path;
$qemu_cmd .= " $qemu_linux_opts{'mach'} $qemu_linux_opts{'cpu'}";
$qemu_cmd .= " $qemu_linux_opts{'mem'} $qemu_linux_opts{'bus'}";