From nobody Sun Feb 8 20:12:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1573571436; cv=none; d=zoho.com; s=zohoarc; b=D5vcmma16sVjGQ2Jh8BKMuzuXVmpR0GaCF4QhS+4AmNrvbcTT791FzLmvY05MoPtEKDF6ZbBvmz9xwZ98CLZyLkjZyfQ/hxA155fyTp40UGS/Kczn0e6UwmYNe8OOwq2XA9m/FXwtEj4XBDrlkx0Ke2exO8RYYMV5jwsIQd4LJY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573571436; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CAviVOr4p4TboGRMmEt4tsjHOL3FJWkY0jLf7mWfJgM=; b=mA8xt4D7hYGRgKbWBOD/i5VgZTU8h4+x2MFLTRGWzymHE6D4F4ynoHbMMIZR9UxZ4kYRALGi8W5wMY6cTyQkKNL2TEchgLe0TP0zpXL/GUM8N4Lyoxt1tlx1RcbFxyNQ1nksJUVcG+KA+HqPI5XkyXW7bogvLM3tUBgWupybYCc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 157357143620414.009211485433866; Tue, 12 Nov 2019 07:10:36 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-12-QaZqCwrTP3qGW-2KCzdG1Q-1; Tue, 12 Nov 2019 10:10:33 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 53827801E6B; Tue, 12 Nov 2019 15:10:28 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2B5F260173; Tue, 12 Nov 2019 15:10:28 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E0E994E562; Tue, 12 Nov 2019 15:10:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xACFAQ1C005261 for ; Tue, 12 Nov 2019 10:10:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id C6D0A28D1E; Tue, 12 Nov 2019 15:10:26 +0000 (UTC) Received: from ridgehead.redhat.com (unknown [10.43.2.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2AD5A816E; Tue, 12 Nov 2019 15:10:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573571435; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=CAviVOr4p4TboGRMmEt4tsjHOL3FJWkY0jLf7mWfJgM=; b=LmZBB4Gg5wwUVhld1/L1t9fN3JyejiSTzOWaRmGEUDOGCc8AP0CtQIcpwvSlxYwhr2D7U2 Gb/ddNWa6h0RwwJKOsUXiCDCYRMHcpWRbdpaLhM4ir3NR/1MbdGF0/PpEZxS6rrEp1VjRe YO3JZBIVR/C1mTFbq4GSB9xAbdukhyM= From: Erik Skultety To: libvir-list@redhat.com Date: Tue, 12 Nov 2019 16:10:18 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Erik Skultety Subject: [libvirt] [tck PATCH 1/3] hooks: Add systemd detection X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: QaZqCwrTP3qGW-2KCzdG1Q-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The hooks assume System V. On RPM-based distros, there's the initscripts package introducing the 'service' command mapping the old style syntax to the systemd format. However, we can't assume this will be the case all the time, so some kind of detection of the init system would prevent test failures originating in the hooks because of the 'service' command missing. --- lib/Sys/Virt/TCK/Hooks.pm | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/lib/Sys/Virt/TCK/Hooks.pm b/lib/Sys/Virt/TCK/Hooks.pm index 7d35072..ef3403d 100644 --- a/lib/Sys/Virt/TCK/Hooks.pm +++ b/lib/Sys/Virt/TCK/Hooks.pm @@ -48,6 +48,13 @@ sub new { return $self; } =20 +sub have_systemd { + my $rc =3D ((system "command -pv systemctl > /dev/null") >> 8) && 1; + + # shell return codes are inverted, IOW 0 is True, 1 is False + return !$rc; +} + sub log_name { my $self =3D shift; my $log_name =3D shift; @@ -70,7 +77,13 @@ sub expect_result { =20 sub libvirtd_status { my $self =3D shift; - my $status =3D `service libvirtd status`; + my $status; + + if (have_systemd()) { + $status =3D `systemctl status libvirtd`; + } else { + $status =3D `service libvirtd status`; + } =20 if ($status =3D~ /stopped|unused|inactive/) { $self->{libvirtd_status} =3D 'stopped'; @@ -238,10 +251,17 @@ sub cleanup { sub service_libvirtd { my $self =3D shift; my $action =3D $self->{action}; + my $cmd; =20 truncate $self->{log_name}, 0 if -f $self->{log_name}; =20 - die "failed on $action daemon" if system "service libvirtd $action"; + if (have_systemd()) { + $cmd =3D "systemctl $action libvirtd"; + } else { + $cmd =3D "service libvirtd $action"; + } + + die "failed on $action daemon" if system $cmd; =20 $self->libvirtd_status; } --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list