29.03.2022 00:15, Maxim Davydov wrote:
Attempt to get address after initialization shouldn't fail on assert in
the qapi automatically generated code. As a possible solution, it can
return null type.

But at some point this address appears? May be we try to query it too early, or 
we need some more initialization steps?

Isn't it better to report failure, when we try to query things that are not yet 
initialized?


Signed-off-by: Maxim Davydov <maxim.davy...@openvz.org>
---
  chardev/char-socket.c | 9 +++++++++
  1 file changed, 9 insertions(+)

diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index fab2d791d4..f851e3346b 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -33,6 +33,7 @@
  #include "qapi/clone-visitor.h"
  #include "qapi/qapi-visit-sockets.h"
  #include "qemu/yank.h"
+#include "qapi/qmp/qnull.h"
#include "chardev/char-io.h"
  #include "chardev/char-socket.h"
@@ -1509,6 +1510,14 @@ char_socket_get_addr(Object *obj, Visitor *v, const char 
*name,
  {
      SocketChardev *s = SOCKET_CHARDEV(obj);
+ QNull *null = NULL;
+
+    /* Return NULL type if getting addr was called after init */
+    if (!s->addr) {
+        visit_type_null(v, NULL, &null, errp);
+        return;
+    }
+
      visit_type_SocketAddress(v, name, &s->addr, errp);
  }


--
Best regards,
Vladimir

Reply via email to