Re: [PATCH v4 0/3] Initial support for SPDM Responders

2024-02-16 Thread Klaus Jensen
On Feb 15 14:44, Jonathan Cameron wrote:
> On Tue, 13 Feb 2024 12:44:00 +1000
> Alistair Francis  wrote:
> 
> Hi All,
> 
> Just wanted to add that back in v2 Klaus Jensen stated:
> 
> "I have no problem with picking this up for nvme, but I'd rather not take
>  the full series through my tree without reviews/acks from the pci
>  maintainers."
> 
> So I'd like to add my request that Michael and/or Marcell takes a look
> when they have time.
> 
> I've been carrying more or less the first 2 patches in my CXL staging
> tree for a couple of years (the initial Linux Kernel support that Lukas
> Wunner is now handling was developed against this) and I would love
> to see this upstream. Along with PCI and CXL and NVME usecases this
> is a major part of the Confidential Compute device assignment story
> via PCI/TDISP and CXL equivalent.
> 
> It's not changed in significant ways since v2 back in October last year.
> 

Would someone be willing to sign up to maintain the spdm_socket backend?


signature.asc
Description: PGP signature


[PATCH] iotests: adapt to output change for recently introduced 'detached header' field

2024-02-16 Thread Fiona Ebner
Failure was noticed when running the tests for the qcow2 image format.

Fixes: 0bd779e27e ("crypto: Introduce 'detached-header' field in 
QCryptoBlockInfoLUKS")
Signed-off-by: Fiona Ebner 
---
 tests/qemu-iotests/198.out | 2 ++
 tests/qemu-iotests/206.out | 1 +
 2 files changed, 3 insertions(+)

diff --git a/tests/qemu-iotests/198.out b/tests/qemu-iotests/198.out
index 805494916f..62fb73fa3e 100644
--- a/tests/qemu-iotests/198.out
+++ b/tests/qemu-iotests/198.out
@@ -39,6 +39,7 @@ Format specific information:
 compression type: COMPRESSION_TYPE
 encrypt:
 ivgen alg: plain64
+detached header: false
 hash alg: sha256
 cipher alg: aes-256
 uuid: ----
@@ -84,6 +85,7 @@ Format specific information:
 compression type: COMPRESSION_TYPE
 encrypt:
 ivgen alg: plain64
+detached header: false
 hash alg: sha256
 cipher alg: aes-256
 uuid: ----
diff --git a/tests/qemu-iotests/206.out b/tests/qemu-iotests/206.out
index 7e95694777..979f00f9bf 100644
--- a/tests/qemu-iotests/206.out
+++ b/tests/qemu-iotests/206.out
@@ -114,6 +114,7 @@ Format specific information:
 refcount bits: 16
 encrypt:
 ivgen alg: plain64
+detached header: false
 hash alg: sha1
 cipher alg: aes-128
 uuid: ----
-- 
2.39.2





Re: [PATCH v4 0/3] Initial support for SPDM Responders

2024-02-16 Thread Alistair Francis
On Fri, Feb 16, 2024 at 6:52 PM Klaus Jensen  wrote:
>
> On Feb 15 14:44, Jonathan Cameron wrote:
> > On Tue, 13 Feb 2024 12:44:00 +1000
> > Alistair Francis  wrote:
> >
> > Hi All,
> >
> > Just wanted to add that back in v2 Klaus Jensen stated:
> >
> > "I have no problem with picking this up for nvme, but I'd rather not take
> >  the full series through my tree without reviews/acks from the pci
> >  maintainers."
> >
> > So I'd like to add my request that Michael and/or Marcell takes a look
> > when they have time.
> >
> > I've been carrying more or less the first 2 patches in my CXL staging
> > tree for a couple of years (the initial Linux Kernel support that Lukas
> > Wunner is now handling was developed against this) and I would love
> > to see this upstream. Along with PCI and CXL and NVME usecases this
> > is a major part of the Confidential Compute device assignment story
> > via PCI/TDISP and CXL equivalent.
> >
> > It's not changed in significant ways since v2 back in October last year.
> >
>
> Would someone be willing to sign up to maintain the spdm_socket backend?

I'm happy to and should have already edited MAINTAINERS to indicate
that. I'll fix that up in the next version

Alistair



[RFC 2/4] drive-mirror: add support for conditional and always bitmap sync modes

2024-02-16 Thread Fiona Ebner
From: John Snow 

Teach mirror two new tricks for using bitmaps:

Always: no matter what, we synchronize the copy_bitmap back to the
sync_bitmap. In effect, this allows us resume a failed mirror at a later
date.

Conditional: On success only, we sync the bitmap. This is akin to
incremental backup modes; we can use this bitmap to later refresh a
successfully created mirror.

Originally-by: John Snow 
[FG: add check for bitmap-mode without bitmap
 switch to bdrv_dirty_bitmap_merge_internal]
Signed-off-by: Fabian Grünbichler 
Signed-off-by: Thomas Lamprecht 
[FE: rebase for 9.0]
Signed-off-by: Fiona Ebner 
---

The original patch this was based on came from a WIP git branch and
thus has no Signed-off-by trailer from John, see [0]. I added an
Originally-by trailer for now. Let me know if I should drop that and
wait for John's Signed-off-by instead.

[0] https://lore.kernel.org/qemu-devel/1599140071.n44h532eeu.astr...@nora.none/

 block/mirror.c | 24 ++--
 blockdev.c |  3 +++
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/block/mirror.c b/block/mirror.c
index 315dff11e2..84155b1f78 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -689,8 +689,6 @@ static int mirror_exit_common(Job *job)
 bdrv_unfreeze_backing_chain(mirror_top_bs, target_bs);
 }
 
-bdrv_release_dirty_bitmap(s->dirty_bitmap);
-
 /* Make sure that the source BDS doesn't go away during bdrv_replace_node,
  * before we can call bdrv_drained_end */
 bdrv_ref(src);
@@ -796,6 +794,18 @@ static int mirror_exit_common(Job *job)
 bdrv_drained_end(target_bs);
 bdrv_unref(target_bs);
 
+if (s->sync_bitmap) {
+if (s->bitmap_mode == BITMAP_SYNC_MODE_ALWAYS ||
+(s->bitmap_mode == BITMAP_SYNC_MODE_ON_SUCCESS &&
+ job->ret == 0 && ret == 0)) {
+/* Success; synchronize copy back to sync. */
+bdrv_clear_dirty_bitmap(s->sync_bitmap, NULL);
+bdrv_dirty_bitmap_merge_internal(s->sync_bitmap, s->dirty_bitmap,
+ NULL, true);
+}
+}
+bdrv_release_dirty_bitmap(s->dirty_bitmap);
+
 bs_opaque->job = NULL;
 
 bdrv_drained_end(src);
@@ -1755,10 +1765,6 @@ static BlockJob *mirror_start_job(
" sync mode",
MirrorSyncMode_str(sync_mode));
 return NULL;
-} else if (bitmap_mode != BITMAP_SYNC_MODE_NEVER) {
-error_setg(errp,
-   "Bitmap Sync Mode '%s' is not supported by Mirror",
-   BitmapSyncMode_str(bitmap_mode));
 }
 } else if (bitmap) {
 error_setg(errp,
@@ -1775,6 +1781,12 @@ static BlockJob *mirror_start_job(
 return NULL;
 }
 granularity = bdrv_dirty_bitmap_granularity(bitmap);
+
+if (bitmap_mode != BITMAP_SYNC_MODE_NEVER) {
+if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_DEFAULT, errp)) {
+return NULL;
+}
+}
 } else if (granularity == 0) {
 granularity = bdrv_get_default_bitmap_granularity(target);
 }
