From mboxrd@z Thu Jan 1 00:00:00 1970 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 Sender: Paolo Bonzini From: Paolo Bonzini Date: Tue, 18 Jun 2013 16:16:53 +0200 Message-Id: <1371565016-2643-5-git-send-email-pbonzini@redhat.com> In-Reply-To: <1371565016-2643-1-git-send-email-pbonzini@redhat.com> References: <1371565016-2643-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 4/7] scsi-disk: scsi-block device for scsi pass-through should not be removable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Pavel Hrdina , mdroth@linux.vnet.ibm.com, qemu-stable@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); } -- 1.8.1.4