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.
Cc: qemu-stable@nongnu.org
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 18e673b8f3
)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
This commit is contained in:
committed by
Michael Roth
parent
637d640fbb
commit
129db3679c
@@ -61,8 +61,9 @@ typedef struct SCSIDiskReq {
|
|||||||
BlockAcctCookie acct;
|
BlockAcctCookie acct;
|
||||||
} SCSIDiskReq;
|
} SCSIDiskReq;
|
||||||
|
|
||||||
#define SCSI_DISK_F_REMOVABLE 0
|
#define SCSI_DISK_F_REMOVABLE 0
|
||||||
#define SCSI_DISK_F_DPOFUA 1
|
#define SCSI_DISK_F_DPOFUA 1
|
||||||
|
#define SCSI_DISK_F_NO_REMOVABLE_DEVOPS 2
|
||||||
|
|
||||||
struct SCSIDiskState
|
struct SCSIDiskState
|
||||||
{
|
{
|
||||||
@@ -2110,7 +2111,8 @@ static int scsi_initfn(SCSIDevice *dev)
|
|||||||
return -1;
|
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);
|
bdrv_set_dev_ops(s->qdev.conf.bs, &scsi_disk_removable_block_ops, s);
|
||||||
} else {
|
} else {
|
||||||
bdrv_set_dev_ops(s->qdev.conf.bs, &scsi_disk_block_ops, s);
|
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 {
|
} else {
|
||||||
s->qdev.blocksize = 512;
|
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);
|
return scsi_initfn(&s->qdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user