[Libguestfs] [PATCH disk-sync 4/5] Require libnbd >= 0.9.8 and fail hard if it's an earlier version.

Richard W.M. Jones rjones at redhat.com
Thu Aug 22 14:39:34 UTC 2019


This was the first version with the stable API and all the fixes
required to make the Python bindings not crash when used
asynchronously.
---
 wrapper/disk_sync.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/wrapper/disk_sync.py b/wrapper/disk_sync.py
index e830193..e655ead 100644
--- a/wrapper/disk_sync.py
+++ b/wrapper/disk_sync.py
@@ -4,6 +4,8 @@ from pyVmomi import vim
 from pyVim.connect import SmartConnect, Disconnect
 from pyVim.task import WaitForTask
 
+from packaging import version
+
 import nbd
 
 from six.moves.urllib.parse import urlparse, unquote
@@ -15,6 +17,8 @@ import ssl
 import sys
 import json
 
+NBD_MIN_VERSION = version.parse("0.9.8")
+
 LOG_FORMAT_TIME = '[%(asctime)s] '
 LOG_FORMAT_MSG = ': %(message)s'
 
@@ -582,6 +586,13 @@ def main():
     '''TODO: Add some description here '''
 
     args = parse_args()
+
+    nbd_version = version.parse(nbd.NBD().get_version())
+    if nbd_version < NBD_MIN_VERSION:
+        logging.error("version on libnbd is too old.  Version found = %s.  Min version required = %s" %
+                      (nbd_version, NBD_MIN_VERSION))
+        sys.exit(1)
+
     state = State(args).instance
     validate_state(args.sync_type)
     parse_input(args)
-- 
2.22.0




More information about the Libguestfs mailing list