From patchwork Tue Feb 16 17:37:49 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: 8330091 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 199B39F38B for ; Tue, 16 Feb 2016 17:40:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 50843200D9 for ; Tue, 16 Feb 2016 17:40:26 +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 7E2242028D for ; Tue, 16 Feb 2016 17:40:25 +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 1aVjZd-0007nU-EZ; Tue, 16 Feb 2016 17:38:05 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aVjZb-0007lz-Lk for xen-devel@lists.xenproject.org; Tue, 16 Feb 2016 17:38:03 +0000 Received: from [193.109.254.147] by server-9.bemta-14.messagelabs.com id DC/E2-13475-A7E53C65; Tue, 16 Feb 2016 17:38:02 +0000 X-Env-Sender: prvs=847277b8a=roger.pau@citrix.com X-Msg-Ref: server-16.tower-27.messagelabs.com!1455644276!24261109!2 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 27180 invoked from network); 16 Feb 2016 17:38:02 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-16.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 16 Feb 2016 17:38:02 -0000 X-IronPort-AV: E=Sophos;i="5.22,456,1449532800"; d="scan'208";a="338559526" From: Roger Pau Monne To: Date: Tue, 16 Feb 2016 18:37:49 +0100 Message-ID: <1455644269-40358-5-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 2.5.4 (Apple Git-61) In-Reply-To: <1455644269-40358-1-git-send-email-roger.pau@citrix.com> References: <1455644269-40358-1-git-send-email-roger.pau@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 v4 4/4] libxl: fix cd-eject 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 Current libxl__device_disk_set_backend implementation tried to guess the backend of devices with format LIBXL_DISK_FORMAT_EMPTY, which is of course doomed to fail since the disk is empty. Instead just return early from the function if an empty disk is detected. This fixes cd ejection. Signed-off-by: Roger Pau Monné Reported-by: Alex Braunegg --- Cc: Ian Jackson Cc: Ian Campbell Cc: Wei Liu Cc: Alex Braunegg --- tools/libxl/libxl_device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c index 8bb5e93..b93cbbf 100644 --- a/tools/libxl/libxl_device.c +++ b/tools/libxl/libxl_device.c @@ -273,7 +273,8 @@ 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; } - memset(&a.stab, 0, sizeof(a.stab)); + /* Disk is empty, so it's useless to try to guess the backend type. */ + return 0; } else if ((disk->backend == LIBXL_DISK_BACKEND_UNKNOWN || disk->backend == LIBXL_DISK_BACKEND_PHY) && disk->backend_domid == LIBXL_TOOLSTACK_DOMID &&