Generated code for 'add_drive_ro' call.
[libguestfs.git] / guestfish-actions.pod
1 =head2 add-cdrom | cdrom
2
3  add-cdrom filename
4
5 This function adds a virtual CD-ROM disk image to the guest.
6
7 This is equivalent to the qemu parameter C<-cdrom filename>.
8
9 Note that this call checks for the existence of C<filename>.  This
10 stops you from specifying other types of drive which are supported
11 by qemu such as C<nbd:> and C<http:> URLs.  To specify those, use
12 the general C<config> call instead.
13
14 =head2 add-drive | add
15
16  add-drive filename
17
18 This function adds a virtual machine disk image C<filename> to the
19 guest.  The first time you call this function, the disk appears as IDE
20 disk 0 (C</dev/sda>) in the guest, the second time as C</dev/sdb>, and
21 so on.
22
23 You don't necessarily need to be root when using libguestfs.  However
24 you obviously do need sufficient permissions to access the filename
25 for whatever operations you want to perform (ie. read access if you
26 just want to read the image or write access if you want to modify the
27 image).
28
29 This is equivalent to the qemu parameter C<-drive file=filename>.
30
31 Note that this call checks for the existence of C<filename>.  This
32 stops you from specifying other types of drive which are supported
33 by qemu such as C<nbd:> and C<http:> URLs.  To specify those, use
34 the general C<config> call instead.
35
36 =head2 add-drive-ro | add-ro
37
38  add-drive-ro filename
39
40 This adds a drive in snapshot mode, making it effectively
41 read-only.
42
43 Note that writes to the device are allowed, and will be seen for
44 the duration of the guestfs handle, but they are written
45 to a temporary file which is discarded as soon as the guestfs
46 handle is closed.  We don't currently have any method to enable
47 changes to be committed, although qemu can support this.
48
49 This is equivalent to the qemu parameter
50 C<-drive file=filename,snapshot=on>.
51
52 Note that this call checks for the existence of C<filename>.  This
53 stops you from specifying other types of drive which are supported
54 by qemu such as C<nbd:> and C<http:> URLs.  To specify those, use
55 the general C<config> call instead.
56
57 =head2 aug-close
58
59  aug-close
60
61 Close the current Augeas handle and free up any resources
62 used by it.  After calling this, you have to call
63 C<aug-init> again before you can use any other
64 Augeas functions.
65
66 =head2 aug-defnode
67
68  aug-defnode name expr val
69
70 Defines a variable C<name> whose value is the result of
71 evaluating C<expr>.
72
73 If C<expr> evaluates to an empty nodeset, a node is created,
74 equivalent to calling C<aug-set> C<expr>, C<value>.
75 C<name> will be the nodeset containing that single node.
76
77 On success this returns a pair containing the
78 number of nodes in the nodeset, and a boolean flag
79 if a node was created.
80
81 =head2 aug-defvar
82
83  aug-defvar name expr
84
85 Defines an Augeas variable C<name> whose value is the result
86 of evaluating C<expr>.  If C<expr> is NULL, then C<name> is
87 undefined.
88
89 On success this returns the number of nodes in C<expr>, or
90 C<0> if C<expr> evaluates to something which is not a nodeset.
91
92 =head2 aug-get
93
94  aug-get path
95
96 Look up the value associated with C<path>.  If C<path>
97 matches exactly one node, the C<value> is returned.
98
99 =head2 aug-init
100
101  aug-init root flags
102
103 Create a new Augeas handle for editing configuration files.
104 If there was any previous Augeas handle associated with this
105 guestfs session, then it is closed.
106
107 You must call this before using any other C<aug-*>
108 commands.
109
110 C<root> is the filesystem root.  C<root> must not be NULL,
111 use C</> instead.
112
113 The flags are the same as the flags defined in
114 E<lt>augeas.hE<gt>, the logical I<or> of the following
115 integers:
116
117 =over 4
118
119 =item C<AUG_SAVE_BACKUP> = 1
120
121 Keep the original file with a C<.augsave> extension.
122
123 =item C<AUG_SAVE_NEWFILE> = 2
124
125 Save changes into a file with extension C<.augnew>, and
126 do not overwrite original.  Overrides C<AUG_SAVE_BACKUP>.
127
128 =item C<AUG_TYPE_CHECK> = 4
129
130 Typecheck lenses (can be expensive).
131
132 =item C<AUG_NO_STDINC> = 8
133
134 Do not use standard load path for modules.
135
136 =item C<AUG_SAVE_NOOP> = 16
137
138 Make save a no-op, just record what would have been changed.
139
140 =item C<AUG_NO_LOAD> = 32
141
142 Do not load the tree in C<aug-init>.
143
144 =back
145
146 To close the handle, you can call C<aug-close>.
147
148 To find out more about Augeas, see L<http://augeas.net/>.
149
150 =head2 aug-insert
151
152  aug-insert path label true|false
153
154 Create a new sibling C<label> for C<path>, inserting it into
155 the tree before or after C<path> (depending on the boolean
156 flag C<before>).
157
158 C<path> must match exactly one existing node in the tree, and
159 C<label> must be a label, ie. not contain C</>, C<*> or end
160 with a bracketed index C<[N]>.
161
162 =head2 aug-load
163
164  aug-load
165
166 Load files into the tree.
167
168 See C<aug_load> in the Augeas documentation for the full gory
169 details.
170
171 =head2 aug-ls
172
173  aug-ls path
174
175 This is just a shortcut for listing C<aug-match>
176 C<path/*> and sorting the resulting nodes into alphabetical order.
177
178 =head2 aug-match
179
180  aug-match path
181
182 Returns a list of paths which match the path expression C<path>.
183 The returned paths are sufficiently qualified so that they match
184 exactly one node in the current tree.
185
186 =head2 aug-mv
187
188  aug-mv src dest
189
190 Move the node C<src> to C<dest>.  C<src> must match exactly
191 one node.  C<dest> is overwritten if it exists.
192
193 =head2 aug-rm
194
195  aug-rm path
196
197 Remove C<path> and all of its children.
198
199 On success this returns the number of entries which were removed.
200
201 =head2 aug-save
202
203  aug-save
204
205 This writes all pending changes to disk.
206
207 The flags which were passed to C<aug-init> affect exactly
208 how files are saved.
209
210 =head2 aug-set
211
212  aug-set path val
213
214 Set the value associated with C<path> to C<value>.
215
216 =head2 blockdev-flushbufs
217
218  blockdev-flushbufs device
219
220 This tells the kernel to flush internal buffers associated
221 with C<device>.
222
223 This uses the L<blockdev(8)> command.
224
225 =head2 blockdev-getbsz
226
227  blockdev-getbsz device
228
229 This returns the block size of a device.
230
231 (Note this is different from both I<size in blocks> and
232 I<filesystem block size>).
233
234 This uses the L<blockdev(8)> command.
235
236 =head2 blockdev-getro
237
238  blockdev-getro device
239
240 Returns a boolean indicating if the block device is read-only
241 (true if read-only, false if not).
242
243 This uses the L<blockdev(8)> command.
244
245 =head2 blockdev-getsize64
246
247  blockdev-getsize64 device
248
249 This returns the size of the device in bytes.
250
251 See also C<blockdev-getsz>.
252
253 This uses the L<blockdev(8)> command.
254
255 =head2 blockdev-getss
256
257  blockdev-getss device
258
259 This returns the size of sectors on a block device.
260 Usually 512, but can be larger for modern devices.
261
262 (Note, this is not the size in sectors, use C<blockdev-getsz>
263 for that).
264
265 This uses the L<blockdev(8)> command.
266
267 =head2 blockdev-getsz
268
269  blockdev-getsz device
270
271 This returns the size of the device in units of 512-byte sectors
272 (even if the sectorsize isn't 512 bytes ... weird).
273
274 See also C<blockdev-getss> for the real sector size of
275 the device, and C<blockdev-getsize64> for the more
276 useful I<size in bytes>.
277
278 This uses the L<blockdev(8)> command.
279
280 =head2 blockdev-rereadpt
281
282  blockdev-rereadpt device
283
284 Reread the partition table on C<device>.
285
286 This uses the L<blockdev(8)> command.
287
288 =head2 blockdev-setbsz
289
290  blockdev-setbsz device blocksize
291
292 This sets the block size of a device.
293
294 (Note this is different from both I<size in blocks> and
295 I<filesystem block size>).
296
297 This uses the L<blockdev(8)> command.
298
299 =head2 blockdev-setro
300
301  blockdev-setro device
302
303 Sets the block device named C<device> to read-only.
304
305 This uses the L<blockdev(8)> command.
306
307 =head2 blockdev-setrw
308
309  blockdev-setrw device
310
311 Sets the block device named C<device> to read-write.
312
313 This uses the L<blockdev(8)> command.
314
315 =head2 cat
316
317  cat path
318
319 Return the contents of the file named C<path>.
320
321 Note that this function cannot correctly handle binary files
322 (specifically, files containing C<\0> character which is treated
323 as end of string).  For those you need to use the C<download>
324 function which has a more complex interface.
325
326 Because of the message protocol, there is a transfer limit 
327 of somewhere between 2MB and 4MB.  To transfer large files you should use
328 FTP.
329
330 =head2 checksum
331
332  checksum csumtype path
333
334 This call computes the MD5, SHAx or CRC checksum of the
335 file named C<path>.
336
337 The type of checksum to compute is given by the C<csumtype>
338 parameter which must have one of the following values:
339
340 =over 4
341
342 =item C<crc>
343
344 Compute the cyclic redundancy check (CRC) specified by POSIX
345 for the C<cksum> command.
346
347 =item C<md5>
348
349 Compute the MD5 hash (using the C<md5sum> program).
350
351 =item C<sha1>
352
353 Compute the SHA1 hash (using the C<sha1sum> program).
354
355 =item C<sha224>
356
357 Compute the SHA224 hash (using the C<sha224sum> program).
358
359 =item C<sha256>
360
361 Compute the SHA256 hash (using the C<sha256sum> program).
362
363 =item C<sha384>
364
365 Compute the SHA384 hash (using the C<sha384sum> program).
366
367 =item C<sha512>
368
369 Compute the SHA512 hash (using the C<sha512sum> program).
370
371 =back
372
373 The checksum is returned as a printable string.
374
375 =head2 chmod
376
377  chmod mode path
378
379 Change the mode (permissions) of C<path> to C<mode>.  Only
380 numeric modes are supported.
381
382 =head2 chown
383
384  chown owner group path
385
386 Change the file owner to C<owner> and group to C<group>.
387
388 Only numeric uid and gid are supported.  If you want to use
389 names, you will need to locate and parse the password file
390 yourself (Augeas support makes this relatively easy).
391
392 =head2 command
393
394  command 'arguments ...'
395
396 This call runs a command from the guest filesystem.  The
397 filesystem must be mounted, and must contain a compatible
398 operating system (ie. something Linux, with the same
399 or compatible processor architecture).
400
401 The single parameter is an argv-style list of arguments.
402 The first element is the name of the program to run.
403 Subsequent elements are parameters.  The list must be
404 non-empty (ie. must contain a program name).
405
406 The return value is anything printed to I<stdout> by
407 the command.
408
409 If the command returns a non-zero exit status, then
410 this function returns an error message.  The error message
411 string is the content of I<stderr> from the command.
412
413 The C<$PATH> environment variable will contain at least
414 C</usr/bin> and C</bin>.  If you require a program from
415 another location, you should provide the full path in the
416 first parameter.
417
418 Shared libraries and data files required by the program
419 must be available on filesystems which are mounted in the
420 correct places.  It is the caller's responsibility to ensure
421 all filesystems that are needed are mounted at the right
422 locations.
423
424 Because of the message protocol, there is a transfer limit 
425 of somewhere between 2MB and 4MB.  To transfer large files you should use
426 FTP.
427
428 =head2 command-lines
429
430  command-lines 'arguments ...'
431
432 This is the same as C<command>, but splits the
433 result into a list of lines.
434
435 Because of the message protocol, there is a transfer limit 
436 of somewhere between 2MB and 4MB.  To transfer large files you should use
437 FTP.
438
439 =head2 config
440
441  config qemuparam qemuvalue
442
443 This can be used to add arbitrary qemu command line parameters
444 of the form C<-param value>.  Actually it's not quite arbitrary - we
445 prevent you from setting some parameters which would interfere with
446 parameters that we use.
447
448 The first character of C<param> string must be a C<-> (dash).
449
450 C<value> can be NULL.
451
452 =head2 cp
453
454  cp src dest
455
456 This copies a file from C<src> to C<dest> where C<dest> is
457 either a destination filename or destination directory.
458
459 =head2 cp-a
460
461  cp-a src dest
462
463 This copies a file or directory from C<src> to C<dest>
464 recursively using the C<cp -a> command.
465
466 =head2 debug
467
468  debug subcmd 'extraargs ...'
469
470 The C<debug> command exposes some internals of
471 C<guestfsd> (the guestfs daemon) that runs inside the
472 qemu subprocess.
473
474 There is no comprehensive help for this command.  You have
475 to look at the file C<daemon/debug.c> in the libguestfs source
476 to find out what you can do.
477
478 =head2 dmesg
479
480  dmesg
481
482 This returns the kernel messages (C<dmesg> output) from
483 the guest kernel.  This is sometimes useful for extended
484 debugging of problems.
485
486 Another way to get the same information is to enable
487 verbose messages with C<set-verbose> or by setting
488 the environment variable C<LIBGUESTFS_DEBUG=1> before
489 running the program.
490
491 =head2 download
492
493  download remotefilename (filename|-)
494
495 Download file C<remotefilename> and save it as C<filename>
496 on the local machine.
497
498 C<filename> can also be a named pipe.
499
500 See also C<upload>, C<cat>.
501
502 Use C<-> instead of a filename to read/write from stdin/stdout.
503
504 =head2 drop-caches
505
506  drop-caches whattodrop
507
508 This instructs the guest kernel to drop its page cache,
509 and/or dentries and inode caches.  The parameter C<whattodrop>
510 tells the kernel what precisely to drop, see
511 L<http://linux-mm.org/Drop_Caches>
512
513 Setting C<whattodrop> to 3 should drop everything.
514
515 This automatically calls L<sync(2)> before the operation,
516 so that the maximum guest memory is freed.
517
518 =head2 e2fsck-f
519
520  e2fsck-f device
521
522 This runs C<e2fsck -p -f device>, ie. runs the ext2/ext3
523 filesystem checker on C<device>, noninteractively (C<-p>),
524 even if the filesystem appears to be clean (C<-f>).
525
526 This command is only needed because of C<resize2fs>
527 (q.v.).  Normally you should use C<fsck>.
528
529 =head2 equal
530
531  equal file1 file2
532
533 This compares the two files C<file1> and C<file2> and returns
534 true if their content is exactly equal, or false otherwise.
535
536 The external L<cmp(1)> program is used for the comparison.
537
538 =head2 exists
539
540  exists path
541
542 This returns C<true> if and only if there is a file, directory
543 (or anything) with the given C<path> name.
544
545 See also C<is-file>, C<is-dir>, C<stat>.
546
547 =head2 file
548
549  file path
550
551 This call uses the standard L<file(1)> command to determine
552 the type or contents of the file.  This also works on devices,
553 for example to find out whether a partition contains a filesystem.
554
555 The exact command which runs is C<file -bsL path>.  Note in
556 particular that the filename is not prepended to the output
557 (the C<-b> option).
558
559 =head2 find
560
561  find directory
562
563 This command lists out all files and directories, recursively,
564 starting at C<directory>.  It is essentially equivalent to
565 running the shell command C<find directory -print> but some
566 post-processing happens on the output, described below.
567
568 This returns a list of strings I<without any prefix>.  Thus
569 if the directory structure was:
570
571  /tmp/a
572  /tmp/b
573  /tmp/c/d
574
575 then the returned list from C<find> C</tmp> would be
576 4 elements:
577
578  a
579  b
580  c
581  c/d
582
583 If C<directory> is not a directory, then this command returns
584 an error.
585
586 The returned list is sorted.
587
588 =head2 fsck
589
590  fsck fstype device
591
592 This runs the filesystem checker (fsck) on C<device> which
593 should have filesystem type C<fstype>.
594
595 The returned integer is the status.  See L<fsck(8)> for the
596 list of status codes from C<fsck>.
597
598 Notes:
599
600 =over 4
601
602 =item *
603
604 Multiple status codes can be summed together.
605
606 =item *
607
608 A non-zero return code can mean "success", for example if
609 errors have been corrected on the filesystem.
610
611 =item *
612
613 Checking or repairing NTFS volumes is not supported
614 (by linux-ntfs).
615
616 =back
617
618 This command is entirely equivalent to running C<fsck -a -t fstype device>.
619
620 =head2 get-append
621
622  get-append
623
624 Return the additional kernel options which are added to the
625 guest kernel command line.
626
627 If C<NULL> then no options are added.
628
629 =head2 get-autosync
630
631  get-autosync
632
633 Get the autosync flag.
634
635 =head2 get-e2label
636
637  get-e2label device
638
639 This returns the ext2/3/4 filesystem label of the filesystem on
640 C<device>.
641
642 =head2 get-e2uuid
643
644  get-e2uuid device
645
646 This returns the ext2/3/4 filesystem UUID of the filesystem on
647 C<device>.
648
649 =head2 get-path
650
651  get-path
652
653 Return the current search path.
654
655 This is always non-NULL.  If it wasn't set already, then this will
656 return the default path.
657
658 =head2 get-qemu
659
660  get-qemu
661
662 Return the current qemu binary.
663
664 This is always non-NULL.  If it wasn't set already, then this will
665 return the default qemu binary name.
666
667 =head2 get-state
668
669  get-state
670
671 This returns the current state as an opaque integer.  This is
672 only useful for printing debug and internal error messages.
673
674 For more information on states, see L<guestfs(3)>.
675
676 =head2 get-verbose
677
678  get-verbose
679
680 This returns the verbose messages flag.
681
682 =head2 grub-install
683
684  grub-install root device
685
686 This command installs GRUB (the Grand Unified Bootloader) on
687 C<device>, with the root directory being C<root>.
688
689 =head2 hexdump
690
691  hexdump path
692
693 This runs C<hexdump -C> on the given C<path>.  The result is
694 the human-readable, canonical hex dump of the file.
695
696 Because of the message protocol, there is a transfer limit 
697 of somewhere between 2MB and 4MB.  To transfer large files you should use
698 FTP.
699
700 =head2 is-busy
701
702  is-busy
703
704 This returns true iff this handle is busy processing a command
705 (in the C<BUSY> state).
706
707 For more information on states, see L<guestfs(3)>.
708
709 =head2 is-config
710
711  is-config
712
713 This returns true iff this handle is being configured
714 (in the C<CONFIG> state).
715
716 For more information on states, see L<guestfs(3)>.
717
718 =head2 is-dir
719
720  is-dir path
721
722 This returns C<true> if and only if there is a directory
723 with the given C<path> name.  Note that it returns false for
724 other objects like files.
725
726 See also C<stat>.
727
728 =head2 is-file
729
730  is-file path
731
732 This returns C<true> if and only if there is a file
733 with the given C<path> name.  Note that it returns false for
734 other objects like directories.
735
736 See also C<stat>.
737
738 =head2 is-launching
739
740  is-launching
741
742 This returns true iff this handle is launching the subprocess
743 (in the C<LAUNCHING> state).
744
745 For more information on states, see L<guestfs(3)>.
746
747 =head2 is-ready
748
749  is-ready
750
751 This returns true iff this handle is ready to accept commands
752 (in the C<READY> state).
753
754 For more information on states, see L<guestfs(3)>.
755
756 =head2 kill-subprocess
757
758  kill-subprocess
759
760 This kills the qemu subprocess.  You should never need to call this.
761
762 =head2 launch | run
763
764  launch
765
766 Internally libguestfs is implemented by running a virtual machine
767 using L<qemu(1)>.
768
769 You should call this after configuring the handle
770 (eg. adding drives) but before performing any actions.
771
772 =head2 list-devices
773
774  list-devices
775
776 List all the block devices.
777
778 The full block device names are returned, eg. C</dev/sda>
779
780 =head2 list-partitions
781
782  list-partitions
783
784 List all the partitions detected on all block devices.
785
786 The full partition device names are returned, eg. C</dev/sda1>
787
788 This does not return logical volumes.  For that you will need to
789 call C<lvs>.
790
791 =head2 ll
792
793  ll directory
794
795 List the files in C<directory> (relative to the root directory,
796 there is no cwd) in the format of 'ls -la'.
797
798 This command is mostly useful for interactive sessions.  It
799 is I<not> intended that you try to parse the output string.
800
801 =head2 ls
802
803  ls directory
804
805 List the files in C<directory> (relative to the root directory,
806 there is no cwd).  The '.' and '..' entries are not returned, but
807 hidden files are shown.
808
809 This command is mostly useful for interactive sessions.  Programs
810 should probably use C<readdir> instead.
811
812 =head2 lstat
813
814  lstat path
815
816 Returns file information for the given C<path>.
817
818 This is the same as C<stat> except that if C<path>
819 is a symbolic link, then the link is stat-ed, not the file it
820 refers to.
821
822 This is the same as the C<lstat(2)> system call.
823
824 =head2 lvcreate
825
826  lvcreate logvol volgroup mbytes
827
828 This creates an LVM volume group called C<logvol>
829 on the volume group C<volgroup>, with C<size> megabytes.
830
831 =head2 lvm-remove-all
832
833  lvm-remove-all
834
835 This command removes all LVM logical volumes, volume groups
836 and physical volumes.
837
838 B<This command is dangerous.  Without careful use you
839 can easily destroy all your data>.
840
841 =head2 lvremove
842
843  lvremove device
844
845 Remove an LVM logical volume C<device>, where C<device> is
846 the path to the LV, such as C</dev/VG/LV>.
847
848 You can also remove all LVs in a volume group by specifying
849 the VG name, C</dev/VG>.
850
851 =head2 lvresize
852
853  lvresize device mbytes
854
855 This resizes (expands or shrinks) an existing LVM logical
856 volume to C<mbytes>.  When reducing, data in the reduced part
857 is lost.
858
859 =head2 lvs
860
861  lvs
862
863 List all the logical volumes detected.  This is the equivalent
864 of the L<lvs(8)> command.
865
866 This returns a list of the logical volume device names
867 (eg. C</dev/VolGroup00/LogVol00>).
868
869 See also C<lvs-full>.
870
871 =head2 lvs-full
872
873  lvs-full
874
875 List all the logical volumes detected.  This is the equivalent
876 of the L<lvs(8)> command.  The "full" version includes all fields.
877
878 =head2 mkdir
879
880  mkdir path
881
882 Create a directory named C<path>.
883
884 =head2 mkdir-p
885
886  mkdir-p path
887
888 Create a directory named C<path>, creating any parent directories
889 as necessary.  This is like the C<mkdir -p> shell command.
890
891 =head2 mkfs
892
893  mkfs fstype device
894
895 This creates a filesystem on C<device> (usually a partition
896 or LVM logical volume).  The filesystem type is C<fstype>, for
897 example C<ext3>.
898
899 =head2 mount
900
901  mount device mountpoint
902
903 Mount a guest disk at a position in the filesystem.  Block devices
904 are named C</dev/sda>, C</dev/sdb> and so on, as they were added to
905 the guest.  If those block devices contain partitions, they will have
906 the usual names (eg. C</dev/sda1>).  Also LVM C</dev/VG/LV>-style
907 names can be used.
908
909 The rules are the same as for L<mount(2)>:  A filesystem must
910 first be mounted on C</> before others can be mounted.  Other
911 filesystems can only be mounted on directories which already
912 exist.
913
914 The mounted filesystem is writable, if we have sufficient permissions
915 on the underlying device.
916
917 The filesystem options C<sync> and C<noatime> are set with this
918 call, in order to improve reliability.
919
920 =head2 mount-options
921
922  mount-options options device mountpoint
923
924 This is the same as the C<mount> command, but it
925 allows you to set the mount options as for the
926 L<mount(8)> I<-o> flag.
927
928 =head2 mount-ro
929
930  mount-ro device mountpoint
931
932 This is the same as the C<mount> command, but it
933 mounts the filesystem with the read-only (I<-o ro>) flag.
934
935 =head2 mount-vfs
936
937  mount-vfs options vfstype device mountpoint
938
939 This is the same as the C<mount> command, but it
940 allows you to set both the mount options and the vfstype
941 as for the L<mount(8)> I<-o> and I<-t> flags.
942
943 =head2 mounts
944
945  mounts
946
947 This returns the list of currently mounted filesystems.  It returns
948 the list of devices (eg. C</dev/sda1>, C</dev/VG/LV>).
949
950 Some internal mounts are not shown.
951
952 =head2 mv
953
954  mv src dest
955
956 This moves a file from C<src> to C<dest> where C<dest> is
957 either a destination filename or destination directory.
958
959 =head2 ping-daemon
960
961  ping-daemon
962
963 This is a test probe into the guestfs daemon running inside
964 the qemu subprocess.  Calling this function checks that the
965 daemon responds to the ping message, without affecting the daemon
966 or attached block device(s) in any other way.
967
968 =head2 pvcreate
969
970  pvcreate device
971
972 This creates an LVM physical volume on the named C<device>,
973 where C<device> should usually be a partition name such
974 as C</dev/sda1>.
975
976 =head2 pvremove
977
978  pvremove device
979
980 This wipes a physical volume C<device> so that LVM will no longer
981 recognise it.
982
983 The implementation uses the C<pvremove> command which refuses to
984 wipe physical volumes that contain any volume groups, so you have
985 to remove those first.
986
987 =head2 pvresize
988
989  pvresize device
990
991 This resizes (expands or shrinks) an existing LVM physical
992 volume to match the new size of the underlying device.
993
994 =head2 pvs
995
996  pvs
997
998 List all the physical volumes detected.  This is the equivalent
999 of the L<pvs(8)> command.
1000
1001 This returns a list of just the device names that contain
1002 PVs (eg. C</dev/sda2>).
1003
1004 See also C<pvs-full>.
1005
1006 =head2 pvs-full
1007
1008  pvs-full
1009
1010 List all the physical volumes detected.  This is the equivalent
1011 of the L<pvs(8)> command.  The "full" version includes all fields.
1012
1013 =head2 read-lines
1014
1015  read-lines path
1016
1017 Return the contents of the file named C<path>.
1018
1019 The file contents are returned as a list of lines.  Trailing
1020 C<LF> and C<CRLF> character sequences are I<not> returned.
1021
1022 Note that this function cannot correctly handle binary files
1023 (specifically, files containing C<\0> character which is treated
1024 as end of line).  For those you need to use the C<read-file>
1025 function which has a more complex interface.
1026
1027 =head2 resize2fs
1028
1029  resize2fs device
1030
1031 This resizes an ext2 or ext3 filesystem to match the size of
1032 the underlying device.
1033
1034 I<Note:> It is sometimes required that you run C<e2fsck-f>
1035 on the C<device> before calling this command.  For unknown reasons
1036 C<resize2fs> sometimes gives an error about this and sometimes not.
1037 In any case, it is always safe to call C<e2fsck-f> before
1038 calling this function.
1039
1040 =head2 rm
1041
1042  rm path
1043
1044 Remove the single file C<path>.
1045
1046 =head2 rm-rf
1047
1048  rm-rf path
1049
1050 Remove the file or directory C<path>, recursively removing the
1051 contents if its a directory.  This is like the C<rm -rf> shell
1052 command.
1053
1054 =head2 rmdir
1055
1056  rmdir path
1057
1058 Remove the single directory C<path>.
1059
1060 =head2 set-append | append
1061
1062  set-append append
1063
1064 This function is used to add additional options to the
1065 guest kernel command line.
1066
1067 The default is C<NULL> unless overridden by setting
1068 C<LIBGUESTFS_APPEND> environment variable.
1069
1070 Setting C<append> to C<NULL> means I<no> additional options
1071 are passed (libguestfs always adds a few of its own).
1072
1073 =head2 set-autosync | autosync
1074
1075  set-autosync true|false
1076
1077 If C<autosync> is true, this enables autosync.  Libguestfs will make a
1078 best effort attempt to run C<umount-all> followed by
1079 C<sync> when the handle is closed
1080 (also if the program exits without closing handles).
1081
1082 This is disabled by default (except in guestfish where it is
1083 enabled by default).
1084
1085 =head2 set-e2label
1086
1087  set-e2label device label
1088
1089 This sets the ext2/3/4 filesystem label of the filesystem on
1090 C<device> to C<label>.  Filesystem labels are limited to
1091 16 characters.
1092
1093 You can use either C<tune2fs-l> or C<get-e2label>
1094 to return the existing label on a filesystem.
1095
1096 =head2 set-e2uuid
1097
1098  set-e2uuid device uuid
1099
1100 This sets the ext2/3/4 filesystem UUID of the filesystem on
1101 C<device> to C<uuid>.  The format of the UUID and alternatives
1102 such as C<clear>, C<random> and C<time> are described in the
1103 L<tune2fs(8)> manpage.
1104
1105 You can use either C<tune2fs-l> or C<get-e2uuid>
1106 to return the existing UUID of a filesystem.
1107
1108 =head2 set-path | path
1109
1110  set-path path
1111
1112 Set the path that libguestfs searches for kernel and initrd.img.
1113
1114 The default is C<$libdir/guestfs> unless overridden by setting
1115 C<LIBGUESTFS_PATH> environment variable.
1116
1117 Setting C<path> to C<NULL> restores the default path.
1118
1119 =head2 set-qemu | qemu
1120
1121  set-qemu qemu
1122
1123 Set the qemu binary that we will use.
1124
1125 The default is chosen when the library was compiled by the
1126 configure script.
1127
1128 You can also override this by setting the C<LIBGUESTFS_QEMU>
1129 environment variable.
1130
1131 Setting C<qemu> to C<NULL> restores the default qemu binary.
1132
1133 =head2 set-verbose | verbose
1134
1135  set-verbose true|false
1136
1137 If C<verbose> is true, this turns on verbose messages (to C<stderr>).
1138
1139 Verbose messages are disabled unless the environment variable
1140 C<LIBGUESTFS_DEBUG> is defined and set to C<1>.
1141
1142 =head2 sfdisk
1143
1144  sfdisk device cyls heads sectors 'lines ...'
1145
1146 This is a direct interface to the L<sfdisk(8)> program for creating
1147 partitions on block devices.
1148
1149 C<device> should be a block device, for example C</dev/sda>.
1150
1151 C<cyls>, C<heads> and C<sectors> are the number of cylinders, heads
1152 and sectors on the device, which are passed directly to sfdisk as
1153 the I<-C>, I<-H> and I<-S> parameters.  If you pass C<0> for any
1154 of these, then the corresponding parameter is omitted.  Usually for
1155 'large' disks, you can just pass C<0> for these, but for small
1156 (floppy-sized) disks, sfdisk (or rather, the kernel) cannot work
1157 out the right geometry and you will need to tell it.
1158
1159 C<lines> is a list of lines that we feed to C<sfdisk>.  For more
1160 information refer to the L<sfdisk(8)> manpage.
1161
1162 To create a single partition occupying the whole disk, you would
1163 pass C<lines> as a single element list, when the single element being
1164 the string C<,> (comma).
1165
1166 See also: C<sfdisk-l>, C<sfdisk-N>
1167
1168 B<This command is dangerous.  Without careful use you
1169 can easily destroy all your data>.
1170
1171 =head2 sfdisk-N
1172
1173  sfdisk-N device n cyls heads sectors line
1174
1175 This runs L<sfdisk(8)> option to modify just the single
1176 partition C<n> (note: C<n> counts from 1).
1177
1178 For other parameters, see C<sfdisk>.  You should usually
1179 pass C<0> for the cyls/heads/sectors parameters.
1180
1181 B<This command is dangerous.  Without careful use you
1182 can easily destroy all your data>.
1183
1184 =head2 sfdisk-disk-geometry
1185
1186  sfdisk-disk-geometry device
1187
1188 This displays the disk geometry of C<device> read from the
1189 partition table.  Especially in the case where the underlying
1190 block device has been resized, this can be different from the
1191 kernel's idea of the geometry (see C<sfdisk-kernel-geometry>).
1192
1193 The result is in human-readable format, and not designed to
1194 be parsed.
1195
1196 =head2 sfdisk-kernel-geometry
1197
1198  sfdisk-kernel-geometry device
1199
1200 This displays the kernel's idea of the geometry of C<device>.
1201
1202 The result is in human-readable format, and not designed to
1203 be parsed.
1204
1205 =head2 sfdisk-l
1206
1207  sfdisk-l device
1208
1209 This displays the partition table on C<device>, in the
1210 human-readable output of the L<sfdisk(8)> command.  It is
1211 not intended to be parsed.
1212
1213 =head2 stat
1214
1215  stat path
1216
1217 Returns file information for the given C<path>.
1218
1219 This is the same as the C<stat(2)> system call.
1220
1221 =head2 statvfs
1222
1223  statvfs path
1224
1225 Returns file system statistics for any mounted file system.
1226 C<path> should be a file or directory in the mounted file system
1227 (typically it is the mount point itself, but it doesn't need to be).
1228
1229 This is the same as the C<statvfs(2)> system call.
1230
1231 =head2 strings
1232
1233  strings path
1234
1235 This runs the L<strings(1)> command on a file and returns
1236 the list of printable strings found.
1237
1238 Because of the message protocol, there is a transfer limit 
1239 of somewhere between 2MB and 4MB.  To transfer large files you should use
1240 FTP.
1241
1242 =head2 strings-e
1243
1244  strings-e encoding path
1245
1246 This is like the C<strings> command, but allows you to
1247 specify the encoding.
1248
1249 See the L<strings(1)> manpage for the full list of encodings.
1250
1251 Commonly useful encodings are C<l> (lower case L) which will
1252 show strings inside Windows/x86 files.
1253
1254 The returned strings are transcoded to UTF-8.
1255
1256 Because of the message protocol, there is a transfer limit 
1257 of somewhere between 2MB and 4MB.  To transfer large files you should use
1258 FTP.
1259
1260 =head2 sync
1261
1262  sync
1263
1264 This syncs the disk, so that any writes are flushed through to the
1265 underlying disk image.
1266
1267 You should always call this if you have modified a disk image, before
1268 closing the handle.
1269
1270 =head2 tar-in
1271
1272  tar-in (tarfile|-) directory
1273
1274 This command uploads and unpacks local file C<tarfile> (an
1275 I<uncompressed> tar file) into C<directory>.
1276
1277 To upload a compressed tarball, use C<tgz-in>.
1278
1279 Use C<-> instead of a filename to read/write from stdin/stdout.
1280
1281 =head2 tar-out
1282
1283  tar-out directory (tarfile|-)
1284
1285 This command packs the contents of C<directory> and downloads
1286 it to local file C<tarfile>.
1287
1288 To download a compressed tarball, use C<tgz-out>.
1289
1290 Use C<-> instead of a filename to read/write from stdin/stdout.
1291
1292 =head2 tgz-in
1293
1294  tgz-in (tarball|-) directory
1295
1296 This command uploads and unpacks local file C<tarball> (a
1297 I<gzip compressed> tar file) into C<directory>.
1298
1299 To upload an uncompressed tarball, use C<tar-in>.
1300
1301 Use C<-> instead of a filename to read/write from stdin/stdout.
1302
1303 =head2 tgz-out
1304
1305  tgz-out directory (tarball|-)
1306
1307 This command packs the contents of C<directory> and downloads
1308 it to local file C<tarball>.
1309
1310 To download an uncompressed tarball, use C<tar-out>.
1311
1312 Use C<-> instead of a filename to read/write from stdin/stdout.
1313
1314 =head2 touch
1315
1316  touch path
1317
1318 Touch acts like the L<touch(1)> command.  It can be used to
1319 update the timestamps on a file, or, if the file does not exist,
1320 to create a new zero-length file.
1321
1322 =head2 tune2fs-l
1323
1324  tune2fs-l device
1325
1326 This returns the contents of the ext2, ext3 or ext4 filesystem
1327 superblock on C<device>.
1328
1329 It is the same as running C<tune2fs -l device>.  See L<tune2fs(8)>
1330 manpage for more details.  The list of fields returned isn't
1331 clearly defined, and depends on both the version of C<tune2fs>
1332 that libguestfs was built against, and the filesystem itself.
1333
1334 =head2 umount | unmount
1335
1336  umount pathordevice
1337
1338 This unmounts the given filesystem.  The filesystem may be
1339 specified either by its mountpoint (path) or the device which
1340 contains the filesystem.
1341
1342 =head2 umount-all | unmount-all
1343
1344  umount-all
1345
1346 This unmounts all mounted filesystems.
1347
1348 Some internal mounts are not unmounted by this call.
1349
1350 =head2 upload
1351
1352  upload (filename|-) remotefilename
1353
1354 Upload local file C<filename> to C<remotefilename> on the
1355 filesystem.
1356
1357 C<filename> can also be a named pipe.
1358
1359 See also C<download>.
1360
1361 Use C<-> instead of a filename to read/write from stdin/stdout.
1362
1363 =head2 vg-activate
1364
1365  vg-activate true|false 'volgroups ...'
1366
1367 This command activates or (if C<activate> is false) deactivates
1368 all logical volumes in the listed volume groups C<volgroups>.
1369 If activated, then they are made known to the
1370 kernel, ie. they appear as C</dev/mapper> devices.  If deactivated,
1371 then those devices disappear.
1372
1373 This command is the same as running C<vgchange -a y|n volgroups...>
1374
1375 Note that if C<volgroups> is an empty list then B<all> volume groups
1376 are activated or deactivated.
1377
1378 =head2 vg-activate-all
1379
1380  vg-activate-all true|false
1381
1382 This command activates or (if C<activate> is false) deactivates
1383 all logical volumes in all volume groups.
1384 If activated, then they are made known to the
1385 kernel, ie. they appear as C</dev/mapper> devices.  If deactivated,
1386 then those devices disappear.
1387
1388 This command is the same as running C<vgchange -a y|n>
1389
1390 =head2 vgcreate
1391
1392  vgcreate volgroup 'physvols ...'
1393
1394 This creates an LVM volume group called C<volgroup>
1395 from the non-empty list of physical volumes C<physvols>.
1396
1397 =head2 vgremove
1398
1399  vgremove vgname
1400
1401 Remove an LVM volume group C<vgname>, (for example C<VG>).
1402
1403 This also forcibly removes all logical volumes in the volume
1404 group (if any).
1405
1406 =head2 vgs
1407
1408  vgs
1409
1410 List all the volumes groups detected.  This is the equivalent
1411 of the L<vgs(8)> command.
1412
1413 This returns a list of just the volume group names that were
1414 detected (eg. C<VolGroup00>).
1415
1416 See also C<vgs-full>.
1417
1418 =head2 vgs-full
1419
1420  vgs-full
1421
1422 List all the volumes groups detected.  This is the equivalent
1423 of the L<vgs(8)> command.  The "full" version includes all fields.
1424
1425 =head2 write-file
1426
1427  write-file path content size
1428
1429 This call creates a file called C<path>.  The contents of the
1430 file is the string C<content> (which can contain any 8 bit data),
1431 with length C<size>.
1432
1433 As a special case, if C<size> is C<0>
1434 then the length is calculated using C<strlen> (so in this case
1435 the content cannot contain embedded ASCII NULs).
1436
1437 I<NB.> Owing to a bug, writing content containing ASCII NUL
1438 characters does I<not> work, even if the length is specified.
1439 We hope to resolve this bug in a future version.  In the meantime
1440 use C<upload>.
1441
1442 Because of the message protocol, there is a transfer limit 
1443 of somewhere between 2MB and 4MB.  To transfer large files you should use
1444 FTP.
1445
1446 =head2 zero
1447
1448  zero device
1449
1450 This command writes zeroes over the first few blocks of C<device>.
1451
1452 How many blocks are zeroed isn't specified (but it's I<not> enough
1453 to securely wipe the device).  It should be sufficient to remove
1454 any partition tables, filesystem superblocks and so on.
1455
1456 =head2 zerofree
1457
1458  zerofree device
1459
1460 This runs the I<zerofree> program on C<device>.  This program
1461 claims to zero unused inodes and disk blocks on an ext2/3
1462 filesystem, thus making it possible to compress the filesystem
1463 more effectively.
1464
1465 You should B<not> run this program if the filesystem is
1466 mounted.
1467
1468 It is possible that using this program can damage the filesystem
1469 or data on the filesystem.
1470