...
...
6
gone with this patch series combined with the following change for GLib:
6
gone with this patch series combined with the following change for GLib:
7
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4120
7
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4120
8
8
9
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
9
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
10
---
10
---
11
Changes in v7:
12
- Don't open code memory_region_ref(). (Peter Xu)
13
- Link to v6: https://lore.kernel.org/r/20250105-san-v6-0-11fc859b99b7@daynix.com
14
15
Changes in v6:
16
- Avoid referring owner as "the object that tracks the region's
17
reference count".
18
- Noted that memroy_region_ref() and memroy_region_unref() do nothing
19
if the owner is not present.
20
- Explicitly stated that memory_region_unref() may destroy the owner
21
along with the memory region itself.
22
- Link to v5: https://lore.kernel.org/r/20250104-san-v5-0-8b430457b09d@daynix.com
23
24
Changes in v5:
25
- Rebased.
26
- Merged four patches to update inline documentation into one
27
- Link to v4: https://lore.kernel.org/r/20240823-san-v4-0-a24c6dfa4ceb@daynix.com
28
11
Changes in v4:
29
Changes in v4:
12
- Changed to create a reference to the subregion instead of its owner
30
- Changed to create a reference to the subregion instead of its owner
13
when its owner equals to the container's owner.
31
when its owner equals to the container's owner.
14
- Dropped R-b from patch "memory: Do not create circular reference with
32
- Dropped R-b from patch "memory: Do not create circular reference with
15
subregion".
33
subregion".
...
...
45
- Corrected title of patch "hw/virtio: Free vqs after vhost_dev_cleanup()"
63
- Corrected title of patch "hw/virtio: Free vqs after vhost_dev_cleanup()"
46
(was "hw/virtio: Free vqs before vhost_dev_cleanup()")
64
(was "hw/virtio: Free vqs before vhost_dev_cleanup()")
47
- Link to v1: https://lore.kernel.org/r/20240626-san-v1-0-f3cc42302189@daynix.com
65
- Link to v1: https://lore.kernel.org/r/20240626-san-v1-0-f3cc42302189@daynix.com
48
66
49
---
67
---
50
Akihiko Odaki (7):
68
Akihiko Odaki (2):
51
migration: Free removed SaveStateEntry
69
memory: Update inline documentation
52
memory: Do not refer to "memory region's reference count"
53
memory: Refer to docs/devel/memory.rst for "owner"
54
memory: Clarify that owner may be missing
55
memory: Clarify owner must not call memory_region_ref()
56
memory: Do not create circular reference with subregion
70
memory: Do not create circular reference with subregion
57
tests/qtest: Delete previous boot file
58
71
59
include/exec/memory.h | 22 +++++++---------------
72
include/exec/memory.h | 59 ++++++++++++++++++++++++---------------------------
60
migration/savevm.c | 2 ++
73
system/memory.c | 24 +++++++++++++++++++--
61
system/memory.c | 8 ++++++--
74
2 files changed, 50 insertions(+), 33 deletions(-)
62
tests/qtest/migration-test.c | 18 +++++++++++-------
63
4 files changed, 26 insertions(+), 24 deletions(-)
64
---
75
---
65
base-commit: 31669121a01a14732f57c49400bc239cf9fd505f
76
base-commit: 38d0939b86e2eef6f6a622c6f1f7befda0146595
66
change-id: 20240625-san-097afaf4f1c2
77
change-id: 20240625-san-097afaf4f1c2
67
78
68
Best regards,
79
Best regards,
69
--
80
--
70
Akihiko Odaki <akihiko.odaki@daynix.com>
81
Akihiko Odaki <akihiko.odaki@daynix.com>
71
82
72
83
diff view generated by jsdifflib
Deleted patch
1
This fixes LeakSanitizer warnings.
2
1
3
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
4
Reviewed-by: Peter Xu <peterx@redhat.com>
5
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
6
---
7
migration/savevm.c | 2 ++
8
1 file changed, 2 insertions(+)
9
10
diff --git a/migration/savevm.c b/migration/savevm.c
11
index XXXXXXX..XXXXXXX 100644
12
--- a/migration/savevm.c
13
+++ b/migration/savevm.c
14
@@ -XXX,XX +XXX,XX @@ int vmstate_replace_hack_for_ppc(VMStateIf *obj, int instance_id,
15
16
if (se) {
17
savevm_state_handler_remove(se);
18
+ g_free(se->compat);
19
+ g_free(se);
20
}
21
return vmstate_register(obj, instance_id, vmsd, opaque);
22
}
23
24
--
25
2.46.0
diff view generated by jsdifflib
Deleted patch
1
Now MemoryRegions do have their own reference counts, but they will not
2
be used when their owners are not themselves. However, the documentation
3
of memory_region_ref() says it adds "1 to a memory region's reference
4
count", which is confusing. Avoid referring to "memory region's
5
reference count" and just say: "Add a reference to a memory region".
6
Make a similar change to memory_region_unref() too.
7
1
8
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
9
---
10
include/exec/memory.h | 4 ++--
11
1 file changed, 2 insertions(+), 2 deletions(-)
12
13
diff --git a/include/exec/memory.h b/include/exec/memory.h
14
index XXXXXXX..XXXXXXX 100644
15
--- a/include/exec/memory.h
16
+++ b/include/exec/memory.h
17
@@ -XXX,XX +XXX,XX @@ void memory_region_init(MemoryRegion *mr,
18
uint64_t size);
19
20
/**
21
- * memory_region_ref: Add 1 to a memory region's reference count
22
+ * memory_region_ref: Add a reference to a memory region
23
*
24
* Whenever memory regions are accessed outside the BQL, they need to be
25
* preserved against hot-unplug. MemoryRegions actually do not have their
26
@@ -XXX,XX +XXX,XX @@ void memory_region_init(MemoryRegion *mr,
27
void memory_region_ref(MemoryRegion *mr);
28
29
/**
30
- * memory_region_unref: Remove 1 to a memory region's reference count
31
+ * memory_region_unref: Remove a reference to a memory region
32
*
33
* Whenever memory regions are accessed outside the BQL, they need to be
34
* preserved against hot-unplug. MemoryRegions actually do not have their
35
36
--
37
2.46.0
diff view generated by jsdifflib
1
Do not refer to "memory region's reference count"
2
-------------------------------------------------
3
4
Now MemoryRegions do have their own reference counts, but they will not
5
be used when their owners are not themselves. However, the documentation
6
of memory_region_ref() says it adds "1 to a memory region's reference
7
count", which is confusing. Avoid referring to "memory region's
8
reference count" and just say: "Add a reference to a memory region".
9
Make a similar change to memory_region_unref() too.
10
11
Refer to docs/devel/memory.rst for "owner"
12
------------------------------------------
13
1
memory_region_ref() and memory_region_unref() used to have their own
14
memory_region_ref() and memory_region_unref() used to have their own
2
descriptions of "owner", but they are somewhat out-of-date and
15
descriptions of "owner", but they are somewhat out-of-date and
3
misleading.
16
misleading.
4
17
5
In particular, they say "whenever memory regions are accessed outside
18
In particular, they say "whenever memory regions are accessed outside
...
...
10
used unless their owners are not themselves.
23
used unless their owners are not themselves.
11
24
12
Refer to docs/devel/memory.rst as the single source of truth instead of
25
Refer to docs/devel/memory.rst as the single source of truth instead of
13
maintaining duplicate descriptions of "owner".
26
maintaining duplicate descriptions of "owner".
14
27
28
Clarify that owner may be missing
29
30
---------------------------------
31
A memory region may not have an owner, and memory_region_ref() and
32
memory_region_unref() do nothing for such.
33
34
memory: Clarify owner must not call memory_region_ref()
35
--------------------------------------------------------
36
37
The owner must not call this function as it results in a circular
38
reference.
39
15
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
40
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
41
Reviewed-by: Peter Xu <peterx@redhat.com>
16
---
42
---
17
include/exec/memory.h | 13 ++-----------
43
include/exec/memory.h | 59 ++++++++++++++++++++++++---------------------------
18
1 file changed, 2 insertions(+), 11 deletions(-)
44
1 file changed, 28 insertions(+), 31 deletions(-)
19
45
20
diff --git a/include/exec/memory.h b/include/exec/memory.h
46
diff --git a/include/exec/memory.h b/include/exec/memory.h
21
index XXXXXXX..XXXXXXX 100644
47
index XXXXXXX..XXXXXXX 100644
22
--- a/include/exec/memory.h
48
--- a/include/exec/memory.h
23
+++ b/include/exec/memory.h
49
+++ b/include/exec/memory.h
50
@@ -XXX,XX +XXX,XX @@ void memory_region_section_free_copy(MemoryRegionSection *s);
51
* memory_region_add_subregion() to add subregions.
52
*
53
* @mr: the #MemoryRegion to be initialized
54
- * @owner: the object that tracks the region's reference count
55
+ * @owner: the object that keeps the region alive
56
* @name: used for debugging; not visible to the user or ABI
57
* @size: size of the region; any subregions beyond this size will be clipped
58
*/
24
@@ -XXX,XX +XXX,XX @@ void memory_region_init(MemoryRegion *mr,
59
@@ -XXX,XX +XXX,XX @@ void memory_region_init(MemoryRegion *mr,
60
uint64_t size);
61
25
/**
62
/**
26
* memory_region_ref: Add a reference to a memory region
63
- * memory_region_ref: Add 1 to a memory region's reference count
64
+ * memory_region_ref: Add a reference to the owner of a memory region
27
*
65
*
28
- * Whenever memory regions are accessed outside the BQL, they need to be
66
- * Whenever memory regions are accessed outside the BQL, they need to be
29
- * preserved against hot-unplug. MemoryRegions actually do not have their
67
- * preserved against hot-unplug. MemoryRegions actually do not have their
30
- * own reference count; they piggyback on a QOM object, their "owner".
68
- * own reference count; they piggyback on a QOM object, their "owner".
31
* This function adds a reference to the owner.
69
- * This function adds a reference to the owner.
32
- *
70
- *
33
- * All MemoryRegions must have an owner if they can disappear, even if the
71
- * All MemoryRegions must have an owner if they can disappear, even if the
34
- * device they belong to operates exclusively under the BQL. This is because
72
- * device they belong to operates exclusively under the BQL. This is because
35
- * the region could be returned at any time by memory_region_find, and this
73
- * the region could be returned at any time by memory_region_find, and this
36
- * is usually under guest control.
74
- * is usually under guest control.
75
+ * This function adds a reference to the owner of a memory region to keep the
76
+ * memory region alive. It does nothing if the owner is not present as a memory
77
+ * region without owner will never die.
78
+ * For references internal to the owner, use object_ref() instead to avoid a
79
+ * circular reference.
37
+ * See docs/devel/memory.rst to know about owner.
80
+ * See docs/devel/memory.rst to know about owner.
38
*
81
*
39
* @mr: the #MemoryRegion
82
* @mr: the #MemoryRegion
40
*/
83
*/
41
@@ -XXX,XX +XXX,XX @@ void memory_region_ref(MemoryRegion *mr);
84
void memory_region_ref(MemoryRegion *mr);
85
42
/**
86
/**
43
* memory_region_unref: Remove a reference to a memory region
87
- * memory_region_unref: Remove 1 to a memory region's reference count
88
+ * memory_region_unref: Remove a reference to the memory region of the owner
44
*
89
*
45
- * Whenever memory regions are accessed outside the BQL, they need to be
90
- * Whenever memory regions are accessed outside the BQL, they need to be
46
- * preserved against hot-unplug. MemoryRegions actually do not have their
91
- * preserved against hot-unplug. MemoryRegions actually do not have their
47
- * own reference count; they piggyback on a QOM object, their "owner".
92
- * own reference count; they piggyback on a QOM object, their "owner".
48
* This function removes a reference to the owner and possibly destroys it.
93
- * This function removes a reference to the owner and possibly destroys it.
94
+ * This function removes a reference to the owner of a memory region and
95
+ * possibly destroys the owner along with the memory region. It does nothing if
96
+ * the owner is not present.
49
+ * See docs/devel/memory.rst to know about owner.
97
+ * See docs/devel/memory.rst to know about owner.
50
*
98
*
51
* @mr: the #MemoryRegion
99
* @mr: the #MemoryRegion
52
*/
100
*/
101
@@ -XXX,XX +XXX,XX @@ void memory_region_unref(MemoryRegion *mr);
102
* if @size is nonzero, subregions will be clipped to @size.
103
*
104
* @mr: the #MemoryRegion to be initialized.
105
- * @owner: the object that tracks the region's reference count
106
+ * @owner: the object that keeps the region alive
107
* @ops: a structure containing read and write callbacks to be used when
108
* I/O is performed on the region.
109
* @opaque: passed to the read and write callbacks of the @ops structure.
110
@@ -XXX,XX +XXX,XX @@ void memory_region_init_io(MemoryRegion *mr,
111
* directly.
112
*
113
* @mr: the #MemoryRegion to be initialized.
114
- * @owner: the object that tracks the region's reference count
115
+ * @owner: the object that keeps the region alive
116
* @name: Region name, becomes part of RAMBlock name used in migration stream
117
* must be unique within any device
118
* @size: size of the region.
119
@@ -XXX,XX +XXX,XX @@ bool memory_region_init_ram_nomigrate(MemoryRegion *mr,
120
* modify memory directly.
121
*
122
* @mr: the #MemoryRegion to be initialized.
123
- * @owner: the object that tracks the region's reference count
124
+ * @owner: the object that keeps the region alive
125
* @name: Region name, becomes part of RAMBlock name used in migration stream
126
* must be unique within any device
127
* @size: size of the region.
128
@@ -XXX,XX +XXX,XX @@ bool memory_region_init_ram_flags_nomigrate(MemoryRegion *mr,
129
* canceled.
130
*
131
* @mr: the #MemoryRegion to be initialized.
132
- * @owner: the object that tracks the region's reference count
133
+ * @owner: the object that keeps the region alive
134
* @name: Region name, becomes part of RAMBlock name used in migration stream
135
* must be unique within any device
136
* @size: used size of the region.
137
@@ -XXX,XX +XXX,XX @@ bool memory_region_init_resizeable_ram(MemoryRegion *mr,
138
* mmap-ed backend.
139
*
140
* @mr: the #MemoryRegion to be initialized.
141
- * @owner: the object that tracks the region's reference count
142
+ * @owner: the object that keeps the region alive
143
* @name: Region name, becomes part of RAMBlock name used in migration stream
144
* must be unique within any device
145
* @size: size of the region.
146
@@ -XXX,XX +XXX,XX @@ bool memory_region_init_ram_from_file(MemoryRegion *mr,
147
* mmap-ed backend.
148
*
149
* @mr: the #MemoryRegion to be initialized.
150
- * @owner: the object that tracks the region's reference count
151
+ * @owner: the object that keeps the region alive
152
* @name: the name of the region.
153
* @size: size of the region.
154
* @ram_flags: RamBlock flags. Supported flags: RAM_SHARED, RAM_PMEM,
155
@@ -XXX,XX +XXX,XX @@ bool memory_region_init_ram_from_fd(MemoryRegion *mr,
156
* region will modify memory directly.
157
*
158
* @mr: the #MemoryRegion to be initialized.
159
- * @owner: the object that tracks the region's reference count
160
+ * @owner: the object that keeps the region alive
161
* @name: Region name, becomes part of RAMBlock name used in migration stream
162
* must be unique within any device
163
* @size: size of the region.
164
@@ -XXX,XX +XXX,XX @@ void memory_region_init_ram_ptr(MemoryRegion *mr,
165
* skip_dump flag.
166
*
167
* @mr: the #MemoryRegion to be initialized.
168
- * @owner: the object that tracks the region's reference count
169
+ * @owner: the object that keeps the region alive
170
* @name: the name of the region.
171
* @size: size of the region.
172
* @ptr: memory to be mapped; must contain at least @size bytes.
173
@@ -XXX,XX +XXX,XX @@ void memory_region_init_ram_device_ptr(MemoryRegion *mr,
174
* part of another memory region.
175
*
176
* @mr: the #MemoryRegion to be initialized.
177
- * @owner: the object that tracks the region's reference count
178
+ * @owner: the object that keeps the region alive
179
* @name: used for debugging; not visible to the user or ABI
180
* @orig: the region to be referenced; @mr will be equivalent to
181
* @orig between @offset and @offset + @size - 1.
182
@@ -XXX,XX +XXX,XX @@ void memory_region_init_alias(MemoryRegion *mr,
183
* of the caller.
184
*
185
* @mr: the #MemoryRegion to be initialized.
186
- * @owner: the object that tracks the region's reference count
187
+ * @owner: the object that keeps the region alive
188
* @name: Region name, becomes part of RAMBlock name used in migration stream
189
* must be unique within any device
190
* @size: size of the region.
191
@@ -XXX,XX +XXX,XX @@ bool memory_region_init_rom_nomigrate(MemoryRegion *mr,
192
* of the caller.
193
*
194
* @mr: the #MemoryRegion to be initialized.
195
- * @owner: the object that tracks the region's reference count
196
+ * @owner: the object that keeps the region alive
197
* @ops: callbacks for write access handling (must not be NULL).
198
* @opaque: passed to the read and write callbacks of the @ops structure.
199
* @name: Region name, becomes part of RAMBlock name used in migration stream
200
@@ -XXX,XX +XXX,XX @@ bool memory_region_init_rom_device_nomigrate(MemoryRegion *mr,
201
* @_iommu_mr: the #IOMMUMemoryRegion to be initialized
202
* @instance_size: the IOMMUMemoryRegion subclass instance size
203
* @mrtypename: the type name of the #IOMMUMemoryRegion
204
- * @owner: the object that tracks the region's reference count
205
+ * @owner: the object that keeps the region alive
206
* @name: used for debugging; not visible to the user or ABI
207
* @size: size of the region.
208
*/
209
@@ -XXX,XX +XXX,XX @@ void memory_region_init_iommu(void *_iommu_mr,
210
* region will modify memory directly.
211
*
212
* @mr: the #MemoryRegion to be initialized
213
- * @owner: the object that tracks the region's reference count (must be
214
+ * @owner: the object that keeps the region alive (must be
215
* TYPE_DEVICE or a subclass of TYPE_DEVICE, or NULL)
216
* @name: name of the memory region
217
* @size: size of the region in bytes
218
@@ -XXX,XX +XXX,XX @@ bool memory_region_init_ram_guest_memfd(MemoryRegion *mr,
219
* If you pass a non-NULL non-device @owner then we will assert.
220
*
221
* @mr: the #MemoryRegion to be initialized.
222
- * @owner: the object that tracks the region's reference count
223
+ * @owner: the object that keeps the region alive
224
* @name: Region name, becomes part of RAMBlock name used in migration stream
225
* must be unique within any device
226
* @size: size of the region.
227
@@ -XXX,XX +XXX,XX @@ bool memory_region_init_rom(MemoryRegion *mr,
228
* If you pass a non-NULL non-device @owner then we will assert.
229
*
230
* @mr: the #MemoryRegion to be initialized.
231
- * @owner: the object that tracks the region's reference count
232
+ * @owner: the object that keeps the region alive
233
* @ops: callbacks for write access handling (must not be NULL).
234
* @opaque: passed to the read and write callbacks of the @ops structure.
235
* @name: Region name, becomes part of RAMBlock name used in migration stream
53
236
54
--
237
--
55
2.46.0
238
2.47.1
diff view generated by jsdifflib
Deleted patch
1
A memory region may not have an owner, and memory_region_ref() and
2
memory_region_unref() do nothing for such.
3
1
4
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
5
---
6
include/exec/memory.h | 6 +++---
7
1 file changed, 3 insertions(+), 3 deletions(-)
8
9
diff --git a/include/exec/memory.h b/include/exec/memory.h
10
index XXXXXXX..XXXXXXX 100644
11
--- a/include/exec/memory.h
12
+++ b/include/exec/memory.h
13
@@ -XXX,XX +XXX,XX @@ void memory_region_init(MemoryRegion *mr,
14
/**
15
* memory_region_ref: Add a reference to a memory region
16
*
17
- * This function adds a reference to the owner.
18
+ * This function adds a reference to the owner if present.
19
* See docs/devel/memory.rst to know about owner.
20
*
21
* @mr: the #MemoryRegion
22
@@ -XXX,XX +XXX,XX @@ void memory_region_ref(MemoryRegion *mr);
23
/**
24
* memory_region_unref: Remove a reference to a memory region
25
*
26
- * This function removes a reference to the owner and possibly destroys it.
27
- * See docs/devel/memory.rst to know about owner.
28
+ * This function removes a reference to the owner and possibly destroys it if
29
+ * present. See docs/devel/memory.rst to know about owner.
30
*
31
* @mr: the #MemoryRegion
32
*/
33
34
--
35
2.46.0
diff view generated by jsdifflib
Deleted patch
1
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
2
---
3
include/exec/memory.h | 1 +
4
1 file changed, 1 insertion(+)
5
1
6
diff --git a/include/exec/memory.h b/include/exec/memory.h
7
index XXXXXXX..XXXXXXX 100644
8
--- a/include/exec/memory.h
9
+++ b/include/exec/memory.h
10
@@ -XXX,XX +XXX,XX @@ void memory_region_init(MemoryRegion *mr,
11
* memory_region_ref: Add a reference to a memory region
12
*
13
* This function adds a reference to the owner if present.
14
+ * The owner must not call this function as it results in a circular reference.
15
* See docs/devel/memory.rst to know about owner.
16
*
17
* @mr: the #MemoryRegion
18
19
--
20
2.46.0
diff view generated by jsdifflib
...
...
11
owner in such a case; the reference to the subregion is still necessary
11
owner in such a case; the reference to the subregion is still necessary
12
to ensure that the subregion gets finalized after the container.
12
to ensure that the subregion gets finalized after the container.
13
13
14
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
14
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
15
---
15
---
16
system/memory.c | 8 ++++++--
16
system/memory.c | 24 ++++++++++++++++++++++--
17
1 file changed, 6 insertions(+), 2 deletions(-)
17
1 file changed, 22 insertions(+), 2 deletions(-)
18
18
19
diff --git a/system/memory.c b/system/memory.c
19
diff --git a/system/memory.c b/system/memory.c
20
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
21
--- a/system/memory.c
21
--- a/system/memory.c
22
+++ b/system/memory.c
22
+++ b/system/memory.c
23
@@ -XXX,XX +XXX,XX @@ void memory_region_unref(MemoryRegion *mr)
24
}
25
}
26
27
+static void memory_region_ref_subregion(MemoryRegion *subregion)
28
+{
29
+ if (subregion->container->owner == subregion->owner) {
30
+ object_ref(OBJECT(subregion));
31
+ } else {
32
+ memory_region_ref(subregion);
33
+ }
34
+}
35
+
36
+static void memory_region_unref_subregion(MemoryRegion *subregion)
37
+{
38
+ if (subregion->container->owner == subregion->owner) {
39
+ object_unref(OBJECT(subregion));
40
+ } else {
41
+ memory_region_unref(subregion);
42
+ }
43
+}
44
+
45
uint64_t memory_region_size(MemoryRegion *mr)
46
{
47
if (int128_eq(mr->size, int128_2_64())) {
23
@@ -XXX,XX +XXX,XX @@ static void memory_region_update_container_subregions(MemoryRegion *subregion)
48
@@ -XXX,XX +XXX,XX @@ static void memory_region_update_container_subregions(MemoryRegion *subregion)
24
49
25
memory_region_transaction_begin();
50
memory_region_transaction_begin();
26
51
27
- memory_region_ref(subregion);
52
- memory_region_ref(subregion);
28
+ object_ref(mr->owner == subregion->owner ?
53
+ memory_region_ref_subregion(subregion);
29
+ OBJECT(subregion) : subregion->owner);
30
+
54
+
31
QTAILQ_FOREACH(other, &mr->subregions, subregions_link) {
55
QTAILQ_FOREACH(other, &mr->subregions, subregions_link) {
32
if (subregion->priority >= other->priority) {
56
if (subregion->priority >= other->priority) {
33
QTAILQ_INSERT_BEFORE(other, subregion, subregions_link);
57
QTAILQ_INSERT_BEFORE(other, subregion, subregions_link);
34
@@ -XXX,XX +XXX,XX @@ void memory_region_del_subregion(MemoryRegion *mr,
58
@@ -XXX,XX +XXX,XX @@ void memory_region_del_subregion(MemoryRegion *mr,
35
assert(alias->mapped_via_alias >= 0);
59
assert(alias->mapped_via_alias >= 0);
36
}
60
}
37
QTAILQ_REMOVE(&mr->subregions, subregion, subregions_link);
61
QTAILQ_REMOVE(&mr->subregions, subregion, subregions_link);
38
- memory_region_unref(subregion);
62
- memory_region_unref(subregion);
39
+ object_unref(mr->owner == subregion->owner ?
63
+ memory_region_unref_subregion(subregion);
40
+ OBJECT(subregion) : subregion->owner);
41
+
64
+
42
memory_region_update_pending |= mr->enabled && subregion->enabled;
65
memory_region_update_pending |= mr->enabled && subregion->enabled;
43
memory_region_transaction_commit();
66
memory_region_transaction_commit();
44
}
67
}
45
68
46
--
69
--
47
2.46.0
70
2.47.1
diff view generated by jsdifflib
Deleted patch
1
A test run may create boot files several times. Delete the previous boot
2
file before creating a new one.
3
1
4
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
5
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
6
Acked-by: Thomas Huth <thuth@redhat.com>
7
---
8
tests/qtest/migration-test.c | 18 +++++++++++-------
9
1 file changed, 11 insertions(+), 7 deletions(-)
10
11
diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
12
index XXXXXXX..XXXXXXX 100644
13
--- a/tests/qtest/migration-test.c
14
+++ b/tests/qtest/migration-test.c
15
@@ -XXX,XX +XXX,XX @@ static char *bootpath;
16
#include "tests/migration/ppc64/a-b-kernel.h"
17
#include "tests/migration/s390x/a-b-bios.h"
18
19
+static void bootfile_delete(void)
20
+{
21
+ unlink(bootpath);
22
+ g_free(bootpath);
23
+ bootpath = NULL;
24
+}
25
+
26
static void bootfile_create(char *dir, bool suspend_me)
27
{
28
const char *arch = qtest_get_arch();
29
unsigned char *content;
30
size_t len;
31
32
+ if (bootpath) {
33
+ bootfile_delete();
34
+ }
35
+
36
bootpath = g_strdup_printf("%s/bootsect", dir);
37
if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
38
/* the assembled x86 boot sector should be exactly one sector large */
39
@@ -XXX,XX +XXX,XX @@ static void bootfile_create(char *dir, bool suspend_me)
40
fclose(bootfile);
41
}
42
43
-static void bootfile_delete(void)
44
-{
45
- unlink(bootpath);
46
- g_free(bootpath);
47
- bootpath = NULL;
48
-}
49
-
50
/*
51
* Wait for some output in the serial output file,
52
* we get an 'A' followed by an endless string of 'B's
53
54
--
55
2.46.0
diff view generated by jsdifflib