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");
{
char c = 0;
int failed = 0;
- const char *srcdir;
const char *filename;
int fd, i;
int nr_tests, test_num = 0;
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);
}
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");
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.");
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;
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
"add",
"add-cdrom",
"cdrom",
+ "add-drive-ro",
+ "add-ro",
"config",
"set-qemu",
"qemu",
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
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
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
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
kill_subprocess,
add_drive,
add_cdrom,
+ add_drive_ro,
config,
set_qemu,
set_path,
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)
* 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)
* 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)
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
}
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)
{
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"
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 *)
}
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);
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;
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
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
}
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;
{ (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 },
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)
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
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;
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",
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);