Allow guestfish -i / virt-inspector on live domains, in limited circumstances.
authorRichard W.M. Jones <rjones@redhat.com>
Wed, 24 Jun 2009 19:10:53 +0000 (20:10 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Wed, 24 Jun 2009 19:10:53 +0000 (20:10 +0100)
inspector/virt-inspector.pl

index 6aa63ad..28bee77 100755 (executable)
@@ -222,6 +222,13 @@ if (-e $ARGV[0]) {
     die "cannot connect to libvirt $uri\n" unless $vmm;
 
     my @doms = $vmm->list_defined_domains ();
     die "cannot connect to libvirt $uri\n" unless $vmm;
 
     my @doms = $vmm->list_defined_domains ();
+    my $isitinactive = "an inactive libvirt domain";
+    if ($output ne "fish") {
+       # In the special case where we want read-only access to
+       # a domain, allow the user to specify an active domain too.
+       push @doms, $vmm->list_domains ();
+       $isitinactive = "a libvirt domain";
+    }
     my $dom;
     foreach (@doms) {
        if ($_->get_name () eq $ARGV[0]) {
     my $dom;
     foreach (@doms) {
        if ($_->get_name () eq $ARGV[0]) {
@@ -229,8 +236,7 @@ if (-e $ARGV[0]) {
            last;
        }
     }
            last;
        }
     }
-    die "$ARGV[0] is not the name of an inactive libvirt domain\n"
-       unless $dom;
+    die "$ARGV[0] is not the name of $isitinactive\n" unless $dom;
 
     # Get the names of the image(s).
     my $xml = $dom->get_xml_description ();
 
     # Get the names of the image(s).
     my $xml = $dom->get_xml_description ();