OK let's restart this whole architecture thing. Firstly two patches which pass the '-z' parameter to 'file' so it looks inside compressed files. (Thanks to Matt for finding this not-so-obscure option). This means the 'zfile' command is now obsolete. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
Richard W.M. Jones
2009-Jul-28 14:35 UTC
[Libguestfs] [PATCH 1/2] Add DeprecatedBy flag to mark functions which are deprecated.
Patch to add a DeprecatedBy patch to functions to point people to the replacement. *NB* We don't ever remove deprecated functions from the API ... Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/ -------------- next part -------------->From 6fe5a945c5cf8094f4d0bf05763418ec20f4c5f2 Mon Sep 17 00:00:00 2001From: Richard Jones <rjones at trick.home.annexia.org> Date: Tue, 28 Jul 2009 15:24:44 +0100 Subject: [PATCH 1/2] Add DeprecatedBy flag to mark functions which are deprecated. --- src/generator.ml | 65 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 53 insertions(+), 12 deletions(-) diff --git a/src/generator.ml b/src/generator.ml index 6aaaf67..bf3e637 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -169,15 +169,7 @@ type flags | FishAction of string (* call this function in guestfish *) | NotInFish (* do not export via guestfish *) | NotInDocs (* do not add this function to documentation *) - -let protocol_limit_warning - "Because of the message protocol, there is a transfer limit -of somewhere between 2MB and 4MB. To transfer large files you should use -FTP." - -let danger_will_robinson - "B<This command is dangerous. Without careful use you -can easily destroy all your data>." + | DeprecatedBy of string (* function is deprecated, use .. instead *) (* You can supply zero or as many tests as you want per API call. * @@ -3380,6 +3372,31 @@ let seq_of_test = function | TestOutputLength (s, _) | TestOutputStruct (s, _) | TestLastFail s -> s +(* Handling for function flags. *) +let protocol_limit_warning + "Because of the message protocol, there is a transfer limit +of somewhere between 2MB and 4MB. To transfer large files you should use +FTP." + +let danger_will_robinson + "B<This command is dangerous. Without careful use you +can easily destroy all your data>." + +let deprecation_notice flags + try + let alt + find_map (function DeprecatedBy str -> Some str | _ -> None) flags in + let txt + sprintf "This function is deprecated. +In new code, use the C<%s> call instead. + +Deprecated functions will not be removed from the API, but the +fact that they are deprecated indicates that there are problems +with correct use of these functions." alt in + Some txt + with + Not_found -> None + (* Check function names etc. for consistency. *) let check_functions () let contains_uppercase str @@ -3628,7 +3645,10 @@ I<The caller must free the returned buffer after use>.\n\n" if List.mem ProtocolLimitWarning flags then pr "%s\n\n" protocol_limit_warning; if List.mem DangerWillRobinson flags then - pr "%s\n\n" danger_will_robinson + pr "%s\n\n" danger_will_robinson; + match deprecation_notice flags with + | None -> () + | Some txt -> pr "%s\n\n" txt ) ) all_functions_sorted @@ -5349,6 +5369,12 @@ and generate_fish_cmds () ("\n\n" ^ danger_will_robinson) else "" in + let warnings + warnings ^ + match deprecation_notice flags with + | None -> "" + | Some txt -> "\n\n" ^ txt in + let describe_alias if name <> alias then sprintf "\n\nYou can use '%s' as an alias for this command." alias @@ -5720,7 +5746,11 @@ and generate_fish_actions_pod () pr "%s\n\n" protocol_limit_warning; if List.mem DangerWillRobinson flags then - pr "%s\n\n" danger_will_robinson + pr "%s\n\n" danger_will_robinson; + + match deprecation_notice flags with + | None -> () + | Some txt -> pr "%s\n\n" txt ) all_functions_sorted (* Generate a C function prototype. *) @@ -6637,7 +6667,10 @@ sub new { if List.mem ProtocolLimitWarning flags then pr "%s\n\n" protocol_limit_warning; if List.mem DangerWillRobinson flags then - pr "%s\n\n" danger_will_robinson + pr "%s\n\n" danger_will_robinson; + match deprecation_notice flags with + | None -> () + | Some txt -> pr "%s\n\n" txt ) ) all_functions_sorted; @@ -7161,6 +7194,10 @@ class GuestFS: if List.mem DangerWillRobinson flags then doc ^ "\n\n" ^ danger_will_robinson else doc in + let doc + match deprecation_notice flags with + | None -> doc + | Some txt -> doc ^ "\n\n" ^ txt in let doc = pod2text ~width:60 name doc in let doc = List.map (fun line -> replace_str line "\\" "\\\\") doc in let doc = String.concat "\n " doc in @@ -7569,6 +7606,10 @@ public class GuestFS { if List.mem DangerWillRobinson flags then doc ^ "\n\n" ^ danger_will_robinson else doc in + let doc + match deprecation_notice flags with + | None -> doc + | Some txt -> doc ^ "\n\n" ^ txt in let doc = pod2text ~width:60 name doc in let doc = List.map ( (* RHBZ#501883 *) function -- 1.6.2.5
Richard W.M. Jones
2009-Jul-28 14:36 UTC
[Libguestfs] [PATCH 2/2] Pass '-z' parameter to 'file' command so it looks inside compressed files.
Pass the extra -z parameter to file. Deprecate zfile. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw -------------- next part -------------->From 549bba81e739ab10d8013c9ca88ce70b0ddda8e4 Mon Sep 17 00:00:00 2001From: Richard Jones <rjones at trick.home.annexia.org> Date: Tue, 28 Jul 2009 15:29:23 +0100 Subject: [PATCH 2/2] Pass '-z' parameter to 'file' command so it looks inside compressed files. Also we deprecate the old 'zfile' command. --- daemon/file.c | 2 +- src/generator.ml | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/daemon/file.c b/daemon/file.c index 6062c50..aab7e93 100644 --- a/daemon/file.c +++ b/daemon/file.c @@ -416,7 +416,7 @@ do_file (char *path) return NULL; } - r = command (&out, &err, "file", "-bsL", buf, NULL); + r = command (&out, &err, "file", "-zbsL", buf, NULL); if (freeit) free (buf); if (r == -1) { diff --git a/src/generator.ml b/src/generator.ml index bf3e637..b787850 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -1449,7 +1449,10 @@ This call uses the standard L<file(1)> command to determine the type or contents of the file. This also works on devices, for example to find out whether a partition contains a filesystem. -The exact command which runs is C<file -bsL path>. Note in +This call will also transparently look inside various types +of compressed file. + +The exact command which runs is C<file -zbsL path>. Note in particular that the filename is not prepended to the output (the C<-b> option)."); @@ -2914,7 +2917,7 @@ were rarely if ever used anyway. See also C<guestfs_sfdisk> and the L<sfdisk(8)> manpage."); - ("zfile", (RString "description", [String "method"; String "path"]), 140, [], + ("zfile", (RString "description", [String "method"; String "path"]), 140, [DeprecatedBy "file"], [], "determine file type inside a compressed file", "\ @@ -2923,7 +2926,8 @@ using C<method>. C<method> must be one of C<gzip>, C<compress> or C<bzip2>. -See also: C<guestfs_file>"); +Since 1.0.63, use C<guestfs_file> instead which can now +process compressed files."); ("getxattrs", (RStructList ("xattrs", "xattr"), [String "path"]), 141, [], [], -- 1.6.2.5
There's one user of zfile (in Lib.pm). This patch removes that use. Note that the new 'file' command which looks inside compressed files will report something like this for an initrd: "ASCII cpio archive (SVR4 with no CRC) (gzip compressed data, from Unix, last modified: Sun May 24 08:26:07 2009)" so checking for /cpio/ seems sufficient. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw -------------- next part -------------->From a82bfb88e553c6626c99757779f9b500664409ba Mon Sep 17 00:00:00 2001From: Richard Jones <rjones at trick.home.annexia.org> Date: Tue, 28 Jul 2009 15:43:14 +0100 Subject: [PATCH] Lib.pm: Use 'file' as replacement for 'zfile'. --- perl/lib/Sys/Guestfs/Lib.pm | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm index 00a9bdb..4020c24 100644 --- a/perl/lib/Sys/Guestfs/Lib.pm +++ b/perl/lib/Sys/Guestfs/Lib.pm @@ -1307,10 +1307,10 @@ sub _check_for_initrd my $version = $1; my @modules; - # Disregard old-style compressed ext2 files, since cpio - # takes ages to (fail to) process these. - if ($g->file ("/boot/$initrd") !~ /gzip compressed/ || - $g->zfile ("gzip", "/boot/$initrd") !~ /ext2 filesystem/) { + # Disregard old-style compressed ext2 files and only + # work with real compressed cpio files, since cpio + # takes ages to (fail to) process anything else. + if ($g->file ("/boot/$initrd") =~ /cpio/) { eval { @modules = $g->initrd_list ("/boot/$initrd"); }; -- 1.6.2.5
Seemingly Similar Threads
- [PATCH 0/7] Add libvirt domain to core API
- [PATCH 0/2] Rework tmpdir and appliance cache directory code.
- [PATCH 0/3] Enhancements to virt-ls
- Some more Virt-P2V CD results - screenshot attached as promised
- [PATCH febootstrap 0/8] Add support for building an ext2-based appliance