Generated code for 'add_drive_ro' call.
authorRichard Jones <rjones@trick.home.annexia.org>
Tue, 2 Jun 2009 13:25:25 +0000 (14:25 +0100)
committerRichard Jones <rjones@trick.home.annexia.org>
Tue, 2 Jun 2009 13:25:25 +0000 (14:25 +0100)
17 files changed:
capitests/tests.c
fish/cmds.c
fish/completion.c
guestfish-actions.pod
guestfs-actions.pod
haskell/Guestfs.hs
java/com/redhat/et/libguestfs/GuestFS.java
java/com_redhat_et_libguestfs_GuestFS.c
ocaml/guestfs.ml
ocaml/guestfs.mli
ocaml/guestfs_c_actions.c
perl/Guestfs.xs
perl/lib/Sys/Guestfs.pm
python/guestfs-py.c
python/guestfs.py
ruby/ext/guestfs/_guestfs.c
src/guestfs-actions.h

index 5b6356f..1b751e8 100644 (file)
@@ -94,6 +94,7 @@ static void no_test_warnings (void)
   fprintf (stderr, "warning: \"guestfs_kill_subprocess\" has no tests\n");
   fprintf (stderr, "warning: \"guestfs_add_drive\" has no tests\n");
   fprintf (stderr, "warning: \"guestfs_add_cdrom\" has no tests\n");
+  fprintf (stderr, "warning: \"guestfs_add_drive_ro\" has no tests\n");
   fprintf (stderr, "warning: \"guestfs_config\" has no tests\n");
   fprintf (stderr, "warning: \"guestfs_set_qemu\" has no tests\n");
   fprintf (stderr, "warning: \"guestfs_get_qemu\" has no tests\n");
@@ -16020,7 +16021,6 @@ int main (int argc, char *argv[])
 {
   char c = 0;
   int failed = 0;
-  const char *srcdir;
   const char *filename;
   int fd, i;
   int nr_tests, test_num = 0;
@@ -16122,8 +16122,8 @@ int main (int argc, char *argv[])
     exit (1);
   }
 
