[PATCH 0/2] virt-tar and virt-ls
These are general updates to: https://www.redhat.com/archives/libguestfs/2009-October/msg00037.html [Libguestfs] [PATCH 4/5] New tool: virt-tar and: https://www.redhat.com/archives/libguestfs/2009-October/msg00038.html [Libguestfs] [PATCH 5/5] New tool: virt-ls The code uses die "prog: ...\n". The parameters to virt-tar are swapped so they always go in source -> destination order, ie: virt-tar -zx myguest /home home.tar.gz virt-tar -zu myguest uploadstuff.tar.gz /tmp and these parameters are checked for sanity which should make it harder to make mistakes. (The guest name still has to come first because of other limitations). Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.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 Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
On 20/10/09 10:39, Richard W.M. Jones wrote:
+sub set_mode_x +{ + die __"virt-tar: extract/upload mode specified twice on the command line\n" + if $mode; + $mode = "x"; +} + +sub set_mode_u +{ + die __"virt-tar: extract/upload mode specified twice on the command line\n" + if $mode; + $mode = "u"; +}
I'm not going to change your mind on this, am I? ;)
+# Note: 'pop' reads arguments right to left. +my ($tarball, $directory); +if ($mode eq "x") { + $tarball = pop @ARGV; + $directory = pop @ARGV; +} else { # $mode eq "u" + $directory = pop @ARGV; + $tarball = pop @ARGV; + die __"virt-tar: $tarball: file not found\n" unless -f $tarball; +} +die __"virt-tar: $directory: directory name must start with '/' character\n" + unless substr ($directory, 0, 1) eq "/";
Good call. ACK. Matt -- Matthew Booth, RHCA, RHCSS Red Hat Engineering, Virtualisation Team M: +44 (0)7977 267231 GPG ID: D33C3490 GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
On 20/10/09 11:27, Matthew Booth wrote:
On 20/10/09 10:39, Richard W.M. Jones wrote:
+sub set_mode_x +{ + die __"virt-tar: extract/upload mode specified twice on the command line\n" + if $mode; + $mode = "x"; +} + +sub set_mode_u +{ + die __"virt-tar: extract/upload mode specified twice on the command line\n" + if $mode; + $mode = "u"; +}
I'm not going to change your mind on this, am I? ;)
+# Note: 'pop' reads arguments right to left. +my ($tarball, $directory); +if ($mode eq "x") { + $tarball = pop @ARGV; + $directory = pop @ARGV; +} else { # $mode eq "u" + $directory = pop @ARGV; + $tarball = pop @ARGV; + die __"virt-tar: $tarball: file not found\n" unless -f $tarball; +} +die __"virt-tar: $directory: directory name must start with '/' character\n" + unless substr ($directory, 0, 1) eq "/";
Good call.
ACK.
Ah, wait. What happens to Windows directories here? Can the user specify 'C:\Temp'? Matt -- Matthew Booth, RHCA, RHCSS Red Hat Engineering, Virtualisation Team M: +44 (0)7977 267231 GPG ID: D33C3490 GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
On Tue, Oct 20, 2009 at 11:36:15AM +0100, Matthew Booth wrote:
What happens to Windows directories here? Can the user specify 'C:\Temp'?
No, they'd specify /Temp. We don't deal with Windows drives at all in virt-inspector / Sys::Guestfs::Lib at the moment. I'm guessing this would require more serious registry parsing than virt-inspector does at the moment. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.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
-- Richard Jones, Virtualization Group, Red Hat http://people.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
On 20/10/09 10:39, Richard W.M. Jones wrote:
+my @r; +unless ($mode) { + @r = $g->ls ($directory); + print "$_\n" foreach @r; +} elsif ($mode eq "l") { + print ($g->ll ($directory)); +} else { # $mode eq "R" + @r = $g->find ($directory); + print "$_\n" foreach @r; +}
Do you want to use the new find0 here? Otherwise, ACK. Matt -- Matthew Booth, RHCA, RHCSS Red Hat Engineering, Virtualisation Team M: +44 (0)7977 267231 GPG ID: D33C3490 GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490
On Tue, Oct 20, 2009 at 11:48:11AM +0100, Matthew Booth wrote:
On 20/10/09 10:39, Richard W.M. Jones wrote:
+my @r; +unless ($mode) { + @r = $g->ls ($directory); + print "$_\n" foreach @r; +} elsif ($mode eq "l") { + print ($g->ll ($directory)); +} else { # $mode eq "R" + @r = $g->find ($directory); + print "$_\n" foreach @r; +}
Do you want to use the new find0 here?
Otherwise, ACK.
Thanks -- find0 is added by a later patch. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
participants (2)
-
Matthew Booth -
Richard W.M. Jones