On Mon, Apr 25, 2022 at 10:35:47PM +0300, Andrey Drobyshev wrote:
> If the appliance is a QCOW2 image, function get_root_uuid_with_file()
> fails to read ext filesystem signature (0x53EF at offset 0x438) from it.
> This results in the following error:
> 
> libguestfs: error: /usr/lib64/guestfs/appliance/root: appliance is not
> an extfs filesystem
> 
> The error itself is harmless, but misleading.  So let's skip retrieving
> the signature and UUID in case the image contains QCOW2 header.  It's
> safe because in this case we'll retrieve it later from RAW image dumped
> from that QCOW2 by "qemu-img dd".
> 
> Signed-off-by: Andrey Drobyshev <[email protected]>

Thanks Andrey, I've pushed it.

Rich.

>  lib/appliance-kcmdline.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/appliance-kcmdline.c b/lib/appliance-kcmdline.c
> index 8b78655eb..092d37329 100644
> --- a/lib/appliance-kcmdline.c
> +++ b/lib/appliance-kcmdline.c
> @@ -65,7 +65,7 @@
>  static char *
>  get_root_uuid_with_file (guestfs_h *g, const char *appliance)
>  {
> -  unsigned char magic[2], uuid[16];
> +  unsigned char magic[4], uuid[16];
>    char *ret;
>    int fd;
>  
> @@ -74,6 +74,10 @@ get_root_uuid_with_file (guestfs_h *g, const char 
> *appliance)
>      perrorf (g, _("open: %s"), appliance);
>      return NULL;
>    }
> +  if (read (fd, magic, 4) != 4 || !strncmp ((char *) magic, "QFI\xfb", 4)) {
> +    /* No point looking for extfs signature in QCOW2 directly. */
> +    return NULL;
> +  }
>    if (lseek (fd, 0x438, SEEK_SET) != 0x438) {
>    magic_error:
>      error (g, _("%s: cannot read extfs magic in superblock"), appliance);
> -- 
> 2.35.1

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
_______________________________________________
Libguestfs mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/libguestfs

Reply via email to