qemu-commits
[Top][All Lists]
Advanced

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

[Qemu-commits] [qemu/qemu] 60efff: monitor: simplify functions for getti


From: Peter Maydell
Subject: [Qemu-commits] [qemu/qemu] 60efff: monitor: simplify functions for getting a dup'd fd...
Date: Thu, 17 Sep 2020 05:45:38 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 60efffa41b34cc299fed65b67e2c2641846d592b
      
https://github.com/qemu/qemu/commit/60efffa41b34cc299fed65b67e2c2641846d592b
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   2020-09-16 (Wed, 16 Sep 2020)

  Changed paths:
    M include/monitor/monitor.h
    M include/qemu/osdep.h
    M monitor/misc.c
    M stubs/fdset.c
    M util/osdep.c

  Log Message:
  -----------
  monitor: simplify functions for getting a dup'd fdset entry

Currently code has to call monitor_fdset_get_fd, then dup
the return fd, and then add the duplicate FD back into the
fdset. This dance is overly verbose for the caller and
introduces extra failure modes which can be avoided by
folding all the logic into monitor_fdset_dup_fd_add and
removing monitor_fdset_get_fd entirely.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>


  Commit: c2069ff624eda7f94bc118d7b5825bce29d7ca94
      
https://github.com/qemu/qemu/commit/c2069ff624eda7f94bc118d7b5825bce29d7ca94
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   2020-09-16 (Wed, 16 Sep 2020)

  Changed paths:
    M util/osdep.c

  Log Message:
  -----------
  util: split off a helper for dealing with O_CLOEXEC flag

We're going to have multiple callers to open() from qemu_open()
soon. Readability would thus benefit from having a helper for
dealing with O_CLOEXEC.

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>


  Commit: 448058aa99aaf30e7b8978508e575284a19fcfc9
      
https://github.com/qemu/qemu/commit/448058aa99aaf30e7b8978508e575284a19fcfc9
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   2020-09-16 (Wed, 16 Sep 2020)

  Changed paths:
    M accel/kvm/kvm-all.c
    M backends/rng-random.c
    M backends/tpm/tpm_passthrough.c
    M block/file-posix.c
    M block/file-win32.c
    M block/vvfat.c
    M chardev/char-fd.c
    M chardev/char-pipe.c
    M chardev/char.c
    M dump/dump.c
    M hw/s390x/s390-skeys.c
    M hw/usb/host-libusb.c
    M hw/usb/u2f-passthru.c
    M hw/vfio/common.c
    M include/qemu/osdep.h
    M io/channel-file.c
    M net/vhost-vdpa.c
    M os-posix.c
    M qga/channel-posix.c
    M qga/commands-posix.c
    M target/arm/kvm.c
    M ui/console.c
    M util/osdep.c
    M util/oslib-posix.c

  Log Message:
  -----------
  util: rename qemu_open() to qemu_open_old()

We want to introduce a new version of qemu_open() that uses an Error
object for reporting problems and make this it the preferred interface.
Rename the existing method to release the namespace for the new impl.

Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>


  Commit: bf93d2ade9008235fe2fbfd683458509ce53d6f7
      
https://github.com/qemu/qemu/commit/bf93d2ade9008235fe2fbfd683458509ce53d6f7
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   2020-09-16 (Wed, 16 Sep 2020)

  Changed paths:
    M util/osdep.c

  Log Message:
  -----------
  util: refactor qemu_open_old to split off variadic args handling

This simple refactoring prepares for future patches. The variadic args
handling is split from the main bulk of the open logic.

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>


  Commit: ebb3d49cb25b1f1d1b3e870ffdf7a05e02d28624
      
https://github.com/qemu/qemu/commit/ebb3d49cb25b1f1d1b3e870ffdf7a05e02d28624
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   2020-09-16 (Wed, 16 Sep 2020)

  Changed paths:
    M util/osdep.c

  Log Message:
  -----------
  util: add Error object for qemu_open_internal error reporting

Instead of relying on the limited information from errno, we can now
also provide detailed error messages to callers that ask for it.

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>


  Commit: c490af57cb451bf39707f4cc73650e81c5797221
      
https://github.com/qemu/qemu/commit/c490af57cb451bf39707f4cc73650e81c5797221
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   2020-09-16 (Wed, 16 Sep 2020)

  Changed paths:
    M include/qemu/osdep.h
    M util/osdep.c

  Log Message:
  -----------
  util: introduce qemu_open and qemu_create with error reporting

qemu_open_old() works like open(): set errno and return -1 on failure.
It has even more failure modes, though.  Reporting the error clearly
to users is basically impossible for many of them.

Our standard cure for "errno is too coarse" is the Error object.
Introduce two new helper methods:

  int qemu_open(const char *name, int flags, Error **errp);
  int qemu_create(const char *name, int flags, mode_t mode, Error **errp);

