a4664a8242893e7332fbb561b984d9148cb958eb
[libguestfs.git] / df / virt-df.pl
1 #!/usr/bin/perl -w
2 # virt-df
3 # Copyright (C) 2009 Red Hat Inc.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 use warnings;
20 use strict;
21
22 use Sys::Guestfs;
23 use Sys::Guestfs::Lib qw(open_guest get_partitions resolve_windows_path
24   inspect_all_partitions inspect_partition
25   inspect_operating_systems mount_operating_system inspect_in_detail);
26 use Pod::Usage;
27 use Getopt::Long;
28 use Data::Dumper;
29 use File::Temp qw/tempdir/;
30 use XML::Writer;
31
32 =encoding utf8
33
34 =head1 NAME
35
36 virt-df - Display free space on virtual filesystems
37
38 =head1 SYNOPSIS
39
40  virt-df [--options]
41
42  virt-df [--options] guest [guest ...]
43
44  virt-df [--options] disk.img [disk.img ...]
45
46 =head1 DESCRIPTION
47
48
49
50
51
52
53 =head1 OPTIONS
54
55 =over 4
56
57 =cut
58
59 my $help;
60
61 =item B<--help>
62
63 Display brief help.
64
65 =cut
66
67 my $uri;
68
69 =item B<--connect URI> | B<-c URI>
70
71 If using libvirt, connect to the given I<URI>.  If omitted,
72 then we connect to the default libvirt hypervisor.
73
74 Libvirt is only used if you specify a C<domname> on the
75 command line.  If you specify guest block devices directly,
76 then libvirt is not used at all.
77
78 =cut
79
80 GetOptions ("help|?" => \$help,
81             "connect|c=s" => \$uri,
82     ) or pod2usage (2);
83 pod2usage (1) if $help;
84 pod2usage ("$0: no image or VM names given") if @ARGV == 0;
85
86 # my $g;
87 # if ($uri) {
88 #     $g = open_guest (\@ARGV, rw => $rw, address => $uri);
89 # } else {
90 #     $g = open_guest (\@ARGV, rw => $rw);
91 # }
92
93 # $g->launch ();
94 # $g->wait_ready ();
95
96 # # List of possible filesystems.
97 # my @partitions = get_partitions ($g);
98
99 # # Now query each one to build up a picture of what's in it.
100 # my %fses =
101 #     inspect_all_partitions ($g, \@partitions,
102 #       use_windows_registry => $windows_registry);
103
104 # #print "fses -----------\n";
105 # #print Dumper(\%fses);
106
107 # my $oses = inspect_operating_systems ($g, \%fses);
108
109 # #print "oses -----------\n";
110 # #print Dumper($oses);
111
112 # # Mount up the disks and check for applications.
113
114 # my $root_dev;
115 # foreach $root_dev (sort keys %$oses) {
116 #     my $os = $oses->{$root_dev};
117 #     mount_operating_system ($g, $os);
118 #     inspect_in_detail ($g, $os);
119 #     $g->umount_all ();
120 # }
121
122 =head1 SEE ALSO
123
124 L<virt-inspector(1)>,
125 L<guestfs(3)>,
126 L<guestfish(1)>,
127 L<Sys::Guestfs(3)>,
128 L<Sys::Guestfs::Lib(3)>,
129 L<Sys::Virt(3)>,
130 L<http://libguestfs.org/>.
131
132 For Windows registry parsing we require the C<reged> program
133 from L<http://home.eunet.no/~pnordahl/ntpasswd/>.
134
135 =head1 AUTHOR
136
137 Richard W.M. Jones L<http://et.redhat.com/~rjones/>
138
139 =head1 COPYRIGHT
140
141 Copyright (C) 2009 Red Hat Inc.
142
143 This program is free software; you can redistribute it and/or modify
144 it under the terms of the GNU General Public License as published by
145 the Free Software Foundation; either version 2 of the License, or
146 (at your option) any later version.
147
148 This program is distributed in the hope that it will be useful,
149 but WITHOUT ANY WARRANTY; without even the implied warranty of
150 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
151 GNU General Public License for more details.
152
153 You should have received a copy of the GNU General Public License
154 along with this program; if not, write to the Free Software
155 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.