diff mbox series

[14/14] block: remove support for using "file" driver with block/char devices

Message ID 20210224131142.1952027-15-berrange@redhat.com (mailing list archive)
State New, archived
Headers show
Series deprecations: remove many old deprecations | expand

Commit Message

Daniel P. Berrangé Feb. 24, 2021, 1:11 p.m. UTC
The 'host_device' and 'host_cdrom' drivers must be used instead.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 block/file-posix.c               | 17 ++++++-----------
 docs/system/deprecated.rst       |  7 -------
 docs/system/removed-features.rst |  7 +++++++
 tests/qemu-iotests/226.out       | 10 +++++-----
 4 files changed, 18 insertions(+), 23 deletions(-)

Comments

Daniel P. Berrangé March 15, 2021, 11:56 a.m. UTC | #1
Ping for anyone, especially block maintainers, willing to review this
before soft freeze.

On Wed, Feb 24, 2021 at 01:11:42PM +0000, Daniel P. Berrangé wrote:
> The 'host_device' and 'host_cdrom' drivers must be used instead.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  block/file-posix.c               | 17 ++++++-----------
>  docs/system/deprecated.rst       |  7 -------
>  docs/system/removed-features.rst |  7 +++++++
>  tests/qemu-iotests/226.out       | 10 +++++-----
>  4 files changed, 18 insertions(+), 23 deletions(-)
> 
> diff --git a/block/file-posix.c b/block/file-posix.c
> index 05079b40ca..20e14f8e96 100644
> --- a/block/file-posix.c
> +++ b/block/file-posix.c
> @@ -719,15 +719,9 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
>      }
>  
>      if (!device) {
> -        if (S_ISBLK(st.st_mode)) {
> -            warn_report("Opening a block device as a file using the '%s' "
> -                        "driver is deprecated", bs->drv->format_name);
> -        } else if (S_ISCHR(st.st_mode)) {
> -            warn_report("Opening a character device as a file using the '%s' "
> -                        "driver is deprecated", bs->drv->format_name);
> -        } else if (!S_ISREG(st.st_mode)) {
> -            error_setg(errp, "A regular file was expected by the '%s' driver, "
> -                       "but something else was given", bs->drv->format_name);
> +        if (!S_ISREG(st.st_mode)) {
> +            error_setg(errp, "'%s' driver requires '%s' to be a regular file",
> +                       bs->drv->format_name, bs->filename);
>              ret = -EINVAL;
>              goto fail;
>          } else {
> @@ -736,8 +730,9 @@ static int raw_open_common(BlockDriverState *bs, QDict *options,
>          }
>      } else {
>          if (!(S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))) {
> -            error_setg(errp, "'%s' driver expects either "
> -                       "a character or block device", bs->drv->format_name);
> +            error_setg(errp, "'%s' driver requires '%s' to be either "
> +                       "a character or block device",
> +                       bs->drv->format_name, bs->filename);
>              ret = -EINVAL;
>              goto fail;
>          }
> diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
> index dc76584e02..3a86deb450 100644
> --- a/docs/system/deprecated.rst
> +++ b/docs/system/deprecated.rst
> @@ -21,13 +21,6 @@ deprecated.
>  System emulator command line arguments
>  --------------------------------------
>  
> -``-drive file=json:{...{'driver':'file'}}`` (since 3.0)
> -'''''''''''''''''''''''''''''''''''''''''''''''''''''''
> -
> -The 'file' driver for drives is no longer appropriate for character or host
> -devices and will only accept regular files (S_IFREG). The correct driver
> -for these file types is 'host_cdrom' or 'host_device' as appropriate.
> -
>  ``QEMU_AUDIO_`` environment variables and ``-audio-help`` (since 4.0)
>  '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>  
> diff --git a/docs/system/removed-features.rst b/docs/system/removed-features.rst
> index 990bf7e015..1c9e384cb0 100644
> --- a/docs/system/removed-features.rst
> +++ b/docs/system/removed-features.rst
> @@ -59,6 +59,13 @@ would automatically enable USB support on the machine type.
>  When using the new syntax, USB support must be explicitly
>  enabled via the ``-machine usb=on`` argument.
>  
> +``-drive file=json:{...{'driver':'file'}}`` (removed 6.0)
> +'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> +
> +The 'file' driver for drives is no longer appropriate for character or host
> +devices and will only accept regular files (S_IFREG). The correct driver
> +for these file types is 'host_cdrom' or 'host_device' as appropriate.
> +
>  QEMU Machine Protocol (QMP) commands
>  ------------------------------------
>  
> diff --git a/tests/qemu-iotests/226.out b/tests/qemu-iotests/226.out
> index 42be973ff2..55504d29c4 100644
> --- a/tests/qemu-iotests/226.out
> +++ b/tests/qemu-iotests/226.out
> @@ -3,23 +3,23 @@ QA output created by 226
>  === Testing with driver:file ===
>  
>  == Testing RO ==
> -qemu-io: can't open: A regular file was expected by the 'file' driver, but something else was given
> -qemu-io: warning: Opening a character device as a file using the 'file' driver is deprecated
> +qemu-io: can't open: 'file' driver requires 'TEST_DIR/t.IMGFMT' to be a regular file
> +qemu-io: can't open: 'file' driver requires '/dev/null' to be a regular file
>  == Testing RW ==
>  qemu-io: can't open: Could not open 'TEST_DIR/t.IMGFMT': Is a directory
> -qemu-io: warning: Opening a character device as a file using the 'file' driver is deprecated
> +qemu-io: can't open: 'file' driver requires '/dev/null' to be a regular file
>  
>  === Testing with driver:host_device ===
>  
>  == Testing RO ==
> -qemu-io: can't open: 'host_device' driver expects either a character or block device
> +qemu-io: can't open: 'host_device' driver requires 'TEST_DIR/t.IMGFMT' to be either a character or block device
>  == Testing RW ==
>  qemu-io: can't open: Could not open 'TEST_DIR/t.IMGFMT': Is a directory
>  
>  === Testing with driver:host_cdrom ===
>  
>  == Testing RO ==
> -qemu-io: can't open: 'host_cdrom' driver expects either a character or block device
> +qemu-io: can't open: 'host_cdrom' driver requires 'TEST_DIR/t.IMGFMT' to be either a character or block device
>  == Testing RW ==
>  qemu-io: can't open: Could not open 'TEST_DIR/t.IMGFMT': Is a directory
>  
> -- 
> 2.29.2
> 

Regards,
Daniel
Eric Blake March 15, 2021, 12:04 p.m. UTC | #2
On 2/24/21 7:11 AM, Daniel P. Berrangé wrote:
> The 'host_device' and 'host_cdrom' drivers must be used instead.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  block/file-posix.c               | 17 ++++++-----------
>  docs/system/deprecated.rst       |  7 -------
>  docs/system/removed-features.rst |  7 +++++++
>  tests/qemu-iotests/226.out       | 10 +++++-----
>  4 files changed, 18 insertions(+), 23 deletions(-)
> 

>      if (!device) {
> -        if (S_ISBLK(st.st_mode)) {
> -            warn_report("Opening a block device as a file using the '%s' "
> -                        "driver is deprecated", bs->drv->format_name);
> -        } else if (S_ISCHR(st.st_mode)) {
> -            warn_report("Opening a character device as a file using the '%s' "
> -                        "driver is deprecated", bs->drv->format_name);
> -        } else if (!S_ISREG(st.st_mode)) {
> -            error_setg(errp, "A regular file was expected by the '%s' driver, "
> -                       "but something else was given", bs->drv->format_name);
> +        if (!S_ISREG(st.st_mode)) {

We're testing with S_ISREG()...


> +++ b/docs/system/deprecated.rst
> @@ -21,13 +21,6 @@ deprecated.
>  System emulator command line arguments
>  --------------------------------------
>  
> -``-drive file=json:{...{'driver':'file'}}`` (since 3.0)
> -'''''''''''''''''''''''''''''''''''''''''''''''''''''''
> -
> -The 'file' driver for drives is no longer appropriate for character or host
> -devices and will only accept regular files (S_IFREG). The correct driver

but documented with S_IFREG().  Thankfully, the two have semantically
equivalent purposes, so the difference doesn't invalidate the docs.

Reviewed-by: Eric Blake <eblake@redhat.com>

but I wouldn't mind if at least one other block maintainer chimes in.
diff mbox series

Patch

diff --git a/block/file-posix.c b/block/file-posix.c
index 05079b40ca..20e14f8e96 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -719,15 +719,9 @@  static int raw_open_common(BlockDriverState *bs, QDict *options,
     }
 
     if (!device) {
-        if (S_ISBLK(st.st_mode)) {
-            warn_report("Opening a block device as a file using the '%s' "
-                        "driver is deprecated", bs->drv->format_name);
-        } else if (S_ISCHR(st.st_mode)) {
-            warn_report("Opening a character device as a file using the '%s' "
-                        "driver is deprecated", bs->drv->format_name);
-        } else if (!S_ISREG(st.st_mode)) {
-            error_setg(errp, "A regular file was expected by the '%s' driver, "
-                       "but something else was given", bs->drv->format_name);
+        if (!S_ISREG(st.st_mode)) {
+            error_setg(errp, "'%s' driver requires '%s' to be a regular file",
+                       bs->drv->format_name, bs->filename);
             ret = -EINVAL;
             goto fail;
         } else {
@@ -736,8 +730,9 @@  static int raw_open_common(BlockDriverState *bs, QDict *options,
         }
     } else {
         if (!(S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))) {
-            error_setg(errp, "'%s' driver expects either "
-                       "a character or block device", bs->drv->format_name);
+            error_setg(errp, "'%s' driver requires '%s' to be either "
+                       "a character or block device",
+                       bs->drv->format_name, bs->filename);
             ret = -EINVAL;
             goto fail;
         }
diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst
index dc76584e02..3a86deb450 100644
--- a/docs/system/deprecated.rst
+++ b/docs/system/deprecated.rst
@@ -21,13 +21,6 @@  deprecated.
 System emulator command line arguments
 --------------------------------------
 
-``-drive file=json:{...{'driver':'file'}}`` (since 3.0)
-'''''''''''''''''''''''''''''''''''''''''''''''''''''''
-
-The 'file' driver for drives is no longer appropriate for character or host
-devices and will only accept regular files (S_IFREG). The correct driver
-for these file types is 'host_cdrom' or 'host_device' as appropriate.
-
 ``QEMU_AUDIO_`` environment variables and ``-audio-help`` (since 4.0)
 '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
 
diff --git a/docs/system/removed-features.rst b/docs/system/removed-features.rst
index 990bf7e015..1c9e384cb0 100644
--- a/docs/system/removed-features.rst
+++ b/docs/system/removed-features.rst
@@ -59,6 +59,13 @@  would automatically enable USB support on the machine type.
 When using the new syntax, USB support must be explicitly
 enabled via the ``-machine usb=on`` argument.
 
+``-drive file=json:{...{'driver':'file'}}`` (removed 6.0)
+'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
+
+The 'file' driver for drives is no longer appropriate for character or host
+devices and will only accept regular files (S_IFREG). The correct driver
+for these file types is 'host_cdrom' or 'host_device' as appropriate.
+
 QEMU Machine Protocol (QMP) commands
 ------------------------------------
 
diff --git a/tests/qemu-iotests/226.out b/tests/qemu-iotests/226.out
index 42be973ff2..55504d29c4 100644
--- a/tests/qemu-iotests/226.out
+++ b/tests/qemu-iotests/226.out
@@ -3,23 +3,23 @@  QA output created by 226
 === Testing with driver:file ===
 
 == Testing RO ==
-qemu-io: can't open: A regular file was expected by the 'file' driver, but something else was given
-qemu-io: warning: Opening a character device as a file using the 'file' driver is deprecated
+qemu-io: can't open: 'file' driver requires 'TEST_DIR/t.IMGFMT' to be a regular file
+qemu-io: can't open: 'file' driver requires '/dev/null' to be a regular file
 == Testing RW ==
 qemu-io: can't open: Could not open 'TEST_DIR/t.IMGFMT': Is a directory
-qemu-io: warning: Opening a character device as a file using the 'file' driver is deprecated
+qemu-io: can't open: 'file' driver requires '/dev/null' to be a regular file
 
 === Testing with driver:host_device ===
 
 == Testing RO ==
-qemu-io: can't open: 'host_device' driver expects either a character or block device
+qemu-io: can't open: 'host_device' driver requires 'TEST_DIR/t.IMGFMT' to be either a character or block device
 == Testing RW ==
 qemu-io: can't open: Could not open 'TEST_DIR/t.IMGFMT': Is a directory
 
 === Testing with driver:host_cdrom ===
 
 == Testing RO ==
-qemu-io: can't open: 'host_cdrom' driver expects either a character or block device
+qemu-io: can't open: 'host_cdrom' driver requires 'TEST_DIR/t.IMGFMT' to be either a character or block device
 == Testing RW ==
 qemu-io: can't open: Could not open 'TEST_DIR/t.IMGFMT': Is a directory