+my $uuid = $dom->get_uuid_string ();
+
+undef $dom;
+undef $conn;
+
+# See if the UUID exists in the cache already.
+print STDERR "checking for UUID $uuid in the cache directory\n" if $verbose;
+
+my $cachedir = "@localstatedir@/lib/virt-tools/keys";
+if (-r "$cachedir/$uuid") {
+ print STDERR "$cachedir/$uuid exists, returning contents\n" if $verbose;
+ open FILE, "$cachedir/$uuid" or die "$cachedir/$uuid: $!";
+ my $key = <FILE>;
+ chomp $key;
+ close FILE;
+ print $key, "\n";
+ exit 0;
+}
+
+print STDERR "$cachedir/$uuid not found, looking inside guest\n" if $verbose;
+