qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [V5 Patch 3/4]Qemu: Command "block_set" for dynamic blo


From: Anthony Liguori
Subject: Re: [Qemu-devel] [V5 Patch 3/4]Qemu: Command "block_set" for dynamic block params change
Date: Wed, 27 Jul 2011 08:52:04 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110516 Lightning/1.0b2 Thunderbird/3.1.10

On 07/27/2011 08:43 AM, Michael Tokarev wrote:
Index: qemu/block.c
===================================================================
--- qemu.orig/block.c
+++ qemu/block.c
@@ -651,6 +651,34 @@ unlink_and_fail:
      return ret;
  }

+int bdrv_reopen(BlockDriverState *bs, int bdrv_flags)
+{
+    BlockDriver *drv = bs->drv;
+    int ret = 0, open_flags;
+
+    /* Quiesce IO for the given block device */
+    qemu_aio_flush();
+    if (bdrv_flush(bs)) {
+        qerror_report(QERR_DATA_SYNC_FAILED, bs->device_name);
+        return ret;
+    }
+    open_flags = bs->open_flags;
+    bdrv_close(bs);
+
+    ret = bdrv_open(bs, bs->filename, bdrv_flags, drv);
+    if (ret<  0) {
+        /* Reopen failed. Try to open with original flags */
+        qerror_report(QERR_REOPEN_FILE_FAILED, bs->filename);
+        ret = bdrv_open(bs, bs->filename, open_flags, drv);
+        if (ret<  0) {
+            /* Reopen failed with orig and modified flags */
+            abort();
+        }

Can we please avoid this stuff completely?  Just keep the
old device open still, until you're sure new one is ok.

I may be misremembering, but I thought Christoph had mentioned wanting to write a kernel patch to toggle O_DIRECT through fcntl().

This seems like the only way to make this not racy to me.

Regards,

Anthony Liguori



reply via email to

[Prev in Thread] Current Thread [Next in Thread]