summaryrefslogtreecommitdiffstats
path: root/virt-df
diff options
context:
space:
mode:
authorrjones@thinkpad <rjones@thinkpad>2008-04-17 11:13:39 +0100
committerrjones@thinkpad <rjones@thinkpad>2008-04-17 11:13:39 +0100
commit5fb80987ddf0f8af6cd479964f1c5bb8340c7ba8 (patch)
tree6774d8d7c9fb2ec1b6f4b5913636f5e36af1dae2 /virt-df
parentf9d99e63272520c19bddc9e4b47731d57e5658e2 (diff)
parentf5f45d38269842b591a89ccaf2e6af7879d57aab (diff)
downloadvirt-top-5fb80987ddf0f8af6cd479964f1c5bb8340c7ba8.tar.gz
virt-top-5fb80987ddf0f8af6cd479964f1c5bb8340c7ba8.tar.xz
virt-top-5fb80987ddf0f8af6cd479964f1c5bb8340c7ba8.zip
Merge.
Diffstat (limited to 'virt-df')
-rw-r--r--virt-df/.depend10
-rw-r--r--virt-df/Makefile.in86
-rw-r--r--virt-df/README2
-rw-r--r--virt-df/virt-df.1280
-rw-r--r--virt-df/virt-df.pod174
-rw-r--r--virt-df/virt-df.txt139
-rw-r--r--virt-df/virt_df.ml505
-rwxr-xr-xvirt-df/virt_df_ext2.ml99
-rwxr-xr-xvirt-df/virt_df_linux_swap.ml40
-rwxr-xr-xvirt-df/virt_df_lvm2.ml38
-rwxr-xr-xvirt-df/virt_df_main.ml20
11 files changed, 0 insertions, 1393 deletions
diff --git a/virt-df/.depend b/virt-df/.depend
deleted file mode 100644
index 1a7750e..0000000
--- a/virt-df/.depend
+++ /dev/null
@@ -1,10 +0,0 @@
-virt_df_ext2.cmo: virt_df.cmo
-virt_df_ext2.cmx: virt_df.cmx
-virt_df_linux_swap.cmo: virt_df.cmo
-virt_df_linux_swap.cmx: virt_df.cmx
-virt_df_lvm2.cmo: virt_df.cmo
-virt_df_lvm2.cmx: virt_df.cmx
-virt_df_main.cmo: virt_df.cmo
-virt_df_main.cmx: virt_df.cmx
-virt_df.cmo: ../libvirt/libvirt_version.cmi ../libvirt/libvirt.cmi
-virt_df.cmx: ../libvirt/libvirt_version.cmx ../libvirt/libvirt.cmx
diff --git a/virt-df/Makefile.in b/virt-df/Makefile.in
deleted file mode 100644
index 1f3af53..0000000
--- a/virt-df/Makefile.in
+++ /dev/null
@@ -1,86 +0,0 @@
-# virt-df
-# Copyright (C) 2007 Red Hat Inc., Richard W.M. Jones
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-PACKAGE := @PACKAGE_NAME@
-VERSION := @PACKAGE_VERSION@
-
-INSTALL := @INSTALL@
-HAVE_PERLDOC := @HAVE_PERLDOC@
-
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-bindir = @bindir@
-
-pkg_xml_light = @pkg_xml_light@
-
-OCAMLCPACKAGES := -package unix,extlib,xml-light
-
-OBJS := virt_df.cmo \
- virt_df_ext2.cmo \
- virt_df_linux_swap.cmo \
- virt_df_lvm2.cmo \
- virt_df_main.cmo
-XOBJS := $(OBJS:.cmo=.cmx)
-
-OCAMLCPACKAGES += -I ../libvirt
-OCAMLCFLAGS := -g -w s
-OCAMLCLIBS := -linkpkg
-
-OCAMLOPTPACKAGES := $(OCAMLCPACKAGES)
-OCAMLOPTFLAGS := -w s
-OCAMLOPTLIBS := $(OCAMLCLIBS)
-
-export LIBRARY_PATH=../libvirt
-export LD_LIBRARY_PATH=../libvirt
-
-BYTE_TARGETS := virt-df
-OPT_TARGETS := virt-df.opt
-
-ifeq ($(HAVE_PERLDOC),perldoc)
-BYTE_TARGETS += virt-df.1 virt-df.txt
-endif
-
-all: $(BYTE_TARGETS)
-
-opt: $(OPT_TARGETS)
-
-virt-df: $(OBJS)
- ocamlfind ocamlc $(OCAMLCPACKAGES) $(OCAMLCFLAGS) $(OCAMLCLIBS) \
- ../libvirt/mllibvirt.cma -o $@ $^
-
-virt-df.opt: $(XOBJS)
- ocamlfind ocamlopt \
- $(OCAMLOPTPACKAGES) $(OCAMLOPTFLAGS) $(OCAMLOPTLIBS) \
- ../libvirt/mllibvirt.cmxa -o $@ $^
-
-# Manual page.
-ifeq ($(HAVE_PERLDOC),perldoc)
-virt-df.1: virt-df.pod
- pod2man -c "Virtualization Support" --release "$(PACKAGE)-$(VERSION)" \
- $< > $@
-
-virt-df.txt: virt-df.pod
- pod2text $< > $@
-endif
-
-install:
- if [ -x virt-df.opt ]; then \
- mkdir -p $(DESTDIR)$(bindir); \
- $(INSTALL) -m 0755 virt-df.opt $(DESTDIR)$(bindir)/virt-df; \
- fi
-
-include ../Make.rules
diff --git a/virt-df/README b/virt-df/README
deleted file mode 100644
index 0623030..0000000
--- a/virt-df/README
+++ /dev/null
@@ -1,2 +0,0 @@
-Please see the manual page (virt-df.pod or virt-df.txt in this
-directory). \ No newline at end of file
diff --git a/virt-df/virt-df.1 b/virt-df/virt-df.1
deleted file mode 100644
index ff7e92d..0000000
--- a/virt-df/virt-df.1
+++ /dev/null
@@ -1,280 +0,0 @@
-.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
-.\"
-.\" Standard preamble:
-.\" ========================================================================
-.de Sh \" Subsection heading
-.br
-.if t .Sp
-.ne 5
-.PP
-\fB\\$1\fR
-.PP
-..
-.de Sp \" Vertical space (when we can't use .PP)
-.if t .sp .5v
-.if n .sp
-..
-.de Vb \" Begin verbatim text
-.ft CW
-.nf
-.ne \\$1
-..
-.de Ve \" End verbatim text
-.ft R
-.fi
-..
-.\" Set up some character translations and predefined strings. \*(-- will
-.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
-.\" double quote, and \*(R" will give a right double quote. | will give a
-.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
-.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
-.\" expand to `' in nroff, nothing in troff, for use with C<>.
-.tr \(*W-|\(bv\*(Tr
-.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
-.ie n \{\
-. ds -- \(*W-
-. ds PI pi
-. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
-. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
-. ds L" ""
-. ds R" ""
-. ds C` ""
-. ds C' ""
-'br\}
-.el\{\
-. ds -- \|\(em\|
-. ds PI \(*p
-. ds L" ``
-. ds R" ''
-'br\}
-.\"
-.\" If the F register is turned on, we'll generate index entries on stderr for
-.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
-.\" entries marked with X<> in POD. Of course, you'll have to process the
-.\" output yourself in some meaningful fashion.
-.if \nF \{\
-. de IX
-. tm Index:\\$1\t\\n%\t"\\$2"
-..
-. nr % 0
-. rr F
-.\}
-.\"
-.\" For nroff, turn off justification. Always turn off hyphenation; it makes
-.\" way too many mistakes in technical documents.
-.hy 0
-.if n .na
-.\"
-.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
-.\" Fear. Run. Save yourself. No user-serviceable parts.
-. \" fudge factors for nroff and troff
-.if n \{\
-. ds #H 0
-. ds #V .8m
-. ds #F .3m
-. ds #[ \f1
-. ds #] \fP
-.\}
-.if t \{\
-. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
-. ds #V .6m
-. ds #F 0
-. ds #[ \&
-. ds #] \&
-.\}
-. \" simple accents for nroff and troff
-.if n \{\
-. ds ' \&
-. ds ` \&
-. ds ^ \&
-. ds , \&
-. ds ~ ~
-. ds /
-.\}
-.if t \{\
-. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
-. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
-. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
-. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
-. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
-. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
-.\}
-. \" troff and (daisy-wheel) nroff accents
-.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
-.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
-.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
-.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
-.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
-.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
-.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
-.ds ae a\h'-(\w'a'u*4/10)'e
-.ds Ae A\h'-(\w'A'u*4/10)'E
-. \" corrections for vroff
-.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
-.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
-. \" for low resolution devices (crt and lpr)
-.if \n(.H>23 .if \n(.V>19 \
-\{\
-. ds : e
-. ds 8 ss
-. ds o a
-. ds d- d\h'-1'\(ga
-. ds D- D\h'-1'\(hy
-. ds th \o'bp'
-. ds Th \o'LP'
-. ds ae ae
-. ds Ae AE
-.\}
-.rm #[ #] #H #V #F C
-.\" ========================================================================
-.\"
-.IX Title "VIRT-DF 1"
-.TH VIRT-DF 1 "2008-03-04" "ocaml-libvirt-0.4.0.3" "Virtualization Support"
-.SH "NAME"
-virt\-df \- 'df'\-like utility for virtualization stats
-.SH "SUMMARY"
-.IX Header "SUMMARY"
-virt-df [\-options]
-.SH "DESCRIPTION"
-.IX Header "DESCRIPTION"
-virt-df is a \fIdf\fR\|(1)\-like utility for showing the actual disk usage
-of guests. Many command line options are the same as for ordinary
-\&\fIdf\fR.
-.PP
-It uses libvirt so it is capable of showing stats across a variety of
-different virtualization systems.
-.PP
-There are some shortcomings to the whole approach of reading disk
-state from outside the guest. Please read \s-1SHORTCOMINGS\s0 section below
-for more details.
-.SH "OPTIONS"
-.IX Header "OPTIONS"
-.IP "\fB\-a\fR, \fB\-\-all\fR" 4
-.IX Item "-a, --all"
-Show all domains. The default is show only running (active) domains.
-.IP "\fB\-c uri\fR, \fB\-\-connect uri\fR" 4
-.IX Item "-c uri, --connect uri"
-Connect to libvirt \s-1URI\s0. The default is to connect to the default
-libvirt \s-1URI\s0, normally Xen.
-.IP "\fB\-h\fR, \fB\-\-human\-readable\fR" 4
-.IX Item "-h, --human-readable"
-Display human-readable sizes (eg. 10GiB).
-.IP "\fB\-i\fR, \fB\-\-inodes\fR" 4
-.IX Item "-i, --inodes"
-Display inode information.
-.IP "\fB\-\-help\fR" 4
-.IX Item "--help"
-Display usage summary.
-.IP "\fB\-\-version\fR" 4
-.IX Item "--version"
-Display version and exit.
-.SH "SHORTCOMINGS"
-.IX Header "SHORTCOMINGS"
-virt-df spies on the guest's disk image to try to work out how much
-disk space it is actually using. There are some shortcomings to this,
-described here.
-.PP
-(1) It does not work over remote connections. The storage \s-1API\s0 does
-not support peeking into remote disks, and libvirt has rejected a
-request to add this support.
-.PP
-(2) It only understands a limited set of partition types. Assuming
-that the files and partitions that we get back from libvirt / Xen
-correspond to block devices in the guests, we can go some way towards
-manually parsing those partitions to find out what they contain. We
-can read the \s-1MBR\s0, \s-1LVM\s0, superblocks and so on. However that's a lot of
-parsing work, and currently there is no library which understands a
-wide range of partition schemes and filesystem types (not even
-libparted which doesn't support \s-1LVM\s0 yet). The Linux kernel does
-support that, but there's not really any good way to access that work.
-.PP
-The current implementation uses a hand-coded parser which understands
-some simple formats (\s-1MBR\s0, \s-1LVM2\s0, ext2/3). In future we should use
-something like libparted.
-.PP
-(3) The statistics you get are delayed. The real state of, for
-example, an ext2 filesystem is only stored in the memory of the
-guest's kernel. The ext2 superblock contains some meta-information
-about blocks used and free, but this superblock is not up to date. In
-fact the guest kernel may not update it even on a 'sync', not until
-the filesystem is unmounted. Some operations do appear to write the
-superblock, for example \fIfsync\fR\|(2) [that is my reading of the ext2/3
-source code at least].
-.SH "SECURITY"
-.IX Header "SECURITY"
-The current code is probably not secure against malicious guests. In
-particular a malicious guest can set up a disk in such a way that disk
-structures with loops can cause virt-df to spin forever. We are
-preparing a parsing library which can fix these sorts of problems.
-.PP
-In the meantime, do not run virt-df on untrusted guests.
-.SH "SEE ALSO"
-.IX Header "SEE ALSO"
-\&\fIdf\fR\|(1),
-\&\fIvirsh\fR\|(1),
-\&\fIxm\fR\|(1),
-<http://www.libvirt.org/ocaml/>,
-<http://www.libvirt.org/>,
-<http://et.redhat.com/~rjones/>,
-<http://caml.inria.fr/>
-.SH "AUTHORS"
-.IX Header "AUTHORS"
-Richard W.M. Jones <rjones @ redhat . com>
-.SH "COPYRIGHT"
-.IX Header "COPYRIGHT"
-(C) Copyright 2007\-2008 Red Hat Inc., Richard W.M. Jones
-http://libvirt.org/
-.PP
-This program is free software; you can redistribute it and/or modify
-it under the terms of the \s-1GNU\s0 General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-.PP
-This program is distributed in the hope that it will be useful,
-but \s-1WITHOUT\s0 \s-1ANY\s0 \s-1WARRANTY\s0; without even the implied warranty of
-\&\s-1MERCHANTABILITY\s0 or \s-1FITNESS\s0 \s-1FOR\s0 A \s-1PARTICULAR\s0 \s-1PURPOSE\s0. See the
-\&\s-1GNU\s0 General Public License for more details.
-.PP
-You should have received a copy of the \s-1GNU\s0 General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, \s-1MA\s0 02139, \s-1USA\s0.
-.SH "REPORTING BUGS"
-.IX Header "REPORTING BUGS"
-Bugs can be viewed on the Red Hat Bugzilla page:
-<https://bugzilla.redhat.com/>.
-.PP
-If you find a bug in virt\-df, please follow these steps to report it:
-.IP "1. Check for existing bug reports" 4
-.IX Item "1. Check for existing bug reports"
-Go to <https://bugzilla.redhat.com/> and search for similar bugs.
-Someone may already have reported the same bug, and they may even
-have fixed it.
-.IP "2. Capture debug and error messages" 4
-.IX Item "2. Capture debug and error messages"
-Run
-.Sp
-.Vb 1
-\& virt-df > virt-df.log 2>&1
-.Ve
-.Sp
-and keep \fIvirt\-df.log\fR. It contains error messages which you should
-submit with your bug report.
-.IP "3. Get version of virt-df and version of libvirt." 4
-.IX Item "3. Get version of virt-df and version of libvirt."
-Run
-.Sp
-.Vb 1
-\& virt-df --version
-.Ve
-.IP "4. Submit a bug report." 4
-.IX Item "4. Submit a bug report."
-Go to <https://bugzilla.redhat.com/> and enter a new bug.
-Please describe the problem in as much detail as possible.
-.Sp
-Remember to include the version numbers (step 3) and the debug
-messages file (step 2).
-.IP "5. Assign the bug to rjones @ redhat.com" 4
-.IX Item "5. Assign the bug to rjones @ redhat.com"
-Assign or reassign the bug to \fBrjones @ redhat.com\fR (without the
-spaces). You can also send me an email with the bug number if you
-want a faster response.
diff --git a/virt-df/virt-df.pod b/virt-df/virt-df.pod
deleted file mode 100644
index 84b1d97..0000000
--- a/virt-df/virt-df.pod
+++ /dev/null
@@ -1,174 +0,0 @@
-=head1 NAME
-
-virt-df - 'df'-like utility for virtualization stats
-
-=head1 SUMMARY
-
-virt-df [-options]
-
-=head1 DESCRIPTION
-
-virt-df is a L<df(1)>-like utility for showing the actual disk usage
-of guests. Many command line options are the same as for ordinary
-I<df>.
-
-It uses libvirt so it is capable of showing stats across a variety of
-different virtualization systems.
-
-There are some shortcomings to the whole approach of reading disk
-state from outside the guest. Please read SHORTCOMINGS section below
-for more details.
-
-=head1 OPTIONS
-
-=over 4
-
-=item B<-a>, B<--all>
-
-Show all domains. The default is show only running (active) domains.
-
-=item B<-c uri>, B<--connect uri>
-
-Connect to libvirt URI. The default is to connect to the default
-libvirt URI, normally Xen.
-
-=item B<-h>, B<--human-readable>
-
-Display human-readable sizes (eg. 10GiB).
-
-=item B<-i>, B<--inodes>
-
-Display inode information.
-
-=item B<--help>
-
-Display usage summary.
-
-=item B<--version>
-
-Display version and exit.
-
-=back
-
-=head1 SHORTCOMINGS
-
-virt-df spies on the guest's disk image to try to work out how much
-disk space it is actually using. There are some shortcomings to this,
-described here.
-
-(1) It does not work over remote connections. The storage API does
-not support peeking into remote disks, and libvirt has rejected a
-request to add this support.
-
-(2) It only understands a limited set of partition types. Assuming
-that the files and partitions that we get back from libvirt / Xen
-correspond to block devices in the guests, we can go some way towards
-manually parsing those partitions to find out what they contain. We
-can read the MBR, LVM, superblocks and so on. However that's a lot of
-parsing work, and currently there is no library which understands a
-wide range of partition schemes and filesystem types (not even
-libparted which doesn't support LVM yet). The Linux kernel does
-support that, but there's not really any good way to access that work.
-
-The current implementation uses a hand-coded parser which understands
-some simple formats (MBR, LVM2, ext2/3). In future we should use
-something like libparted.
-
-(3) The statistics you get are delayed. The real state of, for
-example, an ext2 filesystem is only stored in the memory of the
-guest's kernel. The ext2 superblock contains some meta-information
-about blocks used and free, but this superblock is not up to date. In
-fact the guest kernel may not update it even on a 'sync', not until
-the filesystem is unmounted. Some operations do appear to write the
-superblock, for example L<fsync(2)> [that is my reading of the ext2/3
-source code at least].
-
-=head1 SECURITY
-
-The current code is probably not secure against malicious guests. In
-particular a malicious guest can set up a disk in such a way that disk
-structures with loops can cause virt-df to spin forever. We are
-preparing a parsing library which can fix these sorts of problems.
-
-In the meantime, do not run virt-df on untrusted guests.
-
-=head1 SEE ALSO
-
-L<df(1)>,
-L<virsh(1)>,
-L<xm(1)>,
-L<http://www.libvirt.org/ocaml/>,
-L<http://www.libvirt.org/>,
-L<http://et.redhat.com/~rjones/>,
-L<http://caml.inria.fr/>
-
-=head1 AUTHORS
-
-Richard W.M. Jones <rjones @ redhat . com>
-
-=head1 COPYRIGHT
-
-(C) Copyright 2007-2008 Red Hat Inc., Richard W.M. Jones
-http://libvirt.org/
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-=head1 REPORTING BUGS
-
-Bugs can be viewed on the Red Hat Bugzilla page:
-L<https://bugzilla.redhat.com/>.
-
-If you find a bug in virt-df, please follow these steps to report it:
-
-=over 4
-
-=item 1. Check for existing bug reports
-
-Go to L<https://bugzilla.redhat.com/> and search for similar bugs.
-Someone may already have reported the same bug, and they may even
-have fixed it.
-
-=item 2. Capture debug and error messages
-
-Run
-
- virt-df > virt-df.log 2>&1
-
-and keep I<virt-df.log>. It contains error messages which you should
-submit with your bug report.
-
-=item 3. Get version of virt-df and version of libvirt.
-
-Run
-
- virt-df --version
-
-=item 4. Submit a bug report.
-
-Go to L<https://bugzilla.redhat.com/> and enter a new bug.
-Please describe the problem in as much detail as possible.
-
-Remember to include the version numbers (step 3) and the debug
-messages file (step 2).
-
-=item 5. Assign the bug to rjones @ redhat.com
-
-Assign or reassign the bug to B<rjones @ redhat.com> (without the
-spaces). You can also send me an email with the bug number if you
-want a faster response.
-
-=back
-
-=end
diff --git a/virt-df/virt-df.txt b/virt-df/virt-df.txt
deleted file mode 100644
index fcddafb..0000000
--- a/virt-df/virt-df.txt
+++ /dev/null
@@ -1,139 +0,0 @@
-NAME
- virt-df - 'df'-like utility for virtualization stats
-
-SUMMARY
- virt-df [-options]
-
-DESCRIPTION
- virt-df is a df(1)-like utility for showing the actual disk usage of
- guests. Many command line options are the same as for ordinary *df*.
-
- It uses libvirt so it is capable of showing stats across a variety of
- different virtualization systems.
-
- There are some shortcomings to the whole approach of reading disk state
- from outside the guest. Please read SHORTCOMINGS section below for more
- details.
-
-OPTIONS
- -a, --all
- Show all domains. The default is show only running (active) domains.
-
- -c uri, --connect uri
- Connect to libvirt URI. The default is to connect to the default
- libvirt URI, normally Xen.
-
- -h, --human-readable
- Display human-readable sizes (eg. 10GiB).
-
- -i, --inodes
- Display inode information.
-
- --help
- Display usage summary.
-
- --version
- Display version and exit.
-
-SHORTCOMINGS
- virt-df spies on the guest's disk image to try to work out how much disk
- space it is actually using. There are some shortcomings to this,
- described here.
-
- (1) It does not work over remote connections. The storage API does not
- support peeking into remote disks, and libvirt has rejected a request to
- add this support.
-
- (2) It only understands a limited set of partition types. Assuming that
- the files and partitions that we get back from libvirt / Xen correspond
- to block devices in the guests, we can go some way towards manually
- parsing those partitions to find out what they contain. We can read the
- MBR, LVM, superblocks and so on. However that's a lot of parsing work,
- and currently there is no library which understands a wide range of
- partition schemes and filesystem types (not even libparted which doesn't
- support LVM yet). The Linux kernel does support that, but there's not
- really any good way to access that work.
-
- The current implementation uses a hand-coded parser which understands
- some simple formats (MBR, LVM2, ext2/3). In future we should use
- something like libparted.
-
- (3) The statistics you get are delayed. The real state of, for example,
- an ext2 filesystem is only stored in the memory of the guest's kernel.
- The ext2 superblock contains some meta-information about blocks used and
- free, but this superblock is not up to date. In fact the guest kernel
- may not update it even on a 'sync', not until the filesystem is
- unmounted. Some operations do appear to write the superblock, for
- example fsync(2) [that is my reading of the ext2/3 source code at
- least].
-
-SECURITY
- The current code is probably not secure against malicious guests. In
- particular a malicious guest can set up a disk in such a way that disk
- structures with loops can cause virt-df to spin forever. We are
- preparing a parsing library which can fix these sorts of problems.
-
- In the meantime, do not run virt-df on untrusted guests.
-
-SEE ALSO
- df(1), virsh(1), xm(1), <http://www.libvirt.org/ocaml/>,
- <http://www.libvirt.org/>, <http://et.redhat.com/~rjones/>,
- <http://caml.inria.fr/>
-
-AUTHORS
- Richard W.M. Jones <rjones @ redhat . com>
-
-COPYRIGHT
- (C) Copyright 2007-2008 Red Hat Inc., Richard W.M. Jones
- http://libvirt.org/
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 675 Mass Ave, Cambridge, MA 02139, USA.
-
-REPORTING BUGS
- Bugs can be viewed on the Red Hat Bugzilla page:
- <https://bugzilla.redhat.com/>.
-
- If you find a bug in virt-df, please follow these steps to report it:
-
- 1. Check for existing bug reports
- Go to <https://bugzilla.redhat.com/> and search for similar bugs.
- Someone may already have reported the same bug, and they may even
- have fixed it.
-
- 2. Capture debug and error messages
- Run
-
- virt-df > virt-df.log 2>&1
-
- and keep *virt-df.log*. It contains error messages which you should
- submit with your bug report.
-
- 3. Get version of virt-df and version of libvirt.
- Run
-
- virt-df --version
-
- 4. Submit a bug report.
- Go to <https://bugzilla.redhat.com/> and enter a new bug. Please
- describe the problem in as much detail as possible.
-
- Remember to include the version numbers (step 3) and the debug
- messages file (step 2).
-
- 5. Assign the bug to rjones @ redhat.com
- Assign or reassign the bug to rjones @ redhat.com (without the
- spaces). You can also send me an email with the bug number if you
- want a faster response.
-
diff --git a/virt-df/virt_df.ml b/virt-df/virt_df.ml
deleted file mode 100644
index 350d535..0000000
--- a/virt-df/virt_df.ml
+++ /dev/null
@@ -1,505 +0,0 @@
-(* 'df' command for virtual domains.
- (C) Copyright 2007-2008 Richard W.M. Jones, Red Hat Inc.
- http://libvirt.org/
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *)
-
-open Printf
-open ExtList
-
-open Unix
-
-module C = Libvirt.Connect
-module D = Libvirt.Domain
-module N = Libvirt.Network
-
-(* Int64 operators for convenience.
- * For sanity we do all int operations as int64's.
- *)
-let (+^) = Int64.add
-let (-^) = Int64.sub
-let ( *^ ) = Int64.mul
-let (/^) = Int64.div
-
-let uri = ref None
-let inodes = ref false
-let human = ref false
-let all = ref false
-
-(* Maximum number of extended partitions possible. *)
-let max_extended_partitions = 100
-
-let sector_size = 512L
-
-(* Parse out the device XML to get the names of disks. *)
-type domain = {
- dom_name : string; (* Domain name. *)
- dom_id : int option; (* Domain ID (if running). *)
- dom_disks : disk list; (* Domain disks. *)
-}
-and disk = {
- d_type : string option; (* The <disk type=...> *)
- d_device : string option; (* The <disk device=...> *)
- d_source : string option; (* The <source file=... or dev> *)
- d_target : string option; (* The <target dev=...> *)
-}
-
-type partition = {
- part_status : partition_status; (* Bootable, etc. *)
- part_type : int; (* Partition type. *)
- part_lba_start : int64; (* LBA start sector. *)
- part_len : int64; (* Length in sectors. *)
-}
-and partition_status = Bootable | Nonbootable | Malformed | NullEntry
-
-type filesystem_stats = {
- fs_name : string;
- fs_block_size : int64; (* Block size (bytes). *)
- fs_blocks_total : int64; (* Total blocks. *)
- fs_blocks_reserved : int64; (* Blocks reserved for super-user. *)
- fs_blocks_avail : int64; (* Blocks free (available). *)
- fs_blocks_used : int64; (* Blocks in use. *)
- fs_inodes_total : int64; (* Total inodes. *)
- fs_inodes_reserved : int64; (* Inodes reserved for super-user. *)
- fs_inodes_avail : int64; (* Inodes free (available). *)
- fs_inodes_used : int64; (* Inodes in use. *)
-}
-and swap_stats = {
- swap_name : string;
- swap_block_size : int64; (* Block size (bytes). *)
- swap_blocks_total : int64; (* Total blocks. *)
-}
-and fs_probe_t = (* Return type of the probe_partition.*)
- | Filesystem of filesystem_stats
- | Swap of swap_stats
- | ProbeFailed of string (* Probe failed for some reason. *)
- | ProbeIgnore (* This filesystem should be ignored. *)
-
-(* Register a filesystem type. *)
-let filesystems = Hashtbl.create 13
-let fs_register part_types probe_fn =
- List.iter
- (fun part_type -> Hashtbl.replace filesystems part_type probe_fn)
- part_types
-
-(* Probe the devices and display.
- * - dom_name is the domain name
- * - target will be something like "hda"
- * - source will be the name of a file or disk partition on the local machine
- *)
-let rec probe_device dom_name target source =
- let fd = openfile source [ O_RDONLY ] 0 in
- let size = (LargeFile.fstat fd).LargeFile.st_size in
- let size = size /^ sector_size in (* Size in sectors. *)
-
- (*print_device dom_name target source size;*)
-
- let partitions = probe_mbr fd in
-
- if partitions <> [] then (
- let stats =
- List.mapi (
- fun i part ->
- if part.part_status = Bootable ||
- part.part_status = Nonbootable then (
- let pnum = i+1 in
- let target = target ^ string_of_int pnum in
- Some (target,
- probe_partition target (Some part.part_type)
- fd part.part_lba_start part.part_len)
- )
- else
- None
- ) partitions in
- let stats = List.filter_map (fun x -> x) stats in
- print_stats dom_name stats
- ) else (* Not an MBR, assume it's a single partition. *)
- print_stats dom_name [target, probe_partition target None fd 0L size];
-
- close fd
-
-(* Probe the master boot record (if it is one) and read the partitions.
- * Returns [] if this is not an MBR.
- * http://en.wikipedia.org/wiki/Master_boot_record
- *)
-and probe_mbr fd =
- lseek fd 510 SEEK_SET;
- let str = String.create 2 in
- if read fd str 0 2 <> 2 || str.[0] != '\x55' || str.[1] != '\xAA' then
- [] (* Not MBR *)
- else (
- (* Read the partition table. *)
- lseek fd 446 SEEK_SET;
- let str = String.create 64 in
- if read fd str 0 64 <> 64 then
- failwith "error reading partition table"
- else (
- (* Extract partitions from the data. *)
- let primaries = List.map (get_partition str) [ 0; 16; 32; 48 ] in
- (* XXX validate partition extents compared to disk. *)
- (* Read extended partition data. *)
- let extendeds = List.map (
- function
- | { part_type = 0x05 } as part ->
- probe_extended_partition
- max_extended_partitions fd part part.part_lba_start
- | part -> []
- ) primaries in
- let extendeds = List.concat extendeds in
- primaries @ extendeds
- )
- )
-
-(* Probe an extended partition. *)
-and probe_extended_partition max fd epart sect =
- if max > 0 then (
- (* Offset of the first EBR. *)
- let ebr_offs = sect *^ sector_size in
- (* EBR Signature? *)
- LargeFile.lseek fd (ebr_offs +^ 510L) SEEK_SET;
- let str = String.create 2 in
- if read fd str 0 2 <> 2 || str.[0] != '\x55' || str.[1] != '\xAA' then
- [] (* Not EBR *)
- else (
- (* Read the extended partition table entries (just 2 of them). *)
- LargeFile.lseek fd (ebr_offs +^ 446L) SEEK_SET;
- let str = String.create 32 in
- if read fd str 0 32 <> 32 then
- failwith "error reading extended partition"
- else (
- (* Extract partitions from the data. *)
- let part1, part2 =
- match List.map (get_partition str) [ 0; 16 ] with
- | [p1;p2] -> p1,p2
- | _ -> failwith "probe_extended_partition: internal error" in
- (* First partition entry has offset to the start of this partition. *)
- let part1 = { part1 with
- part_lba_start = sect +^ part1.part_lba_start } in
- (* Second partition entry is zeroes if end of list, otherwise points
- * to the next partition.
- *)
- if part2.part_status = NullEntry then
- [part1]
- else
- part1 :: probe_extended_partition
- (max-1) fd epart (sect +^ part2.part_lba_start)
- )
- )
- )
- else []
-
-(* Get the partition data from str.[offs] - str.[offs+15] *)
-and get_partition str offs =
- let part_type = Char.code str.[offs+4] in
- let part_lba_start = read_int32_le str (offs+8) in
- let part_len = read_int32_le str (offs+12) in
-
- let part_status =
- if part_type = 0 && part_lba_start = 0L && part_len = 0L then
- NullEntry
- else (
- let part_status = Char.code str.[offs] in
- match part_status with
- | 0x80 -> Bootable | 0 -> Nonbootable | _ -> Malformed
- ) in
-
- { part_status = part_status;
- part_type = part_type;
- part_lba_start = part_lba_start;
- part_len = part_len }
-
-(* Probe a single partition, which we assume contains either a
- * filesystem or is a PV.
- * - target will be something like "hda" or "hda1"
- * - part_type will be the partition type if known, or None
- * - fd is a file descriptor opened on the device
- * - start & size are where we think the start and size of the
- * partition is within the file descriptor (in SECTORS)
- *)
-and probe_partition target part_type fd start size =
- match part_type with
- | None ->
- ProbeFailed "detection of unpartitioned devices not yet supported"
- | Some 0x05 ->
- ProbeIgnore (* Extended partition - ignore it. *)
- | Some part_type ->
- try
- let probe_fn = Hashtbl.find filesystems part_type in
- probe_fn target part_type fd start size
- with
- Not_found ->
- ProbeFailed
- (sprintf "unsupported partition type %02x" part_type)
-
-and print_stats dom_name statss =
- List.iter (
- fun (target, fs_probe_t) ->
- let dom_target = dom_name ^ ":" ^ target in
- printf "%-20s " dom_target;
-
- match fs_probe_t with
- (* Swap partition. *)
- | Swap { swap_name = swap_name;
- swap_block_size = block_size;
- swap_blocks_total = blocks_total } ->
- if not !human then
- printf "%10Ld %s\n"
- (block_size *^ blocks_total /^ 1024L) swap_name
- else
- printf "%10s %s\n"
- (printable_size (block_size *^ blocks_total)) swap_name
-
- (* Ordinary filesystem. *)
- | Filesystem stats ->
- if not !inodes then ( (* Block display. *)
- (* 'df' doesn't count the restricted blocks. *)
- let blocks_total =
- stats.fs_blocks_total -^ stats.fs_blocks_reserved in
- let blocks_avail =
- stats.fs_blocks_avail -^ stats.fs_blocks_reserved in
- let blocks_avail =
- if blocks_avail < 0L then 0L else blocks_avail in
-
- if not !human then ( (* Display 1K blocks. *)
- printf "%10Ld %10Ld %10Ld %s\n"
- (blocks_total *^ stats.fs_block_size /^ 1024L)
- (stats.fs_blocks_used *^ stats.fs_block_size /^ 1024L)
- (blocks_avail *^ stats.fs_block_size /^ 1024L)
- stats.fs_name
- ) else ( (* Human-readable blocks. *)
- printf "%10s %10s %10s %s\n"
- (printable_size (blocks_total *^ stats.fs_block_size))
- (printable_size (stats.fs_blocks_used *^ stats.fs_block_size))
- (printable_size (blocks_avail *^ stats.fs_block_size))
- stats.fs_name
- )
- ) else ( (* Inodes display. *)
- printf "%10Ld %10Ld %10Ld %s\n"
- stats.fs_inodes_total stats.fs_inodes_used stats.fs_inodes_avail
- stats.fs_name
- )
-
- (* Unsupported filesystem or other failure. *)
- | ProbeFailed reason ->
- printf " %s\n" reason
-
- | ProbeIgnore -> ()
- ) statss
-
-(* Target is something like "hda" and size is the size in sectors. *)
-and print_device dom_name target source size =
- printf "%s /dev/%s (%s) %s\n"
- dom_name target (printable_size (size *^ sector_size)) source
-
-and printable_size bytes =
- if bytes < 1024L *^ 1024L then
- sprintf "%Ld bytes" bytes
- else if bytes < 1024L *^ 1024L *^ 1024L then
- sprintf "%.1f MiB" (Int64.to_float (bytes /^ 1024L) /. 1024.)
- else
- sprintf "%.1f GiB" (Int64.to_float (bytes /^ 1024L /^ 1024L) /. 1024.)
-
-and read_int32_le str offs =
- Int64.of_int (Char.code str.[offs]) +^
- 256L *^ Int64.of_int (Char.code str.[offs+1]) +^
- 65536L *^ Int64.of_int (Char.code str.[offs+2]) +^
- 16777216L *^ Int64.of_int (Char.code str.[offs+3])
-
-and read_int16_le str offs =
- Int64.of_int (Char.code str.[offs]) +^
- 256L *^ Int64.of_int (Char.code str.[offs+1])
-
-let main () =
- (* Command line argument parsing. *)
- let set_uri = function "" -> uri := None | u -> uri := Some u in
-
- let version () =
- printf "virt-df %s\n" (Libvirt_version.version);
-
- let major, minor, release =
- let v, _ = Libvirt.get_version () in
- v / 1_000_000, (v / 1_000) mod 1_000, v mod 1_000 in
- printf "libvirt %d.%d.%d\n" major minor release;
- exit 0
- in
-
- let argspec = Arg.align [
- "-a", Arg.Set all, " Show all domains (default: only active domains)";
- "--all", Arg.Set all, " Show all domains (default: only active domains)";
- "-c", Arg.String set_uri, "uri Connect to URI (default: Xen)";
- "--connect", Arg.String set_uri, "uri Connect to URI (default: Xen)";
- "-h", Arg.Set human, " Print sizes in human-readable format";
- "--human-readable", Arg.Set human, " Print sizes in human-readable format";
- "-i", Arg.Set inodes, " Show inodes instead of blocks";
- "--inodes", Arg.Set inodes, " Show inodes instead of blocks";
- "--version", Arg.Unit version, " Display version and exit";
- ] in
-
- let anon_fun str = raise (Arg.Bad (str ^ ": unknown parameter")) in
- let usage_msg = "virt-df : like 'df', shows disk space used in guests
-
-SUMMARY
- virt-df [-options]
-
-OPTIONS" in
-
- Arg.parse argspec anon_fun usage_msg;
-
- let xmls =
- (* Connect to the hypervisor. *)
- let conn =
- let name = !uri in
- try C.connect_readonly ?name ()
- with
- Libvirt.Virterror err ->
- prerr_endline (Libvirt.Virterror.to_string err);
- (* If non-root and no explicit connection URI, print a warning. *)
- if geteuid () <> 0 && name = None then (
- print_endline "NB: If you want to monitor a local Xen hypervisor, you usually need to be root";
- );
- exit 1 in
-
- (* Get the list of active & inactive domains. *)
- let doms =
- let nr_active_doms = C.num_of_domains conn in
- let active_doms = Array.to_list (C.list_domains conn nr_active_doms) in
- let active_doms = List.map (D.lookup_by_id conn) active_doms in
- if not !all then
- active_doms
- else (
- let nr_inactive_doms = C.num_of_defined_domains conn in
- let inactive_doms =
- Array.to_list (C.list_defined_domains conn nr_inactive_doms) in
- let inactive_doms = List.map (D.lookup_by_name conn) inactive_doms in
- active_doms @ inactive_doms
- ) in
-
- (* Get their XML. *)
- let xmls = List.map D.get_xml_desc doms in
-
- (* Parse the XML. *)
- let xmls = List.map Xml.parse_string xmls in
-
- (* Return just the XML documents - everything else will be closed
- * and freed including the connection to the hypervisor.
- *)
- xmls in
-
- let doms : domain list =
- (* Grr.. Need to use a library which has XPATH support (or cduce). *)
- List.map (
- fun xml ->
- let nodes, domain_attrs =
- match xml with
- | Xml.Element ("domain", attrs, children) -> children, attrs
- | _ -> failwith "get_xml_desc didn't return <domain/>" in
-
- let domid =
- try Some (int_of_string (List.assoc "id" domain_attrs))
- with Not_found -> None in
-
- let rec loop = function
- | [] ->
- failwith "get_xml_desc returned no <name> node in XML"
- | Xml.Element ("name", _, [Xml.PCData name]) :: _ -> name
- | Xml.Element ("name", _, _) :: _ ->
- failwith "get_xml_desc returned strange <name> node"
- | _ :: rest -> loop rest
- in
- let name = loop nodes in
-
- let devices =
- let devices =
- List.filter_map (
- function
- | Xml.Element ("devices", _, devices) -> Some devices
- | _ -> None
- ) nodes in
- List.concat devices in
-
- let rec target_dev_of = function
- | [] -> None
- | Xml.Element ("target", attrs, _) :: rest ->
- (try Some (List.assoc "dev" attrs)
- with Not_found -> target_dev_of rest)
- | _ :: rest -> target_dev_of rest
- in
-
- let rec source_file_of = function
- | [] -> None
- | Xml.Element ("source", attrs, _) :: rest ->
- (try Some (List.assoc "file" attrs)
- with Not_found -> source_file_of rest)
- | _ :: rest -> source_file_of rest
- in
-
- let rec source_dev_of = function
- | [] -> None
- | Xml.Element ("source", attrs, _) :: rest ->
- (try Some (List.assoc "dev" attrs)
- with Not_found -> source_dev_of rest)
- | _ :: rest -> source_dev_of rest
- in
-
- let disks =
- List.filter_map (
- function
- | Xml.Element ("disk", attrs, children) ->
- let typ =
- try Some (List.assoc "type" attrs)
- with Not_found -> None in
- let device =
- try Some (List.assoc "device" attrs)
- with Not_found -> None in
- let source =
- match source_file_of children with
- | (Some _) as source -> source
- | None -> source_dev_of children in
- let target = target_dev_of children in
-
- Some {
- d_type = typ; d_device = device;
- d_source = source; d_target = target
- }
- | _ -> None
- ) devices in
-
- { dom_name = name; dom_id = domid; dom_disks = disks }
- ) xmls in
-
- (* Print the title. *)
- let () =
- let total, used, avail =
- match !inodes, !human with
- | false, false -> "1K-blocks", "Used", "Available"
- | false, true -> "Size", "Used", "Available"
- | true, _ -> "Inodes", "IUse", "IFree" in
- printf "%-20s %10s %10s %10s %s\n%!"
- "Filesystem" total used avail "Type" in
-
- (* Probe the devices. *)
- List.iter (
- fun { dom_name = dom_name; dom_disks = dom_disks } ->
- List.iter (
- function
- | { d_source = Some source; d_target = Some target } ->
- probe_device dom_name target source
- | { d_device = Some "cdrom" } ->
- () (* Ignore physical CD-ROM devices. *)
- | _ ->
- printf "(device omitted)\n";
- ) dom_disks
- ) doms
diff --git a/virt-df/virt_df_ext2.ml b/virt-df/virt_df_ext2.ml
deleted file mode 100755
index d2b51f3..0000000
--- a/virt-df/virt_df_ext2.ml
+++ /dev/null
@@ -1,99 +0,0 @@
-(* 'df' command for virtual domains.
- (C) Copyright 2007 Richard W.M. Jones, Red Hat Inc.
- http://libvirt.org/
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- Support for EXT2/EXT3 filesystems.
-*)
-
-open Unix
-open Printf
-
-(* Int64 operators for convenience. *)
-let (+^) = Int64.add
-let (-^) = Int64.sub
-let ( *^ ) = Int64.mul
-let (/^) = Int64.div
-
-let sector_size = Virt_df.sector_size
-let read_int32_le = Virt_df.read_int32_le
-
-let probe_ext2 target part_type fd start size =
- LargeFile.lseek fd ((start+^2L) *^ sector_size) SEEK_SET;
- let str = String.create 128 in
- if read fd str 0 128 <> 128 then
- failwith "error reading ext2/ext3 magic"
- else (
- if str.[56] != '\x53' || str.[57] != '\xEF' then (
- Virt_df.ProbeFailed "partition marked EXT2/3 but no valid filesystem"
- ) else (
- (* Refer to <linux/ext2_fs.h> *)
- let s_inodes_count = read_int32_le str 0 in
- let s_blocks_count = read_int32_le str 4 in
- let s_r_blocks_count = read_int32_le str 8 in
- let s_free_blocks_count = read_int32_le str 12 in
- let s_free_inodes_count = read_int32_le str 16 in
- let s_first_data_block = read_int32_le str 20 in
- let s_log_block_size = read_int32_le str 24 in
- (*let s_log_frag_size = read_int32_le str 28 in*)
- let s_blocks_per_group = read_int32_le str 32 in
-
- (* Work out the block size in bytes. *)
- let s_log_block_size = Int64.to_int s_log_block_size in
- let block_size = 1024L in
- let block_size = Int64.shift_left block_size s_log_block_size in
-
- (* Number of groups. *)
- let s_groups_count =
- (s_blocks_count -^ s_first_data_block -^ 1L)
- /^ s_blocks_per_group +^ 1L in
-
-(*
- (* Number of group descriptors per block. *)
- let s_inodes_per_block = s_blocksize /
- let s_desc_per_block = block_size / s_inodes_per_block in
- let db_count =
- (s_groups_count +^ s_desc_per_block -^ 1L)
- /^ s_desc_per_block
-*)
-
- (* Calculate the block overhead (used by superblocks, inodes, etc.)
- * See fs/ext2/super.c.
- *)
- let overhead = s_first_data_block in
- let overhead = (* XXX *) overhead in
-
-
- Virt_df.Filesystem {
- Virt_df.fs_name = "Linux ext2/3";
- fs_block_size = block_size;
- fs_blocks_total = s_blocks_count -^ overhead;
- fs_blocks_reserved = s_r_blocks_count;
- fs_blocks_avail = s_free_blocks_count;
- fs_blocks_used = s_blocks_count -^ overhead -^ s_free_blocks_count;
- fs_inodes_total = s_inodes_count;
- fs_inodes_reserved = 0L; (* XXX? *)
- fs_inodes_avail = s_free_inodes_count;
- fs_inodes_used = s_inodes_count (*-^ 0L*) -^ s_free_inodes_count;
- }
- )
- )
-
-(* Register with main code. *)
-let () =
- Virt_df.fs_register
- [ 0x83 ] (* Partition type. *)
- probe_ext2
diff --git a/virt-df/virt_df_linux_swap.ml b/virt-df/virt_df_linux_swap.ml
deleted file mode 100755
index 4638828..0000000
--- a/virt-df/virt_df_linux_swap.ml
+++ /dev/null
@@ -1,40 +0,0 @@
-(* 'df' command for virtual domains.
-
- (C) Copyright 2007 Richard W.M. Jones, Red Hat Inc.
- http://libvirt.org/
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- Support for Linux swap partitions.
-*)
-
-(* Int64 operators for convenience. *)
-let (+^) = Int64.add
-let (-^) = Int64.sub
-let ( *^ ) = Int64.mul
-let (/^) = Int64.div
-
-let probe_swap target part_type fd start size =
- Virt_df.Swap {
- Virt_df.swap_name = "Linux swap";
- swap_block_size = 4096L; (* XXX *)
- swap_blocks_total = size *^ 512L /^ 4096L;
- }
-
-(* Register with main code. *)
-let () =
- Virt_df.fs_register
- [ 0x82 ] (* Partition type. *)
- probe_swap
diff --git a/virt-df/virt_df_lvm2.ml b/virt-df/virt_df_lvm2.ml
deleted file mode 100755
index 8dc0c05..0000000
--- a/virt-df/virt_df_lvm2.ml
+++ /dev/null
@@ -1,38 +0,0 @@
-(* 'df' command for virtual domains.
-
- (C) Copyright 2007 Richard W.M. Jones, Red Hat Inc.
- http://libvirt.org/
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- Support for LVM2 PVs.
-*)
-
-open Printf
-
-(* Int64 operators for convenience. *)
-let (+^) = Int64.add
-let (-^) = Int64.sub
-let ( *^ ) = Int64.mul
-let (/^) = Int64.div
-
-let probe_lvm2 target part_type fd start size =
- Virt_df.ProbeFailed "LVM2 not supported yet"
-
-(* Register with main code. *)
-let () =
- Virt_df.fs_register
- [ 0x8e ] (* Partition type. *)
- probe_lvm2
diff --git a/virt-df/virt_df_main.ml b/virt-df/virt_df_main.ml
deleted file mode 100755
index bc4096b..0000000
--- a/virt-df/virt_df_main.ml
+++ /dev/null
@@ -1,20 +0,0 @@
-(* 'df' command for virtual domains.
- (C) Copyright 2007 Richard W.M. Jones, Red Hat Inc.
- http://libvirt.org/
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *)
-
-let () = Virt_df.main ()