[Libguestfs] [PATCH] drives: force format=raw for /dev/null dummy drives
Richard W.M. Jones
rjones at redhat.com
Wed May 18 15:39:42 UTC 2016
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.5
Makes 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
More information about the Libguestfs
mailing list