diff --git a/SOURCES/0030-RHEL-7-o-rhv-upload-Use-Python-2-instead-of-Python-3.patch b/SOURCES/0030-RHEL-7-o-rhv-upload-Use-Python-2-instead-of-Python-3.patch
index c9b9945..0a0b33a 100644
--- a/SOURCES/0030-RHEL-7-o-rhv-upload-Use-Python-2-instead-of-Python-3.patch
+++ b/SOURCES/0030-RHEL-7-o-rhv-upload-Use-Python-2-instead-of-Python-3.patch
@@ -1,16 +1,17 @@
-From 6ac10b37563221ca9974439a80b3b02329b60e8d Mon Sep 17 00:00:00 2001
+From 2c47e8f0329a210d26083c7ea7fd14a5553f70b1 Mon Sep 17 00:00:00 2001
 From: "Richard W.M. Jones" <rjones@redhat.com>
-Date: Fri, 9 Mar 2018 12:15:44 +0000
+Date: Mon, 22 Jul 2019 13:32:54 +0200
 Subject: [PATCH] RHEL 7: -o rhv-upload: Use Python 2 instead of Python 3.
 
+[Pino: few additional bits edited by me]
 ---
  v2v/output_rhv_upload.ml      |  2 +-
  v2v/python_script.ml          |  2 +-
- v2v/rhv-upload-createvm.py    | 20 ++++++++++++++++----
- v2v/rhv-upload-plugin.py      | 35 ++++++++++++++++++++++++-----------
- v2v/rhv-upload-precheck.py    | 22 +++++++++++++++++-----
+ v2v/rhv-upload-createvm.py    | 20 ++++++++++++---
+ v2v/rhv-upload-plugin.py      | 46 +++++++++++++++++++++++------------
+ v2v/rhv-upload-precheck.py    | 22 +++++++++++++----
  v2v/test-v2v-python-syntax.sh |  2 +-
- 6 files changed, 60 insertions(+), 23 deletions(-)
+ 6 files changed, 67 insertions(+), 27 deletions(-)
 
 diff --git a/v2v/output_rhv_upload.ml b/v2v/output_rhv_upload.ml
 index 3d6d99008..051ce086f 100644
@@ -83,7 +84,7 @@ index 1d0e8c95d..3f2fae4c6 100644
  # What is passed in is a password file, read the actual password.
  with open(params['output_password'], 'r') as fp:
 diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py
-index b63d127f5..a7fb88dd3 100644
+index b63d127f5..2e8486848 100644
 --- a/v2v/rhv-upload-plugin.py
 +++ b/v2v/rhv-upload-plugin.py
 @@ -1,5 +1,6 @@
@@ -94,7 +95,7 @@ index b63d127f5..a7fb88dd3 100644
  # Copyright (C) 2018 Red Hat Inc.
  #
  # This program is free software; you can redistribute it and/or modify
-@@ -16,7 +17,7 @@
+@@ -16,16 +17,17 @@
  # with this program; if not, write to the Free Software Foundation, Inc.,
  # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  
@@ -103,9 +104,10 @@ index b63d127f5..a7fb88dd3 100644
  import json
  import logging
  import socket
-@@ -24,8 +25,8 @@ import ssl
+ import ssl
  import sys
  import time
++import errno
  
 -from http.client import HTTPSConnection, HTTPConnection
 -from urllib.parse import urlparse
@@ -114,7 +116,7 @@ index b63d127f5..a7fb88dd3 100644
  
  import ovirtsdk4 as sdk
  import ovirtsdk4.types as types
-@@ -37,14 +38,25 @@ timeout = 5*60
+@@ -37,14 +39,25 @@ timeout = 5*60
  # Parameters are passed in via a JSON doc from the OCaml code.
  # Because this Python code ships embedded inside virt-v2v there
  # is no formal API here.
@@ -142,7 +144,7 @@ index b63d127f5..a7fb88dd3 100644
      else:
          raise RuntimeError("unknown configuration key '%s'" % key)
  
-@@ -54,13 +66,14 @@ def config_complete():
+@@ -54,13 +67,14 @@ def config_complete():
  
  def debug(s):
      if params['verbose']:
@@ -159,7 +161,7 @@ index b63d127f5..a7fb88dd3 100644
              vdsm_id = f.readline().strip()
      except Exception as e:
          # This is most likely not an oVirt host.
-@@ -111,7 +124,7 @@ def open(readonly):
+@@ -111,7 +125,7 @@ def open(readonly):
      username = parsed.username or "admin@internal"
  
      # Read the password from file.
@@ -168,7 +170,7 @@ index b63d127f5..a7fb88dd3 100644
          password = fp.read()
      password = password.rstrip()
  
-@@ -244,7 +257,7 @@ def open(readonly):
+@@ -244,7 +258,7 @@ def open(readonly):
          # New imageio never needs authentication.
          needs_auth = False
  
@@ -177,7 +179,31 @@ index b63d127f5..a7fb88dd3 100644
          can_flush = "flush" in j['features']
          can_trim = "trim" in j['features']
          can_zero = "zero" in j['features']
-@@ -533,7 +546,7 @@ def close(h):
+@@ -369,8 +383,9 @@ def pwrite(h, buf, offset):
+ 
+     try:
+         http.send(buf)
+-    except BrokenPipeError:
+-        pass
++    except EnvironmentError as e:
++        if e.errno != errno.EPIPE:
++            raise
+ 
+     r = http.getresponse()
+     if r.status != 200:
+@@ -432,8 +447,9 @@ def emulate_zero(h, count, offset):
+                 http.send(buf)
+                 count -= len(buf)
+             http.send(memoryview(buf)[:count])
+-        except BrokenPipeError:
+-            pass
++        except EnvironmentError as e:
++            if e.errno != errno.EPIPE:
++                raise
+ 
+         r = http.getresponse()
+         if r.status != 200:
+@@ -533,7 +549,7 @@ def close(h):
              pass
  
          # Write the disk ID file.  Only do this on successful completion.
