Block patches for qemu 2.8

-----BEGIN PGP SIGNATURE-----
 
 iQEvBAABCAAZBQJYJdw7EhxtcmVpdHpAcmVkaGF0LmNvbQAKCRD0B9sAYdXPQDaQ
 B/4xLnht9qMPknYsUXZAlCr0hw7zJCla63t4FG8xIK6oMUNteWWPabPhRunR0rLS
 7LPceqeyK1M7klDY+M+stW6ofpcPAEFIdyT1O/t2MId6yFXxskWCZxeQMWxK3Uz5
 36m4ys6AnMx+cs0eUMrQxH3oLGNeE2l+ahZwFY0GXqXO7qIdNpOccNAm79tKxF1i
 eVHirr/BqqP2l2U5lVHFrYkbJQ+Ff4IUJO5hkj7FUk25937SnUg3qMGI/diRh2K0
 sVh6PYt8R6i6Zw3NxkzF2VDGUQpxVQfWkVAMhxKn1AKftkd7Vn+UAApdbChXANBJ
 LOrrwKFNzTBBtwqhGUGQ/Pzp
 =Kqth
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'mreitz/tags/pull-block-2016-11-11' into queue-block

Block patches for qemu 2.8

# gpg: Signature made Fri Nov 11 15:56:59 2016 CET
# gpg:                using RSA key 0xF407DB0061D5CF40
# gpg: Good signature from "Max Reitz <mreitz@redhat.com>"
# Primary key fingerprint: 91BE B60A 30DB 3E88 57D1  1829 F407 DB00 61D5 CF40

* mreitz/tags/pull-block-2016-11-11:
  raw-posix: Rename 'raw_s' to 'rs'
  iotests: Always use -machine accel=qtest
  iotests: Skip test 162 if there is no SSH support
  block: Emit modules in bdrv_iterate_format()
  block: Fix bdrv_iterate_format() sorting

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Kevin Wolf 2016-11-11 15:58:12 +01:00
commit ff569b9424
5 changed files with 56 additions and 37 deletions

20
block.c
View File