-  if (guestfs_add_drive (g, "../images/test.sqsh") == -1) {
-    printf ("guestfs_add_drive %s FAILED\n", filename);
+  if (guestfs_add_drive_ro (g, "../images/test.sqsh") == -1) {
+    printf ("guestfs_add_drive_ro ../images/test.sqsh FAILED\n");
     exit (1);
   }
 
index d200acf..bb982d4 100644 (file)
@@ -33,6 +33,7 @@ void list_commands (void)
   list_builtin_commands ();
   printf ("%-20s %s\n", "add-cdrom", "add a CD-ROM disk image to examine");
   printf ("%-20s %s\n", "add-drive", "add an image to examine or modify");
+  printf ("%-20s %s\n", "add-drive-ro", "add a drive in snapshot mode (read-only)");
   printf ("%-20s %s\n", "aug-close", "close the current Augeas handle");
   printf ("%-20s %s\n", "aug-defnode", "define an Augeas node");
   printf ("%-20s %s\n", "aug-defvar", "define an Augeas variable");
@@ -171,10 +172,13 @@ void display_command (const char *cmd)
     pod2text ("kill-subprocess - kill the qemu subprocess", " kill-subprocess\n\nThis kills the qemu subprocess.  You should never need to call this.");
   else
   if (strcasecmp (cmd, "add_drive") == 0 || strcasecmp (cmd, "add-drive") == 0 || strcasecmp (cmd, "add") == 0)
-    pod2text ("add-drive - add an image to examine or modify", " add-drive <filename>\n\nThis function adds a virtual machine disk image C<filename> to the\nguest.  The first time you call this function, the disk appears as IDE\ndisk 0 (C</dev/sda>) in the guest, the second time as C</dev/sdb>, and\nso on.\n\nYou don't necessarily need to be root when using libguestfs.  However\nyou obviously do need sufficient permissions to access the filename\nfor whatever operations you want to perform (ie. read access if you\njust want to read the image or write access if you want to modify the\nimage).\n\nThis is equivalent to the qemu parameter C<-drive file=filename>.\n\nYou can use 'add' as an alias for this command.");
+    pod2text ("add-drive - add an image to examine or modify", " add-drive <filename>\n\nThis function adds a virtual machine disk image C<filename> to the\nguest.  The first time you call this function, the disk appears as IDE\ndisk 0 (C</dev/sda>) in the guest, the second time as C</dev/sdb>, and\nso on.\n\nYou don't necessarily need to be root when using libguestfs.  However\nyou obviously do need sufficient permissions to access the filename\nfor whatever operations you want to perform (ie. read access if you\njust want to read the image or write access if you want to modify the\nimage).\n\nThis is equivalent to the qemu parameter C<-drive file=filename>.\n\nNote that this call checks for the existence of C<filename>.  This\nstops you from specifying other types of drive which are supported\nby qemu such as C<nbd:> and C<http:> URLs.  To specify those, use\nthe general C<config> call instead.\n\nYou can use 'add' as an alias for this command.");
   else
   if (strcasecmp (cmd, "add_cdrom") == 0 || strcasecmp (cmd, "add-cdrom") == 0 || strcasecmp (cmd, "cdrom") == 0)
-    pod2text ("add-cdrom - add a CD-ROM disk image to examine", " add-cdrom <filename>\n\nThis function adds a virtual CD-ROM disk image to the guest.\n\nThis is equivalent to the qemu parameter C<-cdrom filename>.\n\nYou can use 'cdrom' as an alias for this command.");
+    pod2text ("add-cdrom - add a CD-ROM disk image to examine", " add-cdrom <filename>\n\nThis function adds a virtual CD-ROM disk image to the guest.\n\nThis is equivalent to the qemu parameter C<-cdrom filename>.\n\nNote that this call checks for the existence of C<filename>.  This\nstops you from specifying other types of drive which are supported\nby qemu such as C<nbd:> and C<http:> URLs.  To specify those, use\nthe general C<config> call instead.\n\nYou can use 'cdrom' as an alias for this command.");
+  else
+  if (strcasecmp (cmd, "add_drive_ro") == 0 || strcasecmp (cmd, "add-drive-ro") == 0 || strcasecmp (cmd, "add-ro") == 0)
+    pod2text ("add-drive-ro - add a drive in snapshot mode (read-only)", " add-drive-ro <filename>\n\nThis adds a drive in snapshot mode, making it effectively\nread-only.\n\nNote that writes to the device are allowed, and will be seen for\nthe duration of the guestfs handle, but they are written\nto a temporary file which is discarded as soon as the guestfs\nhandle is closed.  We don't currently have any method to enable\nchanges to be committed, although qemu can support this.\n\nThis is equivalent to the qemu parameter\nC<-drive file=filename,snapshot=on>.\n\nNote that this call checks for the existence of C<filename>.  This\nstops you from specifying other types of drive which are supported\nby qemu such as C<nbd:> and C<http:> URLs.  To specify those, use\nthe general C<config> call instead.\n\nYou can use 'add-ro' as an alias for this command.");
   else
   if (strcasecmp (cmd, "config") == 0)
     pod2text ("config - add qemu parameters", " config <qemuparam> <qemuvalue>\n\nThis can be used to add arbitrary qemu command line parameters\nof the form C<-param value>.  Actually it's not quite arbitrary - we\nprevent you from setting some parameters which would interfere with\nparameters that we use.\n\nThe first character of C<param> string must be a C<-> (dash).\n\nC<value> can be NULL.");
@@ -737,6 +741,20 @@ static int run_add_cdrom (const char *cmd, int argc, char *argv[])
   return r;
 }
 