diff --git a/SOURCES/0031-RHEL-7-v2v-rhv-upload-Disable-Nagle-algorithm.patch b/SOURCES/0031-RHEL-7-v2v-rhv-upload-Disable-Nagle-algorithm.patch
index 2edab1e..d778d27 100644
--- a/SOURCES/0031-RHEL-7-v2v-rhv-upload-Disable-Nagle-algorithm.patch
+++ b/SOURCES/0031-RHEL-7-v2v-rhv-upload-Disable-Nagle-algorithm.patch
@@ -1,4 +1,4 @@
-From 171a127e9b67baa841462875ec2f37f0bec0132e Mon Sep 17 00:00:00 2001
+From 7e37aba0cce21ad9abdf742528e605fa1cbc2e5e Mon Sep 17 00:00:00 2001
 From: Nir Soffer <nirsof@gmail.com>
 Date: Fri, 15 Jun 2018 22:57:32 +0300
 Subject: [PATCH] RHEL 7: v2v: rhv-upload: Disable Nagle algorithm
@@ -39,19 +39,19 @@ This change is needed only for python 2.
  1 file changed, 13 insertions(+), 1 deletion(-)
 
 diff --git a/v2v/rhv-upload-plugin.py b/v2v/rhv-upload-plugin.py
-index a7fb88dd3..566b2ba9a 100644
+index 2e8486848..9e71021ea 100644
 --- a/v2v/rhv-upload-plugin.py
 +++ b/v2v/rhv-upload-plugin.py
-@@ -25,7 +25,7 @@ import ssl
- import sys
+@@ -26,7 +26,7 @@ import sys
  import time
+ import errno
  
 -from httplib import HTTPSConnection, HTTPConnection
 +from httplib import HTTPSConnection as _HTTPSConnection, HTTPConnection
  from urlparse import urlparse
  
  import ovirtsdk4 as sdk
-@@ -51,6 +51,18 @@ def byteify(input):
+@@ -52,6 +52,18 @@ def byteify(input):
          return input
  params = None
  
diff --git a/SOURCES/0032-RHEL-7-p2v-ignore-rhv-upload-driver-RHBZ-1590220.patch b/SOURCES/0032-RHEL-7-p2v-ignore-rhv-upload-driver-RHBZ-1590220.patch
index c773177..6293d25 100644
--- a/SOURCES/0032-RHEL-7-p2v-ignore-rhv-upload-driver-RHBZ-1590220.patch
+++ b/SOURCES/0032-RHEL-7-p2v-ignore-rhv-upload-driver-RHBZ-1590220.patch
@@ -1,4 +1,4 @@
-From bfc01eca10288a26ecc50f0efd0fb6426322407b Mon Sep 17 00:00:00 2001
+From 5cbc97ddb60a8767ff4bc19a968ef325d364a865 Mon Sep 17 00:00:00 2001
 From: Pino Toscano <ptoscano@redhat.com>
 Date: Thu, 19 Jul 2018 13:30:17 +0200
 Subject: [PATCH] RHEL 7: p2v: ignore 'rhv-upload' driver (RHBZ#1590220)
diff --git a/SOURCES/0033-RHEL-7-point-to-KB-for-supported-v2v-hypervisors-gue.patch b/SOURCES/0033-RHEL-7-point-to-KB-for-supported-v2v-hypervisors-gue.patch
index 6862412..96c6fd7 100644
--- a/SOURCES/0033-RHEL-7-point-to-KB-for-supported-v2v-hypervisors-gue.patch
+++ b/SOURCES/0033-RHEL-7-point-to-KB-for-supported-v2v-hypervisors-gue.patch
@@ -1,4 +1,4 @@
-From bcacd972ad9bd4713e5d8f8e32cdca7f28be670e Mon Sep 17 00:00:00 2001
+From 5aa79a014464020380e75fdabd945dcd722b9ffe Mon Sep 17 00:00:00 2001
 From: Pino Toscano <ptoscano@redhat.com>
 Date: Tue, 26 Mar 2019 09:42:25 +0100
 Subject: [PATCH] RHEL 7: point to KB for supported v2v hypervisors/guests
diff --git a/SPECS/libguestfs.spec b/SPECS/libguestfs.spec
index ee5fa78..8d9ef48 100644
--- a/SPECS/libguestfs.spec
+++ b/SPECS/libguestfs.spec
@@ -21,7 +21,7 @@ Summary:       Access and modify virtual machine disk images
 Name:          libguestfs
 Epoch:         1
 Version:       1.40.2
-Release:       5%{?dist}
+Release:       5%{?dist}.1
 License:       LGPLv2+
 
 # Source and patches.
@@ -1289,6 +1289,11 @@ install -m 0644 utils/boot-benchmark/boot-benchmark.1 $RPM_BUILD_ROOT%{_mandir}/
 
 
 %changelog
+* Mon Jul 22 2019 Pino Toscano <ptoscano@redhat.com> - 1:1.40.2-5.el7_7.1
+- v2v: fix a couple of Python 2 porting issues in the nbdkit Python script
+  for 'rhv-upload'
+  resolves: rhbz#1726168
+
 * Tue Jun 04 2019 Pino Toscano <ptoscano@redhat.com> - 1:1.40.2-5
 - Rebase to libguestfs 1.40.2 in RHEL 7.7.
   resolves: rhbz#1621895