[libvirt] [PATCH] libvirt-tck: Ignore SIGPIPE in 051-daemon-hook.t

This test completes successfully, but results in a return code of 141 due to a broken pipe when restarting libvirtd. This patch just masks the SIGPIPE and undefines $tck to avoid the 141 return code. If there is a way to reestablish the tck connection after the restart, that would be a better solution. --- scripts/hooks/051-daemon-hook.t | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/hooks/051-daemon-hook.t b/scripts/hooks/051-daemon-hook.t index 165cf4e..a6c3d03 100644 --- a/scripts/hooks/051-daemon-hook.t +++ b/scripts/hooks/051-daemon-hook.t @@ -163,5 +163,10 @@ SKIP: { ok(`service libvirtd status` =~ /running/, "libvirtd is running"); $hook->cleanup(); + + # Restarting libvirtd broke the tck connection, so ignore sigpipe and + # undefine $tck to avoid a return code of 141 + $SIG{PIPE} = 'IGNORE'; + undef $tck; }; -- 1.8.4.5

On 07/03/14 01:11, Mike Latimer wrote:
This test completes successfully, but results in a return code of 141 due to a broken pipe when restarting libvirtd. This patch just masks the SIGPIPE and undefines $tck to avoid the 141 return code. If there is a way to reestablish the tck connection after the restart, that would be a better solution.
--- scripts/hooks/051-daemon-hook.t | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/scripts/hooks/051-daemon-hook.t b/scripts/hooks/051-daemon-hook.t index 165cf4e..a6c3d03 100644 --- a/scripts/hooks/051-daemon-hook.t +++ b/scripts/hooks/051-daemon-hook.t @@ -163,5 +163,10 @@ SKIP: { ok(`service libvirtd status` =~ /running/, "libvirtd is running");
$hook->cleanup(); + + # Restarting libvirtd broke the tck connection, so ignore sigpipe and + # undefine $tck to avoid a return code of 141 + $SIG{PIPE} = 'IGNORE'; + undef $tck;
We should get the libvirt "connection" closed before restarting libvirtd, in tck, it should be "$tck->cleanup()". Regards, Osier

On Friday, March 07, 2014 05:16:48 PM Osier Yang wrote:
$hook->cleanup(); + + # Restarting libvirtd broke the tck connection, so ignore sigpipe and + # undefine $tck to avoid a return code of 141 + $SIG{PIPE} = 'IGNORE'; + undef $tck;
We should get the libvirt "connection" closed before restarting libvirtd, in tck, it should be "$tck->cleanup()".
I should have stated in the original email that "$tck->cleanup()" does not help here. With just "$tck->cleanup()" after "$hook->cleanup()", the test still exists with a return code of 141. If I add the code to ignore the SIGPIPE, the test ends with the following messages: libvirt error code: 38, message: Cannot write data: Broken pipe libvirt error code: 1, message: internal error: client socket is closed If the test restarts libvirtd (using `service libvirtd restart`), the only way I can get it to end with an exit code of 0 is to undefine $tck. If you have any other ideas, I'd be happy to test them... -Mike

On 07/03/14 23:46, Mike Latimer wrote:
On Friday, March 07, 2014 05:16:48 PM Osier Yang wrote:
$hook->cleanup(); + + # Restarting libvirtd broke the tck connection, so ignore sigpipe and + # undefine $tck to avoid a return code of 141 + $SIG{PIPE} = 'IGNORE'; + undef $tck;
We should get the libvirt "connection" closed before restarting libvirtd, in tck, it should be "$tck->cleanup()". I should have stated in the original email that "$tck->cleanup()" does not help here. With just "$tck->cleanup()" after "$hook->cleanup()", the test still exists with a return code of 141. If I add the code to ignore the SIGPIPE, the test ends with the following messages:
libvirt error code: 38, message: Cannot write data: Broken pipe libvirt error code: 1, message: internal error: client socket is closed
If the test restarts libvirtd (using `service libvirtd restart`), the only way I can get it to end with an exit code of 0 is to undefine $tck.
Hm, $tck->cleanup() doesn't close the connection, it just destroy and undefine the existing domains, networks, and pools. <snip> sub reset { my $self = shift; my $conn = shift || $self->conn; $self->reset_domains($conn); $self->reset_networks($conn); $self->reset_storage_pools($conn); } sub cleanup { my $self = shift; foreach my $conn (@{$self->{conns}}) { $self->reset($conn); } delete $self->{conns}; } </snip> So it looks like we need a new helper to close the connection. Osier

Sorry for the slow response, I've been distracted with other projects. On Monday, March 10, 2014 09:25:37 PM Osier Yang wrote:
Hm, $tck->cleanup() doesn't close the connection, it just destroy and undefine the existing domains, networks, and pools.
<snip> sub reset { my $self = shift; my $conn = shift || $self->conn;
$self->reset_domains($conn); $self->reset_networks($conn); $self->reset_storage_pools($conn); }
sub cleanup { my $self = shift;
foreach my $conn (@{$self->{conns}}) { $self->reset($conn); }
delete $self->{conns}; } </snip>
So it looks like we need a new helper to close the connection.
While that seems to be true, I just realized the cleanup is not actually completing. The SIGPIPE is coming from reset_domains, when $conn->list_domains is accessed. Any attempts to use $conn after stopping (and then starting) libvirtd results in the SIGPIPE. In this particular test case (051-daemon-hook.t) the only purpose for $tck and $conn is to determine the uri to prevent the test from running against xen. After that check has been made, the SIGPIPE can be avoided with the following change: diff --git a/scripts/hooks/051-daemon-hook.t b/scripts/hooks/051-daemon-hook.t index 165cf4e..63e3dbb 100644 --- a/scripts/hooks/051-daemon-hook.t +++ b/scripts/hooks/051-daemon-hook.t @@ -46,6 +46,10 @@ SKIP: { skip 12, "NOT using QEMU/LXC driver" unless $uri eq "qemu:///system" or $uri eq "lxc:///"; + # Cleanup $conn and $tck here, to avoid SIGPIPE during libvirtd stop/start + undef $conn; + $tck->cleanup(); + my $hook = Sys::Virt::TCK::Hooks->new(type => 'daemon', conf_dir => '/etc/libvirt/hooks', log_name => '/tmp/daemon.log'); -- I'm not completely sure why I have to undefine $conn prior to cleaning up $tck, but maybe this is where that new helper you mentioned would come into play. If so, can you give me a pointer on how this should look? Thanks, Mike
participants (2)
-
Mike Latimer
-
Osier Yang