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

Wolfgang Bumiller w.bumiller at proxmox.com
Wed Oct 24 10:56:37 CEST 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 933f54f..6c95623 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -1302,19 +1302,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