All of lore.kernel.org
 help / color / mirror / Atom feed
* [scarthgap][PATCH] libvirt: fix python3 compatibility in hook_support.py
@ 2026-06-03 16:36 Massimiliano Minella
  2026-06-10 18:28 ` Bruce Ashfield
  0 siblings, 1 reply; 2+ messages in thread
From: Massimiliano Minella @ 2026-06-03 16:36 UTC (permalink / raw)
  To: meta-virtualization; +Cc: Massimiliano Minella, Bruce Ashfield

From: Massimiliano Minella <massimiliano.minella@se.com>

By default Popen expects all the streams to be bytes-like objects but,
in the Popen.communicate() function call, the "input" argument is a
string, making the call fail with the error:

qemu hook error: a bytes-like object is required, not 'str'

Fix the error by setting text mode to True in the subprocess creation.

Also fix the "SyntaxWarning: invalid escape sequence '\w'" in the regex
used to match script names.

Signed-off-by: Massimiliano Minella <massimiliano.minella@se.com>
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
(cherry picked from commit fb1d9123351c86d7804e78e1518788913fb7c672)

Signed-off-by: Massimiliano Minella <massimiliano.minella@se.com>
---
 recipes-extended/libvirt/libvirt/hook_support.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/recipes-extended/libvirt/libvirt/hook_support.py b/recipes-extended/libvirt/libvirt/hook_support.py
index 7c5e2a94..63e78b79 100755
--- a/recipes-extended/libvirt/libvirt/hook_support.py
+++ b/recipes-extended/libvirt/libvirt/hook_support.py
@@ -35,7 +35,7 @@ def main():
 			stdin_save = sys.stdin.readlines()
 		# Match the name name of the hook + a dash + atleast
 		# one alpha-numeric character.
-		matcher = re.compile( "%s-\w+" % hook_name )
+		matcher = re.compile( rf"%s-\w+" % hook_name )
 		for file_name in sorted( os.listdir( hook_dir ) ):
 			file_path = os.path.join( hook_dir, file_name )
 			if matcher.match( file_name ) \
@@ -43,7 +43,7 @@ def main():
 			   and os.path.isfile( file_path ) \
 			   and return_value == 0:
 				cmd = [ file_path ] + hook_args
-				p = subprocess.Popen( cmd, stdin=subprocess.PIPE )
+				p = subprocess.Popen( cmd, stdin=subprocess.PIPE, text=True )
 				p.communicate( input = ''.join( stdin_save ) )[0]
 				return_value = p.wait()
 	except Exception as e:

---
base-commit: 89da4f56b4c510059f8dc1527d289d9fd4fef133
change-id: 20260519-backport_fix_libvirt_hook_script-7f72b9a18d7c

Best regards,
--  
Massimiliano Minella <massimiliano.minella@se.com>



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [scarthgap][PATCH] libvirt: fix python3 compatibility in hook_support.py
  2026-06-03 16:36 [scarthgap][PATCH] libvirt: fix python3 compatibility in hook_support.py Massimiliano Minella
@ 2026-06-10 18:28 ` Bruce Ashfield
  0 siblings, 0 replies; 2+ messages in thread
From: Bruce Ashfield @ 2026-06-10 18:28 UTC (permalink / raw)
  To: massimiliano.minella; +Cc: meta-virtualization, massimiliano.minella

Merged into scarthgap as 9d0007a3.

Thanks for picking up the master backport.

Bruce


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-10 18:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-03 16:36 [scarthgap][PATCH] libvirt: fix python3 compatibility in hook_support.py Massimiliano Minella
2026-06-10 18:28 ` Bruce Ashfield

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.