mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-27 13:30:52 +00:00
Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging
* remotes/qmp-unstable/queue/qmp: Add HMP command "info memory-devices" qemu-socket: Eliminate silly QERR_ macros qemu-socket: Polish errors for connect() and listen() failure qemu-iotests: Test missing "driver" key for blockdev-add tests: add QMP input visitor test for unions with no discriminator qapi: dealloc visitor, implement visit_start_union qapi: add visit_start_union and visit_end_union virtio-balloon: fix integer overflow in memory stats feature monitor: Reset HMP mon->rs in CHR_EVENT_OPEN Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
b60a7726cc
@ -1778,6 +1778,8 @@ show qdev device model list
|
||||
show roms
|
||||
@item info tpm
|
||||
show the TPM device
|
||||
@item info memory-devices
|
||||
show the memory devices
|
||||
@end table
|
||||
ETEXI
|
||||
|
||||
|
38
hmp.c
38
hmp.c
@ -1720,3 +1720,41 @@ void hmp_info_memdev(Monitor *mon, const QDict *qdict)
|
||||
|
||||
qapi_free_MemdevList(memdev_list);
|
||||
}
|
||||
|
||||
void hmp_info_memory_devices(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
Error *err = NULL;
|
||||
MemoryDeviceInfoList *info_list = qmp_query_memory_devices(&err);
|
||||
MemoryDeviceInfoList *info;
|
||||
MemoryDeviceInfo *value;
|
||||
PCDIMMDeviceInfo *di;
|
||||
|
||||
for (info = info_list; info; info = info->next) {
|
||||
value = info->value;
|
||||
|
||||
if (value) {
|
||||
switch (value->kind) {
|
||||
case MEMORY_DEVICE_INFO_KIND_DIMM:
|
||||
di = value->dimm;
|
||||
|
||||
monitor_printf(mon, "Memory device [%s]: \"%s\"\n",
|
||||
MemoryDeviceInfoKind_lookup[value->kind],
|
||||
di->id ? di->id : "");
|
||||
monitor_printf(mon, " addr: 0x%" PRIx64 "\n", di->addr);
|
||||
monitor_printf(mon, " slot: %" PRId64 "\n", di->slot);
|
||||
monitor_printf(mon, " node: %" PRId64 "\n", di->node);
|
||||
monitor_printf(mon, " size: %" PRIu64 "\n", di->size);
|
||||
monitor_printf(mon, " memdev: %s\n", di->memdev);
|
||||
monitor_printf(mon, " hotplugged: %s\n",
|
||||
di->hotplugged ? "true" : "false");
|
||||
monitor_printf(mon, " hotpluggable: %s\n",
|
||||
di->hotpluggable ? "true" : "false");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qapi_free_MemoryDeviceInfoList(info_list);
|
||||
}
|
||||
|
1
hmp.h
1
hmp.h
@ -94,6 +94,7 @@ void hmp_cpu_add(Monitor *mon, const QDict *qdict);
|
||||
void hmp_object_add(Monitor *mon, const QDict *qdict);
|
||||
void hmp_object_del(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_memdev(Monitor *mon, const QDict *qdict);
|
||||
void hmp_info_memory_devices(Monitor *mon, const QDict *qdict);
|
||||
void object_add_completion(ReadLineState *rs, int nb_args, const char *str);
|
||||
void object_del_completion(ReadLineState *rs, int nb_args, const char *str);
|
||||
void device_add_completion(ReadLineState *rs, int nb_args, const char *str);
|
||||
|
@ -87,7 +87,7 @@ static void balloon_stats_destroy_timer(VirtIOBalloon *s)
|
||||
}
|
||||
}
|
||||
|
||||
static void balloon_stats_change_timer(VirtIOBalloon *s, int secs)
|
||||
static void balloon_stats_change_timer(VirtIOBalloon *s, int64_t secs)
|
||||
{
|
||||
timer_mod(s->stats_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + secs * 1000);
|
||||
}
|
||||
@ -170,6 +170,11 @@ static void balloon_stats_set_poll_interval(Object *obj, struct Visitor *v,
|
||||
return;
|
||||
}
|
||||
|
||||
if (value > UINT_MAX) {
|
||||
error_setg(errp, "timer value is too big");
|
||||
return;
|
||||
}
|
||||
|
||||
if (value == s->stats_poll_interval) {
|
||||
return;
|
||||
}
|
||||
|
@ -154,16 +154,4 @@ void qerror_report_err(Error *err);
|
||||
#define QERR_UNSUPPORTED \
|
||||
ERROR_CLASS_GENERIC_ERROR, "this feature or command is not currently supported"
|
||||
|
||||
#define QERR_SOCKET_CONNECT_FAILED \
|
||||
ERROR_CLASS_GENERIC_ERROR, "Failed to connect to socket"
|
||||
|
||||
#define QERR_SOCKET_LISTEN_FAILED \
|
||||
ERROR_CLASS_GENERIC_ERROR, "Failed to set socket to listening mode"
|
||||
|
||||
#define QERR_SOCKET_BIND_FAILED \
|
||||
ERROR_CLASS_GENERIC_ERROR, "Failed to bind socket"
|
||||
|
||||
#define QERR_SOCKET_CREATE_FAILED \
|
||||
ERROR_CLASS_GENERIC_ERROR, "Failed to create socket"
|
||||
|
||||
#endif /* QERROR_H */
|
||||
|
@ -55,6 +55,8 @@ struct Visitor
|
||||
void (*type_int64)(Visitor *v, int64_t *obj, const char *name, Error **errp);
|
||||
/* visit_type_size() falls back to (*type_uint64)() if type_size is unset */
|
||||
void (*type_size)(Visitor *v, uint64_t *obj, const char *name, Error **errp);
|
||||
bool (*start_union)(Visitor *v, bool data_present, Error **errp);
|
||||
void (*end_union)(Visitor *v, bool data_present, Error **errp);
|
||||
};
|
||||
|
||||
void input_type_enum(Visitor *v, int *obj, const char *strings[],
|
||||
|
@ -58,5 +58,7 @@ void visit_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp);
|
||||
void visit_type_bool(Visitor *v, bool *obj, const char *name, Error **errp);
|
||||
void visit_type_str(Visitor *v, char **obj, const char *name, Error **errp);
|
||||
void visit_type_number(Visitor *v, double *obj, const char *name, Error **errp);
|
||||
bool visit_start_union(Visitor *v, bool data_present, Error **errp);
|
||||
void visit_end_union(Visitor *v, bool data_present, Error **errp);
|
||||
|
||||
#endif
|
||||
|
@ -2921,6 +2921,13 @@ static mon_cmd_t info_cmds[] = {
|
||||
.help = "show memory backends",
|
||||
.mhandler.cmd = hmp_info_memdev,
|
||||
},
|
||||
{
|
||||
.name = "memory-devices",
|
||||
.args_type = "",
|
||||
.params = "",
|
||||
.help = "show memory devices",
|
||||
.mhandler.cmd = hmp_info_memory_devices,
|
||||
},
|
||||
{
|
||||
.name = NULL,
|
||||
},
|
||||
@ -5249,6 +5256,7 @@ static void monitor_event(void *opaque, int event)
|
||||
monitor_printf(mon, "QEMU %s monitor - type 'help' for more "
|
||||
"information\n", QEMU_VERSION);
|
||||
if (!mon->mux_out) {
|
||||
readline_restart(mon->rs);
|
||||
readline_show_prompt(mon->rs);
|
||||
}
|
||||
mon->reset_seen = 1;
|
||||
|
@ -162,6 +162,31 @@ static void qapi_dealloc_type_enum(Visitor *v, int *obj, const char *strings[],
|
||||
{
|
||||
}
|
||||
|
||||
/* If there's no data present, the dealloc visitor has nothing to free.
|
||||
* Thus, indicate to visitor code that the subsequent union fields can
|
||||
* be skipped. This is not an error condition, since the cleanup of the
|
||||
* rest of an object can continue unhindered, so leave errp unset in
|
||||
* these cases.
|
||||
*
|
||||
* NOTE: In cases where we're attempting to deallocate an object that
|
||||
* may have missing fields, the field indicating the union type may
|
||||
* be missing. In such a case, it's possible we don't have enough
|
||||
* information to differentiate data_present == false from a case where
|
||||
* data *is* present but happens to be a scalar with a value of 0.
|
||||
* This is okay, since in the case of the dealloc visitor there's no
|
||||
* work that needs to done in either situation.
|
||||
*
|
||||
* The current inability in QAPI code to more thoroughly verify a union
|
||||
* type in such cases will likely need to be addressed if we wish to
|
||||
* implement this interface for other types of visitors in the future,
|
||||
* however.
|
||||
*/
|
||||
static bool qapi_dealloc_start_union(Visitor *v, bool data_present,
|
||||
Error **errp)
|
||||
{
|
||||
return data_present;
|
||||
}
|
||||
|
||||
Visitor *qapi_dealloc_get_visitor(QapiDeallocVisitor *v)
|
||||
{
|
||||
return &v->visitor;
|
||||
@ -191,6 +216,7 @@ QapiDeallocVisitor *qapi_dealloc_visitor_new(void)
|
||||
v->visitor.type_str = qapi_dealloc_type_str;
|
||||
v->visitor.type_number = qapi_dealloc_type_number;
|
||||
v->visitor.type_size = qapi_dealloc_type_size;
|
||||
v->visitor.start_union = qapi_dealloc_start_union;
|
||||
|
||||
QTAILQ_INIT(&v->stack);
|
||||
|
||||
|
@ -58,6 +58,21 @@ void visit_end_list(Visitor *v, Error **errp)
|
||||
v->end_list(v, errp);
|
||||
}
|
||||
|
||||
bool visit_start_union(Visitor *v, bool data_present, Error **errp)
|
||||
{
|
||||
if (v->start_union) {
|
||||
return v->start_union(v, data_present, errp);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void visit_end_union(Visitor *v, bool data_present, Error **errp)
|
||||
{
|
||||
if (v->end_union) {
|
||||
v->end_union(v, data_present, errp);
|
||||
}
|
||||
}
|
||||
|
||||
void visit_optional(Visitor *v, bool *present, const char *name,
|
||||
Error **errp)
|
||||
{
|
||||
|
@ -358,6 +358,9 @@ void visit_type_%(name)s(Visitor *m, %(name)s **obj, const char *name, Error **e
|
||||
if (err) {
|
||||
goto out_obj;
|
||||
}
|
||||
if (!visit_start_union(m, !!(*obj)->data, &err) || err) {
|
||||
goto out_obj;
|
||||
}
|
||||
switch ((*obj)->kind) {
|
||||
''',
|
||||
disc_type = disc_type,
|
||||
@ -386,6 +389,9 @@ void visit_type_%(name)s(Visitor *m, %(name)s **obj, const char *name, Error **e
|
||||
out_obj:
|
||||
error_propagate(errp, err);
|
||||
err = NULL;
|
||||
visit_end_union(m, !!(*obj)->data, &err);
|
||||
error_propagate(errp, err);
|
||||
err = NULL;
|
||||
}
|
||||
visit_end_struct(m, &err);
|
||||
out:
|
||||
|
@ -33,6 +33,9 @@
|
||||
{ 'type': 'UserDefB',
|
||||
'data': { 'integer': 'int' } }
|
||||
|
||||
{ 'type': 'UserDefC',
|
||||
'data': { 'string1': 'str', 'string2': 'str' } }
|
||||
|
||||
{ 'union': 'UserDefUnion',
|
||||
'base': 'UserDefZero',
|
||||
'data': { 'a' : 'UserDefA', 'b' : 'UserDefB' } }
|
||||
@ -47,6 +50,13 @@
|
||||
# FIXME generated struct UserDefFlatUnion has members for direct base
|
||||
# UserDefOne, but lacks members for indirect base UserDefZero
|
||||
|
||||
# this variant of UserDefFlatUnion defaults to a union that uses fields with
|
||||
# allocated types to test corner cases in the cleanup/dealloc visitor
|
||||
{ 'union': 'UserDefFlatUnion2',
|
||||
'base': 'UserDefUnionBase',
|
||||
'discriminator': 'enum1',
|
||||
'data': { 'value1' : 'UserDefC', 'value2' : 'UserDefB', 'value3' : 'UserDefA' } }
|
||||
|
||||
{ 'union': 'UserDefAnonUnion',
|
||||
'discriminator': {},
|
||||
'data': { 'uda': 'UserDefA', 's': 'str', 'i': 'int' } }
|
||||
|
@ -6,9 +6,11 @@
|
||||
OrderedDict([('type', 'UserDefNested'), ('data', OrderedDict([('string0', 'str'), ('dict1', OrderedDict([('string1', 'str'), ('dict2', OrderedDict([('userdef1', 'UserDefOne'), ('string2', 'str')])), ('*dict3', OrderedDict([('userdef2', 'UserDefOne'), ('string3', 'str')]))]))]))]),
|
||||
OrderedDict([('type', 'UserDefA'), ('data', OrderedDict([('boolean', 'bool')]))]),
|
||||
OrderedDict([('type', 'UserDefB'), ('data', OrderedDict([('integer', 'int')]))]),
|
||||
OrderedDict([('type', 'UserDefC'), ('data', OrderedDict([('string1', 'str'), ('string2', 'str')]))]),
|
||||
OrderedDict([('union', 'UserDefUnion'), ('base', 'UserDefZero'), ('data', OrderedDict([('a', 'UserDefA'), ('b', 'UserDefB')]))]),
|
||||
OrderedDict([('type', 'UserDefUnionBase'), ('data', OrderedDict([('string', 'str'), ('enum1', 'EnumOne')]))]),
|
||||
OrderedDict([('union', 'UserDefFlatUnion'), ('base', 'UserDefUnionBase'), ('discriminator', 'enum1'), ('data', OrderedDict([('value1', 'UserDefA'), ('value2', 'UserDefB'), ('value3', 'UserDefB')]))]),
|
||||
OrderedDict([('union', 'UserDefFlatUnion2'), ('base', 'UserDefUnionBase'), ('discriminator', 'enum1'), ('data', OrderedDict([('value1', 'UserDefC'), ('value2', 'UserDefB'), ('value3', 'UserDefA')]))]),
|
||||
OrderedDict([('union', 'UserDefAnonUnion'), ('discriminator', OrderedDict()), ('data', OrderedDict([('uda', 'UserDefA'), ('s', 'str'), ('i', 'int')]))]),
|
||||
OrderedDict([('union', 'UserDefNativeListUnion'), ('data', OrderedDict([('integer', ['int']), ('s8', ['int8']), ('s16', ['int16']), ('s32', ['int32']), ('s64', ['int64']), ('u8', ['uint8']), ('u16', ['uint16']), ('u32', ['uint32']), ('u64', ['uint64']), ('number', ['number']), ('boolean', ['bool']), ('string', ['str'])]))]),
|
||||
OrderedDict([('command', 'user_def_cmd'), ('data', OrderedDict())]),
|
||||
@ -32,6 +34,7 @@
|
||||
OrderedDict([('type', 'UserDefNested'), ('data', OrderedDict([('string0', 'str'), ('dict1', OrderedDict([('string1', 'str'), ('dict2', OrderedDict([('userdef1', 'UserDefOne'), ('string2', 'str')])), ('*dict3', OrderedDict([('userdef2', 'UserDefOne'), ('string3', 'str')]))]))]))]),
|
||||
OrderedDict([('type', 'UserDefA'), ('data', OrderedDict([('boolean', 'bool')]))]),
|
||||
OrderedDict([('type', 'UserDefB'), ('data', OrderedDict([('integer', 'int')]))]),
|
||||
OrderedDict([('type', 'UserDefC'), ('data', OrderedDict([('string1', 'str'), ('string2', 'str')]))]),
|
||||
OrderedDict([('type', 'UserDefUnionBase'), ('data', OrderedDict([('string', 'str'), ('enum1', 'EnumOne')]))]),
|
||||
OrderedDict([('type', 'UserDefOptions'), ('data', OrderedDict([('*i64', ['int']), ('*u64', ['uint64']), ('*u16', ['uint16']), ('*i64x', 'int'), ('*u64x', 'uint64')]))]),
|
||||
OrderedDict([('type', 'EventStructOne'), ('data', OrderedDict([('struct1', 'UserDefOne'), ('string', 'str'), ('*enum2', 'EnumOne')]))])]
|
||||
|
@ -218,6 +218,23 @@ run_qemu <<EOF
|
||||
{ "execute": "quit" }
|
||||
EOF
|
||||
|
||||
echo
|
||||
echo === Missing driver ===
|
||||
echo
|
||||
|
||||
_make_test_img -o encryption=on $size
|
||||
run_qemu -S <<EOF
|
||||
{ "execute": "qmp_capabilities" }
|
||||
{ "execute": "blockdev-add",
|
||||
"arguments": {
|
||||
"options": {
|
||||
"id": "disk"
|
||||
}
|
||||
}
|
||||
}
|
||||
{ "execute": "quit" }
|
||||
EOF
|
||||
|
||||
# success, all done
|
||||
echo "*** done"
|
||||
rm -f $seq.full
|
||||
|
@ -64,4 +64,17 @@ QMP_VERSION
|
||||
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}}
|
||||
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "floppy0", "tray-open": true}}
|
||||
|
||||
|
||||
=== Missing driver ===
|
||||
|
||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 encryption=on
|
||||
Testing: -S
|
||||
QMP_VERSION
|
||||
{"return": {}}
|
||||
{"error": {"class": "GenericError", "desc": "Invalid parameter type for 'driver', expected: string"}}
|
||||
{"return": {}}
|
||||
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"}
|
||||
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "ide1-cd0", "tray-open": true}}
|
||||
{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "DEVICE_TRAY_MOVED", "data": {"device": "floppy0", "tray-open": true}}
|
||||
|
||||
*** done
|
||||
|
@ -260,6 +260,21 @@ static void test_validate_fail_union_flat(TestInputVisitorData *data,
|
||||
qapi_free_UserDefFlatUnion(tmp);
|
||||
}
|
||||
|
||||
static void test_validate_fail_union_flat_no_discrim(TestInputVisitorData *data,
|
||||
const void *unused)
|
||||
{
|
||||
UserDefFlatUnion2 *tmp = NULL;
|
||||
Error *err = NULL;
|
||||
Visitor *v;
|
||||
|
||||
/* test situation where discriminator field ('enum1' here) is missing */
|
||||
v = validate_test_init(data, "{ 'string': 'c', 'string1': 'd', 'string2': 'e' }");
|
||||
|
||||
visit_type_UserDefFlatUnion2(v, &tmp, NULL, &err);
|
||||
g_assert(err);
|
||||
qapi_free_UserDefFlatUnion2(tmp);
|
||||
}
|
||||
|
||||
static void test_validate_fail_union_anon(TestInputVisitorData *data,
|
||||
const void *unused)
|
||||
{
|
||||
@ -310,6 +325,8 @@ int main(int argc, char **argv)
|
||||
&testdata, test_validate_fail_union);
|
||||
validate_test_add("/visitor/input-strict/fail/union-flat",
|
||||
&testdata, test_validate_fail_union_flat);
|
||||
validate_test_add("/visitor/input-strict/fail/union-flat-no-discriminator",
|
||||
&testdata, test_validate_fail_union_flat_no_discrim);
|
||||
validate_test_add("/visitor/input-strict/fail/union-anon",
|
||||
&testdata, test_validate_fail_union_anon);
|
||||
|
||||
|
@ -159,7 +159,7 @@ int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp)
|
||||
slisten = qemu_socket(e->ai_family, e->ai_socktype, e->ai_protocol);
|
||||
if (slisten < 0) {
|
||||
if (!e->ai_next) {
|
||||
error_set_errno(errp, errno, QERR_SOCKET_CREATE_FAILED);
|
||||
error_setg_errno(errp, errno, "Failed to create socket");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -183,7 +183,7 @@ int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp)
|
||||
}
|
||||
if (p == port_max) {
|
||||
if (!e->ai_next) {
|
||||
error_set_errno(errp, errno, QERR_SOCKET_BIND_FAILED);
|
||||
error_setg_errno(errp, errno, "Failed to bind socket");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -194,7 +194,7 @@ int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp)
|
||||
|
||||
listen:
|
||||
if (listen(slisten,1) != 0) {
|
||||
error_set_errno(errp, errno, QERR_SOCKET_LISTEN_FAILED);
|
||||
error_setg_errno(errp, errno, "Failed to listen on socket");
|
||||
closesocket(slisten);
|
||||
freeaddrinfo(res);
|
||||
return -1;
|
||||
@ -281,7 +281,7 @@ static int inet_connect_addr(struct addrinfo *addr, bool *in_progress,
|
||||
|
||||
sock = qemu_socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol);
|
||||
if (sock < 0) {
|
||||
error_set_errno(errp, errno, QERR_SOCKET_CREATE_FAILED);
|
||||
error_setg_errno(errp, errno, "Failed to create socket");
|
||||
return -1;
|
||||
}
|
||||
socket_set_fast_reuse(sock);
|
||||
@ -302,7 +302,7 @@ static int inet_connect_addr(struct addrinfo *addr, bool *in_progress,
|
||||
connect_state);
|
||||
*in_progress = true;
|
||||
} else if (rc < 0) {
|
||||
error_set_errno(errp, errno, QERR_SOCKET_CONNECT_FAILED);
|
||||
error_setg_errno(errp, errno, "Failed to connect socket");
|
||||
closesocket(sock);
|
||||
return -1;
|
||||
}
|
||||
@ -466,20 +466,20 @@ int inet_dgram_opts(QemuOpts *opts, Error **errp)
|
||||
/* create socket */
|
||||
sock = qemu_socket(peer->ai_family, peer->ai_socktype, peer->ai_protocol);
|
||||
if (sock < 0) {
|
||||
error_set_errno(errp, errno, QERR_SOCKET_CREATE_FAILED);
|
||||
error_setg_errno(errp, errno, "Failed to create socket");
|
||||
goto err;
|
||||
}
|
||||
socket_set_fast_reuse(sock);
|
||||
|
||||
/* bind socket */
|
||||
if (bind(sock, local->ai_addr, local->ai_addrlen) < 0) {
|
||||
error_set_errno(errp, errno, QERR_SOCKET_BIND_FAILED);
|
||||
error_setg_errno(errp, errno, "Failed to bind socket");
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* connect to peer */
|
||||
if (connect(sock,peer->ai_addr,peer->ai_addrlen) < 0) {
|
||||
error_set_errno(errp, errno, QERR_SOCKET_CONNECT_FAILED);
|
||||
error_setg_errno(errp, errno, "Failed to connect socket");
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -684,7 +684,7 @@ int unix_listen_opts(QemuOpts *opts, Error **errp)
|
||||
|
||||
sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0);
|
||||
if (sock < 0) {
|
||||
error_set_errno(errp, errno, QERR_SOCKET_CREATE_FAILED);
|
||||
error_setg_errno(errp, errno, "Failed to create socket");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -709,11 +709,11 @@ int unix_listen_opts(QemuOpts *opts, Error **errp)
|
||||
|
||||
unlink(un.sun_path);
|
||||
if (bind(sock, (struct sockaddr*) &un, sizeof(un)) < 0) {
|
||||
error_set_errno(errp, errno, QERR_SOCKET_BIND_FAILED);
|
||||
error_setg_errno(errp, errno, "Failed to bind socket");
|
||||
goto err;
|
||||
}
|
||||
if (listen(sock, 1) < 0) {
|
||||
error_set_errno(errp, errno, QERR_SOCKET_LISTEN_FAILED);
|
||||
error_setg_errno(errp, errno, "Failed to listen on socket");
|
||||
goto err;
|
||||
}
|
||||
|
||||
@ -739,7 +739,7 @@ int unix_connect_opts(QemuOpts *opts, Error **errp,
|
||||
|
||||
sock = qemu_socket(PF_UNIX, SOCK_STREAM, 0);
|
||||
if (sock < 0) {
|
||||
error_set_errno(errp, errno, QERR_SOCKET_CREATE_FAILED);
|
||||
error_setg_errno(errp, errno, "Failed to create socket");
|
||||
return -1;
|
||||
}
|
||||
if (callback != NULL) {
|
||||
@ -774,7 +774,7 @@ int unix_connect_opts(QemuOpts *opts, Error **errp,
|
||||
}
|
||||
|
||||
if (rc < 0) {
|
||||
error_set_errno(errp, -rc, QERR_SOCKET_CONNECT_FAILED);
|
||||
error_setg_errno(errp, -rc, "Failed to connect socket");
|
||||
close(sock);
|
||||
sock = -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user