Skip to contentSkip to conversation

mg-host: Prepare $checkhostq only if needed

PATCH New Ian Jackson 1 participant 1 message Sep 1, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mg-host: Prepare $checkhostq only if needed

This is helpful because in standalone mode there is no resources table and this fails. But we want people to use `mg-hosts power' in standalone mode, if they can, rather than running ./msu-pdu ad-hoc (or whatever).

---
 mg-hosts | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
mg-hosts +5 -3
index 5cdece5..b62e430 100755
@@ -99,12 +99,14 @@ use File::Basename;
 
 csreadconfig();
 
-our $checkhostq = $dbh_tests->prepare(<<END);
-    SELECT * FROM resources WHERE restype='host' AND resname=?
-END
+our $checkhostq;
 
 sub checkhost ($) {
     my ($host) = @_;
+
+    $checkhostq //= $dbh_tests->prepare(<<END);
+    SELECT * FROM resources WHERE restype='host' AND resname=?
+END
     $checkhostq->execute($host);
     my $row = $checkhostq->fetchrow_hashref();
     die "$host ?" unless $row;
Signature · 7 lines
2.1.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel