mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 01:03:55 -06:00
Block layer patches
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAABAgAGBQJZFHXJAAoJEH8JsnLIjy/WvdsP/3mTGDZJO4M0HXWBWYQBwdGE EuMyGxn8Y0IUIBNx8sogAY9yQ/aQUh1b3bLWg7MAvZvQpi2S448Ak/2agaRFTWXJ vVv1nP0uigfgElSZZKTyj2SyhghrGkBou98hyYOd05YAApXmxoBKvTgC1di0Ec5K 86Mc91Cr3udh4Q5w5Ss2IxiN+fNoHhHdOOm8gkWM4iQl6fmDJ8lBBxoiU+K2uXX+ /flAVRgogFglKb0EAq8eSdy4qFRyp1G43yzOJKNiM3BuYeXpipnyO5mY3ynrEv5Y 3213hJ/rriY15xHcKtkPxEqd32iX2qCRGFXWMMiq4r527JG/B40SEJQaxfHu33U2 Et3+0MxoDHFseXE2sSjs8c0DKQiU5/hf7RkzqOMPMNluIX4ykrSyOdKzj4EFEowr GGLobm4Hr/rv8YDhRhllyKZ6Xzrjihy5WH5T9+HVfOlf35AxjJGZYqfCouhCiP15 0Nxz3qWfDH/U4zvhY+PIfQ51kvGl02oMZF6uu48kvzwdbIKgnImKg5HbG5R85mYQ BFqCjaEWjSUWxrqbZ/uRBUqavCLJm9C3mEWLCzGBmXNNs4Th8kXftuo1br+QHtr5 aT7xoxUJs/nmBoCKYhlCSrxjqCa0clenvNeiO4Q44UxWmOFQi9SM5myeSuCIaa+S qnYHZLZ74gVZpQaoPkjE =SA0O -----END PGP SIGNATURE----- Merge remote-tracking branch 'kwolf/tags/for-upstream' into staging Block layer patches # gpg: Signature made Thu 11 May 2017 10:31:37 AM EDT # gpg: using RSA key 0x7F09B272C88F2FD6 # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" # Primary key fingerprint: DC3D EB15 9A9A F95D 3D74 56FE 7F09 B272 C88F 2FD6 * kwolf/tags/for-upstream: (58 commits) MAINTAINERS: Add qemu-progress to the block layer qcow2: Discard/zero clusters by byte count qcow2: Assert that cluster operations are aligned qcow2: Optimize write zero of unaligned tail cluster iotests: Add test 179 to cover write zeroes with unmap iotests: Improve _filter_qemu_img_map qcow2: Optimize zero_single_l2() to minimize L2 churn qcow2: Make distinction between zero cluster types obvious qcow2: Name typedef for cluster type qcow2: Correctly report status of preallocated zero clusters block: Update comments on BDRV_BLOCK_* meanings qcow2: Use consistent switch indentation qcow2: Nicer variable names in qcow2_update_snapshot_refcount() tests: Add coverage for recent block geometry fixes blkdebug: Add ability to override unmap geometries blkdebug: Simplify override logic blkdebug: Add pass-through write_zero and discard support blkdebug: Refactor error injection blkdebug: Sanity check block layer guarantees qemu-io: Switch 'map' output to byte-based reporting ... Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
commit
3753e255da
62 changed files with 3092 additions and 616 deletions
48
util/osdep.c
48
util/osdep.c
|
@ -38,6 +38,14 @@ extern int madvise(caddr_t, size_t, int);
|
|||
#include "qemu/error-report.h"
|
||||
#include "monitor/monitor.h"
|
||||
|
||||
#ifdef F_OFD_SETLK
|
||||
#define QEMU_SETLK F_OFD_SETLK
|
||||
#define QEMU_GETLK F_OFD_GETLK
|
||||
#else
|
||||
#define QEMU_SETLK F_SETLK
|
||||
#define QEMU_GETLK F_GETLK
|
||||
#endif
|
||||
|
||||
static bool fips_enabled = false;
|
||||
|
||||
static const char *hw_version = QEMU_HW_VERSION;
|
||||
|
@ -140,6 +148,46 @@ static int qemu_parse_fdset(const char *param)
|
|||
{
|
||||
return qemu_parse_fd(param);
|
||||
}
|
||||
|
||||
static int qemu_lock_fcntl(int fd, int64_t start, int64_t len, int fl_type)
|
||||
{
|
||||
int ret;
|
||||
struct flock fl = {
|
||||
.l_whence = SEEK_SET,
|
||||
.l_start = start,
|
||||
.l_len = len,
|
||||
.l_type = fl_type,
|
||||
};
|
||||
ret = fcntl(fd, QEMU_SETLK, &fl);
|
||||
return ret == -1 ? -errno : 0;
|
||||
}
|
||||
|
||||
int qemu_lock_fd(int fd, int64_t start, int64_t len, bool exclusive)
|
||||
{
|
||||
return qemu_lock_fcntl(fd, start, len, exclusive ? F_WRLCK : F_RDLCK);
|
||||
}
|
||||
|
||||
int qemu_unlock_fd(int fd, int64_t start, int64_t len)
|
||||
{
|
||||
return qemu_lock_fcntl(fd, start, len, F_UNLCK);
|
||||
}
|
||||
|
||||
int qemu_lock_fd_test(int fd, int64_t start, int64_t len, bool exclusive)
|
||||
{
|
||||
int ret;
|
||||
struct flock fl = {
|
||||
.l_whence = SEEK_SET,
|
||||
.l_start = start,
|
||||
.l_len = len,
|
||||
.l_type = exclusive ? F_WRLCK : F_RDLCK,
|
||||
};
|
||||
ret = fcntl(fd, QEMU_GETLK, &fl);
|
||||
if (ret == -1) {
|
||||
return -errno;
|
||||
} else {
|
||||
return fl.l_type == F_UNLCK ? 0 : -EAGAIN;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue