* [Qemu-devel] [PATCH v2 2/2] scsi-disk: scsi-block device for scsi pass-through should not be removable
[not found] <cover.1369834642.git.phrdina@redhat.com>
@ 2013-05-29 13:47 ` Pavel Hrdina
2013-05-29 14:24 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Pavel Hrdina @ 2013-05-29 13:47 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, pbonzini, phrdina
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.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
changes from v1:
- renamed the SCSI_DISK_F_MONITOR_NOT_REMOVABLE
into SCSI_DISK_F_NO_REMOVABLE_DEVOPS
- set this bit directli in scsi_block_initfn
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 c8d2a99..729418f 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
{
@@ -2107,7 +2108,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);
@@ -2319,6 +2321,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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH v2 2/2] scsi-disk: scsi-block device for scsi pass-through should not be removable
2013-05-29 13:47 ` [Qemu-devel] [PATCH v2 2/2] scsi-disk: scsi-block device for scsi pass-through should not be removable Pavel Hrdina
@ 2013-05-29 14:24 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2013-05-29 14:24 UTC (permalink / raw)
To: Pavel Hrdina; +Cc: kwolf, qemu-devel
Il 29/05/2013 15:47, Pavel Hrdina ha scritto:
> 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.
>
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
> changes from v1:
> - renamed the SCSI_DISK_F_MONITOR_NOT_REMOVABLE
> into SCSI_DISK_F_NO_REMOVABLE_DEVOPS
> - set this bit directli in scsi_block_initfn
>
> 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 c8d2a99..729418f 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
> {
> @@ -2107,7 +2108,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);
> @@ -2319,6 +2321,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);
> }
>
>
Applied, thanks.
Paolo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-05-29 14:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1369834642.git.phrdina@redhat.com>
2013-05-29 13:47 ` [Qemu-devel] [PATCH v2 2/2] scsi-disk: scsi-block device for scsi pass-through should not be removable Pavel Hrdina
2013-05-29 14:24 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).