Skip to contentSkip to conversation

scsi-disk: scsi-block device for scsi pass-through should not be removable

PATCH Applied Pavel Hrdina 2 participants 2 messages May 29, 2013 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH v2 2/2 scsi-disk: scsi-block device for scsi pass-through should not be removable

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.

---
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(-)
hw/scsi/scsi-disk.c +11 -3
index c8d2a99..729418f 100644
@@ -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);
 }
 
Signature · 1 line
1.8.1.4
#2 lore raw

Il 29/05/2013 15:47, Pavel Hrdina ha scritto:

Quoted 44 lines

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.

---
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(-)
hw/scsi/scsi-disk.c +5 -3
index c8d2a99..729418f 100644
@@ -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;

hw/scsi/scsi-disk.c static int scsi_block_initfn(SCSIDevice *dev) · line 2332

Quoted 10 lines
hw/scsi/scsi-disk.c +6 -0
     }
+
+    /* 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