diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-07-14 12:42:24 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-07-14 12:42:24 +0100 |
commit | 7486fc6f43bdb22a989cc039e361afc4c0658d52 (patch) | |
tree | eebbe3e0bb3ec8c79a1a60961f1d7c2ea96a28e1 | |
parent | b48ae2eadf43315159f2174c8fd35b05ede14c0f (diff) | |
download | libguestfs-7486fc6f43bdb22a989cc039e361afc4c0658d52.tar.gz libguestfs-7486fc6f43bdb22a989cc039e361afc4c0658d52.tar.xz libguestfs-7486fc6f43bdb22a989cc039e361afc4c0658d52.zip |
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).
47 files changed, 93 insertions, 115 deletions
diff --git a/erlang/examples/create_disk.erl b/erlang/examples/create_disk.erl index d192435a..0e1f0314 100755 --- a/erlang/examples/create_disk.erl +++ b/erlang/examples/create_disk.erl @@ -17,8 +17,8 @@ main(_) -> ok = guestfs:set_trace(G, true), % Attach the disk image to libguestfs. - ok = guestfs:add_drive_opts(G, Output, - [{format, "raw"}, {readonly, false}]), + ok = guestfs:add_drive(G, Output, + [{format, "raw"}, {readonly, false}]), % Run the libguestfs back-end. ok = guestfs:launch(G), diff --git a/erlang/examples/guestfs-erlang.pod b/erlang/examples/guestfs-erlang.pod index 8721318b..1016d986 100644 --- a/erlang/examples/guestfs-erlang.pod +++ b/erlang/examples/guestfs-erlang.pod @@ -7,8 +7,8 @@ guestfs-erlang - How to use libguestfs from Erlang =head1 SYNOPSIS {ok, G} = guestfs:create(), - ok = guestfs:add_drive_opts(G, Disk, - [{format, "raw"}, {readonly, true}]), + ok = guestfs:add_drive(G, Disk, + [{format, "raw"}, {readonly, true}]), ok = guestfs:launch(G), [Device] = guestfs:list_devices(G), ok = guestfs:close(G). @@ -43,12 +43,12 @@ For functions that take optional arguments, the first arguments are the non-optional ones. The last argument is a list of tuples supplying the remaining optional arguments. - ok = guestfs:add_drive_opts(G, Disk, - [{format, "raw"}, {readonly, true}]). + ok = guestfs:add_drive(G, Disk, + [{format, "raw"}, {readonly, true}]). If the last argument would be an empty list, you can also omit it: - ok = guestfs:add_drive_opts(G, Disk). + ok = guestfs:add_drive(G, Disk). =head2 RETURN VALUES AND ERRORS diff --git a/erlang/examples/inspect_vm.erl b/erlang/examples/inspect_vm.erl index 87d751ca..24558895 100755 --- a/erlang/examples/inspect_vm.erl +++ b/erlang/examples/inspect_vm.erl @@ -6,7 +6,7 @@ main([Disk]) -> {ok, G} = guestfs:create(), % Attach the disk image read-only to libguestfs. - ok = guestfs:add_drive_opts(G, Disk, [{readonly, true}]), + ok = guestfs:add_drive(G, Disk, [{readonly, true}]), % Run the libguestfs back-end. ok = guestfs:launch(G), diff --git a/fish/guestfish.pod b/fish/guestfish.pod index 29aa2d6e..07e268c3 100644 --- a/fish/guestfish.pod +++ b/fish/guestfish.pod @@ -253,7 +253,7 @@ auto-detection for C<another.img>. If you have untrusted raw-format guest disk images, you should use this option to specify the disk format. This avoids a possible security problem with malicious guests (CVE-2010-3851). See also -L</add-drive-opts>. +L</add>. =item B<-i> @@ -594,11 +594,11 @@ Some commands take optional arguments. These arguments appear in this documentation as C<[argname:..]>. You can use them as in these examples: - add-drive-opts filename + add filename - add-drive-opts filename readonly:true + add filename readonly:true - add-drive-opts filename format:qcow2 readonly:false + add filename format:qcow2 readonly:false Each optional argument can appear at most once. All optional arguments must appear after the required ones. diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml index 0073c459..6f46f80e 100644 --- a/generator/generator_actions.ml +++ b/generator/generator_actions.ml @@ -164,26 +164,9 @@ This kills the qemu subprocess. Do not call this. See: C<guestfs_shutdown> instead." }; { defaults with - name = "add_drive"; - style = RErr, [String "filename"], []; - config_only = true; - shortdesc = "add an image to examine or modify"; - longdesc = "\ -This function is the equivalent of calling C<guestfs_add_drive_opts> -with no optional parameters, so the disk is added writable, with -the format being detected automatically. - -Automatic detection of the format opens you up to a potential -security hole when dealing with untrusted raw-format images. -See CVE-2010-3851 and RHBZ#642934. Specifying the format closes -this security hole. Therefore you should think about replacing -calls to this function with calls to C<guestfs_add_drive_opts>, -and specifying the format." }; - - { defaults with name = "add_cdrom"; style = RErr, [String "filename"], []; - deprecated_by = Some "add_drive_opts"; config_only = true; + deprecated_by = Some "add_drive"; config_only = true; shortdesc = "add a CD-ROM disk image to examine"; longdesc = "\ This function adds a virtual CD-ROM disk image to the guest. @@ -648,7 +631,7 @@ Return the recovery process enabled flag." }; { defaults with name = "add_drive_with_if"; style = RErr, [String "filename"; String "iface"], []; - deprecated_by = Some "add_drive_opts"; config_only = true; + deprecated_by = Some "add_drive"; config_only = true; shortdesc = "add a drive specifying the QEMU block emulation to use"; longdesc = "\ This is the same as C<guestfs_add_drive> but it allows you @@ -657,7 +640,7 @@ to specify the QEMU interface emulation to use at run time." }; { defaults with name = "add_drive_ro_with_if"; style = RErr, [String "filename"; String "iface"], []; - deprecated_by = Some "add_drive_opts"; config_only = true; + deprecated_by = Some "add_drive"; config_only = true; shortdesc = "add a drive read-only specifying the QEMU block emulation to use"; longdesc = "\ This is the same as C<guestfs_add_drive_ro> but it allows you @@ -1150,8 +1133,9 @@ not all belong to a single logical operating system (use C<guestfs_inspect_os> to look for OSes)." }; { defaults with - name = "add_drive_opts"; + name = "add_drive"; style = RErr, [String "filename"], [OBool "readonly"; OString "format"; OString "iface"; OString "name"]; + once_had_no_optargs = true; fish_alias = ["add"]; config_only = true; shortdesc = "add an image to examine or modify"; longdesc = "\ diff --git a/gobject/Makefile.am b/gobject/Makefile.am index deaf5432..cc360c81 100644 --- a/gobject/Makefile.am +++ b/gobject/Makefile.am @@ -42,7 +42,11 @@ CLEANFILES = \ guestfs-gobject*.c *.o *.lo # Remove old test0 API files. -CLEANFILES += src/optargs-test0.c include/guestfs-gobject/optargs-test0.h +CLEANFILES += \ + src/optargs-add_drive_opts.c \ + include/guestfs-gobject/optargs-add_drive_opts.h \ + src/optargs-test0.c \ + include/guestfs-gobject/optargs-test0.h libname = libguestfs-gobject-1.0.la diff --git a/gobject/Makefile.inc b/gobject/Makefile.inc index e84236d4..d8c6eed4 100644 --- a/gobject/Makefile.inc +++ b/gobject/Makefile.inc @@ -39,7 +39,7 @@ guestfs_gobject_headers= \ include/guestfs-gobject/struct-mdstat.h \ include/guestfs-gobject/struct-btrfssubvolume.h \ include/guestfs-gobject/optargs-internal_test.h \ - include/guestfs-gobject/optargs-add_drive_opts.h \ + include/guestfs-gobject/optargs-add_drive.h \ include/guestfs-gobject/optargs-add_domain.h \ include/guestfs-gobject/optargs-inspect_get_icon.h \ include/guestfs-gobject/optargs-mount_local.h \ @@ -83,7 +83,7 @@ guestfs_gobject_sources= \ src/struct-mdstat.c \ src/struct-btrfssubvolume.c \ src/optargs-internal_test.c \ - src/optargs-add_drive_opts.c \ + src/optargs-add_drive.c \ src/optargs-add_domain.c \ src/optargs-inspect_get_icon.c \ src/optargs-mount_local.c \ diff --git a/gobject/tests-misc.js b/gobject/tests-misc.js index 058a6955..a97da240 100644 --- a/gobject/tests-misc.js +++ b/gobject/tests-misc.js @@ -39,7 +39,7 @@ g.connect('trace', function(session, params) { } }); -g.add_drive('../tests/guests/fedora.img'); +g.add_drive('../tests/guests/fedora.img', null); g.set_trace(true); g.launch(); // Fake progress messages for a 5 second event. We do this as launch() will not diff --git a/haskell/Guestfs010Basic.hs b/haskell/Guestfs010Basic.hs index 0f919e3e..5cf88265 100644 --- a/haskell/Guestfs010Basic.hs +++ b/haskell/Guestfs010Basic.hs @@ -26,7 +26,7 @@ main = do fd <- openFile "test.img" WriteMode hSetFileSize fd (500 * 1024 * 1024) hClose fd - Guestfs.add_drive g "test.img" + Guestfs.add_drive_ro g "test.img" Guestfs.launch g Guestfs.pvcreate g "/dev/sda" diff --git a/java/examples/CreateDisk.java b/java/examples/CreateDisk.java index 381fae1f..7eecf9e4 100644 --- a/java/examples/CreateDisk.java +++ b/java/examples/CreateDisk.java @@ -29,7 +29,7 @@ public class CreateDisk put ("readonly", Boolean.FALSE); } }; - g.add_drive_opts (output, optargs); + g.add_drive (output, optargs); // Run the libguestfs back-end. g.launch (); diff --git a/java/examples/InspectVM.java b/java/examples/InspectVM.java index d92aa70f..1feadbe5 100644 --- a/java/examples/InspectVM.java +++ b/java/examples/InspectVM.java @@ -35,7 +35,7 @@ public class InspectVM } }; - g.add_drive_opts (disk, optargs); + g.add_drive (disk, optargs); // Run the libguestfs back-end. g.launch (); diff --git a/java/examples/guestfs-java.pod b/java/examples/guestfs-java.pod index 482539bd..f7b1e7a0 100644 --- a/java/examples/guestfs-java.pod +++ b/java/examples/guestfs-java.pod @@ -9,7 +9,7 @@ guestfs-java - How to use libguestfs from Java import com.redhat.et.libguestfs.*; GuestFS g = new GuestFS (); - g.add_drive_opts ("disk.img"); + g.add_drive ("disk.img"); g.launch (); =head1 DESCRIPTION diff --git a/java/t/GuestFS080OptArgs.java b/java/t/GuestFS080OptArgs.java index 6eee6c6d..417d0ad4 100644 --- a/java/t/GuestFS080OptArgs.java +++ b/java/t/GuestFS080OptArgs.java @@ -27,7 +27,7 @@ public class GuestFS080OptArgs try { GuestFS g = new GuestFS (); - g.add_drive_opts ("/dev/null"); + g.add_drive ("/dev/null"); HashMap<String,Object> optargs; @@ -36,7 +36,7 @@ public class GuestFS080OptArgs put ("readonly", Boolean.TRUE); } }; - g.add_drive_opts ("/dev/null", optargs); + g.add_drive ("/dev/null", optargs); optargs = new HashMap<String,Object>() { { @@ -44,7 +44,7 @@ public class GuestFS080OptArgs put ("format", "raw"); } }; - g.add_drive_opts ("/dev/null", optargs); + g.add_drive ("/dev/null", optargs); optargs = new HashMap<String,Object>() { { @@ -53,7 +53,7 @@ public class GuestFS080OptArgs put ("iface", "virtio"); } }; - g.add_drive_opts ("/dev/null", optargs); + g.add_drive ("/dev/null", optargs); } catch (Exception exn) { System.err.println (exn); diff --git a/ocaml/examples/create_disk.ml b/ocaml/examples/create_disk.ml index 4437b1c8..fab5e701 100644 --- a/ocaml/examples/create_disk.ml +++ b/ocaml/examples/create_disk.ml @@ -17,7 +17,7 @@ let () = g#set_trace true; (* Attach the disk image to libguestfs. *) - g#add_drive_opts ~format:"raw" ~readonly:false output; + g#add_drive ~format:"raw" ~readonly:false output; (* Run the libguestfs back-end. *) g#launch (); diff --git a/ocaml/examples/guestfs-ocaml.pod b/ocaml/examples/guestfs-ocaml.pod index 139997b8..019e84a3 100644 --- a/ocaml/examples/guestfs-ocaml.pod +++ b/ocaml/examples/guestfs-ocaml.pod @@ -9,13 +9,13 @@ guestfs-ocaml - How to use libguestfs from OCaml Module style: let g = Guestfs.create () in - Guestfs.add_drive_opts g ~format:"raw" ~readonly:true "disk.img"; + Guestfs.add_drive g ~format:"raw" ~readonly:true "disk.img"; Guestfs.launch g; Object-oriented style: let g = new Guestfs.guestfs () in - g#add_drive_opts ~format:"raw" ~readonly:true "disk.img"; + g#add_drive ~format:"raw" ~readonly:true "disk.img"; g#launch (); ocamlfind opt prog.ml -package guestfs -linkpkg -o prog diff --git a/ocaml/examples/inspect_vm.ml b/ocaml/examples/inspect_vm.ml index 44d348e7..c19953b4 100644 --- a/ocaml/examples/inspect_vm.ml +++ b/ocaml/examples/inspect_vm.ml @@ -12,7 +12,7 @@ let () = let g = new Guestfs.guestfs () in (* Attach the disk image read-only to libguestfs. *) - g#add_drive_opts (*~format:"raw"*) ~readonly:true disk; + g#add_drive (*~format:"raw"*) ~readonly:true disk; (* Run the libguestfs back-end. *) g#launch (); diff --git a/ocaml/t/guestfs_080_optargs.ml b/ocaml/t/guestfs_080_optargs.ml index a43a83e1..e2b2f6ca 100644 --- a/ocaml/t/guestfs_080_optargs.ml +++ b/ocaml/t/guestfs_080_optargs.ml @@ -21,10 +21,9 @@ open Unix let () = let g = Guestfs.create () in - Guestfs.add_drive_opts g "/dev/null"; - Guestfs.add_drive_opts g ~readonly:true "/dev/null"; - Guestfs.add_drive_opts g ~readonly:true ~format:"raw" "/dev/null"; - Guestfs.add_drive_opts g ~iface:"virtio" ~readonly:true ~format:"raw" - "/dev/null"; + Guestfs.add_drive g "/dev/null"; + Guestfs.add_drive g ~readonly:true "/dev/null"; + Guestfs.add_drive g ~readonly:true ~format:"raw" "/dev/null"; + Guestfs.add_drive g ~iface:"virtio" ~readonly:true ~format:"raw" "/dev/null"; Guestfs.close g diff --git a/ocaml/t/guestfs_500_parallel_mount_local.ml b/ocaml/t/guestfs_500_parallel_mount_local.ml index e1f5e26a..926b9ee6 100644 --- a/ocaml/t/guestfs_500_parallel_mount_local.ml +++ b/ocaml/t/guestfs_500_parallel_mount_local.ml @@ -100,7 +100,7 @@ and start_thread (filename, mp) = ftruncate fd (500 * 1024 * 1024); close fd; - g#add_drive_opts filename; + g#add_drive filename; g#launch (); g#part_disk "/dev/sda" "mbr"; diff --git a/perl/examples/create_disk.pl b/perl/examples/create_disk.pl index 11b91469..76b51de5 100755 --- a/perl/examples/create_disk.pl +++ b/perl/examples/create_disk.pl @@ -18,7 +18,7 @@ close FILE or die "$output: $!"; $g->set_trace (1); # Attach the disk image to libguestfs. -$g->add_drive_opts ($output, format => "raw", readonly => 0); +$g->add_drive ($output, format => "raw", readonly => 0); # Run the libguestfs back-end. $g->launch (); diff --git a/perl/examples/guestfs-perl.pod b/perl/examples/guestfs-perl.pod index f83d1fd6..c38377c8 100644 --- a/perl/examples/guestfs-perl.pod +++ b/perl/examples/guestfs-perl.pod @@ -9,7 +9,7 @@ guestfs-perl - How to use libguestfs from Perl use Sys::Guestfs; my $h = Sys::Guestfs->new (); - $h->add_drive_opts ('guest.img', format => 'raw'); + $h->add_drive ('guest.img', format => 'raw'); $h->launch (); $h->mount_options ('', '/dev/sda1', '/'); $h->touch ('/hello'); diff --git a/perl/examples/inspect_vm.pl b/perl/examples/inspect_vm.pl index 6d95b697..7800ce02 100755 --- a/perl/examples/inspect_vm.pl +++ b/perl/examples/inspect_vm.pl @@ -16,7 +16,7 @@ my $g = new Sys::Guestfs (); # Attach the disk image read-only to libguestfs. # You could also add an optional format => ... argument here. This is # advisable since automatic format detection is insecure. -$g->add_drive_opts ($disk, readonly => 1); +$g->add_drive ($disk, readonly => 1); # Run the libguestfs back-end. $g->launch (); diff --git a/perl/lib/Sys/Guestfs/Lib.pm b/perl/lib/Sys/Guestfs/Lib.pm index 2ccc09af..037a0500 100644 --- a/perl/lib/Sys/Guestfs/Lib.pm +++ b/perl/lib/Sys/Guestfs/Lib.pm @@ -133,7 +133,7 @@ If the C<Sys::Virt> module is not available, then libvirt is bypassed, and this function can only open disk images. The optional C<interface> parameter can be used to open devices with a -specified qemu interface. See L<Sys::Guestfs/guestfs_add_drive_opts> +specified qemu interface. See L<Sys::Guestfs/guestfs_add_drive> for more details. =cut @@ -257,7 +257,7 @@ sub open_guest push @args, format => $_->[1] if defined $_->[1]; push @args, readonly => 1 unless $rw; push @args, iface => $interface if defined $interface; - $g->add_drive_opts (@args); + $g->add_drive (@args); } return wantarray ? ($g, $conn, $dom, @images) : $g diff --git a/perl/t/070-optargs.t b/perl/t/070-optargs.t index 978db920..885f0cc4 100644 --- a/perl/t/070-optargs.t +++ b/perl/t/070-optargs.t @@ -24,11 +24,11 @@ use Sys::Guestfs; my $h = Sys::Guestfs->new (); ok ($h); -$h->add_drive_opts ("/dev/null"); +$h->add_drive ("/dev/null"); ok (1); -$h->add_drive_opts ("/dev/null", readonly => 1); +$h->add_drive ("/dev/null", readonly => 1); ok (1); -$h->add_drive_opts ("/dev/null", format => "raw", readonly => 0); +$h->add_drive ("/dev/null", format => "raw", readonly => 0); ok (1); diff --git a/perl/t/810-mkdir-eexist.t b/perl/t/810-mkdir-eexist.t index a059ee49..0b257768 100644 --- a/perl/t/810-mkdir-eexist.t +++ b/perl/t/810-mkdir-eexist.t @@ -33,7 +33,7 @@ truncate FILE, 500*1024*1024; close FILE; ok (1); -$g->add_drive_opts ("test.img", format => "raw"); +$g->add_drive ("test.img", format => "raw"); ok (1); $g->launch (); diff --git a/perl/t/900-introspection.t b/perl/t/900-introspection.t index c1fa6f8e..0182250e 100644 --- a/perl/t/900-introspection.t +++ b/perl/t/900-introspection.t @@ -33,6 +33,7 @@ is ($add_drive{args}[0][0], "filename"); is ($add_drive{args}[0][1], "string"); is ($add_drive{args}[0][2], 0); +# In libguestfs >= 1.19.19, this is an alias. my %add_drive_opts = %{$Sys::Guestfs::guestfs_introspection{add_drive_opts}}; ok(1); diff --git a/php/extension/guestfs_php_003.phpt b/php/extension/guestfs_php_003.phpt index 08e53a37..2624a293 100644 --- a/php/extension/guestfs_php_003.phpt +++ b/php/extension/guestfs_php_003.phpt @@ -11,20 +11,20 @@ if ($g == false) { echo ("Failed to create guestfs_php handle.\n"); exit; } -if (guestfs_add_drive_opts ($g, "/dev/null") == false) { - echo ("Failed add_drive_opts, no optional arguments.\n"); +if (guestfs_add_drive ($g, "/dev/null") == false) { + echo ("Failed add_drive, no optional arguments.\n"); exit; } -if (guestfs_add_drive_opts ($g, "/dev/null", 0) == false) { - echo ("Failed add_drive_opts, one optional argument.\n"); +if (guestfs_add_drive ($g, "/dev/null", 0) == false) { + echo ("Failed add_drive, one optional argument.\n"); exit; } -if (guestfs_add_drive_opts ($g, "/dev/null", 1) == false) { - echo ("Failed add_drive_opts, one optional argument.\n"); +if (guestfs_add_drive ($g, "/dev/null", 1) == false) { + echo ("Failed add_drive, one optional argument.\n"); exit; } -if (guestfs_add_drive_opts ($g, "/dev/null", 1, "qcow2") == false) { - echo ("Failed add_drive_opts, two optional arguments.\n"); +if (guestfs_add_drive ($g, "/dev/null", 1, "qcow2") == false) { + echo ("Failed add_drive, two optional arguments.\n"); exit; } echo ("Completed tests OK.\n"); diff --git a/po/POTFILES b/po/POTFILES index 6c819d31..f659a9d4 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -133,7 +133,7 @@ fish/virt.c format/format.c fuse/guestmount.c gobject/src/optargs-add_domain.c -gobject/src/optargs-add_drive_opts.c +gobject/src/optargs-add_drive.c gobject/src/optargs-btrfs_filesystem_resize.c gobject/src/optargs-btrfs_fsck.c gobject/src/optargs-compress_device_out.c diff --git a/python/examples/create_disk.py b/python/examples/create_disk.py index 86f50427..a854c23f 100644 --- a/python/examples/create_disk.py +++ b/python/examples/create_disk.py @@ -16,7 +16,7 @@ f.close () g.set_trace (1) # Attach the disk image to libguestfs. -g.add_drive_opts (output, format = "raw", readonly = 0) +g.add_drive (output, format = "raw", readonly = 0) # Run the libguestfs back-end. g.launch () diff --git a/python/examples/guestfs-python.pod b/python/examples/guestfs-python.pod index e4406f55..59f60e57 100644 --- a/python/examples/guestfs-python.pod +++ b/python/examples/guestfs-python.pod @@ -8,7 +8,7 @@ guestfs-python - How to use libguestfs from Python import guestfs g = guestfs.GuestFS () - g.add_drive_opts ("disk.img", format="raw", readonly=1) + g.add_drive ("disk.img", format="raw", readonly=1) g.launch () =head1 DESCRIPTION diff --git a/python/examples/inspect_vm.py b/python/examples/inspect_vm.py index c491a2ce..816779cc 100644 --- a/python/examples/inspect_vm.py +++ b/python/examples/inspect_vm.py @@ -9,7 +9,7 @@ disk = sys.argv[1] g = guestfs.GuestFS () # Attach the disk image read-only to libguestfs. -g.add_drive_opts (disk, readonly=1) +g.add_drive (disk, readonly=1) # Run the libguestfs back-end. g.launch () diff --git a/python/t/060-optargs.py b/python/t/060-optargs.py index be28a3ce..ae2d934d 100644 --- a/python/t/060-optargs.py +++ b/python/t/060-optargs.py @@ -19,7 +19,7 @@ import os import guestfs g = guestfs.GuestFS() -g.add_drive_opts ("/dev/null") -g.add_drive_opts ("/dev/null", readonly = 1) -g.add_drive_opts ("/dev/null", iface = "virtio", format = "raw") +g.add_drive ("/dev/null") +g.add_drive ("/dev/null", readonly = 1) +g.add_drive ("/dev/null", iface = "virtio", format = "raw") g.close () diff --git a/python/t/rhbz811650.py b/python/t/rhbz811650.py index cf01673f..c84f094b 100644 --- a/python/t/rhbz811650.py +++ b/python/t/rhbz811650.py @@ -25,7 +25,7 @@ f.close () g = guestfs.GuestFS () # Deliberate error: the disk format is supposed to be raw. -g.add_drive_opts ("test.img", format="qcow2"); +g.add_drive ("test.img", format="qcow2"); # Because error() wasn't being called, guestfs_last_error would return # NULL, causing a segfault in the Python bindings (RHBZ#811650). diff --git a/resize/resize.ml b/resize/resize.ml index cd4c9d62..9ef2bbd3 100644 --- a/resize/resize.ml +++ b/resize/resize.ml @@ -173,7 +173,7 @@ read the man page virt-resize(1). printf "alignment\n"; printf "align-first\n"; let g = new G.guestfs () in - g#add_drive_opts "/dev/null"; + g#add_drive "/dev/null"; g#launch (); if feature_available g [| "ntfsprogs"; "ntfs3g" |] then printf "ntfs\n"; @@ -209,8 +209,8 @@ let btrfs_available = ref true let connect_both_disks () = let g = new G.guestfs () in if debug then g#set_trace true; - g#add_drive_opts ?format ~readonly:true infile; - g#add_drive_opts ?format:output_format ~readonly:false outfile; + g#add_drive ?format ~readonly:true infile; + g#add_drive ?format:output_format ~readonly:false outfile; if not quiet then Progress.set_up_progress_bar ~machine_readable g; g#launch (); @@ -1125,7 +1125,7 @@ let g = let g = new G.guestfs () in if debug then g#set_trace true; - g#add_drive_opts ?format:output_format ~readonly:false outfile; + g#add_drive ?format:output_format ~readonly:false outfile; if not quiet then Progress.set_up_progress_bar ~machine_readable g; g#launch (); diff --git a/ruby/examples/create_disk.rb b/ruby/examples/create_disk.rb index 32fb1171..fd6ec01e 100644 --- a/ruby/examples/create_disk.rb +++ b/ruby/examples/create_disk.rb @@ -15,7 +15,7 @@ File.open(output, "w") { g.set_trace(1) # Attach the disk image to libguestfs. -g.add_drive_opts(output, :format => "raw") +g.add_drive(output, :format => "raw") # Run the libguestfs back-end. g.launch(); diff --git a/ruby/examples/guestfs-ruby.pod b/ruby/examples/guestfs-ruby.pod index 1af133de..4b53d018 100644 --- a/ruby/examples/guestfs-ruby.pod +++ b/ruby/examples/guestfs-ruby.pod @@ -8,8 +8,8 @@ guestfs-ruby - How to use libguestfs from Ruby require 'guestfs' g = Guestfs::Guestfs.new() - g.add_drive_opts("disk.img", - :readonly => 1, :format => "raw") + g.add_drive("disk.img", + :readonly => 1, :format => "raw") g.launch() =head1 DESCRIPTION diff --git a/ruby/examples/inspect_vm.rb b/ruby/examples/inspect_vm.rb index abf22790..c29114ea 100644 --- a/ruby/examples/inspect_vm.rb +++ b/ruby/examples/inspect_vm.rb @@ -11,7 +11,7 @@ disk = ARGV[0] g = Guestfs::Guestfs.new() # Attach the disk image read-only to libguestfs. -g.add_drive_opts(disk, :readonly => 1) +g.add_drive(disk, :readonly => 1) # Run the libguestfs back-end. g.launch() diff --git a/ruby/tests/tc_060_optargs.rb b/ruby/tests/tc_060_optargs.rb index de411d6f..6556bc7f 100644 --- a/ruby/tests/tc_060_optargs.rb +++ b/ruby/tests/tc_060_optargs.rb @@ -24,10 +24,10 @@ class TestLoad < Test::Unit::TestCase def test_optargs g = Guestfs::create() - g.add_drive_opts("/dev/null", {}) - g.add_drive_opts("/dev/null", :readonly => 1) - g.add_drive_opts("/dev/null", :readonly => 1, :iface => "virtio") - g.add_drive_opts("/dev/null", - :readonly => 1, :iface => "virtio", :format => "qcow2") + g.add_drive("/dev/null", {}) + g.add_drive("/dev/null", :readonly => 1) + g.add_drive("/dev/null", :readonly => 1, :iface => "virtio") + g.add_drive("/dev/null", + :readonly => 1, :iface => "virtio", :format => "qcow2") end end diff --git a/sparsify/sparsify.ml b/sparsify/sparsify.ml index 6f1635b2..418eb67f 100644 --- a/sparsify/sparsify.ml +++ b/sparsify/sparsify.ml @@ -107,7 +107,7 @@ read the man page virt-sparsify(1). printf "linux-swap\n"; printf "zero\n"; let g = new G.guestfs () in - g#add_drive_opts "/dev/null"; + g#add_drive "/dev/null"; g#launch (); if feature_available g [| "ntfsprogs"; "ntfs3g" |] then printf "ntfs\n"; @@ -195,7 +195,7 @@ let g = if verbose then g#set_verbose true; (* Note that the temporary overlay disk is always qcow2 format. *) - g#add_drive_opts ~format:"qcow2" ~readonly:false overlaydisk; + g#add_drive ~format:"qcow2" ~readonly:false overlaydisk; if not quiet then Progress.set_up_progress_bar ~machine_readable g; g#launch (); diff --git a/src/launch.c b/src/launch.c index e7865195..be834a8e 100644 --- a/src/launch.c +++ b/src/launch.c @@ -441,16 +441,6 @@ err_out: } int -guestfs__add_drive (guestfs_h *g, const char *filename) -{ - struct guestfs_add_drive_opts_argv optargs = { - .bitmask = 0, - }; - - return guestfs__add_drive_opts (g, filename, &optargs); -} - -int guestfs__add_drive_ro (guestfs_h *g, const char *filename) { struct guestfs_add_drive_opts_argv optargs = { diff --git a/sysprep/main.ml b/sysprep/main.ml index 05dd57d7..4c3f9700 100644 --- a/sysprep/main.ml +++ b/sysprep/main.ml @@ -161,7 +161,7 @@ read the man page virt-sysprep(1). fun g readonly -> List.iter ( fun (file, format) -> - g#add_drive_opts ~readonly ?format file + g#add_drive ~readonly ?format file ) files in diff --git a/tests/btrfs/test-btrfs-subvolume-default.pl b/tests/btrfs/test-btrfs-subvolume-default.pl index 2c09ce2d..4672bed8 100755 --- a/tests/btrfs/test-btrfs-subvolume-default.pl +++ b/tests/btrfs/test-btrfs-subvolume-default.pl @@ -33,7 +33,7 @@ close FILE or die "$testimg: $!"; my $g = Sys::Guestfs->new (); -$g->add_drive_opts ($testimg, format => "raw"); +$g->add_drive ($testimg, format => "raw"); $g->launch (); # If btrfs is not available, bail. diff --git a/tests/disks/test-max-disks.pl b/tests/disks/test-max-disks.pl index a0bba7f5..70624342 100755 --- a/tests/disks/test-max-disks.pl +++ b/tests/disks/test-max-disks.pl @@ -40,7 +40,7 @@ for ($i = 0; $i < $max_disks; ++$i) { truncate FILE, 1024*1024 or die "$name: truncate: $!"; close FILE or die "$name: $!"; - $g->add_drive_opts ($name, format => "raw"); + $g->add_drive ($name, format => "raw"); } $g->launch (); diff --git a/tests/lvm/test-lvm-mapping.pl b/tests/lvm/test-lvm-mapping.pl index b92a5c56..beb388ab 100755 --- a/tests/lvm/test-lvm-mapping.pl +++ b/tests/lvm/test-lvm-mapping.pl @@ -34,7 +34,7 @@ my $g = Sys::Guestfs->new (); #$g->set_verbose (1); #$g->set_trace (1); -$g->add_drive_opts ($testimg, format => "raw"); +$g->add_drive ($testimg, format => "raw"); $g->launch (); # Create an arrangement of PVs, VGs and LVs. diff --git a/tests/md/test-inspect-fstab.sh b/tests/md/test-inspect-fstab.sh index 2822c4d7..889ceee0 100755 --- a/tests/md/test-inspect-fstab.sh +++ b/tests/md/test-inspect-fstab.sh @@ -88,7 +88,7 @@ $guestfish -a test1.qcow2 <<'EOF' EOF $guestfish <<'EOF' | $canonical > test.output - add-drive-opts test1.qcow2 readonly:true name:xvdg + add test1.qcow2 readonly:true name:xvdg run inspect-os inspect-get-mountpoints /dev/VG/Root @@ -119,7 +119,7 @@ $guestfish -a test1.qcow2 <<'EOF' EOF $guestfish <<'EOF' | $canonical > test.output - add-drive-opts test1.qcow2 readonly:true name:cciss/c1d3 + add test1.qcow2 readonly:true name:cciss/c1d3 run inspect-os inspect-get-mountpoints /dev/VG/Root diff --git a/tests/qemu/qemu-liveness.sh b/tests/qemu/qemu-liveness.sh index d95321c7..eb8f6089 100755 --- a/tests/qemu/qemu-liveness.sh +++ b/tests/qemu/qemu-liveness.sh @@ -28,7 +28,7 @@ rm -f test1.img test1_md5sum="$(md5sum test1.img | awk '{print $1}')" ../../fish/guestfish <<'EOF' -add-drive-opts test1.img format:raw +add test1.img format:raw run part-disk /dev/sda mbr @@ -49,4 +49,4 @@ if [ "$(md5sum test1.img | awk '{print $1}')" = "$test1_md5sum" ]; then exit 1 fi -rm test1.img
\ No newline at end of file +rm test1.img diff --git a/tests/selinux/run-test.pl b/tests/selinux/run-test.pl index bbe3a2f5..0d3300cc 100755 --- a/tests/selinux/run-test.pl +++ b/tests/selinux/run-test.pl @@ -108,7 +108,7 @@ open FILE, ">$testimg" or die "$testimg: $!"; truncate FILE, 256*1024*1024 or die "$testimg: truncate: $!"; close FILE or die "$testimg: $!"; -$g->add_drive_opts ($testimg, format => "raw"); +$g->add_drive ($testimg, format => "raw"); $g->launch (); unless (feature_available ($g, "linuxxattrs")) { diff --git a/tools/virt-make-fs b/tools/virt-make-fs index b53e8607..a4da3f22 100755 --- a/tools/virt-make-fs +++ b/tools/virt-make-fs @@ -421,7 +421,7 @@ eval { # Run libguestfs. my $g = Sys::Guestfs->new (); - $g->add_drive_opts ($output, format => $format); + $g->add_drive ($output, format => $format); $g->launch (); if ($type eq "ntfs" && !feature_available ($g, "ntfs3g", "ntfsprogs")) { |