qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Pavel Hrdina <phrdina@redhat.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
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 14:56:50 +0200	[thread overview]
Message-ID: <51A5FB12.1010603@redhat.com> (raw)
In-Reply-To: <51A5F586.6000208@redhat.com>

Il 29/05/2013 14:33, Pavel Hrdina ha scritto:
> On 29.5.2013 14:24, Paolo Bonzini wrote:
>> 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 <phrdina@redhat.com>
>>> ---
>>>   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(),
>>>   };
>>>
>>>
>>
>> I think the right fix is simply to remove
>>
>>      if (buf[1] & 0x80) {
>>          s->features |= 1 << SCSI_DISK_F_REMOVABLE;
>>      }
>>
>> from get_device_type.
>>
>> Paolo
>>
> 
> That was my first approach, but without this option it fails to start
> the guest if there was no media in the real CD-ROM.
> 
> These are the errors:
> qemu-system-x86_64: -device
> scsi-block,drive=drive-cd-disk,bus=scsi0.0,id=scsi_cd: Device needs
> media, but drive is empty
> qemu-system-x86_64: -device
> scsi-block,drive=drive-cd-disk,bus=scsi0.0,id=scsi_cd: Device
> initialization failed.
> qemu-system-x86_64: -device
> scsi-block,drive=drive-cd-disk,bus=scsi0.0,id=scsi_cd: Device
> 'scsi-block' could not be initialized

Right.  This test does not make sense for passthrough.  So if we add
another feature bit (e.g. SCSI_DISK_F_PASSTHROUGH) we can simply skip it.

Alternatively, the optimal test in the SCSI_DISK_F_PASSTHROUGH case
would be something like:

bool bdrv_is_opened(BlockDriverState *bs)
{
    return bs->drv != NULL;
}

Kevin, would you be okay with adding such a function?

Paolo

  reply	other threads:[~2013-05-29 12:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-29 12:12 [Qemu-devel] [PATCH 0/2] disable the scsi pass-through eject from monitor Pavel Hrdina
2013-05-29 12:12 ` [Qemu-devel] [PATCH 1/2] scsi-generic: check the return value of bdrv_aio_ioctl in execute_command Pavel Hrdina
2013-05-29 12:22   ` Paolo Bonzini
2013-05-29 12:12 ` [Qemu-devel] [PATCH 2/2] scsi-disk: scsi-block device for scsi pass-through should not be removable Pavel Hrdina
2013-05-29 12:24   ` Paolo Bonzini
2013-05-29 12:33     ` Pavel Hrdina
2013-05-29 12:56       ` Paolo Bonzini [this message]
2013-05-29 13:30   ` Paolo Bonzini
2013-05-29 13:32     ` Pavel Hrdina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51A5FB12.1010603@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=phrdina@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).