Pino Toscano
2016-May-18 15:28 UTC
[Libguestfs] [PATCH] drives: force format=raw for /dev/null dummy drives
When creating the dummy scratch disk for a /dev/null drive, force its format as raw if it was not specified already. After all, raw was already the only format allowed for this kind of drives, so it makes sense to specify the format explicitly and avoid the autodetection in qemu. --- src/drives.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/drives.c b/src/drives.c index c55b87e..1a4ae27 100644 --- a/src/drives.c +++ b/src/drives.c @@ -410,9 +410,15 @@ create_drive_dev_null (guestfs_h *g, { CLEANUP_FREE char *tmpfile = NULL; - if (data->format && STRNEQ (data->format, "raw")) { - error (g, _("for device '/dev/null', format must be 'raw'")); - return NULL; + if (data->format) { + if (data->format && STRNEQ (data->format, "raw")) { + error (g, _("for device '/dev/null', format must be 'raw'")); + return NULL; + } + } else { + /* Manual set format=raw for /dev/null drives, if that was not + * already manually specified. */ + data->format = "raw"; } if (guestfs_int_lazy_make_tmpdir (g) == -1) -- 2.5.5
Richard W.M. Jones
2016-May-18 15:39 UTC
Re: [Libguestfs] [PATCH] drives: force format=raw for /dev/null dummy drives
On Wed, May 18, 2016 at 05:28:12PM +0200, Pino Toscano wrote:> When creating the dummy scratch disk for a /dev/null drive, force its > format as raw if it was not specified already. After all, raw was > already the only format allowed for this kind of drives, so it makes > sense to specify the format explicitly and avoid the autodetection in > qemu. > --- > src/drives.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/src/drives.c b/src/drives.c > index c55b87e..1a4ae27 100644 > --- a/src/drives.c > +++ b/src/drives.c > @@ -410,9 +410,15 @@ create_drive_dev_null (guestfs_h *g, > { > CLEANUP_FREE char *tmpfile = NULL; > > - if (data->format && STRNEQ (data->format, "raw")) { > - error (g, _("for device '/dev/null', format must be 'raw'")); > - return NULL; > + if (data->format) { > + if (data->format && STRNEQ (data->format, "raw")) { > + error (g, _("for device '/dev/null', format must be 'raw'")); > + return NULL; > + } > + } else { > + /* Manual set format=raw for /dev/null drives, if that was not > + * already manually specified. */ > + data->format = "raw"; > } > > if (guestfs_int_lazy_make_tmpdir (g) == -1) > -- > 2.5.5Makes sense, ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
Maybe Matching Threads
- [PATCH v2] drives: force format=raw for /dev/null dummy drives
- [PATCH 2/2] lib: use guestfs_int_make_temp_path to generate temporary files
- [PATCH 0/2] generic function for temporary path generation
- Re: [PATCH v2 03/18] New API parameter: Add discard parameter to guestfs_add_drive_opts.
- [PATCH] Rename mdadm_ apis to md_