]> gitweb.fluxo.info Git - kvm-manager.git/commitdiff
more robust version comparison
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Sun, 21 May 2017 18:37:55 +0000 (14:37 -0400)
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Sun, 21 May 2017 18:37:55 +0000 (14:37 -0400)
a version of kvm like 2.4.10 would have claimed to be greater than
2.6.0 using the existing comparison.  we'll rely on dpkg's
implementation of version comparisons instead.

this does make kvm-manager more specific to debian and debian-derived
systems, but if folks who prefer other systems want to offer patches,
they would be happily accepted :)

kvm-manager

index 1747a38d48137430a99a1a6c3f45b2e9e3db7c5c..0e15c0948140a778747d0f0866a0f6fd9ad1d3fa 100755 (executable)
@@ -51,7 +51,7 @@ BRIDGE="${BRIDGE:-br0}"
 OWNERGROUP=$(groups "$OWNER" | cut -f1 -d\  )
 OWNERHOME=$(getent passwd "$OWNER" | cut -f6 -d: )
 
-kvm_version=$(kvm --version | head -n1 | sed -E 's/QEMU emulator version ([0-9.]+).*/\1/' | tr -d '.')
+kvm_version=$(kvm --version | head -n1 | sed -E 's/^QEMU emulator version ([0-9.]+).*/\1/')
 
 # Disks can be HDA, HDB, HDC, etc. For each disk, we want to detect the
 # corresponding environment variables for disk read/write restrictions
@@ -62,7 +62,7 @@ build_disk_io_params() {
   local option variable argument value
   disk_io_params=
 
-  if [ "$kvm_version" -lt "260" ]; then
+  if dpkg --compare-versions "$kvm_version" lt 2.6.0; then
     # Only supported in version 2.6.0 or above.
     return
   fi