+static int run_add_drive_ro (const char *cmd, int argc, char *argv[])
+{
+  int r;
+  const char *filename;
+  if (argc != 1) {
+    fprintf (stderr, "%s should have 1 parameter(s)\n", cmd);
+    fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd);
+    return -1;
+  }
+  filename = argv[0];
+  r = guestfs_add_drive_ro (g, filename);
+  return r;
+}
+
 static int run_config (const char *cmd, int argc, char *argv[])
 {
   int r;
@@ -2694,6 +2712,9 @@ int run_action (const char *cmd, int argc, char *argv[])
   if (strcasecmp (cmd, "add_cdrom") == 0 || strcasecmp (cmd, "add-cdrom") == 0 || strcasecmp (cmd, "cdrom") == 0)
     return run_add_cdrom (cmd, argc, argv);
   else
+  if (strcasecmp (cmd, "add_drive_ro") == 0 || strcasecmp (cmd, "add-drive-ro") == 0 || strcasecmp (cmd, "add-ro") == 0)
+    return run_add_drive_ro (cmd, argc, argv);
+  else
   if (strcasecmp (cmd, "config") == 0)
     return run_config (cmd, argc, argv);
   else
index 305e810..287c5aa 100644 (file)
@@ -42,6 +42,8 @@ static const char *const commands[] = {
   "add",
   "add-cdrom",
   "cdrom",
+  "add-drive-ro",
+  "add-ro",
   "config",
   "set-qemu",
   "qemu",
index fa82ef1..9b07c40 100644 (file)
@@ -6,6 +6,11 @@ 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<filename>.  This
+stops you from specifying other types of drive which are supported
+by qemu such as C<nbd:> and C<http:> URLs.  To specify those, use
+the general C<config> call instead.
+
 =head2 add-drive | add
 
  add-drive filename
@@ -23,6 +28,32 @@ image).
 
 This is equivalent to the qemu parameter C<-drive file=filename>.
 
+Note that this call checks for the existence of C<filename>.  This
+stops you from specifying other types of drive which are supported
+by qemu such as C<nbd:> and C<http:> URLs.  To specify those, use
+the general C<config> call instead.
+
+=head2 add-drive-ro | add-ro
+
+ add-drive-ro filename
+
+This adds a drive in snapshot mode, making it effectively
+read-only.
+
+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.
+
+This is equivalent to the qemu parameter
+C<-drive file=filename,snapshot=on>.
+
+Note that this call checks for the existence of C<filename>.  This
+stops you from specifying other types of drive which are supported
+by qemu such as C<nbd:> and C<http:> URLs.  To specify those, use
+the general C<config> call instead.
+
 =head2 aug-close
 
  aug-close
index 0b06470..2705c3b 100644 (file)
@@ -7,6 +7,11 @@ 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<filename>.  This
+stops you from specifying other types of drive which are supported
+by qemu such as C<nbd:> and C<http:> URLs.  To specify those, use
+the general C<guestfs_config> call instead.
+
 This function returns 0 on success or -1 on error.
 
 =head2 guestfs_add_drive
@@ -27,6 +32,35 @@ image).
 
 This is equivalent to the qemu parameter C<-drive file=filename>.
 
+Note that this call checks for the existence of C<filename>.  This
+stops you from specifying other types of drive which are supported
+by qemu such as C<nbd:> and C<http:> URLs.  To specify those, use
+the general C<guestfs_config> call instead.
+
+This function returns 0 on success or -1 on error.
+
+=head2 guestfs_add_drive_ro
+
+ int guestfs_add_drive_ro (guestfs_h *handle,
+               const char *filename);
+
+This adds a drive in snapshot mode, making it effectively
+read-only.
+
+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.
+
+This is equivalent to the qemu parameter
+C<-drive file=filename,snapshot=on>.
+
+Note that this call checks for the existence of C<filename>.  This
+stops you from specifying other types of drive which are supported
+by qemu such as C<nbd:> and C<http:> URLs.  To specify those, use
+the general C<guestfs_config> call instead.
+
 This function returns 0 on success or -1 on error.
 
 =head2 guestfs_aug_close
