From patchwork Mon May 10 12:53:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 12247963 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E34EC433ED for ; Mon, 10 May 2021 12:55:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AF36661040 for ; Mon, 10 May 2021 12:55:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AF36661040 Authentication-Results: mail.kernel.org; dmarc=pass (p=none dis=none) header.from=nongnu.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lg5Rp-0007cj-8Z for qemu-devel@archiver.kernel.org; Mon, 10 May 2021 08:55:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lg5Q3-0005DG-Vi for qemu-devel@nongnu.org; Mon, 10 May 2021 08:53:56 -0400 Received: from esa6.hc3370-68.iphmx.com ([216.71.155.175]:9497) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lg5Q2-0002OX-6Y for qemu-devel@nongnu.org; Mon, 10 May 2021 08:53:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1620651233; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=u4QGM8/JFq+CXqBDhAUitCiWNGljacYz2VCNiGxaiPY=; b=I5mUOPRpSOHnEMmAmbCIzzlFLUpMqHENaXtaDhpggJzKd2RGToQJZXKT NWjJATCpdIq6iWj93xU2UdWi5kSeOGgwSgErJE30vQE/i1KarPZsB5fSN 8HzeK6HhlRGaibyFTyeWXDHdbOpUaejlr+FkCuOXCw0Xh+kp5OXxdx/zS k=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: 7Z7gFGls+YTIeR9dHAOqE4/5OSsDGOG0IlwKFfX8QrI346t3wTpVuo0vXGmaWOIO8u0fDtaj6C yRk2urRe3DrKpumAyPYRMogiFUujHezMkQFD1hVpxFRl9KyqGl5IUnTacPZ7C2dqeJ1Z9S0Gxm D/7M6zlH5CpYW8xWExaRXKXgY6qRxN7/AMKQO9TrVbghfR+hrbw/RfYleW9jCvaWCFNKg0UOWR 7XJS8QDlNeQsHgHYADlI2IsmYLMQxPy9x3jKRPFHIIqYm7LD+oV2/LnyHZ6TTVh5GYdt0EH+er MUQ= X-SBRS: 5.1 X-MesageID: 43545480 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED IronPort-HdrOrdr: A9a23:+cRTKK3RqBeITaDSvZmXgQqjBIokLtp133Aq2lEZdPRUGvb3qy nIpoV86faUskdoZJhOo7C90cW7LU80sKQFhLX5Xo3SOzUO2lHYT72KhLGKq1aLdhEWtNQtsZ uIG5IOceEYZmIasS+V2maF+q4bsbu6zJw= X-IronPort-AV: E=Sophos;i="5.82,287,1613451600"; d="scan'208";a="43545480" To: CC: Peter Maydell , Anthony PERARD Subject: [PULL 3/3] xen-block: Use specific blockdev driver Date: Mon, 10 May 2021 13:53:40 +0100 Message-ID: <20210510125340.903323-4-anthony.perard@citrix.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510125340.903323-1-anthony.perard@citrix.com> References: <20210510125340.903323-1-anthony.perard@citrix.com> MIME-Version: 1.0 Received-SPF: pass client-ip=216.71.155.175; envelope-from=anthony.perard@citrix.com; helo=esa6.hc3370-68.iphmx.com X-Spam_score_int: -50 X-Spam_score: -5.1 X-Spam_bar: ----- X-Spam_report: (-5.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.698, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Reply-to: Anthony PERARD X-Patchwork-Original-From: Anthony PERARD via From: Anthony PERARD ... when a xen-block backend instance is created via xenstore. Following 8d17adf34f50 ("block: remove support for using "file" driver with block/char devices"), using the "file" blockdev driver for everything doesn't work anymore, we need to use the "host_device" driver when the disk image is a block device and "file" driver when it is a regular file. Signed-off-by: Anthony PERARD Acked-by: Paul Durrant Message-Id: <20210430163432.468894-1-anthony.perard@citrix.com> Signed-off-by: Anthony PERARD --- hw/block/xen-block.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/hw/block/xen-block.c b/hw/block/xen-block.c index 83754a4344..674953f1ad 100644 --- a/hw/block/xen-block.c +++ b/hw/block/xen-block.c @@ -728,6 +728,8 @@ static XenBlockDrive *xen_block_drive_create(const char *id, XenBlockDrive *drive = NULL; QDict *file_layer; QDict *driver_layer; + struct stat st; + int rc; if (params) { char **v = g_strsplit(params, ":", 2); @@ -761,7 +763,17 @@ static XenBlockDrive *xen_block_drive_create(const char *id, file_layer = qdict_new(); driver_layer = qdict_new(); - qdict_put_str(file_layer, "driver", "file"); + rc = stat(filename, &st); + if (rc) { + error_setg_errno(errp, errno, "Could not stat file '%s'", filename); + goto done; + } + if (S_ISBLK(st.st_mode)) { + qdict_put_str(file_layer, "driver", "host_device"); + } else { + qdict_put_str(file_layer, "driver", "file"); + } + qdict_put_str(file_layer, "filename", filename); g_free(filename);