Note that with this design we no longer require or even accept the
O_CREAT flag. Avoiding overloading the two distinct operations
means we can avoid variable arguments which would prevent 'errp' from
being the last argument. It also gives us a guarantee that the 'mode' is
given when creating files, avoiding a latent security bug.

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>


  Commit: 661b3e81a336570dfbf4c224595921d490ac792f
      
https://github.com/qemu/qemu/commit/661b3e81a336570dfbf4c224595921d490ac792f
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   2020-09-16 (Wed, 16 Sep 2020)

  Changed paths:
    M util/osdep.c

  Log Message:
  -----------
  util: give a specific error message when O_DIRECT doesn't work

A common error scenario is to tell QEMU to use O_DIRECT in combination
with a filesystem that doesn't support it. To aid users to diagnosing
their mistake we want to provide a clear error message when this happens.

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>


  Commit: b18a24a9f889bcf722754046130507d744a1b0b9
      
https://github.com/qemu/qemu/commit/b18a24a9f889bcf722754046130507d744a1b0b9
  Author: Daniel P. Berrangé <berrange@redhat.com>
  Date:   2020-09-16 (Wed, 16 Sep 2020)

  Changed paths:
    M block/file-posix.c
    M block/file-win32.c

  Log Message:
  -----------
  block/file: switch to use qemu_open/qemu_create for improved errors

Currently at startup if using cache=none on a filesystem lacking
O_DIRECT such as tmpfs, at startup QEMU prints

qemu-system-x86_64: -drive file=/tmp/foo.img,cache=none: file system may not 
support O_DIRECT
qemu-system-x86_64: -drive file=/tmp/foo.img,cache=none: Could not open 
'/tmp/foo.img': Invalid argument

while at QMP level the hint is missing, so QEMU reports just

  "error": {
      "class": "GenericError",
      "desc": "Could not open '/tmp/foo.img': Invalid argument"
  }

which is close to useless for the end user trying to figure out what
they did wrong.

With this change at startup QEMU prints

qemu-system-x86_64: -drive file=/tmp/foo.img,cache=none: Unable to open 
'/tmp/foo.img': filesystem does not support O_DIRECT

while at the QMP level QEMU reports a massively more informative

  "error": {
     "class": "GenericError",
     "desc": "Unable to open '/tmp/foo.img': filesystem does not support 
O_DIRECT"
  }

Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>


  Commit: 525009d04fa49567b0eba43f9ff3c17e560dabb7
      
https://github.com/qemu/qemu/commit/525009d04fa49567b0eba43f9ff3c17e560dabb7
  Author: Peter Maydell <peter.maydell@linaro.org>
  Date:   2020-09-16 (Wed, 16 Sep 2020)

  Changed paths:
    M accel/kvm/kvm-all.c
    M backends/rng-random.c
    M backends/tpm/tpm_passthrough.c
    M block/file-posix.c
    M block/file-win32.c
    M block/vvfat.c
    M chardev/char-fd.c
    M chardev/char-pipe.c
    M chardev/char.c
    M dump/dump.c
    M hw/s390x/s390-skeys.c
    M hw/usb/host-libusb.c
    M hw/usb/u2f-passthru.c
    M hw/vfio/common.c
    M include/monitor/monitor.h
    M include/qemu/osdep.h
    M io/channel-file.c
    M monitor/misc.c
    M net/vhost-vdpa.c
    M os-posix.c
    M qga/channel-posix.c
    M qga/commands-posix.c
    M stubs/fdset.c
    M target/arm/kvm.c
    M ui/console.c
    M util/osdep.c
    M util/oslib-posix.c

  Log Message:
  -----------
  Merge remote-tracking branch 
'remotes/berrange/tags/block-odirect-pull-request' into staging

block: improve error reporting for unsupported O_DIRECT

# gpg: Signature made Wed 16 Sep 2020 10:45:48 BST
# gpg:                using RSA key DAF3A6FDB26B62912D0E8E3FBE86EBB415104FDF
# gpg: Good signature from "Daniel P. Berrange <dan@berrange.com>" [full]
# gpg:                 aka "Daniel P. Berrange <berrange@redhat.com>" [full]
# Primary key fingerprint: DAF3 A6FD B26B 6291 2D0E  8E3F BE86 EBB4 1510 4FDF

* remotes/berrange/tags/block-odirect-pull-request:
  block/file: switch to use qemu_open/qemu_create for improved errors
  util: give a specific error message when O_DIRECT doesn't work
  util: introduce qemu_open and qemu_create with error reporting
  util: add Error object for qemu_open_internal error reporting
  util: refactor qemu_open_old to split off variadic args handling
  util: rename qemu_open() to qemu_open_old()
  util: split off a helper for dealing with O_CLOEXEC flag
  monitor: simplify functions for getting a dup'd fdset entry

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>


Compare: https://github.com/qemu/qemu/compare/8ee612722dc0...525009d04fa4



reply via email to

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