[PATCH v3 6/6] qemuDomainBlockJobImpl: utilize blockJob condition

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

 



Instead of unlocking and locking the domain object every 50ms
lets just wait on blockJob condition and run the loop body if and
BLOCK_JOB even occurred.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---

This one, well, I still left the only monitor call as I'm not
very familiar with this code so I don't know if it can be more
optimized. But hey, the 50ms sleep is gone!

 src/qemu/qemu_driver.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 709f468..9298619 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -15872,10 +15872,6 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
             /* XXX If the event reports failure, we should reflect
              * that back into the return status of this API call.  */
             while (1) {
-                /* Poll every 50ms */
-                static struct timespec ts = {
-                    .tv_sec = 0,
-                    .tv_nsec = 50 * 1000 * 1000ull };
                 virDomainBlockJobInfo dummy;
 
                 qemuDomainObjEnterMonitor(driver, vm);
@@ -15886,11 +15882,12 @@ qemuDomainBlockJobImpl(virDomainObjPtr vm,
                 if (ret <= 0)
                     break;
 
-                virObjectUnlock(vm);
-
-                nanosleep(&ts, NULL);
-
-                virObjectLock(vm);
+                if (virCondWait(&priv->blockJob, &vm->parent.lock) < 0) {
+                    virReportSystemError(errno, "%s",
+                                         _("Unable to wait on blockJob condition"));
+                    ret = -1;
+                    break;
+                }
 
                 if (!virDomainObjIsActive(vm)) {
                     virReportError(VIR_ERR_OPERATION_INVALID, "%s",
-- 
2.0.5

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