From: Luiz Capitulino <lcapitulino@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: pbonzini@redhat.com, lma@suse.com, qemu-devel@nongnu.org,
afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH] fix assertion in "info memory-devices" if memdev isn't accessible
Date: Thu, 26 Mar 2015 15:59:25 -0400 [thread overview]
Message-ID: <20150326155925.50ce214a@redhat.com> (raw)
In-Reply-To: <1427388174-30915-1-git-send-email-imammedo@redhat.com>
On Thu, 26 Mar 2015 16:42:54 +0000
Igor Mammedov <imammedo@redhat.com> wrote:
> showing a memory device whose memdev is removed leads to 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
>
> so check if memdev is present before calling
> object_get_canonical_path() and in case it's not assign to
> "memdev:" field "removed" value.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Igor, do you want to go in through my tree?
> ---
> alternative more generic solution:
> http://patchwork.ozlabs.org/patch/453343/
> ---
> backends/hostmem.c | 23 +++++++++++++++++++++++
> hw/mem/pc-dimm.c | 15 ++++++++++++++-
> include/sysemu/hostmem.h | 1 +
> qmp.c | 1 +
> 4 files changed, 39 insertions(+), 1 deletion(-)
>
> diff --git a/backends/hostmem.c b/backends/hostmem.c
> index 99e8f99..aa88691 100644
> --- a/backends/hostmem.c
> +++ b/backends/hostmem.c
> @@ -227,6 +227,26 @@ static void host_memory_backend_set_prealloc(Object *obj, bool value,
> }
> }
>
> +static void host_memory_backend_set_id(Object *obj, const char *id,
> + Error **errp)
> +{
> + HostMemoryBackend *backend = MEMORY_BACKEND(obj);
> +
> + if (backend->id) {
> + error_set(errp, QERR_INVALID_PARAMETER_VALUE, "id",
> + "can't change already set value");
> + return;
> + }
> + backend->id = g_strdup(id);
> +}
> +
> +static char *host_memory_backend_get_id(Object *obj, Error **errp)
> +{
> + HostMemoryBackend *backend = MEMORY_BACKEND(obj);
> +
> + return g_strdup(backend->id);
> +}
> +
> static void host_memory_backend_init(Object *obj)
> {
> HostMemoryBackend *backend = MEMORY_BACKEND(obj);
> @@ -237,6 +257,9 @@ static void host_memory_backend_init(Object *obj)
> "dump-guest-core", true);
> backend->prealloc = mem_prealloc;
>
> + object_property_add_str(obj, "id",
> + host_memory_backend_get_id,
> + host_memory_backend_set_id, NULL);
> object_property_add_bool(obj, "merge",
> host_memory_backend_get_merge,
> host_memory_backend_set_merge, NULL);
> diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c
> index 39f0c97..482a7a0 100644
> --- a/hw/mem/pc-dimm.c
> +++ b/hw/mem/pc-dimm.c
> @@ -69,6 +69,8 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque)
> DeviceState *dev = DEVICE(obj);
>
> if (dev->realized) {
> + char *mdevid, *mdevpath;
> + Object *mdev;
> MemoryDeviceInfoList *elem = g_new0(MemoryDeviceInfoList, 1);
> MemoryDeviceInfo *info = g_new0(MemoryDeviceInfo, 1);
> PCDIMMDeviceInfo *di = g_new0(PCDIMMDeviceInfo, 1);
> @@ -86,7 +88,18 @@ int qmp_pc_dimm_device_list(Object *obj, void *opaque)
> di->node = dimm->node;
> di->size = object_property_get_int(OBJECT(dimm), PC_DIMM_SIZE_PROP,
> NULL);
> - di->memdev = object_get_canonical_path(OBJECT(dimm->hostmem));
> + mdevid = object_property_get_str(OBJECT(dimm->hostmem), "id",
> + &error_abort);
> + mdevpath = g_strdup_printf("/objects/%s", mdevid);
> + g_free(mdevid);
> + mdev = object_resolve_path_type(mdevpath, TYPE_MEMORY_BACKEND,
> + NULL);
> + if (mdev == OBJECT(dimm->hostmem)) {
> + di->memdev = object_get_canonical_path(OBJECT(dimm->hostmem));
> + } else {
> + di->memdev = g_strdup("removed");
> + }
> + g_free(mdevpath);
>
> info->dimm = di;
> elem->value = info;
> diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h
> index 1ce4394..63918aa 100644
> --- a/include/sysemu/hostmem.h
> +++ b/include/sysemu/hostmem.h
> @@ -53,6 +53,7 @@ struct HostMemoryBackend {
> Object parent;
>
> /* protected */
> + char *id;
> uint64_t size;
> bool merge, dump;
> bool prealloc, force_prealloc;
> diff --git a/qmp.c b/qmp.c
> index c479e77..6f1cca7 100644
> --- a/qmp.c
> +++ b/qmp.c
> @@ -649,6 +649,7 @@ void object_add(const char *type, const char *id, const QDict *qdict,
> }
> }
> }
> + object_property_set_str(obj, id, "id", NULL);
>
> object_property_add_child(container_get(object_get_root(), "/objects"),
> id, obj, &local_err);
next prev parent reply other threads:[~2015-03-26 19:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-26 16:42 [Qemu-devel] [PATCH] fix assertion in "info memory-devices" if memdev isn't accessible Igor Mammedov
2015-03-26 19:59 ` Luiz Capitulino [this message]
2015-03-26 20:26 ` Luiz Capitulino
2015-03-27 14:20 ` Igor Mammedov
2015-03-26 20:33 ` Paolo Bonzini
2015-03-27 14:18 ` Igor Mammedov
2015-03-27 14:24 ` Igor Mammedov
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=20150326155925.50ce214a@redhat.com \
--to=lcapitulino@redhat.com \
--cc=afaerber@suse.de \
--cc=imammedo@redhat.com \
--cc=lma@suse.com \
--cc=pbonzini@redhat.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).