* [PATCH RESEND] libvirt: fix python3 compatibility in hook_support.py
@ 2026-05-04 9:31 ` Massimiliano Minella via B4 Relay
0 siblings, 0 replies; 3+ messages in thread
From: Massimiliano Minella @ 2026-05-04 9:31 UTC (permalink / raw)
To: meta-virtualization; +Cc: Massimiliano Minella
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>
---
recipes-extended/libvirt/libvirt/hook_support.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git recipes-extended/libvirt/libvirt/hook_support.py recipes-extended/libvirt/libvirt/hook_support.py
index 7c5e2a94..63e78b79 100755
--- recipes-extended/libvirt/libvirt/hook_support.py
+++ 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: 28d26fd95397bf575e65fcca0cbb302b1e9bc7ff
change-id: 20260107-fix_libvirt_hook_script-c31e952080e9
Best regards,
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEEmyckwKYPNcpMkpYoTLqAMKbmymMFAmleiv0ACgkQTLqAMKbm
ymMqMg//Tf36TeanEuR7dC2FhYcBCxEGl+hoG3OGpD4CJNLmUSN37aqCByV5P0kM
2Tc9JKFZr7fXTNTtkmUoiBRm+3+evDliwdQOCRhGK5Ujen2cYP1BTd8hhkHvzb3U
mswUqFOCEFeCkqt6j/dYc5JtJ//9S22sATEQ6fdUrLLoZRsCRy6we1qXK+Fmpkd0
7UdQd4WLKjFTg+mIGQ3MdEGI9TP5+EcLHziKhb6AnLZ0S0ejV3xdjrnNDneV1yMq
xisdj3Car6N1k39+9aMWYssOUiibKeiQLz0YKJayCfoIk69QtM5bnAx7QNquroAa
fbC7jFjqnSq4yvtlBjQ5d1MuFGSHlE7RSSd6DSz+wbkte4zAFbKWushuGxS08Hf/
qYo9aSZv+ifbB1uPfH49/C3MLp7j+its2l8KTGUbHfwe9yN4IWT1F5cYgJEzeOuO
WjP8G22ym4h/82w+2C0de6eAYCNAL5BuXFaAJfxC74fb2UIn/rh6zGIn6m+EK8sp
AvclYgU1SHwWNUPzCchdSJP6twIhESHdPbMJLxSpwJVT0IYg5ONod4/lS3JFKpvI
bjpF18k0b3orSeS61KyEUiXkazDa34I9biml0TC00wW2I/13Z3c36ztamKHmUmmv
rLEfAunD20nlsbxfXCApgEMwt0OoeiueeI/BKm/9raoYqcmJvdg=
=pK58
-----END PGP SIGNATURE-----
--
Massimiliano Minella <massimiliano.minella@se.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH RESEND] libvirt: fix python3 compatibility in hook_support.py
@ 2026-05-04 9:31 ` Massimiliano Minella via B4 Relay
0 siblings, 0 replies; 3+ messages in thread
From: Massimiliano Minella via B4 Relay @ 2026-05-04 9:31 UTC (permalink / raw)
To: meta-virtualization; +Cc: Massimiliano Minella
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>
---
recipes-extended/libvirt/libvirt/hook_support.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git recipes-extended/libvirt/libvirt/hook_support.py recipes-extended/libvirt/libvirt/hook_support.py
index 7c5e2a94..63e78b79 100755
--- recipes-extended/libvirt/libvirt/hook_support.py
+++ 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: 28d26fd95397bf575e65fcca0cbb302b1e9bc7ff
change-id: 20260107-fix_libvirt_hook_script-c31e952080e9
Best regards,
-----BEGIN PGP SIGNATURE-----
iQIzBAABCgAdFiEEmyckwKYPNcpMkpYoTLqAMKbmymMFAmleiv0ACgkQTLqAMKbm
ymMqMg//Tf36TeanEuR7dC2FhYcBCxEGl+hoG3OGpD4CJNLmUSN37aqCByV5P0kM
2Tc9JKFZr7fXTNTtkmUoiBRm+3+evDliwdQOCRhGK5Ujen2cYP1BTd8hhkHvzb3U
mswUqFOCEFeCkqt6j/dYc5JtJ//9S22sATEQ6fdUrLLoZRsCRy6we1qXK+Fmpkd0
7UdQd4WLKjFTg+mIGQ3MdEGI9TP5+EcLHziKhb6AnLZ0S0ejV3xdjrnNDneV1yMq
xisdj3Car6N1k39+9aMWYssOUiibKeiQLz0YKJayCfoIk69QtM5bnAx7QNquroAa
fbC7jFjqnSq4yvtlBjQ5d1MuFGSHlE7RSSd6DSz+wbkte4zAFbKWushuGxS08Hf/
qYo9aSZv+ifbB1uPfH49/C3MLp7j+its2l8KTGUbHfwe9yN4IWT1F5cYgJEzeOuO
WjP8G22ym4h/82w+2C0de6eAYCNAL5BuXFaAJfxC74fb2UIn/rh6zGIn6m+EK8sp
AvclYgU1SHwWNUPzCchdSJP6twIhESHdPbMJLxSpwJVT0IYg5ONod4/lS3JFKpvI
bjpF18k0b3orSeS61KyEUiXkazDa34I9biml0TC00wW2I/13Z3c36ztamKHmUmmv
rLEfAunD20nlsbxfXCApgEMwt0OoeiueeI/BKm/9raoYqcmJvdg=
=pK58
-----END PGP SIGNATURE-----
--
Massimiliano Minella <massimiliano.minella@se.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [meta-virtualization] [PATCH RESEND] libvirt: fix python3 compatibility in hook_support.py
2026-05-04 9:31 ` Massimiliano Minella via B4 Relay
(?)
@ 2026-05-11 20:16 ` Bruce Ashfield
-1 siblings, 0 replies; 3+ messages in thread
From: Bruce Ashfield @ 2026-05-11 20:16 UTC (permalink / raw)
To: massimiliano.minella; +Cc: meta-virtualization, Massimiliano Minella
Still won't apply via patch:
% git am -s ~/incoming/0003-_meta-virtualization_PATCH_RESEND_libvirt_fix_python3_compatibility_in.patch
Applying: libvirt: fix python3 compatibility in hook_support.py
error: libvirt/libvirt/hook_support.py: does not exist in index
Patch failed at 0001 libvirt: fix python3 compatibility in hook_support.py
hint: Use 'git am --show-current-patch=diff' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
You are generating the patch using non-standard prefixes. I've fixed it
by using -p0
To fix it on your end, set diff.noprefix=false or omit it, or use
git format-patch without --no-prefix
But no need to resend, this is now applied.
Bruce
In message: [meta-virtualization] [PATCH RESEND] libvirt: fix python3 compatibility in hook_support.py
on 04/05/2026 Massimiliano Minella via lists.yoctoproject.org wrote:
> 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>
> ---
> recipes-extended/libvirt/libvirt/hook_support.py | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git recipes-extended/libvirt/libvirt/hook_support.py recipes-extended/libvirt/libvirt/hook_support.py
> index 7c5e2a94..63e78b79 100755
> --- recipes-extended/libvirt/libvirt/hook_support.py
> +++ 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: 28d26fd95397bf575e65fcca0cbb302b1e9bc7ff
> change-id: 20260107-fix_libvirt_hook_script-c31e952080e9
>
> Best regards,
> -----BEGIN PGP SIGNATURE-----
>
> iQIzBAABCgAdFiEEmyckwKYPNcpMkpYoTLqAMKbmymMFAmleiv0ACgkQTLqAMKbm
> ymMqMg//Tf36TeanEuR7dC2FhYcBCxEGl+hoG3OGpD4CJNLmUSN37aqCByV5P0kM
> 2Tc9JKFZr7fXTNTtkmUoiBRm+3+evDliwdQOCRhGK5Ujen2cYP1BTd8hhkHvzb3U
> mswUqFOCEFeCkqt6j/dYc5JtJ//9S22sATEQ6fdUrLLoZRsCRy6we1qXK+Fmpkd0
> 7UdQd4WLKjFTg+mIGQ3MdEGI9TP5+EcLHziKhb6AnLZ0S0ejV3xdjrnNDneV1yMq
> xisdj3Car6N1k39+9aMWYssOUiibKeiQLz0YKJayCfoIk69QtM5bnAx7QNquroAa
> fbC7jFjqnSq4yvtlBjQ5d1MuFGSHlE7RSSd6DSz+wbkte4zAFbKWushuGxS08Hf/
> qYo9aSZv+ifbB1uPfH49/C3MLp7j+its2l8KTGUbHfwe9yN4IWT1F5cYgJEzeOuO
> WjP8G22ym4h/82w+2C0de6eAYCNAL5BuXFaAJfxC74fb2UIn/rh6zGIn6m+EK8sp
> AvclYgU1SHwWNUPzCchdSJP6twIhESHdPbMJLxSpwJVT0IYg5ONod4/lS3JFKpvI
> bjpF18k0b3orSeS61KyEUiXkazDa34I9biml0TC00wW2I/13Z3c36ztamKHmUmmv
> rLEfAunD20nlsbxfXCApgEMwt0OoeiueeI/BKm/9raoYqcmJvdg=
> =pK58
> -----END PGP SIGNATURE-----
> --
> Massimiliano Minella <massimiliano.minella@se.com>
>
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#9785): https://lists.yoctoproject.org/g/meta-virtualization/message/9785
> Mute This Topic: https://lists.yoctoproject.org/mt/119139889/1050810
> Group Owner: meta-virtualization+owner@lists.yoctoproject.org
> Unsubscribe: https://lists.yoctoproject.org/g/meta-virtualization/unsub [bruce.ashfield@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-11 20:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-04 9:31 [PATCH RESEND] libvirt: fix python3 compatibility in hook_support.py Massimiliano Minella
2026-05-04 9:31 ` Massimiliano Minella via B4 Relay
2026-05-11 20:16 ` [meta-virtualization] " 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.