From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Lin Ma <lma@suse.com>
Subject: [Qemu-devel] [PULL 2/5] hostmem: Prevent removing an in-use memory backend
Date: Wed, 1 Apr 2015 12:29:34 +0200 [thread overview]
Message-ID: <1427884177-4928-3-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1427884177-4928-1-git-send-email-pbonzini@redhat.com>
From: Lin Ma <lma@suse.com>
showing a memory device whose memdev is removed leads an assert:
(qemu) object_add memory-backend-ram,id=ram0,size=128M
(qemu) device_add pc-dimm,id=d0,memdev=ram0
(qemu) object_del ram0
(qemu) info memory-devices
**
ERROR:qom/object.c:1274:object_get_canonical_path_component:\
assertion failed: (obj->parent != NULL)
Aborted
The patch prevents removing an in-use mem backend and error out.
Signed-off-by: Lin Ma <lma@suse.com>
Message-Id: <1427704589-7688-3-git-send-email-lma@suse.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
backends/hostmem.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/backends/hostmem.c b/backends/hostmem.c
index 99e8f99..b7b6cf8 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -335,12 +335,26 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp)
}
}
+static bool
+host_memory_backend_can_be_deleted(UserCreatable *uc, Error **errp)
+{
+ MemoryRegion *mr;
+
+ mr = host_memory_backend_get_memory(MEMORY_BACKEND(uc), errp);
+ if (memory_region_is_mapped(mr)) {
+ return false;
+ } else {
+ return true;
+ }
+}
+
static void
host_memory_backend_class_init(ObjectClass *oc, void *data)
{
UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
ucc->complete = host_memory_backend_memory_complete;
+ ucc->can_be_deleted = host_memory_backend_can_be_deleted;
}
static const TypeInfo host_memory_backend_info = {
--
2.3.4
next prev parent reply other threads:[~2015-04-01 10:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-01 10:29 [Qemu-devel] [PULL 0/5] Bugfixes for 2.3.0-rc2 Paolo Bonzini
2015-04-01 10:29 ` [Qemu-devel] [PULL 1/5] qom: Add can_be_deleted callback to UserCreatableClass Paolo Bonzini
2015-04-01 10:29 ` Paolo Bonzini [this message]
2015-04-01 10:29 ` [Qemu-devel] [PULL 3/5] pc: acpi: fix pvpanic regression Paolo Bonzini
2015-04-01 10:29 ` [Qemu-devel] [PULL 4/5] rcu: do not create thread in pthread_atfork callback Paolo Bonzini
2015-04-01 10:29 ` [Qemu-devel] [PULL 5/5] Revert "exec: Respect as_tranlsate_internal length clamp" Paolo Bonzini
2015-04-01 12:27 ` Eric Blake
2015-04-01 12:31 ` Peter Maydell
2015-04-01 13:18 ` Paolo Bonzini
2015-04-01 12:21 ` [Qemu-devel] [PULL 0/5] Bugfixes for 2.3.0-rc2 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1427884177-4928-3-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=lma@suse.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).