[libvirt] [PATCH v3 3/5] osdep: Enable qemu_open to dup pre-opened fd
Kevin Wolf
kwolf at redhat.com
Mon Jun 18 08:10:56 UTC 2012
Am 15.06.2012 22:00, schrieb Eric Blake:
> On 06/15/2012 01:19 PM, Corey Bryant wrote:
>
>>>> There are some flags that I don't think we'll be able to change. For
>>>> example: O_RDONLY, O_WRONLY, O_RDWR. I assume libvirt would open all
>>>> files O_RDWR.
>>>
>>> I think we need to check all of them and fail qemu_open() if they don't
>>> match. Those that qemu can change, should be just changed, of course.
>>>
>>
>> Ok. I remember a scenario where QEMU opens a file read-only (perhaps to
>> check headers and determine the file format) before re-opening it
>> read-write. Perhaps this is only when format= isn't specified with
>> -drive. I'm thinking we may need to change flags to read-write where
>> they used to be read-only, in some circumstances.
>
> In those situations, libvirt would pass fd with O_RDWR, and qemu_open()
> would be fine requesting O_RDONLY the first time (subset is okay), and
> O_RDWR the second time. Where you have to error out is where libvirt
> passes O_RDONLY but qemu wants O_RDWR, and so forth.
Let's try it with requiring an exact match first. If you pass the
format, I think the probing is completely avoided indeed, and having
read-only images really opened O_RDONLY protects against stupid mistakes.
Or if we really need to open the file for probing, maybe we could add a
flag that relaxes the check and that isn't used in the real bdrv_open().
Kevin
More information about the libvir-list
mailing list