Patchwork [v2] block: add bdrv_reopen() support for raw hdev, floppy, and cdrom

login
register
mail settings
Submitter Jeff Cody
Date Nov. 20, 2012, 3:21 p.m.
Message ID <98d24a4a1a82d48a6fdc866fd74d9d33a22a4025.1353424700.git.jcody@redhat.com>
Download mbox | patch
Permalink /patch/200376/
State New
Headers show

Comments

Jeff Cody - Nov. 20, 2012, 3:21 p.m.
For hdev, floppy, and cdrom, the reopen() handlers are the same as
for the file reopen handler.  For floppy and cdrom types, however,
we keep O_NONBLOCK, as in the _open function.

Signed-off-by: Jeff Cody <jcody@redhat.com>
---
 block/raw-posix.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
Stefan Hajnoczi - Nov. 20, 2012, 3:43 p.m.
On Tue, Nov 20, 2012 at 10:21:10AM -0500, Jeff Cody wrote:
> For hdev, floppy, and cdrom, the reopen() handlers are the same as
> for the file reopen handler.  For floppy and cdrom types, however,
> we keep O_NONBLOCK, as in the _open function.
> 
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
>  block/raw-posix.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)

Thanks, applied to my block-next tree:
https://github.com/stefanha/qemu/commits/block-next

Stefan

Patch

diff --git a/block/raw-posix.c b/block/raw-posix.c
index f2f0404..550c81f 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -333,6 +333,10 @@  static int raw_reopen_prepare(BDRVReopenState *state,
     }
 #endif
 
+    if (s->type == FTYPE_FD || s->type == FTYPE_CD) {
+        raw_s->open_flags |= O_NONBLOCK;
+    }
+
     raw_parse_flags(state->flags, &raw_s->open_flags);
 
     raw_s->fd = -1;
@@ -1409,6 +1413,9 @@  static BlockDriver bdrv_host_device = {
     .bdrv_probe_device  = hdev_probe_device,
     .bdrv_file_open     = hdev_open,
     .bdrv_close         = raw_close,
+    .bdrv_reopen_prepare = raw_reopen_prepare,
+    .bdrv_reopen_commit  = raw_reopen_commit,
+    .bdrv_reopen_abort   = raw_reopen_abort,
     .bdrv_create        = hdev_create,
     .create_options     = raw_create_options,
     .bdrv_has_zero_init = hdev_has_zero_init,
@@ -1530,6 +1537,9 @@  static BlockDriver bdrv_host_floppy = {
     .bdrv_probe_device	= floppy_probe_device,
     .bdrv_file_open     = floppy_open,
     .bdrv_close         = raw_close,
+    .bdrv_reopen_prepare = raw_reopen_prepare,
+    .bdrv_reopen_commit  = raw_reopen_commit,
+    .bdrv_reopen_abort   = raw_reopen_abort,
     .bdrv_create        = hdev_create,
     .create_options     = raw_create_options,
     .bdrv_has_zero_init = hdev_has_zero_init,
@@ -1629,6 +1639,9 @@  static BlockDriver bdrv_host_cdrom = {
     .bdrv_probe_device	= cdrom_probe_device,
     .bdrv_file_open     = cdrom_open,
     .bdrv_close         = raw_close,
+    .bdrv_reopen_prepare = raw_reopen_prepare,
+    .bdrv_reopen_commit  = raw_reopen_commit,
+    .bdrv_reopen_abort   = raw_reopen_abort,
     .bdrv_create        = hdev_create,
     .create_options     = raw_create_options,
     .bdrv_has_zero_init = hdev_has_zero_init,
@@ -1748,6 +1761,9 @@  static BlockDriver bdrv_host_cdrom = {
     .bdrv_probe_device	= cdrom_probe_device,
     .bdrv_file_open     = cdrom_open,
     .bdrv_close         = raw_close,
+    .bdrv_reopen_prepare = raw_reopen_prepare,
+    .bdrv_reopen_commit  = raw_reopen_commit,
+    .bdrv_reopen_abort   = raw_reopen_abort,
     .bdrv_create        = hdev_create,
     .create_options     = raw_create_options,
     .bdrv_has_zero_init = hdev_has_zero_init,