[pve-devel] [PATCH qemu-server 2/2] kvm_user_version: update code to use our framework

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Feb 25 14:47:17 CET 2016


Replace backticks with run_command and also do not use
`kvm -help` which produces a lot of unecessary output, lets use
`kvm -version` instead.
---
 PVE/QemuServer.pm | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index bd9cf45..cc37194 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -883,11 +883,14 @@ sub kvm_user_version {
 
     $kvm_user_version = 'unknown';
 
-    my $tmp = `kvm -help 2>/dev/null`;
+    my $code = sub {
+	my $line = shift;
+	if ($line =~ m/^QEMU( PC)? emulator version (\d+\.\d+(\.\d+)?)(\.\d+)?[,\s]/) {
+	    $kvm_user_version = $2;
+	}
+    };
 
-    if ($tmp =~ m/^QEMU( PC)? emulator version (\d+\.\d+(\.\d+)?)(\.\d+)?[,\s]/) {
-	$kvm_user_version = $2;
-    }
+    run_command("kvm -version", outfunc => $code);
 
     return $kvm_user_version;
 
-- 
2.1.4





More information about the pve-devel mailing list