[pve-devel] [PATCH v2 qemu-server 01/12] fix and simplify kvm_version()

Wolfgang Bumiller w.bumiller at proxmox.com
Mon Nov 12 14:10:33 CET 2018


This was never actually used, but we want to use it as
alternative to checking /proc/cpuinfo for 'hvm' on ARM.

Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
 PVE/QemuServer.pm | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 199cf46..ba5511c 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -1331,19 +1331,15 @@ for (my $i = 0; $i < $MAX_UNUSED_DISKS; $i++)  {
 my $kvm_api_version = 0;
 
 sub kvm_version {
-
     return $kvm_api_version if $kvm_api_version;
 
-    my $fh = IO::File->new("</dev/kvm") ||
-	return 0;
+    open my $fh, '<', '/dev/kvm'
+	or return undef;
 
-    if (my $v = $fh->ioctl(KVM_GET_API_VERSION(), 0)) {
-	$kvm_api_version = $v;
-    }
-
-    $fh->close();
+    # 0xae00 => KVM_GET_API_VERSION
+    $kvm_api_version = ioctl($fh, 0xae00, 0);
 
-    return  $kvm_api_version;
+    return $kvm_api_version;
 }
 
 my $kvm_user_version;
-- 
2.11.0





More information about the pve-devel mailing list