qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 1/1] block: add missed BDRV_O_NOCACHE when block device is opened without file
@ 2017-01-25 16:42 Denis V. Lunev
  2017-01-25 17:59 ` Max Reitz
  0 siblings, 1 reply; 6+ messages in thread
From: Denis V. Lunev @ 2017-01-25 16:42 UTC (permalink / raw)
  To: qemu-devel; +Cc: Denis V. Lunev, Kevin Wolf, Max Reitz

Technically there is a problem when the guest DVD is created by libvirt
with AIO mode 'native' on Linux. Current QEMU is unable to start the
domain configured as follows:
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw' cache='none' io='native'/>
      <target dev='sdb' bus='scsi'/>
      <readonly/>
    </disk>
The problem comes from the combination of 'cache' and 'io' options.

'io' option is common option and it is removed from block driver
specific options. 'cache' originally is not. The patch makes 'cache'
option common. This works fine as long as cdrom media insertion
later on.

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Max Reitz <mreitz@redhat.com>
---
 blockdev.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

May be this has already discussed, but still. AIO=native for CDROM without
media seems important case.

diff --git a/blockdev.c b/blockdev.c
index 245e1e1..004dcde 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -374,6 +374,13 @@ static void extract_common_blockdev_options(QemuOpts *opts, int *bdrv_flags,
                return;
             }
         }
+
+        if (qemu_opt_get_bool(opts, BDRV_OPT_CACHE_NO_FLUSH, false)) {
+            *bdrv_flags |= BDRV_O_NO_FLUSH;
+        }
+        if (qemu_opt_get_bool(opts, BDRV_OPT_CACHE_DIRECT, false)) {
+            *bdrv_flags |= BDRV_O_NOCACHE;
+        }
     }
 
     /* disk I/O throttling */
@@ -569,11 +576,8 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts,
         /* bdrv_open() defaults to the values in bdrv_flags (for compatibility
          * with other callers) rather than what we want as the real defaults.
          * Apply the defaults here instead. */
-        qdict_set_default_str(bs_opts, BDRV_OPT_CACHE_DIRECT, "off");
-        qdict_set_default_str(bs_opts, BDRV_OPT_CACHE_NO_FLUSH, "off");
         qdict_set_default_str(bs_opts, BDRV_OPT_READ_ONLY,
                               read_only ? "on" : "off");
-        assert((bdrv_flags & BDRV_O_CACHE_MASK) == 0);
 
         if (runstate_check(RUN_STATE_INMIGRATE)) {
             bdrv_flags |= BDRV_O_INACTIVE;
@@ -3996,6 +4000,14 @@ QemuOptsList qemu_common_drive_opts = {
             .type = QEMU_OPT_STRING,
             .help = "write error action",
         },{
+            .name = BDRV_OPT_CACHE_DIRECT,
+            .type = QEMU_OPT_BOOL,
+            .help = "Bypass software writeback cache on the host",
+        }, {
+            .name = BDRV_OPT_CACHE_NO_FLUSH,
+            .type = QEMU_OPT_BOOL,
+            .help = "Ignore flush requests",
+        }, {
             .name = BDRV_OPT_READ_ONLY,
             .type = QEMU_OPT_BOOL,
             .help = "open drive file as read-only",
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-01-30  9:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-25 16:42 [Qemu-devel] [PATCH 1/1] block: add missed BDRV_O_NOCACHE when block device is opened without file Denis V. Lunev
2017-01-25 17:59 ` Max Reitz
2017-01-25 19:44   ` Denis V. Lunev
2017-01-28 16:23     ` Max Reitz
2017-01-30  8:31       ` Denis V. Lunev
2017-01-30  9:53     ` Kevin Wolf

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).