diff --git a/blockdev.c b/blockdev.c
index c65d9ded70..aeb9fde9f3 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2873,6 +2873,9 @@ static void blockdev_mirror_common(const char *job_id, 
BlockDriverState *bs,
 if (bdrv_dirty_bitmap_check(bitmap, BDRV_BITMAP_ALLOW_RO, errp)) {
 return;
 }
+} else if (has_bitmap_mode) {
+error_setg(errp, "Cannot specify bitmap sync mode without a bitmap");
+return;
 }
 
 if (!replaces) {
-- 
2.39.2





[RFC 0/4] mirror: implement incremental and bitmap modes

2024-02-16 Thread Fiona Ebner
Previous discussion from when this was sent upstream [0] (it's been a
while). I rebased the patches and re-ordered and squashed like
suggested back then [1].

This implements two new mirror modes:

- bitmap mirror mode with always/on-success/never bitmap sync mode
- incremental mirror mode as sugar for bitmap + on-success

Use cases:
* Possibility to resume a failed mirror later.
* Possibility to only mirror deltas to a previously mirrored volume.
* Possibility to (efficiently) mirror an drive that was previously
  mirrored via some external mechanism (e.g. ZFS replication).

We are using the last one in production without any issues since about
4 years now. In particular, like mentioned in [2]:

> - create bitmap(s)
> - (incrementally) replicate storage volume(s) out of band (using ZFS)
> - incrementally drive mirror as part of a live migration of VM
> - drop bitmap(s)


Now, the IO test added in patch 4/4 actually contains yet another use
case, namely doing incremental mirrors to stand-alone qcow2 "diff"
images, that only contain the delta and can be rebased later. I had to
adapt the IO test, because its output expected the mirror bitmap to
still be dirty, but nowadays the mirror is apparently already done
when the bitmaps are queried. So I thought, I'll just use
'write-blocking' mode to avoid any potential timing issues.

But this exposed an issue with the diff image approach. If a write is
not aligned to the granularity of the mirror target, then rebasing the
diff image onto a backing image will not yield the desired result,
because the full cluster is considered to be allocated and will "hide"
some part of the base/backing image. The failure can be seen by either
using 'write-blocking' mode in the IO test or setting the (bitmap)
granularity to 32 KiB rather than the current 64 KiB.

The question is how to deal with these edge cases? Some possibilities
that would make sense to me:

For 'background' mode:
* prohibit if target's cluster size is larger than the bitmap
  granularity
* document the limitation

For 'write-blocking' mode:
* disallow in combination with bitmap mode (would not be happy about
  it, because I'd like to use this without diff images)
* for writes that are not aligned to the target's cluster size, read
  the relevant/missing parts from the source image to be able to write
  whole target clusters (seems rather complex)
* document the limitation


[0]: 
https://lore.kernel.org/qemu-devel/20200218100740.2228521-1-f.gruenbich...@proxmox.com/
[1]: 
https://lore.kernel.org/qemu-devel/d35a76de-78d5-af56-0b34-f7bd2bbd3...@redhat.com/
[2]: https://lore.kernel.org/qemu-devel/1599127031.9uxdp5h9o2.astr...@nora.none/


Fabian Grünbichler (2):
  mirror: move some checks to qmp
  iotests: add test for bitmap mirror

John Snow (2):
  drive-mirror: add support for sync=bitmap mode=never
  drive-mirror: add support for conditional and always bitmap sync modes

 block/mirror.c|   94 +-
 blockdev.c|   70 +-
 include/block/block_int-global-state.h|4 +-
 qapi/block-core.json  |   25 +-
 tests/qemu-iotests/tests/bitmap-sync-mirror   |  550 
 .../qemu-iotests/tests/bitmap-sync-mirror.out | 2810 +
 tests/unit/test-block-iothread.c  |4 +-
 7 files changed, 3527 insertions(+), 30 deletions(-)
 create mode 100755 tests/qemu-iotests/tests/bitmap-sync-mirror
 create mode 100644 tests/qemu-iotests/tests/bitmap-sync-mirror.out

-- 
2.39.2





[RFC 4/4] iotests: add test for bitmap mirror

2024-02-16 Thread Fiona Ebner
From: Fabian Grünbichler 

heavily based on/practically forked off iotest 257 for bitmap backups,
but:

- no writes to filter node 'mirror-top' between completion and
finalization, as those seem to deadlock?
- no inclusion of not-yet-available full/top sync modes in combination
with bitmaps
- extra set of reference/test mirrors to verify that writes in parallel
with active mirror work

intentionally keeping copyright and ownership of original test case to
honor provenance.

Signed-off-by: Fabian Grünbichler 
Signed-off-by: Thomas Lamprecht 
[FE: rebase for 9.0, i.e. adapt to renames like vm.command -> vm.cmd,
 specifying explicit image format for rebase,
 adapt to new behavior of qemu_img(),
 dropping of 'status' field in output, etc.
 rename test from '384' to 'bitmap-sync-mirror']
Signed-off-by: Fiona Ebner 
---
 tests/qemu-iotests/tests/bitmap-sync-mirror   |  550 
 .../qemu-iotests/tests/bitmap-sync-mirror.out | 2810 +
 2 files changed, 3360 insertions(+)
 create mode 100755 tests/qemu-iotests/tests/bitmap-sync-mirror
 create mode 100644 tests/qemu-iotests/tests/bitmap-sync-mirror.out

diff --git a/tests/qemu-iotests/tests/bitmap-sync-mirror 
b/tests/qemu-iotests/tests/bitmap-sync-mirror
new file mode 100755
index 00..6cd9b74dac
--- /dev/null
+++ b/tests/qemu-iotests/tests/bitmap-sync-mirror
@@ -0,0 +1,550 @@
+#!/usr/bin/env python3
+# group: rw
+#
+# Test bitmap-sync mirrors (incremental, differential, and partials)
+#
+# Copyright (c) 2019 John Snow for Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see .
+#
+# owner=js...@redhat.com
+
+import math
+import os
+
+import iotests
+from iotests import log, qemu_img
+
+SIZE = 64 * 1024 * 1024
+GRANULARITY = 64 * 1024
+
+
+class Pattern:
+def __init__(self, byte, offset, size=GRANULARITY):
+self.byte = byte
+self.offset = offset
+self.size = size
+
+def bits(self, granularity):
+lower = self.offset // granularity
+upper = (self.offset + self.size - 1) // granularity
+return set(range(lower, upper + 1))
+
+
+class PatternGroup:
+"""Grouping of Pattern objects. Initialize with an iterable of Patterns."""
+def __init__(self, patterns):
+self.patterns = patterns
+
+def bits(self, granularity):
+"""Calculate the unique bits dirtied by this pattern grouping"""
+res = set()
+for pattern in self.patterns:
+res |= pattern.bits(granularity)
+return res
+
+
+GROUPS = [
+PatternGroup([
+# Batch 0: 4 clusters
+Pattern('0x49', 0x000),
+Pattern('0x6c', 0x010),   # 1M
+Pattern('0x6f', 0x200),   # 32M
+Pattern('0x76', 0x3ff)]), # 64M - 64K
+PatternGroup([
+# Batch 1: 6 clusters (3 new)
+Pattern('0x65', 0x000),   # Full overwrite
+Pattern('0x77', 0x00f8000),   # Partial-left (1M-32K)
+Pattern('0x72', 0x2008000),   # Partial-right (32M+32K)
+Pattern('0x69', 0x3fe)]), # Adjacent-left (64M - 128K)
+PatternGroup([
+# Batch 2: 7 clusters (3 new)
+Pattern('0x74', 0x001),   # Adjacent-right
+Pattern('0x69', 0x00e8000),   # Partial-left  (1M-96K)
+Pattern('0x6e', 0x2018000),   # Partial-right (32M+96K)
+Pattern('0x67', 0x3fe,
+2*GRANULARITY)]), # Overwrite [(64M-128K)-64M)
+PatternGroup([
+# Batch 3: 8 clusters (5 new)
+# Carefully chosen such that nothing re-dirties the one cluster
+# that copies out successfully before failure in Group #1.
+Pattern('0xaa', 0x001,
+3*GRANULARITY),   # Overwrite and 2x Adjacent-right
+Pattern('0xbb', 0x00d8000),   # Partial-left (1M-160K)
+Pattern('0xcc', 0x2028000),   # Partial-right (32M+160K)
+Pattern('0xdd', 0x3fc)]), # New; leaving a gap to the right
+]
+
+
+class EmulatedBitmap:
+def __init__(self, granularity=GRANULARITY):
+self._bits = set()
+self.granularity = granularity
+
+def dirty_bits(self, bits):
+self._bits |= set(bits)
+
+def dirty_group(self, n):
+self.dirty_bits(GROUPS[n].bits(self.granularity))
+
+def clear(self):
+self._bits = set()
+
+def clear_bits(self, bits):
+self._bits -= set(bits)
+
+def clear_bit(self, bit):
+self.c

[RFC 3/4] mirror: move some checks to qmp

2024-02-16 Thread Fiona Ebner
From: Fabian Grünbichler 

and assert the passing conditions in block/mirror.c. while incremental
mode was never available for drive-mirror, it makes the interface more
uniform w.r.t. backup block jobs.

Signed-off-by: Fabian Grünbichler 
Signed-off-by: Thomas Lamprecht 
[FE: rebase for 9.0]
Signed-off-by: Fiona Ebner 
---
 block/mirror.c | 28 +---
 blockdev.c | 29 +
 2 files changed, 34 insertions(+), 23 deletions(-)

diff --git a/block/mirror.c b/block/mirror.c
index 84155b1f78..15d1c060eb 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -1755,31 +1755,13 @@ static BlockJob *mirror_start_job(
 
 GLOBAL_STATE_CODE();
 
-if (sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) {
-error_setg(errp, "Sync mode '%s' not supported",
-   MirrorSyncMode_str(sync_mode));
-return NULL;
-} else if (sync_mode == MIRROR_SYNC_MODE_BITMAP) {
-if (!bitmap) {
-error_setg(errp, "Must provide a valid bitmap name for '%s'"
-   " sync mode",
-   MirrorSyncMode_str(sync_mode));
-return NULL;
-}
-} else if (bitmap) {
-error_setg(errp,
-   "sync mode '%s' is not compatible with bitmaps",
-   MirrorSyncMode_str(sync_mode));
-return NULL;
-}
+/* QMP interface protects us from these cases */
+assert(sync_mode != MIRROR_SYNC_MODE_INCREMENTAL);
+assert((bitmap && sync_mode == MIRROR_SYNC_MODE_BITMAP) ||
+   (!bitmap && sync_mode != MIRROR_SYNC_MODE_BITMAP));
+assert(!(bitmap && granularity));
 
 if (bitmap) {
-if (granularity) {
-error_setg(errp, "granularity (%d)"
-   "cannot be specified when a bitmap is provided",
-   granularity);
-return NULL;
-}
 granularity = bdrv_dirty_bitmap_granularity(bitmap);
 
 if (bitmap_mode != BITMAP_SYNC_MODE_NEVER) {
diff --git a/blockdev.c b/blockdev.c
index aeb9fde9f3..519f408359 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2852,7 +2852,36 @@ static void blockdev_mirror_common(const char *job_id, 
BlockDriverState *bs,
 sync = MIRROR_SYNC_MODE_FULL;
 }
 
+if ((sync == MIRROR_SYNC_MODE_BITMAP) ||
+(sync == MIRROR_SYNC_MODE_INCREMENTAL)) {
+/* done before desugaring 'incremental' to print the right message */
+if (!bitmap_name) {
+error_setg(errp, "Must provide a valid bitmap name for "
+   "'%s' sync mode", MirrorSyncMode_str(sync));
+return;
+}
+}
+
+if (sync == MIRROR_SYNC_MODE_INCREMENTAL) {
+if (has_bitmap_mode &&
+bitmap_mode != BITMAP_SYNC_MODE_ON_SUCCESS) {
+error_setg(errp, "Bitmap sync mode must be '%s' "
+   "when using sync mode '%s'",
+   BitmapSyncMode_str(BITMAP_SYNC_MODE_ON_SUCCESS),
+   MirrorSyncMode_str(sync));
+return;
+}
+has_bitmap_mode = true;
+sync = MIRROR_SYNC_MODE_BITMAP;
+bitmap_mode = BITMAP_SYNC_MODE_ON_SUCCESS;
+}
+
 if (bitmap_name) {
+if (sync != MIRROR_SYNC_MODE_BITMAP) {
+error_setg(errp, "Sync mode '%s' not supported with bitmap.",
+   MirrorSyncMode_str(sync));
+return;
+}
 if (granularity) {
 error_setg(errp, "Granularity and bitmap cannot both be set");
 return;
-- 
2.39.2





[RFC 1/4] drive-mirror: add support for sync=bitmap mode=never

2024-02-16 Thread Fiona Ebner
From: John Snow 

This patch adds support for the "BITMAP" sync mode to drive-mirror and
blockdev-mirror. It adds support only for the BitmapSyncMode "never,"
because it's the simplest mode.

This mode simply uses a user-provided bitmap as an initial copy
manifest, and then does not clear any bits in the bitmap at the
conclusion of the operation.

Any new writes dirtied during the operation are copied out, in contrast
to backup. Note that whether these writes are reflected in the bitmap
at the conclusion of the operation depends on whether that bitmap is
actually recording!

This patch was originally based on one by Ma Haocong, but it has since
been modified pretty heavily.

Suggested-by: Ma Haocong 
Signed-off-by: Ma Haocong 
Signed-off-by: John Snow 
[FG: switch to bdrv_dirty_bitmap_merge_internal]
Signed-off-by: Fabian Grünbichler 
Signed-off-by: Thomas Lamprecht 
[FE: rebase for 9.0
 update version and formatting in QAPI]
Signed-off-by: Fiona Ebner 
---
 block/mirror.c | 96 --
 blockdev.c | 38 +-
 include/block/block_int-global-state.h |  4 +-
 qapi/block-core.json   | 25 ++-
 tests/unit/test-block-iothread.c   |  4 +-
 5 files changed, 139 insertions(+), 28 deletions(-)

diff --git a/block/mirror.c b/block/mirror.c
index 5145eb53e1..315dff11e2 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -51,7 +51,7 @@ typedef struct MirrorBlockJob {
 BlockDriverState *to_replace;
 /* Used to block operations on the drive-mirror-replace target */
 Error *replace_blocker;
-bool is_none_mode;
+MirrorSyncMode sync_mode;
 BlockMirrorBackingMode backing_mode;
 /* Whether the target image requires explicit zero-initialization */
 bool zero_target;
@@ -73,6 +73,8 @@ typedef struct MirrorBlockJob {
 size_t buf_size;
 int64_t bdev_length;
 unsigned long *cow_bitmap;
+BdrvDirtyBitmap *sync_bitmap;
+BitmapSyncMode bitmap_mode;
 BdrvDirtyBitmap *dirty_bitmap;
 BdrvDirtyBitmapIter *dbi;
 uint8_t *buf;
@@ -718,7 +720,8 @@ static int mirror_exit_common(Job *job)
  &error_abort);
 
 if (!abort && s->backing_mode == MIRROR_SOURCE_BACKING_CHAIN) {
-BlockDriverState *backing = s->is_none_mode ? src : s->base;
+BlockDriverState *backing;
+backing = s->sync_mode == MIRROR_SYNC_MODE_NONE ? src : s->base;
 BlockDriverState *unfiltered_target = bdrv_skip_filters(target_bs);
 
 if (bdrv_cow_bs(unfiltered_target) != backing) {
@@ -815,6 +818,16 @@ static void mirror_abort(Job *job)
 assert(ret == 0);
 }
 
+/* Always called after commit/abort. */
+static void mirror_clean(Job *job)
+{
+MirrorBlockJob *s = container_of(job, MirrorBlockJob, common.job);
+
+if (s->sync_bitmap) {
+bdrv_dirty_bitmap_set_busy(s->sync_bitmap, false);
+}
+}
+
 static void coroutine_fn mirror_throttle(MirrorBlockJob *s)
 {
 int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
@@ -1011,7 +1024,8 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
 mirror_free_init(s);
 
 s->last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);
-if (!s->is_none_mode) {
+if ((s->sync_mode == MIRROR_SYNC_MODE_TOP) ||
+(s->sync_mode == MIRROR_SYNC_MODE_FULL)) {
 ret = mirror_dirty_init(s);
 if (ret < 0 || job_is_cancelled(&s->common.job)) {
 goto immediate_exit;
@@ -1302,6 +1316,7 @@ static const BlockJobDriver mirror_job_driver = {
 .run= mirror_run,
 .prepare= mirror_prepare,
 .abort  = mirror_abort,
+.clean  = mirror_clean,
 .pause  = mirror_pause,
 .complete   = mirror_complete,
 .cancel = mirror_cancel,
@@ -1320,6 +1335,7 @@ static const BlockJobDriver commit_active_job_driver = {
 .run= mirror_run,
 .prepare= mirror_prepare,
 .abort  = mirror_abort,
+.clean  = mirror_clean,
 .pause  = mirror_pause,
 .complete   = mirror_complete,
 .cancel = commit_active_cancel,
@@ -1712,7 +1728,10 @@ static BlockJob *mirror_start_job(
  BlockCompletionFunc *cb,
  void *opaque,
  const BlockJobDriver *driver,
- bool is_none_mode, BlockDriverState *base,
+ MirrorSyncMode sync_mode,
+ BdrvDirtyBitmap *bitmap,
+ BitmapSyncMode bitmap_mode,
+ BlockDriverState *base,
  bool auto_complete, const char *filter_node_name,
  bool is_mirror, MirrorCopyMode copy_mode,

[PATCH 01/21] hw/i386/pc: Do not use C99 mixed-declarations style

2024-02-16 Thread Philippe Mathieu-Daudé
QEMU's coding style generally forbids C99 mixed declarations.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/i386/pc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 196827531a..3c00a87317 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1227,6 +1227,7 @@ void pc_basic_device_init(struct PCMachineState *pcms,
  */
 if (pcms->hpet_enabled) {
 qemu_irq rtc_irq;
+uint8_t compat;
 
 hpet = qdev_try_new(TYPE_HPET);
 if (!hpet) {
@@ -1238,8 +1239,7 @@ void pc_basic_device_init(struct PCMachineState *pcms,
  * use IRQ16~23, IRQ8 and IRQ2.  If the user has already set
  * the property, use whatever mask they specified.
  */
-uint8_t compat = object_property_get_uint(OBJECT(hpet),
-HPET_INTCAP, NULL);
+compat = object_property_get_uint(OBJECT(hpet), HPET_INTCAP, NULL);
 if (!compat) {
 qdev_prop_set_uint32(hpet, HPET_INTCAP, hpet_irqs);
 }
-- 
2.41.0




[PATCH 06/21] hw: Replace DEVICE(object_new) -> qdev_new()

2024-02-16 Thread Philippe Mathieu-Daudé
Prefer QDev API for QDev objects, avoid the underlying QOM layer.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/arm/musicpal.c | 2 +-
 hw/core/qdev.c| 2 +-
 hw/sparc/sun4m.c  | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index 2020f73a57..74e4d24aab 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -1238,7 +1238,7 @@ static void musicpal_init(MachineState *machine)
   qdev_get_gpio_in(pic, MP_TIMER4_IRQ), NULL);
 
 /* Logically OR both UART IRQs together */
-uart_orgate = DEVICE(object_new(TYPE_OR_IRQ));
+uart_orgate = qdev_new(TYPE_OR_IRQ);
 object_property_set_int(OBJECT(uart_orgate), "num-lines", 2, &error_fatal);
 qdev_realize_and_unref(uart_orgate, NULL, &error_fatal);
 qdev_connect_gpio_out(uart_orgate, 0,
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index c68d0f7c51..a271380d20 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -171,7 +171,7 @@ DeviceState *qdev_try_new(const char *name)
 if (!module_object_class_by_name(name)) {
 return NULL;
 }
-return DEVICE(object_new(name));
+return qdev_new(name);
 }
 
 static QTAILQ_HEAD(, DeviceListener) device_listeners
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index d52e6a7213..fedc4b8b3f 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -979,7 +979,7 @@ static void sun4m_hw_init(MachineState *machine)
 sysbus_mmio_map(s, 0, hwdef->ms_kb_base);
 
 /* Logically OR both its IRQs together */
-ms_kb_orgate = DEVICE(object_new(TYPE_OR_IRQ));
+ms_kb_orgate = qdev_new(TYPE_OR_IRQ);
 object_property_set_int(OBJECT(ms_kb_orgate), "num-lines", 2, 
&error_fatal);
 qdev_realize_and_unref(ms_kb_orgate, NULL, &error_fatal);
 sysbus_connect_irq(s, 0, qdev_get_gpio_in(ms_kb_orgate, 0));
@@ -1000,7 +1000,7 @@ static void sun4m_hw_init(MachineState *machine)
 sysbus_mmio_map(s, 0, hwdef->serial_base);
 
 /* Logically OR both its IRQs together */
-serial_orgate = DEVICE(object_new(TYPE_OR_IRQ));
+serial_orgate = qdev_new(TYPE_OR_IRQ);
 object_property_set_int(OBJECT(serial_orgate), "num-lines", 2,
 &error_fatal);
 qdev_realize_and_unref(serial_orgate, NULL, &error_fatal);
-- 
2.41.0




[PATCH 05/21] hw/ppc/pnv_bmc: Use qdev_new() instead of QOM API

2024-02-16 Thread Philippe Mathieu-Daudé
Prefer QDev API for QDev objects, avoid the underlying QOM layer.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/ppc/pnv_bmc.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/ppc/pnv_bmc.c b/hw/ppc/pnv_bmc.c
index 99f1e8d7f9..0c1274df21 100644
--- a/hw/ppc/pnv_bmc.c
+++ b/hw/ppc/pnv_bmc.c
@@ -269,13 +269,13 @@ void pnv_bmc_set_pnor(IPMIBmc *bmc, PnvPnor *pnor)
  */
 IPMIBmc *pnv_bmc_create(PnvPnor *pnor)
 {
-Object *obj;
+DeviceState *dev;
 
-obj = object_new(TYPE_IPMI_BMC_SIMULATOR);
-qdev_realize(DEVICE(obj), NULL, &error_fatal);
-pnv_bmc_set_pnor(IPMI_BMC(obj), pnor);
+dev = qdev_new(TYPE_IPMI_BMC_SIMULATOR);
+qdev_realize(dev, NULL, &error_fatal);
+pnv_bmc_set_pnor(IPMI_BMC(dev), pnor);
 
-return IPMI_BMC(obj);
+return IPMI_BMC(dev);
 }
 
 typedef struct ForeachArgs {
-- 
2.41.0




[PATCH 12/21] hw/pci-host/q35: Update q35_host_props[] comment

2024-02-16 Thread Philippe Mathieu-Daudé
Commit aff39be0ed ("hw/pci-host: Use object_initialize_child for
correct reference counting") replaced object_initialize() by
object_initialize_child(), update the comment.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/pci-host/q35.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/pci-host/q35.c b/hw/pci-host/q35.c
index 0d7d4e3f08..0eb1c7034d 100644
--- a/hw/pci-host/q35.c
+++ b/hw/pci-host/q35.c
@@ -165,10 +165,10 @@ static void q35_host_get_pci_hole64_end(Object *obj, 
Visitor *v,
 /*
  * NOTE: setting defaults for the mch.* fields in this table
  * doesn't work, because mch is a separate QOM object that is
- * zeroed by the object_initialize(&s->mch, ...) call inside
+ * zeroed by the object_initialize_child(..., &s->mch, ...) call inside
  * q35_host_initfn().  The default values for those
  * properties need to be initialized manually by
- * q35_host_initfn() after the object_initialize() call.
+ * q35_host_initfn() after the object_initialize_child() call.
  */
 static Property q35_host_props[] = {
 DEFINE_PROP_UINT64(PCIE_HOST_MCFG_BASE, Q35PCIHost, parent_obj.base_addr,
@@ -211,7 +211,7 @@ static void q35_host_initfn(Object *obj)
 object_initialize_child(OBJECT(s), "mch", &s->mch, TYPE_MCH_PCI_DEVICE);
 qdev_prop_set_int32(DEVICE(&s->mch), "addr", PCI_DEVFN(0, 0));
 qdev_prop_set_bit(DEVICE(&s->mch), "multifunction", false);
-/* mch's object_initialize resets the default value, set it again */
+/* mch's object_initialize_child resets the default value, set it again */
 qdev_prop_set_uint64(DEVICE(s), PCI_HOST_PROP_PCI_HOLE64_SIZE,
  Q35_PCI_HOST_HOLE64_SIZE_DEFAULT);
 object_property_add(obj, PCI_HOST_PROP_PCI_HOLE_START, "uint32",
-- 
2.41.0




[PATCH 11/21] hw/usb: Add QOM parentship relation with hub devices

2024-02-16 Thread Philippe Mathieu-Daudé
QDev objects created with qdev_*new() need to manually add
their parent relationship with object_property_add_child().

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/usb/bus.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index a599e2552b..baad04f466 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -439,6 +439,7 @@ void usb_claim_port(USBDevice *dev, Error **errp)
 /* Create a new hub and chain it on */
 hub = USB_DEVICE(qdev_try_new("usb-hub"));
 if (hub) {
+object_property_add_child(OBJECT(dev), "hub", OBJECT(hub));
 usb_realize_and_unref(hub, bus, NULL);
 }
 }
-- 
2.41.0




[PATCH 07/21] target: Replace DEVICE(object_new) -> qdev_new()

2024-02-16 Thread Philippe Mathieu-Daudé
Prefer QDev API for QDev objects, avoid the underlying QOM layer.

Signed-off-by: Philippe Mathieu-Daudé 
---
 target/mips/cpu.c   | 2 +-
 target/xtensa/cpu.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/mips/cpu.c b/target/mips/cpu.c
index d644adbc77..6b3909ee08 100644
--- a/target/mips/cpu.c
+++ b/target/mips/cpu.c
@@ -649,7 +649,7 @@ MIPSCPU *mips_cpu_create_with_clock(const char *cpu_type, 
Clock *cpu_refclk)
 {
 DeviceState *cpu;
 
-cpu = DEVICE(object_new(cpu_type));
+cpu = qdev_new(cpu_type);
 qdev_connect_clock_in(cpu, "clk-in", cpu_refclk);
 qdev_realize(cpu, NULL, &error_abort);
 
diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c
index 79f91819df..4f9408e1a0 100644
--- a/target/xtensa/cpu.c
+++ b/target/xtensa/cpu.c
@@ -205,7 +205,7 @@ XtensaCPU *xtensa_cpu_create_with_clock(const char 
*cpu_type, Clock *cpu_refclk)
 {
 DeviceState *cpu;
 
-cpu = DEVICE(object_new(cpu_type));
+cpu = qdev_new(cpu_type);
 qdev_connect_clock_in(cpu, "clk-in", cpu_refclk);
 qdev_realize(cpu, NULL, &error_abort);
 
-- 
2.41.0




[PATCH 16/21] hw/net/can/versal: Prefer object_initialize_child over object_initialize

2024-02-16 Thread Philippe Mathieu-Daudé
When the QOM parent is available, prefer object_initialize_child()
over object_initialize(), since it create the parent relationship.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/net/can/xlnx-versal-canfd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/net/can/xlnx-versal-canfd.c b/hw/net/can/xlnx-versal-canfd.c
index 47a14cfe63..f8e4bd75e4 100644
--- a/hw/net/can/xlnx-versal-canfd.c
+++ b/hw/net/can/xlnx-versal-canfd.c
@@ -1900,7 +1900,7 @@ static int canfd_populate_regarray(XlnxVersalCANFDState 
*s,
 int index = rae[i].addr / 4;
 RegisterInfo *r = &s->reg_info[index];
 
-object_initialize(r, sizeof(*r), TYPE_REGISTER);
+object_initialize_child(OBJECT(s), "reg[*]", r, TYPE_REGISTER);
 
 *r = (RegisterInfo) {
 .data = &s->regs[index],
-- 
2.41.0




[PATCH 04/21] hw/tricore/testboard: Use qdev_new() instead of QOM basic API

2024-02-16 Thread Philippe Mathieu-Daudé
Prefer QDev API for QDev objects, avoid the underlying QOM layer.

Signed-off-by: Philippe Mathieu-Daudé 
---
 include/hw/tricore/tricore_testdevice.h | 3 ---
 hw/tricore/tricore_testboard.c  | 4 +---
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/include/hw/tricore/tricore_testdevice.h 
b/include/hw/tricore/tricore_testdevice.h
index 8b4fe15f24..2c57b62f22 100644
--- a/include/hw/tricore/tricore_testdevice.h
+++ b/include/hw/tricore/tricore_testdevice.h
@@ -25,12 +25,9 @@
 OBJECT_CHECK(TriCoreTestDeviceState, (obj), TYPE_TRICORE_TESTDEVICE)
 
 typedef struct {
-/*  */
 SysBusDevice parent_obj;
 
-/*  */
 MemoryRegion iomem;
-
 } TriCoreTestDeviceState;
 
 #endif
diff --git a/hw/tricore/tricore_testboard.c b/hw/tricore/tricore_testboard.c
index b6810e3be0..c29db8b451 100644
--- a/hw/tricore/tricore_testboard.c
+++ b/hw/tricore/tricore_testboard.c
@@ -89,9 +89,7 @@ static void tricore_testboard_init(MachineState *machine, int 
board_id)
 memory_region_add_subregion(sysmem, 0xf005, pcp_data);
 memory_region_add_subregion(sysmem, 0xf006, pcp_text);
 
-test_dev = g_new(TriCoreTestDeviceState, 1);
-object_initialize(test_dev, sizeof(TriCoreTestDeviceState),
-  TYPE_TRICORE_TESTDEVICE);
+test_dev = TRICORE_TESTDEVICE(qdev_new(TYPE_TRICORE_TESTDEVICE));
 memory_region_add_subregion(sysmem, 0xf000, &test_dev->iomem);
 
 
-- 
2.41.0




[PATCH 09/21] hw/usb: Inline usb_try_new()

2024-02-16 Thread Philippe Mathieu-Daudé
Inline the single use of usb_try_new().

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/usb/bus.c | 7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 59c39945dd..148224f06a 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -334,11 +334,6 @@ USBDevice *usb_new(const char *name)
 return USB_DEVICE(qdev_new(name));
 }
 
-static USBDevice *usb_try_new(const char *name)
-{
-return USB_DEVICE(qdev_try_new(name));
-}
-
 bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp)
 {
 return qdev_realize_and_unref(&dev->qdev, &bus->qbus, errp);
@@ -447,7 +442,7 @@ void usb_claim_port(USBDevice *dev, Error **errp)
 } else {
 if (bus->nfree == 1 && strcmp(object_get_typename(OBJECT(dev)), 
"usb-hub") != 0) {
 /* Create a new hub and chain it on */
-hub = usb_try_new("usb-hub");
+hub = USB_DEVICE(qdev_try_new("usb-hub"));
 if (hub) {
 usb_realize_and_unref(hub, bus, NULL);
 }
-- 
2.41.0




[PATCH 00/21] hw: More QDev cleanups

2024-02-16 Thread Philippe Mathieu-Daudé
Various QDev cleanups extracted to my "enforce QDev API" branch.
- When available, instead of plain QOM, use QDev API equivalent
- Add missing QOM parentship for some obj created with qdev_*new()
- Prefer object_initialize_child() over object_initialize()

Philippe Mathieu-Daudé (21):
  hw/i386/pc: Do not use C99 mixed-declarations style
  hw/i386/pc_sysfw: Use qdev_is_realized() instead of QOM API
  hw/ppc/spapr_cpu: Use qdev_is_realized() instead of QOM API
  hw/tricore/testboard: Use qdev_new() instead of QOM basic API
  hw/ppc/pnv_bmc: Use qdev_new() instead of QOM API
  hw: Replace DEVICE(object_new) -> qdev_new()
  target: Replace DEVICE(object_new) -> qdev_new()
  hw/isa: Inline isa_try_new()
  hw/usb: Inline usb_try_new()
  hw/usb: Inline usb_new()
  hw/usb: Add QOM parentship relation with hub devices
  hw/pci-host/q35: Update q35_host_props[] comment
  hw/pci-host/raven: Embedded OrIRQ in PRePPCIState
  hw/pci-host/raven: Prefer object_initialize_child over
object_initialize
  hw/core/register: Prefer object_initialize_child over
object_initialize
  hw/net/can/versal: Prefer object_initialize_child over
object_initialize
  hw/i386/iommu: Prefer object_initialize_child over object_initialize
  hw/pci-host/versatile: Replace object_initialize() -> _child()
  hw/s390x/zpci-bus: Add QOM parentship relation with zPCI devices
  hw/arm/mps2: Add QOM parentship relation with OR IRQ gates
  hw: Add QOM parentship relation with CPUs

 include/hw/isa/isa.h |  1 -
 include/hw/net/ne2000-isa.h  |  2 +-
 include/hw/tricore/tricore_testdevice.h  |  3 ---
 include/hw/usb.h |  1 -
 hw/arm/mps2.c|  5 +
 hw/arm/musicpal.c|  2 +-
 hw/core/qdev.c   |  2 +-
 hw/core/register.c   |  2 +-
 hw/i386/amd_iommu.c  |  6 +++---
 hw/i386/pc.c |  6 +++---
 hw/i386/pc_sysfw.c   |  6 ++
 hw/i386/x86.c|  1 +
 hw/isa/isa-bus.c |  5 -
 hw/microblaze/petalogix_ml605_mmu.c  |  1 +
 hw/microblaze/petalogix_s3adsp1800_mmu.c |  1 +
 hw/mips/cps.c|  1 +
 hw/net/can/xlnx-versal-canfd.c   |  2 +-
 hw/nios2/10m50_devboard.c|  1 +
 hw/pci-host/q35.c|  6 +++---
 hw/pci-host/raven.c  | 18 --
 hw/pci-host/versatile.c  |  3 ++-
 hw/ppc/e500.c|  1 +
 hw/ppc/pnv_bmc.c | 10 +-
 hw/ppc/spapr.c   |  1 +
 hw/ppc/spapr_cpu_core.c  |  3 +--
 hw/s390x/s390-pci-bus.c  |  1 +
 hw/sparc/sun4m.c |  4 ++--
 hw/tricore/tricore_testboard.c   |  4 +---
 hw/usb/bus.c | 17 -
 hw/usb/dev-serial.c  |  2 +-
 target/mips/cpu.c|  2 +-
 target/xtensa/cpu.c  |  2 +-
 32 files changed, 55 insertions(+), 67 deletions(-)

-- 
2.41.0




[PATCH 02/21] hw/i386/pc_sysfw: Use qdev_is_realized() instead of QOM API

2024-02-16 Thread Philippe Mathieu-Daudé
Prefer QDev API for QDev objects, avoid the underlying QOM layer.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/i386/pc_sysfw.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
index c8d9e71b88..3efabbbab2 100644
--- a/hw/i386/pc_sysfw.c
+++ b/hw/i386/pc_sysfw.c
@@ -107,17 +107,15 @@ void pc_system_flash_cleanup_unused(PCMachineState *pcms)
 {
 char *prop_name;
 int i;
-Object *dev_obj;
 
 assert(PC_MACHINE_GET_CLASS(pcms)->pci_enabled);
 
 for (i = 0; i < ARRAY_SIZE(pcms->flash); i++) {
-dev_obj = OBJECT(pcms->flash[i]);
-if (!object_property_get_bool(dev_obj, "realized", &error_abort)) {
+if (!qdev_is_realized(DEVICE(pcms->flash[i]))) {
 prop_name = g_strdup_printf("pflash%d", i);
 object_property_del(OBJECT(pcms), prop_name);
 g_free(prop_name);
-object_unparent(dev_obj);
+object_unparent(OBJECT(pcms->flash[i]));
 pcms->flash[i] = NULL;
 }
 }
-- 
2.41.0




[PATCH 08/21] hw/isa: Inline isa_try_new()

2024-02-16 Thread Philippe Mathieu-Daudé
Inline the 2 single uses of isa_try_new().

Signed-off-by: Philippe Mathieu-Daudé 
---
 include/hw/isa/isa.h| 1 -
 include/hw/net/ne2000-isa.h | 2 +-
 hw/i386/pc.c| 2 +-
 hw/isa/isa-bus.c| 5 -
 4 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h
index 40d6224a4e..8475120849 100644
--- a/include/hw/isa/isa.h
+++ b/include/hw/isa/isa.h
@@ -81,7 +81,6 @@ IsaDma *isa_bus_get_dma(ISABus *bus, int nchan);
  */
 qemu_irq isa_bus_get_irq(ISABus *bus, unsigned irqnum);
 ISADevice *isa_new(const char *name);
-ISADevice *isa_try_new(const char *name);
 bool isa_realize_and_unref(ISADevice *dev, ISABus *bus, Error **errp);
 ISADevice *isa_create_simple(ISABus *bus, const char *name);
 
diff --git a/include/hw/net/ne2000-isa.h b/include/hw/net/ne2000-isa.h
index 73bae10ad1..2440ac8621 100644
--- a/include/hw/net/ne2000-isa.h
+++ b/include/hw/net/ne2000-isa.h
@@ -22,7 +22,7 @@ static inline ISADevice *isa_ne2000_init(ISABus *bus, int 
base, int irq,
 {
 ISADevice *d;
 
-d = isa_try_new(TYPE_ISA_NE2000);
+d = ISA_DEVICE(qdev_try_new(TYPE_ISA_NE2000));
 if (d) {
 DeviceState *dev = DEVICE(d);
 
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 3c00a87317..e8130774ad 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1183,7 +1183,7 @@ static void pc_superio_init(ISABus *isa_bus, bool 
create_fdctrl,
 i8042 = isa_create_simple(isa_bus, TYPE_I8042);
 if (!no_vmport) {
 isa_create_simple(isa_bus, TYPE_VMPORT);
-vmmouse = isa_try_new("vmmouse");
+vmmouse = ISA_DEVICE(qdev_try_new("vmmouse"));
 } else {
 vmmouse = NULL;
 }
diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c
index f1e0f14007..8aaf44a3ef 100644
--- a/hw/isa/isa-bus.c
+++ b/hw/isa/isa-bus.c
@@ -158,11 +158,6 @@ ISADevice *isa_new(const char *name)
 return ISA_DEVICE(qdev_new(name));
 }
 
-ISADevice *isa_try_new(const char *name)
-{
-return ISA_DEVICE(qdev_try_new(name));
-}
-
 ISADevice *isa_create_simple(ISABus *bus, const char *name)
 {
 ISADevice *dev;
-- 
2.41.0




[PATCH 19/21] hw/s390x/zpci-bus: Add QOM parentship relation with zPCI devices

2024-02-16 Thread Philippe Mathieu-Daudé
QDev objects created with qdev_*new() need to manually add
their parent relationship with object_property_add_child().

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/s390x/s390-pci-bus.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
index 3e57d5faca..6d07a7b530 100644
--- a/hw/s390x/s390-pci-bus.c
+++ b/hw/s390x/s390-pci-bus.c
@@ -934,6 +934,7 @@ static S390PCIBusDevice *s390_pci_device_new(S390pciState 
*s,
 "zPCI device could not be created: ");
 return NULL;
 }
+object_property_add_child(OBJECT(s), "zpci[*]", OBJECT(dev));
 if (!qdev_realize_and_unref(dev, BUS(s->bus), &local_err)) {
 object_unparent(OBJECT(dev));
 error_propagate_prepend(errp, local_err,
-- 
2.41.0




[PATCH 14/21] hw/pci-host/raven: Prefer object_initialize_child over object_initialize

2024-02-16 Thread Philippe Mathieu-Daudé
When the QOM parent is available, prefer object_initialize_child()
over object_initialize(), since it create the parent relationship.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/pci-host/raven.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/hw/pci-host/raven.c b/hw/pci-host/raven.c
index 9e47caebc5..5ef25edba6 100644
--- a/hw/pci-host/raven.c
+++ b/hw/pci-host/raven.c
@@ -290,7 +290,6 @@ static void raven_pcihost_initfn(Object *obj)
 PCIHostState *h = PCI_HOST_BRIDGE(obj);
 PREPPCIState *s = RAVEN_PCI_HOST_BRIDGE(obj);
 MemoryRegion *address_space_mem = get_system_memory();
-DeviceState *pci_dev;
 
 memory_region_init(&s->pci_io, obj, "pci-io", 0x3f80);
 memory_region_init_io(&s->pci_io_non_contiguous, obj, &raven_io_ops, s,
@@ -328,11 +327,10 @@ static void raven_pcihost_initfn(Object *obj)
 
 h->bus = &s->pci_bus;
 
-object_initialize(&s->pci_dev, sizeof(s->pci_dev), TYPE_RAVEN_PCI_DEVICE);
-pci_dev = DEVICE(&s->pci_dev);
+object_initialize_child(obj, "bridge", &s->pci_dev, TYPE_RAVEN_PCI_DEVICE);
 object_property_set_int(OBJECT(&s->pci_dev), "addr", PCI_DEVFN(0, 0),
 NULL);
-qdev_prop_set_bit(pci_dev, "multifunction", false);
+qdev_prop_set_bit(DEVICE(&s->pci_dev), "multifunction", false);
 }
 
 static void raven_realize(PCIDevice *d, Error **errp)
-- 
2.41.0




[PATCH 21/21] hw: Add QOM parentship relation with CPUs

2024-02-16 Thread Philippe Mathieu-Daudé
QDev objects created with object_new() need to manually add
their parent relationship with object_property_add_child().

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/i386/x86.c| 1 +
 hw/microblaze/petalogix_ml605_mmu.c  | 1 +
 hw/microblaze/petalogix_s3adsp1800_mmu.c | 1 +
 hw/mips/cps.c| 1 +
 hw/nios2/10m50_devboard.c| 1 +
 hw/ppc/e500.c| 1 +
 hw/ppc/spapr.c   | 1 +
 7 files changed, 7 insertions(+)

diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 684dce90e9..7021419d91 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -102,6 +102,7 @@ void x86_cpu_new(X86MachineState *x86ms, int64_t apic_id, 
Error **errp)
 if (!object_property_set_uint(cpu, "apic-id", apic_id, errp)) {
 goto out;
 }
+object_property_add_child(OBJECT(x86ms), "cpu[*]", OBJECT(cpu));
 qdev_realize(DEVICE(cpu), NULL, errp);
 
 out:
diff --git a/hw/microblaze/petalogix_ml605_mmu.c 
b/hw/microblaze/petalogix_ml605_mmu.c
index 0f5fabc32e..dfd881322d 100644
--- a/hw/microblaze/petalogix_ml605_mmu.c
+++ b/hw/microblaze/petalogix_ml605_mmu.c
@@ -83,6 +83,7 @@ petalogix_ml605_init(MachineState *machine)
 
 /* init CPUs */
 cpu = MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU));
+object_property_add_child(OBJECT(machine), "cpu", OBJECT(cpu));
 object_property_set_str(OBJECT(cpu), "version", "8.10.a", &error_abort);
 /* Use FPU but don't use floating point conversion and square
  * root instructions
diff --git a/hw/microblaze/petalogix_s3adsp1800_mmu.c 
b/hw/microblaze/petalogix_s3adsp1800_mmu.c
index dad46bd7f9..255d8d4d47 100644
--- a/hw/microblaze/petalogix_s3adsp1800_mmu.c
+++ b/hw/microblaze/petalogix_s3adsp1800_mmu.c
@@ -70,6 +70,7 @@ petalogix_s3adsp1800_init(MachineState *machine)
 MemoryRegion *sysmem = get_system_memory();
 
 cpu = MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU));
+object_property_add_child(OBJECT(machine), "cpu", OBJECT(cpu));
 object_property_set_str(OBJECT(cpu), "version", "7.10.d", &error_abort);
 qdev_realize(DEVICE(cpu), NULL, &error_abort);
 
diff --git a/hw/mips/cps.c b/hw/mips/cps.c
index 07b73b0a1f..6b4e918807 100644
--- a/hw/mips/cps.c
+++ b/hw/mips/cps.c
@@ -84,6 +84,7 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)
 /* All cores use the same clock tree */
 qdev_connect_clock_in(DEVICE(cpu), "clk-in", s->clock);
 
+object_property_add_child(OBJECT(dev), "cpu[*]", OBJECT(cpu));
 if (!qdev_realize_and_unref(DEVICE(cpu), NULL, errp)) {
 return;
 }
diff --git a/hw/nios2/10m50_devboard.c b/hw/nios2/10m50_devboard.c
index 6cb32f777b..f6a691d340 100644
--- a/hw/nios2/10m50_devboard.c
+++ b/hw/nios2/10m50_devboard.c
@@ -95,6 +95,7 @@ static void nios2_10m50_ghrd_init(MachineState *machine)
 cpu->exception_addr = 0xc8000120;
 cpu->fast_tlb_miss_addr = 0xc100;
 
+object_property_add_child(OBJECT(machine), "cpu", OBJECT(cpu));
 qdev_realize_and_unref(DEVICE(cpu), NULL, &error_fatal);
 
 if (nms->vic) {
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index 3bd12b54ab..77b7d2858c 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -956,6 +956,7 @@ void ppce500_init(MachineState *machine)
  */
 object_property_set_bool(OBJECT(cs), "start-powered-off", i != 0,
  &error_abort);
+object_property_add_child(OBJECT(machine), "cpu[*]", OBJECT(cpu));
 qdev_realize_and_unref(DEVICE(cs), NULL, &error_fatal);
 
 if (!firstenv) {
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 0d72d286d8..b6e5caa0d2 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -2715,6 +2715,7 @@ static void spapr_init_cpus(SpaprMachineState *spapr)
 &error_fatal);
 object_property_set_int(core, CPU_CORE_PROP_CORE_ID, core_id,
 &error_fatal);
+object_property_add_child(OBJECT(spapr), "cpu[*]", OBJECT(core));
 qdev_realize(DEVICE(core), NULL, &error_fatal);
 
 object_unref(core);
-- 
2.41.0




[PATCH 10/21] hw/usb: Inline usb_new()

2024-02-16 Thread Philippe Mathieu-Daudé
Inline the 2 uses of usb_new().

Signed-off-by: Philippe Mathieu-Daudé 
---
 include/hw/usb.h| 1 -
 hw/usb/bus.c| 9 ++---
 hw/usb/dev-serial.c | 2 +-
 3 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/include/hw/usb.h b/include/hw/usb.h
index 32c23a5ca2..2d820685cc 100644
--- a/include/hw/usb.h
+++ b/include/hw/usb.h
@@ -500,7 +500,6 @@ void usb_bus_release(USBBus *bus);
 USBBus *usb_bus_find(int busnr);
 void usb_legacy_register(const char *typename, const char *usbdevice_name,
  USBDevice *(*usbdevice_init)(void));
-USBDevice *usb_new(const char *name);
 bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp);
 USBDevice *usb_create_simple(USBBus *bus, const char *name);
 USBDevice *usbdevice_create(const char *cmdline);
diff --git a/hw/usb/bus.c b/hw/usb/bus.c
index 148224f06a..a599e2552b 100644
--- a/hw/usb/bus.c
+++ b/hw/usb/bus.c
@@ -329,11 +329,6 @@ void usb_legacy_register(const char *typename, const char 
*usbdevice_name,
 }
 }
 
-USBDevice *usb_new(const char *name)
-{
-return USB_DEVICE(qdev_new(name));
-}
-
 bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, Error **errp)
 {
 return qdev_realize_and_unref(&dev->qdev, &bus->qbus, errp);
@@ -341,7 +336,7 @@ bool usb_realize_and_unref(USBDevice *dev, USBBus *bus, 
Error **errp)
 
 USBDevice *usb_create_simple(USBBus *bus, const char *name)
 {
-USBDevice *dev = usb_new(name);
+USBDevice *dev = USB_DEVICE(qdev_new(name));
 
 usb_realize_and_unref(dev, bus, &error_abort);
 return dev;
@@ -693,7 +688,7 @@ USBDevice *usbdevice_create(const char *driver)
 return NULL;
 }
 
-dev = f->usbdevice_init ? f->usbdevice_init() : usb_new(f->name);
+dev = f->usbdevice_init ? f->usbdevice_init() : 
USB_DEVICE(qdev_new(f->name));
 if (!dev) {
 error_report("Failed to create USB device '%s'", f->name);
 return NULL;
diff --git a/hw/usb/dev-serial.c b/hw/usb/dev-serial.c
index 63047d79cf..6e79c46d53 100644
--- a/hw/usb/dev-serial.c
+++ b/hw/usb/dev-serial.c
@@ -624,7 +624,7 @@ static USBDevice *usb_braille_init(void)
 return NULL;
 }
 
-dev = usb_new("usb-braille");
+dev = USB_DEVICE(qdev_new("usb-braille"));
 qdev_prop_set_chr(&dev->qdev, "chardev", cdrv);
 return dev;
 }
-- 
2.41.0




[PATCH 17/21] hw/i386/iommu: Prefer object_initialize_child over object_initialize

2024-02-16 Thread Philippe Mathieu-Daudé
When the QOM parent is available, prefer object_initialize_child()
over object_initialize(), since it create the parent relationship.

Rename the 'klass' variable as 'obj' since the argument holds a
reference to an instance object and not a class one.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/i386/amd_iommu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
index 7329553ad3..c3afbc4130 100644
--- a/hw/i386/amd_iommu.c
+++ b/hw/i386/amd_iommu.c
@@ -1616,11 +1616,11 @@ static const VMStateDescription vmstate_amdvi_sysbus = {
 .unmigratable = 1
 };
 
-static void amdvi_sysbus_instance_init(Object *klass)
+static void amdvi_sysbus_instance_init(Object *obj)
 {
-AMDVIState *s = AMD_IOMMU_DEVICE(klass);
+AMDVIState *s = AMD_IOMMU_DEVICE(obj);
 
-object_initialize(&s->pci, sizeof(s->pci), TYPE_AMD_IOMMU_PCI);
+object_initialize_child(obj, "iommu", &s->pci, TYPE_AMD_IOMMU_PCI);
 }
 
 static void amdvi_sysbus_class_init(ObjectClass *klass, void *data)
-- 
2.41.0




[PATCH 13/21] hw/pci-host/raven: Embedded OrIRQ in PRePPCIState

2024-02-16 Thread Philippe Mathieu-Daudé
Since we know the size of the OrIRQ object, we can initialize
it directly in place with object_initialize_child(). Doing so
we also set the QOM parent <-> child relationship.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/pci-host/raven.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/pci-host/raven.c b/hw/pci-host/raven.c
index c7a0a2878a..9e47caebc5 100644
--- a/hw/pci-host/raven.c
+++ b/hw/pci-host/raven.c
@@ -60,7 +60,7 @@ DECLARE_INSTANCE_CHECKER(PREPPCIState, RAVEN_PCI_HOST_BRIDGE,
 struct PRePPCIState {
 PCIHostState parent_obj;
 
-OrIRQState *or_irq;
+OrIRQState or_irq;
 qemu_irq pci_irqs[PCI_NUM_PINS];
 PCIBus pci_bus;
 AddressSpace pci_io_as;
@@ -249,14 +249,14 @@ static void raven_pcihost_realizefn(DeviceState *d, Error 
**errp)
 } else {
 /* According to PReP specification section 6.1.6 "System Interrupt
  * Assignments", all PCI interrupts are routed via IRQ 15 */
-s->or_irq = OR_IRQ(object_new(TYPE_OR_IRQ));
-object_property_set_int(OBJECT(s->or_irq), "num-lines", PCI_NUM_PINS,
+object_initialize_child(OBJECT(dev), "or-irq", &s->or_irq, 
TYPE_OR_IRQ);
+object_property_set_int(OBJECT(&s->or_irq), "num-lines", PCI_NUM_PINS,
 &error_fatal);
-qdev_realize(DEVICE(s->or_irq), NULL, &error_fatal);
-sysbus_init_irq(dev, &s->or_irq->out_irq);
+qdev_realize(DEVICE(&s->or_irq), NULL, &error_fatal);
+sysbus_init_irq(dev, &s->or_irq.out_irq);
 
 for (i = 0; i < PCI_NUM_PINS; i++) {
-s->pci_irqs[i] = qdev_get_gpio_in(DEVICE(s->or_irq), i);
+s->pci_irqs[i] = qdev_get_gpio_in(DEVICE(&s->or_irq), i);
 }
 }
 
-- 
2.41.0




Re: [PATCH 05/21] hw/ppc/pnv_bmc: Use qdev_new() instead of QOM API

2024-02-16 Thread Cédric Le Goater

On 2/16/24 12:02, Philippe Mathieu-Daudé wrote:

Prefer QDev API for QDev objects, avoid the underlying QOM layer.

Signed-off-by: Philippe Mathieu-Daudé 



Reviewed-by: Cédric Le Goater 

Thanks,

C.



---
  hw/ppc/pnv_bmc.c | 10 +-
  1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/ppc/pnv_bmc.c b/hw/ppc/pnv_bmc.c
index 99f1e8d7f9..0c1274df21 100644
--- a/hw/ppc/pnv_bmc.c
+++ b/hw/ppc/pnv_bmc.c
@@ -269,13 +269,13 @@ void pnv_bmc_set_pnor(IPMIBmc *bmc, PnvPnor *pnor)
   */
  IPMIBmc *pnv_bmc_create(PnvPnor *pnor)
  {
-Object *obj;
+DeviceState *dev;
  
-obj = object_new(TYPE_IPMI_BMC_SIMULATOR);

-qdev_realize(DEVICE(obj), NULL, &error_fatal);
-pnv_bmc_set_pnor(IPMI_BMC(obj), pnor);
+dev = qdev_new(TYPE_IPMI_BMC_SIMULATOR);
+qdev_realize(dev, NULL, &error_fatal);
+pnv_bmc_set_pnor(IPMI_BMC(dev), pnor);
  
-return IPMI_BMC(obj);

+return IPMI_BMC(dev);
  }
  
  typedef struct ForeachArgs {





[PATCH 18/21] hw/pci-host/versatile: Replace object_initialize() -> _child()

2024-02-16 Thread Philippe Mathieu-Daudé
When the QOM parent is available, prefer object_initialize_child()
over object_initialize(), since it create the parent relationship.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/pci-host/versatile.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/pci-host/versatile.c b/hw/pci-host/versatile.c
index 0e65deb3f9..5d1f9cc96d 100644
--- a/hw/pci-host/versatile.c
+++ b/hw/pci-host/versatile.c
@@ -410,7 +410,8 @@ static void pci_vpb_realize(DeviceState *dev, Error **errp)
   PCI_DEVFN(11, 0), TYPE_PCI_BUS);
 h->bus = &s->pci_bus;
 
-object_initialize(&s->pci_dev, sizeof(s->pci_dev), 
TYPE_VERSATILE_PCI_HOST);
+object_initialize_child(OBJECT(dev), "pci-func0",
+&s->pci_dev, TYPE_VERSATILE_PCI_HOST);
 
 for (i = 0; i < 4; i++) {
 sysbus_init_irq(sbd, &s->irq[i]);
-- 
2.41.0




[PATCH 20/21] hw/arm/mps2: Add QOM parentship relation with OR IRQ gates

2024-02-16 Thread Philippe Mathieu-Daudé
QDev objects created with object_new() need to manually add
their parent relationship with object_property_add_child().

Signed-off-by: Philippe Mathieu-Daudé 
---
Better would be to embedded an call object_initialize_child()...
---
 hw/arm/mps2.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/hw/arm/mps2.c b/hw/arm/mps2.c
index 50919ee46d..780f2adf0f 100644
--- a/hw/arm/mps2.c
+++ b/hw/arm/mps2.c
@@ -274,6 +274,7 @@ static void mps2_common_init(MachineState *machine)
 
 orgate = object_new(TYPE_OR_IRQ);
 object_property_set_int(orgate, "num-lines", 6, &error_fatal);
+object_property_add_child(OBJECT(machine), "orgate12", orgate);
 qdev_realize(DEVICE(orgate), NULL, &error_fatal);
 orgate_dev = DEVICE(orgate);
 qdev_connect_gpio_out(orgate_dev, 0, qdev_get_gpio_in(armv7m, 12));
@@ -317,6 +318,7 @@ static void mps2_common_init(MachineState *machine)
 
 orgate = object_new(TYPE_OR_IRQ);
 object_property_set_int(orgate, "num-lines", 10, &error_fatal);
+object_property_add_child(OBJECT(machine), "orgate-12", orgate);
 qdev_realize(DEVICE(orgate), NULL, &error_fatal);
 orgate_dev = DEVICE(orgate);
 qdev_connect_gpio_out(orgate_dev, 0, qdev_get_gpio_in(armv7m, 12));
@@ -333,6 +335,8 @@ static void mps2_common_init(MachineState *machine)
 
 txrx_orgate = object_new(TYPE_OR_IRQ);
 object_property_set_int(txrx_orgate, "num-lines", 2, &error_fatal);
+object_property_add_child(OBJECT(machine),
+  "orgate-uart[*]", txrx_orgate);
 qdev_realize(DEVICE(txrx_orgate), NULL, &error_fatal);
 txrx_orgate_dev = DEVICE(txrx_orgate);
 qdev_connect_gpio_out(txrx_orgate_dev, 0,
@@ -425,6 +429,7 @@ static void mps2_common_init(MachineState *machine)
 
 orgate = object_new(TYPE_OR_IRQ);
 object_property_set_int(orgate, "num-lines", 2, &error_fatal);
+object_property_add_child(OBJECT(machine), "orgate-ssi[*]", orgate);
 orgate_dev = DEVICE(orgate);
 qdev_realize(orgate_dev, NULL, &error_fatal);
 qdev_connect_gpio_out(orgate_dev, 0,
-- 
2.41.0




[PATCH 03/21] hw/ppc/spapr_cpu: Use qdev_is_realized() instead of QOM API

2024-02-16 Thread Philippe Mathieu-Daudé
Prefer QDev API for QDev objects, avoid the underlying QOM layer.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/ppc/spapr_cpu_core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
index 0c0fb3f1b0..40b7c52f7f 100644
--- a/hw/ppc/spapr_cpu_core.c
+++ b/hw/ppc/spapr_cpu_core.c
@@ -245,8 +245,7 @@ static void spapr_cpu_core_unrealize(DeviceState *dev)
  * spapr_cpu_core_realize(), make sure we only unrealize
  * vCPUs that have already been realized.
  */
-if (object_property_get_bool(OBJECT(sc->threads[i]), "realized",
- &error_abort)) {
+if (qdev_is_realized(DEVICE(sc->threads[i]))) {
 spapr_unrealize_vcpu(sc->threads[i], sc);
 }
 spapr_delete_vcpu(sc->threads[i]);
-- 
2.41.0




[PATCH 15/21] hw/core/register: Prefer object_initialize_child over object_initialize

2024-02-16 Thread Philippe Mathieu-Daudé
When the QOM parent is available, prefer object_initialize_child()
over object_initialize(), since it create the parent relationship.

Signed-off-by: Philippe Mathieu-Daudé 
---
 hw/core/register.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/core/register.c b/hw/core/register.c
index 95b0150c0a..b6beca0e02 100644
--- a/hw/core/register.c
+++ b/hw/core/register.c
@@ -259,7 +259,7 @@ static RegisterInfoArray *register_init_block(DeviceState 
*owner,
 RegisterInfo *r = &ri[index];
 
 /* Init the register, this will zero it. */
-object_initialize((void *)r, sizeof(*r), TYPE_REGISTER);
+object_initialize_child(OBJECT(owner), "reg[*]", r, TYPE_REGISTER);
 
 /* Set the properties of the register */
 r->data = data + data_size * index;
-- 
2.41.0




Re: [PULL 00/56] Misc HW patches for 2024-02-15

2024-02-16 Thread Peter Maydell
On Thu, 15 Feb 2024 at 17:58, Philippe Mathieu-Daudé  wrote:
>
> The following changes since commit 5767815218efd3cbfd409505ed824d5f356044ae:
>
>   Merge tag 'for_upstream' of 
> https://git.kernel.org/pub/scm/virt/kvm/mst/qemu into staging (2024-02-14 
> 15:45:52 +)
>
> are available in the Git repository at:
>
>   https://github.com/philmd/qemu.git tags/hw-misc-20240215
>
> for you to fetch changes up to 9a4b35f57eefbfc6977ed47d1f19d839e9e4784d:
>
>   hw/ide/ich9: Use AHCIPCIState typedef (2024-02-15 16:58:47 +0100)
>
> 
> Misc HW patch queue
>
> - Remove unused MIPS SAAR* registers (Phil)
> - Remove warning when testing the TC58128 NAND EEPROM (Peter)
> - KConfig cleanups around ISA SuperI/O and MIPS (Paolo)
> - QDev API uses sanitization (Philippe)
> - Split AHCI model as PCI / SysBus (Philippe)
> - Add SMP support to SPARC Leon3 board (Clément)
>


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/9.0
for any user-visible changes.

-- PMM



[RFC] Convert VMWARE vmdk (snapshot) to raw disk

2024-02-16 Thread Jinpu Wang
Hi,

We want to convert some VMWARE VM to KVM, and to reduce the VM down
time, we want to do it in two steps copy approach:

1. a snapshot is taken
- source VM continues to run on VMware => diff creates

2. snapshot is available for download as vmdk
- we need a software to copy snapshot to target VM raw disk

3. source VM is shut down
- diff is available

4. diff needs to be applied to target raw disk
is qemu-img able to do it, or is there another tool?  I saw commit
98eb9733f4cf2eeab6d12db7e758665d2fd5367b
Author: Sam Eiderman 
Date:   Thu Jun 20 12:10:57 2019 +0300

vmdk: Add read-only support for seSparse snapshots

So it seems qemu vmdk already support the seSparse snapshot format,
but it is unclear for us how to connect all these features together.

In short we want to
1 vmdk => raw (big size)
2 vmdk delta => same raw disk (later time, with less content)

Can you give us some suggestions?

Thx!
Jinpu Wang



Re: [PATCH] tests/cdrom-test: Add cdrom test for LoongArch virt machine

2024-02-16 Thread maobibo




On 2024/2/6 下午5:20, Thomas Huth wrote:

On 06/02/2024 03.29, maobibo wrote:

Hi Philippe,

On 2024/2/5 下午8:58, Philippe Mathieu-Daudé wrote:

Hi Bibo,

On 5/2/24 03:13, Bibo Mao wrote:

The cdrom test skips to execute on LoongArch system with command
"make check", this patch enables cdrom test for LoongArch virt
machine platform.

With this patch, cdrom test passes to run on LoongArch virt
machine type.

Signed-off-by: Bibo Mao 
---
  tests/qtest/cdrom-test.c | 3 +++
  1 file changed, 3 insertions(+)

diff --git a/tests/qtest/cdrom-test.c b/tests/qtest/cdrom-test.c
index 0945383789..c8b97d8d9a 100644
--- a/tests/qtest/cdrom-test.c
+++ b/tests/qtest/cdrom-test.c
@@ -271,6 +271,9 @@ int main(int argc, char **argv)
  const char *virtmachine[] = { "virt", NULL };
  add_cdrom_param_tests(virtmachine);
  }
+    } else if (g_str_equal(arch, "loongarch64")) {
+    const char *virtmachine[] = { "virt", NULL };
+    add_cdrom_param_tests(virtmachine);


What is the default device used, virtio-blk-pci?


yes, it is. For virt machine type, the default type for block device is
virtio interface, and it is defined at function loongarch_class_init().
    mc->block_default_type = IF_VIRTIO


Ok, then you might need to check whether your patch still works when you 
run "configure" with "--without-default-devices". You might need to 
check with 'if (qtest_has_device("virtio-blk-pci"))' whether the device 
is really available in the binary, like it is done some lines earlier in 
the arm case.
Sorry for the late response. Yes cdrom test case will report failure 
with it is compiled with --without-default-devices option.


I will refresh the patch like arm case.

Regards
Bibo Mao


  Thomas