From patchwork Fri Feb 19 18:01:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 8363291 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E70EE9F372 for ; Fri, 19 Feb 2016 18:04:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1E6232053A for ; Fri, 19 Feb 2016 18:04:32 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3D7CA20529 for ; Fri, 19 Feb 2016 18:04:31 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aWpNU-00023d-MK; Fri, 19 Feb 2016 18:02:04 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aWpNS-00023A-IU for xen-devel@lists.xenproject.org; Fri, 19 Feb 2016 18:02:02 +0000 Received: from [85.158.139.211] by server-10.bemta-5.messagelabs.com id 75/A5-02978-99857C65; Fri, 19 Feb 2016 18:02:01 +0000 X-Env-Sender: prvs=850bb4f4b=roger.pau@citrix.com X-Msg-Ref: server-13.tower-206.messagelabs.com!1455904919!23404524!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 7070 invoked from network); 19 Feb 2016 18:02:00 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-13.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 19 Feb 2016 18:02:00 -0000 X-IronPort-AV: E=Sophos;i="5.22,471,1449532800"; d="scan'208";a="339477285" From: Roger Pau Monne To: Date: Fri, 19 Feb 2016 19:01:55 +0100 Message-ID: <1455904915-45056-1-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 2.5.4 (Apple Git-61) In-Reply-To: <56C753DE.7030409@citrix.com> References: <56C753DE.7030409@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Wei Liu , Alex Braunegg , Ian Jackson , Ian Campbell , Roger Pau Monne Subject: [Xen-devel] [PATCH v7] libxl: allow 'phy' backend to use empty files X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This was introduced by 97ee1f (~5 years ago), but was probably never surfaced because most people used regular files as CDROM images, so the PHY backend was actually never selected. A year ago this was changed, and now regular RAW files are also handled by the PHY backend, which has made this bug suface. Fix it by allowing empty disks to use the PHY backend, skipping the stat tests. Signed-off-by: Roger Pau Monné Reported-by: Alex Braunegg --- Cc: Ian Jackson Cc: Ian Campbell Cc: Wei Liu Cc: Alex Braunegg --- Changes since v6: - Turn the assert into a check at libxl__device_disk_set_backend. Changes since v4: - Split form the rest of the series. - Fix disk_try_backend. --- tools/libxl/libxl_device.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c index 8bb5e93..e0a81e3 100644 --- a/tools/libxl/libxl_device.c +++ b/tools/libxl/libxl_device.c @@ -196,6 +196,12 @@ static int disk_try_backend(disk_try_backend_args *a, goto bad_format; } + if (a->disk->format == LIBXL_DISK_FORMAT_EMPTY) { + LOG(DEBUG, "Disk vdev=%s is empty, skipping physical device check", + a->disk->vdev); + return backend; + } + if (a->disk->backend_domid != LIBXL_TOOLSTACK_DOMID) { LOG(DEBUG, "Disk vdev=%s, is using a storage driver domain, " "skipping physical device check", a->disk->vdev); @@ -273,6 +279,12 @@ int libxl__device_disk_set_backend(libxl__gc *gc, libxl_device_disk *disk) { LOG(ERROR, "Disk vdev=%s is empty but not cdrom", disk->vdev); return ERROR_INVAL; } + if (disk->pdev_path != NULL && strcmp(disk->pdev_path, "")) { + LOG(ERROR, + "Disk vdev=%s is empty but an image has been provided: %s", + disk->vdev, disk->pdev_path); + return ERROR_INVAL; + } memset(&a.stab, 0, sizeof(a.stab)); } else if ((disk->backend == LIBXL_DISK_BACKEND_UNKNOWN || disk->backend == LIBXL_DISK_BACKEND_PHY) &&