From: Ian Campbell Subject: Re: [PATCH] Only call stat() when adding a disk if we expect a device to exist. Date: Tue, 23 Apr 2013 10:44:48 +0100 Message-ID: <1366710288.20256.87.camel@zakaz.uk.xensource.com> References: <1366709813-27967-1-git-send-email-dave.scott@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1366709813-27967-1-git-send-email-dave.scott@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: David Scott Cc: "xen-devel@lists.xen.org" , Roger Pau Monne List-Id: xen-devel@lists.xenproject.org On Tue, 2013-04-23 at 10:36 +0100, David Scott wrote: > We consider calling stat() a helpful error check in the following > circumstances only: > 1. the disk backend type must be PHYsical > 2. the disk backend domain must be the same as the running libxl > code (assumed to be 0) AKA LIBXL_TOOLSTACK_DOMID. That line could also do with wrapping but I can do that as I commit if you like. > 3. there must not be a hotplug script because this would imply that > the device won't be created until after the hotplug script has > run. > > With this fix, it is possible to use qemu's built-in block drivers > such as ceph, with a xl config disk spec like this: > > disk=[ 'backendtype=qdisk,format=raw,vdev=hda,access=rw,target=rbd:rbd/ubuntu1204.img' ] > > Signed-off-by: David Scott With the above changes: Acked-by: Ian Campbell > --- > tools/libxl/libxl_device.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c > index eeea9d9..ec0fec2 100644 > --- a/tools/libxl/libxl_device.c > +++ b/tools/libxl/libxl_device.c > @@ -236,7 +236,7 @@ int libxl__device_disk_set_backend(libxl__gc *gc, libxl_device_disk *disk) { > return ERROR_INVAL; > } > memset(&a.stab, 0, sizeof(a.stab)); > - } else if (!disk->script) { > + } else if (disk->backend == LIBXL_DISK_BACKEND_PHY && disk->backend_domid == 0 && !disk->script) { > if (stat(disk->pdev_path, &a.stab)) { > LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Disk vdev=%s " > "failed to stat: %s",