[libvirt] [PATCH v4 16/23] security_manager: Introduce metadata locking APIs
Bjoern Walk
bwalk at linux.ibm.com
Mon Sep 10 12:19:20 UTC 2018
Michal Privoznik <mprivozn at redhat.com> [2018-09-10, 11:36AM +0200]:
> +int
> +virSecurityManagerMetadataLock(virSecurityManagerPtr mgr,
> + const char * const *paths,
> + size_t npaths)
> +{
> + virLockManagerPtr lock;
> + virTimeBackOffVar timebackoff;
> + int fd = -1;
> + int rv;
gcc complains that rv might be uninitialized.
> + int ret = -1;
> +
> + virMutexLock(&lockManagerMutex);
> +
> + if (!(lock = virSecurityManagerNewLockManager(mgr, paths, npaths)))
> + goto cleanup;
> +
> + if (virTimeBackOffStart(&timebackoff, 1, LOCK_ACQUIRE_TIMEOUT * 1000) < 0)
> + goto cleanup;
> + while (virTimeBackOffWait(&timebackoff)) {
> + rv = virLockManagerAcquire(lock, NULL,
> + VIR_LOCK_MANAGER_ACQUIRE_ROLLBACK,
> + VIR_DOMAIN_LOCK_FAILURE_DEFAULT, &fd);
> +
> + if (rv >= 0)
> + break;
> +
> + if (virGetLastErrorCode() == VIR_ERR_RESOURCE_BUSY)
> + continue;
> +
> + goto cleanup;
> + }
> +
> + if (rv < 0)
> + goto cleanup;
> +
> + mgr->fd = fd;
> + fd = -1;
> +
> + ret = 0;
> + cleanup:
> + virLockManagerFree(lock);
> + VIR_FORCE_CLOSE(fd);
> + if (ret < 0)
> + virMutexUnlock(&lockManagerMutex);
> + return ret;
> +}
--
IBM Systems
Linux on Z & Virtualization Development
------------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Schönaicher Str. 220, 71032 Böblingen
Phone: +49 7031 16 1819
------------------------------------------------------------------------
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 902 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180910/855218bb/attachment-0001.sig>
More information about the libvir-list
mailing list