qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

qobject: let object_property_get_str() use new API

We can simplify object_property_get_str() using the new
qobject_get_try_str().

Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <20180309090006.10018-5-peterx@redhat.com>
[eblake: rebase context of qobject_to() macro]
Signed-off-by: Eric Blake <eblake@redhat.com>

authored by

Peter Xu and committed by
Eric Blake
aafb21a0 b26ae1cb

+3 -6
+3 -6
qom/object.c
··· 1136 1136 Error **errp) 1137 1137 { 1138 1138 QObject *ret = object_property_get_qobject(obj, name, errp); 1139 - QString *qstring; 1140 1139 char *retval; 1141 1140 1142 1141 if (!ret) { 1143 1142 return NULL; 1144 1143 } 1145 - qstring = qobject_to(QString, ret); 1146 - if (!qstring) { 1144 + 1145 + retval = g_strdup(qobject_get_try_str(ret)); 1146 + if (!retval) { 1147 1147 error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "string"); 1148 - retval = NULL; 1149 - } else { 1150 - retval = g_strdup(qstring_get_str(qstring)); 1151 1148 } 1152 1149 1153 1150 qobject_decref(ret);