From patchwork Tue Jun 18 14:16:53 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 252363 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1D6642C02AD for ; Wed, 19 Jun 2013 00:40:57 +1000 (EST) Received: from localhost ([::1]:34654 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UowmO-0005yx-NY for incoming@patchwork.ozlabs.org; Tue, 18 Jun 2013 10:21:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35886) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uowij-0000IW-3B for qemu-devel@nongnu.org; Tue, 18 Jun 2013 10:17:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uowie-0001Q8-El for qemu-devel@nongnu.org; Tue, 18 Jun 2013 10:17:17 -0400 Received: from mail-we0-x235.google.com ([2a00:1450:400c:c03::235]:44163) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uowie-0001Q1-9g; Tue, 18 Jun 2013 10:17:12 -0400 Received: by mail-we0-f181.google.com with SMTP id p58so3487463wes.12 for ; Tue, 18 Jun 2013 07:17:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=7xm1I4WoB4iKs+8xYpnrd8PjliV+SjoG//cizH5I5Mg=; b=dT8IM6xjrJpcG/k6tmmC7lvtkfdX8Cs6OmdCgm5c3hposTz6m8ti3FCg46NUIRPDFW knT1ZciyuCegCQh7El2iZQgD5C09ocpOwVO8FvX0dl+jKvPmFajjskzuHvZ75/DzN54v VQA5jdgA/5SSRribsUG+XeaZTy/Jkhwip9Cszy3IhBurdZH1AfGRBjno150ekFTQX2z5 dAEXbwTHgj6mGBLq8eo48Gr5d/vLmKrx4BCvOJl6K+wxXKZD7eB2oyf2PpMYh2NDxyio Qg3im96TUmYT78v9RF2aq1Fce+T41VbkDiF3buZftq5n5vjwzdrzx6+BCUp6MonIv/ye 3fbA== X-Received: by 10.194.24.225 with SMTP id x1mr8844508wjf.62.1371565031568; Tue, 18 Jun 2013 07:17:11 -0700 (PDT) Received: from playground.lan (net-37-116-217-184.cust.dsl.vodafone.it. [37.116.217.184]) by mx.google.com with ESMTPSA id o14sm2385861wiv.3.2013.06.18.07.17.09 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 18 Jun 2013 07:17:10 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Tue, 18 Jun 2013 16:16:53 +0200 Message-Id: <1371565016-2643-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1371565016-2643-1-git-send-email-pbonzini@redhat.com> References: <1371565016-2643-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c03::235 Cc: Pavel Hrdina , mdroth@linux.vnet.ibm.com, qemu-stable@nongnu.org Subject: [Qemu-devel] [PATCH 4/7] scsi-disk: scsi-block device for scsi pass-through should not be removable X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Pavel Hrdina This patch adds a new SCSI_DISK_F_NO_REMOVABLE_DEVOPS feature. By this feature we can set that the scsi-block (scsi pass-through) device will still be removable from the guest side, but from monitor it cannot be removed. Cc: qemu-stable@nongnu.org Signed-off-by: Pavel Hrdina Signed-off-by: Paolo Bonzini --- hw/scsi/scsi-disk.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 02733dc..74e6a14 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -61,8 +61,9 @@ typedef struct SCSIDiskReq { BlockAcctCookie acct; } SCSIDiskReq; -#define SCSI_DISK_F_REMOVABLE 0 -#define SCSI_DISK_F_DPOFUA 1 +#define SCSI_DISK_F_REMOVABLE 0 +#define SCSI_DISK_F_DPOFUA 1 +#define SCSI_DISK_F_NO_REMOVABLE_DEVOPS 2 struct SCSIDiskState { @@ -2110,7 +2111,8 @@ static int scsi_initfn(SCSIDevice *dev) return -1; } - if (s->features & (1 << SCSI_DISK_F_REMOVABLE)) { + if ((s->features & (1 << SCSI_DISK_F_REMOVABLE)) && + !(s->features & (1 << SCSI_DISK_F_NO_REMOVABLE_DEVOPS))) { bdrv_set_dev_ops(s->qdev.conf.bs, &scsi_disk_removable_block_ops, s); } else { bdrv_set_dev_ops(s->qdev.conf.bs, &scsi_disk_block_ops, s); @@ -2322,6 +2324,12 @@ static int scsi_block_initfn(SCSIDevice *dev) } else { s->qdev.blocksize = 512; } + + /* Makes the scsi-block device not removable by using HMP and QMP eject + * command. + */ + s->features |= (1 << SCSI_DISK_F_NO_REMOVABLE_DEVOPS); + return scsi_initfn(&s->qdev); }