qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Kevin Shanahan <kmshanah@disenchant.net>
Cc: libvir-list@redhat.com, qemu-devel@nongnu.org,
	Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] block: Set cdrom device read only flag
Date: Mon, 06 Aug 2012 12:07:37 +0200	[thread overview]
Message-ID: <501F9769.2000902@redhat.com> (raw)
In-Reply-To: <20120802072040.GD18298@tuon.disenchant.local>

Am 02.08.2012 09:20, schrieb Kevin Shanahan:
> On Thu, Aug 02, 2012 at 02:49:52PM +0930, Kevin Shanahan wrote:
>> On Thu, Aug 02, 2012 at 11:46:13AM +0930, Kevin Shanahan wrote:
>>> On Thu, Aug 02, 2012 at 11:02:42AM +0930, Kevin Shanahan wrote:
>>>> Set the block driver read_only flag for cdrom devices so that
>>>> qmp_change_blockdev does not attempt to open cdrom files in read-write
>>>> mode when changing media.
>>>
>>> Hrm, this fixes my simple test case using the kvm monitor directly but
>>> changing media via libvirt still has the same issue (fails for RO
>>> files, succeeds for writable files).
>>>
>>> $ virsh attach-disk --type cdrom --mode readonly test1 /srv/kvm/iso/ubuntu-12.04-server-amd64.iso hdc
>>> error: Failed to attach disk
>>> error: internal error unable to execute QEMU command 'change': Could not open '/srv/kvm/iso/ubuntu-12.04-server-amd64.iso'
>>>
>>> I'll keep looking into it.
>>
>> In the libvirt case, it seems libvirt is failing to add media=cdrom to
>> the commandline, so in this case qemu is defaulting to media=disk and
>> my proposed fix has no effect. Diving into libvirt now to see why no
>> media=disk is getting added...
>>
>> Common test case has this xml (generated by virt-install):
>>
>>     <disk type='block' device='cdrom'>
>>       <driver name='qemu' type='raw'/>
>>       <target dev='hdc' bus='ide'/>
>>       <readonly/>
>>       <alias name='ide0-1-0'/>
>>       <address type='drive' controller='0' bus='1' target='0' unit='0'/>
>>     </disk>
> 
> Ok, looks like libvirt is intentionally leaving media=cdrom off the
> command line in the case that "-device ide-cd,..." is
> supported. Presumably by specifying the device this way, qemu is
> supposed to work out that the media type is cdrom automatically (but
> it doesn't, it defaults to disk).
> 
> Libvirt wants to use:
> 
> qemu-kvm ... \
>      -drive if=none,id=drive-ide0-1-0,readonly=on,format=raw \
>      -device ide-cd,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 ...
> 
> If I hack qemu/qemu_command.c::qemuBuildDriveStr() to ignore the check
> for QEMU_CAPS_IDE_CD and always add media=cdrom, then (with my qemu as
> well patch) qemu will open cdrom media files read-only.
> 
> There's probably a neater way to just get qemu to set the media type
> if "-device ide-cd,..." is used, but I haven't worked it out yet.
> 
> Anyway, apologies for the rambling conversation with myself on your
> lists. Hope this is helpful in some way.

Thanks, that's some good information.

However, I don't think you should start from media=cdrom. libvirt
already does specify readonly=on and that is the property you're really
interested in. Since commit 528f7663 (released with 0.13) the 'change'
command should keep the read-only flag for all kinds of media.

Now I'm not sure where you lost the read-only flag. At least on git
master it doesn't seem to reproduce for me.

Kevin

  reply	other threads:[~2012-08-06 10:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-02  1:32 [Qemu-devel] [PATCH] block: Set cdrom device read only flag Kevin Shanahan
2012-08-02  2:16 ` Kevin Shanahan
2012-08-02  5:19   ` Kevin Shanahan
2012-08-02  7:20     ` Kevin Shanahan
2012-08-06 10:07       ` Kevin Wolf [this message]
2012-08-07  8:47         ` Markus Armbruster
2012-08-07  9:46           ` ronnie sahlberg
2012-08-07 11:54             ` Markus Armbruster
2012-08-09  8:42           ` Kevin Wolf
2012-08-12  2:48             ` Kevin Shanahan
2012-08-13  7:54               ` Kevin Wolf
2012-08-13 11:57                 ` Markus Armbruster
2012-08-13 13:20                   ` Kevin Wolf
2012-09-20  8:22                 ` Kevin Wolf

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=501F9769.2000902@redhat.com \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=kmshanah@disenchant.net \
    --cc=libvir-list@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).