X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=perl%2Flib%2FSys%2FGuestfs.pm;h=436f218c4d17680377afd7249f8e805f555c4772;hp=0a8226fea8b7864d9e0c0ab6c0291c4d5231d711;hb=ad8a256f54a6cb99f89bb444c8597a152a793dce;hpb=9908e03e922b670437bcd89b6873f9ebc914567e diff --git a/perl/lib/Sys/Guestfs.pm b/perl/lib/Sys/Guestfs.pm index 0a8226f..436f218 100644 --- a/perl/lib/Sys/Guestfs.pm +++ b/perl/lib/Sys/Guestfs.pm @@ -91,10 +91,19 @@ sub new { return $self; } -=item $h->add_drive ($filename); - =item $h->add_cdrom ($filename); +This function adds a virtual CD-ROM disk image to the guest. + +This is equivalent to the qemu parameter C<-cdrom filename>. + +Note that this call checks for the existence of C. This +stops you from specifying other types of drive which are supported +by qemu such as C and C URLs. To specify those, use +the general C<$h-Econfig> call instead. + +=item $h->add_drive ($filename); + This function adds a virtual machine disk image C to the guest. The first time you call this function, the disk appears as IDE disk 0 (C) in the guest, the second time as C, and @@ -106,60 +115,650 @@ for whatever operations you want to perform (ie. read access if you just want to read the image or write access if you want to modify the image). -The C variation adds a CD-ROM device. +This is equivalent to the qemu parameter C<-drive file=filename>. -=item $h->config ($param, $value); +Note that this call checks for the existence of C. This +stops you from specifying other types of drive which are supported +by qemu such as C and C URLs. To specify those, use +the general C<$h-Econfig> call instead. -=item $h->config ($param); +=item $h->add_drive_ro ($filename); -Use this to add arbitrary parameters to the C command line. -See L. +This adds a drive in snapshot mode, making it effectively +read-only. -=item $h->launch (); +Note that writes to the device are allowed, and will be seen for +the duration of the guestfs handle, but they are written +to a temporary file which is discarded as soon as the guestfs +handle is closed. We don't currently have any method to enable +changes to be committed, although qemu can support this. -=item $h->wait_ready (); +This is equivalent to the qemu parameter +C<-drive file=filename,snapshot=on>. -Internally libguestfs is implemented by running a virtual machine -using L. These calls are necessary in order to boot the -virtual machine. +Note that this call checks for the existence of C. This +stops you from specifying other types of drive which are supported +by qemu such as C and C URLs. To specify those, use +the general C<$h-Econfig> call instead. -You should call these two functions after configuring the handle -(eg. adding drives) but before performing any actions. +=item $h->aug_close (); -=item $h->set_path ($path); +Close the current Augeas handle and free up any resources +used by it. After calling this, you have to call +C<$h-Eaug_init> again before you can use any other +Augeas functions. -=item $path = $h->get_path (); +=item ($nrnodes, $created) = $h->aug_defnode ($name, $expr, $val); -See the discussion of C in the L -manpage. +Defines a variable C whose value is the result of +evaluating C. -=item $h->set_autosync ($autosync); +If C evaluates to an empty nodeset, a node is created, +equivalent to calling C<$h-Eaug_set> C, C. +C will be the nodeset containing that single node. -=item $autosync = $h->get_autosync (); +On success this returns a pair containing the +number of nodes in the nodeset, and a boolean flag +if a node was created. -See the discussion of I in the L -manpage. +=item $nrnodes = $h->aug_defvar ($name, $expr); -=item $h->set_verbose ($verbose); +Defines an Augeas variable C whose value is the result +of evaluating C. If C is NULL, then C is +undefined. -=item $verbose = $h->get_verbose (); +On success this returns the number of nodes in C, or +C<0> if C evaluates to something which is not a nodeset. + +=item $val = $h->aug_get ($path); + +Look up the value associated with C. If C +matches exactly one node, the C is returned. + +=item $h->aug_init ($root, $flags); + +Create a new Augeas handle for editing configuration files. +If there was any previous Augeas handle associated with this +guestfs session, then it is closed. + +You must call this before using any other C<$h-Eaug_*> +commands. + +C is the filesystem root. C must not be NULL, +use C instead. + +The flags are the same as the flags defined in +Eaugeas.hE, the logical I of the following +integers: + +=over 4 + +=item C = 1 + +Keep the original file with a C<.augsave> extension. + +=item C = 2 + +Save changes into a file with extension C<.augnew>, and +do not overwrite original. Overrides C. + +=item C = 4 + +Typecheck lenses (can be expensive). + +=item C = 8 + +Do not use standard load path for modules. + +=item C = 16 + +Make save a no-op, just record what would have been changed. + +=item C = 32 + +Do not load the tree in C<$h-Eaug_init>. + +=back + +To close the handle, you can call C<$h-Eaug_close>. + +To find out more about Augeas, see L. + +=item $h->aug_insert ($path, $label, $before); + +Create a new sibling C