index ee7dabd..210274e 100644 (file)
@@ -29,6 +29,7 @@ module Guestfs (
   kill_subprocess,
   add_drive,
   add_cdrom,
+  add_drive_ro,
   config,
   set_qemu,
   set_path,
@@ -192,6 +193,18 @@ add_cdrom h filename = do
       fail err
     else return ()
 
+foreign import ccall unsafe "guestfs_add_drive_ro" c_add_drive_ro
+  :: GuestfsP -> CString -> IO (CInt)
+
+add_drive_ro :: GuestfsH -> String -> IO ()
+add_drive_ro h filename = do
+  r <- withCString filename $ \filename -> withForeignPtr h (\p -> c_add_drive_ro p filename)
+  if (r == -1)
+    then do
+      err <- last_error h
+      fail err
+    else return ()
+
 foreign import ccall unsafe "guestfs_config" c_config
   :: GuestfsP -> CString -> CString -> IO (CInt)
 
index d340b8c..1d00547 100644 (file)
@@ -429,6 +429,12 @@ public HashMap<String,String> test0rhashtableerr ()
    * This is equivalent to the qemu parameter "-drive
    * file=filename".
    * <p>
+   * Note that this call checks for the existence of
+   * "filename". This stops you from specifying other types
+   * of drive which are supported by qemu such as "nbd:" and
+   * "http:" URLs. To specify those, use the general
+   * "g.config" call instead.
+   * <p>
    * @throws LibGuestFSException
    */
   public void add_drive (String filename)
@@ -450,6 +456,12 @@ public HashMap<String,String> test0rhashtableerr ()
    * This is equivalent to the qemu parameter "-cdrom
    * filename".
    * <p>
+   * Note that this call checks for the existence of
+   * "filename". This stops you from specifying other types
+   * of drive which are supported by qemu such as "nbd:" and
+   * "http:" URLs. To specify those, use the general
+   * "g.config" call instead.
+   * <p>
    * @throws LibGuestFSException
    */
   public void add_cdrom (String filename)
@@ -463,6 +475,40 @@ public HashMap<String,String> test0rhashtableerr ()
     throws LibGuestFSException;
 
   /**
+   * add a drive in snapshot mode (read-only)
+   * <p>
+   * This adds a drive in snapshot mode, making it
+   * effectively read-only.
+   * <p>
+   * 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.
+   * <p>
+   * This is equivalent to the qemu parameter "-drive
+   * file=filename,snapshot=on".
+   * <p>
+   * Note that this call checks for the existence of
+   * "filename". This stops you from specifying other types
+   * of drive which are supported by qemu such as "nbd:" and
+   * "http:" URLs. To specify those, use the general
+   * "g.config" call instead.
+   * <p>
+   * @throws LibGuestFSException
+   */
+  public void add_drive_ro (String filename)
+    throws LibGuestFSException
+  {
+    if (g == 0)
+      throw new LibGuestFSException ("add_drive_ro: handle is closed");
+    _add_drive_ro (g, filename);
+  }
+  private native void _add_drive_ro (long g, String filename)
+    throws LibGuestFSException;
+
+  /**
    * add qemu parameters
    * <p>
    * This can be used to add arbitrary qemu command line
index c5971c5..fc858f6 100644 (file)
@@ -1089,6 +1089,23 @@ Java_com_redhat_et_libguestfs_GuestFS__1add_1cdrom
 }
 
 JNIEXPORT void JNICALL
+Java_com_redhat_et_libguestfs_GuestFS__1add_1drive_1ro
+  (JNIEnv *env, jobject obj, jlong jg, jstring jfilename)
+{
+  guestfs_h *g = (guestfs_h *) (long) jg;
+  int r;
+  const char *filename;
+
+  filename = (*env)->GetStringUTFChars (env, jfilename, NULL);
+  r = guestfs_add_drive_ro (g, filename);
+  (*env)->ReleaseStringUTFChars (env, jfilename, filename);
+  if (r == -1) {
+    throw_exception (env, guestfs_last_error (g));
+    return ;
+  }
+}
+
+JNIEXPORT void JNICALL
 Java_com_redhat_et_libguestfs_GuestFS__1config
   (JNIEnv *env, jobject obj, jlong jg, jstring jqemuparam, jstring jqemuvalue)
 {
index d218b3e..cf75d7b 100644 (file)
@@ -147,6 +147,7 @@ external wait_ready : t -> unit = "ocaml_guestfs_wait_ready"
 external kill_subprocess : t -> unit = "ocaml_guestfs_kill_subprocess"
 external add_drive : t -> string -> unit = "ocaml_guestfs_add_drive"
 external add_cdrom : t -> string -> unit = "ocaml_guestfs_add_cdrom"
+external add_drive_ro : t -> string -> unit = "ocaml_guestfs_add_drive_ro"
 external config : t -> string -> string option -> unit = "ocaml_guestfs_config"
 external set_qemu : t -> string -> unit = "ocaml_guestfs_set_qemu"
 external get_qemu : t -> string = "ocaml_guestfs_get_qemu"
index 564f163..686bc60 100644 (file)
@@ -220,6 +220,9 @@ val add_drive : t -> string -> unit
 val add_cdrom : t -> string -> unit
 (** add a CD-ROM disk image to examine *)
 
+val add_drive_ro : t -> string -> unit
+(** add a drive in snapshot mode (read-only) *)
+
 val config : t -> string -> string option -> unit
 (** add qemu parameters *)
 
index 74c25d9..73dfdd9 100644 (file)
@@ -1094,6 +1094,29 @@ ocaml_guestfs_add_cdrom (value gv, value filenamev)
 }
 
 CAMLprim value
+ocaml_guestfs_add_drive_ro (value gv, value filenamev)
+{
+  CAMLparam2 (gv, filenamev);
+  CAMLlocal1 (rv);
+
+  guestfs_h *g = Guestfs_val (gv);
+  if (g == NULL)
+    caml_failwith ("add_drive_ro: used handle after closing it");
+
+  const char *filename = String_val (filenamev);
+  int r;
+
+  caml_enter_blocking_section ();
+  r = guestfs_add_drive_ro (g, filename);
+  caml_leave_blocking_section ();
+  if (r == -1)
+    ocaml_guestfs_raise_error (g, "add_drive_ro");
+
+  rv = Val_unit;
+  CAMLreturn (rv);
+}
+
+CAMLprim value
 ocaml_guestfs_config (value gv, value qemuparamv, value qemuvaluev)
 {
   CAMLparam3 (gv, qemuparamv, qemuvaluev);
index 0f90aff..08b55b8 100644 (file)
@@ -724,6 +724,17 @@ PREINIT:
         croak ("add_cdrom: %s", guestfs_last_error (g));
 
 void
+add_drive_ro (g, filename)
+      guestfs_h *g;
+      char *filename;
+PREINIT:
+      int r;
+ PPCODE:
+      r = guestfs_add_drive_ro (g, filename);
+      if (r == -1)
+        croak ("add_drive_ro: %s", guestfs_last_error (g));
+
+void
 config (g, qemuparam, qemuvalue)
       guestfs_h *g;
       char *qemuparam;
index cba0032..f8e6b77 100644 (file)
@@ -97,6 +97,11 @@ 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<filename>.  This
+stops you from specifying other types of drive which are supported
+by qemu such as C<nbd:> and C<http:> URLs.  To specify those, use
+the general C<$h-E<gt>config> call instead.
+
 =item $h->add_drive ($filename);
 
 This function adds a virtual machine disk image C<filename> to the
@@ -112,6 +117,30 @@ image).
 
 This is equivalent to the qemu parameter C<-drive file=filename>.
 
+Note that this call checks for the existence of C<filename>.  This
+stops you from specifying other types of drive which are supported
+by qemu such as C<nbd:> and C<http:> URLs.  To specify those, use
+the general C<$h-E<gt>config> call instead.
+
+=item $h->add_drive_ro ($filename);
+
+This adds a drive in snapshot mode, making it effectively
+read-only.
+
+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.
+
+This is equivalent to the qemu parameter
+C<-drive file=filename,snapshot=on>.
+
+Note that this call checks for the existence of C<filename>.  This
+stops you from specifying other types of drive which are supported
+by qemu such as C<nbd:> and C<http:> URLs.  To specify those, use
+the general C<$h-E<gt>config> call instead.
+
 =item $h->aug_close ();
 
 Close the current Augeas handle and free up any resources
index 6ac3bd9..71ef85e 100644 (file)
@@ -1179,6 +1179,31 @@ py_guestfs_add_cdrom (PyObject *self, PyObject *args)
 }
 
 static PyObject *
+py_guestfs_add_drive_ro (PyObject *self, PyObject *args)
+{
+  PyObject *py_g;
+  guestfs_h *g;
+  PyObject *py_r;
+  int r;
+  const char *filename;
+
+  if (!PyArg_ParseTuple (args, (char *) "Os:guestfs_add_drive_ro",
+                         &py_g, &filename))
+    return NULL;
+  g = get_handle (py_g);
+
+  r = guestfs_add_drive_ro (g, filename);
+  if (r == -1) {
+    PyErr_SetString (PyExc_RuntimeError, guestfs_last_error (g));
+    return NULL;
+  }
+
+  Py_INCREF (Py_None);
+  py_r = Py_None;
+  return py_r;
+}
+
+static PyObject *
 py_guestfs_config (PyObject *self, PyObject *args)
 {
   PyObject *py_g;
@@ -4416,6 +4441,7 @@ static PyMethodDef methods[] = {
   { (char *) "kill_subprocess", py_guestfs_kill_subprocess, METH_VARARGS, NULL },
   { (char *) "add_drive", py_guestfs_add_drive, METH_VARARGS, NULL },
   { (char *) "add_cdrom", py_guestfs_add_cdrom, METH_VARARGS, NULL },
+  { (char *) "add_drive_ro", py_guestfs_add_drive_ro, METH_VARARGS, NULL },
   { (char *) "config", py_guestfs_config, METH_VARARGS, NULL },
   { (char *) "set_qemu", py_guestfs_set_qemu, METH_VARARGS, NULL },
   { (char *) "get_qemu", py_guestfs_get_qemu, METH_VARARGS, NULL },
index 4f32ae7..a75148e 100644 (file)
@@ -198,6 +198,12 @@ class GuestFS:
         
         This is equivalent to the qemu parameter "-drive
         file=filename".
+        
+        Note that this call checks for the existence of
+        "filename". This stops you from specifying other types
+        of drive which are supported by qemu such as "nbd:" and
+        "http:" URLs. To specify those, use the general
+        "g.config" call instead.
         """
         return libguestfsmod.add_drive (self._o, filename)
 
@@ -207,9 +213,37 @@ class GuestFS:
         
         This is equivalent to the qemu parameter "-cdrom
         filename".
+        
+        Note that this call checks for the existence of
+        "filename". This stops you from specifying other types
+        of drive which are supported by qemu such as "nbd:" and
+        "http:" URLs. To specify those, use the general
+        "g.config" call instead.
         """
         return libguestfsmod.add_cdrom (self._o, filename)
 
+    def add_drive_ro (self, filename):
+        u"""This adds a drive in snapshot mode, making it
+        effectively read-only.
+        
+        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.
+        
+        This is equivalent to the qemu parameter "-drive
+        file=filename,snapshot=on".
+        
+        Note that this call checks for the existence of
+        "filename". This stops you from specifying other types
+        of drive which are supported by qemu such as "nbd:" and
+        "http:" URLs. To specify those, use the general
+        "g.config" call instead.
+        """
+        return libguestfsmod.add_drive_ro (self._o, filename)
+
     def config (self, qemuparam, qemuvalue):
         u"""This can be used to add arbitrary qemu command line
         parameters of the form "-param value". Actually it's not
index 6fb2608..4983932 100644 (file)
@@ -941,6 +941,27 @@ static VALUE ruby_guestfs_add_cdrom (VALUE gv, VALUE filenamev)
   return Qnil;
 }
 
+static VALUE ruby_guestfs_add_drive_ro (VALUE gv, VALUE filenamev)
+{
+  guestfs_h *g;
+  Data_Get_Struct (gv, guestfs_h, g);
+  if (!g)
+    rb_raise (rb_eArgError, "%s: used handle after closing it", "add_drive_ro");
+
+  const char *filename = StringValueCStr (filenamev);
+  if (!filename)
+    rb_raise (rb_eTypeError, "expected string for parameter %s of %s",
+              "filename", "add_drive_ro");
+
+  int r;
+
+  r = guestfs_add_drive_ro (g, filename);
+  if (r == -1)
+    rb_raise (e_Error, "%s", guestfs_last_error (g));
+
+  return Qnil;
+}
+
 static VALUE ruby_guestfs_config (VALUE gv, VALUE qemuparamv, VALUE qemuvaluev)
 {
   guestfs_h *g;
@@ -4016,6 +4037,8 @@ void Init__guestfs ()
         ruby_guestfs_add_drive, 1);
   rb_define_method (c_guestfs, "add_cdrom",
         ruby_guestfs_add_cdrom, 1);
+  rb_define_method (c_guestfs, "add_drive_ro",
+        ruby_guestfs_add_drive_ro, 1);
   rb_define_method (c_guestfs, "config",
         ruby_guestfs_config, 2);
   rb_define_method (c_guestfs, "set_qemu",
index 4364d35..2cd3bdb 100644 (file)
@@ -51,6 +51,7 @@ extern int guestfs_wait_ready (guestfs_h *handle);
 extern int guestfs_kill_subprocess (guestfs_h *handle);
 extern int guestfs_add_drive (guestfs_h *handle, const char *filename);
 extern int guestfs_add_cdrom (guestfs_h *handle, const char *filename);
+extern int guestfs_add_drive_ro (guestfs_h *handle, const char *filename);
 extern int guestfs_config (guestfs_h *handle, const char *qemuparam, const char *qemuvalue);
 extern int guestfs_set_qemu (guestfs_h *handle, const char *qemu);
 extern const char *guestfs_get_qemu (guestfs_h *handle);