Merge tag 'pull-request-2022-03-21' of https://gitlab.com/thuth/qemu into staging
* Fix stack-overflow due to recursive DMA in intel-hda (CVE-2021-3611)
* Fix heap overflow due to recursive DMA in sdhci code
# gpg: Signature made Mon 21 Mar 2022 16:14:36 GMT
# gpg: using RSA key 27B88847EEE0250118F3EAB92ED9D774FE702DB5
# gpg: issuer "thuth@redhat.com"
# gpg: Good signature from "Thomas Huth <th.huth@gmx.de>" [full]
# gpg: aka "Thomas Huth <thuth@redhat.com>" [full]
# gpg: aka "Thomas Huth <huth@tuxfamily.org>" [full]
# gpg: aka "Thomas Huth <th.huth@posteo.de>" [unknown]
# Primary key fingerprint: 27B8 8847 EEE0 2501 18F3 EAB9 2ED9 D774 FE70 2DB5
* tag 'pull-request-2022-03-21' of https://gitlab.com/thuth/qemu:
tests/qtest/fuzz-sdcard-test: Add reproducer for OSS-Fuzz (Issue 29225)
hw/sd/sdhci: Prohibit DMA accesses to devices
hw/sd/sdhci: Honor failed DMA transactions
tests/qtest/intel-hda-test: Add reproducer for issue #542
hw/audio/intel-hda: Restrict DMA engine to memories (not MMIO devices)
hw/audio/intel-hda: Do not ignore DMA overrun errors
softmmu/physmem: Introduce MemTxAttrs::memory field and MEMTX_ACCESS_ERROR
softmmu/physmem: Simplify flatview_write and address_space_access_valid
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
diff --git a/.gitlab-ci.d/custom-runners/ubuntu-20.04-s390x.yml b/.gitlab-ci.d/custom-runners/ubuntu-20.04-s390x.yml
index 0333872..4f292a8 100644
--- a/.gitlab-ci.d/custom-runners/ubuntu-20.04-s390x.yml
+++ b/.gitlab-ci.d/custom-runners/ubuntu-20.04-s390x.yml
@@ -8,6 +8,8 @@
tags:
- ubuntu_20.04
- s390x
+ variables:
+ DFLTCC: 0
rules:
- if: '$CI_PROJECT_NAMESPACE == "qemu-project" && $CI_COMMIT_BRANCH =~ /^staging/'
- if: "$S390X_RUNNER_AVAILABLE"
@@ -27,6 +29,8 @@
tags:
- ubuntu_20.04
- s390x
+ variables:
+ DFLTCC: 0
rules:
- if: '$CI_PROJECT_NAMESPACE == "qemu-project" && $CI_COMMIT_BRANCH =~ /^staging/'
- if: "$S390X_RUNNER_AVAILABLE"
@@ -43,6 +47,8 @@
tags:
- ubuntu_20.04
- s390x
+ variables:
+ DFLTCC: 0
rules:
- if: '$CI_PROJECT_NAMESPACE == "qemu-project" && $CI_COMMIT_BRANCH =~ /^staging/'
when: manual
@@ -64,6 +70,8 @@
tags:
- ubuntu_20.04
- s390x
+ variables:
+ DFLTCC: 0
rules:
- if: '$CI_PROJECT_NAMESPACE == "qemu-project" && $CI_COMMIT_BRANCH =~ /^staging/'
when: manual
@@ -84,6 +92,8 @@
tags:
- ubuntu_20.04
- s390x
+ variables:
+ DFLTCC: 0
rules:
- if: '$CI_PROJECT_NAMESPACE == "qemu-project" && $CI_COMMIT_BRANCH =~ /^staging/'
when: manual
@@ -103,6 +113,8 @@
tags:
- ubuntu_20.04
- s390x
+ variables:
+ DFLTCC: 0
rules:
- if: '$CI_PROJECT_NAMESPACE == "qemu-project" && $CI_COMMIT_BRANCH =~ /^staging/'
when: manual
diff --git a/.travis.yml b/.travis.yml
index c3c8048..9afc4a5 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -218,6 +218,7 @@
- TEST_CMD="make check check-tcg V=1"
- CONFIG="--disable-containers --target-list=${MAIN_SOFTMMU_TARGETS},s390x-linux-user"
- UNRELIABLE=true
+ - DFLTCC=0
script:
- BUILD_RC=0 && make -j${JOBS} || BUILD_RC=$?
- |
@@ -257,7 +258,7 @@
env:
- CONFIG="--disable-containers --audio-drv-list=sdl --disable-user
--target-list-exclude=${MAIN_SOFTMMU_TARGETS}"
-
+ - DFLTCC=0
- name: "[s390x] GCC (user)"
arch: s390x
dist: focal
@@ -269,7 +270,7 @@
- ninja-build
env:
- CONFIG="--disable-containers --disable-system"
-
+ - DFLTCC=0
- name: "[s390x] Clang (disable-tcg)"
arch: s390x
dist: focal
@@ -303,3 +304,4 @@
- CONFIG="--disable-containers --disable-tcg --enable-kvm
--disable-tools --host-cc=clang --cxx=clang++"
- UNRELIABLE=true
+ - DFLTCC=0
diff --git a/MAINTAINERS b/MAINTAINERS
index 9aed5f3..cc364af 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -2507,7 +2507,7 @@
Block Jobs
M: John Snow <jsnow@redhat.com>
-M: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
+M: Vladimir Sementsov-Ogievskiy <v.sementsov-og@mail.ru>
L: qemu-block@nongnu.org
S: Supported
F: blockjob.c
@@ -2546,7 +2546,7 @@
Dirty Bitmaps
M: Eric Blake <eblake@redhat.com>
-M: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
+M: Vladimir Sementsov-Ogievskiy <v.sementsov-og@mail.ru>
R: John Snow <jsnow@redhat.com>
L: qemu-block@nongnu.org
S: Supported
@@ -2770,13 +2770,13 @@
F: tests/*.py
Benchmark util
-M: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
+M: Vladimir Sementsov-Ogievskiy <v.sementsov-og@mail.ru>
S: Maintained
F: scripts/simplebench/
T: git https://src.openvz.org/scm/~vsementsov/qemu.git simplebench
Transactions helper
-M: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
+M: Vladimir Sementsov-Ogievskiy <v.sementsov-og@mail.ru>
S: Maintained
F: include/qemu/transactions.h
F: util/transactions.c
@@ -3360,7 +3360,7 @@
Network Block Device (NBD)
M: Eric Blake <eblake@redhat.com>
-M: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
+M: Vladimir Sementsov-Ogievskiy <v.sementsov-og@mail.ru>
L: qemu-block@nongnu.org
S: Maintained
F: block/nbd*
@@ -3456,7 +3456,7 @@
parallels
M: Stefan Hajnoczi <stefanha@redhat.com>
M: Denis V. Lunev <den@openvz.org>
-M: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
+M: Vladimir Sementsov-Ogievskiy <v.sementsov-og@mail.ru>
L: qemu-block@nongnu.org
S: Supported
F: block/parallels.c
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 27864df..5f1377c 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -1646,7 +1646,7 @@
{
int i;
- kml->slots = g_malloc0(s->nr_slots * sizeof(KVMSlot));
+ kml->slots = g_new0(KVMSlot, s->nr_slots);
kml->as_id = as_id;
for (i = 0; i < s->nr_slots; i++) {
@@ -1941,7 +1941,7 @@
return virq;
}
- route = g_malloc0(sizeof(KVMMSIRoute));
+ route = g_new0(KVMMSIRoute, 1);
route->kroute.gsi = virq;
route->kroute.type = KVM_IRQ_ROUTING_MSI;
route->kroute.flags = 0;
@@ -3244,7 +3244,7 @@
return 0;
}
- bp = g_malloc(sizeof(struct kvm_sw_breakpoint));
+ bp = g_new(struct kvm_sw_breakpoint, 1);
bp->pc = addr;
bp->use_count = 1;
err = kvm_arch_insert_sw_breakpoint(cpu, bp);
diff --git a/accel/tcg/tcg-accel-ops-mttcg.c b/accel/tcg/tcg-accel-ops-mttcg.c
index dc421c8..ea2b741 100644
--- a/accel/tcg/tcg-accel-ops-mttcg.c
+++ b/accel/tcg/tcg-accel-ops-mttcg.c
@@ -143,7 +143,7 @@
g_assert(tcg_enabled());
tcg_cpu_init_cflags(cpu, current_machine->smp.max_cpus > 1);
- cpu->thread = g_malloc0(sizeof(QemuThread));
+ cpu->thread = g_new0(QemuThread, 1);
cpu->halt_cond = g_malloc0(sizeof(QemuCond));
qemu_cond_init(cpu->halt_cond);
diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c
index a805fb6..b287110 100644
--- a/accel/tcg/tcg-accel-ops-rr.c
+++ b/accel/tcg/tcg-accel-ops-rr.c
@@ -280,8 +280,8 @@
tcg_cpu_init_cflags(cpu, false);
if (!single_tcg_cpu_thread) {
- cpu->thread = g_malloc0(sizeof(QemuThread));
- cpu->halt_cond = g_malloc0(sizeof(QemuCond));
+ cpu->thread = g_new0(QemuThread, 1);
+ cpu->halt_cond = g_new0(QemuCond, 1);
qemu_cond_init(cpu->halt_cond);
/* share a single thread for all cpus with TCG */
diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c
index b04716a..4a61378 100644
--- a/audio/alsaaudio.c
+++ b/audio/alsaaudio.c
@@ -72,7 +72,7 @@
snd_pcm_uframes_t samples;
};
-static void GCC_FMT_ATTR (2, 3) alsa_logerr (int err, const char *fmt, ...)
+static void G_GNUC_PRINTF (2, 3) alsa_logerr (int err, const char *fmt, ...)
{
va_list ap;
@@ -83,7 +83,7 @@
AUD_log (AUDIO_CAP, "Reason: %s\n", snd_strerror (err));
}
-static void GCC_FMT_ATTR (3, 4) alsa_logerr2 (
+static void G_GNUC_PRINTF (3, 4) alsa_logerr2 (
int err,
const char *typ,
const char *fmt,
diff --git a/audio/audio.c b/audio/audio.c
index 6bc313d..1c98964 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -1733,7 +1733,7 @@
audio_validate_opts(dev, &error_abort);
}
- s = g_malloc0(sizeof(AudioState));
+ s = g_new0(AudioState, 1);
s->dev = dev;
QLIST_INIT (&s->hw_head_out);
@@ -2108,7 +2108,7 @@
audio_validate_opts(dev, &error_fatal);
- e = g_malloc0(sizeof(AudiodevListEntry));
+ e = g_new0(AudiodevListEntry, 1);
e->dev = dev;
QSIMPLEQ_INSERT_TAIL(&audiodevs, e, next);
}
diff --git a/audio/audio.h b/audio/audio.h
index c8bde53..cbb10f4 100644
--- a/audio/audio.h
+++ b/audio/audio.h
@@ -91,8 +91,8 @@
uint64_t old_ts;
} QEMUAudioTimeStamp;
-void AUD_vlog (const char *cap, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);
-void AUD_log (const char *cap, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
+void AUD_vlog (const char *cap, const char *fmt, va_list ap) G_GNUC_PRINTF(2, 0);
+void AUD_log (const char *cap, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
void AUD_register_card (const char *name, QEMUSoundCard *card);
void AUD_remove_card (QEMUSoundCard *card);
diff --git a/audio/audio_legacy.c b/audio/audio_legacy.c
index 0fe827b..595949f 100644
--- a/audio/audio_legacy.c
+++ b/audio/audio_legacy.c
@@ -328,8 +328,8 @@
static AudiodevListEntry *legacy_opt(const char *drvname)
{
- AudiodevListEntry *e = g_malloc0(sizeof(AudiodevListEntry));
- e->dev = g_malloc0(sizeof(Audiodev));
+ AudiodevListEntry *e = g_new0(AudiodevListEntry, 1);
+ e->dev = g_new0(Audiodev, 1);
e->dev->id = g_strdup(drvname);
e->dev->driver = qapi_enum_parse(
&AudiodevDriver_lookup, drvname, -1, &error_abort);
@@ -508,7 +508,7 @@
static Visitor *legacy_visitor_new(void)
{
- LegacyPrintVisitor *lv = g_malloc0(sizeof(LegacyPrintVisitor));
+ LegacyPrintVisitor *lv = g_new0(LegacyPrintVisitor, 1);
lv->visitor.start_struct = lv_start_struct;
lv->visitor.end_struct = lv_end_struct;
diff --git a/audio/coreaudio.m b/audio/coreaudio.m
index 3186b68..4695291 100644
--- a/audio/coreaudio.m
+++ b/audio/coreaudio.m
@@ -211,7 +211,7 @@
AUD_log (AUDIO_CAP, "Reason: %s\n", str);
}
-static void GCC_FMT_ATTR (2, 3) coreaudio_logerr (
+static void G_GNUC_PRINTF (2, 3) coreaudio_logerr (
OSStatus status,
const char *fmt,
...
@@ -226,7 +226,7 @@
coreaudio_logstatus (status);
}
-static void GCC_FMT_ATTR (3, 4) coreaudio_logerr2 (
+static void G_GNUC_PRINTF (3, 4) coreaudio_logerr2 (
OSStatus status,
const char *typ,
const char *fmt,
diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c
index 231f3e6..3fb67ec 100644
--- a/audio/dsoundaudio.c
+++ b/audio/dsoundaudio.c
@@ -222,7 +222,7 @@
AUD_log (AUDIO_CAP, "Reason: %s\n", str);
}
-static void GCC_FMT_ATTR (2, 3) dsound_logerr (
+static void G_GNUC_PRINTF (2, 3) dsound_logerr (
HRESULT hr,
const char *fmt,
...
@@ -237,7 +237,7 @@
dsound_log_hresult (hr);
}
-static void GCC_FMT_ATTR (3, 4) dsound_logerr2 (
+static void G_GNUC_PRINTF (3, 4) dsound_logerr2 (
HRESULT hr,
const char *typ,
const char *fmt,
@@ -623,7 +623,7 @@
{
int err;
HRESULT hr;
- dsound *s = g_malloc0(sizeof(dsound));
+ dsound *s = g_new0(dsound, 1);
AudiodevDsoundOptions *dso;
assert(dev->driver == AUDIODEV_DRIVER_DSOUND);
diff --git a/audio/jackaudio.c b/audio/jackaudio.c
index bf75725..5bdf3d7 100644
--- a/audio/jackaudio.c
+++ b/audio/jackaudio.c
@@ -97,9 +97,9 @@
buffer->used = 0;
buffer->rptr = 0;
buffer->wptr = 0;
- buffer->data = g_malloc(channels * sizeof(float *));
+ buffer->data = g_new(float *, channels);
for (int i = 0; i < channels; ++i) {
- buffer->data[i] = g_malloc(frames * sizeof(float));
+ buffer->data[i] = g_new(float, frames);
}
}
@@ -453,7 +453,7 @@
jack_on_shutdown(c->client, qjack_shutdown, c);
/* allocate and register the ports */
- c->port = g_malloc(sizeof(jack_port_t *) * c->nchannels);
+ c->port = g_new(jack_port_t *, c->nchannels);
for (int i = 0; i < c->nchannels; ++i) {
char port_name[16];
diff --git a/audio/ossaudio.c b/audio/ossaudio.c
index da9c232..8e075ed 100644
--- a/audio/ossaudio.c
+++ b/audio/ossaudio.c
@@ -63,7 +63,7 @@
int fragsize;
};
-static void GCC_FMT_ATTR (2, 3) oss_logerr (int err, const char *fmt, ...)
+static void G_GNUC_PRINTF (2, 3) oss_logerr (int err, const char *fmt, ...)
{
va_list ap;
@@ -74,7 +74,7 @@
AUD_log (AUDIO_CAP, "Reason: %s\n", strerror (err));
}
-static void GCC_FMT_ATTR (3, 4) oss_logerr2 (
+static void G_GNUC_PRINTF (3, 4) oss_logerr2 (
int err,
const char *typ,
const char *fmt,
diff --git a/audio/paaudio.c b/audio/paaudio.c
index a53ed85..e91116f 100644
--- a/audio/paaudio.c
+++ b/audio/paaudio.c
@@ -43,7 +43,7 @@
static void qpa_conn_fini(PAConnection *c);
-static void GCC_FMT_ATTR (2, 3) qpa_logerr (int err, const char *fmt, ...)
+static void G_GNUC_PRINTF (2, 3) qpa_logerr (int err, const char *fmt, ...)
{
va_list ap;
@@ -760,7 +760,7 @@
/* common */
static void *qpa_conn_init(const char *server)
{
- PAConnection *c = g_malloc0(sizeof(PAConnection));
+ PAConnection *c = g_new0(PAConnection, 1);
QTAILQ_INSERT_TAIL(&pa_conns, c, list);
c->mainloop = pa_threaded_mainloop_new();
@@ -849,7 +849,7 @@
return NULL;
}
- g = g_malloc0(sizeof(paaudio));
+ g = g_new0(paaudio, 1);
server = popts->has_server ? popts->server : NULL;
g->dev = dev;
diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c
index 797b47b..68a237b 100644
--- a/audio/sdlaudio.c
+++ b/audio/sdlaudio.c
@@ -55,7 +55,7 @@
SDL_AudioDeviceID devid;
} SDLVoiceIn;
-static void GCC_FMT_ATTR (1, 2) sdl_logerr (const char *fmt, ...)
+static void G_GNUC_PRINTF (1, 2) sdl_logerr (const char *fmt, ...)
{
va_list ap;
diff --git a/backends/cryptodev.c b/backends/cryptodev.c
index bf52476..2b105e4 100644
--- a/backends/cryptodev.c
+++ b/backends/cryptodev.c
@@ -39,7 +39,7 @@
{
CryptoDevBackendClient *cc;
- cc = g_malloc0(sizeof(CryptoDevBackendClient));
+ cc = g_new0(CryptoDevBackendClient, 1);
cc->model = g_strdup(model);
if (name) {
cc->name = g_strdup(name);
diff --git a/block/blkverify.c b/block/blkverify.c
index 53ba1c9..e4a37af 100644
--- a/block/blkverify.c
+++ b/block/blkverify.c
@@ -44,7 +44,7 @@
QEMUIOVector *raw_qiov; /* cloned I/O vector for raw file */
} BlkverifyRequest;
-static void GCC_FMT_ATTR(2, 3) blkverify_err(BlkverifyRequest *r,
+static void G_GNUC_PRINTF(2, 3) blkverify_err(BlkverifyRequest *r,
const char *fmt, ...)
{
va_list ap;
diff --git a/block/nbd.c b/block/nbd.c
index 34b9429..567872a 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -533,8 +533,8 @@
if (i != -1) {
s->requests[i].coroutine = NULL;
s->in_flight--;
- qemu_co_queue_next(&s->free_sema);
}
+ qemu_co_queue_next(&s->free_sema);
}
qemu_co_mutex_unlock(&s->send_mutex);
return rc;
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 9403397..b914994 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -33,9 +33,11 @@
static int64_t alloc_clusters_noref(BlockDriverState *bs, uint64_t size,
uint64_t max);
-static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
- int64_t offset, int64_t length, uint64_t addend,
- bool decrease, enum qcow2_discard_type type);
+
+G_GNUC_WARN_UNUSED_RESULT
+static int update_refcount(BlockDriverState *bs,
+ int64_t offset, int64_t length, uint64_t addend,
+ bool decrease, enum qcow2_discard_type type);
static uint64_t get_refcount_ro0(const void *refcount_array, uint64_t index);
static uint64_t get_refcount_ro1(const void *refcount_array, uint64_t index);
@@ -803,12 +805,12 @@
/* XXX: cache several refcount block clusters ? */
/* @addend is the absolute value of the addend; if @decrease is set, @addend
* will be subtracted from the current refcount, otherwise it will be added */
-static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
- int64_t offset,
- int64_t length,
- uint64_t addend,
- bool decrease,
- enum qcow2_discard_type type)
+static int update_refcount(BlockDriverState *bs,
+ int64_t offset,
+ int64_t length,
+ uint64_t addend,
+ bool decrease,
+ enum qcow2_discard_type type)
{
BDRVQcow2State *s = bs->opaque;
int64_t start, last, cluster_offset;
diff --git a/block/qcow2.h b/block/qcow2.h
index fd48a89..ba436a8 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -838,7 +838,7 @@
void qcow2_signal_corruption(BlockDriverState *bs, bool fatal, int64_t offset,
int64_t size, const char *message_format, ...)
- GCC_FMT_ATTR(5, 6);
+ G_GNUC_PRINTF(5, 6);
int qcow2_validate_table(BlockDriverState *bs, uint64_t offset,
uint64_t entries, size_t entry_len,
diff --git a/block/rbd.c b/block/rbd.c
index 8f183eb..6caf35c 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -1107,6 +1107,20 @@
assert(!qiov || qiov->size == bytes);
+ if (cmd == RBD_AIO_WRITE || cmd == RBD_AIO_WRITE_ZEROES) {
+ /*
+ * RBD APIs don't allow us to write more than actual size, so in order
+ * to support growing images, we resize the image before write
+ * operations that exceed the current size.
+ */
+ if (offset + bytes > s->image_size) {
+ int r = qemu_rbd_resize(bs, offset + bytes);
+ if (r < 0) {
+ return r;
+ }
+ }
+ }
+
r = rbd_aio_create_completion(&task,
(rbd_callback_t) qemu_rbd_completion_cb, &c);
if (r < 0) {
@@ -1182,18 +1196,6 @@
int64_t bytes, QEMUIOVector *qiov,
BdrvRequestFlags flags)
{
- BDRVRBDState *s = bs->opaque;
- /*
- * RBD APIs don't allow us to write more than actual size, so in order
- * to support growing images, we resize the image before write
- * operations that exceed the current size.
- */
- if (offset + bytes > s->image_size) {
- int r = qemu_rbd_resize(bs, offset + bytes);
- if (r < 0) {
- return r;
- }
- }
return qemu_rbd_start_co(bs, offset, bytes, qiov, flags, RBD_AIO_WRITE);
}
diff --git a/block/ssh.c b/block/ssh.c
index a64db14..a2dc646 100644
--- a/block/ssh.c
+++ b/block/ssh.c
@@ -108,7 +108,7 @@
}
}
-static void GCC_FMT_ATTR(3, 4)
+static void G_GNUC_PRINTF(3, 4)
session_error_setg(Error **errp, BDRVSSHState *s, const char *fs, ...)
{
va_list args;
@@ -133,7 +133,7 @@
g_free(msg);
}
-static void GCC_FMT_ATTR(3, 4)
+static void G_GNUC_PRINTF(3, 4)
sftp_error_setg(Error **errp, BDRVSSHState *s, const char *fs, ...)
{
va_list args;
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index af272c2..21c06f2 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -175,7 +175,7 @@
abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1,
abi_long arg2, abi_long arg3, abi_long arg4,
abi_long arg5, abi_long arg6);
-void gemu_log(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
+void gemu_log(const char *fmt, ...) G_GNUC_PRINTF(1, 2);
extern __thread CPUState *thread_cpu;
void cpu_loop(CPUArchState *env);
char *target_strerror(int err);
diff --git a/configure b/configure
index cd4946b..6d9cb23 100755
--- a/configure
+++ b/configure
@@ -2248,7 +2248,7 @@
{
g_free(f);
}
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free);
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(Foo, foo_free)
int main(void) { return 0; }
EOF
if ! compile_prog "$glib_cflags -Werror" "$glib_libs" ; then
@@ -2481,41 +2481,6 @@
int128=yes
fi
-#########################################
-# See if 128-bit atomic operations are supported.
-
-atomic128=no
-if test "$int128" = "yes"; then
- cat > $TMPC << EOF
-int main(void)
-{
- unsigned __int128 x = 0, y = 0;
- y = __atomic_load(&x, 0);
- __atomic_store(&x, y, 0);
- __atomic_compare_exchange(&x, &y, x, 0, 0, 0);
- return 0;
-}
-EOF
- if compile_prog "" "" ; then
- atomic128=yes
- fi
-fi
-
-cmpxchg128=no
-if test "$int128" = yes && test "$atomic128" = no; then
- cat > $TMPC << EOF
-int main(void)
-{
- unsigned __int128 x = 0, y = 0;
- __sync_val_compare_and_swap_16(&x, y, x);
- return 0;
-}
-EOF
- if compile_prog "" "" ; then
- cmpxchg128=yes
- fi
-fi
-
########################################
# check if ccache is interfering with
# semantic analysis of macros
@@ -2959,18 +2924,6 @@
echo "CONFIG_TSAN=y" >> $config_host_mak
fi
-if test "$int128" = "yes" ; then
- echo "CONFIG_INT128=y" >> $config_host_mak
-fi
-
-if test "$atomic128" = "yes" ; then
- echo "CONFIG_ATOMIC128=y" >> $config_host_mak
-fi
-
-if test "$cmpxchg128" = "yes" ; then
- echo "CONFIG_CMPXCHG128=y" >> $config_host_mak
-fi
-
if test "$rdma" = "yes" ; then
echo "CONFIG_RDMA=y" >> $config_host_mak
echo "RDMA_LIBS=$rdma_libs" >> $config_host_mak
diff --git a/contrib/vhost-user-gpu/vhost-user-gpu.c b/contrib/vhost-user-gpu/vhost-user-gpu.c
index 611360e..bfb8d93 100644
--- a/contrib/vhost-user-gpu/vhost-user-gpu.c
+++ b/contrib/vhost-user-gpu/vhost-user-gpu.c
@@ -455,7 +455,7 @@
return -1;
}
- *iov = g_malloc0(sizeof(struct iovec) * ab->nr_entries);
+ *iov = g_new0(struct iovec, ab->nr_entries);
for (i = 0; i < ab->nr_entries; i++) {
uint64_t len = ents[i].length;
(*iov)[i].iov_len = ents[i].length;
diff --git a/cpus-common.c b/cpus-common.c
index 6e73d3e..db459b4 100644
--- a/cpus-common.c
+++ b/cpus-common.c
@@ -160,7 +160,7 @@
{
struct qemu_work_item *wi;
- wi = g_malloc0(sizeof(struct qemu_work_item));
+ wi = g_new0(struct qemu_work_item, 1);
wi->func = func;
wi->data = data;
wi->free = true;
@@ -305,7 +305,7 @@
{
struct qemu_work_item *wi;
- wi = g_malloc0(sizeof(struct qemu_work_item));
+ wi = g_new0(struct qemu_work_item, 1);
wi->func = func;
wi->data = data;
wi->free = true;
diff --git a/crypto/cipher-afalg.c b/crypto/cipher-afalg.c
index 052355a..c55cd28 100644
--- a/crypto/cipher-afalg.c
+++ b/crypto/cipher-afalg.c
@@ -84,8 +84,8 @@
g_free(name);
/* setkey */
- if (qemu_setsockopt(afalg->tfmfd, SOL_ALG, ALG_SET_KEY, key,
- nkey) != 0) {
+ if (setsockopt(afalg->tfmfd, SOL_ALG, ALG_SET_KEY, key,
+ nkey) != 0) {
error_setg_errno(errp, errno, "Set key failed");
qcrypto_afalg_comm_free(afalg);
return NULL;
diff --git a/crypto/hash-afalg.c b/crypto/hash-afalg.c
index cf34c69..4ac18c7 100644
--- a/crypto/hash-afalg.c
+++ b/crypto/hash-afalg.c
@@ -88,8 +88,8 @@
/* HMAC needs setkey */
if (is_hmac) {
- if (qemu_setsockopt(afalg->tfmfd, SOL_ALG, ALG_SET_KEY,
- key, nkey) != 0) {
+ if (setsockopt(afalg->tfmfd, SOL_ALG, ALG_SET_KEY,
+ key, nkey) != 0) {
error_setg_errno(errp, errno, "Set hmac key failed");
qcrypto_afalg_comm_free(afalg);
return NULL;
diff --git a/docs/tools/qemu-nbd.rst b/docs/tools/qemu-nbd.rst
index 2b8c90c..4c950f6 100644
--- a/docs/tools/qemu-nbd.rst
+++ b/docs/tools/qemu-nbd.rst
@@ -27,7 +27,7 @@
.. program:: qemu-nbd
*filename* is a disk image filename, or a set of block
-driver options if ``--image-opts`` is specified.
+driver options if :option:`--image-opts` is specified.
*dev* is an NBD device.
@@ -165,9 +165,9 @@
.. option:: --tls-creds=ID
Enable mandatory TLS encryption for the server by setting the ID
- of the TLS credentials object previously created with the --object
- option; or provide the credentials needed for connecting as a client
- in list mode.
+ of the TLS credentials object previously created with the
+ :option:`--object` option; or provide the credentials needed for
+ connecting as a client in list mode.
.. option:: --tls-hostname=hostname
@@ -176,11 +176,11 @@
against information in the server provided certificate. Sometimes
it might be required to override the hostname used to perform this
check. For example, if the NBD client is using a tunnel from localhost
- to connect to the remote server, the `--tls-hostname` option should
+ to connect to the remote server, the :option:`--tls-hostname` option should
be used to set the officially expected hostname of the remote NBD
server. This can also be used if accessing NBD over a UNIX socket
where there is no inherent hostname available. This is only permitted
- when acting as a NBD client with the `--list` option.
+ when acting as a NBD client with the :option:`--list` option.
.. option:: --fork
diff --git a/dump/dump.c b/dump/dump.c
index a84d8b1..f57ed76 100644
--- a/dump/dump.c
+++ b/dump/dump.c
@@ -2041,7 +2041,7 @@
DumpGuestMemoryCapability *qmp_query_dump_guest_memory_capability(Error **errp)
{
DumpGuestMemoryCapability *cap =
- g_malloc0(sizeof(DumpGuestMemoryCapability));
+ g_new0(DumpGuestMemoryCapability, 1);
DumpGuestMemoryFormatList **tail = &cap->formats;
/* elf is always available */
diff --git a/fsdev/9p-marshal.c b/fsdev/9p-marshal.c
index 51881fe..f9b0336 100644
--- a/fsdev/9p-marshal.c
+++ b/fsdev/9p-marshal.c
@@ -27,7 +27,7 @@
str->size = 0;
}
-void GCC_FMT_ATTR(2, 3)
+void G_GNUC_PRINTF(2, 3)
v9fs_string_sprintf(V9fsString *str, const char *fmt, ...)
{
va_list ap;
diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c
index 15c0e79..d06a0f7 100644
--- a/fsdev/virtfs-proxy-helper.c
+++ b/fsdev/virtfs-proxy-helper.c
@@ -57,7 +57,7 @@
static bool get_version; /* IOC getversion IOCTL supported */
static char *prog_name;
-static void GCC_FMT_ATTR(2, 3) do_log(int loglevel, const char *format, ...)
+static void G_GNUC_PRINTF(2, 3) do_log(int loglevel, const char *format, ...)
{
va_list ap;
diff --git a/gdbstub.c b/gdbstub.c
index 3c14c6a..c8375e3 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -426,7 +426,7 @@
int ret;
for(;;) {
- ret = qemu_recv(gdbserver_state.fd, &ch, 1, 0);
+ ret = recv(gdbserver_state.fd, &ch, 1, 0);
if (ret < 0) {
if (errno == ECONNRESET)
gdbserver_state.fd = -1;
diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c
index 8b4b5cf..4c5e0fc 100644
--- a/hw/9pfs/9p-proxy.c
+++ b/hw/9pfs/9p-proxy.c
@@ -1187,7 +1187,7 @@
static int proxy_init(FsContext *ctx, Error **errp)
{
- V9fsProxy *proxy = g_malloc(sizeof(V9fsProxy));
+ V9fsProxy *proxy = g_new(V9fsProxy, 1);
int sock_id;
if (ctx->export_flags & V9FS_PROXY_SOCK_NAME) {
diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c
index b3080e4..d99d263 100644
--- a/hw/9pfs/9p-synth.c
+++ b/hw/9pfs/9p-synth.c
@@ -49,7 +49,7 @@
/* Add directory type and remove write bits */
mode = ((mode & 0777) | S_IFDIR) & ~(S_IWUSR | S_IWGRP | S_IWOTH);
- node = g_malloc0(sizeof(V9fsSynthNode));
+ node = g_new0(V9fsSynthNode, 1);
if (attr) {
/* We are adding .. or . entries */
node->attr = attr;
@@ -128,7 +128,7 @@
}
/* Add file type and remove write bits */
mode = ((mode & 0777) | S_IFREG);
- node = g_malloc0(sizeof(V9fsSynthNode));
+ node = g_new0(V9fsSynthNode, 1);
node->attr = &node->actual_attr;
node->attr->inode = synth_node_count++;
node->attr->nlink = 1;
diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index a6d6b3f..dcaa602 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -203,7 +203,7 @@
}
-void GCC_FMT_ATTR(2, 3)
+void G_GNUC_PRINTF(2, 3)
v9fs_path_sprintf(V9fsPath *path, const char *fmt, ...)
{
va_list ap;
@@ -324,7 +324,7 @@
return NULL;
}
}
- f = g_malloc0(sizeof(V9fsFidState));
+ f = g_new0(V9fsFidState, 1);
f->fid = fid;
f->fid_type = P9_FID_NONE;
f->ref = 1;
@@ -804,7 +804,7 @@
val = qht_lookup(&pdu->s->qpd_table, &lookup, hash);
if (!val) {
- val = g_malloc0(sizeof(QpdEntry));
+ val = g_new0(QpdEntry, 1);
*val = lookup;
affix = affixForIndex(pdu->s->qp_affix_next);
val->prefix_bits = affix.bits;
@@ -852,7 +852,7 @@
return -ENFILE;
}
- val = g_malloc0(sizeof(QppEntry));
+ val = g_new0(QpfEntry, 1);
*val = lookup;
/* new unique inode and device combo */
@@ -928,7 +928,7 @@
return -ENFILE;
}
- val = g_malloc0(sizeof(QppEntry));
+ val = g_new0(QppEntry, 1);
*val = lookup;
/* new unique inode affix and device combo */
diff --git a/hw/9pfs/codir.c b/hw/9pfs/codir.c
index 75148bc..93ba44f 100644
--- a/hw/9pfs/codir.c
+++ b/hw/9pfs/codir.c
@@ -141,9 +141,9 @@
/* append next node to result chain */
if (!e) {
- *entries = e = g_malloc0(sizeof(V9fsDirEnt));
+ *entries = e = g_new0(V9fsDirEnt, 1);
} else {
- e = e->next = g_malloc0(sizeof(V9fsDirEnt));
+ e = e->next = g_new0(V9fsDirEnt, 1);
}
e->dent = qemu_dirent_dup(dent);
@@ -163,7 +163,7 @@
break;
}
- e->st = g_malloc0(sizeof(struct stat));
+ e->st = g_new0(struct stat, 1);
memcpy(e->st, &stbuf, sizeof(struct stat));
}
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index 1773cf5..4086879 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -207,7 +207,7 @@
g_array_append_vals(array, "____", ACPI_NAMESEG_LEN - len);
}
-static void GCC_FMT_ATTR(2, 0)
+static void G_GNUC_PRINTF(2, 0)
build_append_namestringv(GArray *array, const char *format, va_list ap)
{
char *s;
@@ -270,7 +270,7 @@
g_strfreev(segs);
}
-GCC_FMT_ATTR(2, 3)
+G_GNUC_PRINTF(2, 3)
static void build_append_namestring(GArray *array, const char *format, ...)
{
va_list ap;
diff --git a/hw/acpi/hmat.c b/hw/acpi/hmat.c
index 6913ebf..3a6d512 100644
--- a/hw/acpi/hmat.c
+++ b/hw/acpi/hmat.c
@@ -128,7 +128,7 @@
}
/* Latency or Bandwidth Entries */
- entry_list = g_malloc0(num_initiator * num_target * sizeof(uint16_t));
+ entry_list = g_new0(uint16_t, num_initiator * num_target);
for (i = 0; i < hmat_lb->list->len; i++) {
lb_data = &g_array_index(hmat_lb->list, HMAT_LB_Data, i);
index = lb_data->initiator * num_target + lb_data->target;
diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c
index 78a47bc..bc77e3d 100644
--- a/hw/audio/intel-hda.c
+++ b/hw/audio/intel-hda.c
@@ -478,7 +478,7 @@
addr = intel_hda_addr(st->bdlp_lbase, st->bdlp_ubase);
st->bentries = st->lvi +1;
g_free(st->bpl);
- st->bpl = g_malloc(sizeof(bpl) * st->bentries);
+ st->bpl = g_new(bpl, st->bentries);
for (i = 0; i < st->bentries; i++, addr += 16) {
pci_dma_read(&d->pci, addr, buf, 16);
st->bpl[i].addr = le64_to_cpu(*(uint64_t *)buf);
diff --git a/hw/char/parallel.c b/hw/char/parallel.c
index adb9bd9..f735a6c 100644
--- a/hw/char/parallel.c
+++ b/hw/char/parallel.c
@@ -622,7 +622,7 @@
{
ParallelState *s;
- s = g_malloc0(sizeof(ParallelState));
+ s = g_new0(ParallelState, 1);
s->irq = irq;
qemu_chr_fe_init(&s->chr, chr, &error_abort);
s->it_shift = it_shift;
diff --git a/hw/char/riscv_htif.c b/hw/char/riscv_htif.c
index 729edbf..6577f0e 100644
--- a/hw/char/riscv_htif.c
+++ b/hw/char/riscv_htif.c
@@ -248,7 +248,7 @@
tohost_offset = tohost_addr - base;
fromhost_offset = fromhost_addr - base;
- HTIFState *s = g_malloc0(sizeof(HTIFState));
+ HTIFState *s = g_new0(HTIFState, 1);
s->address_space = address_space;
s->main_mem = main_mem;
s->main_mem_ram_ptr = memory_region_get_ram_ptr(main_mem);
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index f01ec21..6048d40 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -1055,10 +1055,8 @@
QTAILQ_INIT(&vser->ports);
vser->bus.max_nr_ports = vser->serial.max_virtserial_ports;
- vser->ivqs = g_malloc(vser->serial.max_virtserial_ports
- * sizeof(VirtQueue *));
- vser->ovqs = g_malloc(vser->serial.max_virtserial_ports
- * sizeof(VirtQueue *));
+ vser->ivqs = g_new(VirtQueue *, vser->serial.max_virtserial_ports);
+ vser->ovqs = g_new(VirtQueue *, vser->serial.max_virtserial_ports);
/* Add a queue for host to guest transfers for port 0 (backward compat) */
vser->ivqs[0] = virtio_add_queue(vdev, 128, handle_input);
diff --git a/hw/core/irq.c b/hw/core/irq.c
index 8a9cbdd..7412192 100644
--- a/hw/core/irq.c
+++ b/hw/core/irq.c
@@ -115,7 +115,7 @@
qemu_irq qemu_irq_split(qemu_irq irq1, qemu_irq irq2)
{
- qemu_irq *s = g_malloc0(2 * sizeof(qemu_irq));
+ qemu_irq *s = g_new0(qemu_irq, 2);
s[0] = irq1;
s[1] = irq2;
return qemu_allocate_irq(qemu_splitirq, s, 0);
diff --git a/hw/core/reset.c b/hw/core/reset.c
index 9c477f2..36be82c 100644
--- a/hw/core/reset.c
+++ b/hw/core/reset.c
@@ -40,7 +40,7 @@
void qemu_register_reset(QEMUResetHandler *func, void *opaque)
{
- QEMUResetEntry *re = g_malloc0(sizeof(QEMUResetEntry));
+ QEMUResetEntry *re = g_new0(QEMUResetEntry, 1);
re->func = func;
re->opaque = opaque;
diff --git a/hw/display/pxa2xx_lcd.c b/hw/display/pxa2xx_lcd.c
index 2887ce4..0f06ed6 100644
--- a/hw/display/pxa2xx_lcd.c
+++ b/hw/display/pxa2xx_lcd.c
@@ -1427,7 +1427,7 @@
{
PXA2xxLCDState *s;
- s = (PXA2xxLCDState *) g_malloc0(sizeof(PXA2xxLCDState));
+ s = g_new0(PXA2xxLCDState, 1);
s->invalidated = 1;
s->irq = irq;
s->sysmem = sysmem;
diff --git a/hw/display/qxl.h b/hw/display/qxl.h
index 30d21f4..e74de95 100644
--- a/hw/display/qxl.h
+++ b/hw/display/qxl.h
@@ -149,7 +149,7 @@
/* qxl.c */
void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL phys, int group_id);
void qxl_set_guest_bug(PCIQXLDevice *qxl, const char *msg, ...)
- GCC_FMT_ATTR(2, 3);
+ G_GNUC_PRINTF(2, 3);
void qxl_spice_update_area(PCIQXLDevice *qxl, uint32_t surface_id,
struct QXLRect *area, struct QXLRect *dirty_rects,
diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c
index 1f28223..c7beba4 100644
--- a/hw/display/tc6393xb.c
+++ b/hw/display/tc6393xb.c
@@ -540,7 +540,7 @@
},
};
- s = (TC6393xbState *) g_malloc0(sizeof(TC6393xbState));
+ s = g_new0(TC6393xbState, 1);
s->irq = irq;
s->gpio_in = qemu_allocate_irqs(tc6393xb_gpio_set, s, TC6393XB_GPIOS);
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index c6dc818..529b524 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -831,9 +831,9 @@
}
if (!(v % 16)) {
- *iov = g_realloc(*iov, sizeof(struct iovec) * (v + 16));
+ *iov = g_renew(struct iovec, *iov, v + 16);
if (addr) {
- *addr = g_realloc(*addr, sizeof(uint64_t) * (v + 16));
+ *addr = g_renew(uint64_t, *addr, v + 16);
}
}
(*iov)[v].iov_base = map;
diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c
index 838260b..cea10fe 100644
--- a/hw/display/xenfb.c
+++ b/hw/display/xenfb.c
@@ -496,8 +496,8 @@
n_fbdirs = xenfb->fbpages * mode / 8;
n_fbdirs = DIV_ROUND_UP(n_fbdirs, XC_PAGE_SIZE);
- pgmfns = g_malloc0(sizeof(xen_pfn_t) * n_fbdirs);
- fbmfns = g_malloc0(sizeof(xen_pfn_t) * xenfb->fbpages);
+ pgmfns = g_new0(xen_pfn_t, n_fbdirs);
+ fbmfns = g_new0(xen_pfn_t, xenfb->fbpages);
xenfb_copy_mfns(mode, n_fbdirs, pgmfns, pd);
map = xenforeignmemory_map(xen_fmem, xenfb->c.xendev.dom,
diff --git a/hw/dma/rc4030.c b/hw/dma/rc4030.c
index e4d2f17..aa1d323 100644
--- a/hw/dma/rc4030.c
+++ b/hw/dma/rc4030.c
@@ -646,8 +646,8 @@
struct rc4030DMAState *p;
int i;
- s = (rc4030_dma *)g_new0(rc4030_dma, n);
- p = (struct rc4030DMAState *)g_new0(struct rc4030DMAState, n);
+ s = g_new0(rc4030_dma, n);
+ p = g_new0(struct rc4030DMAState, n);
for (i = 0; i < n; i++) {
p->opaque = opaque;
p->n = i;
diff --git a/hw/i2c/core.c b/hw/i2c/core.c
index 0e7d276..d0cb2d3 100644
--- a/hw/i2c/core.c
+++ b/hw/i2c/core.c
@@ -274,7 +274,7 @@
bus = I2C_BUS(qdev_get_parent_bus(DEVICE(dev)));
if ((bus->saved_address == dev->address) ||
(bus->saved_address == I2C_BROADCAST)) {
- node = g_malloc(sizeof(struct I2CNode));
+ node = g_new(struct I2CNode, 1);
node->elt = dev;
QLIST_INSERT_HEAD(&bus->current_devs, node, next);
}
@@ -319,7 +319,7 @@
bool broadcast, I2CNodeList *current_devs)
{
if ((candidate->address == address) || (broadcast)) {
- I2CNode *node = g_malloc(sizeof(struct I2CNode));
+ I2CNode *node = g_new(struct I2CNode, 1);
node->elt = candidate;
QLIST_INSERT_HEAD(current_devs, node, next);
return true;
diff --git a/hw/i2c/i2c_mux_pca954x.c b/hw/i2c/i2c_mux_pca954x.c
index a9517b6..3945de7 100644
--- a/hw/i2c/i2c_mux_pca954x.c
+++ b/hw/i2c/i2c_mux_pca954x.c
@@ -71,7 +71,7 @@
/* They are talking to the mux itself (or all devices enabled). */
if ((candidate->address == address) || broadcast) {
- I2CNode *node = g_malloc(sizeof(struct I2CNode));
+ I2CNode *node = g_new(struct I2CNode, 1);
node->elt = candidate;
QLIST_INSERT_HEAD(current_devs, node, next);
if (!broadcast) {
diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
index 4d13d8e..ea8eaeb 100644
--- a/hw/i386/amd_iommu.c
+++ b/hw/i386/amd_iommu.c
@@ -913,7 +913,7 @@
}
/* we are at the leaf page table or page table encodes a huge page */
- while (level > 0) {
+ do {
pte_perms = amdvi_get_perms(pte);
present = pte & 1;
if (!present || perms != (perms & pte_perms)) {
@@ -932,10 +932,7 @@
}
oldlevel = level;
level = get_pte_translation_mode(pte);
- if (level == 0x7) {
- break;
- }
- }
+ } while (level > 0 && level < 7);
if (level == 0x7) {
page_mask = pte_override_page_mask(pte);
@@ -1405,7 +1402,7 @@
/* allocate memory during the first run */
if (!iommu_as) {
- iommu_as = g_malloc0(sizeof(AMDVIAddressSpace *) * PCI_DEVFN_MAX);
+ iommu_as = g_new0(AMDVIAddressSpace *, PCI_DEVFN_MAX);
s->address_spaces[bus_num] = iommu_as;
}
@@ -1413,7 +1410,7 @@
if (!iommu_as[devfn]) {
snprintf(name, sizeof(name), "amd_iommu_devfn_%d", devfn);
- iommu_as[devfn] = g_malloc0(sizeof(AMDVIAddressSpace));
+ iommu_as[devfn] = g_new0(AMDVIAddressSpace, 1);
iommu_as[devfn]->bus_num = (uint8_t)bus_num;
iommu_as[devfn]->devfn = (uint8_t)devfn;
iommu_as[devfn]->iommu_state = s;
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 32471a4..c64aa81 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -3416,7 +3416,7 @@
if (!vtd_dev_as) {
snprintf(name, sizeof(name), "vtd-%02x.%x", PCI_SLOT(devfn),
PCI_FUNC(devfn));
- vtd_bus->dev_as[devfn] = vtd_dev_as = g_malloc0(sizeof(VTDAddressSpace));
+ vtd_bus->dev_as[devfn] = vtd_dev_as = g_new0(VTDAddressSpace, 1);
vtd_dev_as->bus = bus;
vtd_dev_as->devfn = (uint8_t)devfn;
diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c
index cf8e500..0731f70 100644
--- a/hw/i386/xen/xen-hvm.c
+++ b/hw/i386/xen/xen-hvm.c
@@ -396,7 +396,7 @@
mr_name = memory_region_name(mr);
- physmap = g_malloc(sizeof(XenPhysmap));
+ physmap = g_new(XenPhysmap, 1);
physmap->start_addr = start_addr;
physmap->size = size;
@@ -1281,7 +1281,7 @@
return;
for (i = 0; i < num; i++) {
- physmap = g_malloc(sizeof (XenPhysmap));
+ physmap = g_new(XenPhysmap, 1);
physmap->phys_offset = strtoull(entries[i], NULL, 16);
snprintf(path, sizeof(path),
"/local/domain/0/device-model/%d/physmap/%s/start_addr",
@@ -1410,7 +1410,7 @@
xen_pfn_t ioreq_pfn;
XenIOState *state;
- state = g_malloc0(sizeof (XenIOState));
+ state = g_new0(XenIOState, 1);
state->xce_handle = xenevtchn_open(NULL, 0);
if (state->xce_handle == NULL) {
@@ -1463,7 +1463,7 @@
}
/* Note: cpus is empty at this point in init */
- state->cpu_by_vcpu_id = g_malloc0(max_cpus * sizeof(CPUState *));
+ state->cpu_by_vcpu_id = g_new0(CPUState *, max_cpus);
rc = xen_set_ioreq_server_state(xen_domid, state->ioservid, true);
if (rc < 0) {
@@ -1472,7 +1472,7 @@
goto err;
}
- state->ioreq_local_port = g_malloc0(max_cpus * sizeof (evtchn_port_t));
+ state->ioreq_local_port = g_new0(evtchn_port_t, max_cpus);
/* FIXME: how about if we overflow the page here? */
for (i = 0; i < max_cpus; i++) {
diff --git a/hw/i386/xen/xen-mapcache.c b/hw/i386/xen/xen-mapcache.c
index f2ef977..a2f9309 100644
--- a/hw/i386/xen/xen-mapcache.c
+++ b/hw/i386/xen/xen-mapcache.c
@@ -108,7 +108,7 @@
unsigned long size;
struct rlimit rlimit_as;
- mapcache = g_malloc0(sizeof (MapCache));
+ mapcache = g_new0(MapCache, 1);
mapcache->phys_offset_to_gaddr = f;
mapcache->opaque = opaque;
@@ -164,8 +164,8 @@
trace_xen_remap_bucket(address_index);
- pfns = g_malloc0(nb_pfn * sizeof (xen_pfn_t));
- err = g_malloc0(nb_pfn * sizeof (int));
+ pfns = g_new0(xen_pfn_t, nb_pfn);
+ err = g_new0(int, nb_pfn);
if (entry->vaddr_base != NULL) {
if (!(entry->flags & XEN_MAPCACHE_ENTRY_DUMMY)) {
@@ -231,8 +231,8 @@
entry->vaddr_base = vaddr_base;
entry->paddr_index = address_index;
entry->size = size;
- entry->valid_mapping = (unsigned long *) g_malloc0(sizeof(unsigned long) *
- BITS_TO_LONGS(size >> XC_PAGE_SHIFT));
+ entry->valid_mapping = g_new0(unsigned long,
+ BITS_TO_LONGS(size >> XC_PAGE_SHIFT));
if (dummy) {
entry->flags |= XEN_MAPCACHE_ENTRY_DUMMY;
@@ -319,7 +319,7 @@
pentry = free_pentry;
}
if (!entry) {
- entry = g_malloc0(sizeof (MapCacheEntry));
+ entry = g_new0(MapCacheEntry, 1);
pentry->next = entry;
xen_remap_bucket(entry, NULL, cache_size, address_index, dummy);
} else if (!entry->lock) {
@@ -353,7 +353,7 @@
mapcache->last_entry = entry;
if (lock) {
- MapCacheRev *reventry = g_malloc0(sizeof(MapCacheRev));
+ MapCacheRev *reventry = g_new0(MapCacheRev, 1);
entry->lock++;
if (entry->lock == 0) {
fprintf(stderr,
diff --git a/hw/input/lasips2.c b/hw/input/lasips2.c
index 68d741d..94f18be 100644
--- a/hw/input/lasips2.c
+++ b/hw/input/lasips2.c
@@ -266,7 +266,7 @@
{
LASIPS2State *s;
- s = g_malloc0(sizeof(LASIPS2State));
+ s = g_new0(LASIPS2State, 1);
s->irq = irq;
s->mouse.id = 1;
diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c
index 1773db0..4efdf75 100644
--- a/hw/input/pckbd.c
+++ b/hw/input/pckbd.c
@@ -649,7 +649,7 @@
MemoryRegion *region, ram_addr_t size,
hwaddr mask)
{
- KBDState *s = g_malloc0(sizeof(KBDState));
+ KBDState *s = g_new0(KBDState, 1);
s->irq_kbd = kbd_irq;
s->irq_mouse = mouse_irq;
diff --git a/hw/input/ps2.c b/hw/input/ps2.c
index 6236711..c16df1d 100644
--- a/hw/input/ps2.c
+++ b/hw/input/ps2.c
@@ -1226,7 +1226,7 @@
void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg)
{
- PS2KbdState *s = (PS2KbdState *)g_malloc0(sizeof(PS2KbdState));
+ PS2KbdState *s = g_new0(PS2KbdState, 1);
trace_ps2_kbd_init(s);
s->common.update_irq = update_irq;
@@ -1248,7 +1248,7 @@
void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg)
{
- PS2MouseState *s = (PS2MouseState *)g_malloc0(sizeof(PS2MouseState));
+ PS2MouseState *s = g_new0(PS2MouseState, 1);
trace_ps2_mouse_init(s);
s->common.update_irq = update_irq;
diff --git a/hw/input/pxa2xx_keypad.c b/hw/input/pxa2xx_keypad.c
index 7f2f739..3dd03e8 100644
--- a/hw/input/pxa2xx_keypad.c
+++ b/hw/input/pxa2xx_keypad.c
@@ -306,7 +306,7 @@
{
PXA2xxKeyPadState *s;
- s = (PXA2xxKeyPadState *) g_malloc0(sizeof(PXA2xxKeyPadState));
+ s = g_new0(PXA2xxKeyPadState, 1);
s->irq = irq;
memory_region_init_io(&s->iomem, NULL, &pxa2xx_keypad_ops, s,
diff --git a/hw/input/tsc2005.c b/hw/input/tsc2005.c
index 55d61cc..14698ce 100644
--- a/hw/input/tsc2005.c
+++ b/hw/input/tsc2005.c
@@ -489,8 +489,7 @@
{
TSC2005State *s;
- s = (TSC2005State *)
- g_malloc0(sizeof(TSC2005State));
+ s = g_new0(TSC2005State, 1);
s->x = 400;
s->y = 240;
s->pressure = false;
diff --git a/hw/intc/riscv_aclint.c b/hw/intc/riscv_aclint.c
index f1a5d3d..e43b050 100644
--- a/hw/intc/riscv_aclint.c
+++ b/hw/intc/riscv_aclint.c
@@ -235,7 +235,7 @@
s, TYPE_RISCV_ACLINT_MTIMER, s->aperture_size);
sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mmio);
- s->timer_irqs = g_malloc(sizeof(qemu_irq) * s->num_harts);
+ s->timer_irqs = g_new(qemu_irq, s->num_harts);
qdev_init_gpio_out(dev, s->timer_irqs, s->num_harts);
/* Claim timer interrupt bits */
@@ -292,7 +292,7 @@
RISCVCPU *rvcpu = RISCV_CPU(cpu);
CPURISCVState *env = cpu ? cpu->env_ptr : NULL;
riscv_aclint_mtimer_callback *cb =
- g_malloc0(sizeof(riscv_aclint_mtimer_callback));
+ g_new0(riscv_aclint_mtimer_callback, 1);
if (!env) {
g_free(cb);
@@ -393,7 +393,7 @@
TYPE_RISCV_ACLINT_SWI, RISCV_ACLINT_SWI_SIZE);
sysbus_init_mmio(SYS_BUS_DEVICE(dev), &swi->mmio);
- swi->soft_irqs = g_malloc(sizeof(qemu_irq) * swi->num_harts);
+ swi->soft_irqs = g_new(qemu_irq, swi->num_harts);
qdev_init_gpio_out(dev, swi->soft_irqs, swi->num_harts);
/* Claim software interrupt bits */
diff --git a/hw/intc/xics.c b/hw/intc/xics.c
index 48a835e..24e6702 100644
--- a/hw/intc/xics.c
+++ b/hw/intc/xics.c
@@ -604,7 +604,7 @@
error_setg(errp, "Number of interrupts needs to be greater 0");
return;
}
- ics->irqs = g_malloc0(ics->nr_irqs * sizeof(ICSIRQState));
+ ics->irqs = g_new0(ICSIRQState, ics->nr_irqs);
qemu_register_reset(ics_reset_handler, ics);
}
diff --git a/hw/m68k/virt.c b/hw/m68k/virt.c
index bbaf630..8e63028 100644
--- a/hw/m68k/virt.c
+++ b/hw/m68k/virt.c
@@ -132,7 +132,7 @@
exit(1);
}
- reset_info = g_malloc0(sizeof(ResetInfo));
+ reset_info = g_new0(ResetInfo, 1);
/* init CPUs */
cpu = M68K_CPU(cpu_create(machine->cpu_type));
diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c
index c1b8066..c9f14e7 100644
--- a/hw/mips/fuloong2e.c
+++ b/hw/mips/fuloong2e.c
@@ -72,7 +72,7 @@
const char *initrd_filename;
} loaderparams;
-static void GCC_FMT_ATTR(3, 4) prom_set(uint32_t *prom_buf, int index,
+static void G_GNUC_PRINTF(3, 4) prom_set(uint32_t *prom_buf, int index,
const char *string, ...)
{
va_list ap;
diff --git a/hw/mips/malta.c b/hw/mips/malta.c
index 55037eb..6288511 100644
--- a/hw/mips/malta.c
+++ b/hw/mips/malta.c
@@ -995,7 +995,7 @@
}
-static void GCC_FMT_ATTR(3, 4) prom_set(uint32_t *prom_buf, int index,
+static void G_GNUC_PRINTF(3, 4) prom_set(uint32_t *prom_buf, int index,
const char *string, ...)
{
va_list ap;
diff --git a/hw/mips/mipssim.c b/hw/mips/mipssim.c
index 2325e7e..27a46bd 100644
--- a/hw/mips/mipssim.c
+++ b/hw/mips/mipssim.c
@@ -162,7 +162,7 @@
cpu = mips_cpu_create_with_clock(machine->cpu_type, cpuclk);
env = &cpu->env;
- reset_info = g_malloc0(sizeof(ResetData));
+ reset_info = g_new0(ResetData, 1);
reset_info->cpu = cpu;
reset_info->vector = env->active_tc.PC;
qemu_register_reset(main_cpu_reset, reset_info);
diff --git a/hw/misc/applesmc.c b/hw/misc/applesmc.c
index 1b9acaf..81cd6b6 100644
--- a/hw/misc/applesmc.c
+++ b/hw/misc/applesmc.c
@@ -253,7 +253,7 @@
{
struct AppleSMCData *def;
- def = g_malloc0(sizeof(struct AppleSMCData));
+ def = g_new0(struct AppleSMCData, 1);
def->key = key;
def->len = len;
def->data = data;
diff --git a/hw/misc/imx6_src.c b/hw/misc/imx6_src.c
index 79f4375..7b0e9688 100644
--- a/hw/misc/imx6_src.c
+++ b/hw/misc/imx6_src.c
@@ -151,7 +151,7 @@
return;
}
- ri = g_malloc(sizeof(struct SRCSCRResetInfo));
+ ri = g_new(struct SRCSCRResetInfo, 1);
ri->s = s;
ri->reset_bit = reset_shift;
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index 2307f4a..e7c0099 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -411,7 +411,7 @@
assert(nb_peers > old_nb_peers);
IVSHMEM_DPRINTF("bumping storage to %d peers\n", nb_peers);
- s->peers = g_realloc(s->peers, nb_peers * sizeof(Peer));
+ s->peers = g_renew(Peer, s->peers, nb_peers);
s->nb_peers = nb_peers;
for (i = old_nb_peers; i < nb_peers; i++) {
@@ -731,7 +731,7 @@
static int ivshmem_setup_interrupts(IVShmemState *s, Error **errp)
{
/* allocate QEMU callback data for receiving interrupts */
- s->msi_vectors = g_malloc0(s->vectors * sizeof(MSIVector));
+ s->msi_vectors = g_new0(MSIVector, s->vectors);
if (ivshmem_has_feature(s, IVSHMEM_MSI)) {
if (msix_init_exclusive_bar(PCI_DEVICE(s), s->vectors, 1, errp)) {
diff --git a/hw/net/rocker/rocker.h b/hw/net/rocker/rocker.h
index 412fa44..f85354d 100644
--- a/hw/net/rocker/rocker.h
+++ b/hw/net/rocker/rocker.h
@@ -30,7 +30,7 @@
fprintf(stderr, "%s ROCKER: " fmt, nowstr, ## __VA_ARGS__);\
} while (0)
#else
-static inline GCC_FMT_ATTR(1, 2) int DPRINTF(const char *fmt, ...)
+static inline G_GNUC_PRINTF(1, 2) int DPRINTF(const char *fmt, ...)
{
return 0;
}
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index 90b4fc6..6b65823 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -86,7 +86,7 @@
# define DPRINTF(fmt, ...) \
do { fprintf(stderr, "RTL8139: " fmt, ## __VA_ARGS__); } while (0)
#else
-static inline GCC_FMT_ATTR(1, 2) int DPRINTF(const char *fmt, ...)
+static inline G_GNUC_PRINTF(1, 2) int DPRINTF(const char *fmt, ...)
{
return 0;
}
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 2087516..1067e72 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1995,7 +1995,7 @@
VirtioNetRscSeg *seg;
hdr_len = chain->n->guest_hdr_len;
- seg = g_malloc(sizeof(VirtioNetRscSeg));
+ seg = g_new(VirtioNetRscSeg, 1);
seg->buf = g_malloc(hdr_len + sizeof(struct eth_header)
+ sizeof(struct ip6_header) + VIRTIO_NET_MAX_TCP_PAYLOAD);
memcpy(seg->buf, buf, size);
@@ -3443,7 +3443,7 @@
virtio_cleanup(vdev);
return;
}
- n->vqs = g_malloc0(sizeof(VirtIONetQueue) * n->max_queue_pairs);
+ n->vqs = g_new0(VirtIONetQueue, n->max_queue_pairs);
n->curr_queue_pairs = 1;
n->tx_timeout = n->net_conf.txtimer;
diff --git a/hw/nvme/ns.c b/hw/nvme/ns.c
index 8a3613d..324f53ea 100644
--- a/hw/nvme/ns.c
+++ b/hw/nvme/ns.c
@@ -268,7 +268,7 @@
nvme_ns_zoned_init_state(ns);
- id_ns_z = g_malloc0(sizeof(NvmeIdNsZoned));
+ id_ns_z = g_new0(NvmeIdNsZoned, 1);
/* MAR/MOR are zeroes-based, FFFFFFFFFh means no limit */
id_ns_z->mar = cpu_to_le32(ns->params.max_active_zones - 1);
diff --git a/hw/pci-host/pnv_phb3.c b/hw/pci-host/pnv_phb3.c
index ac801ac..6e9aa9d 100644
--- a/hw/pci-host/pnv_phb3.c
+++ b/hw/pci-host/pnv_phb3.c
@@ -946,7 +946,7 @@
}
if (ds == NULL) {
- ds = g_malloc0(sizeof(PnvPhb3DMASpace));
+ ds = g_new0(PnvPhb3DMASpace, 1);
ds->bus = bus;
ds->devfn = devfn;
ds->pe_num = PHB_INVALID_PE;
diff --git a/hw/pci-host/pnv_phb4.c b/hw/pci-host/pnv_phb4.c
index b301762..11c97e2 100644
--- a/hw/pci-host/pnv_phb4.c
+++ b/hw/pci-host/pnv_phb4.c
@@ -1466,7 +1466,7 @@
ds = pnv_phb4_dma_find(phb, bus, devfn);
if (ds == NULL) {
- ds = g_malloc0(sizeof(PnvPhb4DMASpace));
+ ds = g_new0(PnvPhb4DMASpace, 1);
ds->bus = bus;
ds->devfn = devfn;
ds->pe_num = PHB_INVALID_PE;
diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c
index 87abad6..8e3faf1 100644
--- a/hw/pci/pcie_sriov.c
+++ b/hw/pci/pcie_sriov.c
@@ -177,7 +177,7 @@
assert(sriov_cap > 0);
num_vfs = pci_get_word(dev->config + sriov_cap + PCI_SRIOV_NUM_VF);
- dev->exp.sriov_pf.vf = g_malloc(sizeof(PCIDevice *) * num_vfs);
+ dev->exp.sriov_pf.vf = g_new(PCIDevice *, num_vfs);
assert(dev->exp.sriov_pf.vf);
trace_sriov_register_vfs(dev->name, PCI_SLOT(dev->devfn),
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index 960e7ef..c7e6767 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -899,7 +899,7 @@
if (!i) {
/* Primary CPU */
struct boot_info *boot_info;
- boot_info = g_malloc0(sizeof(struct boot_info));
+ boot_info = g_new0(struct boot_info, 1);
qemu_register_reset(ppce500_cpu_reset, cpu);
env->load_info = boot_info;
} else {
diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c
index 9e99625..faa02d6 100644
--- a/hw/ppc/ppc.c
+++ b/hw/ppc/ppc.c
@@ -1063,7 +1063,7 @@
PowerPCCPU *cpu = env_archcpu(env);
ppc_tb_t *tb_env;
- tb_env = g_malloc0(sizeof(ppc_tb_t));
+ tb_env = g_new0(ppc_tb_t, 1);
env->tb_env = tb_env;
tb_env->flags = PPC_DECR_UNDERFLOW_TRIGGERED;
if (is_book3s_arch2x(env)) {
@@ -1338,8 +1338,8 @@
trace_ppc40x_timers_init(freq);
- tb_env = g_malloc0(sizeof(ppc_tb_t));
- ppc40x_timer = g_malloc0(sizeof(ppc40x_timer_t));
+ tb_env = g_new0(ppc_tb_t, 1);
+ ppc40x_timer = g_new0(ppc40x_timer_t, 1);
env->tb_env = tb_env;
tb_env->flags = PPC_DECR_UNDERFLOW_TRIGGERED;
@@ -1447,7 +1447,7 @@
{
ppc_dcr_t *dcr_env;
- dcr_env = g_malloc0(sizeof(ppc_dcr_t));
+ dcr_env = g_new0(ppc_dcr_t, 1);
dcr_env->read_error = read_error;
dcr_env->write_error = write_error;
env->dcr_env = dcr_env;
diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c
index 3ae2b36..7e1a4ac 100644
--- a/hw/ppc/ppc405_boards.c
+++ b/hw/ppc/ppc405_boards.c
@@ -130,7 +130,7 @@
ref405ep_fpga_t *fpga;
MemoryRegion *fpga_memory = g_new(MemoryRegion, 1);
- fpga = g_malloc0(sizeof(ref405ep_fpga_t));
+ fpga = g_new0(ref405ep_fpga_t, 1);
memory_region_init_io(fpga_memory, NULL, &ref405ep_fpga_ops, fpga,
"fpga", 0x00000100);
memory_region_add_subregion(sysmem, base, fpga_memory);
@@ -431,7 +431,7 @@
taihu_cpld_t *cpld;
MemoryRegion *cpld_memory = g_new(MemoryRegion, 1);
- cpld = g_malloc0(sizeof(taihu_cpld_t));
+ cpld = g_new0(taihu_cpld_t, 1);
memory_region_init_io(cpld_memory, NULL, &taihu_cpld_ops, cpld, "cpld", 0x100);
memory_region_add_subregion(sysmem, base, cpld_memory);
qemu_register_reset(&taihu_cpld_reset, cpld);
diff --git a/hw/ppc/ppc405_uc.c b/hw/ppc/ppc405_uc.c
index 8aacd27..36c8ba6 100644
--- a/hw/ppc/ppc405_uc.c
+++ b/hw/ppc/ppc405_uc.c
@@ -215,7 +215,7 @@
{
ppc4xx_plb_t *plb;
- plb = g_malloc0(sizeof(ppc4xx_plb_t));
+ plb = g_new0(ppc4xx_plb_t, 1);
ppc_dcr_register(env, PLB3A0_ACR, plb, &dcr_read_plb, &dcr_write_plb);
ppc_dcr_register(env, PLB4A0_ACR, plb, &dcr_read_plb, &dcr_write_plb);
ppc_dcr_register(env, PLB0_ACR, plb, &dcr_read_plb, &dcr_write_plb);
@@ -300,7 +300,7 @@
{
ppc4xx_pob_t *pob;
- pob = g_malloc0(sizeof(ppc4xx_pob_t));
+ pob = g_new0(ppc4xx_pob_t, 1);
ppc_dcr_register(env, POB0_BEAR, pob, &dcr_read_pob, &dcr_write_pob);
ppc_dcr_register(env, POB0_BESR0, pob, &dcr_read_pob, &dcr_write_pob);
ppc_dcr_register(env, POB0_BESR1, pob, &dcr_read_pob, &dcr_write_pob);
@@ -380,7 +380,7 @@
trace_opba_init(base);
- opba = g_malloc0(sizeof(ppc4xx_opba_t));
+ opba = g_new0(ppc4xx_opba_t, 1);
memory_region_init_io(&opba->io, NULL, &opba_ops, opba, "opba", 0x002);
memory_region_add_subregion(get_system_memory(), base, &opba->io);
qemu_register_reset(ppc4xx_opba_reset, opba);
@@ -575,7 +575,7 @@
{
ppc4xx_ebc_t *ebc;
- ebc = g_malloc0(sizeof(ppc4xx_ebc_t));
+ ebc = g_new0(ppc4xx_ebc_t, 1);
qemu_register_reset(&ebc_reset, ebc);
ppc_dcr_register(env, EBC0_CFGADDR,
ebc, &dcr_read_ebc, &dcr_write_ebc);
@@ -658,7 +658,7 @@
{
ppc405_dma_t *dma;
- dma = g_malloc0(sizeof(ppc405_dma_t));
+ dma = g_new0(ppc405_dma_t, 1);
memcpy(dma->irqs, irqs, 4 * sizeof(qemu_irq));
qemu_register_reset(&ppc405_dma_reset, dma);
ppc_dcr_register(env, DMA0_CR0,
@@ -757,7 +757,7 @@
trace_ppc405_gpio_init(base);
- gpio = g_malloc0(sizeof(ppc405_gpio_t));
+ gpio = g_new0(ppc405_gpio_t, 1);
memory_region_init_io(&gpio->io, NULL, &ppc405_gpio_ops, gpio, "pgio", 0x038);
memory_region_add_subregion(get_system_memory(), base, &gpio->io);
qemu_register_reset(&ppc405_gpio_reset, gpio);
@@ -906,7 +906,7 @@
{
ppc405_ocm_t *ocm;
- ocm = g_malloc0(sizeof(ppc405_ocm_t));
+ ocm = g_new0(ppc405_ocm_t, 1);
/* XXX: Size is 4096 or 0x04000000 */
memory_region_init_ram(&ocm->isarc_ram, NULL, "ppc405.ocm", 4 * KiB,
&error_fatal);
@@ -1148,7 +1148,7 @@
trace_ppc4xx_gpt_init(base);
- gpt = g_malloc0(sizeof(ppc4xx_gpt_t));
+ gpt = g_new0(ppc4xx_gpt_t, 1);
for (i = 0; i < 5; i++) {
gpt->irqs[i] = irqs[i];
}
@@ -1399,7 +1399,7 @@
{
ppc405ep_cpc_t *cpc;
- cpc = g_malloc0(sizeof(ppc405ep_cpc_t));
+ cpc = g_new0(ppc405ep_cpc_t, 1);
memcpy(cpc->clk_setup, clk_setup,
PPC405EP_CLK_NB * sizeof(clk_setup_t));
cpc->jtagid = 0x20267049;
diff --git a/hw/ppc/ppc4xx_devs.c b/hw/ppc/ppc4xx_devs.c
index e7d82ae..737c089 100644
--- a/hw/ppc/ppc4xx_devs.c
+++ b/hw/ppc/ppc4xx_devs.c
@@ -389,7 +389,7 @@
{
ppc4xx_sdram_t *sdram;
- sdram = g_malloc0(sizeof(ppc4xx_sdram_t));
+ sdram = g_new0(ppc4xx_sdram_t, 1);
sdram->irq = irq;
sdram->nbanks = nbanks;
sdram->ram_memories = ram_memories;
diff --git a/hw/ppc/ppc_booke.c b/hw/ppc/ppc_booke.c
index 10b6438..ca22da1 100644
--- a/hw/ppc/ppc_booke.c
+++ b/hw/ppc/ppc_booke.c
@@ -337,8 +337,8 @@
booke_timer_t *booke_timer;
int ret = 0;
- tb_env = g_malloc0(sizeof(ppc_tb_t));
- booke_timer = g_malloc0(sizeof(booke_timer_t));
+ tb_env = g_new0(ppc_tb_t, 1);
+ booke_timer = g_new0(booke_timer_t, 1);
cpu->env.tb_env = tb_env;
tb_env->flags = flags | PPC_TIMER_BOOKE | PPC_DECR_ZERO_TRIGGERED;
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 953fc65..a4372ba 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -3601,7 +3601,7 @@
*/
ds = spapr_pending_dimm_unplugs_find(spapr, dimm);
if (!ds) {
- ds = g_malloc0(sizeof(SpaprDimmState));
+ ds = g_new0(SpaprDimmState, 1);
ds->nr_lmbs = nr_lmbs;
ds->dimm = dimm;
QTAILQ_INSERT_HEAD(&spapr->pending_dimm_unplugs, ds, next);
diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c
index 630e862..4508e40 100644
--- a/hw/ppc/spapr_events.c
+++ b/hw/ppc/spapr_events.c
@@ -594,7 +594,7 @@
struct rtas_event_log_v6_hp *hp;
entry = g_new(SpaprEventLogEntry, 1);
- new_hp = g_malloc0(sizeof(struct hp_extended_log));
+ new_hp = g_new0(struct hp_extended_log, 1);
entry->extended_log = new_hp;
v6hdr = &new_hp->v6hdr;
diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index f008290..7c8bb76 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -1596,7 +1596,7 @@
return H_PARAMETER;
}
- spapr_cpu->nested_host_state = g_try_malloc(sizeof(CPUPPCState));
+ spapr_cpu->nested_host_state = g_try_new(CPUPPCState, 1);
if (!spapr_cpu->nested_host_state) {
return H_NO_MEM;
}
diff --git a/hw/ppc/spapr_numa.c b/hw/ppc/spapr_numa.c
index 4f93bde..d7c0e21 100644
--- a/hw/ppc/spapr_numa.c
+++ b/hw/ppc/spapr_numa.c
@@ -436,8 +436,7 @@
int i;
/* ibm,associativity-lookup-arrays */
- int_buf = g_malloc0((nr_nodes * max_distance_ref_points + 2) *
- sizeof(uint32_t));
+ int_buf = g_new0(uint32_t, nr_nodes * max_distance_ref_points + 2);
cur_index = int_buf;
int_buf[0] = cpu_to_be32(nr_nodes);
/* Number of entries per associativity list */
diff --git a/hw/rdma/vmw/pvrdma_dev_ring.c b/hw/rdma/vmw/pvrdma_dev_ring.c
index 4213066..598e6ad 100644
--- a/hw/rdma/vmw/pvrdma_dev_ring.c
+++ b/hw/rdma/vmw/pvrdma_dev_ring.c
@@ -41,7 +41,7 @@
qatomic_set(&ring->ring_state->cons_head, 0);
*/
ring->npages = npages;
- ring->pages = g_malloc0(npages * sizeof(void *));
+ ring->pages = g_new0(void *, npages);
for (i = 0; i < npages; i++) {
if (!tbl[i]) {
diff --git a/hw/rdma/vmw/pvrdma_qp_ops.c b/hw/rdma/vmw/pvrdma_qp_ops.c
index 8050287..bd7cbf2 100644
--- a/hw/rdma/vmw/pvrdma_qp_ops.c
+++ b/hw/rdma/vmw/pvrdma_qp_ops.c
@@ -154,7 +154,7 @@
CompHandlerCtx *comp_ctx;
/* Prepare CQE */
- comp_ctx = g_malloc(sizeof(CompHandlerCtx));
+ comp_ctx = g_new(CompHandlerCtx, 1);
comp_ctx->dev = dev;
comp_ctx->cq_handle = qp->send_cq_handle;
comp_ctx->cqe.wr_id = wqe->hdr.wr_id;
@@ -217,7 +217,7 @@
CompHandlerCtx *comp_ctx;
/* Prepare CQE */
- comp_ctx = g_malloc(sizeof(CompHandlerCtx));
+ comp_ctx = g_new(CompHandlerCtx, 1);
comp_ctx->dev = dev;
comp_ctx->cq_handle = qp->recv_cq_handle;
comp_ctx->cqe.wr_id = wqe->hdr.wr_id;
@@ -259,7 +259,7 @@
CompHandlerCtx *comp_ctx;
/* Prepare CQE */
- comp_ctx = g_malloc(sizeof(CompHandlerCtx));
+ comp_ctx = g_new(CompHandlerCtx, 1);
comp_ctx->dev = dev;
comp_ctx->cq_handle = srq->recv_cq_handle;
comp_ctx->cqe.wr_id = wqe->hdr.wr_id;
diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
index 7275941..39fc4f1 100644
--- a/hw/sh4/r2d.c
+++ b/hw/sh4/r2d.c
@@ -190,7 +190,7 @@
{
r2d_fpga_t *s;
- s = g_malloc0(sizeof(r2d_fpga_t));
+ s = g_new0(r2d_fpga_t, 1);
s->irl = irl;
@@ -248,7 +248,7 @@
cpu = SUPERH_CPU(cpu_create(machine->cpu_type));
env = &cpu->env;
- reset_info = g_malloc0(sizeof(ResetData));
+ reset_info = g_new0(ResetData, 1);
reset_info->cpu = cpu;
reset_info->vector = env->pc;
qemu_register_reset(main_cpu_reset, reset_info);
diff --git a/hw/sh4/sh7750.c b/hw/sh4/sh7750.c
index 43dfb64..c77792d 100644
--- a/hw/sh4/sh7750.c
+++ b/hw/sh4/sh7750.c
@@ -770,7 +770,7 @@
SysBusDevice *sb;
MemoryRegion *mr, *alias;
- s = g_malloc0(sizeof(SH7750State));
+ s = g_new0(SH7750State, 1);
s->cpu = cpu;
s->periph_freq = 60000000; /* 60MHz */
memory_region_init_io(&s->iomem, NULL, &sh7750_mem_ops, s,
diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c
index 7b4dec1..a9f2496 100644
--- a/hw/sparc/leon3.c
+++ b/hw/sparc/leon3.c
@@ -241,7 +241,7 @@
cpu_sparc_set_id(env, 0);
/* Reset data */
- reset_info = g_malloc0(sizeof(ResetData));
+ reset_info = g_new0(ResetData, 1);
reset_info->cpu = cpu;
reset_info->sp = LEON3_RAM_OFFSET + ram_size;
qemu_register_reset(main_cpu_reset, reset_info);
diff --git a/hw/sparc64/sparc64.c b/hw/sparc64/sparc64.c
index 8654e95..72f0849 100644
--- a/hw/sparc64/sparc64.c
+++ b/hw/sparc64/sparc64.c
@@ -81,7 +81,7 @@
QEMUBHFunc *cb, uint32_t frequency,
uint64_t disabled_mask, uint64_t npt_mask)
{
- CPUTimer *timer = g_malloc0(sizeof(CPUTimer));
+ CPUTimer *timer = g_new0(CPUTimer, 1);
timer->name = name;
timer->frequency = frequency;
@@ -288,7 +288,7 @@
hstick_frequency, TICK_INT_DIS,
TICK_NPT_MASK);
- reset_info = g_malloc0(sizeof(ResetData));
+ reset_info = g_new0(ResetData, 1);
reset_info->cpu = cpu;
reset_info->prom_addr = prom_addr;
qemu_register_reset(main_cpu_reset, reset_info);
diff --git a/hw/timer/arm_timer.c b/hw/timer/arm_timer.c
index 15caff0..84cf272 100644
--- a/hw/timer/arm_timer.c
+++ b/hw/timer/arm_timer.c
@@ -176,7 +176,7 @@
{
arm_timer_state *s;
- s = (arm_timer_state *)g_malloc0(sizeof(arm_timer_state));
+ s = g_new0(arm_timer_state, 1);
s->freq = freq;
s->control = TIMER_CTRL_IE;
diff --git a/hw/timer/slavio_timer.c b/hw/timer/slavio_timer.c
index 03e33fc..90fdce4 100644
--- a/hw/timer/slavio_timer.c
+++ b/hw/timer/slavio_timer.c
@@ -400,7 +400,7 @@
uint64_t size;
char timer_name[20];
- tc = g_malloc0(sizeof(TimerContext));
+ tc = g_new0(TimerContext, 1);
tc->s = s;
tc->timer_index = i;
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index d07a4e9..67a183f 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -1532,8 +1532,8 @@
int ret;
Error *err = NULL;
- vdev->msix->pending = g_malloc0(BITS_TO_LONGS(vdev->msix->entries) *
- sizeof(unsigned long));
+ vdev->msix->pending = g_new0(unsigned long,
+ BITS_TO_LONGS(vdev->msix->entries));
ret = msix_init(&vdev->pdev, vdev->msix->entries,
vdev->bars[vdev->msix->table_bar].mr,
vdev->msix->table_bar, vdev->msix->table_offset,
diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c
index f8f08a0..5af73f9 100644
--- a/hw/vfio/platform.c
+++ b/hw/vfio/platform.c
@@ -71,7 +71,7 @@
sysbus_init_irq(sbdev, &intp->qemuirq);
/* Get an eventfd for trigger */
- intp->interrupt = g_malloc0(sizeof(EventNotifier));
+ intp->interrupt = g_new0(EventNotifier, 1);
ret = event_notifier_init(intp->interrupt, 0);
if (ret) {
g_free(intp->interrupt);
@@ -82,7 +82,7 @@
}
if (vfio_irq_is_automasked(intp)) {
/* Get an eventfd for resample/unmask */
- intp->unmask = g_malloc0(sizeof(EventNotifier));
+ intp->unmask = g_new0(EventNotifier, 1);
ret = event_notifier_init(intp->unmask, 0);
if (ret) {
g_free(intp->interrupt);
diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c
index 54f9bbb..dcd80b9 100644
--- a/hw/virtio/virtio-crypto.c
+++ b/hw/virtio/virtio-crypto.c
@@ -812,7 +812,7 @@
virtio_init(vdev, "virtio-crypto", VIRTIO_ID_CRYPTO, vcrypto->config_size);
vcrypto->curr_queues = 1;
- vcrypto->vqs = g_malloc0(sizeof(VirtIOCryptoQueue) * vcrypto->max_queues);
+ vcrypto->vqs = g_new0(VirtIOCryptoQueue, vcrypto->max_queues);
for (i = 0; i < vcrypto->max_queues; i++) {
vcrypto->vqs[i].dataq =
virtio_add_queue(vdev, 1024, virtio_crypto_handle_dataq_bh);
diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
index 239fe97..664cbd9 100644
--- a/hw/virtio/virtio-iommu.c
+++ b/hw/virtio/virtio-iommu.c
@@ -316,7 +316,7 @@
char *name = g_strdup_printf("%s-%d-%d",
TYPE_VIRTIO_IOMMU_MEMORY_REGION,
mr_index++, devfn);
- sdev = sbus->pbdev[devfn] = g_malloc0(sizeof(IOMMUDevice));
+ sdev = sbus->pbdev[devfn] = g_new0(IOMMUDevice, 1);
sdev->viommu = s;
sdev->bus = bus;
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 9e8f51d..9d637e0 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2380,8 +2380,7 @@
vdev->vq[i].vring.num_default = queue_size;
vdev->vq[i].vring.align = VIRTIO_PCI_VRING_ALIGN;
vdev->vq[i].handle_output = handle_output;
- vdev->vq[i].used_elems = g_malloc0(sizeof(VirtQueueElement) *
- queue_size);
+ vdev->vq[i].used_elems = g_new0(VirtQueueElement, queue_size);
return &vdev->vq[i];
}
@@ -3228,7 +3227,7 @@
qatomic_set(&vdev->isr, 0);
vdev->queue_sel = 0;
vdev->config_vector = VIRTIO_NO_VECTOR;
- vdev->vq = g_malloc0(sizeof(VirtQueue) * VIRTIO_QUEUE_MAX);
+ vdev->vq = g_new0(VirtQueue, VIRTIO_QUEUE_MAX);
vdev->vm_running = runstate_is_running();
vdev->broken = false;
for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
@@ -3580,7 +3579,7 @@
vdev->bus_name = g_strdup(bus_name);
}
-void GCC_FMT_ATTR(2, 3) virtio_error(VirtIODevice *vdev, const char *fmt, ...)
+void G_GNUC_PRINTF(2, 3) virtio_error(VirtIODevice *vdev, const char *fmt, ...)
{
va_list ap;
diff --git a/hw/xen/xen_pt.h b/hw/xen/xen_pt.h
index c74c467..6b8e13c 100644
--- a/hw/xen/xen_pt.h
+++ b/hw/xen/xen_pt.h
@@ -9,7 +9,7 @@
bool xen_igd_gfx_pt_enabled(void);
void xen_igd_gfx_pt_set(bool value, Error **errp);
-void xen_pt_log(const PCIDevice *d, const char *f, ...) GCC_FMT_ATTR(2, 3);
+void xen_pt_log(const PCIDevice *d, const char *f, ...) G_GNUC_PRINTF(2, 3);
#define XEN_PT_ERR(d, _f, _a...) xen_pt_log(d, "%s: Error: "_f, __func__, ##_a)
diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c
index 17f087b..c1e004e 100644
--- a/hw/xtensa/xtfpga.c
+++ b/hw/xtensa/xtfpga.c
@@ -126,7 +126,7 @@
static XtfpgaFpgaState *xtfpga_fpga_init(MemoryRegion *address_space,
hwaddr base, uint32_t freq)
{
- XtfpgaFpgaState *s = g_malloc(sizeof(XtfpgaFpgaState));
+ XtfpgaFpgaState *s = g_new(XtfpgaFpgaState, 1);
memory_region_init_io(&s->iomem, NULL, &xtfpga_fpga_ops, s,
"xtfpga.fpga", 0x10000);
diff --git a/include/chardev/char-fe.h b/include/chardev/char-fe.h
index 867ef1b..8c420fa 100644
--- a/include/chardev/char-fe.h
+++ b/include/chardev/char-fe.h
@@ -172,7 +172,7 @@
* Chardev.
*/
void qemu_chr_fe_printf(CharBackend *be, const char *fmt, ...)
- GCC_FMT_ATTR(2, 3);
+ G_GNUC_PRINTF(2, 3);
typedef gboolean (*FEWatchFunc)(void *do_not_use, GIOCondition condition, void *data);
diff --git a/include/disas/dis-asm.h b/include/disas/dis-asm.h
index 102a1e7..fadf6a6 100644
--- a/include/disas/dis-asm.h
+++ b/include/disas/dis-asm.h
@@ -269,7 +269,7 @@
} asymbol;
typedef int (*fprintf_function)(FILE *f, const char *fmt, ...)
- GCC_FMT_ATTR(2, 3);
+ G_GNUC_PRINTF(2, 3);
enum dis_insn_type {
dis_noninsn, /* Not a valid instruction */
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index 8346003..d1fb085 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -289,7 +289,7 @@
void aml_append(Aml *parent_ctx, Aml *child);
/* non block AML object primitives */
-Aml *aml_name(const char *name_format, ...) GCC_FMT_ATTR(1, 2);
+Aml *aml_name(const char *name_format, ...) G_GNUC_PRINTF(1, 2);
Aml *aml_name_decl(const char *name, Aml *val);
Aml *aml_debug(void);
Aml *aml_return(Aml *val);
@@ -344,13 +344,13 @@
Aml *aml_named_field(const char *name, unsigned length);
Aml *aml_reserved_field(unsigned length);
Aml *aml_local(int num);
-Aml *aml_string(const char *name_format, ...) GCC_FMT_ATTR(1, 2);
+Aml *aml_string(const char *name_format, ...) G_GNUC_PRINTF(1, 2);
Aml *aml_lnot(Aml *arg);
Aml *aml_equal(Aml *arg1, Aml *arg2);
Aml *aml_lgreater(Aml *arg1, Aml *arg2);
Aml *aml_lgreater_equal(Aml *arg1, Aml *arg2);
Aml *aml_processor(uint8_t proc_id, uint32_t pblk_addr, uint8_t pblk_len,
- const char *name_format, ...) GCC_FMT_ATTR(4, 5);
+ const char *name_format, ...) G_GNUC_PRINTF(4, 5);
Aml *aml_eisaid(const char *str);
Aml *aml_word_bus_number(AmlMinFixed min_fixed, AmlMaxFixed max_fixed,
AmlDecode dec, uint16_t addr_gran,
@@ -384,8 +384,8 @@
Aml *aml_i2c_serial_bus_device(uint16_t address, const char *resource_source);
/* Block AML object primitives */
-Aml *aml_scope(const char *name_format, ...) GCC_FMT_ATTR(1, 2);
-Aml *aml_device(const char *name_format, ...) GCC_FMT_ATTR(1, 2);
+Aml *aml_scope(const char *name_format, ...) G_GNUC_PRINTF(1, 2);
+Aml *aml_device(const char *name_format, ...) G_GNUC_PRINTF(1, 2);
Aml *aml_method(const char *name, int arg_count, AmlSerializeFlag sflag);
Aml *aml_if(Aml *predicate);
Aml *aml_else(void);
@@ -460,7 +460,7 @@
int
build_append_named_dword(GArray *array, const char *name_format, ...)
-GCC_FMT_ATTR(2, 3);
+G_GNUC_PRINTF(2, 3);
void build_append_gas(GArray *table, AmlAddressSpace as,
uint8_t bit_width, uint8_t bit_offset,
diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h
index 0efc615..1369736 100644
--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -1016,7 +1016,7 @@
AddressSpace *cpu_get_address_space(CPUState *cpu, int asidx);
void QEMU_NORETURN cpu_abort(CPUState *cpu, const char *fmt, ...)
- GCC_FMT_ATTR(2, 3);
+ G_GNUC_PRINTF(2, 3);
/* $(top_srcdir)/cpu.c */
void cpu_class_init_props(DeviceClass *dc);
diff --git a/include/hw/hw.h b/include/hw/hw.h
index fc5301f..34377f5 100644
--- a/include/hw/hw.h
+++ b/include/hw/hw.h
@@ -5,6 +5,6 @@
#error Cannot include hw/hw.h from user emulation
#endif
-void QEMU_NORETURN hw_error(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
+void QEMU_NORETURN hw_error(const char *fmt, ...) G_GNUC_PRINTF(1, 2);
#endif
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index f095637..b31c450 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -169,7 +169,7 @@
uint16_t device_id, size_t config_size);
void virtio_cleanup(VirtIODevice *vdev);
-void virtio_error(VirtIODevice *vdev, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
+void virtio_error(VirtIODevice *vdev, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
/* Set the child bus name. */
void virtio_device_set_child_bus_name(VirtIODevice *vdev, char *bus_name);
diff --git a/include/hw/xen/xen-bus-helper.h b/include/hw/xen/xen-bus-helper.h
index 4c0f747..629a904 100644
--- a/include/hw/xen/xen-bus-helper.h
+++ b/include/hw/xen/xen-bus-helper.h
@@ -22,11 +22,11 @@
void xs_node_vprintf(struct xs_handle *xsh, xs_transaction_t tid,
const char *node, const char *key, Error **errp,
const char *fmt, va_list ap)
- GCC_FMT_ATTR(6, 0);
+ G_GNUC_PRINTF(6, 0);
void xs_node_printf(struct xs_handle *xsh, xs_transaction_t tid,
const char *node, const char *key, Error **errp,
const char *fmt, ...)
- GCC_FMT_ATTR(6, 7);
+ G_GNUC_PRINTF(6, 7);
/* Read from node/key unless node is empty, in which case read from key */
int xs_node_vscanf(struct xs_handle *xsh, xs_transaction_t tid,
diff --git a/include/hw/xen/xen-bus.h b/include/hw/xen/xen-bus.h
index 6bdbf3f..713e763 100644
--- a/include/hw/xen/xen-bus.h
+++ b/include/hw/xen/xen-bus.h
@@ -88,10 +88,10 @@
void xen_device_backend_printf(XenDevice *xendev, const char *key,
const char *fmt, ...)
- GCC_FMT_ATTR(3, 4);
+ G_GNUC_PRINTF(3, 4);
void xen_device_frontend_printf(XenDevice *xendev, const char *key,
const char *fmt, ...)
- GCC_FMT_ATTR(3, 4);
+ G_GNUC_PRINTF(3, 4);
int xen_device_frontend_scanf(XenDevice *xendev, const char *key,
const char *fmt, ...);
diff --git a/include/hw/xen/xen_common.h b/include/hw/xen/xen_common.h
index a8118b4..179741f 100644
--- a/include/hw/xen/xen_common.h
+++ b/include/hw/xen/xen_common.h
@@ -358,7 +358,7 @@
void destroy_hvm_domain(bool reboot);
/* shutdown/destroy current domain because of an error */
-void xen_shutdown_fatal_error(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
+void xen_shutdown_fatal_error(const char *fmt, ...) G_GNUC_PRINTF(1, 2);
#ifdef HVM_PARAM_VMPORT_REGS_PFN
static inline int xen_get_vmport_regs_pfn(xc_interface *xc, domid_t dom,
diff --git a/include/hw/xen/xen_pvdev.h b/include/hw/xen/xen_pvdev.h
index 83e5174..7cd4bc2 100644
--- a/include/hw/xen/xen_pvdev.h
+++ b/include/hw/xen/xen_pvdev.h
@@ -76,6 +76,6 @@
int xen_pv_send_notify(struct XenLegacyDevice *xendev);
void xen_pv_printf(struct XenLegacyDevice *xendev, int msg_level,
- const char *fmt, ...) GCC_FMT_ATTR(3, 4);
+ const char *fmt, ...) G_GNUC_PRINTF(3, 4);
#endif /* QEMU_HW_XEN_PVDEV_H */
diff --git a/include/monitor/monitor.h b/include/monitor/monitor.h
index 12d395d..cc4cc6c 100644
--- a/include/monitor/monitor.h
+++ b/include/monitor/monitor.h
@@ -32,8 +32,8 @@
int monitor_fd_param(Monitor *mon, const char *fdname, Error **errp);
int monitor_vprintf(Monitor *mon, const char *fmt, va_list ap)
- GCC_FMT_ATTR(2, 0);
-int monitor_printf(Monitor *mon, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
+ G_GNUC_PRINTF(2, 0);
+int monitor_printf(Monitor *mon, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
void monitor_flush(Monitor *mon);
int monitor_set_cpu(Monitor *mon, int cpu_index);
int monitor_get_cpu_index(Monitor *mon);
diff --git a/include/qapi/error.h b/include/qapi/error.h
index 4a9260b..d798fae 100644
--- a/include/qapi/error.h
+++ b/include/qapi/error.h
@@ -320,7 +320,7 @@
void error_setg_internal(Error **errp,
const char *src, int line, const char *func,
const char *fmt, ...)
- GCC_FMT_ATTR(5, 6);
+ G_GNUC_PRINTF(5, 6);
/*
* Just like error_setg(), with @os_error info added to the message.
@@ -336,7 +336,7 @@
void error_setg_errno_internal(Error **errp,
const char *fname, int line, const char *func,
int os_error, const char *fmt, ...)
- GCC_FMT_ATTR(6, 7);
+ G_GNUC_PRINTF(6, 7);
#ifdef _WIN32
/*
@@ -350,7 +350,7 @@
void error_setg_win32_internal(Error **errp,
const char *src, int line, const char *func,
int win32_err, const char *fmt, ...)
- GCC_FMT_ATTR(6, 7);
+ G_GNUC_PRINTF(6, 7);
#endif
/*
@@ -383,21 +383,21 @@
*/
void error_propagate_prepend(Error **dst_errp, Error *local_err,
const char *fmt, ...)
- GCC_FMT_ATTR(3, 4);
+ G_GNUC_PRINTF(3, 4);
/*
* Prepend some text to @errp's human-readable error message.
* The text is made by formatting @fmt, @ap like vprintf().
*/
void error_vprepend(Error *const *errp, const char *fmt, va_list ap)
- GCC_FMT_ATTR(2, 0);
+ G_GNUC_PRINTF(2, 0);
/*
* Prepend some text to @errp's human-readable error message.
* The text is made by formatting @fmt, ... like printf().
*/
void error_prepend(Error *const *errp, const char *fmt, ...)
- GCC_FMT_ATTR(2, 3);
+ G_GNUC_PRINTF(2, 3);
/*
* Append a printf-style human-readable explanation to an existing error.
@@ -414,7 +414,7 @@
* newline.
*/
void error_append_hint(Error *const *errp, const char *fmt, ...)
- GCC_FMT_ATTR(2, 3);
+ G_GNUC_PRINTF(2, 3);
/*
* Convenience function to report open() failure.
@@ -458,13 +458,13 @@
* Convenience function to error_prepend(), warn_report() and free @err.
*/
void warn_reportf_err(Error *err, const char *fmt, ...)
- GCC_FMT_ATTR(2, 3);
+ G_GNUC_PRINTF(2, 3);
/*
* Convenience function to error_prepend(), error_report() and free @err.
*/
void error_reportf_err(Error *err, const char *fmt, ...)
- GCC_FMT_ATTR(2, 3);
+ G_GNUC_PRINTF(2, 3);
/*
* Just like error_setg(), except you get to specify the error class.
@@ -477,7 +477,7 @@
void error_set_internal(Error **errp,
const char *src, int line, const char *func,
ErrorClass err_class, const char *fmt, ...)
- GCC_FMT_ATTR(6, 7);
+ G_GNUC_PRINTF(6, 7);
/*
* Make @errp parameter easier to use regardless of argument value
diff --git a/include/qapi/qmp/qjson.h b/include/qapi/qmp/qjson.h
index 593b40b..7bd8d2d 100644
--- a/include/qapi/qmp/qjson.h
+++ b/include/qapi/qmp/qjson.h
@@ -17,13 +17,13 @@
QObject *qobject_from_json(const char *string, Error **errp);
QObject *qobject_from_vjsonf_nofail(const char *string, va_list ap)
- GCC_FMT_ATTR(1, 0);
+ G_GNUC_PRINTF(1, 0);
QObject *qobject_from_jsonf_nofail(const char *string, ...)
- GCC_FMT_ATTR(1, 2);
+ G_GNUC_PRINTF(1, 2);
QDict *qdict_from_vjsonf_nofail(const char *string, va_list ap)
- GCC_FMT_ATTR(1, 0);
+ G_GNUC_PRINTF(1, 0);
QDict *qdict_from_jsonf_nofail(const char *string, ...)
- GCC_FMT_ATTR(1, 2);
+ G_GNUC_PRINTF(1, 2);
GString *qobject_to_json(const QObject *obj);
GString *qobject_to_json_pretty(const QObject *obj, bool pretty);
diff --git a/include/qemu-common.h b/include/qemu-common.h
index 8c0d9ab..f0fe07c 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -27,7 +27,7 @@
#endif
ssize_t qemu_write_full(int fd, const void *buf, size_t count)
- QEMU_WARN_UNUSED_RESULT;
+ G_GNUC_WARN_UNUSED_RESULT;
#ifndef _WIN32
int qemu_pipe(int pipefd[2]);
@@ -35,25 +35,6 @@
int qemu_openpty_raw(int *aslave, char *pty_name);
#endif
-#ifdef _WIN32
-/* MinGW needs type casts for the 'buf' and 'optval' arguments. */
-#define qemu_getsockopt(sockfd, level, optname, optval, optlen) \
- getsockopt(sockfd, level, optname, (void *)optval, optlen)
-#define qemu_setsockopt(sockfd, level, optname, optval, optlen) \
- setsockopt(sockfd, level, optname, (const void *)optval, optlen)
-#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, (void *)buf, len, flags)
-#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
- sendto(sockfd, (const void *)buf, len, flags, destaddr, addrlen)
-#else
-#define qemu_getsockopt(sockfd, level, optname, optval, optlen) \
- getsockopt(sockfd, level, optname, optval, optlen)
-#define qemu_setsockopt(sockfd, level, optname, optval, optlen) \
- setsockopt(sockfd, level, optname, optval, optlen)
-#define qemu_recv(sockfd, buf, len, flags) recv(sockfd, buf, len, flags)
-#define qemu_sendto(sockfd, buf, len, flags, destaddr, addrlen) \
- sendto(sockfd, buf, len, flags, destaddr, addrlen)
-#endif
-
void cpu_exec_init_all(void);
void cpu_exec_step_atomic(CPUState *cpu);
@@ -127,7 +108,6 @@
*/
int parse_debug_env(const char *name, int max, int initial);
-const char *qemu_ether_ntoa(const MACAddr *mac);
void page_size_init(void);
/* returns non-zero if dump is in progress, otherwise zero is
diff --git a/include/qemu/buffer.h b/include/qemu/buffer.h
index d34d2c8..e95dfd6 100644
--- a/include/qemu/buffer.h
+++ b/include/qemu/buffer.h
@@ -49,7 +49,7 @@
* to identify in debug traces.
*/
void buffer_init(Buffer *buffer, const char *name, ...)
- GCC_FMT_ATTR(2, 3);
+ G_GNUC_PRINTF(2, 3);
/**
* buffer_shrink:
diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h
index 3baa5e3..d935985 100644
--- a/include/qemu/compiler.h
+++ b/include/qemu/compiler.h
@@ -7,6 +7,11 @@
#ifndef COMPILER_H
#define COMPILER_H
+#define HOST_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
+
+/* HOST_LONG_BITS is the size of a native pointer in bits. */
+#define HOST_LONG_BITS (__SIZEOF_POINTER__ * 8)
+
#if defined __clang_analyzer__ || defined __COVERITY__
#define QEMU_STATIC_ANALYSIS 1
#endif
@@ -19,10 +24,6 @@
#define QEMU_NORETURN __attribute__ ((__noreturn__))
-#define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
-
-#define QEMU_SENTINEL __attribute__((sentinel))
-
#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__))
# define QEMU_PACKED __attribute__((gcc_struct, packed))
#else
@@ -79,19 +80,12 @@
#define QEMU_BUILD_BUG_ON_ZERO(x) (sizeof(QEMU_BUILD_BUG_ON_STRUCT(x)) - \
sizeof(QEMU_BUILD_BUG_ON_STRUCT(x)))
-#if defined(__clang__)
-/* clang doesn't support gnu_printf, so use printf. */
-# define GCC_FMT_ATTR(n, m) __attribute__((format(printf, n, m)))
-#else
-/* Use gnu_printf (qemu uses standard format strings). */
-# define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
-# if defined(_WIN32)
+#if !defined(__clang__) && defined(_WIN32)
/*
* Map __printf__ to __gnu_printf__ because we want standard format strings even
* when MinGW or GLib include files use __printf__.
*/
-# define __printf__ __gnu_printf__
-# endif
+# define __printf__ __gnu_printf__
#endif
#ifndef __has_warning
diff --git a/include/qemu/error-report.h b/include/qemu/error-report.h
index 9d197da..b6f45e6 100644
--- a/include/qemu/error-report.h
+++ b/include/qemu/error-report.h
@@ -30,23 +30,23 @@
void loc_set_cmdline(char **argv, int idx, int cnt);
void loc_set_file(const char *fname, int lno);
-int error_vprintf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0);
-int error_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
-int error_vprintf_unless_qmp(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0);
-int error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
+int error_vprintf(const char *fmt, va_list ap) G_GNUC_PRINTF(1, 0);
+int error_printf(const char *fmt, ...) G_GNUC_PRINTF(1, 2);
+int error_vprintf_unless_qmp(const char *fmt, va_list ap) G_GNUC_PRINTF(1, 0);
+int error_printf_unless_qmp(const char *fmt, ...) G_GNUC_PRINTF(1, 2);
-void error_vreport(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0);
-void warn_vreport(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0);
-void info_vreport(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0);
+void error_vreport(const char *fmt, va_list ap) G_GNUC_PRINTF(1, 0);
+void warn_vreport(const char *fmt, va_list ap) G_GNUC_PRINTF(1, 0);
+void info_vreport(const char *fmt, va_list ap) G_GNUC_PRINTF(1, 0);
-void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
-void warn_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
-void info_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
+void error_report(const char *fmt, ...) G_GNUC_PRINTF(1, 2);
+void warn_report(const char *fmt, ...) G_GNUC_PRINTF(1, 2);
+void info_report(const char *fmt, ...) G_GNUC_PRINTF(1, 2);
bool error_report_once_cond(bool *printed, const char *fmt, ...)
- GCC_FMT_ATTR(2, 3);
+ G_GNUC_PRINTF(2, 3);
bool warn_report_once_cond(bool *printed, const char *fmt, ...)
- GCC_FMT_ATTR(2, 3);
+ G_GNUC_PRINTF(2, 3);
void error_init(const char *argv0);
@@ -72,8 +72,6 @@
fmt, ##__VA_ARGS__); \
})
-const char *error_get_progname(void);
-
extern bool message_with_timestamp;
extern bool error_with_guestname;
extern const char *error_guest_name;
diff --git a/include/qemu/log-for-trace.h b/include/qemu/log-for-trace.h
index 2f0a5b0..5e41517 100644
--- a/include/qemu/log-for-trace.h
+++ b/include/qemu/log-for-trace.h
@@ -30,6 +30,6 @@
}
/* main logging function */
-int GCC_FMT_ATTR(1, 2) qemu_log(const char *fmt, ...);
+int G_GNUC_PRINTF(1, 2) qemu_log(const char *fmt, ...);
#endif
diff --git a/include/qemu/log.h b/include/qemu/log.h
index 9b80660..5739c7e 100644
--- a/include/qemu/log.h
+++ b/include/qemu/log.h
@@ -96,7 +96,7 @@
/* vfprintf-like logging function
*/
-static inline void GCC_FMT_ATTR(1, 0)
+static inline void G_GNUC_PRINTF(1, 0)
qemu_log_vprintf(const char *fmt, va_list va)
{
QemuLogFile *logfile;
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index f2274b2..9f06bf5 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -244,15 +244,6 @@
#define TIME_MAX TYPE_MAXIMUM(time_t)
#endif
-/* HOST_LONG_BITS is the size of a native pointer in bits. */
-#if UINTPTR_MAX == UINT32_MAX
-# define HOST_LONG_BITS 32
-#elif UINTPTR_MAX == UINT64_MAX
-# define HOST_LONG_BITS 64
-#else
-# error Unknown pointer size
-#endif
-
/* Mac OSX has a <stdint.h> bug that incorrectly defines SIZE_MAX with
* the wrong type. Our replacement isn't usable in preprocessor
* expressions, but it is sufficient for our needs. */
diff --git a/include/qemu/qemu-print.h b/include/qemu/qemu-print.h
index 40b5962..1b709206 100644
--- a/include/qemu/qemu-print.h
+++ b/include/qemu/qemu-print.h
@@ -13,11 +13,11 @@
#ifndef QEMU_PRINT_H
#define QEMU_PRINT_H
-int qemu_vprintf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0);
-int qemu_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
+int qemu_vprintf(const char *fmt, va_list ap) G_GNUC_PRINTF(1, 0);
+int qemu_printf(const char *fmt, ...) G_GNUC_PRINTF(1, 2);
int qemu_vfprintf(FILE *stream, const char *fmt, va_list ap)
- GCC_FMT_ATTR(2, 0);
-int qemu_fprintf(FILE *stream, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
+ G_GNUC_PRINTF(2, 0);
+int qemu_fprintf(FILE *stream, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
#endif
diff --git a/include/qemu/range.h b/include/qemu/range.h
index f62b363..7e2b1cc 100644
--- a/include/qemu/range.h
+++ b/include/qemu/range.h
@@ -114,8 +114,8 @@
* @size may be 0. If the range would overflow, returns -ERANGE, otherwise
* 0.
*/
-static inline int QEMU_WARN_UNUSED_RESULT range_init(Range *range, uint64_t lob,
- uint64_t size)
+G_GNUC_WARN_UNUSED_RESULT
+static inline int range_init(Range *range, uint64_t lob, uint64_t size)
{
if (lob + size < lob) {
return -ERANGE;
diff --git a/include/qemu/readline.h b/include/qemu/readline.h
index e812583..622aa45 100644
--- a/include/qemu/readline.h
+++ b/include/qemu/readline.h
@@ -5,7 +5,7 @@
#define READLINE_MAX_CMDS 64
#define READLINE_MAX_COMPLETIONS 256
-typedef void GCC_FMT_ATTR(2, 3) ReadLinePrintfFunc(void *opaque,
+typedef void G_GNUC_PRINTF(2, 3) ReadLinePrintfFunc(void *opaque,
const char *fmt, ...);
typedef void ReadLineFlushFunc(void *opaque);
typedef void ReadLineFunc(void *opaque, const char *str,
diff --git a/include/qemu/timer.h b/include/qemu/timer.h
index 88ef114..ee071e0 100644
--- a/include/qemu/timer.h
+++ b/include/qemu/timer.h
@@ -520,7 +520,7 @@
int scale, int attributes,
QEMUTimerCB *cb, void *opaque)
{
- QEMUTimer *ts = g_malloc0(sizeof(QEMUTimer));
+ QEMUTimer *ts = g_new0(QEMUTimer, 1);
timer_init_full(ts, timer_list_group, type, scale, attributes, cb, opaque);
return ts;
}
diff --git a/include/qom/object.h b/include/qom/object.h
index fae096f..5f3d5b5 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -616,7 +616,7 @@
Object *parent,
const char *id,
Error **errp,
- ...) QEMU_SENTINEL;
+ ...) G_GNUC_NULL_TERMINATED;
/**
* object_new_with_propv:
@@ -676,7 +676,7 @@
*
* Returns: %true on success, %false on error.
*/
-bool object_set_props(Object *obj, Error **errp, ...) QEMU_SENTINEL;
+bool object_set_props(Object *obj, Error **errp, ...) G_GNUC_NULL_TERMINATED;
/**
* object_set_propv:
@@ -728,7 +728,7 @@
bool object_initialize_child_with_props(Object *parentobj,
const char *propname,
void *childobj, size_t size, const char *type,
- Error **errp, ...) QEMU_SENTINEL;
+ Error **errp, ...) G_GNUC_NULL_TERMINATED;
/**
* object_initialize_child_with_propsv:
diff --git a/io/channel-socket.c b/io/channel-socket.c
index 459922c..7a8d9f6 100644
--- a/io/channel-socket.c
+++ b/io/channel-socket.c
@@ -681,9 +681,9 @@
QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(ioc);
int v = enabled ? 0 : 1;
- qemu_setsockopt(sioc->fd,
- IPPROTO_TCP, TCP_NODELAY,
- &v, sizeof(v));
+ setsockopt(sioc->fd,
+ IPPROTO_TCP, TCP_NODELAY,
+ &v, sizeof(v));
}
diff --git a/io/channel-websock.c b/io/channel-websock.c
index 70889bb..55145a6 100644
--- a/io/channel-websock.c
+++ b/io/channel-websock.c
@@ -157,7 +157,7 @@
QIO_CHANNEL_WEBSOCK_OPCODE_PONG = 0xA
};
-static void GCC_FMT_ATTR(2, 3)
+static void G_GNUC_PRINTF(2, 3)
qio_channel_websock_handshake_send_res(QIOChannelWebsock *ioc,
const char *resmsg,
...)
diff --git a/linux-user/include/host/ppc/host-signal.h b/linux-user/include/host/ppc/host-signal.h
deleted file mode 100644
index b80384d..0000000
--- a/linux-user/include/host/ppc/host-signal.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * host-signal.h: signal info dependent on the host architecture
- *
- * Copyright (c) 2003-2005 Fabrice Bellard
- * Copyright (c) 2021 Linaro Limited
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING file in the top-level directory.
- */
-
-#ifndef PPC_HOST_SIGNAL_H
-#define PPC_HOST_SIGNAL_H
-
-/* The third argument to a SA_SIGINFO handler is ucontext_t. */
-typedef ucontext_t host_sigcontext;
-
-static inline uintptr_t host_signal_pc(host_sigcontext *uc)
-{
- return uc->uc_mcontext.regs->nip;
-}
-
-static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
-{
- uc->uc_mcontext.regs->nip = pc;
-}
-
-static inline void *host_signal_mask(host_sigcontext *uc)
-{
- return &uc->uc_sigmask;
-}
-
-static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
-{
- return uc->uc_mcontext.regs->trap != 0x400
- && (uc->uc_mcontext.regs->dsisr & 0x02000000);
-}
-
-#endif
diff --git a/linux-user/include/host/ppc64/host-signal.h b/linux-user/include/host/ppc64/host-signal.h
index a353c22..c4ea866 100644
--- a/linux-user/include/host/ppc64/host-signal.h
+++ b/linux-user/include/host/ppc64/host-signal.h
@@ -1 +1,41 @@
-#include "../ppc/host-signal.h"
+/*
+ * host-signal.h: signal info dependent on the host architecture
+ *
+ * Copyright (c) 2003-2005 Fabrice Bellard
+ * Copyright (c) 2021 Linaro Limited
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef PPC_HOST_SIGNAL_H
+#define PPC_HOST_SIGNAL_H
+
+/* Needed for PT_* constants */
+#include <asm/ptrace.h>
+
+/* The third argument to a SA_SIGINFO handler is ucontext_t. */
+typedef ucontext_t host_sigcontext;
+
+static inline uintptr_t host_signal_pc(host_sigcontext *uc)
+{
+ return uc->uc_mcontext.gp_regs[PT_NIP];
+}
+
+static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
+{
+ uc->uc_mcontext.gp_regs[PT_NIP] = pc;
+}
+
+static inline void *host_signal_mask(host_sigcontext *uc)
+{
+ return &uc->uc_sigmask;
+}
+
+static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
+{
+ return uc->uc_mcontext.gp_regs[PT_TRAP] != 0x400
+ && (uc->uc_mcontext.gp_regs[PT_DSISR] & 0x02000000);
+}
+
+#endif
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index b9b18a7..75ed71e 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5076,7 +5076,7 @@
target_size = thunk_type_size(arg_type, THUNK_TARGET);
/* construct host copy of urb and metadata */
- lurb = g_try_malloc0(sizeof(struct live_urb));
+ lurb = g_try_new0(struct live_urb, 1);
if (!lurb) {
return -TARGET_ENOMEM;
}
diff --git a/meson.build b/meson.build
index 282e7c4..aef724a 100644
--- a/meson.build
+++ b/meson.build
@@ -3,9 +3,9 @@
'b_staticpic=false', 'stdsplit=false'],
version: files('VERSION'))
-add_test_setup('quick', exclude_suites: ['block', 'slow', 'thorough'], is_default: true)
-add_test_setup('slow', exclude_suites: ['block', 'thorough'], env: ['G_TEST_SLOW=1', 'SPEED=slow'])
-add_test_setup('thorough', exclude_suites: ['block'], env: ['G_TEST_SLOW=1', 'SPEED=thorough'])
+add_test_setup('quick', exclude_suites: ['slow', 'thorough'], is_default: true)
+add_test_setup('slow', exclude_suites: ['thorough'], env: ['G_TEST_SLOW=1', 'SPEED=slow'])
+add_test_setup('thorough', env: ['G_TEST_SLOW=1', 'SPEED=thorough'])
not_found = dependency('', required: false)
keyval = import('keyval')
@@ -1853,21 +1853,57 @@
return printf("%zu", SIZE_MAX);
}''', args: ['-Werror']))
-# See if 64-bit atomic operations are supported.
-# Note that without __atomic builtins, we can only
-# assume atomic loads/stores max at pointer size.
-config_host_data.set('CONFIG_ATOMIC64', cc.links('''
+atomic_test = '''
#include <stdint.h>
int main(void)
{
- uint64_t x = 0, y = 0;
+ @0@ x = 0, y = 0;
y = __atomic_load_n(&x, __ATOMIC_RELAXED);
__atomic_store_n(&x, y, __ATOMIC_RELAXED);
__atomic_compare_exchange_n(&x, &y, x, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
__atomic_exchange_n(&x, y, __ATOMIC_RELAXED);
__atomic_fetch_add(&x, y, __ATOMIC_RELAXED);
return 0;
- }'''))
+ }'''
+
+# See if 64-bit atomic operations are supported.
+# Note that without __atomic builtins, we can only
+# assume atomic loads/stores max at pointer size.
+config_host_data.set('CONFIG_ATOMIC64', cc.links(atomic_test.format('uint64_t')))
+
+has_int128 = cc.links('''
+ __int128_t a;
+ __uint128_t b;
+ int main (void) {
+ a = a + b;
+ b = a * b;
+ a = a * a;
+ return 0;
+ }''')
+
+config_host_data.set('CONFIG_INT128', has_int128)
+
+if has_int128
+ # "do we have 128-bit atomics which are handled inline and specifically not
+ # via libatomic". The reason we can't use libatomic is documented in the
+ # comment starting "GCC is a house divided" in include/qemu/atomic128.h.
+ has_atomic128 = cc.links(atomic_test.format('unsigned __int128'))
+
+ config_host_data.set('CONFIG_ATOMIC128', has_atomic128)
+
+ if not has_atomic128
+ has_cmpxchg128 = cc.links('''
+ int main(void)
+ {
+ unsigned __int128 x = 0, y = 0;
+ __sync_val_compare_and_swap_16(&x, y, x);
+ return 0;
+ }
+ ''')
+
+ config_host_data.set('CONFIG_CMPXCHG128', has_cmpxchg128)
+ endif
+endif
config_host_data.set('CONFIG_GETAUXVAL', cc.links(gnu_source_prefix + '''
#include <sys/auxv.h>
diff --git a/migration/dirtyrate.c b/migration/dirtyrate.c
index d65e744..aace12a 100644
--- a/migration/dirtyrate.c
+++ b/migration/dirtyrate.c
@@ -91,7 +91,7 @@
{
int i;
int64_t dirty_rate = DirtyStat.dirty_rate;
- struct DirtyRateInfo *info = g_malloc0(sizeof(DirtyRateInfo));
+ struct DirtyRateInfo *info = g_new0(DirtyRateInfo, 1);
DirtyRateVcpuList *head = NULL, **tail = &head;
info->status = CalculatingState;
@@ -112,7 +112,7 @@
info->sample_pages = 0;
info->has_vcpu_dirty_rate = true;
for (i = 0; i < DirtyStat.dirty_ring.nvcpu; i++) {
- DirtyRateVcpu *rate = g_malloc0(sizeof(DirtyRateVcpu));
+ DirtyRateVcpu *rate = g_new0(DirtyRateVcpu, 1);
rate->id = DirtyStat.dirty_ring.rates[i].id;
rate->dirty_rate = DirtyStat.dirty_ring.rates[i].dirty_rate;
QAPI_LIST_APPEND(tail, rate);
diff --git a/migration/multifd-zlib.c b/migration/multifd-zlib.c
index aba1c88..3a7ae44 100644
--- a/migration/multifd-zlib.c
+++ b/migration/multifd-zlib.c
@@ -43,7 +43,7 @@
*/
static int zlib_send_setup(MultiFDSendParams *p, Error **errp)
{
- struct zlib_data *z = g_malloc0(sizeof(struct zlib_data));
+ struct zlib_data *z = g_new0(struct zlib_data, 1);
z_stream *zs = &z->zs;
zs->zalloc = Z_NULL;
@@ -164,7 +164,7 @@
*/
static int zlib_recv_setup(MultiFDRecvParams *p, Error **errp)
{
- struct zlib_data *z = g_malloc0(sizeof(struct zlib_data));
+ struct zlib_data *z = g_new0(struct zlib_data, 1);
z_stream *zs = &z->zs;
p->data = z;
diff --git a/migration/ram.c b/migration/ram.c
index 170e522..3532f64 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -2059,7 +2059,7 @@
}
struct RAMSrcPageRequest *new_entry =
- g_malloc0(sizeof(struct RAMSrcPageRequest));
+ g_new0(struct RAMSrcPageRequest, 1);
new_entry->rb = ramblock;
new_entry->offset = start;
new_entry->len = len;
diff --git a/monitor/hmp.c b/monitor/hmp.c
index 5690660..24fd2e5 100644
--- a/monitor/hmp.c
+++ b/monitor/hmp.c
@@ -308,7 +308,7 @@
static const char *pch;
static sigjmp_buf expr_env;
-static void GCC_FMT_ATTR(2, 3) QEMU_NORETURN
+static void G_GNUC_PRINTF(2, 3) QEMU_NORETURN
expr_error(Monitor *mon, const char *fmt, ...)
{
va_list ap;
@@ -1462,7 +1462,7 @@
* These functions just adapt the readline interface in a typesafe way. We
* could cast function pointers but that discards compiler checks.
*/
-static void GCC_FMT_ATTR(2, 3) monitor_readline_printf(void *opaque,
+static void G_GNUC_PRINTF(2, 3) monitor_readline_printf(void *opaque,
const char *fmt, ...)
{
MonitorHMP *mon = opaque;
diff --git a/monitor/misc.c b/monitor/misc.c
index b1839cb..a756dbd 100644
--- a/monitor/misc.c
+++ b/monitor/misc.c
@@ -1028,7 +1028,7 @@
return;
}
- monfd = g_malloc0(sizeof(mon_fd_t));
+ monfd = g_new0(mon_fd_t, 1);
monfd->name = g_strdup(fdname);
monfd->fd = fd;
diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c
index ad82c27..0b04855 100644
--- a/monitor/qmp-cmds.c
+++ b/monitor/qmp-cmds.c
@@ -318,7 +318,7 @@
MemoryInfo *qmp_query_memory_size_summary(Error **errp)
{
- MemoryInfo *mem_info = g_malloc0(sizeof(MemoryInfo));
+ MemoryInfo *mem_info = g_new0(MemoryInfo, 1);
MachineState *ms = MACHINE(qdev_get_machine());
mem_info->base_memory = ms->ram_size;
diff --git a/nbd/server.c b/nbd/server.c
index 5da884c..c5644fd 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -213,7 +213,7 @@
/* Send an error reply.
* Return -errno on error, 0 on success. */
-static int GCC_FMT_ATTR(4, 0)
+static int G_GNUC_PRINTF(4, 0)
nbd_negotiate_send_rep_verr(NBDClient *client, uint32_t type,
Error **errp, const char *fmt, va_list va)
{
@@ -253,7 +253,7 @@
/* Send an error reply.
* Return -errno on error, 0 on success. */
-static int GCC_FMT_ATTR(4, 5)
+static int G_GNUC_PRINTF(4, 5)
nbd_negotiate_send_rep_err(NBDClient *client, uint32_t type,
Error **errp, const char *fmt, ...)
{
@@ -269,7 +269,7 @@
/* Drop remainder of the current option, and send a reply with the
* given error type and message. Return -errno on read or write
* failure; or 0 if connection is still live. */
-static int GCC_FMT_ATTR(4, 0)
+static int G_GNUC_PRINTF(4, 0)
nbd_opt_vdrop(NBDClient *client, uint32_t type, Error **errp,
const char *fmt, va_list va)
{
@@ -282,7 +282,7 @@
return ret;
}
-static int GCC_FMT_ATTR(4, 5)
+static int G_GNUC_PRINTF(4, 5)
nbd_opt_drop(NBDClient *client, uint32_t type, Error **errp,
const char *fmt, ...)
{
@@ -296,7 +296,7 @@
return ret;
}
-static int GCC_FMT_ATTR(3, 4)
+static int G_GNUC_PRINTF(3, 4)
nbd_opt_invalid(NBDClient *client, Error **errp, const char *fmt, ...)
{
int ret;
@@ -2064,7 +2064,7 @@
g_free(ea->extents);
g_free(ea);
}
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(NBDExtentArray, nbd_extent_array_free);
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(NBDExtentArray, nbd_extent_array_free)
/* Further modifications of the array after conversion are abandoned */
static void nbd_extent_array_convert_to_be(NBDExtentArray *ea)
diff --git a/net/announce.c b/net/announce.c
index 26f057f..3b9e2f1 100644
--- a/net/announce.c
+++ b/net/announce.c
@@ -120,6 +120,19 @@
return 60; /* len (FCS will be added by hardware) */
}
+/*
+ * Helper to print ethernet mac address
+ */
+static const char *qemu_ether_ntoa(const MACAddr *mac)
+{
+ static char ret[18];
+
+ snprintf(ret, sizeof(ret), "%02x:%02x:%02x:%02x:%02x:%02x",
+ mac->a[0], mac->a[1], mac->a[2], mac->a[3], mac->a[4], mac->a[5]);
+
+ return ret;
+}
+
static void qemu_announce_self_iter(NICState *nic, void *opaque)
{
AnnounceTimer *timer = opaque;
diff --git a/net/socket.c b/net/socket.c
index 15b410e..c4b80e9 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -120,9 +120,9 @@
do {
if (s->dgram_dst.sin_family != AF_UNIX) {
- ret = qemu_sendto(s->fd, buf, size, 0,
- (struct sockaddr *)&s->dgram_dst,
- sizeof(s->dgram_dst));
+ ret = sendto(s->fd, buf, size, 0,
+ (struct sockaddr *)&s->dgram_dst,
+ sizeof(s->dgram_dst));
} else {
ret = send(s->fd, buf, size, 0);
}
@@ -163,7 +163,7 @@
uint8_t buf1[NET_BUFSIZE];
const uint8_t *buf;
- size = qemu_recv(s->fd, buf1, sizeof(buf1), 0);
+ size = recv(s->fd, buf1, sizeof(buf1), 0);
if (size < 0) {
if (errno != EWOULDBLOCK)
goto eoc;
@@ -198,7 +198,7 @@
NetSocketState *s = opaque;
int size;
- size = qemu_recv(s->fd, s->rs.buf, sizeof(s->rs.buf), 0);
+ size = recv(s->fd, s->rs.buf, sizeof(s->rs.buf), 0);
if (size < 0)
return;
if (size == 0) {
@@ -246,7 +246,7 @@
* only on posix systems.
*/
val = 1;
- ret = qemu_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
+ ret = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
if (ret < 0) {
error_setg_errno(errp, errno,
"can't set socket option SO_REUSEADDR");
@@ -268,8 +268,8 @@
imr.imr_interface.s_addr = htonl(INADDR_ANY);
}
- ret = qemu_setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
- &imr, sizeof(struct ip_mreq));
+ ret = setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
+ &imr, sizeof(struct ip_mreq));
if (ret < 0) {
error_setg_errno(errp, errno,
"can't add socket to multicast group %s",
@@ -279,8 +279,8 @@
/* Force mcast msgs to loopback (eg. several QEMUs in same host */
loop = 1;
- ret = qemu_setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP,
- &loop, sizeof(loop));
+ ret = setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP,
+ &loop, sizeof(loop));
if (ret < 0) {
error_setg_errno(errp, errno,
"can't force multicast message to loopback");
@@ -289,8 +289,8 @@
/* If a bind address is given, only send packets from that address */
if (localaddr != NULL) {
- ret = qemu_setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
- localaddr, sizeof(*localaddr));
+ ret = setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF,
+ localaddr, sizeof(*localaddr));
if (ret < 0) {
error_setg_errno(errp, errno,
"can't set the default network send interface");
diff --git a/python/qemu/utils/__init__.py b/python/qemu/utils/__init__.py
index 7f1a513..9fb273b 100644
--- a/python/qemu/utils/__init__.py
+++ b/python/qemu/utils/__init__.py
@@ -15,7 +15,11 @@
# the COPYING file in the top-level directory.
#
+import os
import re
+import shutil
+from subprocess import CalledProcessError
+import textwrap
from typing import Optional
# pylint: disable=import-error
@@ -23,6 +27,8 @@
__all__ = (
+ 'VerboseProcessError',
+ 'add_visual_margin',
'get_info_usernet_hostfwd_port',
'kvm_available',
'list_accel',
@@ -43,3 +49,114 @@
if match is not None:
return int(match[1])
return None
+
+
+# pylint: disable=too-many-arguments
+def add_visual_margin(
+ content: str = '',
+ width: Optional[int] = None,
+ name: Optional[str] = None,
+ padding: int = 1,
+ upper_left: str = '┏',
+ lower_left: str = '┗',
+ horizontal: str = '━',
+ vertical: str = '┃',
+) -> str:
+ """
+ Decorate and wrap some text with a visual decoration around it.
+
+ This function assumes that the text decoration characters are single
+ characters that display using a single monospace column.
+
+ ┏━ Example ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+ ┃ This is what this function looks like with text content that's
+ ┃ wrapped to 66 characters. The right-hand margin is left open to
+ ┃ accommodate the occasional unicode character that might make
+ ┃ predicting the total "visual" width of a line difficult. This
+ ┃ provides a visual distinction that's good-enough, though.
+ ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+ :param content: The text to wrap and decorate.
+ :param width:
+ The number of columns to use, including for the decoration
+ itself. The default (None) uses the the available width of the
+ current terminal, or a fallback of 72 lines. A negative number
+ subtracts a fixed-width from the default size. The default obeys
+ the COLUMNS environment variable, if set.
+ :param name: A label to apply to the upper-left of the box.
+ :param padding: How many columns of padding to apply inside.
+ :param upper_left: Upper-left single-width text decoration character.
+ :param lower_left: Lower-left single-width text decoration character.
+ :param horizontal: Horizontal single-width text decoration character.
+ :param vertical: Vertical single-width text decoration character.
+ """
+ if width is None or width < 0:
+ avail = shutil.get_terminal_size(fallback=(72, 24))[0]
+ if width is None:
+ _width = avail
+ else:
+ _width = avail + width
+ else:
+ _width = width
+
+ prefix = vertical + (' ' * padding)
+
+ def _bar(name: Optional[str], top: bool = True) -> str:
+ ret = upper_left if top else lower_left
+ if name is not None:
+ ret += f"{horizontal} {name} "
+
+ filler_len = _width - len(ret)
+ ret += f"{horizontal * filler_len}"
+ return ret
+
+ def _wrap(line: str) -> str:
+ return os.linesep.join(
+ textwrap.wrap(
+ line, width=_width - padding, initial_indent=prefix,
+ subsequent_indent=prefix, replace_whitespace=False,
+ drop_whitespace=True, break_on_hyphens=False)
+ )
+
+ return os.linesep.join((
+ _bar(name, top=True),
+ os.linesep.join(_wrap(line) for line in content.splitlines()),
+ _bar(None, top=False),
+ ))
+
+
+class VerboseProcessError(CalledProcessError):
+ """
+ The same as CalledProcessError, but more verbose.
+
+ This is useful for debugging failed calls during test executions.
+ The return code, signal (if any), and terminal output will be displayed
+ on unhandled exceptions.
+ """
+ def summary(self) -> str:
+ """Return the normal CalledProcessError str() output."""
+ return super().__str__()
+
+ def __str__(self) -> str:
+ lmargin = ' '
+ width = -len(lmargin)
+ sections = []
+
+ # Does self.stdout contain both stdout and stderr?
+ has_combined_output = self.stderr is None
+
+ name = 'output' if has_combined_output else 'stdout'
+ if self.stdout:
+ sections.append(add_visual_margin(self.stdout, width, name))
+ else:
+ sections.append(f"{name}: N/A")
+
+ if self.stderr:
+ sections.append(add_visual_margin(self.stderr, width, 'stderr'))
+ elif not has_combined_output:
+ sections.append("stderr: N/A")
+
+ return os.linesep.join((
+ self.summary(),
+ textwrap.indent(os.linesep.join(sections), prefix=lmargin),
+ ))
diff --git a/qapi/qapi-forward-visitor.c b/qapi/qapi-forward-visitor.c
index 4ea7e0b..e36d9bc 100644
--- a/qapi/qapi-forward-visitor.c
+++ b/qapi/qapi-forward-visitor.c
@@ -23,7 +23,6 @@
#include "qapi/qmp/qnum.h"
#include "qapi/qmp/qstring.h"
#include "qemu/cutils.h"
-#include "qemu/option.h"
struct ForwardFieldVisitor {
Visitor visitor;
diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c
index d378bcc..0990873 100644
--- a/qapi/qmp-dispatch.c
+++ b/qapi/qmp-dispatch.c
@@ -21,7 +21,6 @@
#include "qapi/qmp/qjson.h"
#include "qapi/qobject-input-visitor.h"
#include "qapi/qobject-output-visitor.h"
-#include "sysemu/runstate.h"
#include "qapi/qmp/qbool.h"
#include "qemu/coroutine.h"
#include "qemu/main-loop.h"
diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c
index 5506c93..71ddc92 100644
--- a/qapi/string-output-visitor.c
+++ b/qapi/string-output-visitor.c
@@ -14,7 +14,6 @@
#include "qemu/cutils.h"
#include "qapi/string-output-visitor.h"
#include "qapi/visitor-impl.h"
-#include "qemu/host-utils.h"
#include <math.h>
#include "qemu/range.h"
diff --git a/qemu-img.c b/qemu-img.c
index 5dffb3e..1caddfb 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -99,7 +99,7 @@
printf(" %s", name);
}
-static void QEMU_NORETURN GCC_FMT_ATTR(1, 2) error_exit(const char *fmt, ...)
+static void QEMU_NORETURN G_GNUC_PRINTF(1, 2) error_exit(const char *fmt, ...)
{
va_list ap;
@@ -284,7 +284,7 @@
},
};
-static int GCC_FMT_ATTR(2, 3) qprintf(bool quiet, const char *fmt, ...)
+static int G_GNUC_PRINTF(2, 3) qprintf(bool quiet, const char *fmt, ...)
{
int ret = 0;
if (!quiet) {
diff --git a/qemu-io.c b/qemu-io.c
index 3924639..eb8afc8 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -323,13 +323,13 @@
static char prompt[FILENAME_MAX + 2 /*"> "*/ + 1 /*"\0"*/ ];
if (!prompt[0]) {
- snprintf(prompt, sizeof(prompt), "%s> ", error_get_progname());
+ snprintf(prompt, sizeof(prompt), "%s> ", g_get_prgname());
}
return prompt;
}
-static void GCC_FMT_ATTR(2, 3) readline_printf_func(void *opaque,
+static void G_GNUC_PRINTF(2, 3) readline_printf_func(void *opaque,
const char *fmt, ...)
{
va_list ap;
@@ -598,10 +598,10 @@
break;
case 'V':
printf("%s version " QEMU_FULL_VERSION "\n"
- QEMU_COPYRIGHT "\n", error_get_progname());
+ QEMU_COPYRIGHT "\n", g_get_prgname());
exit(0);
case 'h':
- usage(error_get_progname());
+ usage(g_get_prgname());
exit(0);
case 'U':
force_share = true;
@@ -613,13 +613,13 @@
imageOpts = true;
break;
default:
- usage(error_get_progname());
+ usage(g_get_prgname());
exit(1);
}
}
if ((argc - optind) > 1) {
- usage(error_get_progname());
+ usage(g_get_prgname());
exit(1);
}
diff --git a/qemu-options.hx b/qemu-options.hx
index 58f2f76..34e9b32 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2097,6 +2097,7 @@
Enable SDL.
ERST
+#ifdef CONFIG_SPICE
DEF("spice", HAS_ARG, QEMU_OPTION_spice,
"-spice [port=port][,tls-port=secured-port][,x509-dir=<dir>]\n"
" [,x509-key-file=<file>][,x509-key-password=<file>]\n"
@@ -2118,6 +2119,7 @@
" enable spice\n"
" at least one of {port, tls-port} is mandatory\n",
QEMU_ARCH_ALL)
+#endif
SRST
``-spice option[,option[,...]]``
Enable the spice remote desktop protocol. Valid options are
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 4fbbad7..3c42821 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -949,7 +949,7 @@
} else if (last_err == ERROR_INVALID_FUNCTION) {
/* Possibly CD-ROM or a shared drive. Try to pass the volume */
g_debug("volume not on disk");
- disk = g_malloc0(sizeof(GuestDiskAddress));
+ disk = g_new0(GuestDiskAddress, 1);
disk->has_dev = true;
disk->dev = g_strdup(name);
get_single_disk_info(0xffffffff, disk, &local_err);
@@ -972,7 +972,7 @@
/* Go through each extent */
for (i = 0; i < extents->NumberOfDiskExtents; i++) {
- disk = g_malloc0(sizeof(GuestDiskAddress));
+ disk = g_new0(GuestDiskAddress, 1);
/* Disk numbers directly correspond to numbers used in UNCs
*
@@ -1076,7 +1076,7 @@
sdn.DeviceNumber);
g_debug(" number: %lu", sdn.DeviceNumber);
- address = g_malloc0(sizeof(GuestDiskAddress));
+ address = g_new0(GuestDiskAddress, 1);
address->has_dev = true;
address->dev = g_strdup(disk->name);
get_single_disk_info(sdn.DeviceNumber, address, &local_err);
@@ -1368,7 +1368,7 @@
continue;
}
- uc_path = g_malloc(sizeof(WCHAR) * char_count);
+ uc_path = g_new(WCHAR, char_count);
if (!GetVolumePathNamesForVolumeNameW(guid, uc_path, char_count,
&char_count) || !*uc_path) {
/* strange, but this condition could be faced even with size == 2 */
diff --git a/qga/commands.c b/qga/commands.c
index 80501e4..72e6022 100644
--- a/qga/commands.c
+++ b/qga/commands.c
@@ -244,7 +244,7 @@
str = g_malloc(str_size);
*str = 0;
- args = g_malloc(count * sizeof(char *));
+ args = g_new(char *, count);
for (it = entry; it != NULL; it = it->next) {
args[i++] = it->value;
pstrcat(str, str_size, it->value);
diff --git a/qga/guest-agent-core.h b/qga/guest-agent-core.h
index 9d01ea9..29cd504 100644
--- a/qga/guest-agent-core.h
+++ b/qga/guest-agent-core.h
@@ -36,7 +36,7 @@
bool ga_logging_enabled(GAState *s);
void ga_disable_logging(GAState *s);
void ga_enable_logging(GAState *s);
-void GCC_FMT_ATTR(1, 2) slog(const gchar *fmt, ...);
+void G_GNUC_PRINTF(1, 2) slog(const gchar *fmt, ...);
void ga_set_response_delimited(GAState *s);
bool ga_is_frozen(GAState *s);
void ga_set_frozen(GAState *s);
diff --git a/qga/main.c b/qga/main.c
index 15fd3a4..b9dd199 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -27,7 +27,6 @@
#include "qapi/qmp/qerror.h"
#include "qapi/error.h"
#include "channel.h"
-#include "qemu/bswap.h"
#include "qemu/cutils.h"
#include "qemu/help_option.h"
#include "qemu/sockets.h"
diff --git a/qga/vss-win32/requester.h b/qga/vss-win32/requester.h
index 5a8e8fa..ecc5f2a 100644
--- a/qga/vss-win32/requester.h
+++ b/qga/vss-win32/requester.h
@@ -25,7 +25,7 @@
typedef void (*ErrorSetFunc)(struct Error **errp,
const char *src, int line, const char *func,
int win32_err, const char *fmt, ...)
- GCC_FMT_ATTR(6, 7);
+ G_GNUC_PRINTF(6, 7);
typedef struct ErrorSet {
ErrorSetFunc error_setg_win32_wrapper;
struct Error **errp; /* restriction: must not be null */
diff --git a/qobject/block-qdict.c b/qobject/block-qdict.c
index 1487cc5..4a83bda 100644
--- a/qobject/block-qdict.c
+++ b/qobject/block-qdict.c
@@ -251,12 +251,12 @@
if (is_subqdict) {
qdict_extract_subqdict(src, &subqdict, prefix);
assert(qdict_size(subqdict) > 0);
+ qlist_append_obj(*dst, QOBJECT(subqdict));
} else {
qobject_ref(subqobj);
qdict_del(src, indexstr);
+ qlist_append_obj(*dst, subqobj);
}
-
- qlist_append_obj(*dst, subqobj ?: QOBJECT(subqdict));
}
}
diff --git a/qobject/json-parser.c b/qobject/json-parser.c
index 008b326..d498db6 100644
--- a/qobject/json-parser.c
+++ b/qobject/json-parser.c
@@ -54,7 +54,7 @@
/**
* Error handler
*/
-static void GCC_FMT_ATTR(3, 4) parse_error(JSONParserContext *ctxt,
+static void G_GNUC_PRINTF(3, 4) parse_error(JSONParserContext *ctxt,
JSONToken *token, const char *msg, ...)
{
va_list ap;
diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c
index 2d6f41e..2e63a4c 100644
--- a/qom/qom-qmp-cmds.c
+++ b/qom/qom-qmp-cmds.c
@@ -49,7 +49,7 @@
object_property_iter_init(&iter, obj);
while ((prop = object_property_iter_next(&iter))) {
- ObjectPropertyInfo *value = g_malloc0(sizeof(ObjectPropertyInfo));
+ ObjectPropertyInfo *value = g_new0(ObjectPropertyInfo, 1);
QAPI_LIST_PREPEND(props, value);
diff --git a/replay/replay-char.c b/replay/replay-char.c
index dc00023..d202594 100644
--- a/replay/replay-char.c
+++ b/replay/replay-char.c
@@ -50,7 +50,7 @@
void replay_chr_be_write(Chardev *s, uint8_t *buf, int len)
{
- CharEvent *event = g_malloc0(sizeof(CharEvent));
+ CharEvent *event = g_new0(CharEvent, 1);
event->id = find_char_driver(s);
if (event->id < 0) {
@@ -85,7 +85,7 @@
void *replay_event_char_read_load(void)
{
- CharEvent *event = g_malloc0(sizeof(CharEvent));
+ CharEvent *event = g_new0(CharEvent, 1);
event->id = replay_get_byte();
replay_get_array_alloc(&event->buf, &event->len);
diff --git a/replay/replay-events.c b/replay/replay-events.c
index 15983dd..ac47c89 100644
--- a/replay/replay-events.c
+++ b/replay/replay-events.c
@@ -119,7 +119,7 @@
return;
}
- Event *event = g_malloc0(sizeof(Event));
+ Event *event = g_new0(Event, 1);
event->event_kind = event_kind;
event->opaque = opaque;
event->opaque2 = opaque2;
@@ -243,17 +243,17 @@
}
break;
case REPLAY_ASYNC_EVENT_INPUT:
- event = g_malloc0(sizeof(Event));
+ event = g_new0(Event, 1);
event->event_kind = replay_state.read_event_kind;
event->opaque = replay_read_input_event();
return event;
case REPLAY_ASYNC_EVENT_INPUT_SYNC:
- event = g_malloc0(sizeof(Event));
+ event = g_new0(Event, 1);
event->event_kind = replay_state.read_event_kind;
event->opaque = 0;
return event;
case REPLAY_ASYNC_EVENT_CHAR_READ:
- event = g_malloc0(sizeof(Event));
+ event = g_new0(Event, 1);
event->event_kind = replay_state.read_event_kind;
event->opaque = replay_event_char_read_load();
return event;
@@ -263,7 +263,7 @@
}
break;
case REPLAY_ASYNC_EVENT_NET:
- event = g_malloc0(sizeof(Event));
+ event = g_new0(Event, 1);
event->event_kind = replay_state.read_event_kind;
event->opaque = replay_event_net_load();
return event;
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index ddd8148..ddc6003 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -224,10 +224,10 @@
const|
volatile|
QEMU_NORETURN|
- QEMU_WARN_UNUSED_RESULT|
- QEMU_SENTINEL|
+ G_GNUC_WARN_UNUSED_RESULT|
+ G_GNUC_NULL_TERMINATED|
QEMU_PACKED|
- GCC_FMT_ATTR
+ G_GNUC_PRINTF
}x;
our $Modifier;
our $Inline = qr{inline};
diff --git a/scripts/cocci-macro-file.h b/scripts/cocci-macro-file.h
index 20eea6b..3d1e9b5 100644
--- a/scripts/cocci-macro-file.h
+++ b/scripts/cocci-macro-file.h
@@ -20,8 +20,8 @@
/* From qemu/compiler.h */
#define QEMU_NORETURN __attribute__ ((__noreturn__))
-#define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
-#define QEMU_SENTINEL __attribute__((sentinel))
+#define G_GNUC_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
+#define G_GNUC_NULL_TERMINATED __attribute__((sentinel))
#if defined(_WIN32) && (defined(__x86_64__) || defined(__i386__))
# define QEMU_PACKED __attribute__((gcc_struct, packed))
@@ -34,7 +34,7 @@
#define QEMU_BUILD_BUG_ON(x) \
typedef char cat2(qemu_build_bug_on__,__LINE__)[(x)?-1:1] __attribute__((unused));
-#define GCC_FMT_ATTR(n, m) __attribute__((format(gnu_printf, n, m)))
+#define G_GNUC_PRINTF(n, m) __attribute__((format(gnu_printf, n, m)))
#define xglue(x, y) x ## y
#define glue(x, y) xglue(x, y)
diff --git a/scripts/coccinelle/use-g_new-etc.cocci b/scripts/coccinelle/use-g_new-etc.cocci
new file mode 100644
index 0000000..e2280e9
--- /dev/null
+++ b/scripts/coccinelle/use-g_new-etc.cocci
@@ -0,0 +1,75 @@
+// Use g_new() & friends where that makes obvious sense
+@@
+type T;
+@@
+-g_malloc(sizeof(T))
++g_new(T, 1)
+@@
+type T;
+@@
+-g_try_malloc(sizeof(T))
++g_try_new(T, 1)
+@@
+type T;
+@@
+-g_malloc0(sizeof(T))
++g_new0(T, 1)
+@@
+type T;
+@@
+-g_try_malloc0(sizeof(T))
++g_try_new0(T, 1)
+@@
+type T;
+expression n;
+@@
+-g_malloc(sizeof(T) * (n))
++g_new(T, n)
+@@
+type T;
+expression n;
+@@
+-g_try_malloc(sizeof(T) * (n))
++g_try_new(T, n)
+@@
+type T;
+expression n;
+@@
+-g_malloc0(sizeof(T) * (n))
++g_new0(T, n)
+@@
+type T;
+expression n;
+@@
+-g_try_malloc0(sizeof(T) * (n))
++g_try_new0(T, n)
+@@
+type T;
+expression p, n;
+@@
+-g_realloc(p, sizeof(T) * (n))
++g_renew(T, p, n)
+@@
+type T;
+expression p, n;
+@@
+-g_try_realloc(p, sizeof(T) * (n))
++g_try_renew(T, p, n)
+@@
+type T;
+expression n;
+@@
+-(T *)g_new(T, n)
++g_new(T, n)
+@@
+type T;
+expression n;
+@@
+-(T *)g_new0(T, n)
++g_new0(T, n)
+@@
+type T;
+expression p, n;
+@@
+-(T *)g_renew(T, p, n)
++g_renew(T, p, n)
diff --git a/scripts/modinfo-collect.py b/scripts/modinfo-collect.py
index 61b9068..4e7584d 100755
--- a/scripts/modinfo-collect.py
+++ b/scripts/modinfo-collect.py
@@ -18,13 +18,8 @@
def process_command(src, command):
skip = False
- arg = False
out = []
for item in shlex.split(command):
- if arg:
- out.append(x)
- arg = False
- continue
if skip:
skip = False
continue
diff --git a/scripts/mtest2make.py b/scripts/mtest2make.py
index 4d542e8..304634b 100644
--- a/scripts/mtest2make.py
+++ b/scripts/mtest2make.py
@@ -101,10 +101,6 @@
testsuites = defaultdict(Suite)
for test in introspect['tests']:
process_tests(test, targets, testsuites)
-# HACK: check-block is a separate target so that it runs with --verbose;
-# only write the dependencies
-emit_suite_deps('block', testsuites['block'], 'check')
-del testsuites['block']
emit_prolog(testsuites, 'check')
for name, suite in testsuites.items():
emit_suite(name, suite, 'check')
diff --git a/softmmu/bootdevice.c b/softmmu/bootdevice.c
index add4e3d..c0713bf 100644
--- a/softmmu/bootdevice.c
+++ b/softmmu/bootdevice.c
@@ -166,7 +166,7 @@
del_boot_device_path(dev, suffix);
- node = g_malloc0(sizeof(FWBootEntry));
+ node = g_new0(FWBootEntry, 1);
node->bootindex = bootindex;
node->suffix = g_strdup(suffix);
node->dev = dev;
@@ -367,7 +367,7 @@
assert(dev != NULL || suffix != NULL);
- node = g_malloc0(sizeof(FWLCHSEntry));
+ node = g_new0(FWLCHSEntry, 1);
node->suffix = g_strdup(suffix);
node->dev = dev;
node->lcyls = lcyls;
diff --git a/softmmu/dma-helpers.c b/softmmu/dma-helpers.c
index 160095e..7820fec 100644
--- a/softmmu/dma-helpers.c
+++ b/softmmu/dma-helpers.c
@@ -29,7 +29,7 @@
void qemu_sglist_init(QEMUSGList *qsg, DeviceState *dev, int alloc_hint,
AddressSpace *as)
{
- qsg->sg = g_malloc(alloc_hint * sizeof(ScatterGatherEntry));
+ qsg->sg = g_new(ScatterGatherEntry, alloc_hint);
qsg->nsg = 0;
qsg->nalloc = alloc_hint;
qsg->size = 0;
@@ -42,7 +42,7 @@
{
if (qsg->nsg == qsg->nalloc) {
qsg->nalloc = 2 * qsg->nalloc + 1;
- qsg->sg = g_realloc(qsg->sg, qsg->nalloc * sizeof(ScatterGatherEntry));
+ qsg->sg = g_renew(ScatterGatherEntry, qsg->sg, qsg->nalloc);
}
qsg->sg[qsg->nsg].base = base;
qsg->sg[qsg->nsg].len = len;
diff --git a/softmmu/memory_mapping.c b/softmmu/memory_mapping.c
index 8320165..f6f0a82 100644
--- a/softmmu/memory_mapping.c
+++ b/softmmu/memory_mapping.c
@@ -42,7 +42,7 @@
{
MemoryMapping *memory_mapping;
- memory_mapping = g_malloc(sizeof(MemoryMapping));
+ memory_mapping = g_new(MemoryMapping, 1);
memory_mapping->phys_addr = phys_addr;
memory_mapping->virt_addr = virt_addr;
memory_mapping->length = length;
diff --git a/softmmu/qtest.c b/softmmu/qtest.c
index 8b7cb6a..cc58623 100644
--- a/softmmu/qtest.c
+++ b/softmmu/qtest.c
@@ -288,7 +288,7 @@
(long) tv.tv_sec, (long) tv.tv_usec);
}
-static void GCC_FMT_ATTR(1, 2) qtest_log_send(const char *fmt, ...)
+static void G_GNUC_PRINTF(1, 2) qtest_log_send(const char *fmt, ...)
{
va_list ap;
@@ -318,7 +318,7 @@
qtest_server_send(qtest_server_send_opaque, str);
}
-static void GCC_FMT_ATTR(2, 3) qtest_sendf(CharBackend *chr,
+static void G_GNUC_PRINTF(2, 3) qtest_sendf(CharBackend *chr,
const char *fmt, ...)
{
va_list ap;
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 0b81f61..6f64653 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -836,7 +836,7 @@
version();
printf("usage: %s [options] [disk_image]\n\n"
"'disk_image' is a raw hard disk image for IDE hard disk 0\n\n",
- error_get_progname());
+ g_get_prgname());
#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask) \
if ((arch_mask) & arch_type) \
@@ -1961,7 +1961,7 @@
object_option_foreach_add(object_create_early);
/* spice needs the timers to be initialized by this point */
- /* spice must initialize before audio as it changes the default auiodev */
+ /* spice must initialize before audio as it changes the default audiodev */
/* spice must initialize before chardevs (for spicevmc and spiceport) */
qemu_spice.init();
@@ -3537,6 +3537,7 @@
case QEMU_OPTION_readconfig:
qemu_read_config_file(optarg, qemu_parse_config_group, &error_fatal);
break;
+#ifdef CONFIG_SPICE
case QEMU_OPTION_spice:
olist = qemu_find_opts_err("spice", NULL);
if (!olist) {
@@ -3549,6 +3550,7 @@
}
display_remote++;
break;
+#endif
case QEMU_OPTION_writeconfig:
{
FILE *fp;
diff --git a/storage-daemon/qemu-storage-daemon.c b/storage-daemon/qemu-storage-daemon.c
index dd18b2c..eb72407 100644
--- a/storage-daemon/qemu-storage-daemon.c
+++ b/storage-daemon/qemu-storage-daemon.c
@@ -141,7 +141,7 @@
" --pidfile <path> write process ID to a file after startup\n"
"\n"
QEMU_HELP_BOTTOM "\n",
- error_get_progname());
+ g_get_prgname());
}
enum {
diff --git a/target/i386/cpu-sysemu.c b/target/i386/cpu-sysemu.c
index 37b7c56..e254d8b 100644
--- a/target/i386/cpu-sysemu.c
+++ b/target/i386/cpu-sysemu.c
@@ -313,7 +313,7 @@
GuestPanicInformation *panic_info = NULL;
if (hyperv_feat_enabled(cpu, HYPERV_FEAT_CRASH)) {
- panic_info = g_malloc0(sizeof(GuestPanicInformation));
+ panic_info = g_new0(GuestPanicInformation, 1);
panic_info->type = GUEST_PANIC_INFORMATION_TYPE_HYPER_V;
diff --git a/target/i386/hax/hax-accel-ops.c b/target/i386/hax/hax-accel-ops.c
index 136630e..18114fe 100644
--- a/target/i386/hax/hax-accel-ops.c
+++ b/target/i386/hax/hax-accel-ops.c
@@ -61,8 +61,8 @@
{
char thread_name[VCPU_THREAD_NAME_SIZE];
- cpu->thread = g_malloc0(sizeof(QemuThread));
- cpu->halt_cond = g_malloc0(sizeof(QemuCond));
+ cpu->thread = g_new0(QemuThread, 1);
+ cpu->halt_cond = g_new0(QemuCond, 1);
qemu_cond_init(cpu->halt_cond);
snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/HAX",
diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c
index ef2c68a..06901c2 100644
--- a/target/i386/kvm/kvm.c
+++ b/target/i386/kvm/kvm.c
@@ -411,6 +411,12 @@
}
} else if (function == 0xd && index == 0 &&
(reg == R_EAX || reg == R_EDX)) {
+ /*
+ * The value returned by KVM_GET_SUPPORTED_CPUID does not include
+ * features that still have to be enabled with the arch_prctl
+ * system call. QEMU needs the full value, which is retrieved
+ * with KVM_GET_DEVICE_ATTR.
+ */
struct kvm_device_attr attr = {
.group = 0,
.attr = KVM_X86_XCOMP_GUEST_SUPP,
@@ -419,13 +425,16 @@
bool sys_attr = kvm_check_extension(s, KVM_CAP_SYS_ATTRIBUTES);
if (!sys_attr) {
- warn_report("cannot get sys attribute capabilities %d", sys_attr);
+ return ret;
}
int rc = kvm_ioctl(s, KVM_GET_DEVICE_ATTR, &attr);
- if (rc == -1 && (errno == ENXIO || errno == EINVAL)) {
- warn_report("KVM_GET_DEVICE_ATTR(0, KVM_X86_XCOMP_GUEST_SUPP) "
- "error: %d", rc);
+ if (rc < 0) {
+ if (rc != -ENXIO) {
+ warn_report("KVM_GET_DEVICE_ATTR(0, KVM_X86_XCOMP_GUEST_SUPP) "
+ "error: %d", rc);
+ }
+ return ret;
}
ret = (reg == R_EAX) ? bitmask : bitmask >> 32;
} else if (function == 0x80000001 && reg == R_ECX) {
diff --git a/target/i386/nvmm/nvmm-accel-ops.c b/target/i386/nvmm/nvmm-accel-ops.c
index f788f75..6c46101 100644
--- a/target/i386/nvmm/nvmm-accel-ops.c
+++ b/target/i386/nvmm/nvmm-accel-ops.c
@@ -64,8 +64,8 @@
{
char thread_name[VCPU_THREAD_NAME_SIZE];
- cpu->thread = g_malloc0(sizeof(QemuThread));
- cpu->halt_cond = g_malloc0(sizeof(QemuCond));
+ cpu->thread = g_new0(QemuThread, 1);
+ cpu->halt_cond = g_new0(QemuCond, 1);
qemu_cond_init(cpu->halt_cond);
snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/NVMM",
cpu->cpu_index);
diff --git a/target/i386/whpx/whpx-accel-ops.c b/target/i386/whpx/whpx-accel-ops.c
index 1d30e4e..dd2a9f7 100644
--- a/target/i386/whpx/whpx-accel-ops.c
+++ b/target/i386/whpx/whpx-accel-ops.c
@@ -64,8 +64,8 @@
{
char thread_name[VCPU_THREAD_NAME_SIZE];
- cpu->thread = g_malloc0(sizeof(QemuThread));
- cpu->halt_cond = g_malloc0(sizeof(QemuCond));
+ cpu->thread = g_new0(QemuThread, 1);
+ cpu->halt_cond = g_new0(QemuCond, 1);
qemu_cond_init(cpu->halt_cond);
snprintf(thread_name, VCPU_THREAD_NAME_SIZE, "CPU %d/WHPX",
cpu->cpu_index);
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index ecddf0c..03ba52d 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -1382,7 +1382,7 @@
}
}
- vcpu = g_malloc0(sizeof(struct whpx_vcpu));
+ vcpu = g_new0(struct whpx_vcpu, 1);
if (!vcpu) {
error_report("WHPX: Failed to allocte VCPU context.");
diff --git a/target/m68k/m68k-semi.c b/target/m68k/m68k-semi.c
index 44ec7e4..c5c164e 100644
--- a/target/m68k/m68k-semi.c
+++ b/target/m68k/m68k-semi.c
@@ -381,7 +381,7 @@
qemu_timeval tv;
struct gdb_timeval *p;
result = qemu_gettimeofday(&tv);
- if (result != 0) {
+ if (result == 0) {
if (!(p = lock_user(VERIFY_WRITE,
arg0, sizeof(struct gdb_timeval), 0))) {
/* FIXME - check error code? */
diff --git a/target/nios2/nios2-semi.c b/target/nios2/nios2-semi.c
index fe5598b..5a7ad0c 100644
--- a/target/nios2/nios2-semi.c
+++ b/target/nios2/nios2-semi.c
@@ -403,7 +403,7 @@
qemu_timeval tv;
struct gdb_timeval *p;
result = qemu_gettimeofday(&tv);
- if (result != 0) {
+ if (result == 0) {
p = lock_user(VERIFY_WRITE, arg0, sizeof(struct gdb_timeval),
0);
if (!p) {
diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c
index bd12db9..7e8be99 100644
--- a/target/ppc/fpu_helper.c
+++ b/target/ppc/fpu_helper.c
@@ -2691,11 +2691,35 @@
do_float_check_status(env, GETPC()); \
}
-VSX_CVT_FP_TO_FP(xscvdpsp, 1, float64, float32, VsrD(0), VsrW(0), 1)
VSX_CVT_FP_TO_FP(xscvspdp, 1, float32, float64, VsrW(0), VsrD(0), 1)
-VSX_CVT_FP_TO_FP(xvcvdpsp, 2, float64, float32, VsrD(i), VsrW(2 * i), 0)
VSX_CVT_FP_TO_FP(xvcvspdp, 2, float32, float64, VsrW(2 * i), VsrD(i), 0)
+#define VSX_CVT_FP_TO_FP2(op, nels, stp, ttp, sfprf) \
+void helper_##op(CPUPPCState *env, ppc_vsr_t *xt, ppc_vsr_t *xb) \
+{ \
+ ppc_vsr_t t = { }; \
+ int i; \
+ \
+ for (i = 0; i < nels; i++) { \
+ t.VsrW(2 * i) = stp##_to_##ttp(xb->VsrD(i), &env->fp_status); \
+ if (unlikely(stp##_is_signaling_nan(xb->VsrD(i), \
+ &env->fp_status))) { \
+ float_invalid_op_vxsnan(env, GETPC()); \
+ t.VsrW(2 * i) = ttp##_snan_to_qnan(t.VsrW(2 * i)); \
+ } \
+ if (sfprf) { \
+ helper_compute_fprf_##ttp(env, t.VsrW(2 * i)); \
+ } \
+ t.VsrW(2 * i + 1) = t.VsrW(2 * i); \
+ } \
+ \
+ *xt = t; \
+ do_float_check_status(env, GETPC()); \
+}
+
+VSX_CVT_FP_TO_FP2(xvcvdpsp, 2, float64, float32, 0)
+VSX_CVT_FP_TO_FP2(xscvdpsp, 1, float64, float32, 1)
+
/*
* VSX_CVT_FP_TO_FP_VECTOR - VSX floating point/floating point conversion
* op - instruction mnemonic
@@ -2891,16 +2915,10 @@
VSX_CVT_FP_TO_INT(xscvdpsxds, 1, float64, int64, VsrD(0), VsrD(0), \
0x8000000000000000ULL)
-VSX_CVT_FP_TO_INT(xscvdpsxws, 1, float64, int32, VsrD(0), VsrW(1), \
- 0x80000000U)
VSX_CVT_FP_TO_INT(xscvdpuxds, 1, float64, uint64, VsrD(0), VsrD(0), 0ULL)
-VSX_CVT_FP_TO_INT(xscvdpuxws, 1, float64, uint32, VsrD(0), VsrW(1), 0U)
VSX_CVT_FP_TO_INT(xvcvdpsxds, 2, float64, int64, VsrD(i), VsrD(i), \
0x8000000000000000ULL)
-VSX_CVT_FP_TO_INT(xvcvdpsxws, 2, float64, int32, VsrD(i), VsrW(2 * i), \
- 0x80000000U)
VSX_CVT_FP_TO_INT(xvcvdpuxds, 2, float64, uint64, VsrD(i), VsrD(i), 0ULL)
-VSX_CVT_FP_TO_INT(xvcvdpuxws, 2, float64, uint32, VsrD(i), VsrW(2 * i), 0U)
VSX_CVT_FP_TO_INT(xvcvspsxds, 2, float32, int64, VsrW(2 * i), VsrD(i), \
0x8000000000000000ULL)
VSX_CVT_FP_TO_INT(xvcvspsxws, 4, float32, int32, VsrW(i), VsrW(i), 0x80000000U)
@@ -2908,6 +2926,45 @@
VSX_CVT_FP_TO_INT(xvcvspuxws, 4, float32, uint32, VsrW(i), VsrW(i), 0U)
/*
+ * Likewise, except that the result is duplicated into both subwords.
+ * Power ISA v3.1 has Programming Notes for these insns:
+ * Previous versions of the architecture allowed the contents of
+ * word 0 of the result register to be undefined. However, all
+ * processors that support this instruction write the result into
+ * words 0 and 1 (and words 2 and 3) of the result register, as
+ * is required by this version of the architecture.
+ */
+#define VSX_CVT_FP_TO_INT2(op, nels, stp, ttp, rnan) \
+void helper_##op(CPUPPCState *env, ppc_vsr_t *xt, ppc_vsr_t *xb) \
+{ \
+ int all_flags = env->fp_status.float_exception_flags, flags; \
+ ppc_vsr_t t = { }; \
+ int i; \
+ \
+ for (i = 0; i < nels; i++) { \
+ env->fp_status.float_exception_flags = 0; \
+ t.VsrW(2 * i) = stp##_to_##ttp##_round_to_zero(xb->VsrD(i), \
+ &env->fp_status); \
+ flags = env->fp_status.float_exception_flags; \
+ if (unlikely(flags & float_flag_invalid)) { \
+ t.VsrW(2 * i) = float_invalid_cvt(env, flags, t.VsrW(2 * i), \
+ rnan, 0, GETPC()); \
+ } \
+ t.VsrW(2 * i + 1) = t.VsrW(2 * i); \
+ all_flags |= flags; \
+ } \
+ \
+ *xt = t; \
+ env->fp_status.float_exception_flags = all_flags; \
+ do_float_check_status(env, GETPC()); \
+}
+
+VSX_CVT_FP_TO_INT2(xscvdpsxws, 1, float64, int32, 0x80000000U)
+VSX_CVT_FP_TO_INT2(xscvdpuxws, 1, float64, uint32, 0U)
+VSX_CVT_FP_TO_INT2(xvcvdpsxws, 2, float64, int32, 0x80000000U)
+VSX_CVT_FP_TO_INT2(xvcvdpuxws, 2, float64, uint32, 0U)
+
+/*
* VSX_CVT_FP_TO_INT_VECTOR - VSX floating point to integer conversion
* op - instruction mnemonic
* stp - source type (float32 or float64)
@@ -2980,11 +3037,27 @@
VSX_CVT_INT_TO_FP(xvcvuxddp, 2, uint64, float64, VsrD(i), VsrD(i), 0, 0)
VSX_CVT_INT_TO_FP(xvcvsxwdp, 2, int32, float64, VsrW(2 * i), VsrD(i), 0, 0)
VSX_CVT_INT_TO_FP(xvcvuxwdp, 2, uint64, float64, VsrW(2 * i), VsrD(i), 0, 0)
-VSX_CVT_INT_TO_FP(xvcvsxdsp, 2, int64, float32, VsrD(i), VsrW(2 * i), 0, 0)
-VSX_CVT_INT_TO_FP(xvcvuxdsp, 2, uint64, float32, VsrD(i), VsrW(2 * i), 0, 0)
VSX_CVT_INT_TO_FP(xvcvsxwsp, 4, int32, float32, VsrW(i), VsrW(i), 0, 0)
VSX_CVT_INT_TO_FP(xvcvuxwsp, 4, uint32, float32, VsrW(i), VsrW(i), 0, 0)
+#define VSX_CVT_INT_TO_FP2(op, stp, ttp) \
+void helper_##op(CPUPPCState *env, ppc_vsr_t *xt, ppc_vsr_t *xb) \
+{ \
+ ppc_vsr_t t = { }; \
+ int i; \
+ \
+ for (i = 0; i < 2; i++) { \
+ t.VsrW(2 * i) = stp##_to_##ttp(xb->VsrD(i), &env->fp_status); \
+ t.VsrW(2 * i + 1) = t.VsrW(2 * i); \
+ } \
+ \
+ *xt = t; \
+ do_float_check_status(env, GETPC()); \
+}
+
+VSX_CVT_INT_TO_FP2(xvcvsxdsp, int64, float32)
+VSX_CVT_INT_TO_FP2(xvcvuxdsp, uint64, float32)
+
/*
* VSX_CVT_INT_TO_FP_VECTOR - VSX integer to floating point conversion
* op - instruction mnemonic
diff --git a/target/s390x/cpu-sysemu.c b/target/s390x/cpu-sysemu.c
index 5471e01..948e4bd 100644
--- a/target/s390x/cpu-sysemu.c
+++ b/target/s390x/cpu-sysemu.c
@@ -76,7 +76,7 @@
S390CPU *cpu = S390_CPU(cs);
cpu_synchronize_state(cs);
- panic_info = g_malloc0(sizeof(GuestPanicInformation));
+ panic_info = g_new0(GuestPanicInformation, 1);
panic_info->type = GUEST_PANIC_INFORMATION_TYPE_S390;
panic_info->u.s390.core = cpu->env.core_id;
diff --git a/tests/Makefile.include b/tests/Makefile.include
index e7153c8..b89018c 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -147,16 +147,9 @@
# Consolidated targets
-.PHONY: check-block check check-clean get-vm-images
+.PHONY: check check-clean get-vm-images
check:
-ifneq ($(.check-block.deps),)
-check: check-block
-check-block: run-ninja
- $(if $(MAKE.n),,+)$(MESON) test $(MTESTARGS) $(.mtestargs) --verbose \
- --logbase iotestslog $(call .speed.$(SPEED), block block-slow block-thorough)
-endif
-
check-build: run-ninja
check-clean:
diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041
index db9f5dc..3e16ace 100755
--- a/tests/qemu-iotests/041
+++ b/tests/qemu-iotests/041
@@ -24,7 +24,7 @@
import re
import json
import iotests
-from iotests import qemu_img, qemu_img_pipe, qemu_io
+from iotests import qemu_img, qemu_img_map, qemu_io
backing_img = os.path.join(iotests.test_dir, 'backing.img')
target_backing_img = os.path.join(iotests.test_dir, 'target-backing.img')
@@ -1360,8 +1360,7 @@
self.vm.qmp('blockdev-del', node_name='target')
- target_map = qemu_img_pipe('map', '--output=json', target_img)
- target_map = json.loads(target_map)
+ target_map = qemu_img_map(target_img)
assert target_map[0]['start'] == 0
assert target_map[0]['length'] == 512 * 1024
diff --git a/tests/qemu-iotests/065 b/tests/qemu-iotests/065
index f7c1b68..ba94e19 100755
--- a/tests/qemu-iotests/065
+++ b/tests/qemu-iotests/065
@@ -24,7 +24,7 @@
import re
import json
import iotests
-from iotests import qemu_img, qemu_img_pipe
+from iotests import qemu_img, qemu_img_info
import unittest
test_img = os.path.join(iotests.test_dir, 'test.img')
@@ -49,13 +49,12 @@
human_compare = None
def test_json(self):
- data = json.loads(qemu_img_pipe('info', '--output=json', test_img))
- data = data['format-specific']
+ data = qemu_img_info(test_img)['format-specific']
self.assertEqual(data['type'], iotests.imgfmt)
self.assertEqual(data['data'], self.json_compare)
def test_human(self):
- data = qemu_img_pipe('info', '--output=human', test_img).split('\n')
+ data = qemu_img('info', '--output=human', test_img).stdout.split('\n')
data = data[(data.index('Format specific information:') + 1)
:data.index('')]
for field in data:
diff --git a/tests/qemu-iotests/149 b/tests/qemu-iotests/149
index d49646c..9bb96d6 100755
--- a/tests/qemu-iotests/149
+++ b/tests/qemu-iotests/149
@@ -265,8 +265,11 @@
"%dM" % size_mb]
iotests.log("qemu-img " + " ".join(args), filters=[iotests.filter_test_dir])
- iotests.log(check_cipher_support(config, iotests.qemu_img_pipe(*args)),
- filters=[iotests.filter_test_dir])
+ try:
+ iotests.qemu_img(*args)
+ except subprocess.CalledProcessError as exc:
+ check_cipher_support(config, exc.output)
+ raise
def qemu_io_image_args(config, dev=False):
"""Get the args for access an image or device with qemu-io"""
diff --git a/tests/qemu-iotests/149.out b/tests/qemu-iotests/149.out
index ab87959..2cc5b82 100644
--- a/tests/qemu-iotests/149.out
+++ b/tests/qemu-iotests/149.out
@@ -61,7 +61,6 @@
# ================= qemu-img aes-256-xts-plain64-sha1 =================
# Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-aes-256-xts-plain64-sha1.img 4194304M
-
# Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha1.img qiotest-145-aes-256-xts-plain64-sha1
# Write test pattern 0xa7
@@ -180,7 +179,6 @@
# ================= qemu-img twofish-256-xts-plain64-sha1 =================
# Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=twofish-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-twofish-256-xts-plain64-sha1.img 4194304M
-
# Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-twofish-256-xts-plain64-sha1.img qiotest-145-twofish-256-xts-plain64-sha1
# Write test pattern 0xa7
@@ -299,7 +297,6 @@
# ================= qemu-img serpent-256-xts-plain64-sha1 =================
# Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=serpent-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-serpent-256-xts-plain64-sha1.img 4194304M
-
# Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-serpent-256-xts-plain64-sha1.img qiotest-145-serpent-256-xts-plain64-sha1
# Write test pattern 0xa7
@@ -418,7 +415,6 @@
# ================= qemu-img cast5-128-cbc-plain64-sha1 =================
# Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=cast5-128,cipher-mode=cbc,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-cast5-128-cbc-plain64-sha1.img 4194304M
-
# Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-cast5-128-cbc-plain64-sha1.img qiotest-145-cast5-128-cbc-plain64-sha1
# Write test pattern 0xa7
@@ -538,7 +534,6 @@
# ================= qemu-img aes-256-cbc-plain-sha1 =================
# Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=cbc,ivgen-alg=plain,hash-alg=sha1 TEST_DIR/luks-aes-256-cbc-plain-sha1.img 4194304M
-
# Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-plain-sha1.img qiotest-145-aes-256-cbc-plain-sha1
# Write test pattern 0xa7
@@ -657,7 +652,6 @@
# ================= qemu-img aes-256-cbc-plain64-sha1 =================
# Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=cbc,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-aes-256-cbc-plain64-sha1.img 4194304M
-
# Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-plain64-sha1.img qiotest-145-aes-256-cbc-plain64-sha1
# Write test pattern 0xa7
@@ -776,7 +770,6 @@
# ================= qemu-img aes-256-cbc-essiv-sha256-sha1 =================
# Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=cbc,ivgen-alg=essiv,hash-alg=sha1,ivgen-hash-alg=sha256 TEST_DIR/luks-aes-256-cbc-essiv-sha256-sha1.img 4194304M
-
# Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-essiv-sha256-sha1.img qiotest-145-aes-256-cbc-essiv-sha256-sha1
# Write test pattern 0xa7
@@ -895,7 +888,6 @@
# ================= qemu-img aes-256-xts-essiv-sha256-sha1 =================
# Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=essiv,hash-alg=sha1,ivgen-hash-alg=sha256 TEST_DIR/luks-aes-256-xts-essiv-sha256-sha1.img 4194304M
-
# Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-essiv-sha256-sha1.img qiotest-145-aes-256-xts-essiv-sha256-sha1
# Write test pattern 0xa7
@@ -1014,7 +1006,6 @@
# ================= qemu-img aes-128-xts-plain64-sha256-sha1 =================
# Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-128,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-aes-128-xts-plain64-sha256-sha1.img 4194304M
-
# Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-128-xts-plain64-sha256-sha1.img qiotest-145-aes-128-xts-plain64-sha256-sha1
# Write test pattern 0xa7
@@ -1133,7 +1124,6 @@
# ================= qemu-img aes-192-xts-plain64-sha256-sha1 =================
# Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-192,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-aes-192-xts-plain64-sha256-sha1.img 4194304M
-
# Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-192-xts-plain64-sha256-sha1.img qiotest-145-aes-192-xts-plain64-sha256-sha1
# Write test pattern 0xa7
@@ -1252,7 +1242,6 @@
# ================= qemu-img twofish-128-xts-plain64-sha1 =================
# Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=twofish-128,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-twofish-128-xts-plain64-sha1.img 4194304M
-
# Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-twofish-128-xts-plain64-sha1.img qiotest-145-twofish-128-xts-plain64-sha1
# Write test pattern 0xa7
@@ -1372,7 +1361,6 @@
# ================= qemu-img serpent-128-xts-plain64-sha1 =================
# Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=serpent-128,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-serpent-128-xts-plain64-sha1.img 4194304M
-
# Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-serpent-128-xts-plain64-sha1.img qiotest-145-serpent-128-xts-plain64-sha1
# Write test pattern 0xa7
@@ -1491,7 +1479,6 @@
# ================= qemu-img serpent-192-xts-plain64-sha1 =================
# Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=serpent-192,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha1 TEST_DIR/luks-serpent-192-xts-plain64-sha1.img 4194304M
-
# Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-serpent-192-xts-plain64-sha1.img qiotest-145-serpent-192-xts-plain64-sha1
# Write test pattern 0xa7
@@ -1612,7 +1599,6 @@
# ================= qemu-img aes-256-xts-plain64-sha224 =================
# Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha224 TEST_DIR/luks-aes-256-xts-plain64-sha224.img 4194304M
-
# Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha224.img qiotest-145-aes-256-xts-plain64-sha224
# Write test pattern 0xa7
@@ -1731,7 +1717,6 @@
# ================= qemu-img aes-256-xts-plain64-sha256 =================
# Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha256 TEST_DIR/luks-aes-256-xts-plain64-sha256.img 4194304M
-
# Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha256.img qiotest-145-aes-256-xts-plain64-sha256
# Write test pattern 0xa7
@@ -1850,7 +1835,6 @@
# ================= qemu-img aes-256-xts-plain64-sha384 =================
# Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha384 TEST_DIR/luks-aes-256-xts-plain64-sha384.img 4194304M
-
# Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha384.img qiotest-145-aes-256-xts-plain64-sha384
# Write test pattern 0xa7
@@ -1969,7 +1953,6 @@
# ================= qemu-img aes-256-xts-plain64-sha512 =================
# Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=sha512 TEST_DIR/luks-aes-256-xts-plain64-sha512.img 4194304M
-
# Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-sha512.img qiotest-145-aes-256-xts-plain64-sha512
# Write test pattern 0xa7
@@ -2088,7 +2071,6 @@
# ================= qemu-img aes-256-xts-plain64-ripemd160 =================
# Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain64,hash-alg=ripemd160 TEST_DIR/luks-aes-256-xts-plain64-ripemd160.img 4194304M
-
# Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain64-ripemd160.img qiotest-145-aes-256-xts-plain64-ripemd160
# Write test pattern 0xa7
@@ -2281,7 +2263,6 @@
# ================= qemu-img aes-256-xts-plain-sha1-pwallslots =================
# Create image
qemu-img create -f luks --object secret,id=sec0,data=c2xvdDE=,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=xts,ivgen-alg=plain,hash-alg=sha1 TEST_DIR/luks-aes-256-xts-plain-sha1-pwallslots.img 4194304M
-
# Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-xts-plain-sha1-pwallslots.img qiotest-145-aes-256-xts-plain-sha1-pwallslots
# Write test pattern 0xa7
@@ -2400,7 +2381,6 @@
# ================= qemu-img aes-256-cbc-essiv-auto-sha1 =================
# Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=cbc,ivgen-alg=essiv,hash-alg=sha1 TEST_DIR/luks-aes-256-cbc-essiv-auto-sha1.img 4194304M
-
# Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-essiv-auto-sha1.img qiotest-145-aes-256-cbc-essiv-auto-sha1
# Write test pattern 0xa7
@@ -2519,7 +2499,6 @@
# ================= qemu-img aes-256-cbc-plain64-sha256-sha1 =================
# Create image
qemu-img create -f luks --object secret,id=sec0,data=MTIzNDU2,format=base64 -o key-secret=sec0,iter-time=10,cipher-alg=aes-256,cipher-mode=cbc,ivgen-alg=plain64,hash-alg=sha1,ivgen-hash-alg=sha256 TEST_DIR/luks-aes-256-cbc-plain64-sha256-sha1.img 4194304M
-
# Open dev
sudo cryptsetup -q -v luksOpen TEST_DIR/luks-aes-256-cbc-plain64-sha256-sha1.img qiotest-145-aes-256-cbc-plain64-sha256-sha1
# Write test pattern 0xa7
diff --git a/tests/qemu-iotests/163 b/tests/qemu-iotests/163
index b8bfc95..e4cd4b2 100755
--- a/tests/qemu-iotests/163
+++ b/tests/qemu-iotests/163
@@ -107,8 +107,7 @@
if iotests.imgfmt == 'raw':
return
- self.assertEqual(qemu_img('check', test_img), 0,
- "Verifying image corruption")
+ qemu_img('check', test_img)
def test_empty_image(self):
qemu_img('resize', '-f', iotests.imgfmt, '--shrink', test_img,
@@ -130,8 +129,7 @@
qemu_img('resize', '-f', iotests.imgfmt, '--shrink', test_img,
self.shrink_size)
- self.assertEqual(qemu_img("compare", test_img, check_img), 0,
- "Verifying image content")
+ qemu_img("compare", test_img, check_img)
self.image_verify()
@@ -146,8 +144,7 @@
qemu_img('resize', '-f', iotests.imgfmt, '--shrink', test_img,
self.shrink_size)
- self.assertEqual(qemu_img("compare", test_img, check_img), 0,
- "Verifying image content")
+ qemu_img("compare", test_img, check_img)
self.image_verify()
diff --git a/tests/qemu-iotests/194 b/tests/qemu-iotests/194
index e44b8df..6889437 100755
--- a/tests/qemu-iotests/194
+++ b/tests/qemu-iotests/194
@@ -33,8 +33,8 @@
iotests.VM('dest') as dest_vm:
img_size = '1G'
- iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, source_img_path, img_size)
- iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, dest_img_path, img_size)
+ iotests.qemu_img_create('-f', iotests.imgfmt, source_img_path, img_size)
+ iotests.qemu_img_create('-f', iotests.imgfmt, dest_img_path, img_size)
iotests.log('Launching VMs...')
(source_vm.add_drive(source_img_path)
diff --git a/tests/qemu-iotests/202 b/tests/qemu-iotests/202
index 8eb5f32..b784dcd 100755
--- a/tests/qemu-iotests/202
+++ b/tests/qemu-iotests/202
@@ -35,8 +35,8 @@
iotests.VM() as vm:
img_size = '10M'
- iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, disk0_img_path, img_size)
- iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, disk1_img_path, img_size)
+ iotests.qemu_img_create('-f', iotests.imgfmt, disk0_img_path, img_size)
+ iotests.qemu_img_create('-f', iotests.imgfmt, disk1_img_path, img_size)
iotests.log('Launching VM...')
vm.launch()
diff --git a/tests/qemu-iotests/203 b/tests/qemu-iotests/203
index ea30e50..ab80fd0 100755
--- a/tests/qemu-iotests/203
+++ b/tests/qemu-iotests/203
@@ -33,8 +33,8 @@
iotests.VM() as vm:
img_size = '10M'
- iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, disk0_img_path, img_size)
- iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, disk1_img_path, img_size)
+ iotests.qemu_img_create('-f', iotests.imgfmt, disk0_img_path, img_size)
+ iotests.qemu_img_create('-f', iotests.imgfmt, disk1_img_path, img_size)
iotests.log('Launching VM...')
(vm.add_object('iothread,id=iothread0')
diff --git a/tests/qemu-iotests/207 b/tests/qemu-iotests/207
index 0f5c4bc..41dcf3f 100755
--- a/tests/qemu-iotests/207
+++ b/tests/qemu-iotests/207
@@ -35,7 +35,12 @@
if key == 'hash' and re.match('[0-9a-f]+', value):
return 'HASH'
return value
- return iotests.filter_qmp(qmsg, _filter)
+ if isinstance(qmsg, str):
+ # Strip key type and fingerprint
+ p = r"\S+ (key fingerprint) '(md5|sha1|sha256):[0-9a-f]+'"
+ return re.sub(p, r"\1 '\2:HASH'", qmsg)
+ else:
+ return iotests.filter_qmp(qmsg, _filter)
def blockdev_create(vm, options):
vm.blockdev_create(options, filters=[iotests.filter_qmp_testfiles, filter_hash])
diff --git a/tests/qemu-iotests/207.out b/tests/qemu-iotests/207.out
index aeb8569..05cf753 100644
--- a/tests/qemu-iotests/207.out
+++ b/tests/qemu-iotests/207.out
@@ -42,7 +42,7 @@
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "ssh", "location": {"host-key-check": {"hash": "wrong", "mode": "hash", "type": "md5"}, "path": "TEST_DIR/PID-t.img", "server": {"host": "127.0.0.1", "port": "22"}}, "size": 2097152}}}
{"return": {}}
-Job failed: remote host key does not match host_key_check 'wrong'
+Job failed: remote host key fingerprint 'md5:HASH' does not match host_key_check 'md5:wrong'
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
{"return": {}}
@@ -59,7 +59,7 @@
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "ssh", "location": {"host-key-check": {"hash": "wrong", "mode": "hash", "type": "sha1"}, "path": "TEST_DIR/PID-t.img", "server": {"host": "127.0.0.1", "port": "22"}}, "size": 2097152}}}
{"return": {}}
-Job failed: remote host key does not match host_key_check 'wrong'
+Job failed: remote host key fingerprint 'sha1:HASH' does not match host_key_check 'sha1:wrong'
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
{"return": {}}
@@ -76,7 +76,7 @@
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "ssh", "location": {"host-key-check": {"hash": "wrong", "mode": "hash", "type": "sha256"}, "path": "TEST_DIR/PID-t.img", "server": {"host": "127.0.0.1", "port": "22"}}, "size": 2097152}}}
{"return": {}}
-Job failed: remote host key does not match host_key_check 'wrong'
+Job failed: remote host key fingerprint 'sha256:HASH' does not match host_key_check 'sha256:wrong'
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
{"return": {}}
diff --git a/tests/qemu-iotests/211 b/tests/qemu-iotests/211
index f52cada..1a3b459 100755
--- a/tests/qemu-iotests/211
+++ b/tests/qemu-iotests/211
@@ -59,7 +59,7 @@
vm.shutdown()
iotests.img_info_log(disk_path)
- iotests.log(iotests.qemu_img_pipe('map', '--output=json', disk_path))
+ iotests.log(iotests.qemu_img_map(disk_path))
#
# Successful image creation (explicit defaults)
@@ -83,7 +83,7 @@
vm.shutdown()
iotests.img_info_log(disk_path)
- iotests.log(iotests.qemu_img_pipe('map', '--output=json', disk_path))
+ iotests.log(iotests.qemu_img_map(disk_path))
#
# Successful image creation (with non-default options)
@@ -107,7 +107,7 @@
vm.shutdown()
iotests.img_info_log(disk_path)
- iotests.log(iotests.qemu_img_pipe('map', '--output=json', disk_path))
+ iotests.log(iotests.qemu_img_map(disk_path))
#
# Invalid BlockdevRef
diff --git a/tests/qemu-iotests/211.out b/tests/qemu-iotests/211.out
index c4425b5..f02c754 100644
--- a/tests/qemu-iotests/211.out
+++ b/tests/qemu-iotests/211.out
@@ -17,8 +17,7 @@
virtual size: 128 MiB (134217728 bytes)
cluster_size: 1048576
-[{ "start": 0, "length": 134217728, "depth": 0, "present": true, "zero": true, "data": false}]
-
+[{"data": false, "depth": 0, "length": 134217728, "present": true, "start": 0, "zero": true}]
=== Successful image creation (explicit defaults) ===
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "file", "filename": "TEST_DIR/PID-t.vdi", "size": 0}}}
@@ -36,8 +35,7 @@
virtual size: 64 MiB (67108864 bytes)
cluster_size: 1048576
-[{ "start": 0, "length": 67108864, "depth": 0, "present": true, "zero": true, "data": false}]
-
+[{"data": false, "depth": 0, "length": 67108864, "present": true, "start": 0, "zero": true}]
=== Successful image creation (with non-default options) ===
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "file", "filename": "TEST_DIR/PID-t.vdi", "size": 0}}}
@@ -55,9 +53,7 @@
virtual size: 32 MiB (33554432 bytes)
cluster_size: 1048576
-[{ "start": 0, "length": 3072, "depth": 0, "present": true, "zero": false, "data": true, "offset": 1024},
-{ "start": 3072, "length": 33551360, "depth": 0, "present": true, "zero": true, "data": true, "offset": 4096}]
-
+[{"data": true, "depth": 0, "length": 3072, "offset": 1024, "present": true, "start": 0, "zero": false}, {"data": true, "depth": 0, "length": 33551360, "offset": 4096, "present": true, "start": 3072, "zero": true}]
=== Invalid BlockdevRef ===
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "vdi", "file": "this doesn't exist", "size": 33554432}}}
diff --git a/tests/qemu-iotests/216 b/tests/qemu-iotests/216
index c02f8d2..88b385a 100755
--- a/tests/qemu-iotests/216
+++ b/tests/qemu-iotests/216
@@ -51,10 +51,10 @@
log('--- Setting up images ---')
log('')
- assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') == 0
+ qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M')
assert qemu_io_silent(base_img_path, '-c', 'write -P 1 0M 1M') == 0
- assert qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
- '-F', iotests.imgfmt, top_img_path) == 0
+ qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
+ '-F', iotests.imgfmt, top_img_path)
assert qemu_io_silent(top_img_path, '-c', 'write -P 2 1M 1M') == 0
log('Done')
diff --git a/tests/qemu-iotests/218 b/tests/qemu-iotests/218
index 4922b4d..853ed52 100755
--- a/tests/qemu-iotests/218
+++ b/tests/qemu-iotests/218
@@ -145,7 +145,7 @@
with iotests.VM() as vm, \
iotests.FilePath('src.img') as src_img_path:
- assert qemu_img('create', '-f', iotests.imgfmt, src_img_path, '64M') == 0
+ qemu_img('create', '-f', iotests.imgfmt, src_img_path, '64M')
assert qemu_io_silent('-f', iotests.imgfmt, src_img_path,
'-c', 'write -P 42 0M 64M') == 0
diff --git a/tests/qemu-iotests/224 b/tests/qemu-iotests/224
index 38dd153..c31c55b 100755
--- a/tests/qemu-iotests/224
+++ b/tests/qemu-iotests/224
@@ -47,12 +47,11 @@
iotests.FilePath('top.img') as top_img_path, \
iotests.VM() as vm:
- assert qemu_img('create', '-f', iotests.imgfmt,
- base_img_path, '64M') == 0
- assert qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
- '-F', iotests.imgfmt, mid_img_path) == 0
- assert qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path,
- '-F', iotests.imgfmt, top_img_path) == 0
+ qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M')
+ qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
+ '-F', iotests.imgfmt, mid_img_path)
+ qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path,
+ '-F', iotests.imgfmt, top_img_path)
# Something to commit
assert qemu_io_silent(mid_img_path, '-c', 'write -P 1 0 1M') == 0
diff --git a/tests/qemu-iotests/228 b/tests/qemu-iotests/228
index a5eda2e..f79bae0 100755
--- a/tests/qemu-iotests/228
+++ b/tests/qemu-iotests/228
@@ -54,11 +54,11 @@
iotests.FilePath('top.img') as top_img_path, \
iotests.VM() as vm:
- assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') == 0
+ qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M')
# Choose a funny way to describe the backing filename
- assert qemu_img('create', '-f', iotests.imgfmt, '-b',
- 'file:' + base_img_path, '-F', iotests.imgfmt,
- top_img_path) == 0
+ qemu_img('create', '-f', iotests.imgfmt, '-b',
+ 'file:' + base_img_path, '-F', iotests.imgfmt,
+ top_img_path)
vm.launch()
@@ -172,8 +172,8 @@
# (because qemu cannot "canonicalize"/"resolve" the backing
# filename unless the backing file is opened implicitly with the
# overlay)
- assert qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
- '-F', iotests.imgfmt, top_img_path) == 0
+ qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
+ '-F', iotests.imgfmt, top_img_path)
# You can only reliably override backing options by using a node
# reference (or by specifying file.filename, but, well...)
diff --git a/tests/qemu-iotests/234 b/tests/qemu-iotests/234
index cb5f175..a9f764b 100755
--- a/tests/qemu-iotests/234
+++ b/tests/qemu-iotests/234
@@ -34,8 +34,8 @@
iotests.VM(path_suffix='a') as vm_a, \
iotests.VM(path_suffix='b') as vm_b:
- iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, backing_path, '64M')
- iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, img_path, '64M')
+ iotests.qemu_img_create('-f', iotests.imgfmt, backing_path, '64M')
+ iotests.qemu_img_create('-f', iotests.imgfmt, img_path, '64M')
os.mkfifo(fifo_a)
os.mkfifo(fifo_b)
diff --git a/tests/qemu-iotests/237 b/tests/qemu-iotests/237
index 43dfd3b..5ea13eb 100755
--- a/tests/qemu-iotests/237
+++ b/tests/qemu-iotests/237
@@ -165,8 +165,7 @@
iotests.log("")
for path in [ extent1_path, extent2_path, extent3_path ]:
- msg = iotests.qemu_img_pipe('create', '-f', imgfmt, path, '0')
- iotests.log(msg, [iotests.filter_testfiles])
+ iotests.qemu_img_create('-f', imgfmt, path, '0')
vm.add_blockdev('driver=file,filename=%s,node-name=ext1' % (extent1_path))
vm.add_blockdev('driver=file,filename=%s,node-name=ext2' % (extent2_path))
diff --git a/tests/qemu-iotests/237.out b/tests/qemu-iotests/237.out
index aeb9724..62b8865 100644
--- a/tests/qemu-iotests/237.out
+++ b/tests/qemu-iotests/237.out
@@ -129,9 +129,6 @@
=== Other subformats ===
-
-
-
== Missing extent ==
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "vmdk", "file": "node0", "size": 33554432, "subformat": "monolithicFlat"}}}
diff --git a/tests/qemu-iotests/242 b/tests/qemu-iotests/242
index 96a3015..b3afd36 100755
--- a/tests/qemu-iotests/242
+++ b/tests/qemu-iotests/242
@@ -22,7 +22,7 @@
import iotests
import json
import struct
-from iotests import qemu_img_create, qemu_io, qemu_img_pipe, \
+from iotests import qemu_img_create, qemu_io, qemu_img_info, \
file_path, img_info_log, log, filter_qemu_io
iotests.script_initialize(supported_fmts=['qcow2'],
@@ -39,8 +39,7 @@
def print_bitmap(extra_args):
log('qemu-img info dump:\n')
img_info_log(disk, extra_args=extra_args)
- result = json.loads(qemu_img_pipe('info', '--force-share',
- '--output=json', disk))
+ result = qemu_img_info('--force-share', disk)
if 'bitmaps' in result['format-specific']['data']:
bitmaps = result['format-specific']['data']['bitmaps']
log('The same bitmaps in JSON format:')
@@ -101,7 +100,7 @@
log('Write an unknown bitmap flag \'{}\' into a new QCOW2 image at offset {}'
.format(hex(bitmap_flag_unknown), flag_offset))
toggle_flag(flag_offset)
-img_info_log(disk)
+img_info_log(disk, check=False)
toggle_flag(flag_offset)
log('Unset the unknown bitmap flag \'{}\' in the bitmap directory entry:\n'
.format(hex(bitmap_flag_unknown)))
diff --git a/tests/qemu-iotests/255 b/tests/qemu-iotests/255
index 3d6d0e8..f86fa85 100755
--- a/tests/qemu-iotests/255
+++ b/tests/qemu-iotests/255
@@ -42,8 +42,8 @@
size_str = str(size)
iotests.create_image(base_path, size)
- iotests.qemu_img_log('create', '-f', iotests.imgfmt, mid_path, size_str)
- iotests.qemu_img_log('create', '-f', iotests.imgfmt, disk_path, size_str)
+ iotests.qemu_img_create('-f', iotests.imgfmt, mid_path, size_str)
+ iotests.qemu_img_create('-f', iotests.imgfmt, disk_path, size_str)
# Create a backing chain like this:
# base <- [throttled: bps-read=4096] <- mid <- overlay
@@ -92,8 +92,8 @@
size = 128 * 1024 * 1024
size_str = str(size)
- iotests.qemu_img_log('create', '-f', iotests.imgfmt, src_path, size_str)
- iotests.qemu_img_log('create', '-f', iotests.imgfmt, dst_path, size_str)
+ iotests.qemu_img_create('-f', iotests.imgfmt, src_path, size_str)
+ iotests.qemu_img_create('-f', iotests.imgfmt, dst_path, size_str)
iotests.log(iotests.qemu_io('-f', iotests.imgfmt, '-c', 'write 0 1M',
src_path),
diff --git a/tests/qemu-iotests/255.out b/tests/qemu-iotests/255.out
index 11a05a5..2e837cb 100644
--- a/tests/qemu-iotests/255.out
+++ b/tests/qemu-iotests/255.out
@@ -3,8 +3,6 @@
=== Create backing chain and start VM ===
-
-
=== Start background read requests ===
=== Run a commit job ===
@@ -21,8 +19,6 @@
=== Create images and start VM ===
-
-
wrote 1048576/1048576 bytes at offset 0
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
diff --git a/tests/qemu-iotests/257 b/tests/qemu-iotests/257
index c72c82a..e7e7a23 100755
--- a/tests/qemu-iotests/257
+++ b/tests/qemu-iotests/257
@@ -240,13 +240,14 @@
"""
expected_ret = 0 if expected_match else 1
if baseimg:
- assert qemu_img("rebase", "-u", "-b", baseimg, '-F', iotests.imgfmt,
- image) == 0
- ret = qemu_img("compare", image, reference)
+ qemu_img("rebase", "-u", "-b", baseimg, '-F', iotests.imgfmt, image)
+
+ sub = qemu_img("compare", image, reference, check=False)
+
log('qemu_img compare "{:s}" "{:s}" ==> {:s}, {:s}'.format(
image, reference,
- "Identical" if ret == 0 else "Mismatch",
- "OK!" if ret == expected_ret else "ERROR!"),
+ "Identical" if sub.returncode == 0 else "Mismatch",
+ "OK!" if sub.returncode == expected_ret else "ERROR!"),
filters=[iotests.filter_testfiles])
def test_bitmap_sync(bsync_mode, msync_mode='bitmap', failure=None):
diff --git a/tests/qemu-iotests/258 b/tests/qemu-iotests/258
index a661820..7798a04 100755
--- a/tests/qemu-iotests/258
+++ b/tests/qemu-iotests/258
@@ -75,13 +75,13 @@
# It is important to use raw for the base layer (so that
# permissions are just handed through to the protocol layer)
- assert qemu_img('create', '-f', 'raw', node0_path, '64M') == 0
+ qemu_img('create', '-f', 'raw', node0_path, '64M')
stream_throttle=None
commit_throttle=None
for path in [node1_path, node2_path, node3_path, node4_path]:
- assert qemu_img('create', '-f', iotests.imgfmt, path, '64M') == 0
+ qemu_img('create', '-f', iotests.imgfmt, path, '64M')
if write_to_stream_node:
# This is what (most of the time) makes commit finish
diff --git a/tests/qemu-iotests/262 b/tests/qemu-iotests/262
index 32d6998..2294fd5 100755
--- a/tests/qemu-iotests/262
+++ b/tests/qemu-iotests/262
@@ -51,7 +51,7 @@
vm.add_device('virtio-blk,drive=%s,iothread=iothread0' % root)
- iotests.qemu_img_pipe('create', '-f', iotests.imgfmt, img_path, '64M')
+ iotests.qemu_img_create('-f', iotests.imgfmt, img_path, '64M')
os.mkfifo(fifo)
diff --git a/tests/qemu-iotests/266 b/tests/qemu-iotests/266
index 71ce81d..8fc3807 100755
--- a/tests/qemu-iotests/266
+++ b/tests/qemu-iotests/266
@@ -137,7 +137,7 @@
iotests.log('')
vm.shutdown()
- iotests.img_info_log(file_path)
+ iotests.img_info_log(file_path, check=False)
iotests.script_main(main,
diff --git a/tests/qemu-iotests/274 b/tests/qemu-iotests/274
index 080a90f..2495e05 100755
--- a/tests/qemu-iotests/274
+++ b/tests/qemu-iotests/274
@@ -31,12 +31,11 @@
size_diff = size_long - size_short
def create_chain() -> None:
- iotests.qemu_img_log('create', '-f', iotests.imgfmt, base,
- str(size_long))
- iotests.qemu_img_log('create', '-f', iotests.imgfmt, '-b', base,
- '-F', iotests.imgfmt, mid, str(size_short))
- iotests.qemu_img_log('create', '-f', iotests.imgfmt, '-b', mid,
- '-F', iotests.imgfmt, top, str(size_long))
+ iotests.qemu_img_create('-f', iotests.imgfmt, base, str(size_long))
+ iotests.qemu_img_create('-f', iotests.imgfmt, '-b', base,
+ '-F', iotests.imgfmt, mid, str(size_short))
+ iotests.qemu_img_create('-f', iotests.imgfmt, '-b', mid,
+ '-F', iotests.imgfmt, top, str(size_long))
iotests.qemu_io_log('-c', 'write -P 1 0 %d' % size_long, base)
@@ -160,9 +159,9 @@
('off', '512k', '256k', '500k', '436k')]:
iotests.log('=== preallocation=%s ===' % prealloc)
- iotests.qemu_img_log('create', '-f', iotests.imgfmt, base, base_size)
- iotests.qemu_img_log('create', '-f', iotests.imgfmt, '-b', base,
- '-F', iotests.imgfmt, top, top_size_old)
+ iotests.qemu_img_create('-f', iotests.imgfmt, base, base_size)
+ iotests.qemu_img_create('-f', iotests.imgfmt, '-b', base,
+ '-F', iotests.imgfmt, top, top_size_old)
iotests.qemu_io_log('-c', 'write -P 1 %s 64k' % off, base)
# After this, top_size_old to base_size should be allocated/zeroed.
diff --git a/tests/qemu-iotests/274.out b/tests/qemu-iotests/274.out
index 1ce40d8..acd8b16 100644
--- a/tests/qemu-iotests/274.out
+++ b/tests/qemu-iotests/274.out
@@ -1,7 +1,4 @@
== Commit tests ==
-
-
-
wrote 2097152/2097152 bytes at offset 0
2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -63,9 +60,6 @@
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
=== Testing HMP commit (top -> mid) ===
-
-
-
wrote 2097152/2097152 bytes at offset 0
2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -92,9 +86,6 @@
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
=== Testing QMP active commit (top -> mid) ===
-
-
-
wrote 2097152/2097152 bytes at offset 0
2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -127,9 +118,6 @@
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
=== Testing qemu-img commit (top -> base) ===
-
-
-
wrote 2097152/2097152 bytes at offset 0
2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -154,9 +142,6 @@
1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
=== Testing QMP active commit (top -> base) ===
-
-
-
wrote 2097152/2097152 bytes at offset 0
2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -190,8 +175,6 @@
== Resize tests ==
=== preallocation=off ===
-
-
wrote 65536/65536 bytes at offset 5368709120
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -207,8 +190,6 @@
{ "start": 1073741824, "length": 7516192768, "depth": 0, "present": true, "zero": true, "data": false}]
=== preallocation=metadata ===
-
-
wrote 65536/65536 bytes at offset 33285996544
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -229,8 +210,6 @@
{ "start": 34896609280, "length": 536870912, "depth": 0, "present": true, "zero": true, "data": false, "offset": 2685075456}]
=== preallocation=falloc ===
-
-
wrote 65536/65536 bytes at offset 9437184
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -246,8 +225,6 @@
{ "start": 5242880, "length": 10485760, "depth": 0, "present": true, "zero": false, "data": true, "offset": 327680}]
=== preallocation=full ===
-
-
wrote 65536/65536 bytes at offset 11534336
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -263,8 +240,6 @@
{ "start": 8388608, "length": 4194304, "depth": 0, "present": true, "zero": false, "data": true, "offset": 327680}]
=== preallocation=off ===
-
-
wrote 65536/65536 bytes at offset 259072
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -281,8 +256,6 @@
{ "start": 262144, "length": 262144, "depth": 0, "present": true, "zero": true, "data": false}]
=== preallocation=off ===
-
-
wrote 65536/65536 bytes at offset 344064
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
@@ -298,8 +271,6 @@
{ "start": 262144, "length": 262144, "depth": 0, "present": true, "zero": true, "data": false}]
=== preallocation=off ===
-
-
wrote 65536/65536 bytes at offset 446464
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
diff --git a/tests/qemu-iotests/280 b/tests/qemu-iotests/280
index 628f3c3..5f50500 100755
--- a/tests/qemu-iotests/280
+++ b/tests/qemu-iotests/280
@@ -33,7 +33,7 @@
iotests.FilePath('top') as top_path, \
iotests.VM() as vm:
- iotests.qemu_img_log('create', '-f', iotests.imgfmt, base_path, '64M')
+ iotests.qemu_img_create('-f', iotests.imgfmt, base_path, '64M')
iotests.log('=== Launch VM ===')
vm.add_object('iothread,id=iothread0')
diff --git a/tests/qemu-iotests/280.out b/tests/qemu-iotests/280.out
index e39164c..c75f437 100644
--- a/tests/qemu-iotests/280.out
+++ b/tests/qemu-iotests/280.out
@@ -1,4 +1,3 @@
-
=== Launch VM ===
Enabling migration QMP events on VM...
{"return": {}}
diff --git a/tests/qemu-iotests/296 b/tests/qemu-iotests/296
index f80ef34..0d21b74 100755
--- a/tests/qemu-iotests/296
+++ b/tests/qemu-iotests/296
@@ -76,7 +76,7 @@
# create the encrypted block device using qemu-img
def createImg(self, file, secret):
- output = iotests.qemu_img_pipe(
+ iotests.qemu_img(
'create',
'--object', *secret.to_cmdline_object(),
'-f', iotests.imgfmt,
@@ -84,8 +84,7 @@
'-o', 'iter-time=10',
file,
'1M')
-
- iotests.log(output, filters=[iotests.filter_test_dir])
+ iotests.log('')
# attempts to add a key using qemu-img
def addKey(self, file, secret, new_secret):
@@ -99,7 +98,7 @@
}
}
- output = iotests.qemu_img_pipe(
+ output = iotests.qemu_img(
'amend',
'--object', *secret.to_cmdline_object(),
'--object', *new_secret.to_cmdline_object(),
@@ -108,8 +107,9 @@
'-o', 'new-secret=' + new_secret.id(),
'-o', 'iter-time=10',
- "json:" + json.dumps(image_options)
- )
+ "json:" + json.dumps(image_options),
+ check=False # Expected to fail. Log output.
+ ).stdout
iotests.log(output, filters=[iotests.filter_test_dir])
diff --git a/tests/qemu-iotests/303 b/tests/qemu-iotests/303
index 16c2e10..93aa5ce 100755
--- a/tests/qemu-iotests/303
+++ b/tests/qemu-iotests/303
@@ -38,7 +38,7 @@
if disabled:
args.append('--disable')
- iotests.qemu_img_pipe(*args)
+ iotests.qemu_img(*args)
def write_to_disk(offset, size):
diff --git a/tests/qemu-iotests/310 b/tests/qemu-iotests/310
index 33c3411..e3bfedc 100755
--- a/tests/qemu-iotests/310
+++ b/tests/qemu-iotests/310
@@ -43,15 +43,15 @@
log('--- Setting up images ---')
log('')
- assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') == 0
+ qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M')
assert qemu_io_silent(base_img_path, '-c', 'write -P 1 0M 1M') == 0
assert qemu_io_silent(base_img_path, '-c', 'write -P 1 3M 1M') == 0
- assert qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
- '-F', iotests.imgfmt, mid_img_path) == 0
+ qemu_img('create', '-f', iotests.imgfmt, '-b', base_img_path,
+ '-F', iotests.imgfmt, mid_img_path)
assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 2M 1M') == 0
assert qemu_io_silent(mid_img_path, '-c', 'write -P 3 4M 1M') == 0
- assert qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path,
- '-F', iotests.imgfmt, top_img_path) == 0
+ qemu_img('create', '-f', iotests.imgfmt, '-b', mid_img_path,
+ '-F', iotests.imgfmt, top_img_path)
assert qemu_io_silent(top_img_path, '-c', 'write -P 2 1M 1M') == 0
# 0 1 2 3 4
@@ -105,8 +105,7 @@
log('')
# Detach backing to check that we can read the data from the top level now
- assert qemu_img('rebase', '-u', '-b', '', '-f', iotests.imgfmt,
- top_img_path) == 0
+ qemu_img('rebase', '-u', '-b', '', '-f', iotests.imgfmt, top_img_path)
assert qemu_io_silent(top_img_path, '-c', 'read -P 0 0 1M') == 0
assert qemu_io_silent(top_img_path, '-c', 'read -P 2 1M 1M') == 0
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
index 9790411..cc9f1a5 100644
--- a/tests/qemu-iotests/common.filter
+++ b/tests/qemu-iotests/common.filter
@@ -106,13 +106,13 @@
# replace block job offset
_filter_block_job_offset()
{
- sed -e 's/, "offset": [0-9]\+,/, "offset": OFFSET,/'
+ gsed -e 's/, "offset": [0-9]\+,/, "offset": OFFSET,/'
}
# replace block job len
_filter_block_job_len()
{
- sed -e 's/, "len": [0-9]\+,/, "len": LEN,/g'
+ gsed -e 's/, "len": [0-9]\+,/, "len": LEN,/g'
}
# replace actual image size (depends on the host filesystem)
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 508adad..fcec3e5 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -37,9 +37,10 @@
from contextlib import contextmanager
+from qemu.aqmp.legacy import QEMUMonitorProtocol
from qemu.machine import qtest
from qemu.qmp import QMPMessage
-from qemu.aqmp.legacy import QEMUMonitorProtocol
+from qemu.utils import VerboseProcessError
# Use this logger for logging messages directly from the iotests module
logger = logging.getLogger('qemu.iotests')
@@ -206,18 +207,50 @@
return result
-def qemu_img_pipe_and_status(*args: str) -> Tuple[str, int]:
+def qemu_img(*args: str, check: bool = True, combine_stdio: bool = True
+ ) -> 'subprocess.CompletedProcess[str]':
"""
- Run qemu-img and return both its output and its exit code
- """
- is_create = bool(args and args[0] == 'create')
- full_args = qemu_img_args + qemu_img_create_prepare_args(list(args))
- return qemu_tool_pipe_and_status('qemu-img', full_args,
- drop_successful_output=is_create)
+ Run qemu_img and return the status code and console output.
-def qemu_img(*args: str) -> int:
- '''Run qemu-img and return the exit code'''
- return qemu_img_pipe_and_status(*args)[1]
+ This function always prepends QEMU_IMG_OPTIONS and may further alter
+ the args for 'create' commands.
+
+ :param args: command-line arguments to qemu-img.
+ :param check: Enforce a return code of zero.
+ :param combine_stdio: set to False to keep stdout/stderr separated.
+
+ :raise VerboseProcessError:
+ When the return code is negative, or on any non-zero exit code
+ when 'check=True' was provided (the default). This exception has
+ 'stdout', 'stderr', and 'returncode' properties that may be
+ inspected to show greater detail. If this exception is not
+ handled, the command-line, return code, and all console output
+ will be included at the bottom of the stack trace.
+
+ :return:
+ a CompletedProcess. This object has args, returncode, and stdout
+ properties. If streams are not combined, it will also have a
+ stderr property.
+ """
+ full_args = qemu_img_args + qemu_img_create_prepare_args(list(args))
+
+ subp = subprocess.run(
+ full_args,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT if combine_stdio else subprocess.PIPE,
+ universal_newlines=True,
+ check=False
+ )
+
+ if check and subp.returncode or (subp.returncode < 0):
+ raise VerboseProcessError(
+ subp.returncode, full_args,
+ output=subp.stdout,
+ stderr=subp.stderr,
+ )
+
+ return subp
+
def ordered_qmp(qmsg, conv_keys=True):
# Dictionaries are not ordered prior to 3.6, therefore:
@@ -232,26 +265,63 @@
return od
return qmsg
-def qemu_img_create(*args):
+def qemu_img_create(*args: str) -> 'subprocess.CompletedProcess[str]':
return qemu_img('create', *args)
-def qemu_img_measure(*args):
- return json.loads(qemu_img_pipe("measure", "--output", "json", *args))
+def qemu_img_json(*args: str) -> Any:
+ """
+ Run qemu-img and return its output as deserialized JSON.
-def qemu_img_check(*args):
- return json.loads(qemu_img_pipe("check", "--output", "json", *args))
+ :raise CalledProcessError:
+ When qemu-img crashes, or returns a non-zero exit code without
+ producing a valid JSON document to stdout.
+ :raise JSONDecoderError:
+ When qemu-img returns 0, but failed to produce a valid JSON document.
-def qemu_img_pipe(*args: str) -> str:
- '''Run qemu-img and return its output'''
- return qemu_img_pipe_and_status(*args)[0]
+ :return: A deserialized JSON object; probably a dict[str, Any].
+ """
+ try:
+ res = qemu_img(*args, combine_stdio=False)
+ except subprocess.CalledProcessError as exc:
+ # Terminated due to signal. Don't bother.
+ if exc.returncode < 0:
+ raise
-def qemu_img_log(*args):
- result = qemu_img_pipe(*args)
- log(result, filters=[filter_testfiles])
+ # Commands like 'check' can return failure (exit codes 2 and 3)
+ # to indicate command completion, but with errors found. For
+ # multi-command flexibility, ignore the exact error codes and
+ # *try* to load JSON.
+ try:
+ return json.loads(exc.stdout)
+ except json.JSONDecodeError:
+ # Nope. This thing is toast. Raise the /process/ error.
+ pass
+ raise
+
+ return json.loads(res.stdout)
+
+def qemu_img_measure(*args: str) -> Any:
+ return qemu_img_json("measure", "--output", "json", *args)
+
+def qemu_img_check(*args: str) -> Any:
+ return qemu_img_json("check", "--output", "json", *args)
+
+def qemu_img_info(*args: str) -> Any:
+ return qemu_img_json('info', "--output", "json", *args)
+
+def qemu_img_map(*args: str) -> Any:
+ return qemu_img_json('map', "--output", "json", *args)
+
+def qemu_img_log(*args: str, check: bool = True
+ ) -> 'subprocess.CompletedProcess[str]':
+ result = qemu_img(*args, check=check)
+ log(result.stdout, filters=[filter_testfiles])
return result
-def img_info_log(filename, filter_path=None, use_image_opts=False,
- extra_args=()):
+def img_info_log(filename: str, filter_path: Optional[str] = None,
+ use_image_opts: bool = False, extra_args: Sequence[str] = (),
+ check: bool = True,
+ ) -> None:
args = ['info']
if use_image_opts:
args.append('--image-opts')
@@ -260,7 +330,7 @@
args += extra_args
args.append(filename)
- output = qemu_img_pipe(*args)
+ output = qemu_img(*args, check=check).stdout
if not filter_path:
filter_path = filename
log(filter_img_info(output, filter_path))
@@ -465,10 +535,22 @@
p.kill()
p.wait()
-def compare_images(img1, img2, fmt1=imgfmt, fmt2=imgfmt):
- '''Return True if two image files are identical'''
- return qemu_img('compare', '-f', fmt1,
- '-F', fmt2, img1, img2) == 0
+def compare_images(img1: str, img2: str,
+ fmt1: str = imgfmt, fmt2: str = imgfmt) -> bool:
+ """
+ Compare two images with QEMU_IMG; return True if they are identical.
+
+ :raise CalledProcessError:
+ when qemu-img crashes or returns a status code of anything other
+ than 0 (identical) or 1 (different).
+ """
+ try:
+ qemu_img('compare', '-f', fmt1, '-F', fmt2, img1, img2)
+ return True
+ except subprocess.CalledProcessError as exc:
+ if exc.returncode == 1:
+ return False
+ raise
def create_image(name, size):
'''Create a fully-allocated raw image with sector markers'''
@@ -479,10 +561,14 @@
file.write(sector)
i = i + 512
-def image_size(img):
- '''Return image's virtual size'''
- r = qemu_img_pipe('info', '--output=json', '-f', imgfmt, img)
- return json.loads(r)['virtual-size']
+def image_size(img: str) -> int:
+ """Return image's virtual size"""
+ value = qemu_img_info('-f', imgfmt, img)['virtual-size']
+ if not isinstance(value, int):
+ type_name = type(value).__name__
+ raise TypeError("Expected 'int' for 'virtual-size', "
+ f"got '{value}' of type '{type_name}'")
+ return value
def is_str(val):
return isinstance(val, str)
@@ -521,8 +607,10 @@
# Iterate through either lists or dicts;
if isinstance(qmsg, list):
items = enumerate(qmsg)
- else:
+ elif isinstance(qmsg, dict):
items = qmsg.items()
+ else:
+ return filter_fn(None, qmsg)
for k, v in items:
if isinstance(v, (dict, list)):
@@ -858,8 +946,12 @@
return result
# Returns None on success, and an error string on failure
- def run_job(self, job, auto_finalize=True, auto_dismiss=False,
- pre_finalize=None, cancel=False, wait=60.0):
+ def run_job(self, job: str, auto_finalize: bool = True,
+ auto_dismiss: bool = False,
+ pre_finalize: Optional[Callable[[], None]] = None,
+ cancel: bool = False, wait: float = 60.0,
+ filters: Iterable[Callable[[Any], Any]] = (),
+ ) -> Optional[str]:
"""
run_job moves a job from creation through to dismissal.
@@ -889,7 +981,7 @@
while True:
ev = filter_qmp_event(self.events_wait(events, timeout=wait))
if ev['event'] != 'JOB_STATUS_CHANGE':
- log(ev)
+ log(ev, filters=filters)
continue
status = ev['data']['status']
if status == 'aborting':
@@ -897,18 +989,18 @@
for j in result['return']:
if j['id'] == job:
error = j['error']
- log('Job failed: %s' % (j['error']))
+ log('Job failed: %s' % (j['error']), filters=filters)
elif status == 'ready':
- self.qmp_log('job-complete', id=job)
+ self.qmp_log('job-complete', id=job, filters=filters)
elif status == 'pending' and not auto_finalize:
if pre_finalize:
pre_finalize()
if cancel:
- self.qmp_log('job-cancel', id=job)
+ self.qmp_log('job-cancel', id=job, filters=filters)
else:
- self.qmp_log('job-finalize', id=job)
+ self.qmp_log('job-finalize', id=job, filters=filters)
elif status == 'concluded' and not auto_dismiss:
- self.qmp_log('job-dismiss', id=job)
+ self.qmp_log('job-dismiss', id=job, filters=filters)
elif status == 'null':
return error
@@ -921,7 +1013,7 @@
if 'return' in result:
assert result['return'] == {}
- job_result = self.run_job(job_id)
+ job_result = self.run_job(job_id, filters=filters)
else:
job_result = result['error']
@@ -1332,8 +1424,8 @@
notrun(f'not suitable for this imgopts: {imgopts}')
-def supports_quorum():
- return 'quorum' in qemu_img_pipe('--help')
+def supports_quorum() -> bool:
+ return 'quorum' in qemu_img('--help').stdout
def verify_quorum():
'''Skip test suite if quorum support is not available'''
@@ -1349,20 +1441,20 @@
"""
img_file = f'{test_dir}/luks-test.luks'
- (output, status) = \
- qemu_img_pipe_and_status('create', '-f', 'luks',
- '--object', luks_default_secret_object,
- '-o', luks_default_key_secret_opt,
- '-o', 'iter-time=10',
- img_file, '1G')
+ res = qemu_img('create', '-f', 'luks',
+ '--object', luks_default_secret_object,
+ '-o', luks_default_key_secret_opt,
+ '-o', 'iter-time=10',
+ img_file, '1G',
+ check=False)
try:
os.remove(img_file)
except OSError:
pass
- if status != 0:
- reason = output
- for line in output.splitlines():
+ if res.returncode:
+ reason = res.stdout
+ for line in res.stdout.splitlines():
if img_file + ':' in line:
reason = line.split(img_file + ':', 1)[1].strip()
break
diff --git a/tests/qemu-iotests/testenv.py b/tests/qemu-iotests/testenv.py
index b11e943..a864c74 100644
--- a/tests/qemu-iotests/testenv.py
+++ b/tests/qemu-iotests/testenv.py
@@ -235,6 +235,8 @@
('aarch64', 'virt'),
('avr', 'mega2560'),
('m68k', 'virt'),
+ ('riscv32', 'virt'),
+ ('riscv64', 'virt'),
('rx', 'gdbsim-r5f562n8'),
('tricore', 'tricore_testboard')
)
diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunner.py
index 5c20722..aae70a8 100644
--- a/tests/qemu-iotests/testrunner.py
+++ b/tests/qemu-iotests/testrunner.py
@@ -388,6 +388,7 @@
if self.tap:
self.env.print_env('# ')
+ print('1..%d' % len(tests))
else:
self.env.print_env()
diff --git a/tests/qemu-iotests/tests/block-status-cache b/tests/qemu-iotests/tests/block-status-cache
index 6fa10bb..5a7bc2c 100755
--- a/tests/qemu-iotests/tests/block-status-cache
+++ b/tests/qemu-iotests/tests/block-status-cache
@@ -22,7 +22,7 @@
import os
import signal
import iotests
-from iotests import qemu_img_create, qemu_img_pipe, qemu_nbd
+from iotests import qemu_img_create, qemu_img_map, qemu_nbd
image_size = 1 * 1024 * 1024
@@ -35,8 +35,7 @@
class TestBscWithNbd(iotests.QMPTestCase):
def setUp(self) -> None:
"""Just create an empty image with a read-only NBD server on it"""
- assert qemu_img_create('-f', iotests.imgfmt, test_img,
- str(image_size)) == 0
+ qemu_img_create('-f', iotests.imgfmt, test_img, str(image_size))
# Pass --allocation-depth to enable the qemu:allocation-depth context,
# which we are going to query to provoke a block-status inquiry with
@@ -77,8 +76,7 @@
# to allocate the first sector to facilitate alignment probing), and
# then the rest to be zero. The BSC will thus contain (if anything)
# one range covering the first sector.
- map_pre = qemu_img_pipe('map', '--output=json', '--image-opts',
- nbd_img_opts)
+ map_pre = qemu_img_map('--image-opts', nbd_img_opts)
# qemu:allocation-depth maps for want_zero=false.
# want_zero=false should (with the file driver, which the server is
@@ -112,14 +110,12 @@
# never loop too many times here.
for _ in range(2):
# (Ignore the result, this is just to contaminate the cache)
- qemu_img_pipe('map', '--output=json', '--image-opts',
- nbd_img_opts_alloc_depth)
+ qemu_img_map('--image-opts', nbd_img_opts_alloc_depth)
# Now let's see whether the cache reports everything as data, or
# whether we get correct information (i.e. the same as we got on our
# first attempt).
- map_post = qemu_img_pipe('map', '--output=json', '--image-opts',
- nbd_img_opts)
+ map_post = qemu_img_map('--image-opts', nbd_img_opts)
if map_pre != map_post:
print('ERROR: Map information differs before and after querying ' +
diff --git a/tests/qemu-iotests/tests/graph-changes-while-io b/tests/qemu-iotests/tests/graph-changes-while-io
index 567e8cf..7664f33 100755
--- a/tests/qemu-iotests/tests/graph-changes-while-io
+++ b/tests/qemu-iotests/tests/graph-changes-while-io
@@ -34,16 +34,15 @@
"""
Do some I/O requests on `nbd_sock`.
"""
- assert qemu_img('bench', '-f', 'raw', '-c', '2000000',
- f'nbd+unix:///node0?socket={nbd_sock}') == 0
+ qemu_img('bench', '-f', 'raw', '-c', '2000000',
+ f'nbd+unix:///node0?socket={nbd_sock}')
class TestGraphChangesWhileIO(QMPTestCase):
def setUp(self) -> None:
# Create an overlay that can be added at runtime on top of the
# null-co block node that will receive I/O
- assert qemu_img_create('-f', imgfmt, '-F', 'raw', '-b', 'null-co://',
- top) == 0
+ qemu_img_create('-f', imgfmt, '-F', 'raw', '-b', 'null-co://', top)
# QSD instance with a null-co block node in an I/O thread,
# exported over NBD (on `nbd_sock`, export name "node0")
diff --git a/tests/qemu-iotests/tests/image-fleecing b/tests/qemu-iotests/tests/image-fleecing
index c562786..b7e5076 100755
--- a/tests/qemu-iotests/tests/image-fleecing
+++ b/tests/qemu-iotests/tests/image-fleecing
@@ -63,18 +63,18 @@
log('--- Setting up images ---')
log('')
- assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') == 0
+ qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M')
if bitmap:
- assert qemu_img('bitmap', '--add', base_img_path, 'bitmap0') == 0
+ qemu_img('bitmap', '--add', base_img_path, 'bitmap0')
if use_snapshot_access_filter:
assert use_cbw
- assert qemu_img('create', '-f', 'raw', fleece_img_path, '64M') == 0
+ qemu_img('create', '-f', 'raw', fleece_img_path, '64M')
else:
- assert qemu_img('create', '-f', 'qcow2', fleece_img_path, '64M') == 0
+ qemu_img('create', '-f', 'qcow2', fleece_img_path, '64M')
if push_backup:
- assert qemu_img('create', '-f', 'qcow2', target_img_path, '64M') == 0
+ qemu_img('create', '-f', 'qcow2', target_img_path, '64M')
for p in patterns:
qemu_io('-f', iotests.imgfmt,
diff --git a/tests/qemu-iotests/tests/mirror-ready-cancel-error b/tests/qemu-iotests/tests/mirror-ready-cancel-error
index 770ffca..1d0e333 100755
--- a/tests/qemu-iotests/tests/mirror-ready-cancel-error
+++ b/tests/qemu-iotests/tests/mirror-ready-cancel-error
@@ -31,10 +31,8 @@
class TestMirrorReadyCancelError(iotests.QMPTestCase):
def setUp(self) -> None:
- assert iotests.qemu_img_create('-f', iotests.imgfmt, source,
- str(image_size)) == 0
- assert iotests.qemu_img_create('-f', iotests.imgfmt, target,
- str(image_size)) == 0
+ iotests.qemu_img_create('-f', iotests.imgfmt, source, str(image_size))
+ iotests.qemu_img_create('-f', iotests.imgfmt, target, str(image_size))
# Ensure that mirror will copy something before READY so the
# target format layer will forward the pre-READY flush to its
diff --git a/tests/qemu-iotests/tests/mirror-top-perms b/tests/qemu-iotests/tests/mirror-top-perms
index b584997..6ac8d5e 100755
--- a/tests/qemu-iotests/tests/mirror-top-perms
+++ b/tests/qemu-iotests/tests/mirror-top-perms
@@ -34,8 +34,7 @@
class TestMirrorTopPerms(iotests.QMPTestCase):
def setUp(self):
- assert qemu_img('create', '-f', iotests.imgfmt, source,
- str(image_size)) == 0
+ qemu_img('create', '-f', iotests.imgfmt, source, str(image_size))
self.vm = iotests.VM()
self.vm.add_drive(source)
self.vm.add_blockdev(f'null-co,node-name=null,size={image_size}')
diff --git a/tests/qemu-iotests/tests/parallels-read-bitmap b/tests/qemu-iotests/tests/parallels-read-bitmap
index af6b9c5..38ab5fa 100755
--- a/tests/qemu-iotests/tests/parallels-read-bitmap
+++ b/tests/qemu-iotests/tests/parallels-read-bitmap
@@ -18,9 +18,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-import json
import iotests
-from iotests import qemu_nbd_popen, qemu_img_pipe, log, file_path
+from iotests import qemu_nbd_popen, qemu_img_map, log, file_path
iotests.script_initialize(supported_fmts=['parallels'])
@@ -36,8 +35,7 @@
with qemu_nbd_popen('--read-only', f'--socket={nbd_sock}',
f'--bitmap={bitmap}', '-f', iotests.imgfmt, disk):
- out = qemu_img_pipe('map', '--output=json', '--image-opts', nbd_opts)
- chunks = json.loads(out)
+ chunks = qemu_img_map('--image-opts', nbd_opts)
cluster = 64 * 1024
log('dirty clusters (cluster size is 64K):')
diff --git a/tests/qemu-iotests/tests/remove-bitmap-from-backing b/tests/qemu-iotests/tests/remove-bitmap-from-backing
index 3c397b0..15be32d 100755
--- a/tests/qemu-iotests/tests/remove-bitmap-from-backing
+++ b/tests/qemu-iotests/tests/remove-bitmap-from-backing
@@ -19,7 +19,7 @@
#
import iotests
-from iotests import log, qemu_img_create, qemu_img, qemu_img_pipe
+from iotests import log, qemu_img_create, qemu_img, qemu_img_info
iotests.script_initialize(supported_fmts=['qcow2'],
unsupported_imgopts=['compat'])
@@ -27,13 +27,13 @@
top, base = iotests.file_path('top', 'base')
size = '1M'
-assert qemu_img_create('-f', iotests.imgfmt, base, size) == 0
-assert qemu_img_create('-f', iotests.imgfmt, '-b', base,
- '-F', iotests.imgfmt, top, size) == 0
+qemu_img_create('-f', iotests.imgfmt, base, size)
+qemu_img_create('-f', iotests.imgfmt, '-b', base,
+ '-F', iotests.imgfmt, top, size)
-assert qemu_img('bitmap', '--add', base, 'bitmap0') == 0
+qemu_img('bitmap', '--add', base, 'bitmap0')
# Just assert that our method of checking bitmaps in the image works.
-assert 'bitmaps' in qemu_img_pipe('info', base)
+assert 'bitmaps' in qemu_img_info(base)['format-specific']['data']
vm = iotests.VM().add_drive(top, 'backing.node-name=base')
vm.launch()
@@ -68,5 +68,5 @@
vm.shutdown()
-if 'bitmaps' in qemu_img_pipe('info', base):
+if 'bitmaps' in qemu_img_info(base)['format-specific']['data']:
log('ERROR: Bitmap is still in the base image')
diff --git a/tests/qemu-iotests/tests/stream-error-on-reset b/tests/qemu-iotests/tests/stream-error-on-reset
index 7eaedb2..389ae82 100755
--- a/tests/qemu-iotests/tests/stream-error-on-reset
+++ b/tests/qemu-iotests/tests/stream-error-on-reset
@@ -54,9 +54,9 @@
to it will result in an error
- top image is attached to a virtio-scsi device
"""
- assert qemu_img_create('-f', imgfmt, base, str(image_size)) == 0
+ qemu_img_create('-f', imgfmt, base, str(image_size))
assert qemu_io_silent('-c', f'write 0 {data_size}', base) == 0
- assert qemu_img_create('-f', imgfmt, top, str(image_size)) == 0
+ qemu_img_create('-f', imgfmt, top, str(image_size))
self.vm = iotests.VM()
self.vm.add_args('-accel', 'tcg') # Make throttling work properly
diff --git a/tests/qtest/e1000e-test.c b/tests/qtest/e1000e-test.c
index 0273fe4..e648fdd 100644
--- a/tests/qtest/e1000e-test.c
+++ b/tests/qtest/e1000e-test.c
@@ -91,9 +91,9 @@
g_assert_cmphex(le32_to_cpu(descr.upper.data) & dsta_dd, ==, dsta_dd);
/* Check data sent to the backend */
- ret = qemu_recv(test_sockets[0], &recv_len, sizeof(recv_len), 0);
+ ret = recv(test_sockets[0], &recv_len, sizeof(recv_len), 0);
g_assert_cmpint(ret, == , sizeof(recv_len));
- ret = qemu_recv(test_sockets[0], buffer, 64, 0);
+ ret = recv(test_sockets[0], buffer, 64, 0);
g_assert_cmpint(ret, >=, 5);
g_assert_cmpstr(buffer, == , "TEST");
diff --git a/tests/qtest/libqos/libqtest.h b/tests/qtest/libqos/libqtest.h
index cf38d27..552667f 100644
--- a/tests/qtest/libqos/libqtest.h
+++ b/tests/qtest/libqos/libqtest.h
@@ -31,7 +31,7 @@
*
* Returns: #QTestState instance.
*/
-QTestState *qtest_initf(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
+QTestState *qtest_initf(const char *fmt, ...) G_GNUC_PRINTF(1, 2);
/**
* qtest_vinitf:
@@ -43,7 +43,7 @@
*
* Returns: #QTestState instance.
*/
-QTestState *qtest_vinitf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0);
+QTestState *qtest_vinitf(const char *fmt, va_list ap) G_GNUC_PRINTF(1, 0);
/**
* qtest_init:
@@ -106,7 +106,7 @@
*/
QDict *qtest_qmp_fds(QTestState *s, int *fds, size_t fds_num,
const char *fmt, ...)
- GCC_FMT_ATTR(4, 5);
+ G_GNUC_PRINTF(4, 5);
/**
* qtest_qmp:
@@ -118,7 +118,7 @@
* Sends a QMP message to QEMU and returns the response.
*/
QDict *qtest_qmp(QTestState *s, const char *fmt, ...)
- GCC_FMT_ATTR(2, 3);
+ G_GNUC_PRINTF(2, 3);
/**
* qtest_qmp_send:
@@ -130,7 +130,7 @@
* Sends a QMP message to QEMU and leaves the response in the stream.
*/
void qtest_qmp_send(QTestState *s, const char *fmt, ...)
- GCC_FMT_ATTR(2, 3);
+ G_GNUC_PRINTF(2, 3);
/**
* qtest_qmp_send_raw:
@@ -141,7 +141,7 @@
* this is useful for negative tests.
*/
void qtest_qmp_send_raw(QTestState *s, const char *fmt, ...)
- GCC_FMT_ATTR(2, 3);
+ G_GNUC_PRINTF(2, 3);
/**
* qtest_socket_server:
@@ -165,7 +165,7 @@
*/
QDict *qtest_vqmp_fds(QTestState *s, int *fds, size_t fds_num,
const char *fmt, va_list ap)
- GCC_FMT_ATTR(4, 0);
+ G_GNUC_PRINTF(4, 0);
/**
* qtest_vqmp:
@@ -178,7 +178,7 @@
* Sends a QMP message to QEMU and returns the response.
*/
QDict *qtest_vqmp(QTestState *s, const char *fmt, va_list ap)
- GCC_FMT_ATTR(2, 0);
+ G_GNUC_PRINTF(2, 0);
/**
* qtest_qmp_vsend_fds:
@@ -194,7 +194,7 @@
*/
void qtest_qmp_vsend_fds(QTestState *s, int *fds, size_t fds_num,
const char *fmt, va_list ap)
- GCC_FMT_ATTR(4, 0);
+ G_GNUC_PRINTF(4, 0);
/**
* qtest_qmp_vsend:
@@ -207,7 +207,7 @@
* Sends a QMP message to QEMU and leaves the response in the stream.
*/
void qtest_qmp_vsend(QTestState *s, const char *fmt, va_list ap)
- GCC_FMT_ATTR(2, 0);
+ G_GNUC_PRINTF(2, 0);
/**
* qtest_qmp_receive_dict:
@@ -269,7 +269,7 @@
*
* Returns: the command's output. The caller should g_free() it.
*/
-char *qtest_hmp(QTestState *s, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
+char *qtest_hmp(QTestState *s, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
/**
* qtest_hmpv:
@@ -283,7 +283,7 @@
* Returns: the command's output. The caller should g_free() it.
*/
char *qtest_vhmp(QTestState *s, const char *fmt, va_list ap)
- GCC_FMT_ATTR(2, 0);
+ G_GNUC_PRINTF(2, 0);
void qtest_module_load(QTestState *s, const char *prefix, const char *libname);
@@ -688,17 +688,17 @@
* the response.
*/
void qtest_qmp_assert_success(QTestState *qts, const char *fmt, ...)
- GCC_FMT_ATTR(2, 3);
+ G_GNUC_PRINTF(2, 3);
QDict *qmp_fd_receive(int fd);
void qmp_fd_vsend_fds(int fd, int *fds, size_t fds_num,
- const char *fmt, va_list ap) GCC_FMT_ATTR(4, 0);
-void qmp_fd_vsend(int fd, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);
-void qmp_fd_send(int fd, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
-void qmp_fd_send_raw(int fd, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
-void qmp_fd_vsend_raw(int fd, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);
-QDict *qmp_fdv(int fd, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);
-QDict *qmp_fd(int fd, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
+ const char *fmt, va_list ap) G_GNUC_PRINTF(4, 0);
+void qmp_fd_vsend(int fd, const char *fmt, va_list ap) G_GNUC_PRINTF(2, 0);
+void qmp_fd_send(int fd, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
+void qmp_fd_send_raw(int fd, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
+void qmp_fd_vsend_raw(int fd, const char *fmt, va_list ap) G_GNUC_PRINTF(2, 0);
+QDict *qmp_fdv(int fd, const char *fmt, va_list ap) G_GNUC_PRINTF(2, 0);
+QDict *qmp_fd(int fd, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
/**
* qtest_cb_for_every_machine:
@@ -750,7 +750,7 @@
* Generic hot-plugging test via the device_add QMP command.
*/
void qtest_qmp_device_add(QTestState *qts, const char *driver, const char *id,
- const char *fmt, ...) GCC_FMT_ATTR(4, 5);
+ const char *fmt, ...) G_GNUC_PRINTF(4, 5);
/**
* qtest_qmp_add_client:
diff --git a/tests/qtest/libqtest-single.h b/tests/qtest/libqtest-single.h
index 0d7f568..b0838b9 100644
--- a/tests/qtest/libqtest-single.h
+++ b/tests/qtest/libqtest-single.h
@@ -52,7 +52,7 @@
*
* Sends a QMP message to QEMU and returns the response.
*/
-GCC_FMT_ATTR(1, 2)
+G_GNUC_PRINTF(1, 2)
static inline QDict *qmp(const char *fmt, ...)
{
va_list ap;
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index 41f4da4..dc5566c 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -94,8 +94,8 @@
struct timeval timeout = { .tv_sec = SOCKET_TIMEOUT,
.tv_usec = 0 };
- if (qemu_setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,
- (void *)&timeout, sizeof(timeout))) {
+ if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,
+ (void *)&timeout, sizeof(timeout))) {
fprintf(stderr, "%s failed to set SO_RCVTIMEO: %s\n",
__func__, strerror(errno));
close(sock);
@@ -437,7 +437,7 @@
socket_send(s->fd, buf, strlen(buf));
}
-static void GCC_FMT_ATTR(2, 3) qtest_sendf(QTestState *s, const char *fmt, ...)
+static void G_GNUC_PRINTF(2, 3) qtest_sendf(QTestState *s, const char *fmt, ...)
{
va_list ap;
diff --git a/tests/qtest/migration-helpers.h b/tests/qtest/migration-helpers.h
index d63bba9..555adaf 100644
--- a/tests/qtest/migration-helpers.h
+++ b/tests/qtest/migration-helpers.h
@@ -16,13 +16,13 @@
extern bool got_stop;
-GCC_FMT_ATTR(3, 4)
+G_GNUC_PRINTF(3, 4)
QDict *wait_command_fd(QTestState *who, int fd, const char *command, ...);
-GCC_FMT_ATTR(2, 3)
+G_GNUC_PRINTF(2, 3)
QDict *wait_command(QTestState *who, const char *command, ...);
-GCC_FMT_ATTR(3, 4)
+G_GNUC_PRINTF(3, 4)
void migrate_qmp(QTestState *who, const char *uri, const char *fmt, ...);
QDict *migrate_query(QTestState *who);
diff --git a/tests/qtest/npcm7xx_emc-test.c b/tests/qtest/npcm7xx_emc-test.c
index 9eec71d..7c435ac 100644
--- a/tests/qtest/npcm7xx_emc-test.c
+++ b/tests/qtest/npcm7xx_emc-test.c
@@ -521,12 +521,12 @@
/* Check data sent to the backend. */
recv_len = ~0;
- ret = qemu_recv(fd, &recv_len, sizeof(recv_len), MSG_DONTWAIT);
+ ret = recv(fd, &recv_len, sizeof(recv_len), MSG_DONTWAIT);
g_assert_cmpint(ret, == , sizeof(recv_len));
g_assert(wait_socket_readable(fd));
memset(buffer, 0xff, sizeof(buffer));
- ret = qemu_recv(fd, buffer, test_size, MSG_DONTWAIT);
+ ret = recv(fd, buffer, test_size, MSG_DONTWAIT);
g_assert_cmpmem(buffer, ret, test_data, test_size);
}
diff --git a/tests/qtest/test-filter-mirror.c b/tests/qtest/test-filter-mirror.c
index 95367d1..da4f94d 100644
--- a/tests/qtest/test-filter-mirror.c
+++ b/tests/qtest/test-filter-mirror.c
@@ -58,13 +58,13 @@
g_assert_cmpint(ret, ==, sizeof(send_buf) + sizeof(size));
close(send_sock[0]);
- ret = qemu_recv(recv_sock[0], &len, sizeof(len), 0);
+ ret = recv(recv_sock[0], &len, sizeof(len), 0);
g_assert_cmpint(ret, ==, sizeof(len));
len = ntohl(len);
g_assert_cmpint(len, ==, sizeof(send_buf));
recv_buf = g_malloc(len);
- ret = qemu_recv(recv_sock[0], recv_buf, len, 0);
+ ret = recv(recv_sock[0], recv_buf, len, 0);
g_assert_cmpstr(recv_buf, ==, send_buf);
g_free(recv_buf);
diff --git a/tests/qtest/test-filter-redirector.c b/tests/qtest/test-filter-redirector.c
index 4f3f59c..fc16cf7 100644
--- a/tests/qtest/test-filter-redirector.c
+++ b/tests/qtest/test-filter-redirector.c
@@ -115,13 +115,13 @@
g_assert_cmpint(ret, ==, sizeof(send_buf) + sizeof(size));
close(backend_sock[0]);
- ret = qemu_recv(recv_sock, &len, sizeof(len), 0);
+ ret = recv(recv_sock, &len, sizeof(len), 0);
g_assert_cmpint(ret, ==, sizeof(len));
len = ntohl(len);
g_assert_cmpint(len, ==, sizeof(send_buf));
recv_buf = g_malloc(len);
- ret = qemu_recv(recv_sock, recv_buf, len, 0);
+ ret = recv(recv_sock, recv_buf, len, 0);
g_assert_cmpstr(recv_buf, ==, send_buf);
g_free(recv_buf);
@@ -182,13 +182,13 @@
ret = iov_send(send_sock, iov, 2, 0, sizeof(size) + sizeof(send_buf));
g_assert_cmpint(ret, ==, sizeof(send_buf) + sizeof(size));
- ret = qemu_recv(backend_sock[0], &len, sizeof(len), 0);
+ ret = recv(backend_sock[0], &len, sizeof(len), 0);
g_assert_cmpint(ret, ==, sizeof(len));
len = ntohl(len);
g_assert_cmpint(len, ==, sizeof(send_buf));
recv_buf = g_malloc(len);
- ret = qemu_recv(backend_sock[0], recv_buf, len, 0);
+ ret = recv(backend_sock[0], recv_buf, len, 0);
g_assert_cmpstr(recv_buf, ==, send_buf);
close(send_sock);
diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c
index 01ca076..e28c71b 100644
--- a/tests/qtest/virtio-9p-test.c
+++ b/tests/qtest/virtio-9p-test.c
@@ -468,12 +468,12 @@
togo -= 13 + 8 + 1 + 2 + slen, ++n)
{
if (!e) {
- e = g_malloc(sizeof(struct V9fsDirent));
+ e = g_new(struct V9fsDirent, 1);
if (entries) {
*entries = e;
}
} else {
- e = e->next = g_malloc(sizeof(struct V9fsDirent));
+ e = e->next = g_new(struct V9fsDirent, 1);
}
e->next = NULL;
/* qid[13] offset[8] type[1] name[s] */
diff --git a/tests/qtest/virtio-net-test.c b/tests/qtest/virtio-net-test.c
index 8bf74e5..a713958 100644
--- a/tests/qtest/virtio-net-test.c
+++ b/tests/qtest/virtio-net-test.c
@@ -87,11 +87,11 @@
QVIRTIO_NET_TIMEOUT_US);
guest_free(alloc, req_addr);
- ret = qemu_recv(socket, &len, sizeof(len), 0);
+ ret = recv(socket, &len, sizeof(len), 0);
g_assert_cmpint(ret, ==, sizeof(len));
len = ntohl(len);
- ret = qemu_recv(socket, buffer, len, 0);
+ ret = recv(socket, buffer, len, 0);
g_assert_cmpstr(buffer, ==, "TEST");
}
@@ -202,11 +202,11 @@
qobject_unref(rsp);
/* Catch the first packet and make sure it's a RARP */
- ret = qemu_recv(sv[0], &len, sizeof(len), 0);
+ ret = recv(sv[0], &len, sizeof(len), 0);
g_assert_cmpint(ret, ==, sizeof(len));
len = ntohl(len);
- ret = qemu_recv(sv[0], buffer, len, 0);
+ ret = recv(sv[0], buffer, len, 0);
g_assert_cmpint(*proto, ==, htons(ETH_P_RARP));
/*
@@ -230,7 +230,7 @@
while (true) {
int saved_err;
- ret = qemu_recv(sv[0], buffer, 60, MSG_DONTWAIT);
+ ret = recv(sv[0], buffer, 60, MSG_DONTWAIT);
saved_err = errno;
now = g_get_monotonic_time();
g_assert_cmpint(now, <, deadline);
diff --git a/tests/unit/check-qobject.c b/tests/unit/check-qobject.c
index c1713d1..c3d50e9 100644
--- a/tests/unit/check-qobject.c
+++ b/tests/unit/check-qobject.c
@@ -8,7 +8,6 @@
*/
#include "qemu/osdep.h"
-#include "block/qdict.h"
#include "qapi/error.h"
#include "qapi/qmp/qbool.h"
#include "qapi/qmp/qdict.h"
diff --git a/tests/unit/socket-helpers.c b/tests/unit/socket-helpers.c
index f704fd1..ef31664 100644
--- a/tests/unit/socket-helpers.c
+++ b/tests/unit/socket-helpers.c
@@ -105,7 +105,7 @@
}
if (check_soerr) {
- if (qemu_getsockopt(cfd, SOL_SOCKET, SO_ERROR, &soerr, &soerrlen) < 0) {
+ if (getsockopt(cfd, SOL_SOCKET, SO_ERROR, &soerr, &soerrlen) < 0) {
goto cleanup;
}
if (soerr) {
diff --git a/tests/unit/test-hbitmap.c b/tests/unit/test-hbitmap.c
index b6726cf..a4fe067 100644
--- a/tests/unit/test-hbitmap.c
+++ b/tests/unit/test-hbitmap.c
@@ -113,7 +113,7 @@
n = hbitmap_test_array_size(size);
m = hbitmap_test_array_size(data->old_size);
- data->bits = g_realloc(data->bits, sizeof(unsigned long) * n);
+ data->bits = g_renew(unsigned long, data->bits, n);
if (n > m) {
memset(&data->bits[m], 0x00, sizeof(unsigned long) * (n - m));
}
diff --git a/tests/unit/test-qmp-cmds.c b/tests/unit/test-qmp-cmds.c
index faa8586..6085c09 100644
--- a/tests/unit/test-qmp-cmds.c
+++ b/tests/unit/test-qmp-cmds.c
@@ -82,8 +82,8 @@
Error **errp)
{
UserDefTwo *ret;
- UserDefOne *ud1c = g_malloc0(sizeof(UserDefOne));
- UserDefOne *ud1d = g_malloc0(sizeof(UserDefOne));
+ UserDefOne *ud1c = g_new0(UserDefOne, 1);
+ UserDefOne *ud1d = g_new0(UserDefOne, 1);
ud1c->string = strdup(ud1a->string);
ud1c->integer = ud1a->integer;
@@ -344,23 +344,23 @@
UserDefOne *ud1test, *ud1a, *ud1b;
UserDefOneList *ud1list;
- ud1test = g_malloc0(sizeof(UserDefOne));
+ ud1test = g_new0(UserDefOne, 1);
ud1test->integer = 42;
ud1test->string = g_strdup("hi there 42");
qapi_free_UserDefOne(ud1test);
- ud1a = g_malloc0(sizeof(UserDefOne));
+ ud1a = g_new0(UserDefOne, 1);
ud1a->integer = 43;
ud1a->string = g_strdup("hi there 43");
- ud1b = g_malloc0(sizeof(UserDefOne));
+ ud1b = g_new0(UserDefOne, 1);
ud1b->integer = 44;
ud1b->string = g_strdup("hi there 44");
- ud1list = g_malloc0(sizeof(UserDefOneList));
+ ud1list = g_new0(UserDefOneList, 1);
ud1list->value = ud1a;
- ud1list->next = g_malloc0(sizeof(UserDefOneList));
+ ud1list->next = g_new0(UserDefOneList, 1);
ud1list->next->value = ud1b;
qapi_free_UserDefOneList(ud1list);
diff --git a/tests/unit/test-qobject-input-visitor.c b/tests/unit/test-qobject-input-visitor.c
index 6f59a7f..22538f8 100644
--- a/tests/unit/test-qobject-input-visitor.c
+++ b/tests/unit/test-qobject-input-visitor.c
@@ -64,7 +64,7 @@
return data->qiv;
}
-static GCC_FMT_ATTR(3, 4)
+static G_GNUC_PRINTF(3, 4)
Visitor *visitor_input_test_init_full(TestInputVisitorData *data,
bool keyval,
const char *json_string, ...)
@@ -79,7 +79,7 @@
return v;
}
-static GCC_FMT_ATTR(2, 3)
+static G_GNUC_PRINTF(2, 3)
Visitor *visitor_input_test_init(TestInputVisitorData *data,
const char *json_string, ...)
{
diff --git a/tests/unit/test-qobject-output-visitor.c b/tests/unit/test-qobject-output-visitor.c
index 34d67a4..6af4c33 100644
--- a/tests/unit/test-qobject-output-visitor.c
+++ b/tests/unit/test-qobject-output-visitor.c
@@ -338,7 +338,7 @@
{
QDict *qdict;
- UserDefFlatUnion *tmp = g_malloc0(sizeof(UserDefFlatUnion));
+ UserDefFlatUnion *tmp = g_new0(UserDefFlatUnion, 1);
tmp->enum1 = ENUM_ONE_VALUE1;
tmp->string = g_strdup("str");
tmp->integer = 41;
diff --git a/tests/unit/test-vmstate.c b/tests/unit/test-vmstate.c
index 4688c03..6a417bb 100644
--- a/tests/unit/test-vmstate.c
+++ b/tests/unit/test-vmstate.c
@@ -1002,22 +1002,22 @@
TestGTreeMapping *map_a, *map_b;
TestGTreeInterval *a, *b;
- domain = g_malloc0(sizeof(TestGTreeDomain));
+ domain = g_new0(TestGTreeDomain, 1);
domain->id = 6;
- a = g_malloc0(sizeof(TestGTreeInterval));
+ a = g_new0(TestGTreeInterval, 1);
a->low = 0x1000;
a->high = 0x1FFF;
- b = g_malloc0(sizeof(TestGTreeInterval));
+ b = g_new0(TestGTreeInterval, 1);
b->low = 0x4000;
b->high = 0x4FFF;
- map_a = g_malloc0(sizeof(TestGTreeMapping));
+ map_a = g_new0(TestGTreeMapping, 1);
map_a->phys_addr = 0xa000;
map_a->flags = 1;
- map_b = g_malloc0(sizeof(TestGTreeMapping));
+ map_b = g_new0(TestGTreeMapping, 1);
map_b->phys_addr = 0xe0000;
map_b->flags = 2;
@@ -1120,7 +1120,7 @@
static void test_gtree_load_domain(void)
{
- TestGTreeDomain *dest_domain = g_malloc0(sizeof(TestGTreeDomain));
+ TestGTreeDomain *dest_domain = g_new0(TestGTreeDomain, 1);
TestGTreeDomain *orig_domain = create_first_domain();
QEMUFile *fload, *fsave;
char eof;
@@ -1185,7 +1185,7 @@
static TestGTreeIOMMU *create_iommu(void)
{
- TestGTreeIOMMU *iommu = g_malloc0(sizeof(TestGTreeIOMMU));
+ TestGTreeIOMMU *iommu = g_new0(TestGTreeIOMMU, 1);
TestGTreeDomain *first_domain = create_first_domain();
TestGTreeDomain *second_domain;
TestGTreeMapping *map_c;
@@ -1196,7 +1196,7 @@
NULL,
destroy_domain);
- second_domain = g_malloc0(sizeof(TestGTreeDomain));
+ second_domain = g_new0(TestGTreeDomain, 1);
second_domain->id = 5;
second_domain->mappings = g_tree_new_full((GCompareDataFunc)interval_cmp,
NULL,
@@ -1206,11 +1206,11 @@
g_tree_insert(iommu->domains, GUINT_TO_POINTER(6), first_domain);
g_tree_insert(iommu->domains, (gpointer)0x0000000000000005, second_domain);
- c = g_malloc0(sizeof(TestGTreeInterval));
+ c = g_new0(TestGTreeInterval, 1);
c->low = 0x1000000;
c->high = 0x1FFFFFF;
- map_c = g_malloc0(sizeof(TestGTreeMapping));
+ map_c = g_new0(TestGTreeMapping, 1);
map_c->phys_addr = 0xF000000;
map_c->flags = 0x3;
@@ -1235,7 +1235,7 @@
static void test_gtree_load_iommu(void)
{
- TestGTreeIOMMU *dest_iommu = g_malloc0(sizeof(TestGTreeIOMMU));
+ TestGTreeIOMMU *dest_iommu = g_new0(TestGTreeIOMMU, 1);
TestGTreeIOMMU *orig_iommu = create_iommu();
QEMUFile *fsave, *fload;
char eof;
@@ -1274,11 +1274,11 @@
static TestQListContainer *alloc_container(void)
{
- TestQListElement *a = g_malloc(sizeof(TestQListElement));
- TestQListElement *b = g_malloc(sizeof(TestQListElement));
- TestQListElement *c = g_malloc(sizeof(TestQListElement));
- TestQListElement *d = g_malloc(sizeof(TestQListElement));
- TestQListContainer *container = g_malloc(sizeof(TestQListContainer));
+ TestQListElement *a = g_new(TestQListElement, 1);
+ TestQListElement *b = g_new(TestQListElement, 1);
+ TestQListElement *c = g_new(TestQListElement, 1);
+ TestQListElement *d = g_new(TestQListElement, 1);
+ TestQListContainer *container = g_new(TestQListContainer, 1);
a->id = 0x0a;
b->id = 0x0b00;
@@ -1332,11 +1332,11 @@
TestQListElement *prev = NULL, *iter = QLIST_FIRST(&c->list);
TestQListElement *elem;
- elem = g_malloc(sizeof(TestQListElement));
+ elem = g_new(TestQListElement, 1);
elem->id = 0x12;
QLIST_INSERT_AFTER(iter, elem, next);
- elem = g_malloc(sizeof(TestQListElement));
+ elem = g_new(TestQListElement, 1);
elem->id = 0x13;
QLIST_INSERT_HEAD(&c->list, elem, next);
@@ -1345,11 +1345,11 @@
iter = QLIST_NEXT(iter, next);
}
- elem = g_malloc(sizeof(TestQListElement));
+ elem = g_new(TestQListElement, 1);
elem->id = 0x14;
QLIST_INSERT_BEFORE(prev, elem, next);
- elem = g_malloc(sizeof(TestQListElement));
+ elem = g_new(TestQListElement, 1);
elem->id = 0x15;
QLIST_INSERT_AFTER(prev, elem, next);
@@ -1370,7 +1370,7 @@
{
QEMUFile *fsave, *fload;
TestQListContainer *orig_container = alloc_container();
- TestQListContainer *dest_container = g_malloc0(sizeof(TestQListContainer));
+ TestQListContainer *dest_container = g_new0(TestQListContainer, 1);
char eof;
QLIST_INIT(&dest_container->list);
diff --git a/trace/control.c b/trace/control.c
index d5b68e8..6c77cc6 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -161,7 +161,7 @@
fprintf(f, "This list of names of trace points may be incomplete "
"when using the DTrace/SystemTap backends.\n"
"Run 'qemu-trace-stap list %s' to print the full list.\n",
- error_get_progname());
+ g_get_prgname());
#endif
}
diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c
index cebd358..7b86a47 100644
--- a/ui/vnc-enc-tight.c
+++ b/ui/vnc-enc-tight.c
@@ -1477,7 +1477,7 @@
#endif
if (!color_count_palette) {
- color_count_palette = g_malloc(sizeof(VncPalette));
+ color_count_palette = g_new(VncPalette, 1);
vnc_tight_cleanup_notifier.notify = vnc_tight_cleanup;
qemu_thread_atexit_add(&vnc_tight_cleanup_notifier);
}
diff --git a/util/aio-posix.c b/util/aio-posix.c
index 7b9f629..be0182a 100644
--- a/util/aio-posix.c
+++ b/util/aio-posix.c
@@ -23,15 +23,6 @@
#include "trace.h"
#include "aio-posix.h"
-/*
- * G_IO_IN and G_IO_OUT are not appropriate revents values for polling, since
- * the handler may not need to access the file descriptor. For example, the
- * handler doesn't need to read from an EventNotifier if it polled a memory
- * location and a read syscall would be slow. Define our own unique revents
- * value to indicate that polling determined this AioHandler is ready.
- */
-#define REVENTS_POLL_READY 0
-
/* Stop userspace polling on a handler if it isn't active for some time */
#define POLL_IDLE_INTERVAL_NS (7 * NANOSECONDS_PER_SECOND)
@@ -49,6 +40,14 @@
QLIST_INSERT_HEAD(ready_list, node, node_ready);
}
+static void aio_add_poll_ready_handler(AioHandlerList *ready_list,
+ AioHandler *node)
+{
+ QLIST_SAFE_REMOVE(node, node_ready); /* remove from nested parent's list */
+ node->poll_ready = true;
+ QLIST_INSERT_HEAD(ready_list, node, node_ready);
+}
+
static AioHandler *find_aio_handler(AioContext *ctx, int fd)
{
AioHandler *node;
@@ -76,6 +75,7 @@
}
node->pfd.revents = 0;
+ node->poll_ready = false;
/* If the fd monitor has already marked it deleted, leave it alone */
if (QLIST_IS_INSERTED(node, node_deleted)) {
@@ -247,7 +247,7 @@
/* Poll one last time in case ->io_poll_end() raced with the event */
if (!started && node->io_poll(node->opaque)) {
- aio_add_ready_handler(ready_list, node, REVENTS_POLL_READY);
+ aio_add_poll_ready_handler(ready_list, node);
progress = true;
}
}
@@ -282,6 +282,7 @@
QLIST_FOREACH_RCU(node, &ctx->aio_handlers, node) {
int revents;
+ /* TODO should this check poll ready? */
revents = node->pfd.revents & node->pfd.events;
if (revents & (G_IO_IN | G_IO_HUP | G_IO_ERR) && node->io_read &&
aio_node_check(ctx, node->is_external)) {
@@ -323,11 +324,15 @@
static bool aio_dispatch_handler(AioContext *ctx, AioHandler *node)
{
bool progress = false;
+ bool poll_ready;
int revents;
revents = node->pfd.revents & node->pfd.events;
node->pfd.revents = 0;
+ poll_ready = node->poll_ready;
+ node->poll_ready = false;
+
/*
* Start polling AioHandlers when they become ready because activity is
* likely to continue. Note that starvation is theoretically possible when
@@ -344,7 +349,7 @@
QLIST_INSERT_HEAD(&ctx->poll_aio_handlers, node, node_poll);
}
if (!QLIST_IS_INSERTED(node, node_deleted) &&
- revents == 0 &&
+ poll_ready && revents == 0 &&
aio_node_check(ctx, node->is_external) &&
node->io_poll_ready) {
node->io_poll_ready(node->opaque);
@@ -432,7 +437,7 @@
QLIST_FOREACH_SAFE(node, &ctx->poll_aio_handlers, node_poll, tmp) {
if (aio_node_check(ctx, node->is_external) &&
node->io_poll(node->opaque)) {
- aio_add_ready_handler(ready_list, node, REVENTS_POLL_READY);
+ aio_add_poll_ready_handler(ready_list, node);
node->poll_idle_timeout = now + POLL_IDLE_INTERVAL_NS;
@@ -491,8 +496,7 @@
* this causes progress.
*/
if (node->io_poll(node->opaque)) {
- aio_add_ready_handler(ready_list, node,
- REVENTS_POLL_READY);
+ aio_add_poll_ready_handler(ready_list, node);
progress = true;
}
}
diff --git a/util/aio-posix.h b/util/aio-posix.h
index 7f2c37a..80b927c 100644
--- a/util/aio-posix.h
+++ b/util/aio-posix.h
@@ -37,6 +37,7 @@
unsigned flags; /* see fdmon-io_uring.c */
#endif
int64_t poll_idle_timeout; /* when to stop userspace polling */
+ bool poll_ready; /* has polling detected an event? */
bool is_external;
};
diff --git a/util/cutils.c b/util/cutils.c
index c9b91e7..0d475ec 100644
--- a/util/cutils.c
+++ b/util/cutils.c
@@ -27,9 +27,6 @@
#include <math.h>
#include "qemu-common.h"
-#include "qemu/sockets.h"
-#include "qemu/iov.h"
-#include "net/net.h"
#include "qemu/ctype.h"
#include "qemu/cutils.h"
#include "qemu/error-report.h"
@@ -939,19 +936,6 @@
}
/*
- * Helper to print ethernet mac address
- */
-const char *qemu_ether_ntoa(const MACAddr *mac)
-{
- static char ret[18];
-
- snprintf(ret, sizeof(ret), "%02x:%02x:%02x:%02x:%02x:%02x",
- mac->a[0], mac->a[1], mac->a[2], mac->a[3], mac->a[4], mac->a[5]);
-
- return ret;
-}
-
-/*
* Return human readable string for size @val.
* @val can be anything that uint64_t allows (no more than "16 EiB").
* Use IEC binary units like KiB, MiB, and so forth.
diff --git a/util/envlist.c b/util/envlist.c
index 2bcc13f..ab55534 100644
--- a/util/envlist.c
+++ b/util/envlist.c
@@ -217,7 +217,7 @@
struct envlist_entry *entry;
char **env, **penv;
- penv = env = g_malloc((envlist->el_count + 1) * sizeof(char *));
+ penv = env = g_new(char *, envlist->el_count + 1);
for (entry = envlist->el_entries.lh_first; entry != NULL;
entry = entry->ev_link.le_next) {
diff --git a/util/fdmon-io_uring.c b/util/fdmon-io_uring.c
index 1461dfa..ab43052 100644
--- a/util/fdmon-io_uring.c
+++ b/util/fdmon-io_uring.c
@@ -179,7 +179,11 @@
{
struct io_uring_sqe *sqe = get_sqe(ctx);
+#ifdef LIBURING_HAVE_DATA64
+ io_uring_prep_poll_remove(sqe, (__u64)(uintptr_t)node);
+#else
io_uring_prep_poll_remove(sqe, node);
+#endif
}
/* Add a timeout that self-cancels when another cqe becomes ready */
diff --git a/util/hbitmap.c b/util/hbitmap.c
index dd0501d..ea989e1 100644
--- a/util/hbitmap.c
+++ b/util/hbitmap.c
@@ -862,7 +862,7 @@
}
old = hb->sizes[i];
hb->sizes[i] = size;
- hb->levels[i] = g_realloc(hb->levels[i], size * sizeof(unsigned long));
+ hb->levels[i] = g_renew(unsigned long, hb->levels[i], size);
if (!shrink) {
memset(&hb->levels[i][old], 0x00,
(size - old) * sizeof(*hb->levels[i]));
diff --git a/util/main-loop.c b/util/main-loop.c
index 4d5a5b9..b7b0ce4 100644
--- a/util/main-loop.c
+++ b/util/main-loop.c
@@ -273,7 +273,7 @@
int qemu_add_polling_cb(PollingFunc *func, void *opaque)
{
PollingEntry **ppe, *pe;
- pe = g_malloc0(sizeof(PollingEntry));
+ pe = g_new0(PollingEntry, 1);
pe->func = func;
pe->opaque = opaque;
for(ppe = &first_polling_entry; *ppe != NULL; ppe = &(*ppe)->next);
diff --git a/util/osdep.c b/util/osdep.c
index 394804d..84575ec 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -39,7 +39,7 @@
int socket_set_cork(int fd, int v)
{
#if defined(SOL_TCP) && defined(TCP_CORK)
- return qemu_setsockopt(fd, SOL_TCP, TCP_CORK, &v, sizeof(v));
+ return setsockopt(fd, SOL_TCP, TCP_CORK, &v, sizeof(v));
#else
return 0;
#endif
@@ -48,7 +48,7 @@
int socket_set_nodelay(int fd)
{
int v = 1;
- return qemu_setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &v, sizeof(v));
+ return setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &v, sizeof(v));
}
int qemu_madvise(void *addr, size_t len, int advice)
diff --git a/util/qemu-error.c b/util/qemu-error.c
index 52a9e01..7769aee 100644
--- a/util/qemu-error.c
+++ b/util/qemu-error.c
@@ -146,22 +146,6 @@
}
}
-static const char *progname;
-
-/*
- * Set the program name for error_print_loc().
- */
-static void error_set_progname(const char *argv0)
-{
- const char *p = strrchr(argv0, '/');
- progname = p ? p + 1 : argv0;
-}
-
-const char *error_get_progname(void)
-{
- return progname;
-}
-
/*
* Print current location to current monitor if we have one, else to stderr.
*/
@@ -171,8 +155,8 @@
int i;
const char *const *argp;
- if (!monitor_cur() && progname) {
- fprintf(stderr, "%s:", progname);
+ if (!monitor_cur() && g_get_prgname()) {
+ fprintf(stderr, "%s:", g_get_prgname());
sep = " ";
}
switch (cur_loc->kind) {
@@ -400,8 +384,10 @@
void error_init(const char *argv0)
{
+ const char *p = strrchr(argv0, '/');
+
/* Set the program name for error_print_loc(). */
- error_set_progname(argv0);
+ g_set_prgname(p ? p + 1 : argv0);
/*
* This sets up glib logging so libraries using it also print their logs
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 0585e7a..e8f45a7 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -97,7 +97,7 @@
{
int optval;
socklen_t optlen = sizeof(optval);
- return !qemu_getsockopt(fd, SOL_SOCKET, SO_TYPE, &optval, &optlen);
+ return !getsockopt(fd, SOL_SOCKET, SO_TYPE, &optval, &optlen);
}
@@ -185,8 +185,8 @@
rebind:
if (e->ai_family == PF_INET6) {
- qemu_setsockopt(socket, IPPROTO_IPV6, IPV6_V6ONLY, &v6only,
- sizeof(v6only));
+ setsockopt(socket, IPPROTO_IPV6, IPV6_V6ONLY, &v6only,
+ sizeof(v6only));
}
stat = bind(socket, e->ai_addr, e->ai_addrlen);
@@ -483,8 +483,8 @@
if (saddr->keep_alive) {
int val = 1;
- int ret = qemu_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
- &val, sizeof(val));
+ int ret = setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE,
+ &val, sizeof(val));
if (ret < 0) {
error_setg_errno(errp, errno, "Unable to set KEEPALIVE");
diff --git a/util/qemu-timer.c b/util/qemu-timer.c
index f36c75e..a670a57 100644
--- a/util/qemu-timer.c
+++ b/util/qemu-timer.c
@@ -100,7 +100,7 @@
QEMUTimerList *timer_list;
QEMUClock *clock = qemu_clock_ptr(type);
- timer_list = g_malloc0(sizeof(QEMUTimerList));
+ timer_list = g_new0(QEMUTimerList, 1);
qemu_event_init(&timer_list->timers_done_ev, true);
timer_list->clock = clock;
timer_list->notify_cb = cb;
diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
index 00a8043..b037d5f 100644
--- a/util/vfio-helpers.c
+++ b/util/vfio-helpers.c
@@ -279,8 +279,8 @@
s->nb_iova_ranges = cap_iova_range->nr_iovas;
if (s->nb_iova_ranges > 1) {
s->usable_iova_ranges =
- g_realloc(s->usable_iova_ranges,
- s->nb_iova_ranges * sizeof(struct IOVARange));
+ g_renew(struct IOVARange, s->usable_iova_ranges,
+ s->nb_iova_ranges);
}
for (i = 0; i < s->nb_iova_ranges; i++) {