@ -2796,7 +2796,7 @@ const char *bdrv_get_format_name(BlockDriverState *bs)
static int qsort_strcmp(const void *a, const void *b) static int qsort_strcmp(const void *a, const void *b)
{ {
return strcmp(a, b); return strcmp(*(char *const *)a, *(char *const *)b);
} }
void bdrv_iterate_format(void (*it)(void *opaque, const char *name), void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
@ -2822,6 +2822,24 @@ void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
} }
} }
for (i = 0; i < (int)ARRAY_SIZE(block_driver_modules); i++) {
const char *format_name = block_driver_modules[i].format_name;
if (format_name) {
bool found = false;
int j = count;
while (formats && j && !found) {
found = !strcmp(formats[--j], format_name);
}
if (!found) {
formats = g_renew(const char *, formats, count + 1);
formats[count++] = format_name;
}
}
}
qsort(formats, count, sizeof(formats[0]), qsort_strcmp); qsort(formats, count, sizeof(formats[0]), qsort_strcmp);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {

View File

@ -542,7 +542,7 @@ static int raw_reopen_prepare(BDRVReopenState *state,
BlockReopenQueue *queue, Error **errp) BlockReopenQueue *queue, Error **errp)
{ {
BDRVRawState *s; BDRVRawState *s;
BDRVRawReopenState *raw_s; BDRVRawReopenState *rs;
int ret = 0; int ret = 0;
Error *local_err = NULL; Error *local_err = NULL;
@ -552,15 +552,15 @@ static int raw_reopen_prepare(BDRVReopenState *state,
s = state->bs->opaque; s = state->bs->opaque;
state->opaque = g_new0(BDRVRawReopenState, 1); state->opaque = g_new0(BDRVRawReopenState, 1);
raw_s = state->opaque; rs = state->opaque;
if (s->type == FTYPE_CD) { if (s->type == FTYPE_CD) {
raw_s->open_flags |= O_NONBLOCK; rs->open_flags |= O_NONBLOCK;
} }
raw_parse_flags(state->flags, &raw_s->open_flags); raw_parse_flags(state->flags, &rs->open_flags);
raw_s->fd = -1; rs->fd = -1;
int fcntl_flags = O_APPEND | O_NONBLOCK; int fcntl_flags = O_APPEND | O_NONBLOCK;
#ifdef O_NOATIME #ifdef O_NOATIME
@ -569,35 +569,35 @@ static int raw_reopen_prepare(BDRVReopenState *state,
#ifdef O_ASYNC #ifdef O_ASYNC
/* Not all operating systems have O_ASYNC, and those that don't /* Not all operating systems have O_ASYNC, and those that don't
* will not let us track the state into raw_s->open_flags (typically * will not let us track the state into rs->open_flags (typically
* you achieve the same effect with an ioctl, for example I_SETSIG * you achieve the same effect with an ioctl, for example I_SETSIG
* on Solaris). But we do not use O_ASYNC, so that's fine. * on Solaris). But we do not use O_ASYNC, so that's fine.
*/ */
assert((s->open_flags & O_ASYNC) == 0); assert((s->open_flags & O_ASYNC) == 0);
#endif #endif
if ((raw_s->open_flags & ~fcntl_flags) == (s->open_flags & ~fcntl_flags)) { if ((rs->open_flags & ~fcntl_flags) == (s->open_flags & ~fcntl_flags)) {
/* dup the original fd */ /* dup the original fd */
raw_s->fd = qemu_dup(s->fd); rs->fd = qemu_dup(s->fd);
if (raw_s->fd >= 0) { if (rs->fd >= 0) {
ret = fcntl_setfl(raw_s->fd, raw_s->open_flags); ret = fcntl_setfl(rs->fd, rs->open_flags);
if (ret) { if (ret) {
qemu_close(raw_s->fd); qemu_close(rs->fd);
raw_s->fd = -1; rs->fd = -1;
} }
} }
} }
/* If we cannot use fcntl, or fcntl failed, fall back to qemu_open() */ /* If we cannot use fcntl, or fcntl failed, fall back to qemu_open() */
if (raw_s->fd == -1) { if (rs->fd == -1) {
const char *normalized_filename = state->bs->filename; const char *normalized_filename = state->bs->filename;
ret = raw_normalize_devicepath(&normalized_filename); ret = raw_normalize_devicepath(&normalized_filename);
if (ret < 0) { if (ret < 0) {
error_setg_errno(errp, -ret, "Could not normalize device path"); error_setg_errno(errp, -ret, "Could not normalize device path");
} else { } else {
assert(!(raw_s->open_flags & O_CREAT)); assert(!(rs->open_flags & O_CREAT));
raw_s->fd = qemu_open(normalized_filename, raw_s->open_flags); rs->fd = qemu_open(normalized_filename, rs->open_flags);
if (raw_s->fd == -1) { if (rs->fd == -1) {
error_setg_errno(errp, errno, "Could not reopen file"); error_setg_errno(errp, errno, "Could not reopen file");
ret = -1; ret = -1;
} }
@ -606,11 +606,11 @@ static int raw_reopen_prepare(BDRVReopenState *state,
/* Fail already reopen_prepare() if we can't get a working O_DIRECT /* Fail already reopen_prepare() if we can't get a working O_DIRECT
* alignment with the new fd. */ * alignment with the new fd. */
if (raw_s->fd != -1) { if (rs->fd != -1) {
raw_probe_alignment(state->bs, raw_s->fd, &local_err); raw_probe_alignment(state->bs, rs->fd, &local_err);
if (local_err) { if (local_err) {
qemu_close(raw_s->fd); qemu_close(rs->fd);
raw_s->fd = -1; rs->fd = -1;
error_propagate(errp, local_err); error_propagate(errp, local_err);
ret = -EINVAL; ret = -EINVAL;
} }
@ -621,13 +621,13 @@ static int raw_reopen_prepare(BDRVReopenState *state,
static void raw_reopen_commit(BDRVReopenState *state) static void raw_reopen_commit(BDRVReopenState *state)
{ {
BDRVRawReopenState *raw_s = state->opaque; BDRVRawReopenState *rs = state->opaque;
BDRVRawState *s = state->bs->opaque; BDRVRawState *s = state->bs->opaque;
s->open_flags = raw_s->open_flags; s->open_flags = rs->open_flags;
qemu_close(s->fd); qemu_close(s->fd);
s->fd = raw_s->fd; s->fd = rs->fd;
g_free(state->opaque); g_free(state->opaque);
state->opaque = NULL; state->opaque = NULL;
@ -636,16 +636,16 @@ static void raw_reopen_commit(BDRVReopenState *state)
static void raw_reopen_abort(BDRVReopenState *state) static void raw_reopen_abort(BDRVReopenState *state)
{ {
BDRVRawReopenState *raw_s = state->opaque; BDRVRawReopenState *rs = state->opaque;
/* nothing to do if NULL, we didn't get far enough */ /* nothing to do if NULL, we didn't get far enough */
if (raw_s == NULL) { if (rs == NULL) {
return; return;
} }
if (raw_s->fd >= 0) { if (rs->fd >= 0) {
qemu_close(raw_s->fd); qemu_close(rs->fd);
raw_s->fd = -1; rs->fd = -1;
} }
g_free(state->opaque); g_free(state->opaque);
state->opaque = NULL; state->opaque = NULL;

View File

@ -35,6 +35,9 @@ status=1 # failure is the default!
_supported_fmt generic _supported_fmt generic
_supported_os Linux _supported_os Linux
test_ssh=$($QEMU_IMG --help | grep '^Supported formats:.* ssh\( \|$\)')
[ "$test_ssh" = "" ] && _notrun "ssh support required"
echo echo
echo '=== NBD ===' echo '=== NBD ==='
# NBD expects all of its arguments to be strings # NBD expects all of its arguments to be strings

View File

@ -51,7 +51,7 @@ export IMGOPTS=""
export CACHEMODE="writeback" export CACHEMODE="writeback"
export QEMU_IO_OPTIONS="" export QEMU_IO_OPTIONS=""
export CACHEMODE_IS_DEFAULT=true export CACHEMODE_IS_DEFAULT=true
export QEMU_OPTIONS="-nodefaults" export QEMU_OPTIONS="-nodefaults -machine accel=qtest"
export VALGRIND_QEMU= export VALGRIND_QEMU=
export IMGKEYSECRET= export IMGKEYSECRET=
export IMGOPTSSYNTAX=false export IMGOPTSSYNTAX=false

View File

@ -155,15 +155,13 @@ function _launch_qemu()
if [ -z "$keep_stderr" ]; then if [ -z "$keep_stderr" ]; then
QEMU_NEED_PID='y'\ QEMU_NEED_PID='y'\
${QEMU} -nographic -serial none ${comm} -machine accel=qtest "${@}" \ ${QEMU} -nographic -serial none ${comm} "${@}" >"${fifo_out}" \
>"${fifo_out}" \ 2>&1 \
2>&1 \ <"${fifo_in}" &
<"${fifo_in}" &
elif [ "$keep_stderr" = "y" ]; then elif [ "$keep_stderr" = "y" ]; then
QEMU_NEED_PID='y'\ QEMU_NEED_PID='y'\
${QEMU} -nographic -serial none ${comm} -machine accel=qtest "${@}" \ ${QEMU} -nographic -serial none ${comm} "${@}" >"${fifo_out}" \
>"${fifo_out}" \ <"${fifo_in}" &
<"${fifo_in}" &
else else
exit 1 exit 1
fi fi