From patchwork Wed Mar 11 16:00:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 11432053 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 265B914B4 for ; Wed, 11 Mar 2020 16:02:40 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F37AE206E7 for ; Wed, 11 Mar 2020 16:02:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="Lk0inVvc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F37AE206E7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jC3nN-0003tQ-Fs; Wed, 11 Mar 2020 16:01:21 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jC3nM-0003tK-OL for xen-devel@lists.xenproject.org; Wed, 11 Mar 2020 16:01:20 +0000 X-Inumbo-ID: 898dff7e-63b1-11ea-b005-12813bfff9fa Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 898dff7e-63b1-11ea-b005-12813bfff9fa; Wed, 11 Mar 2020 16:01:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1583942477; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=fddvphNVK3C3yyVk96RtN0eGx1+Dvq4tckd/Zs2tqL0=; b=Lk0inVvchUrCfMAABS9CU4qOqdzJOWzULB44Y9e/ibx09+e907rvGk4+ lISW6BNLcd1x0YiGqSejNLfArsIwj2g9nQGmN94a9AQf24IZriYUq9YqV sV6tb1Zs+e8EAhuSpzJjPKEjP/218SB7lXd5cg8G5lfc8QUAWEeIhTgjv c=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=roger.pau@citrix.com; spf=Pass smtp.mailfrom=roger.pau@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of roger.pau@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa3.hc3370-68.iphmx.com: domain of roger.pau@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="roger.pau@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="roger.pau@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: MeoXjyiJpX9QkyeEmcPwKDpczg+c/GPzvkMOIwJwTKr9pHOwHKOOmYt1K+IK5RUoeJ9bk+dmr/ +ltO7uoRCg/8ZT9crxrAwEsCFqT/RKYeo7oWwdz2uZTrShFKwDv0hohhD8tPCqe/q+JnXxoHAP uKAP82lzexAHvFpKiKm7csxYmoPz85QG87UZiohGvdeo7B0pCVIqw/0mliruLqE8JwWzc3tUKw MxTf+d8dn4i3v2/2kY4L1C257vz8cZjfXhrCPnb8o3bsfTqV5hB9QT8CuAWxW1H0kfy/vg55n2 ldM= X-SBRS: 2.7 X-MesageID: 13761928 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,541,1574139600"; d="scan'208";a="13761928" From: Roger Pau Monne To: Date: Wed, 11 Mar 2020 17:00:18 +0100 Message-ID: <20200311160021.6075-1-roger.pau@citrix.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH OSSTEST v4 1/3] host: introduce helpers to modify hostflags X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: ian.jackson@eu.citrix.com, Roger Pau Monne Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Add a generic function to perform database changes related to a host and use it to implement set_property and and {set/remove}_flag. Signed-off-by: Roger Pau Monné --- Changes since v3: - Introduce modify_flag instead of {set/remove}_flag. - Introduce a generic modify_host helper. - Split from patch 1. --- Osstest/HostDB/Executive.pm | 33 ++++++++++++++++++++++++++++----- Osstest/HostDB/Static.pm | 7 +++++++ Osstest/TestSupport.pm | 21 ++++++++++++++++++++- 3 files changed, 55 insertions(+), 6 deletions(-) diff --git a/Osstest/HostDB/Executive.pm b/Osstest/HostDB/Executive.pm index 7ffca6c4..a6dc4462 100644 --- a/Osstest/HostDB/Executive.pm +++ b/Osstest/HostDB/Executive.pm @@ -51,6 +51,16 @@ END } } +sub modify_host ($$$) { + my ($hd, $ho, $query) = @_; + my $blessing = intended_blessing(); + + die "Attempting to modify host with intended blessing $blessing != real" + if $blessing ne "real"; + + db_retry($dbh_tests, [qw(resources)], $query); +} + sub set_property($$$$) { my ($hd, $ho, $prop, $val) = @_; my $rmq = $dbh_tests->prepare(<execute($ho->{Name}, $prop); if (length $val) { $addq->execute($ho->{Name}, $prop, $val); @@ -90,6 +96,23 @@ END return $flags; } +sub modify_flag ($$$$) { + my ($hd, $ho, $flag, $set) = @_; + my $rmq = $dbh_tests->prepare(<prepare(<execute($ho->{Name}, $flag); + if ($set) { + $addq->execute($ho->{Name}, $flag); + } + }); +} + sub get_arch_platforms ($$$) { my ($hd, $blessing, $arch, $suite) = @_; diff --git a/Osstest/HostDB/Static.pm b/Osstest/HostDB/Static.pm index 0c6be3ee..d0669fb2 100644 --- a/Osstest/HostDB/Static.pm +++ b/Osstest/HostDB/Static.pm @@ -72,6 +72,13 @@ sub get_flags ($$) { #method return $flags; } +sub modify_flag ($$$$) { + my ($hd, $ho, $flag, $set) = @_; + + die + "Cannot modify flags in standalone mode for $ho->{Name} $flag set: $set\n"; +} + sub get_arch_platforms ($$$) { my ($hd, $blessing, $arch, $suite) = @_; diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm index f49ed529..b80e89bc 100644 --- a/Osstest/TestSupport.pm +++ b/Osstest/TestSupport.pm @@ -85,8 +85,9 @@ BEGIN { hostnamepath hostnamepath_list set_runtime_hostflag power_state power_cycle power_reboot_attempts serial_fetch_logs set_host_property + set_host_flag remove_host_flag propname_massage propname_check - hostprop_putative_record + hostprop_putative_record hostflag_putative_record get_stashed open_unique_stashfile compress_stashed dir_identify_vcs @@ -1411,6 +1412,24 @@ sub hostprop_putative_record ($$$) { store_runvar("hostprop/$ho->{Ident}/$prop", $val); } +sub set_host_flag ($$) { + my ($ho,$flag) = @_; + + $mhostdb->modify_flag($ho, $flag, 1); +} + +sub remove_host_flag ($$) { + my ($ho,$flag) = @_; + + $mhostdb->modify_flag($ho, $flag, 0); +} + +sub hostflag_putative_record ($$$) { + my ($ho, $prop, $set) = @_; + + store_runvar("hostflag/$ho->{Ident}/$prop", !!$set); +} + sub get_target_property ($$;$); sub get_target_property ($$;$) { my ($ho, $prop, $defval) = @_;