qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/2] scsi-disk: scsi-block device for scsi pass-


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 2/2] scsi-disk: scsi-block device for scsi pass-through should not be removable
Date: Wed, 29 May 2013 15:30:17 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6

Il 29/05/2013 14:12, Pavel Hrdina ha scritto:
> This patch adds a new SCSI_DISK_F_MONITOR_NOT_REMOVABLE 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 <address@hidden>
> ---
>  hw/scsi/scsi-disk.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
> index c8d2a99..190c3ad 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_MONITOR_NOT_REMOVABLE   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_MONITOR_NOT_REMOVABLE))) {
>          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);
> @@ -2463,6 +2465,8 @@ static const TypeInfo scsi_cd_info = {
>  static Property scsi_block_properties[] = {
>      DEFINE_PROP_DRIVE("drive", SCSIDiskState, qdev.conf.bs),
>      DEFINE_PROP_INT32("bootindex", SCSIDiskState, qdev.conf.bootindex, -1),
> +    DEFINE_PROP_BIT("monitor_not_removable", SCSIDiskState, features,
> +                    SCSI_DISK_F_MONITOR_NOT_REMOVABLE, true),
>      DEFINE_PROP_END_OF_LIST(),
>  };
>  
> 

Kevin convinced me offlist to take this patch, but I'll still ask for
two changes:

1) rename the feature bit to SCSI_DISK_F_NO_REMOVABLE_DEVOPS

2) set the feature in scsi_block_initfn instead of using a bit, because
the user should not be able to toggle this.

Thanks!

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]