All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Campbell <Ian.Campbell@eu.citrix.com>
To: Ian Jackson <Ian.Jackson@eu.citrix.com>
Cc: Kamala Narasimhan <kamala.narasimhan@gmail.com>,
	"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>,
	Gianni Tedesco <gianni.tedesco@citrix.com>,
	Stefano Stabellini <Stefano.Stabellini@eu.citrix.com>
Subject: Re: [PATCH] xl: Perform minimal validation of virtual disk file while parsing config file
Date: Wed, 26 Jan 2011 10:27:34 +0000	[thread overview]
Message-ID: <1296037654.14780.6743.camel@zakaz.uk.xensource.com> (raw)
In-Reply-To: <19775.4623.927492.247420@mariner.uk.xensource.com>

On Tue, 2011-01-25 at 18:10 +0000, Ian Jackson wrote:
> Kamala Narasimhan writes ("Re: [Xen-devel] [PATCH] xl: Perform minimal validation of virtual disk file while parsing config file"):
> > Ian - Apologies for the delay.  I think I have covered all comments so far.  If there are more I will get to it ASAP.  Please let me know.
> 
> Thanks, I have applied your patch, with a minor tweak to make it work
> with Stefano's PHYSTYPE_EMPTY patch.

With this patch applied I get an error using an LVM device via file://
(which is currently necessary on upstream dom0 support in order to
activate the qdisk support):
        # xl cr -c /etc/xen/debian-x86_32p-1
        Parsing config file /etc/xen/debian-x86_32p-1
        libxl: error: libxl.c:854:validate_virtual_disk Virtual disk /dev/VG/debian-x86_32-1 size is 0!
        
My disk stanza is
        # grep ^disk /etc/xen/debian-x86_32p-1
        disk = ['file:/dev/VG/debian-x86_32-1,xvda,w']

I think the issue is in this fragment:
    if ( disk_type == PHYSTYPE_PHY ) {
        if ( !(S_ISBLK(stat_buf.st_mode)) ) {
            LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Virtual disk %s is not a block device!\n",
                file_name);
            return ERROR_INVAL;
        }
    } else if ( stat_buf.st_size == 0 ) {
        LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Virtual disk %s size is 0!\n", file_name);
        return ERROR_INVAL;
    }
since stat(2) says that st_size is only valid for a regular file or
symbolic link (the latter being irrelevant in this case since we are
using stat() and not lstat()).

Ian.

8<--------------------


# HG changeset patch
# User Ian Campbell <ian.campbell@citrix.com>
# Date 1296037362 0
# Node ID e4e69622dc95037eab6740f79ecf9c1d05bca529
# Parent  751232406cedb808149ece09480f7a7ec552483d
libxl: only check size of regular files when validating a virtual disk

st_size is only valid for regular files and not block devices.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>

diff -r 751232406ced -r e4e69622dc95 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Wed Jan 26 09:11:34 2011 +0000
+++ b/tools/libxl/libxl.c	Wed Jan 26 10:22:42 2011 +0000
@@ -850,7 +850,7 @@ static int validate_virtual_disk(libxl_c
                 file_name);
             return ERROR_INVAL;
         }
-    } else if ( stat_buf.st_size == 0 ) {
+    } else if ( S_ISREG(stat_buf.st_mode) && stat_buf.st_size == 0 ) {
         LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Virtual disk %s size is 0!\n", file_name);
         return ERROR_INVAL;
     }

  parent reply	other threads:[~2011-01-26 10:27 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-13 15:35 [PATCH] xl: Perform minimal validation of virtual disk file while parsing config file Kamala Narasimhan
2011-01-14  9:05 ` Ian Campbell
2011-01-14 14:55   ` Kamala Narasimhan
2011-01-14 16:59     ` Gianni Tedesco
2011-01-14 17:17       ` Kamala Narasimhan
2011-01-19 18:09         ` Kamala Narasimhan
2011-01-19 18:26           ` Kamala Narasimhan
2011-01-20 14:04             ` Gianni Tedesco
2011-01-20 14:12               ` Gianni Tedesco
2011-01-20 15:08               ` Kamala Narasimhan
2011-01-20 15:22                 ` Gianni Tedesco
2011-01-20 15:22                 ` Kamala Narasimhan
2011-01-20 15:41               ` Kamala Narasimhan
2011-01-20 15:49               ` Ian Jackson
2011-01-20 16:46                 ` Kamala Narasimhan
2011-01-20 21:14                   ` Kamala Narasimhan
2011-01-21 12:17                     ` Ian Jackson
2011-01-21 13:27                       ` Gianni Tedesco
2011-01-22  2:33                         ` Kamala Narasimhan
2011-01-25 18:10                           ` Ian Jackson
2011-01-26  3:07                             ` Kamala Narasimhan
2011-01-26 11:43                               ` Ian Jackson
2011-01-26 18:02                                 ` Kamala Narasimhan
2011-01-26 10:27                             ` Ian Campbell [this message]
2011-01-26 11:48                               ` Ian Jackson
2011-01-26 11:54                                 ` Ian Campbell
2011-01-24 14:18                       ` Kamala Narasimhan
2011-01-24 14:31                         ` Kamala Narasimhan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1296037654.14780.6743.camel@zakaz.uk.xensource.com \
    --to=ian.campbell@eu.citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=Stefano.Stabellini@eu.citrix.com \
    --cc=gianni.tedesco@citrix.com \
    --cc=kamala.narasimhan@gmail.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.