qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vl.c/memdev: Error on bad memory backend
@ 2020-03-17 12:07 Dr. David Alan Gilbert (git)
  2020-03-17 12:34 ` Igor Mammedov
  0 siblings, 1 reply; 3+ messages in thread
From: Dr. David Alan Gilbert (git) @ 2020-03-17 12:07 UTC (permalink / raw)
  To: qemu-devel, imammedo, pbonzini

From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

If memory-backend is a non-existent object, qemu crashes.
Check that the backend actually resolves.

e.g.   ./qemu-system-x86_64 -machine pc,accel=kvm,memory-backend=foo

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 softmmu/vl.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/softmmu/vl.c b/softmmu/vl.c
index ff2685dff8..76507e99c4 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -4288,6 +4288,11 @@ void qemu_init(int argc, char **argv, char **envp)
 
         backend = object_resolve_path_type(current_machine->ram_memdev_id,
                                            TYPE_MEMORY_BACKEND, NULL);
+        if (!backend) {
+            error_report("Unknown memory backend object id '%s'",
+                         current_machine->ram_memdev_id);
+            exit(EXIT_FAILURE);
+        }
         backend_size = object_property_get_uint(backend, "size",  &error_abort);
         if (have_custom_ram_size && backend_size != ram_size) {
                 error_report("Size specified by -m option must match size of "
-- 
2.24.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-17 12:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-17 12:07 [PATCH] vl.c/memdev: Error on bad memory backend Dr. David Alan Gilbert (git)
2020-03-17 12:34 ` Igor Mammedov
2020-03-17 12:55   ` Dr. David Alan Gilbert

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).