Bug 2178553

Summary: Should show complete error info if hotplugging passt backend interface failed
Product: Red Hat Enterprise Linux 9 Reporter: yafu <yafu>
Component: libvirtAssignee: Michal Privoznik <mprivozn>
libvirt sub component: Networking QA Contact: yalzhang <yalzhang>
Status: CLOSED DUPLICATE Docs Contact:
Severity: low    
Priority: low CC: lmen, mprivozn, virt-maint, yalzhang
Version: 9.2   
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-03-23 13:57:46 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description yafu 2023-03-15 09:08:39 UTC
Description of problem:
Should show complete error info if hotplugging passt backend interface failed

Version-Release number of selected component (if applicable):
libvirt-9.0.0-8.el9_2.x86_64
qemu-kvm-7.2.0-12.el9_2.x86_64

How reproducible:
100%

Steps to Reproduce:
1.Prepare a passt backend interface xml with non-existing logFile dir:
#cat passt-0.xml
$ cat passt-0.xml 
<interface type="user">
  <mac address="52:54:00:bc:fa:5e"/>
  <source dev="br0"/>
  <model type="virtio"/>
  <backend type="passt" logFile="/home/test2/passt.log"/>
  <alias name="net0"/>
</interface>

$ ll /home/test2
ls: cannot access '/home/test2': No such file or directory

2.Hotplug the passt backend interface to a running guest:
$ virsh attach-device test passt-0.xml 
error: Failed to attach device from passt-0.xml
error: internal error: Failed to start passt

3.

Actual results:
The error info does not show the reason of starting passt failed.

Expected results:
Show complete error info if hotplugging passt backend interface failed, such as:
$ virsh attach-device test passt-0.xml 
error: Failed to attach device from passt-0.xml
error: internal error: Failed to start passt: Couldn't open log file /home/test2/passt.log: No such file or directory


Additional info:
1.Could show complete error info if starting guest with passt backend interface failed:
$ virsh start test
error: Failed to start domain 'test'
error: internal error: Could not start 'passt': Couldn't open log file /home/test2/passt.log: No such file or directory

Comment 1 Michal Privoznik 2023-03-23 13:54:06 UTC
Fixed by the following commit:

commit 02355840ced2af18df1aa9ba387a6137a515eede
Author:     Michal Prívozník <mprivozn>
AuthorDate: Thu Feb 16 12:19:26 2023 +0100
Commit:     Michal Prívozník <mprivozn>
CommitDate: Mon Feb 20 09:43:14 2023 +0100

    qemu_passt: Report passt's error on failed start
    
    When starting passt, it may write something onto its stderr
    (convincing it to print even more is addressed later). Pass this
    string we read to user.
    
    Since we're not daemonizing passt anymore (see previous commit),
    we can let virCommand module do all the heavy lifting and switch
    to virCommandSetErrorBuffer() instead of reading error from an
    FD.
    
    Signed-off-by: Michal Privoznik <mprivozn>
    Reviewed-by: Stefano Brivio <sbrivio>
    Reviewed-by: Laine Stump <laine>

which is part of libvirt-9.1.0 release.

Comment 4 yalzhang@redhat.com 2023-04-25 10:02:32 UTC
Test on libvirt-9.2.0-1.el9.x86_64 with the same scenarios in comment 0, the bug is fixed:

1) no permission to create the log file:
$ cat interface.xml
<interface type="user">
  <mac address="52:54:00:bc:fa:5e"/>
  <source dev="eno1"/>
  <model type="virtio"/>
  <backend type="passt" logFile='/var/log/test.log'/>
  <alias name="net0"/>
</interface>

$ virsh attach-device vm1 interface.xml 
error: Failed to attach device from interface.xml
error: internal error: Child process (/usr/bin/passt --one-off --socket /run/user/1000/libvirt/qemu/run/passt/1-vm1-net0.socket --mac-addr 52:54:00:bc:fa:5e --pid /run/user/1000/libvirt/qemu/run/passt/1-vm1-net0-passt.pid --interface eno1 --log-file /var/log/test.log) unexpected exit status 1: Couldn't open log file /var/log/test.log: Permission denied

2) no log dir:
$ cat interface1.xml 
<interface type="user">
  <mac address="52:54:00:bc:fa:5e"/>
  <source dev="eno1"/>
  <model type="virtio"/>
  <backend type="passt" logFile='/var/no_dir/test.log'/>
  <alias name="net0"/>
</interface>

$ virsh attach-device vm1 interface1.xml 
error: Failed to attach device from interface1.xml
error: internal error: Child process (/usr/bin/passt --one-off --socket /run/user/1000/libvirt/qemu/run/passt/1-vm1-net0.socket --mac-addr 52:54:00:bc:fa:5e --pid /run/user/1000/libvirt/qemu/run/passt/1-vm1-net0-passt.pid --interface eno1 --log-file /var/no_dir/test.log) unexpected exit status 1: Couldn't open log file /var/no_dir/test.log: No such file or directory