From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhfZ8-00011c-DQ for qemu-devel@nongnu.org; Wed, 29 May 2013 08:33:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UhfZ3-0004n6-8J for qemu-devel@nongnu.org; Wed, 29 May 2013 08:33:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60018) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhfZ2-0004mj-TQ for qemu-devel@nongnu.org; Wed, 29 May 2013 08:33:13 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4TCXC2W021972 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 29 May 2013 08:33:12 -0400 Message-ID: <51A5F586.6000208@redhat.com> Date: Wed, 29 May 2013 14:33:10 +0200 From: Pavel Hrdina MIME-Version: 1.0 References: <51A5F390.9030707@redhat.com> In-Reply-To: <51A5F390.9030707@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/2] scsi-disk: scsi-block device for scsi pass-through should not be removable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: kwolf@redhat.com, qemu-devel@nongnu.org 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 >> --- >> 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 Pavel