[PATCH 0/6] virObject for reference-counting

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

 



This series adds a virObject structure that manages reference-counting.

Some notes about referece-counting introduced by this series:

A thread owns a virObject by incrementing its reference-count by 1.
If a thread owns a virObject, the virObject is guarenteed not be
freed until the thread releases ownership by decrementing its
reference-count by 1. A thread can't access a virObject after it
releases the ownership of virObject because it can be freed at
anytime.

A thread can own a virObject legally in these ways:

- a thread owns a virObject that it creates.
- a thread owns a virObject if another thread passes the ownership
  to it. Example: qemuMonitorOpen
- a thread gets a virObject from a container.
  Example: virDomainFindByUUID
- a container owns a virObject by incrementing its reference-count
  by 1 before adding it to the container
- if a virObject is removed from a container its reference-count
  must be decremented by 1

By following these rules, there is no need to protect operations on
an object's reference-count by an external lock. (like in old ways
virDomainObj lock protects qemu monitor's ref-count.)

This series is a draft and posted for early review. Any comments are
welcome.

Hu Tao (6):
  Add virObject and virAtomic.
  use virObject to manage reference-count of qemud_client
  use virObject to manage reference-count of virDomainObj
  qemu: use virObject to manages reference-counting for qemu monitor
  remove qemuDomainObjEnterMonitorWithDriver and
    qemuDomainObjExitMonitorWithDriver
  remove qemuDomainObjBeginJobWithDriver

 daemon/dispatch.c         |    2 -
 daemon/libvirtd.c         |   62 ++++++--
 daemon/libvirtd.h         |    5 +-
 src/Makefile.am           |    2 +
 src/conf/domain_conf.c    |   56 ++++----
 src/conf/domain_conf.h    |    6 +-
 src/libvirt_private.syms  |    5 +
 src/openvz/openvz_conf.c  |    8 +-
 src/qemu/qemu_domain.c    |  121 +--------------
 src/qemu/qemu_domain.h    |    8 +-
 src/qemu/qemu_driver.c    |  358 ++++++++++++++++++++-------------------------
 src/qemu/qemu_hotplug.c   |   90 ++++++------
 src/qemu/qemu_migration.c |  101 ++++++-------
 src/qemu/qemu_monitor.c   |  109 ++++++++-------
 src/qemu/qemu_monitor.h   |    4 +-
 src/qemu/qemu_process.c   |   99 ++++++-------
 src/util/viratomic.c      |   46 ++++++
 src/util/viratomic.h      |   30 ++++
 src/util/virobject.c      |   52 +++++++
 src/util/virobject.h      |   39 +++++
 src/vmware/vmware_conf.c  |    2 +-
 21 files changed, 628 insertions(+), 577 deletions(-)
 create mode 100644 src/util/viratomic.c
 create mode 100644 src/util/viratomic.h
 create mode 100644 src/util/virobject.c
 create mode 100644 src/util/virobject.h

-- 
1.7.3.1

--
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]