[PATCH 0/2] adding virHas/GetLastErrorCode/Domain to paritally replace virGetLastError

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

 



Many places in the code call virGetLastError() just to check the
raised error code, or domain. However virGetLastError() can return
NULL, so the code has to check for that as well.

So Instead we create functions virGetLastErrorCode and virGetLastErrorDomain
(in addition to the existing virGetLastErrorMessage) that always return a
valid error code/domain/message, to simplify callers.

Also created virHasLastErrorCode for completion

This is my first commit, for:
https://wiki.libvirt.org/page/BiteSizedTasks#Add_and_use_virGetLastErrorCode.28.29

Notes:
* There are a few instances of virGetLastErrorCode() left where we use multiple
fields from the error, which makes sense to keep it.
* I didn't manage to use virGetLastErrorDomain() (due to the above) so I'm inclined
to remove it.
* virHasLastError is more or less only a semantic improvement over virGetLastError,
so I'm happy to revert it if needed

Signed-off-by: Ramy Elkest <ramyelkest@xxxxxxxxx>


ramyelkest (2):
  util: adding virHasLastError and virGetLastErrorCode/Domain
  all: replacing virGetLastError with virHas/GetLastErrorCode/Domain

 include/libvirt/virterror.h     |  3 ++
 src/libvirt_public.syms         |  7 +++++
 src/locking/lock_driver_lockd.c |  3 +-
 src/lxc/lxc_controller.c        |  4 +--
 src/qemu/qemu_agent.c           |  3 +-
 src/qemu/qemu_conf.c            |  3 +-
 src/qemu/qemu_domain.c          |  2 +-
 src/qemu/qemu_driver.c          | 12 ++++----
 src/qemu/qemu_hotplug.c         |  2 +-
 src/qemu/qemu_migration.c       |  4 +--
 src/qemu/qemu_monitor.c         |  5 ++--
 src/qemu/qemu_monitor_json.c    |  2 +-
 src/qemu/qemu_process.c         |  2 +-
 src/remote/remote_driver.c      |  3 +-
 src/rpc/virnetclient.c          |  2 +-
 src/util/virerror.c             | 63 +++++++++++++++++++++++++++++++++++++++++
 src/util/virfilecache.c         |  3 +-
 src/util/virxml.c               |  4 +--
 tests/commandtest.c             |  2 +-
 tests/testutils.c               |  6 ++--
 tests/virhostcputest.c          |  2 +-
 tests/virstoragetest.c          |  8 +++---
 tools/virsh-domain-monitor.c    |  7 ++---
 tools/virsh-domain.c            |  4 +--
 tools/virsh-util.c              |  3 +-
 tools/vsh.c                     |  2 +-
 26 files changed, 110 insertions(+), 51 deletions(-)

-- 
2.7.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux