RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2013573 - the network hook doesn't work well by "issuing shutdown" in split daemon mode
Summary: the network hook doesn't work well by "issuing shutdown" in split daemon mode
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: libvirt
Version: 9.0
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Michal Privoznik
QA Contact: Jing Qi
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-10-13 09:44 UTC by Jing Qi
Modified: 2022-05-17 13:05 UTC (History)
5 users (show)

Fixed In Version: libvirt-7.9.0-1.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-05-17 12:45:32 UTC
Type: Bug
Target Upstream Version: 7.9.0
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-99616 0 None None None 2021-10-13 09:46:55 UTC
Red Hat Product Errata RHBA-2022:2390 0 None None None 2022-05-17 12:45:58 UTC

Description Jing Qi 2021-10-13 09:44:33 UTC
Description of problem:
In split daemon mode, the network hook doesn't work well when the vm with an interface was shutdown by issuing "shutdown" command in the guest.

Version-Release number of selected component (if applicable):
libvirt-7.7.0-3.el9.x86_64 
qemu-kvm-6.1.0-3.el9.x86_64

How reproducible:
Always

Steps to Reproduce:
1. In split daemon mode, config the network hook in /etc/libvirt/hooks/network.

#!/bin/bash
echo "$0" "$@" >> /tmp/network.log
exit 0

and change the file mode - "chmod +x network"

2. Start a domain with an interface and check /tmp/network.log
/etc/libvirt/hooks/network default port-created begin -

2. Login the console of the vm and run "shutdown 0". 

3. Check the log file and there is no expected log like
/etc/libvirt/hooks/network default port-deleted begin -


Actual results:
No expected log after step2 - 
/etc/libvirt/hooks/network default port-created begin -

Expected results:
Add below log to log file - 
/etc/libvirt/hooks/network default port-deleted begin -


Additional info:

1.In split daemon mode, shutdown the vm with "virsh destroy vm", the log can be found in the file.
2.In a monolithic mode, run "shutdown 0" in the guest, the log can be found.

Comment 1 Michal Privoznik 2021-10-25 12:56:48 UTC
Yes, this is a genuine bug. The problem is that virtqemud fails to connect to virtnetworkd thus the latter doesn't run hook scripts. It's just a coincidence that the TAP device disappears (because QEMU that had it open is gone). What I'm seeing is that in qemuProcessStop() the virGetConnectNetwork() fails and it does so because virIdentityGetCurrent() in virGetConnectGeneric() returned NULL. This is understandable because this whole code runs in a separate thread (per vm thread for processing events) and thus has no identity set (identity is stored in a thread local store). Maybe setting the identity would help, but it needs to be done carefully so that the identity is not leaked when the thread exits.

Comment 2 Michal Privoznik 2021-10-25 13:26:48 UTC
Oh, my bad, the thread I'm talking about is not per VM; so we have to do something more clever.

Comment 3 Michal Privoznik 2021-10-26 10:18:00 UTC
Patches proposed upstream:

https://listman.redhat.com/archives/libvir-list/2021-October/msg01020.html

Comment 4 Michal Privoznik 2021-10-27 15:14:10 UTC
Merged upstream:

efc1ccc75b qemu: Set "qemu-event" thread identity
0c8f1aeddf virthreadpool: Allow setting identity for workers

v7.9.0-rc1-5-gefc1ccc75b

Comment 5 Jing Qi 2021-10-29 01:19:26 UTC
Using upstream libvirt v7.9.0-rc1-3-g775de86975 with the above patch &qemu-6.1.0-9.fc36.x86_64

1. In split daemon mode, config the network hook in /etc/libvirt/hooks/network.

#!/bin/bash
echo "$0" "$@" >> /tmp/network.log
exit 0

and change the file mode - "chmod +x network"

2. Start a domain with an interface and check /tmp/network.log
/etc/libvirt/hooks/network default port-created begin -

3. Login the console of the vm and run "shutdown 0". 

4. Check the log file and the below expected log is recorded
/etc/libvirt/hooks/network default port-deleted begin -

Comment 8 Jing Qi 2021-11-12 02:23:32 UTC
Verified with libvirt-7.9.0-1.el9.x86_64 & qemu-kvm-6.1.0-6.el9.x86_64
Steps are the same as comments 5.

Comment 10 errata-xmlrpc 2022-05-17 12:45:32 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (new packages: libvirt), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:2390


Note You need to log in before you can comment on or make changes to this bug.