51 Commits

Author SHA1 Message Date
Richard W.M. Jones
72cfaff5c5 Update copyright dates for 2025
Automated using this command:

perl -pi.bak -e 's/(20[012][0-9])-20[12][01234]/$1-2025/g' `git ls-files`
2025-02-16 17:00:46 +00:00
Richard W.M. Jones
e2c7bddf10 Update copyright dates for 2023
Run this command across the source:

  perl -pi.bak -e 's/(20[012][0-9])-20[12][012]/$1-2023/g' `git ls-files`

and remove changes to po{,-docs}/*.po{,t} (these will be regenerated
later when we run 'make dist').
2023-02-07 10:50:48 +00:00
Richard W.M. Jones
0e17236d7d Update copyright dates to 2020. 2020-03-06 19:32:32 +00:00
Pino Toscano
19ce506ccb perl: silence usage of add_cdrom in test
One test explicitly tests add_cdrom, so silence the deprecation warning
only for that function.
2019-04-24 12:49:28 +02:00
Richard W.M. Jones
05d4fcb64d Update copyright dates for 2019.
This command run over the source:

perl -pi.bak -e 's/(20[01][0-9])-2018/$1-2019/g' `git ls-files`
2019-01-08 11:58:30 +00:00
Richard W.M. Jones
212762c593 Update copyright dates for 2018.
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2017/$1-2018/g' `git ls-files`
2018-01-04 15:30:10 +00:00
Pino Toscano
b06cc25a58 perl: drop %guestfs_introspection stuff
It is not something standard, and actually unused by libguestfs itself.
Possibly going to be used by the old virt-v2v (which was in Perl), but
never used for that either.
2017-05-04 10:51:29 +02:00
Pino Toscano
55bf7de97c Update copyright dates for 2017
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2016/$1-2017/g' `git ls-files`

(Thanks Rich for the perl snippet, as used in past years.)
2017-01-03 16:48:21 +01:00
Pino Toscano
f7765ea6e4 Start adding return values tests for bindings
Introduce a new kind of bindings tests, 090-retvalues, to check all the
possible return values in bindings; start implementing them for
scripting languages such as GObject introspection, Perl, PHP, Python,
and Ruby, reusing existing implementations where existing.
2016-02-15 18:32:07 +01:00
Richard W.M. Jones
85b1815e7b tests: Make '080' be an official test of the guestfs_version API.
Useful because it tests returning a single structure.
2016-02-12 15:41:42 +00:00
Richard W.M. Jones
307c83177c Update copyright dates for 2016.
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2015/$1-2016/g' `git ls-files`
2016-01-02 21:19:51 +00:00
Pino Toscano
668c4784a9 perl: tests: reenable set_path tests
guestfs_set_path now does a copy of the passed string, so bindings don't
need to take care of the lifetime of strings parameters for it.
2015-02-09 11:00:47 +01:00
Richard W.M. Jones
c5800dc97d Update copyright dates for 2015. 2015-01-17 09:08:15 +00:00
Richard W.M. Jones
6c971faecf Update copyright dates for 2014. 2014-01-02 16:53:34 +00:00
Richard W.M. Jones
92e1864913 events: Add a warning event and direct all warning messages through it.
This also causes warnings to be printed even in non-verbose mode,
which is useful.
2013-10-11 15:34:23 +01:00
Richard W.M. Jones
14fabcd88e tests: Use new guestfs_add_drive_scratch API where possible in tests.
Replaces code such as:

  fd = open "test1.img"
  ftruncate fd, size
  close fd
  g.add_drive "test1.img"

with the shorter and simpler:

  g.add_drive_scratch size
2013-07-20 16:31:42 +01:00
Richard W.M. Jones
897a69604d perl: Make the 030-create-flags test same as canonical OCaml version. 2013-04-30 15:42:31 +01:00
Richard W.M. Jones
d02af3a311 perl: Almost standardize the Perl tests.
This needs more work, but brings them mostly up to the same
standard form as the OCaml tests and the test documentation.
2013-04-29 16:10:49 +01:00
Richard W.M. Jones
667482ca9a perl: Remove Sys::Guestfs::Lib.
See announcement on the mailing list for more details about this change:

https://www.redhat.com/archives/libguestfs/2013-April/msg00001.html
2013-04-02 15:26:05 +01:00
Richard W.M. Jones
e9d83e94a2 perl: Add binding for guestfs_event_to_string. 2013-02-19 13:41:58 +00:00
Richard W.M. Jones
d14557d434 perl: Add test of multiple independent handles. 2012-11-19 09:39:30 +00:00
Richard W.M. Jones
4a2e8e8957 perl: Clean up and update the tests. 2012-11-17 18:14:20 +00:00
Richard W.M. Jones
3d0e937b84 perl: Small test of create with flags. 2012-11-17 17:55:06 +00:00
Richard W.M. Jones
d67e6ea75d Replace mount-options with mount where appropriate.
Since our minimum supported version is now 1.16 and mount was fixed in
1.13.16, it is now safe to replace mount-options + empty options with
mount wherever it occurs.
2012-08-18 22:08:29 +01:00
Richard W.M. Jones
a99ea198b2 perl: Use $g instead of $h in documentation.
$g is the "standard" name for libguestfs handles.
2012-07-17 12:33:45 +01:00
Richard W.M. Jones
7486fc6f43 generator: Rename 'add_drive_opts' API to 'add_drive'.
By using the once_had_no_optargs flag, this change is backwards
compatible for callers (except Haskell, PHP and GObject as discussed
in earlier commit).
2012-07-14 12:42:24 +01:00
Richard W.M. Jones
e452a0b8ca tests: Rename test0* functions as internal_test*.
The internal_* prefix is reserved for internal functions
such as these tests.
2012-07-11 23:56:10 +01:00
Richard W.M. Jones
729bb9c6b5 launch: Treat /dev/null specially, for old KVM.
Old KVM can't add /dev/null readonly.  Treat /dev/null as a special
case.

We also fix a few tests where /dev/null was being used with
format=qcow2.  This was always incorrect behaviour, but qemu appears
to tolerate it.
2012-06-25 11:20:35 +01:00
Richard W.M. Jones
a505423e58 lib: Remove the BUSY state.
Originally this state was intended so that in some way you could find
out if the appliance was running a command.  However there was never a
thread-safe way to access the state of the handle, so in effect you
could never do anything useful safely with this information.

This commit completely removes the BUSY state.

The only visible change is to the guestfs_is_busy API.  Previously you
could never call this safely from another thread.  If you called it
from the same thread it would always return false (since the current
thread can't be running a libguestfs command at that point by
definition).  Now it always returns false.
2012-04-26 16:48:47 +01:00
Matthew Booth
04ea1375c5 Update FSF address. 2011-11-08 14:43:07 +00:00
Richard W.M. Jones
365885dab2 perl: Add %guestfs_introspection hash with introspection information.
Because this is a useful introspection API, it is a candidate for
being backported into older stable branches.
2011-10-28 14:04:47 +01:00
Richard W.M. Jones
883390fb2e perl: Binding and test for guestfs_last_errno (RHBZ#672491). 2011-03-15 16:49:12 +00:00
Richard W.M. Jones
bc468c87d0 New event API - Perl bindings (RHBZ#664558).
The methods $h->set_progress_callback and $h->clear_progress_callback
have been removed, and replaced with a complete mechanism for setting
and deleting general-purpose events.

This also updates virt-resize to use the new API.
2011-03-15 12:16:51 +00:00
Richard W.M. Jones
6975e87153 perl: Ignore internal_* functions in POD coverage test.
This updates commit 1d999540bd.
2011-01-29 07:01:06 +00:00
Richard W.M. Jones
3431f397d3 perl: Ignore debug functions in Test::Pod::Coverage. 2010-11-11 22:25:20 +00:00
Richard W.M. Jones
14490c3e1a generator: Optional arguments, add-drive-opts (RHBZ#642934,CVE-2010-3851).
This large commit changes the generator so that optional arguments
can be supported for functions.

The model for arguments (known as the "style") is changed from
(ret, args) to (ret, args, optargs) where optargs is a more limited
list of arguments.

One function has been added which takes optional arguments, it is
"add-drive-opts", modelled as:

  (RErr, [String "filename"], #required
         [Bool "readonly"; String "format"; String "iface"]) #optional

Note that this function is processed in the library (does not go over
the RPC protocol to the daemon).  This has allowed us to simplify
the current implementation by omitting changes related to RPC or the
daemon, although we plan to add these at some point in the future.

From C this function can be called in 3 different ways as in these
examples:

  guestfs_add_drive_opts (g, filename,
                          GUESTFS_ADD_DRIVE_OPTS_READONLY, 1,
			  GUESTFS_ADD_DRIVE_OPTS_FORMAT, "raw",
                          -1);

(the argument(s) between 'filename' and '-1' are the optional ones).

  guestfs_add_drive_opts_va (g, filename, args);

where 'args' is a va_list.  This works like the first version.

  struct guestfs_add_drive_opts_argv optargs = {
    .bitmask = GUESTFS_ADD_DRIVE_OPTS_READONLY_BITMASK,
    .readonly = 1,
  }
  guestfs_add_drive_opts_argv (g, filename, &optargs);

This last form lets you construct lists of optional arguments, and
is used by guestfish and the language bindings.

In guestfish optional arguments are used like this:

  add-drive-opts filename readonly:true

In OCaml these are mapped naturally to OCaml optional arguments, eg:

  g#add_drive_opts ~readonly:true filename;

In Perl these are mapped to extra arguments, eg:

  $g->add_drive_opts ($filename, readonly => 1);

In Python these are mapped to optional arguments, eg:

  g.add_drive_opts ("file", readonly = 1, format = "qcow2")

In Ruby these are mapped to a final hash argument, eg:

  g.add_drive_opts("file", {})
  g.add_drive_opts("file", :readonly => 1)
  g.add_drive_opts("file", :readonly => 1, :iface => "virtio")

In PHP these are mapped to extra parameters.  This is not quite
accurate since you cannot omit arbitrary optional parameters, but
there's not much than can be done within the limitations of PHP
as a language.

Unimplemented in: Haskell, C#, Java.
2010-10-22 17:45:00 +01:00
Richard Jones
ad4cff2625 New API: file-architecture
This change simply converts the existing Perl-only function
file_architecture into a core API call.  The core API call is
written in C and available in all languages and from guestfish.
2010-08-17 14:09:25 +01:00
Richard Jones
eb566f7dc7 perl: Add explicit close() method (RHBZ#602592).
This add an optional explicit $g->close method which may be
used to force the handle to be closed immediately.  Note the
provisos about this method in the manual page entry.  Callers
should *not* normally use this method.

The implementation of the handle also changes.  Before, the
handle was a blessed reference to an integer (the integer
being the pointer to the C guestfs_h handle).  Now we change
this to a hashref containing currently the following field:

  _g => pointer to C guestfs_h handle (as an integer)

If this field is not present, it means that the handle has been
explicitly closed.  This avoids double-freeing the handle.

The user may add their own fields to this hash in order to store
per-handle data.  However any fields whose names begin with
an underscore are reserved for use by the Perl bindings.

This commit also adds a regression test.

This commit also changes the existing warning when you call
a method without a Sys::Guestfs handle as the first parameter,
into an error.  This is because such cases are always errors.
2010-06-10 17:52:54 +01:00
Richard Jones
f93cbe5756 Use mount-options instead of mount to avoid implicit -o sync.
guestfs_mount adds -o sync implicitly.  This causes a very large
performance problem for write-intensive programs (eg. virt-v2v).

Document this as a "gotcha".

Change the tests, guestfish, Sys::Guestfs::Lib, guestmount to use
mount-options instead.

(Note that this gotcha does not affect mount-ro).

The source of the performance problem was first identified by
Matthew Booth.
2010-02-10 10:46:23 +00:00
Richard Jones
b1e1ca2f74 Generic partition creation interface.
This commit introduces a generic partition creation interface
which should be future-proof and extensible, and partially
replaces the old sfdisk-based interface.

The implementation is based on parted but is hopefully not too
dependent on the particulars of parted.

The following new calls are introduced:

  guestfs_part_init:
    Initialize a disk with a partition table.  Unlike the sfdisk-
    based interface, we also support GPT and other partition
    types, which is essential to scale to devices larger than 2TB.

  guestfs_part_add: Add a partition to an existing disk.

  guestfs_part_disk:
    Convenience function which combines part_init & part_add,
    creating a single partition that covers the whole disk.

  guestfs_part_set_bootable:
  guestfs_part_set_name:
    Set various aspects of existing partitions.

  guestfs_part_list:
    List partitions on a device.  This returns a programming-friendly
    list of partition structs (in contrast to sfdisk-l which cannot
    be parsed).

  guestfs_part_get_parttype:
    Return the partition table type, eg. "msdos" or "gpt".

The following calls are planned, but not added currently:

  guestfs_part_get_bootable
  guestfs_part_get_name
  guestfs_part_set_type
  guestfs_part_get_type
2009-11-10 16:32:20 +00:00
Richard Jones
8869adf1e8 Remove guestfs_wait_ready (turn it into a no-op).
This commit changes guestfs_launch so that it both launches
the appliance and waits until it is ready (ie. the daemon communicates
back to us).

Since we removed the pretence that we could implement a low-level
asynchronous API, the need to call launch() followed by wait_ready()
has looked a bit silly.

Now guestfs_wait_ready() is basically a no-op.  It is left in the
API for backwards compatibility.  Any calls to guestfs_wait_ready()
can be removed from client code.
2009-09-21 12:01:51 +01:00
Richard W.M. Jones
0c92c583d5 tests: Found three more references to the squashfs, replaced with ISO. 2009-08-19 21:37:56 +01:00
Jim Meyering
2f1a50d816 Convert all TABs-as-indentation to spaces.
Do it by running this command:
[exempted files are matched via .x-sc_TAB_in_indentation]

  git ls-files \
    | pcregrep -vf .x-sc_TAB_in_indentation \
    | xargs pcregrep -l '^ *\t' \
    | xargs perl -MText::Tabs -ni -le \
      '$m=/^( *\t[ \t]*)(.*)/; print $m ? expand($1) . $2 : $_'
2009-08-03 17:17:57 +02:00
Richard Jones
aa999d0586 Lib.pm: Skip tests if perl-libintl module is not available. 2009-07-29 15:51:14 +01:00
Richard Jones
1f65b900f0 Lib.pm: Add file_architecture command.
This command detects the architecture of some types of binaries,
libraries, kernel modules and initrd images.
2009-07-29 10:16:06 +01:00
Richard W.M. Jones
5186251f8f Add 'readdir' call.
This adds a readdir call (mostly intended for programs).  The
return value is a list of guestfs_dirent structures.

This adds the new types 'struct guestfs_dirent' and
'struct guestfs_dirent_list', along with all the code to
return these in the different language bindings.

Also includes additional tests for OCaml and Perl bindings
to test this.
2009-07-02 10:11:55 +01:00
Richard W.M. Jones
c41fe04a65 Add the test0* functions, used to test language bindings. 2009-05-28 16:23:04 +01:00
Richard Jones
70c2ffc396 Additional test programs for Perl, Python, OCaml bindings. 2009-04-13 19:10:10 +01:00
Richard Jones
b3f11c5f62 Lots, mainly Python bindings. 2009-04-13 18:32:03 +01:00
Richard Jones
c3168fc03c Added more Perl bindings tests. 2009-04-08 15:22:29 +01:00