mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-23 11:39:53 +00:00
sockets: Rename SocketAddress to SocketAddressLegacy
The next commit will rename SocketAddressFlat to SocketAddress, and the commit after that will replace most uses of SocketAddressLegacy by SocketAddress, replacing most of this commit's renames right back. Note that checkpatch emits a few "line over 80 characters" warnings. The long lines are all temporary; the SocketAddressLegacy replacement will shorten them again. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1493192202-3184-5-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
4626a19c86
commit
dfd100f242
@ -309,7 +309,7 @@ NBDClientSession *nbd_get_client_session(BlockDriverState *bs)
|
|||||||
static QIOChannelSocket *nbd_establish_connection(SocketAddressFlat *saddr_flat,
|
static QIOChannelSocket *nbd_establish_connection(SocketAddressFlat *saddr_flat,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
SocketAddress *saddr = socket_address_crumple(saddr_flat);
|
SocketAddressLegacy *saddr = socket_address_crumple(saddr_flat);
|
||||||
QIOChannelSocket *sioc;
|
QIOChannelSocket *sioc;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
|
|
||||||
@ -319,7 +319,7 @@ static QIOChannelSocket *nbd_establish_connection(SocketAddressFlat *saddr_flat,
|
|||||||
qio_channel_socket_connect_sync(sioc,
|
qio_channel_socket_connect_sync(sioc,
|
||||||
saddr,
|
saddr,
|
||||||
&local_err);
|
&local_err);
|
||||||
qapi_free_SocketAddress(saddr);
|
qapi_free_SocketAddressLegacy(saddr);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
object_unref(OBJECT(sioc));
|
object_unref(OBJECT(sioc));
|
||||||
error_propagate(errp, local_err);
|
error_propagate(errp, local_err);
|
||||||
|
@ -378,7 +378,7 @@ struct BDRVSheepdogState {
|
|||||||
uint32_t cache_flags;
|
uint32_t cache_flags;
|
||||||
bool discard_supported;
|
bool discard_supported;
|
||||||
|
|
||||||
SocketAddress *addr;
|
SocketAddressLegacy *addr;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
CoMutex lock;
|
CoMutex lock;
|
||||||
@ -530,17 +530,17 @@ static void sd_aio_setup(SheepdogAIOCB *acb, BDRVSheepdogState *s,
|
|||||||
QLIST_INSERT_HEAD(&s->inflight_aiocb_head, acb, aiocb_siblings);
|
QLIST_INSERT_HEAD(&s->inflight_aiocb_head, acb, aiocb_siblings);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SocketAddress *sd_socket_address(const char *path,
|
static SocketAddressLegacy *sd_socket_address(const char *path,
|
||||||
const char *host, const char *port)
|
const char *host, const char *port)
|
||||||
{
|
{
|
||||||
SocketAddress *addr = g_new0(SocketAddress, 1);
|
SocketAddressLegacy *addr = g_new0(SocketAddressLegacy, 1);
|
||||||
|
|
||||||
if (path) {
|
if (path) {
|
||||||
addr->type = SOCKET_ADDRESS_KIND_UNIX;
|
addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
|
||||||
addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
|
addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
|
||||||
addr->u.q_unix.data->path = g_strdup(path);
|
addr->u.q_unix.data->path = g_strdup(path);
|
||||||
} else {
|
} else {
|
||||||
addr->type = SOCKET_ADDRESS_KIND_INET;
|
addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
|
||||||
addr->u.inet.data = g_new0(InetSocketAddress, 1);
|
addr->u.inet.data = g_new0(InetSocketAddress, 1);
|
||||||
addr->u.inet.data->host = g_strdup(host ?: SD_DEFAULT_ADDR);
|
addr->u.inet.data->host = g_strdup(host ?: SD_DEFAULT_ADDR);
|
||||||
addr->u.inet.data->port = g_strdup(port ?: stringify(SD_DEFAULT_PORT));
|
addr->u.inet.data->port = g_strdup(port ?: stringify(SD_DEFAULT_PORT));
|
||||||
@ -549,13 +549,13 @@ static SocketAddress *sd_socket_address(const char *path,
|
|||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SocketAddress *sd_server_config(QDict *options, Error **errp)
|
static SocketAddressLegacy *sd_server_config(QDict *options, Error **errp)
|
||||||
{
|
{
|
||||||
QDict *server = NULL;
|
QDict *server = NULL;
|
||||||
QObject *crumpled_server = NULL;
|
QObject *crumpled_server = NULL;
|
||||||
Visitor *iv = NULL;
|
Visitor *iv = NULL;
|
||||||
SocketAddressFlat *saddr_flat = NULL;
|
SocketAddressFlat *saddr_flat = NULL;
|
||||||
SocketAddress *saddr = NULL;
|
SocketAddressLegacy *saddr = NULL;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
|
|
||||||
qdict_extract_subqdict(options, &server, "server.");
|
qdict_extract_subqdict(options, &server, "server.");
|
||||||
@ -597,7 +597,7 @@ static int connect_to_sdog(BDRVSheepdogState *s, Error **errp)
|
|||||||
|
|
||||||
fd = socket_connect(s->addr, NULL, NULL, errp);
|
fd = socket_connect(s->addr, NULL, NULL, errp);
|
||||||
|
|
||||||
if (s->addr->type == SOCKET_ADDRESS_KIND_INET && fd >= 0) {
|
if (s->addr->type == SOCKET_ADDRESS_LEGACY_KIND_INET && fd >= 0) {
|
||||||
int ret = socket_set_nodelay(fd);
|
int ret = socket_set_nodelay(fd);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
error_report("%s", strerror(errno));
|
error_report("%s", strerror(errno));
|
||||||
@ -2149,7 +2149,7 @@ static void sd_close(BlockDriverState *bs)
|
|||||||
aio_set_fd_handler(bdrv_get_aio_context(bs), s->fd,
|
aio_set_fd_handler(bdrv_get_aio_context(bs), s->fd,
|
||||||
false, NULL, NULL, NULL, NULL);
|
false, NULL, NULL, NULL, NULL);
|
||||||
closesocket(s->fd);
|
closesocket(s->fd);
|
||||||
qapi_free_SocketAddress(s->addr);
|
qapi_free_SocketAddressLegacy(s->addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t sd_getlength(BlockDriverState *bs)
|
static int64_t sd_getlength(BlockDriverState *bs)
|
||||||
|
@ -99,7 +99,7 @@ static QCryptoTLSCreds *nbd_get_tls_creds(const char *id, Error **errp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void qmp_nbd_server_start(SocketAddress *addr,
|
void qmp_nbd_server_start(SocketAddressLegacy *addr,
|
||||||
bool has_tls_creds, const char *tls_creds,
|
bool has_tls_creds, const char *tls_creds,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
@ -124,8 +124,8 @@ void qmp_nbd_server_start(SocketAddress *addr,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO SOCKET_ADDRESS_KIND_FD where fd has AF_INET or AF_INET6 */
|
/* TODO SOCKET_ADDRESS_LEGACY_KIND_FD where fd has AF_INET or AF_INET6 */
|
||||||
if (addr->type != SOCKET_ADDRESS_KIND_INET) {
|
if (addr->type != SOCKET_ADDRESS_LEGACY_KIND_INET) {
|
||||||
error_setg(errp, "TLS is only supported with IPv4/IPv6");
|
error_setg(errp, "TLS is only supported with IPv4/IPv6");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ typedef struct {
|
|||||||
int *write_msgfds;
|
int *write_msgfds;
|
||||||
size_t write_msgfds_num;
|
size_t write_msgfds_num;
|
||||||
|
|
||||||
SocketAddress *addr;
|
SocketAddressLegacy *addr;
|
||||||
bool is_listen;
|
bool is_listen;
|
||||||
bool is_telnet;
|
bool is_telnet;
|
||||||
bool is_tn3270;
|
bool is_tn3270;
|
||||||
@ -356,27 +356,27 @@ static void tcp_chr_free_connection(Chardev *chr)
|
|||||||
s->connected = 0;
|
s->connected = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *SocketAddress_to_str(const char *prefix, SocketAddress *addr,
|
static char *SocketAddress_to_str(const char *prefix, SocketAddressLegacy *addr,
|
||||||
bool is_listen, bool is_telnet)
|
bool is_listen, bool is_telnet)
|
||||||
{
|
{
|
||||||
switch (addr->type) {
|
switch (addr->type) {
|
||||||
case SOCKET_ADDRESS_KIND_INET:
|
case SOCKET_ADDRESS_LEGACY_KIND_INET:
|
||||||
return g_strdup_printf("%s%s:%s:%s%s", prefix,
|
return g_strdup_printf("%s%s:%s:%s%s", prefix,
|
||||||
is_telnet ? "telnet" : "tcp",
|
is_telnet ? "telnet" : "tcp",
|
||||||
addr->u.inet.data->host,
|
addr->u.inet.data->host,
|
||||||
addr->u.inet.data->port,
|
addr->u.inet.data->port,
|
||||||
is_listen ? ",server" : "");
|
is_listen ? ",server" : "");
|
||||||
break;
|
break;
|
||||||
case SOCKET_ADDRESS_KIND_UNIX:
|
case SOCKET_ADDRESS_LEGACY_KIND_UNIX:
|
||||||
return g_strdup_printf("%sunix:%s%s", prefix,
|
return g_strdup_printf("%sunix:%s%s", prefix,
|
||||||
addr->u.q_unix.data->path,
|
addr->u.q_unix.data->path,
|
||||||
is_listen ? ",server" : "");
|
is_listen ? ",server" : "");
|
||||||
break;
|
break;
|
||||||
case SOCKET_ADDRESS_KIND_FD:
|
case SOCKET_ADDRESS_LEGACY_KIND_FD:
|
||||||
return g_strdup_printf("%sfd:%s%s", prefix, addr->u.fd.data->str,
|
return g_strdup_printf("%sfd:%s%s", prefix, addr->u.fd.data->str,
|
||||||
is_listen ? ",server" : "");
|
is_listen ? ",server" : "");
|
||||||
break;
|
break;
|
||||||
case SOCKET_ADDRESS_KIND_VSOCK:
|
case SOCKET_ADDRESS_LEGACY_KIND_VSOCK:
|
||||||
return g_strdup_printf("%svsock:%s:%s", prefix,
|
return g_strdup_printf("%svsock:%s:%s", prefix,
|
||||||
addr->u.vsock.data->cid,
|
addr->u.vsock.data->cid,
|
||||||
addr->u.vsock.data->port);
|
addr->u.vsock.data->port);
|
||||||
@ -796,7 +796,7 @@ static void char_socket_finalize(Object *obj)
|
|||||||
g_source_remove(s->reconnect_timer);
|
g_source_remove(s->reconnect_timer);
|
||||||
s->reconnect_timer = 0;
|
s->reconnect_timer = 0;
|
||||||
}
|
}
|
||||||
qapi_free_SocketAddress(s->addr);
|
qapi_free_SocketAddressLegacy(s->addr);
|
||||||
if (s->listen_tag) {
|
if (s->listen_tag) {
|
||||||
g_source_remove(s->listen_tag);
|
g_source_remove(s->listen_tag);
|
||||||
s->listen_tag = 0;
|
s->listen_tag = 0;
|
||||||
@ -859,7 +859,7 @@ static void qmp_chardev_open_socket(Chardev *chr,
|
|||||||
{
|
{
|
||||||
SocketChardev *s = SOCKET_CHARDEV(chr);
|
SocketChardev *s = SOCKET_CHARDEV(chr);
|
||||||
ChardevSocket *sock = backend->u.socket.data;
|
ChardevSocket *sock = backend->u.socket.data;
|
||||||
SocketAddress *addr = sock->addr;
|
SocketAddressLegacy *addr = sock->addr;
|
||||||
bool do_nodelay = sock->has_nodelay ? sock->nodelay : false;
|
bool do_nodelay = sock->has_nodelay ? sock->nodelay : false;
|
||||||
bool is_listen = sock->has_server ? sock->server : true;
|
bool is_listen = sock->has_server ? sock->server : true;
|
||||||
bool is_telnet = sock->has_telnet ? sock->telnet : false;
|
bool is_telnet = sock->has_telnet ? sock->telnet : false;
|
||||||
@ -905,11 +905,11 @@ static void qmp_chardev_open_socket(Chardev *chr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s->addr = QAPI_CLONE(SocketAddress, sock->addr);
|
s->addr = QAPI_CLONE(SocketAddressLegacy, sock->addr);
|
||||||
|
|
||||||
qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_RECONNECTABLE);
|
qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_RECONNECTABLE);
|
||||||
/* TODO SOCKET_ADDRESS_FD where fd has AF_UNIX */
|
/* TODO SOCKET_ADDRESS_FD where fd has AF_UNIX */
|
||||||
if (addr->type == SOCKET_ADDRESS_KIND_UNIX) {
|
if (addr->type == SOCKET_ADDRESS_LEGACY_KIND_UNIX) {
|
||||||
qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_FD_PASS);
|
qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_FD_PASS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -945,7 +945,7 @@ static void qmp_chardev_open_socket(Chardev *chr,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
qapi_free_SocketAddress(s->addr);
|
qapi_free_SocketAddressLegacy(s->addr);
|
||||||
s->addr = socket_local_address(sioc->fd, errp);
|
s->addr = socket_local_address(sioc->fd, errp);
|
||||||
update_disconnected_filename(s);
|
update_disconnected_filename(s);
|
||||||
|
|
||||||
@ -985,7 +985,7 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend,
|
|||||||
const char *host = qemu_opt_get(opts, "host");
|
const char *host = qemu_opt_get(opts, "host");
|
||||||
const char *port = qemu_opt_get(opts, "port");
|
const char *port = qemu_opt_get(opts, "port");
|
||||||
const char *tls_creds = qemu_opt_get(opts, "tls-creds");
|
const char *tls_creds = qemu_opt_get(opts, "tls-creds");
|
||||||
SocketAddress *addr;
|
SocketAddressLegacy *addr;
|
||||||
ChardevSocket *sock;
|
ChardevSocket *sock;
|
||||||
|
|
||||||
backend->type = CHARDEV_BACKEND_KIND_SOCKET;
|
backend->type = CHARDEV_BACKEND_KIND_SOCKET;
|
||||||
@ -1022,14 +1022,14 @@ static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend,
|
|||||||
sock->reconnect = reconnect;
|
sock->reconnect = reconnect;
|
||||||
sock->tls_creds = g_strdup(tls_creds);
|
sock->tls_creds = g_strdup(tls_creds);
|
||||||
|
|
||||||
addr = g_new0(SocketAddress, 1);
|
addr = g_new0(SocketAddressLegacy, 1);
|
||||||
if (path) {
|
if (path) {
|
||||||
UnixSocketAddress *q_unix;
|
UnixSocketAddress *q_unix;
|
||||||
addr->type = SOCKET_ADDRESS_KIND_UNIX;
|
addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
|
||||||
q_unix = addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
|
q_unix = addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
|
||||||
q_unix->path = g_strdup(path);
|
q_unix->path = g_strdup(path);
|
||||||
} else {
|
} else {
|
||||||
addr->type = SOCKET_ADDRESS_KIND_INET;
|
addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
|
||||||
addr->u.inet.data = g_new(InetSocketAddress, 1);
|
addr->u.inet.data = g_new(InetSocketAddress, 1);
|
||||||
*addr->u.inet.data = (InetSocketAddress) {
|
*addr->u.inet.data = (InetSocketAddress) {
|
||||||
.host = g_strdup(host),
|
.host = g_strdup(host),
|
||||||
@ -1051,7 +1051,7 @@ char_socket_get_addr(Object *obj, Visitor *v, const char *name,
|
|||||||
{
|
{
|
||||||
SocketChardev *s = SOCKET_CHARDEV(obj);
|
SocketChardev *s = SOCKET_CHARDEV(obj);
|
||||||
|
|
||||||
visit_type_SocketAddress(v, name, &s->addr, errp);
|
visit_type_SocketAddressLegacy(v, name, &s->addr, errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@ -1078,7 +1078,7 @@ static void char_socket_class_init(ObjectClass *oc, void *data)
|
|||||||
cc->chr_add_watch = tcp_chr_add_watch;
|
cc->chr_add_watch = tcp_chr_add_watch;
|
||||||
cc->chr_update_read_handler = tcp_chr_update_read_handler;
|
cc->chr_update_read_handler = tcp_chr_update_read_handler;
|
||||||
|
|
||||||
object_class_property_add(oc, "addr", "SocketAddress",
|
object_class_property_add(oc, "addr", "SocketAddressLegacy",
|
||||||
char_socket_get_addr, NULL,
|
char_socket_get_addr, NULL,
|
||||||
NULL, NULL, &error_abort);
|
NULL, NULL, &error_abort);
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ static void qemu_chr_parse_udp(QemuOpts *opts, ChardevBackend *backend,
|
|||||||
const char *localaddr = qemu_opt_get(opts, "localaddr");
|
const char *localaddr = qemu_opt_get(opts, "localaddr");
|
||||||
const char *localport = qemu_opt_get(opts, "localport");
|
const char *localport = qemu_opt_get(opts, "localport");
|
||||||
bool has_local = false;
|
bool has_local = false;
|
||||||
SocketAddress *addr;
|
SocketAddressLegacy *addr;
|
||||||
ChardevUdp *udp;
|
ChardevUdp *udp;
|
||||||
|
|
||||||
backend->type = CHARDEV_BACKEND_KIND_UDP;
|
backend->type = CHARDEV_BACKEND_KIND_UDP;
|
||||||
@ -159,8 +159,8 @@ static void qemu_chr_parse_udp(QemuOpts *opts, ChardevBackend *backend,
|
|||||||
udp = backend->u.udp.data = g_new0(ChardevUdp, 1);
|
udp = backend->u.udp.data = g_new0(ChardevUdp, 1);
|
||||||
qemu_chr_parse_common(opts, qapi_ChardevUdp_base(udp));
|
qemu_chr_parse_common(opts, qapi_ChardevUdp_base(udp));
|
||||||
|
|
||||||
addr = g_new0(SocketAddress, 1);
|
addr = g_new0(SocketAddressLegacy, 1);
|
||||||
addr->type = SOCKET_ADDRESS_KIND_INET;
|
addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
|
||||||
addr->u.inet.data = g_new(InetSocketAddress, 1);
|
addr->u.inet.data = g_new(InetSocketAddress, 1);
|
||||||
*addr->u.inet.data = (InetSocketAddress) {
|
*addr->u.inet.data = (InetSocketAddress) {
|
||||||
.host = g_strdup(host),
|
.host = g_strdup(host),
|
||||||
@ -174,8 +174,8 @@ static void qemu_chr_parse_udp(QemuOpts *opts, ChardevBackend *backend,
|
|||||||
|
|
||||||
if (has_local) {
|
if (has_local) {
|
||||||
udp->has_local = true;
|
udp->has_local = true;
|
||||||
addr = g_new0(SocketAddress, 1);
|
addr = g_new0(SocketAddressLegacy, 1);
|
||||||
addr->type = SOCKET_ADDRESS_KIND_INET;
|
addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
|
||||||
addr->u.inet.data = g_new(InetSocketAddress, 1);
|
addr->u.inet.data = g_new(InetSocketAddress, 1);
|
||||||
*addr->u.inet.data = (InetSocketAddress) {
|
*addr->u.inet.data = (InetSocketAddress) {
|
||||||
.host = g_strdup(localaddr),
|
.host = g_strdup(localaddr),
|
||||||
|
4
hmp.c
4
hmp.c
@ -2108,7 +2108,7 @@ void hmp_nbd_server_start(Monitor *mon, const QDict *qdict)
|
|||||||
bool all = qdict_get_try_bool(qdict, "all", false);
|
bool all = qdict_get_try_bool(qdict, "all", false);
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
BlockInfoList *block_list, *info;
|
BlockInfoList *block_list, *info;
|
||||||
SocketAddress *addr;
|
SocketAddressLegacy *addr;
|
||||||
|
|
||||||
if (writable && !all) {
|
if (writable && !all) {
|
||||||
error_setg(&local_err, "-w only valid together with -a");
|
error_setg(&local_err, "-w only valid together with -a");
|
||||||
@ -2122,7 +2122,7 @@ void hmp_nbd_server_start(Monitor *mon, const QDict *qdict)
|
|||||||
}
|
}
|
||||||
|
|
||||||
qmp_nbd_server_start(addr, false, NULL, &local_err);
|
qmp_nbd_server_start(addr, false, NULL, &local_err);
|
||||||
qapi_free_SocketAddress(addr);
|
qapi_free_SocketAddressLegacy(addr);
|
||||||
if (local_err != NULL) {
|
if (local_err != NULL) {
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ qio_channel_socket_new_fd(int fd,
|
|||||||
* an error occurs.
|
* an error occurs.
|
||||||
*/
|
*/
|
||||||
int qio_channel_socket_connect_sync(QIOChannelSocket *ioc,
|
int qio_channel_socket_connect_sync(QIOChannelSocket *ioc,
|
||||||
SocketAddress *addr,
|
SocketAddressLegacy *addr,
|
||||||
Error **errp);
|
Error **errp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,7 +110,7 @@ int qio_channel_socket_connect_sync(QIOChannelSocket *ioc,
|
|||||||
* as this function returns without waiting for completion.
|
* as this function returns without waiting for completion.
|
||||||
*/
|
*/
|
||||||
void qio_channel_socket_connect_async(QIOChannelSocket *ioc,
|
void qio_channel_socket_connect_async(QIOChannelSocket *ioc,
|
||||||
SocketAddress *addr,
|
SocketAddressLegacy *addr,
|
||||||
QIOTaskFunc callback,
|
QIOTaskFunc callback,
|
||||||
gpointer opaque,
|
gpointer opaque,
|
||||||
GDestroyNotify destroy);
|
GDestroyNotify destroy);
|
||||||
@ -128,7 +128,7 @@ void qio_channel_socket_connect_async(QIOChannelSocket *ioc,
|
|||||||
* an error occurs.
|
* an error occurs.
|
||||||
*/
|
*/
|
||||||
int qio_channel_socket_listen_sync(QIOChannelSocket *ioc,
|
int qio_channel_socket_listen_sync(QIOChannelSocket *ioc,
|
||||||
SocketAddress *addr,
|
SocketAddressLegacy *addr,
|
||||||
Error **errp);
|
Error **errp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -147,7 +147,7 @@ int qio_channel_socket_listen_sync(QIOChannelSocket *ioc,
|
|||||||
* as this function returns without waiting for completion.
|
* as this function returns without waiting for completion.
|
||||||
*/
|
*/
|
||||||
void qio_channel_socket_listen_async(QIOChannelSocket *ioc,
|
void qio_channel_socket_listen_async(QIOChannelSocket *ioc,
|
||||||
SocketAddress *addr,
|
SocketAddressLegacy *addr,
|
||||||
QIOTaskFunc callback,
|
QIOTaskFunc callback,
|
||||||
gpointer opaque,
|
gpointer opaque,
|
||||||
GDestroyNotify destroy);
|
GDestroyNotify destroy);
|
||||||
@ -167,8 +167,8 @@ void qio_channel_socket_listen_async(QIOChannelSocket *ioc,
|
|||||||
* is established or an error occurs.
|
* is established or an error occurs.
|
||||||
*/
|
*/
|
||||||
int qio_channel_socket_dgram_sync(QIOChannelSocket *ioc,
|
int qio_channel_socket_dgram_sync(QIOChannelSocket *ioc,
|
||||||
SocketAddress *localAddr,
|
SocketAddressLegacy *localAddr,
|
||||||
SocketAddress *remoteAddr,
|
SocketAddressLegacy *remoteAddr,
|
||||||
Error **errp);
|
Error **errp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -190,8 +190,8 @@ int qio_channel_socket_dgram_sync(QIOChannelSocket *ioc,
|
|||||||
* waiting for completion.
|
* waiting for completion.
|
||||||
*/
|
*/
|
||||||
void qio_channel_socket_dgram_async(QIOChannelSocket *ioc,
|
void qio_channel_socket_dgram_async(QIOChannelSocket *ioc,
|
||||||
SocketAddress *localAddr,
|
SocketAddressLegacy *localAddr,
|
||||||
SocketAddress *remoteAddr,
|
SocketAddressLegacy *remoteAddr,
|
||||||
QIOTaskFunc callback,
|
QIOTaskFunc callback,
|
||||||
gpointer opaque,
|
gpointer opaque,
|
||||||
GDestroyNotify destroy);
|
GDestroyNotify destroy);
|
||||||
@ -205,12 +205,12 @@ void qio_channel_socket_dgram_async(QIOChannelSocket *ioc,
|
|||||||
* Get the string representation of the local socket
|
* Get the string representation of the local socket
|
||||||
* address. A pointer to the allocated address information
|
* address. A pointer to the allocated address information
|
||||||
* struct will be returned, which the caller is required to
|
* struct will be returned, which the caller is required to
|
||||||
* release with a call qapi_free_SocketAddress when no
|
* release with a call qapi_free_SocketAddressLegacy() when no
|
||||||
* longer required.
|
* longer required.
|
||||||
*
|
*
|
||||||
* Returns: 0 on success, -1 on error
|
* Returns: 0 on success, -1 on error
|
||||||
*/
|
*/
|
||||||
SocketAddress *
|
SocketAddressLegacy *
|
||||||
qio_channel_socket_get_local_address(QIOChannelSocket *ioc,
|
qio_channel_socket_get_local_address(QIOChannelSocket *ioc,
|
||||||
Error **errp);
|
Error **errp);
|
||||||
|
|
||||||
@ -222,12 +222,12 @@ qio_channel_socket_get_local_address(QIOChannelSocket *ioc,
|
|||||||
* Get the string representation of the local socket
|
* Get the string representation of the local socket
|
||||||
* address. A pointer to the allocated address information
|
* address. A pointer to the allocated address information
|
||||||
* struct will be returned, which the caller is required to
|
* struct will be returned, which the caller is required to
|
||||||
* release with a call qapi_free_SocketAddress when no
|
* release with a call qapi_free_SocketAddressLegacy() when no
|
||||||
* longer required.
|
* longer required.
|
||||||
*
|
*
|
||||||
* Returns: the socket address struct, or NULL on error
|
* Returns: the socket address struct, or NULL on error
|
||||||
*/
|
*/
|
||||||
SocketAddress *
|
SocketAddressLegacy *
|
||||||
qio_channel_socket_get_remote_address(QIOChannelSocket *ioc,
|
qio_channel_socket_get_remote_address(QIOChannelSocket *ioc,
|
||||||
Error **errp);
|
Error **errp);
|
||||||
|
|
||||||
|
@ -40,15 +40,15 @@ typedef struct QIODNSResolverClass QIODNSResolverClass;
|
|||||||
* QIODNSResolver:
|
* QIODNSResolver:
|
||||||
*
|
*
|
||||||
* The QIODNSResolver class provides a framework for doing
|
* The QIODNSResolver class provides a framework for doing
|
||||||
* DNS resolution on SocketAddress objects, independently
|
* DNS resolution on SocketAddressLegacy objects, independently
|
||||||
* of socket creation.
|
* of socket creation.
|
||||||
*
|
*
|
||||||
* <example>
|
* <example>
|
||||||
* <title>Resolving addresses synchronously</title>
|
* <title>Resolving addresses synchronously</title>
|
||||||
* <programlisting>
|
* <programlisting>
|
||||||
* int mylisten(SocketAddress *addr, Error **errp) {
|
* int mylisten(SocketAddressLegacy *addr, Error **errp) {
|
||||||
* QIODNSResolver *resolver = qio_dns_resolver_get_instance();
|
* QIODNSResolver *resolver = qio_dns_resolver_get_instance();
|
||||||
* SocketAddress **rawaddrs = NULL;
|
* SocketAddressLegacy **rawaddrs = NULL;
|
||||||
* size_t nrawaddrs = 0;
|
* size_t nrawaddrs = 0;
|
||||||
* Error *err = NULL;
|
* Error *err = NULL;
|
||||||
* QIOChannel **socks = NULL;
|
* QIOChannel **socks = NULL;
|
||||||
@ -69,7 +69,7 @@ typedef struct QIODNSResolverClass QIODNSResolverClass;
|
|||||||
* socks = g_renew(QIOChannelSocket *, socks, nsocks + 1);
|
* socks = g_renew(QIOChannelSocket *, socks, nsocks + 1);
|
||||||
* socks[nsocks++] = sock;
|
* socks[nsocks++] = sock;
|
||||||
* }
|
* }
|
||||||
* qapi_free_SocketAddress(rawaddrs[i]);
|
* qapi_free_SocketAddressLegacy(rawaddrs[i]);
|
||||||
* }
|
* }
|
||||||
* g_free(rawaddrs);
|
* g_free(rawaddrs);
|
||||||
*
|
*
|
||||||
@ -95,7 +95,7 @@ typedef struct QIODNSResolverClass QIODNSResolverClass;
|
|||||||
* MyListenData *data = opaque;
|
* MyListenData *data = opaque;
|
||||||
* QIODNSResolver *resolver =
|
* QIODNSResolver *resolver =
|
||||||
* QIO_DNS_RESOLVER(qio_task_get_source(task);
|
* QIO_DNS_RESOLVER(qio_task_get_source(task);
|
||||||
* SocketAddress **rawaddrs = NULL;
|
* SocketAddressLegacy **rawaddrs = NULL;
|
||||||
* size_t nrawaddrs = 0;
|
* size_t nrawaddrs = 0;
|
||||||
* Error *err = NULL;
|
* Error *err = NULL;
|
||||||
*
|
*
|
||||||
@ -116,7 +116,7 @@ typedef struct QIODNSResolverClass QIODNSResolverClass;
|
|||||||
* socks = g_renew(QIOChannelSocket *, socks, nsocks + 1);
|
* socks = g_renew(QIOChannelSocket *, socks, nsocks + 1);
|
||||||
* socks[nsocks++] = sock;
|
* socks[nsocks++] = sock;
|
||||||
* }
|
* }
|
||||||
* qapi_free_SocketAddress(rawaddrs[i]);
|
* qapi_free_SocketAddressLegacy(rawaddrs[i]);
|
||||||
* }
|
* }
|
||||||
* g_free(rawaddrs);
|
* g_free(rawaddrs);
|
||||||
*
|
*
|
||||||
@ -127,7 +127,7 @@ typedef struct QIODNSResolverClass QIODNSResolverClass;
|
|||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* void mylisten(SocketAddress *addr, MyListenData *data) {
|
* void mylisten(SocketAddressLegacy *addr, MyListenData *data) {
|
||||||
* QIODNSResolver *resolver = qio_dns_resolver_get_instance();
|
* QIODNSResolver *resolver = qio_dns_resolver_get_instance();
|
||||||
* qio_dns_resolver_lookup_async(dns, addr,
|
* qio_dns_resolver_lookup_async(dns, addr,
|
||||||
* mylistenresult, data, NULL);
|
* mylistenresult, data, NULL);
|
||||||
@ -177,9 +177,9 @@ QIODNSResolver *qio_dns_resolver_get_instance(void);
|
|||||||
* Returns: 0 if resolution was successful, -1 on error
|
* Returns: 0 if resolution was successful, -1 on error
|
||||||
*/
|
*/
|
||||||
int qio_dns_resolver_lookup_sync(QIODNSResolver *resolver,
|
int qio_dns_resolver_lookup_sync(QIODNSResolver *resolver,
|
||||||
SocketAddress *addr,
|
SocketAddressLegacy *addr,
|
||||||
size_t *naddrs,
|
size_t *naddrs,
|
||||||
SocketAddress ***addrs,
|
SocketAddressLegacy ***addrs,
|
||||||
Error **errp);
|
Error **errp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -201,7 +201,7 @@ int qio_dns_resolver_lookup_sync(QIODNSResolver *resolver,
|
|||||||
* of the caller will not be blocked.
|
* of the caller will not be blocked.
|
||||||
*/
|
*/
|
||||||
void qio_dns_resolver_lookup_async(QIODNSResolver *resolver,
|
void qio_dns_resolver_lookup_async(QIODNSResolver *resolver,
|
||||||
SocketAddress *addr,
|
SocketAddressLegacy *addr,
|
||||||
QIOTaskFunc func,
|
QIOTaskFunc func,
|
||||||
gpointer opaque,
|
gpointer opaque,
|
||||||
GDestroyNotify notify);
|
GDestroyNotify notify);
|
||||||
@ -223,6 +223,6 @@ void qio_dns_resolver_lookup_async(QIODNSResolver *resolver,
|
|||||||
void qio_dns_resolver_lookup_result(QIODNSResolver *resolver,
|
void qio_dns_resolver_lookup_result(QIODNSResolver *resolver,
|
||||||
QIOTask *task,
|
QIOTask *task,
|
||||||
size_t *naddrs,
|
size_t *naddrs,
|
||||||
SocketAddress ***addrs);
|
SocketAddressLegacy ***addrs);
|
||||||
|
|
||||||
#endif /* QIO_DNS_RESOLVER_H */
|
#endif /* QIO_DNS_RESOLVER_H */
|
||||||
|
@ -166,7 +166,7 @@ typedef void (*QIOTaskWorker)(QIOTask *task,
|
|||||||
* gpointer opaque)
|
* gpointer opaque)
|
||||||
* {
|
* {
|
||||||
* QMyObject obj = QMY_OBJECT(qio_task_get_source(task));
|
* QMyObject obj = QMY_OBJECT(qio_task_get_source(task));
|
||||||
* SocketAddress *addr = opaque;
|
* SocketAddressLegacy *addr = opaque;
|
||||||
* Error *err = NULL;
|
* Error *err = NULL;
|
||||||
*
|
*
|
||||||
* obj->fd = socket_listen(addr, &err);
|
* obj->fd = socket_listen(addr, &err);
|
||||||
@ -175,20 +175,20 @@ typedef void (*QIOTaskWorker)(QIOTask *task,
|
|||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* void myobject_listen_async(QMyObject *obj,
|
* void myobject_listen_async(QMyObject *obj,
|
||||||
* SocketAddress *addr,
|
* SocketAddressLegacy *addr,
|
||||||
* QIOTaskFunc *func,
|
* QIOTaskFunc *func,
|
||||||
* gpointer opaque,
|
* gpointer opaque,
|
||||||
* GDestroyNotify notify)
|
* GDestroyNotify notify)
|
||||||
* {
|
* {
|
||||||
* QIOTask *task;
|
* QIOTask *task;
|
||||||
* SocketAddress *addrCopy;
|
* SocketAddressLegacy *addrCopy;
|
||||||
*
|
*
|
||||||
* addrCopy = QAPI_CLONE(SocketAddress, addr);
|
* addrCopy = QAPI_CLONE(SocketAddressLegacy, addr);
|
||||||
* task = qio_task_new(OBJECT(obj), func, opaque, notify);
|
* task = qio_task_new(OBJECT(obj), func, opaque, notify);
|
||||||
*
|
*
|
||||||
* qio_task_run_in_thread(task, myobject_listen_worker,
|
* qio_task_run_in_thread(task, myobject_listen_worker,
|
||||||
* addrCopy,
|
* addrCopy,
|
||||||
* qapi_free_SocketAddress);
|
* qapi_free_SocketAddressLegacy);
|
||||||
* }
|
* }
|
||||||
* </example>
|
* </example>
|
||||||
*
|
*
|
||||||
|
@ -45,12 +45,12 @@ NetworkAddressFamily inet_netfamily(int family);
|
|||||||
int unix_listen(const char *path, char *ostr, int olen, Error **errp);
|
int unix_listen(const char *path, char *ostr, int olen, Error **errp);
|
||||||
int unix_connect(const char *path, Error **errp);
|
int unix_connect(const char *path, Error **errp);
|
||||||
|
|
||||||
SocketAddress *socket_parse(const char *str, Error **errp);
|
SocketAddressLegacy *socket_parse(const char *str, Error **errp);
|
||||||
int socket_connect(SocketAddress *addr, NonBlockingConnectHandler *callback,
|
int socket_connect(SocketAddressLegacy *addr, NonBlockingConnectHandler *callback,
|
||||||
void *opaque, Error **errp);
|
void *opaque, Error **errp);
|
||||||
int socket_listen(SocketAddress *addr, Error **errp);
|
int socket_listen(SocketAddressLegacy *addr, Error **errp);
|
||||||
void socket_listen_cleanup(int fd, Error **errp);
|
void socket_listen_cleanup(int fd, Error **errp);
|
||||||
int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp);
|
int socket_dgram(SocketAddressLegacy *remote, SocketAddressLegacy *local, Error **errp);
|
||||||
|
|
||||||
/* Old, ipv4 only bits. Don't use for new code. */
|
/* Old, ipv4 only bits. Don't use for new code. */
|
||||||
int parse_host_port(struct sockaddr_in *saddr, const char *str);
|
int parse_host_port(struct sockaddr_in *saddr, const char *str);
|
||||||
@ -65,12 +65,12 @@ int socket_init(void);
|
|||||||
* Get the string representation of the socket
|
* Get the string representation of the socket
|
||||||
* address. A pointer to the allocated address information
|
* address. A pointer to the allocated address information
|
||||||
* struct will be returned, which the caller is required to
|
* struct will be returned, which the caller is required to
|
||||||
* release with a call qapi_free_SocketAddress when no
|
* release with a call qapi_free_SocketAddressLegacy() when no
|
||||||
* longer required.
|
* longer required.
|
||||||
*
|
*
|
||||||
* Returns: the socket address struct, or NULL on error
|
* Returns: the socket address struct, or NULL on error
|
||||||
*/
|
*/
|
||||||
SocketAddress *
|
SocketAddressLegacy *
|
||||||
socket_sockaddr_to_address(struct sockaddr_storage *sa,
|
socket_sockaddr_to_address(struct sockaddr_storage *sa,
|
||||||
socklen_t salen,
|
socklen_t salen,
|
||||||
Error **errp);
|
Error **errp);
|
||||||
@ -83,12 +83,12 @@ socket_sockaddr_to_address(struct sockaddr_storage *sa,
|
|||||||
* Get the string representation of the local socket
|
* Get the string representation of the local socket
|
||||||
* address. A pointer to the allocated address information
|
* address. A pointer to the allocated address information
|
||||||
* struct will be returned, which the caller is required to
|
* struct will be returned, which the caller is required to
|
||||||
* release with a call qapi_free_SocketAddress when no
|
* release with a call qapi_free_SocketAddressLegacy() when no
|
||||||
* longer required.
|
* longer required.
|
||||||
*
|
*
|
||||||
* Returns: the socket address struct, or NULL on error
|
* Returns: the socket address struct, or NULL on error
|
||||||
*/
|
*/
|
||||||
SocketAddress *socket_local_address(int fd, Error **errp);
|
SocketAddressLegacy *socket_local_address(int fd, Error **errp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* socket_remote_address:
|
* socket_remote_address:
|
||||||
@ -98,12 +98,12 @@ SocketAddress *socket_local_address(int fd, Error **errp);
|
|||||||
* Get the string representation of the remote socket
|
* Get the string representation of the remote socket
|
||||||
* address. A pointer to the allocated address information
|
* address. A pointer to the allocated address information
|
||||||
* struct will be returned, which the caller is required to
|
* struct will be returned, which the caller is required to
|
||||||
* release with a call qapi_free_SocketAddress when no
|
* release with a call qapi_free_SocketAddressLegacy() when no
|
||||||
* longer required.
|
* longer required.
|
||||||
*
|
*
|
||||||
* Returns: the socket address struct, or NULL on error
|
* Returns: the socket address struct, or NULL on error
|
||||||
*/
|
*/
|
||||||
SocketAddress *socket_remote_address(int fd, Error **errp);
|
SocketAddressLegacy *socket_remote_address(int fd, Error **errp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* socket_address_to_string:
|
* socket_address_to_string:
|
||||||
@ -118,17 +118,17 @@ SocketAddress *socket_remote_address(int fd, Error **errp);
|
|||||||
*
|
*
|
||||||
* Returns: the socket address in string format, or NULL on error
|
* Returns: the socket address in string format, or NULL on error
|
||||||
*/
|
*/
|
||||||
char *socket_address_to_string(struct SocketAddress *addr, Error **errp);
|
char *socket_address_to_string(struct SocketAddressLegacy *addr, Error **errp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* socket_address_crumple:
|
* socket_address_crumple:
|
||||||
* @addr_flat: the socket address to crumple
|
* @addr_flat: the socket address to crumple
|
||||||
*
|
*
|
||||||
* Convert SocketAddressFlat to SocketAddress. Caller is responsible
|
* Convert SocketAddressFlat to SocketAddressLegacy. Caller is responsible
|
||||||
* for freeing with qapi_free_SocketAddress().
|
* for freeing with qapi_free_SocketAddressLegacy().
|
||||||
*
|
*
|
||||||
* Returns: the argument converted to SocketAddress.
|
* Returns: the argument converted to SocketAddressLegacy.
|
||||||
*/
|
*/
|
||||||
SocketAddress *socket_address_crumple(SocketAddressFlat *addr_flat);
|
SocketAddressLegacy *socket_address_crumple(SocketAddressFlat *addr_flat);
|
||||||
|
|
||||||
#endif /* QEMU_SOCKETS_H */
|
#endif /* QEMU_SOCKETS_H */
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#define SOCKET_MAX_FDS 16
|
#define SOCKET_MAX_FDS 16
|
||||||
|
|
||||||
SocketAddress *
|
SocketAddressLegacy *
|
||||||
qio_channel_socket_get_local_address(QIOChannelSocket *ioc,
|
qio_channel_socket_get_local_address(QIOChannelSocket *ioc,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
@ -36,7 +36,7 @@ qio_channel_socket_get_local_address(QIOChannelSocket *ioc,
|
|||||||
errp);
|
errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
SocketAddress *
|
SocketAddressLegacy *
|
||||||
qio_channel_socket_get_remote_address(QIOChannelSocket *ioc,
|
qio_channel_socket_get_remote_address(QIOChannelSocket *ioc,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
@ -134,7 +134,7 @@ qio_channel_socket_new_fd(int fd,
|
|||||||
|
|
||||||
|
|
||||||
int qio_channel_socket_connect_sync(QIOChannelSocket *ioc,
|
int qio_channel_socket_connect_sync(QIOChannelSocket *ioc,
|
||||||
SocketAddress *addr,
|
SocketAddressLegacy *addr,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
@ -160,7 +160,7 @@ static void qio_channel_socket_connect_worker(QIOTask *task,
|
|||||||
gpointer opaque)
|
gpointer opaque)
|
||||||
{
|
{
|
||||||
QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(qio_task_get_source(task));
|
QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(qio_task_get_source(task));
|
||||||
SocketAddress *addr = opaque;
|
SocketAddressLegacy *addr = opaque;
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
|
|
||||||
qio_channel_socket_connect_sync(ioc, addr, &err);
|
qio_channel_socket_connect_sync(ioc, addr, &err);
|
||||||
@ -170,16 +170,16 @@ static void qio_channel_socket_connect_worker(QIOTask *task,
|
|||||||
|
|
||||||
|
|
||||||
void qio_channel_socket_connect_async(QIOChannelSocket *ioc,
|
void qio_channel_socket_connect_async(QIOChannelSocket *ioc,
|
||||||
SocketAddress *addr,
|
SocketAddressLegacy *addr,
|
||||||
QIOTaskFunc callback,
|
QIOTaskFunc callback,
|
||||||
gpointer opaque,
|
gpointer opaque,
|
||||||
GDestroyNotify destroy)
|
GDestroyNotify destroy)
|
||||||
{
|
{
|
||||||
QIOTask *task = qio_task_new(
|
QIOTask *task = qio_task_new(
|
||||||
OBJECT(ioc), callback, opaque, destroy);
|
OBJECT(ioc), callback, opaque, destroy);
|
||||||
SocketAddress *addrCopy;
|
SocketAddressLegacy *addrCopy;
|
||||||
|
|
||||||
addrCopy = QAPI_CLONE(SocketAddress, addr);
|
addrCopy = QAPI_CLONE(SocketAddressLegacy, addr);
|
||||||
|
|
||||||
/* socket_connect() does a non-blocking connect(), but it
|
/* socket_connect() does a non-blocking connect(), but it
|
||||||
* still blocks in DNS lookups, so we must use a thread */
|
* still blocks in DNS lookups, so we must use a thread */
|
||||||
@ -187,12 +187,12 @@ void qio_channel_socket_connect_async(QIOChannelSocket *ioc,
|
|||||||
qio_task_run_in_thread(task,
|
qio_task_run_in_thread(task,
|
||||||
qio_channel_socket_connect_worker,
|
qio_channel_socket_connect_worker,
|
||||||
addrCopy,
|
addrCopy,
|
||||||
(GDestroyNotify)qapi_free_SocketAddress);
|
(GDestroyNotify)qapi_free_SocketAddressLegacy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int qio_channel_socket_listen_sync(QIOChannelSocket *ioc,
|
int qio_channel_socket_listen_sync(QIOChannelSocket *ioc,
|
||||||
SocketAddress *addr,
|
SocketAddressLegacy *addr,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
@ -219,7 +219,7 @@ static void qio_channel_socket_listen_worker(QIOTask *task,
|
|||||||
gpointer opaque)
|
gpointer opaque)
|
||||||
{
|
{
|
||||||
QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(qio_task_get_source(task));
|
QIOChannelSocket *ioc = QIO_CHANNEL_SOCKET(qio_task_get_source(task));
|
||||||
SocketAddress *addr = opaque;
|
SocketAddressLegacy *addr = opaque;
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
|
|
||||||
qio_channel_socket_listen_sync(ioc, addr, &err);
|
qio_channel_socket_listen_sync(ioc, addr, &err);
|
||||||
@ -229,29 +229,29 @@ static void qio_channel_socket_listen_worker(QIOTask *task,
|
|||||||
|
|
||||||
|
|
||||||
void qio_channel_socket_listen_async(QIOChannelSocket *ioc,
|
void qio_channel_socket_listen_async(QIOChannelSocket *ioc,
|
||||||
SocketAddress *addr,
|
SocketAddressLegacy *addr,
|
||||||
QIOTaskFunc callback,
|
QIOTaskFunc callback,
|
||||||
gpointer opaque,
|
gpointer opaque,
|
||||||
GDestroyNotify destroy)
|
GDestroyNotify destroy)
|
||||||
{
|
{
|
||||||
QIOTask *task = qio_task_new(
|
QIOTask *task = qio_task_new(
|
||||||
OBJECT(ioc), callback, opaque, destroy);
|
OBJECT(ioc), callback, opaque, destroy);
|
||||||
SocketAddress *addrCopy;
|
SocketAddressLegacy *addrCopy;
|
||||||
|
|
||||||
addrCopy = QAPI_CLONE(SocketAddress, addr);
|
addrCopy = QAPI_CLONE(SocketAddressLegacy, addr);
|
||||||
|
|
||||||
/* socket_listen() blocks in DNS lookups, so we must use a thread */
|
/* socket_listen() blocks in DNS lookups, so we must use a thread */
|
||||||
trace_qio_channel_socket_listen_async(ioc, addr);
|
trace_qio_channel_socket_listen_async(ioc, addr);
|
||||||
qio_task_run_in_thread(task,
|
qio_task_run_in_thread(task,
|
||||||
qio_channel_socket_listen_worker,
|
qio_channel_socket_listen_worker,
|
||||||
addrCopy,
|
addrCopy,
|
||||||
(GDestroyNotify)qapi_free_SocketAddress);
|
(GDestroyNotify)qapi_free_SocketAddressLegacy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int qio_channel_socket_dgram_sync(QIOChannelSocket *ioc,
|
int qio_channel_socket_dgram_sync(QIOChannelSocket *ioc,
|
||||||
SocketAddress *localAddr,
|
SocketAddressLegacy *localAddr,
|
||||||
SocketAddress *remoteAddr,
|
SocketAddressLegacy *remoteAddr,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
@ -274,16 +274,16 @@ int qio_channel_socket_dgram_sync(QIOChannelSocket *ioc,
|
|||||||
|
|
||||||
|
|
||||||
struct QIOChannelSocketDGramWorkerData {
|
struct QIOChannelSocketDGramWorkerData {
|
||||||
SocketAddress *localAddr;
|
SocketAddressLegacy *localAddr;
|
||||||
SocketAddress *remoteAddr;
|
SocketAddressLegacy *remoteAddr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static void qio_channel_socket_dgram_worker_free(gpointer opaque)
|
static void qio_channel_socket_dgram_worker_free(gpointer opaque)
|
||||||
{
|
{
|
||||||
struct QIOChannelSocketDGramWorkerData *data = opaque;
|
struct QIOChannelSocketDGramWorkerData *data = opaque;
|
||||||
qapi_free_SocketAddress(data->localAddr);
|
qapi_free_SocketAddressLegacy(data->localAddr);
|
||||||
qapi_free_SocketAddress(data->remoteAddr);
|
qapi_free_SocketAddressLegacy(data->remoteAddr);
|
||||||
g_free(data);
|
g_free(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,8 +303,8 @@ static void qio_channel_socket_dgram_worker(QIOTask *task,
|
|||||||
|
|
||||||
|
|
||||||
void qio_channel_socket_dgram_async(QIOChannelSocket *ioc,
|
void qio_channel_socket_dgram_async(QIOChannelSocket *ioc,
|
||||||
SocketAddress *localAddr,
|
SocketAddressLegacy *localAddr,
|
||||||
SocketAddress *remoteAddr,
|
SocketAddressLegacy *remoteAddr,
|
||||||
QIOTaskFunc callback,
|
QIOTaskFunc callback,
|
||||||
gpointer opaque,
|
gpointer opaque,
|
||||||
GDestroyNotify destroy)
|
GDestroyNotify destroy)
|
||||||
@ -314,8 +314,8 @@ void qio_channel_socket_dgram_async(QIOChannelSocket *ioc,
|
|||||||
struct QIOChannelSocketDGramWorkerData *data = g_new0(
|
struct QIOChannelSocketDGramWorkerData *data = g_new0(
|
||||||
struct QIOChannelSocketDGramWorkerData, 1);
|
struct QIOChannelSocketDGramWorkerData, 1);
|
||||||
|
|
||||||
data->localAddr = QAPI_CLONE(SocketAddress, localAddr);
|
data->localAddr = QAPI_CLONE(SocketAddressLegacy, localAddr);
|
||||||
data->remoteAddr = QAPI_CLONE(SocketAddress, remoteAddr);
|
data->remoteAddr = QAPI_CLONE(SocketAddressLegacy, remoteAddr);
|
||||||
|
|
||||||
trace_qio_channel_socket_dgram_async(ioc, localAddr, remoteAddr);
|
trace_qio_channel_socket_dgram_async(ioc, localAddr, remoteAddr);
|
||||||
qio_task_run_in_thread(task,
|
qio_task_run_in_thread(task,
|
||||||
|
@ -45,9 +45,9 @@ QIODNSResolver *qio_dns_resolver_get_instance(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int qio_dns_resolver_lookup_sync_inet(QIODNSResolver *resolver,
|
static int qio_dns_resolver_lookup_sync_inet(QIODNSResolver *resolver,
|
||||||
SocketAddress *addr,
|
SocketAddressLegacy *addr,
|
||||||
size_t *naddrs,
|
size_t *naddrs,
|
||||||
SocketAddress ***addrs,
|
SocketAddressLegacy ***addrs,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
struct addrinfo ai, *res, *e;
|
struct addrinfo ai, *res, *e;
|
||||||
@ -97,14 +97,14 @@ static int qio_dns_resolver_lookup_sync_inet(QIODNSResolver *resolver,
|
|||||||
(*naddrs)++;
|
(*naddrs)++;
|
||||||
}
|
}
|
||||||
|
|
||||||
*addrs = g_new0(SocketAddress *, *naddrs);
|
*addrs = g_new0(SocketAddressLegacy *, *naddrs);
|
||||||
|
|
||||||
/* create socket + bind */
|
/* create socket + bind */
|
||||||
for (i = 0, e = res; e != NULL; i++, e = e->ai_next) {
|
for (i = 0, e = res; e != NULL; i++, e = e->ai_next) {
|
||||||
SocketAddress *newaddr = g_new0(SocketAddress, 1);
|
SocketAddressLegacy *newaddr = g_new0(SocketAddressLegacy, 1);
|
||||||
InetSocketAddress *newiaddr = g_new0(InetSocketAddress, 1);
|
InetSocketAddress *newiaddr = g_new0(InetSocketAddress, 1);
|
||||||
newaddr->u.inet.data = newiaddr;
|
newaddr->u.inet.data = newiaddr;
|
||||||
newaddr->type = SOCKET_ADDRESS_KIND_INET;
|
newaddr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
|
||||||
|
|
||||||
getnameinfo((struct sockaddr *)e->ai_addr, e->ai_addrlen,
|
getnameinfo((struct sockaddr *)e->ai_addr, e->ai_addrlen,
|
||||||
uaddr, INET6_ADDRSTRLEN, uport, 32,
|
uaddr, INET6_ADDRSTRLEN, uport, 32,
|
||||||
@ -129,36 +129,36 @@ static int qio_dns_resolver_lookup_sync_inet(QIODNSResolver *resolver,
|
|||||||
|
|
||||||
|
|
||||||
static int qio_dns_resolver_lookup_sync_nop(QIODNSResolver *resolver,
|
static int qio_dns_resolver_lookup_sync_nop(QIODNSResolver *resolver,
|
||||||
SocketAddress *addr,
|
SocketAddressLegacy *addr,
|
||||||
size_t *naddrs,
|
size_t *naddrs,
|
||||||
SocketAddress ***addrs,
|
SocketAddressLegacy ***addrs,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
*naddrs = 1;
|
*naddrs = 1;
|
||||||
*addrs = g_new0(SocketAddress *, 1);
|
*addrs = g_new0(SocketAddressLegacy *, 1);
|
||||||
(*addrs)[0] = QAPI_CLONE(SocketAddress, addr);
|
(*addrs)[0] = QAPI_CLONE(SocketAddressLegacy, addr);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int qio_dns_resolver_lookup_sync(QIODNSResolver *resolver,
|
int qio_dns_resolver_lookup_sync(QIODNSResolver *resolver,
|
||||||
SocketAddress *addr,
|
SocketAddressLegacy *addr,
|
||||||
size_t *naddrs,
|
size_t *naddrs,
|
||||||
SocketAddress ***addrs,
|
SocketAddressLegacy ***addrs,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
switch (addr->type) {
|
switch (addr->type) {
|
||||||
case SOCKET_ADDRESS_KIND_INET:
|
case SOCKET_ADDRESS_LEGACY_KIND_INET:
|
||||||
return qio_dns_resolver_lookup_sync_inet(resolver,
|
return qio_dns_resolver_lookup_sync_inet(resolver,
|
||||||
addr,
|
addr,
|
||||||
naddrs,
|
naddrs,
|
||||||
addrs,
|
addrs,
|
||||||
errp);
|
errp);
|
||||||
|
|
||||||
case SOCKET_ADDRESS_KIND_UNIX:
|
case SOCKET_ADDRESS_LEGACY_KIND_UNIX:
|
||||||
case SOCKET_ADDRESS_KIND_VSOCK:
|
case SOCKET_ADDRESS_LEGACY_KIND_VSOCK:
|
||||||
case SOCKET_ADDRESS_KIND_FD:
|
case SOCKET_ADDRESS_LEGACY_KIND_FD:
|
||||||
return qio_dns_resolver_lookup_sync_nop(resolver,
|
return qio_dns_resolver_lookup_sync_nop(resolver,
|
||||||
addr,
|
addr,
|
||||||
naddrs,
|
naddrs,
|
||||||
@ -172,8 +172,8 @@ int qio_dns_resolver_lookup_sync(QIODNSResolver *resolver,
|
|||||||
|
|
||||||
|
|
||||||
struct QIODNSResolverLookupData {
|
struct QIODNSResolverLookupData {
|
||||||
SocketAddress *addr;
|
SocketAddressLegacy *addr;
|
||||||
SocketAddress **addrs;
|
SocketAddressLegacy **addrs;
|
||||||
size_t naddrs;
|
size_t naddrs;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -183,9 +183,9 @@ static void qio_dns_resolver_lookup_data_free(gpointer opaque)
|
|||||||
struct QIODNSResolverLookupData *data = opaque;
|
struct QIODNSResolverLookupData *data = opaque;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
qapi_free_SocketAddress(data->addr);
|
qapi_free_SocketAddressLegacy(data->addr);
|
||||||
for (i = 0; i < data->naddrs; i++) {
|
for (i = 0; i < data->naddrs; i++) {
|
||||||
qapi_free_SocketAddress(data->addrs[i]);
|
qapi_free_SocketAddressLegacy(data->addrs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(data->addrs);
|
g_free(data->addrs);
|
||||||
@ -216,7 +216,7 @@ static void qio_dns_resolver_lookup_worker(QIOTask *task,
|
|||||||
|
|
||||||
|
|
||||||
void qio_dns_resolver_lookup_async(QIODNSResolver *resolver,
|
void qio_dns_resolver_lookup_async(QIODNSResolver *resolver,
|
||||||
SocketAddress *addr,
|
SocketAddressLegacy *addr,
|
||||||
QIOTaskFunc func,
|
QIOTaskFunc func,
|
||||||
gpointer opaque,
|
gpointer opaque,
|
||||||
GDestroyNotify notify)
|
GDestroyNotify notify)
|
||||||
@ -225,7 +225,7 @@ void qio_dns_resolver_lookup_async(QIODNSResolver *resolver,
|
|||||||
struct QIODNSResolverLookupData *data =
|
struct QIODNSResolverLookupData *data =
|
||||||
g_new0(struct QIODNSResolverLookupData, 1);
|
g_new0(struct QIODNSResolverLookupData, 1);
|
||||||
|
|
||||||
data->addr = QAPI_CLONE(SocketAddress, addr);
|
data->addr = QAPI_CLONE(SocketAddressLegacy, addr);
|
||||||
|
|
||||||
task = qio_task_new(OBJECT(resolver), func, opaque, notify);
|
task = qio_task_new(OBJECT(resolver), func, opaque, notify);
|
||||||
|
|
||||||
@ -239,7 +239,7 @@ void qio_dns_resolver_lookup_async(QIODNSResolver *resolver,
|
|||||||
void qio_dns_resolver_lookup_result(QIODNSResolver *resolver,
|
void qio_dns_resolver_lookup_result(QIODNSResolver *resolver,
|
||||||
QIOTask *task,
|
QIOTask *task,
|
||||||
size_t *naddrs,
|
size_t *naddrs,
|
||||||
SocketAddress ***addrs)
|
SocketAddressLegacy ***addrs)
|
||||||
{
|
{
|
||||||
struct QIODNSResolverLookupData *data =
|
struct QIODNSResolverLookupData *data =
|
||||||
qio_task_get_result_pointer(task);
|
qio_task_get_result_pointer(task);
|
||||||
@ -252,9 +252,9 @@ void qio_dns_resolver_lookup_result(QIODNSResolver *resolver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
*naddrs = data->naddrs;
|
*naddrs = data->naddrs;
|
||||||
*addrs = g_new0(SocketAddress *, data->naddrs);
|
*addrs = g_new0(SocketAddressLegacy *, data->naddrs);
|
||||||
for (i = 0; i < data->naddrs; i++) {
|
for (i = 0; i < data->naddrs; i++) {
|
||||||
(*addrs)[i] = QAPI_CLONE(SocketAddress, data->addrs[i]);
|
(*addrs)[i] = QAPI_CLONE(SocketAddressLegacy, data->addrs[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,30 +25,30 @@
|
|||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
|
||||||
|
|
||||||
static SocketAddress *tcp_build_address(const char *host_port, Error **errp)
|
static SocketAddressLegacy *tcp_build_address(const char *host_port, Error **errp)
|
||||||
{
|
{
|
||||||
InetSocketAddress *iaddr = g_new(InetSocketAddress, 1);
|
InetSocketAddress *iaddr = g_new(InetSocketAddress, 1);
|
||||||
SocketAddress *saddr;
|
SocketAddressLegacy *saddr;
|
||||||
|
|
||||||
if (inet_parse(iaddr, host_port, errp)) {
|
if (inet_parse(iaddr, host_port, errp)) {
|
||||||
qapi_free_InetSocketAddress(iaddr);
|
qapi_free_InetSocketAddress(iaddr);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
saddr = g_new0(SocketAddress, 1);
|
saddr = g_new0(SocketAddressLegacy, 1);
|
||||||
saddr->type = SOCKET_ADDRESS_KIND_INET;
|
saddr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
|
||||||
saddr->u.inet.data = iaddr;
|
saddr->u.inet.data = iaddr;
|
||||||
|
|
||||||
return saddr;
|
return saddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static SocketAddress *unix_build_address(const char *path)
|
static SocketAddressLegacy *unix_build_address(const char *path)
|
||||||
{
|
{
|
||||||
SocketAddress *saddr;
|
SocketAddressLegacy *saddr;
|
||||||
|
|
||||||
saddr = g_new0(SocketAddress, 1);
|
saddr = g_new0(SocketAddressLegacy, 1);
|
||||||
saddr->type = SOCKET_ADDRESS_KIND_UNIX;
|
saddr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
|
||||||
saddr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
|
saddr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
|
||||||
saddr->u.q_unix.data->path = g_strdup(path);
|
saddr->u.q_unix.data->path = g_strdup(path);
|
||||||
|
|
||||||
@ -90,14 +90,14 @@ static void socket_outgoing_migration(QIOTask *task,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void socket_start_outgoing_migration(MigrationState *s,
|
static void socket_start_outgoing_migration(MigrationState *s,
|
||||||
SocketAddress *saddr,
|
SocketAddressLegacy *saddr,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
QIOChannelSocket *sioc = qio_channel_socket_new();
|
QIOChannelSocket *sioc = qio_channel_socket_new();
|
||||||
struct SocketConnectData *data = g_new0(struct SocketConnectData, 1);
|
struct SocketConnectData *data = g_new0(struct SocketConnectData, 1);
|
||||||
|
|
||||||
data->s = s;
|
data->s = s;
|
||||||
if (saddr->type == SOCKET_ADDRESS_KIND_INET) {
|
if (saddr->type == SOCKET_ADDRESS_LEGACY_KIND_INET) {
|
||||||
data->hostname = g_strdup(saddr->u.inet.data->host);
|
data->hostname = g_strdup(saddr->u.inet.data->host);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ static void socket_start_outgoing_migration(MigrationState *s,
|
|||||||
socket_outgoing_migration,
|
socket_outgoing_migration,
|
||||||
data,
|
data,
|
||||||
socket_connect_data_free);
|
socket_connect_data_free);
|
||||||
qapi_free_SocketAddress(saddr);
|
qapi_free_SocketAddressLegacy(saddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tcp_start_outgoing_migration(MigrationState *s,
|
void tcp_start_outgoing_migration(MigrationState *s,
|
||||||
@ -115,7 +115,7 @@ void tcp_start_outgoing_migration(MigrationState *s,
|
|||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
SocketAddress *saddr = tcp_build_address(host_port, &err);
|
SocketAddressLegacy *saddr = tcp_build_address(host_port, &err);
|
||||||
if (!err) {
|
if (!err) {
|
||||||
socket_start_outgoing_migration(s, saddr, &err);
|
socket_start_outgoing_migration(s, saddr, &err);
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ void unix_start_outgoing_migration(MigrationState *s,
|
|||||||
const char *path,
|
const char *path,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
SocketAddress *saddr = unix_build_address(path);
|
SocketAddressLegacy *saddr = unix_build_address(path);
|
||||||
socket_start_outgoing_migration(s, saddr, errp);
|
socket_start_outgoing_migration(s, saddr, errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void socket_start_incoming_migration(SocketAddress *saddr,
|
static void socket_start_incoming_migration(SocketAddressLegacy *saddr,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
QIOChannelSocket *listen_ioc = qio_channel_socket_new();
|
QIOChannelSocket *listen_ioc = qio_channel_socket_new();
|
||||||
@ -170,7 +170,7 @@ static void socket_start_incoming_migration(SocketAddress *saddr,
|
|||||||
|
|
||||||
if (qio_channel_socket_listen_sync(listen_ioc, saddr, errp) < 0) {
|
if (qio_channel_socket_listen_sync(listen_ioc, saddr, errp) < 0) {
|
||||||
object_unref(OBJECT(listen_ioc));
|
object_unref(OBJECT(listen_ioc));
|
||||||
qapi_free_SocketAddress(saddr);
|
qapi_free_SocketAddressLegacy(saddr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,13 +179,13 @@ static void socket_start_incoming_migration(SocketAddress *saddr,
|
|||||||
socket_accept_incoming_migration,
|
socket_accept_incoming_migration,
|
||||||
listen_ioc,
|
listen_ioc,
|
||||||
(GDestroyNotify)object_unref);
|
(GDestroyNotify)object_unref);
|
||||||
qapi_free_SocketAddress(saddr);
|
qapi_free_SocketAddressLegacy(saddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tcp_start_incoming_migration(const char *host_port, Error **errp)
|
void tcp_start_incoming_migration(const char *host_port, Error **errp)
|
||||||
{
|
{
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
SocketAddress *saddr = tcp_build_address(host_port, &err);
|
SocketAddressLegacy *saddr = tcp_build_address(host_port, &err);
|
||||||
if (!err) {
|
if (!err) {
|
||||||
socket_start_incoming_migration(saddr, &err);
|
socket_start_incoming_migration(saddr, &err);
|
||||||
}
|
}
|
||||||
@ -194,6 +194,6 @@ void tcp_start_incoming_migration(const char *host_port, Error **errp)
|
|||||||
|
|
||||||
void unix_start_incoming_migration(const char *path, Error **errp)
|
void unix_start_incoming_migration(const char *path, Error **errp)
|
||||||
{
|
{
|
||||||
SocketAddress *saddr = unix_build_address(path);
|
SocketAddressLegacy *saddr = unix_build_address(path);
|
||||||
socket_start_incoming_migration(saddr, errp);
|
socket_start_incoming_migration(saddr, errp);
|
||||||
}
|
}
|
||||||
|
10
net/socket.c
10
net/socket.c
@ -489,7 +489,7 @@ static int net_socket_listen_init(NetClientState *peer,
|
|||||||
{
|
{
|
||||||
NetClientState *nc;
|
NetClientState *nc;
|
||||||
NetSocketState *s;
|
NetSocketState *s;
|
||||||
SocketAddress *saddr;
|
SocketAddressLegacy *saddr;
|
||||||
int ret;
|
int ret;
|
||||||
Error *local_error = NULL;
|
Error *local_error = NULL;
|
||||||
|
|
||||||
@ -501,7 +501,7 @@ static int net_socket_listen_init(NetClientState *peer,
|
|||||||
|
|
||||||
ret = socket_listen(saddr, &local_error);
|
ret = socket_listen(saddr, &local_error);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
qapi_free_SocketAddress(saddr);
|
qapi_free_SocketAddressLegacy(saddr);
|
||||||
error_report_err(local_error);
|
error_report_err(local_error);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -514,20 +514,20 @@ static int net_socket_listen_init(NetClientState *peer,
|
|||||||
net_socket_rs_init(&s->rs, net_socket_rs_finalize);
|
net_socket_rs_init(&s->rs, net_socket_rs_finalize);
|
||||||
|
|
||||||
qemu_set_fd_handler(s->listen_fd, net_socket_accept, NULL, s);
|
qemu_set_fd_handler(s->listen_fd, net_socket_accept, NULL, s);
|
||||||
qapi_free_SocketAddress(saddr);
|
qapi_free_SocketAddressLegacy(saddr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
NetClientState *peer;
|
NetClientState *peer;
|
||||||
SocketAddress *saddr;
|
SocketAddressLegacy *saddr;
|
||||||
char *model;
|
char *model;
|
||||||
char *name;
|
char *name;
|
||||||
} socket_connect_data;
|
} socket_connect_data;
|
||||||
|
|
||||||
static void socket_connect_data_free(socket_connect_data *c)
|
static void socket_connect_data_free(socket_connect_data *c)
|
||||||
{
|
{
|
||||||
qapi_free_SocketAddress(c->saddr);
|
qapi_free_SocketAddressLegacy(c->saddr);
|
||||||
g_free(c->model);
|
g_free(c->model);
|
||||||
g_free(c->name);
|
g_free(c->name);
|
||||||
g_free(c);
|
g_free(c);
|
||||||
|
@ -4122,13 +4122,15 @@
|
|||||||
'port': 'str' } }
|
'port': 'str' } }
|
||||||
|
|
||||||
##
|
##
|
||||||
# @SocketAddress:
|
# @SocketAddressLegacy:
|
||||||
#
|
#
|
||||||
# Captures the address of a socket, which could also be a named file descriptor
|
# Captures the address of a socket, which could also be a named file descriptor
|
||||||
#
|
#
|
||||||
|
# Note: This type is deprecated in favor of SocketAddressFlat.
|
||||||
|
#
|
||||||
# Since: 1.3
|
# Since: 1.3
|
||||||
##
|
##
|
||||||
{ 'union': 'SocketAddress',
|
{ 'union': 'SocketAddressLegacy',
|
||||||
'data': {
|
'data': {
|
||||||
'inet': 'InetSocketAddress',
|
'inet': 'InetSocketAddress',
|
||||||
'unix': 'UnixSocketAddress',
|
'unix': 'UnixSocketAddress',
|
||||||
@ -4156,7 +4158,7 @@
|
|||||||
#
|
#
|
||||||
# @type: Transport type
|
# @type: Transport type
|
||||||
#
|
#
|
||||||
# This is just like SocketAddress, except it's a flat union rather
|
# This is just like SocketAddressLegacy, except it's a flat union rather
|
||||||
# than a simple union. Nicer because it avoids nesting on the wire,
|
# than a simple union. Nicer because it avoids nesting on the wire,
|
||||||
# i.e. this form has fewer {}.
|
# i.e. this form has fewer {}.
|
||||||
#
|
#
|
||||||
@ -4886,7 +4888,7 @@
|
|||||||
#
|
#
|
||||||
# Since: 1.4
|
# Since: 1.4
|
||||||
##
|
##
|
||||||
{ 'struct': 'ChardevSocket', 'data': { 'addr' : 'SocketAddress',
|
{ 'struct': 'ChardevSocket', 'data': { 'addr' : 'SocketAddressLegacy',
|
||||||
'*tls-creds' : 'str',
|
'*tls-creds' : 'str',
|
||||||
'*server' : 'bool',
|
'*server' : 'bool',
|
||||||
'*wait' : 'bool',
|
'*wait' : 'bool',
|
||||||
@ -4906,8 +4908,8 @@
|
|||||||
#
|
#
|
||||||
# Since: 1.5
|
# Since: 1.5
|
||||||
##
|
##
|
||||||
{ 'struct': 'ChardevUdp', 'data': { 'remote' : 'SocketAddress',
|
{ 'struct': 'ChardevUdp', 'data': { 'remote' : 'SocketAddressLegacy',
|
||||||
'*local' : 'SocketAddress' },
|
'*local' : 'SocketAddressLegacy' },
|
||||||
'base': 'ChardevCommon' }
|
'base': 'ChardevCommon' }
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -204,7 +204,7 @@
|
|||||||
# Since: 1.3.0
|
# Since: 1.3.0
|
||||||
##
|
##
|
||||||
{ 'command': 'nbd-server-start',
|
{ 'command': 'nbd-server-start',
|
||||||
'data': { 'addr': 'SocketAddress',
|
'data': { 'addr': 'SocketAddressLegacy',
|
||||||
'*tls-creds': 'str'} }
|
'*tls-creds': 'str'} }
|
||||||
|
|
||||||
##
|
##
|
||||||
|
12
qemu-nbd.c
12
qemu-nbd.c
@ -57,7 +57,7 @@ static NBDExport *exp;
|
|||||||
static bool newproto;
|
static bool newproto;
|
||||||
static int verbose;
|
static int verbose;
|
||||||
static char *srcpath;
|
static char *srcpath;
|
||||||
static SocketAddress *saddr;
|
static SocketAddressLegacy *saddr;
|
||||||
static int persistent = 0;
|
static int persistent = 0;
|
||||||
static enum { RUNNING, TERMINATE, TERMINATING, TERMINATED } state;
|
static enum { RUNNING, TERMINATE, TERMINATING, TERMINATED } state;
|
||||||
static int shared = 1;
|
static int shared = 1;
|
||||||
@ -387,20 +387,20 @@ static void nbd_update_server_watch(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static SocketAddress *nbd_build_socket_address(const char *sockpath,
|
static SocketAddressLegacy *nbd_build_socket_address(const char *sockpath,
|
||||||
const char *bindto,
|
const char *bindto,
|
||||||
const char *port)
|
const char *port)
|
||||||
{
|
{
|
||||||
SocketAddress *saddr;
|
SocketAddressLegacy *saddr;
|
||||||
|
|
||||||
saddr = g_new0(SocketAddress, 1);
|
saddr = g_new0(SocketAddressLegacy, 1);
|
||||||
if (sockpath) {
|
if (sockpath) {
|
||||||
saddr->type = SOCKET_ADDRESS_KIND_UNIX;
|
saddr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
|
||||||
saddr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
|
saddr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
|
||||||
saddr->u.q_unix.data->path = g_strdup(sockpath);
|
saddr->u.q_unix.data->path = g_strdup(sockpath);
|
||||||
} else {
|
} else {
|
||||||
InetSocketAddress *inet;
|
InetSocketAddress *inet;
|
||||||
saddr->type = SOCKET_ADDRESS_KIND_INET;
|
saddr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
|
||||||
inet = saddr->u.inet.data = g_new0(InetSocketAddress, 1);
|
inet = saddr->u.inet.data = g_new0(InetSocketAddress, 1);
|
||||||
inet->host = g_strdup(bindto);
|
inet->host = g_strdup(bindto);
|
||||||
if (port) {
|
if (port) {
|
||||||
|
@ -203,7 +203,7 @@ static gboolean ga_channel_open(GAChannel *c, const gchar *path,
|
|||||||
case GA_CHANNEL_VSOCK_LISTEN: {
|
case GA_CHANNEL_VSOCK_LISTEN: {
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
SocketAddress *addr;
|
SocketAddressLegacy *addr;
|
||||||
char *addr_str;
|
char *addr_str;
|
||||||
|
|
||||||
addr_str = g_strdup_printf("vsock:%s", path);
|
addr_str = g_strdup_printf("vsock:%s", path);
|
||||||
@ -216,7 +216,7 @@ static gboolean ga_channel_open(GAChannel *c, const gchar *path,
|
|||||||
}
|
}
|
||||||
|
|
||||||
fd = socket_listen(addr, &local_err);
|
fd = socket_listen(addr, &local_err);
|
||||||
qapi_free_SocketAddress(addr);
|
qapi_free_SocketAddressLegacy(addr);
|
||||||
if (local_err != NULL) {
|
if (local_err != NULL) {
|
||||||
g_critical("%s", error_get_pretty(local_err));
|
g_critical("%s", error_get_pretty(local_err));
|
||||||
error_free(local_err);
|
error_free(local_err);
|
||||||
|
@ -1379,7 +1379,7 @@ int main(int argc, char **argv)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
if (socket_activation) {
|
if (socket_activation) {
|
||||||
SocketAddress *addr;
|
SocketAddressLegacy *addr;
|
||||||
|
|
||||||
g_free(config->method);
|
g_free(config->method);
|
||||||
g_free(config->channel_path);
|
g_free(config->channel_path);
|
||||||
@ -1388,13 +1388,13 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
addr = socket_local_address(FIRST_SOCKET_ACTIVATION_FD, NULL);
|
addr = socket_local_address(FIRST_SOCKET_ACTIVATION_FD, NULL);
|
||||||
if (addr) {
|
if (addr) {
|
||||||
if (addr->type == SOCKET_ADDRESS_KIND_UNIX) {
|
if (addr->type == SOCKET_ADDRESS_LEGACY_KIND_UNIX) {
|
||||||
config->method = g_strdup("unix-listen");
|
config->method = g_strdup("unix-listen");
|
||||||
} else if (addr->type == SOCKET_ADDRESS_KIND_VSOCK) {
|
} else if (addr->type == SOCKET_ADDRESS_LEGACY_KIND_VSOCK) {
|
||||||
config->method = g_strdup("vsock-listen");
|
config->method = g_strdup("vsock-listen");
|
||||||
}
|
}
|
||||||
|
|
||||||
qapi_free_SocketAddress(addr);
|
qapi_free_SocketAddressLegacy(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config->method) {
|
if (!config->method) {
|
||||||
|
@ -115,8 +115,8 @@ static void test_io_channel_set_socket_bufs(QIOChannel *src,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void test_io_channel_setup_sync(SocketAddress *listen_addr,
|
static void test_io_channel_setup_sync(SocketAddressLegacy *listen_addr,
|
||||||
SocketAddress *connect_addr,
|
SocketAddressLegacy *connect_addr,
|
||||||
QIOChannel **src,
|
QIOChannel **src,
|
||||||
QIOChannel **dst)
|
QIOChannel **dst)
|
||||||
{
|
{
|
||||||
@ -125,14 +125,14 @@ static void test_io_channel_setup_sync(SocketAddress *listen_addr,
|
|||||||
lioc = qio_channel_socket_new();
|
lioc = qio_channel_socket_new();
|
||||||
qio_channel_socket_listen_sync(lioc, listen_addr, &error_abort);
|
qio_channel_socket_listen_sync(lioc, listen_addr, &error_abort);
|
||||||
|
|
||||||
if (listen_addr->type == SOCKET_ADDRESS_KIND_INET) {
|
if (listen_addr->type == SOCKET_ADDRESS_LEGACY_KIND_INET) {
|
||||||
SocketAddress *laddr = qio_channel_socket_get_local_address(
|
SocketAddressLegacy *laddr = qio_channel_socket_get_local_address(
|
||||||
lioc, &error_abort);
|
lioc, &error_abort);
|
||||||
|
|
||||||
g_free(connect_addr->u.inet.data->port);
|
g_free(connect_addr->u.inet.data->port);
|
||||||
connect_addr->u.inet.data->port = g_strdup(laddr->u.inet.data->port);
|
connect_addr->u.inet.data->port = g_strdup(laddr->u.inet.data->port);
|
||||||
|
|
||||||
qapi_free_SocketAddress(laddr);
|
qapi_free_SocketAddressLegacy(laddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
*src = QIO_CHANNEL(qio_channel_socket_new());
|
*src = QIO_CHANNEL(qio_channel_socket_new());
|
||||||
@ -165,8 +165,8 @@ static void test_io_channel_complete(QIOTask *task,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void test_io_channel_setup_async(SocketAddress *listen_addr,
|
static void test_io_channel_setup_async(SocketAddressLegacy *listen_addr,
|
||||||
SocketAddress *connect_addr,
|
SocketAddressLegacy *connect_addr,
|
||||||
QIOChannel **src,
|
QIOChannel **src,
|
||||||
QIOChannel **dst)
|
QIOChannel **dst)
|
||||||
{
|
{
|
||||||
@ -186,14 +186,14 @@ static void test_io_channel_setup_async(SocketAddress *listen_addr,
|
|||||||
|
|
||||||
g_assert(!data.err);
|
g_assert(!data.err);
|
||||||
|
|
||||||
if (listen_addr->type == SOCKET_ADDRESS_KIND_INET) {
|
if (listen_addr->type == SOCKET_ADDRESS_LEGACY_KIND_INET) {
|
||||||
SocketAddress *laddr = qio_channel_socket_get_local_address(
|
SocketAddressLegacy *laddr = qio_channel_socket_get_local_address(
|
||||||
lioc, &error_abort);
|
lioc, &error_abort);
|
||||||
|
|
||||||
g_free(connect_addr->u.inet.data->port);
|
g_free(connect_addr->u.inet.data->port);
|
||||||
connect_addr->u.inet.data->port = g_strdup(laddr->u.inet.data->port);
|
connect_addr->u.inet.data->port = g_strdup(laddr->u.inet.data->port);
|
||||||
|
|
||||||
qapi_free_SocketAddress(laddr);
|
qapi_free_SocketAddressLegacy(laddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
*src = QIO_CHANNEL(qio_channel_socket_new());
|
*src = QIO_CHANNEL(qio_channel_socket_new());
|
||||||
@ -221,8 +221,8 @@ static void test_io_channel_setup_async(SocketAddress *listen_addr,
|
|||||||
|
|
||||||
|
|
||||||
static void test_io_channel(bool async,
|
static void test_io_channel(bool async,
|
||||||
SocketAddress *listen_addr,
|
SocketAddressLegacy *listen_addr,
|
||||||
SocketAddress *connect_addr,
|
SocketAddressLegacy *connect_addr,
|
||||||
bool passFD)
|
bool passFD)
|
||||||
{
|
{
|
||||||
QIOChannel *src, *dst;
|
QIOChannel *src, *dst;
|
||||||
@ -297,17 +297,17 @@ static void test_io_channel(bool async,
|
|||||||
|
|
||||||
static void test_io_channel_ipv4(bool async)
|
static void test_io_channel_ipv4(bool async)
|
||||||
{
|
{
|
||||||
SocketAddress *listen_addr = g_new0(SocketAddress, 1);
|
SocketAddressLegacy *listen_addr = g_new0(SocketAddressLegacy, 1);
|
||||||
SocketAddress *connect_addr = g_new0(SocketAddress, 1);
|
SocketAddressLegacy *connect_addr = g_new0(SocketAddressLegacy, 1);
|
||||||
|
|
||||||
listen_addr->type = SOCKET_ADDRESS_KIND_INET;
|
listen_addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
|
||||||
listen_addr->u.inet.data = g_new(InetSocketAddress, 1);
|
listen_addr->u.inet.data = g_new(InetSocketAddress, 1);
|
||||||
*listen_addr->u.inet.data = (InetSocketAddress) {
|
*listen_addr->u.inet.data = (InetSocketAddress) {
|
||||||
.host = g_strdup("127.0.0.1"),
|
.host = g_strdup("127.0.0.1"),
|
||||||
.port = NULL, /* Auto-select */
|
.port = NULL, /* Auto-select */
|
||||||
};
|
};
|
||||||
|
|
||||||
connect_addr->type = SOCKET_ADDRESS_KIND_INET;
|
connect_addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
|
||||||
connect_addr->u.inet.data = g_new(InetSocketAddress, 1);
|
connect_addr->u.inet.data = g_new(InetSocketAddress, 1);
|
||||||
*connect_addr->u.inet.data = (InetSocketAddress) {
|
*connect_addr->u.inet.data = (InetSocketAddress) {
|
||||||
.host = g_strdup("127.0.0.1"),
|
.host = g_strdup("127.0.0.1"),
|
||||||
@ -316,8 +316,8 @@ static void test_io_channel_ipv4(bool async)
|
|||||||
|
|
||||||
test_io_channel(async, listen_addr, connect_addr, false);
|
test_io_channel(async, listen_addr, connect_addr, false);
|
||||||
|
|
||||||
qapi_free_SocketAddress(listen_addr);
|
qapi_free_SocketAddressLegacy(listen_addr);
|
||||||
qapi_free_SocketAddress(connect_addr);
|
qapi_free_SocketAddressLegacy(connect_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -335,17 +335,17 @@ static void test_io_channel_ipv4_async(void)
|
|||||||
|
|
||||||
static void test_io_channel_ipv6(bool async)
|
static void test_io_channel_ipv6(bool async)
|
||||||
{
|
{
|
||||||
SocketAddress *listen_addr = g_new0(SocketAddress, 1);
|
SocketAddressLegacy *listen_addr = g_new0(SocketAddressLegacy, 1);
|
||||||
SocketAddress *connect_addr = g_new0(SocketAddress, 1);
|
SocketAddressLegacy *connect_addr = g_new0(SocketAddressLegacy, 1);
|
||||||
|
|
||||||
listen_addr->type = SOCKET_ADDRESS_KIND_INET;
|
listen_addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
|
||||||
listen_addr->u.inet.data = g_new(InetSocketAddress, 1);
|
listen_addr->u.inet.data = g_new(InetSocketAddress, 1);
|
||||||
*listen_addr->u.inet.data = (InetSocketAddress) {
|
*listen_addr->u.inet.data = (InetSocketAddress) {
|
||||||
.host = g_strdup("::1"),
|
.host = g_strdup("::1"),
|
||||||
.port = NULL, /* Auto-select */
|
.port = NULL, /* Auto-select */
|
||||||
};
|
};
|
||||||
|
|
||||||
connect_addr->type = SOCKET_ADDRESS_KIND_INET;
|
connect_addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
|
||||||
connect_addr->u.inet.data = g_new(InetSocketAddress, 1);
|
connect_addr->u.inet.data = g_new(InetSocketAddress, 1);
|
||||||
*connect_addr->u.inet.data = (InetSocketAddress) {
|
*connect_addr->u.inet.data = (InetSocketAddress) {
|
||||||
.host = g_strdup("::1"),
|
.host = g_strdup("::1"),
|
||||||
@ -354,8 +354,8 @@ static void test_io_channel_ipv6(bool async)
|
|||||||
|
|
||||||
test_io_channel(async, listen_addr, connect_addr, false);
|
test_io_channel(async, listen_addr, connect_addr, false);
|
||||||
|
|
||||||
qapi_free_SocketAddress(listen_addr);
|
qapi_free_SocketAddressLegacy(listen_addr);
|
||||||
qapi_free_SocketAddress(connect_addr);
|
qapi_free_SocketAddressLegacy(connect_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -374,22 +374,22 @@ static void test_io_channel_ipv6_async(void)
|
|||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
static void test_io_channel_unix(bool async)
|
static void test_io_channel_unix(bool async)
|
||||||
{
|
{
|
||||||
SocketAddress *listen_addr = g_new0(SocketAddress, 1);
|
SocketAddressLegacy *listen_addr = g_new0(SocketAddressLegacy, 1);
|
||||||
SocketAddress *connect_addr = g_new0(SocketAddress, 1);
|
SocketAddressLegacy *connect_addr = g_new0(SocketAddressLegacy, 1);
|
||||||
|
|
||||||
#define TEST_SOCKET "test-io-channel-socket.sock"
|
#define TEST_SOCKET "test-io-channel-socket.sock"
|
||||||
listen_addr->type = SOCKET_ADDRESS_KIND_UNIX;
|
listen_addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
|
||||||
listen_addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
|
listen_addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
|
||||||
listen_addr->u.q_unix.data->path = g_strdup(TEST_SOCKET);
|
listen_addr->u.q_unix.data->path = g_strdup(TEST_SOCKET);
|
||||||
|
|
||||||
connect_addr->type = SOCKET_ADDRESS_KIND_UNIX;
|
connect_addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
|
||||||
connect_addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
|
connect_addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
|
||||||
connect_addr->u.q_unix.data->path = g_strdup(TEST_SOCKET);
|
connect_addr->u.q_unix.data->path = g_strdup(TEST_SOCKET);
|
||||||
|
|
||||||
test_io_channel(async, listen_addr, connect_addr, true);
|
test_io_channel(async, listen_addr, connect_addr, true);
|
||||||
|
|
||||||
qapi_free_SocketAddress(listen_addr);
|
qapi_free_SocketAddressLegacy(listen_addr);
|
||||||
qapi_free_SocketAddress(connect_addr);
|
qapi_free_SocketAddressLegacy(connect_addr);
|
||||||
g_assert(g_file_test(TEST_SOCKET, G_FILE_TEST_EXISTS) == FALSE);
|
g_assert(g_file_test(TEST_SOCKET, G_FILE_TEST_EXISTS) == FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -407,8 +407,8 @@ static void test_io_channel_unix_async(void)
|
|||||||
|
|
||||||
static void test_io_channel_unix_fd_pass(void)
|
static void test_io_channel_unix_fd_pass(void)
|
||||||
{
|
{
|
||||||
SocketAddress *listen_addr = g_new0(SocketAddress, 1);
|
SocketAddressLegacy *listen_addr = g_new0(SocketAddressLegacy, 1);
|
||||||
SocketAddress *connect_addr = g_new0(SocketAddress, 1);
|
SocketAddressLegacy *connect_addr = g_new0(SocketAddressLegacy, 1);
|
||||||
QIOChannel *src, *dst;
|
QIOChannel *src, *dst;
|
||||||
int testfd;
|
int testfd;
|
||||||
int fdsend[3];
|
int fdsend[3];
|
||||||
@ -427,11 +427,11 @@ static void test_io_channel_unix_fd_pass(void)
|
|||||||
fdsend[1] = testfd;
|
fdsend[1] = testfd;
|
||||||
fdsend[2] = testfd;
|
fdsend[2] = testfd;
|
||||||
|
|
||||||
listen_addr->type = SOCKET_ADDRESS_KIND_UNIX;
|
listen_addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
|
||||||
listen_addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
|
listen_addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
|
||||||
listen_addr->u.q_unix.data->path = g_strdup(TEST_SOCKET);
|
listen_addr->u.q_unix.data->path = g_strdup(TEST_SOCKET);
|
||||||
|
|
||||||
connect_addr->type = SOCKET_ADDRESS_KIND_UNIX;
|
connect_addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
|
||||||
connect_addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
|
connect_addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
|
||||||
connect_addr->u.q_unix.data->path = g_strdup(TEST_SOCKET);
|
connect_addr->u.q_unix.data->path = g_strdup(TEST_SOCKET);
|
||||||
|
|
||||||
@ -488,8 +488,8 @@ static void test_io_channel_unix_fd_pass(void)
|
|||||||
|
|
||||||
object_unref(OBJECT(src));
|
object_unref(OBJECT(src));
|
||||||
object_unref(OBJECT(dst));
|
object_unref(OBJECT(dst));
|
||||||
qapi_free_SocketAddress(listen_addr);
|
qapi_free_SocketAddressLegacy(listen_addr);
|
||||||
qapi_free_SocketAddress(connect_addr);
|
qapi_free_SocketAddressLegacy(connect_addr);
|
||||||
unlink(TEST_SOCKET);
|
unlink(TEST_SOCKET);
|
||||||
unlink(TEST_FILE);
|
unlink(TEST_FILE);
|
||||||
close(testfd);
|
close(testfd);
|
||||||
|
@ -498,7 +498,7 @@ vnc_socket_ip_addr_string(QIOChannelSocket *ioc,
|
|||||||
bool local,
|
bool local,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
SocketAddress *addr;
|
SocketAddressLegacy *addr;
|
||||||
char *ret;
|
char *ret;
|
||||||
|
|
||||||
if (local) {
|
if (local) {
|
||||||
@ -510,13 +510,13 @@ vnc_socket_ip_addr_string(QIOChannelSocket *ioc,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addr->type != SOCKET_ADDRESS_KIND_INET) {
|
if (addr->type != SOCKET_ADDRESS_LEGACY_KIND_INET) {
|
||||||
error_setg(errp, "Not an inet socket type");
|
error_setg(errp, "Not an inet socket type");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ret = g_strdup_printf("%s;%s", addr->u.inet.data->host,
|
ret = g_strdup_printf("%s;%s", addr->u.inet.data->host,
|
||||||
addr->u.inet.data->port);
|
addr->u.inet.data->port);
|
||||||
qapi_free_SocketAddress(addr);
|
qapi_free_SocketAddressLegacy(addr);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
104
ui/vnc.c
104
ui/vnc.c
@ -108,12 +108,12 @@ static void vnc_set_share_mode(VncState *vs, VncShareMode mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void vnc_init_basic_info(SocketAddress *addr,
|
static void vnc_init_basic_info(SocketAddressLegacy *addr,
|
||||||
VncBasicInfo *info,
|
VncBasicInfo *info,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
switch (addr->type) {
|
switch (addr->type) {
|
||||||
case SOCKET_ADDRESS_KIND_INET:
|
case SOCKET_ADDRESS_LEGACY_KIND_INET:
|
||||||
info->host = g_strdup(addr->u.inet.data->host);
|
info->host = g_strdup(addr->u.inet.data->host);
|
||||||
info->service = g_strdup(addr->u.inet.data->port);
|
info->service = g_strdup(addr->u.inet.data->port);
|
||||||
if (addr->u.inet.data->ipv6) {
|
if (addr->u.inet.data->ipv6) {
|
||||||
@ -123,16 +123,16 @@ static void vnc_init_basic_info(SocketAddress *addr,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SOCKET_ADDRESS_KIND_UNIX:
|
case SOCKET_ADDRESS_LEGACY_KIND_UNIX:
|
||||||
info->host = g_strdup("");
|
info->host = g_strdup("");
|
||||||
info->service = g_strdup(addr->u.q_unix.data->path);
|
info->service = g_strdup(addr->u.q_unix.data->path);
|
||||||
info->family = NETWORK_ADDRESS_FAMILY_UNIX;
|
info->family = NETWORK_ADDRESS_FAMILY_UNIX;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SOCKET_ADDRESS_KIND_VSOCK:
|
case SOCKET_ADDRESS_LEGACY_KIND_VSOCK:
|
||||||
case SOCKET_ADDRESS_KIND_FD:
|
case SOCKET_ADDRESS_LEGACY_KIND_FD:
|
||||||
error_setg(errp, "Unsupported socket address type %s",
|
error_setg(errp, "Unsupported socket address type %s",
|
||||||
SocketAddressKind_lookup[addr->type]);
|
SocketAddressLegacyKind_lookup[addr->type]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
abort();
|
abort();
|
||||||
@ -145,7 +145,7 @@ static void vnc_init_basic_info_from_server_addr(QIOChannelSocket *ioc,
|
|||||||
VncBasicInfo *info,
|
VncBasicInfo *info,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
SocketAddress *addr = NULL;
|
SocketAddressLegacy *addr = NULL;
|
||||||
|
|
||||||
if (!ioc) {
|
if (!ioc) {
|
||||||
error_setg(errp, "No listener socket available");
|
error_setg(errp, "No listener socket available");
|
||||||
@ -158,14 +158,14 @@ static void vnc_init_basic_info_from_server_addr(QIOChannelSocket *ioc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
vnc_init_basic_info(addr, info, errp);
|
vnc_init_basic_info(addr, info, errp);
|
||||||
qapi_free_SocketAddress(addr);
|
qapi_free_SocketAddressLegacy(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vnc_init_basic_info_from_remote_addr(QIOChannelSocket *ioc,
|
static void vnc_init_basic_info_from_remote_addr(QIOChannelSocket *ioc,
|
||||||
VncBasicInfo *info,
|
VncBasicInfo *info,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
SocketAddress *addr = NULL;
|
SocketAddressLegacy *addr = NULL;
|
||||||
|
|
||||||
addr = qio_channel_socket_get_remote_address(ioc, errp);
|
addr = qio_channel_socket_get_remote_address(ioc, errp);
|
||||||
if (!addr) {
|
if (!addr) {
|
||||||
@ -173,7 +173,7 @@ static void vnc_init_basic_info_from_remote_addr(QIOChannelSocket *ioc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
vnc_init_basic_info(addr, info, errp);
|
vnc_init_basic_info(addr, info, errp);
|
||||||
qapi_free_SocketAddress(addr);
|
qapi_free_SocketAddressLegacy(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *vnc_auth_name(VncDisplay *vd) {
|
static const char *vnc_auth_name(VncDisplay *vd) {
|
||||||
@ -377,7 +377,7 @@ VncInfo *qmp_query_vnc(Error **errp)
|
|||||||
{
|
{
|
||||||
VncInfo *info = g_malloc0(sizeof(*info));
|
VncInfo *info = g_malloc0(sizeof(*info));
|
||||||
VncDisplay *vd = vnc_display_find(NULL);
|
VncDisplay *vd = vnc_display_find(NULL);
|
||||||
SocketAddress *addr = NULL;
|
SocketAddressLegacy *addr = NULL;
|
||||||
|
|
||||||
if (vd == NULL || !vd->nlsock) {
|
if (vd == NULL || !vd->nlsock) {
|
||||||
info->enabled = false;
|
info->enabled = false;
|
||||||
@ -398,7 +398,7 @@ VncInfo *qmp_query_vnc(Error **errp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (addr->type) {
|
switch (addr->type) {
|
||||||
case SOCKET_ADDRESS_KIND_INET:
|
case SOCKET_ADDRESS_LEGACY_KIND_INET:
|
||||||
info->host = g_strdup(addr->u.inet.data->host);
|
info->host = g_strdup(addr->u.inet.data->host);
|
||||||
info->service = g_strdup(addr->u.inet.data->port);
|
info->service = g_strdup(addr->u.inet.data->port);
|
||||||
if (addr->u.inet.data->ipv6) {
|
if (addr->u.inet.data->ipv6) {
|
||||||
@ -408,16 +408,16 @@ VncInfo *qmp_query_vnc(Error **errp)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SOCKET_ADDRESS_KIND_UNIX:
|
case SOCKET_ADDRESS_LEGACY_KIND_UNIX:
|
||||||
info->host = g_strdup("");
|
info->host = g_strdup("");
|
||||||
info->service = g_strdup(addr->u.q_unix.data->path);
|
info->service = g_strdup(addr->u.q_unix.data->path);
|
||||||
info->family = NETWORK_ADDRESS_FAMILY_UNIX;
|
info->family = NETWORK_ADDRESS_FAMILY_UNIX;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SOCKET_ADDRESS_KIND_VSOCK:
|
case SOCKET_ADDRESS_LEGACY_KIND_VSOCK:
|
||||||
case SOCKET_ADDRESS_KIND_FD:
|
case SOCKET_ADDRESS_LEGACY_KIND_FD:
|
||||||
error_setg(errp, "Unsupported socket address type %s",
|
error_setg(errp, "Unsupported socket address type %s",
|
||||||
SocketAddressKind_lookup[addr->type]);
|
SocketAddressLegacyKind_lookup[addr->type]);
|
||||||
goto out_error;
|
goto out_error;
|
||||||
default:
|
default:
|
||||||
abort();
|
abort();
|
||||||
@ -431,11 +431,11 @@ VncInfo *qmp_query_vnc(Error **errp)
|
|||||||
info->auth = g_strdup(vnc_auth_name(vd));
|
info->auth = g_strdup(vnc_auth_name(vd));
|
||||||
}
|
}
|
||||||
|
|
||||||
qapi_free_SocketAddress(addr);
|
qapi_free_SocketAddressLegacy(addr);
|
||||||
return info;
|
return info;
|
||||||
|
|
||||||
out_error:
|
out_error:
|
||||||
qapi_free_SocketAddress(addr);
|
qapi_free_SocketAddressLegacy(addr);
|
||||||
qapi_free_VncInfo(info);
|
qapi_free_VncInfo(info);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -455,7 +455,7 @@ static VncServerInfo2List *qmp_query_server_entry(QIOChannelSocket *ioc,
|
|||||||
VncServerInfo2List *list;
|
VncServerInfo2List *list;
|
||||||
VncServerInfo2 *info;
|
VncServerInfo2 *info;
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
SocketAddress *addr;
|
SocketAddressLegacy *addr;
|
||||||
|
|
||||||
addr = qio_channel_socket_get_local_address(ioc, &err);
|
addr = qio_channel_socket_get_local_address(ioc, &err);
|
||||||
if (!addr) {
|
if (!addr) {
|
||||||
@ -465,7 +465,7 @@ static VncServerInfo2List *qmp_query_server_entry(QIOChannelSocket *ioc,
|
|||||||
|
|
||||||
info = g_new0(VncServerInfo2, 1);
|
info = g_new0(VncServerInfo2, 1);
|
||||||
vnc_init_basic_info(addr, qapi_VncServerInfo2_base(info), &err);
|
vnc_init_basic_info(addr, qapi_VncServerInfo2_base(info), &err);
|
||||||
qapi_free_SocketAddress(addr);
|
qapi_free_SocketAddressLegacy(addr);
|
||||||
if (err) {
|
if (err) {
|
||||||
qapi_free_VncServerInfo2(info);
|
qapi_free_VncServerInfo2(info);
|
||||||
error_free(err);
|
error_free(err);
|
||||||
@ -3149,7 +3149,7 @@ int vnc_display_pw_expire(const char *id, time_t expires)
|
|||||||
|
|
||||||
static void vnc_display_print_local_addr(VncDisplay *vd)
|
static void vnc_display_print_local_addr(VncDisplay *vd)
|
||||||
{
|
{
|
||||||
SocketAddress *addr;
|
SocketAddressLegacy *addr;
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
|
|
||||||
if (!vd->nlsock) {
|
if (!vd->nlsock) {
|
||||||
@ -3161,14 +3161,14 @@ static void vnc_display_print_local_addr(VncDisplay *vd)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addr->type != SOCKET_ADDRESS_KIND_INET) {
|
if (addr->type != SOCKET_ADDRESS_LEGACY_KIND_INET) {
|
||||||
qapi_free_SocketAddress(addr);
|
qapi_free_SocketAddressLegacy(addr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
error_printf_unless_qmp("VNC server running on %s:%s\n",
|
error_printf_unless_qmp("VNC server running on %s:%s\n",
|
||||||
addr->u.inet.data->host,
|
addr->u.inet.data->host,
|
||||||
addr->u.inet.data->port);
|
addr->u.inet.data->port);
|
||||||
qapi_free_SocketAddress(addr);
|
qapi_free_SocketAddressLegacy(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QemuOptsList qemu_vnc_opts = {
|
static QemuOptsList qemu_vnc_opts = {
|
||||||
@ -3414,16 +3414,16 @@ static int vnc_display_get_address(const char *addrstr,
|
|||||||
bool has_ipv6,
|
bool has_ipv6,
|
||||||
bool ipv4,
|
bool ipv4,
|
||||||
bool ipv6,
|
bool ipv6,
|
||||||
SocketAddress **retaddr,
|
SocketAddressLegacy **retaddr,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
SocketAddress *addr = NULL;
|
SocketAddressLegacy *addr = NULL;
|
||||||
|
|
||||||
addr = g_new0(SocketAddress, 1);
|
addr = g_new0(SocketAddressLegacy, 1);
|
||||||
|
|
||||||
if (strncmp(addrstr, "unix:", 5) == 0) {
|
if (strncmp(addrstr, "unix:", 5) == 0) {
|
||||||
addr->type = SOCKET_ADDRESS_KIND_UNIX;
|
addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
|
||||||
addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
|
addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
|
||||||
addr->u.q_unix.data->path = g_strdup(addrstr + 5);
|
addr->u.q_unix.data->path = g_strdup(addrstr + 5);
|
||||||
|
|
||||||
@ -3461,7 +3461,7 @@ static int vnc_display_get_address(const char *addrstr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addr->type = SOCKET_ADDRESS_KIND_INET;
|
addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
|
||||||
inet = addr->u.inet.data = g_new0(InetSocketAddress, 1);
|
inet = addr->u.inet.data = g_new0(InetSocketAddress, 1);
|
||||||
if (addrstr[0] == '[' && addrstr[hostlen - 1] == ']') {
|
if (addrstr[0] == '[' && addrstr[hostlen - 1] == ']') {
|
||||||
inet->host = g_strndup(addrstr + 1, hostlen - 2);
|
inet->host = g_strndup(addrstr + 1, hostlen - 2);
|
||||||
@ -3518,21 +3518,21 @@ static int vnc_display_get_address(const char *addrstr,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
qapi_free_SocketAddress(addr);
|
qapi_free_SocketAddressLegacy(addr);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vnc_display_get_addresses(QemuOpts *opts,
|
static int vnc_display_get_addresses(QemuOpts *opts,
|
||||||
bool reverse,
|
bool reverse,
|
||||||
SocketAddress ***retsaddr,
|
SocketAddressLegacy ***retsaddr,
|
||||||
size_t *retnsaddr,
|
size_t *retnsaddr,
|
||||||
SocketAddress ***retwsaddr,
|
SocketAddressLegacy ***retwsaddr,
|
||||||
size_t *retnwsaddr,
|
size_t *retnwsaddr,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
SocketAddress *saddr = NULL;
|
SocketAddressLegacy *saddr = NULL;
|
||||||
SocketAddress *wsaddr = NULL;
|
SocketAddressLegacy *wsaddr = NULL;
|
||||||
QemuOptsIter addriter;
|
QemuOptsIter addriter;
|
||||||
const char *addr;
|
const char *addr;
|
||||||
int to = qemu_opt_get_number(opts, "to", 0);
|
int to = qemu_opt_get_number(opts, "to", 0);
|
||||||
@ -3577,7 +3577,7 @@ static int vnc_display_get_addresses(QemuOpts *opts,
|
|||||||
if (displaynum == -1) {
|
if (displaynum == -1) {
|
||||||
displaynum = rv;
|
displaynum = rv;
|
||||||
}
|
}
|
||||||
*retsaddr = g_renew(SocketAddress *, *retsaddr, *retnsaddr + 1);
|
*retsaddr = g_renew(SocketAddressLegacy *, *retsaddr, *retnsaddr + 1);
|
||||||
(*retsaddr)[(*retnsaddr)++] = saddr;
|
(*retsaddr)[(*retnsaddr)++] = saddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3601,8 +3601,8 @@ static int vnc_display_get_addresses(QemuOpts *opts,
|
|||||||
* address for websocket too
|
* address for websocket too
|
||||||
*/
|
*/
|
||||||
if (*retnsaddr == 1 &&
|
if (*retnsaddr == 1 &&
|
||||||
(*retsaddr)[0]->type == SOCKET_ADDRESS_KIND_INET &&
|
(*retsaddr)[0]->type == SOCKET_ADDRESS_LEGACY_KIND_INET &&
|
||||||
wsaddr->type == SOCKET_ADDRESS_KIND_INET &&
|
wsaddr->type == SOCKET_ADDRESS_LEGACY_KIND_INET &&
|
||||||
g_str_equal(wsaddr->u.inet.data->host, "") &&
|
g_str_equal(wsaddr->u.inet.data->host, "") &&
|
||||||
!g_str_equal((*retsaddr)[0]->u.inet.data->host, "")) {
|
!g_str_equal((*retsaddr)[0]->u.inet.data->host, "")) {
|
||||||
g_free(wsaddr->u.inet.data->host);
|
g_free(wsaddr->u.inet.data->host);
|
||||||
@ -3610,7 +3610,7 @@ static int vnc_display_get_addresses(QemuOpts *opts,
|
|||||||
g_strdup((*retsaddr)[0]->u.inet.data->host);
|
g_strdup((*retsaddr)[0]->u.inet.data->host);
|
||||||
}
|
}
|
||||||
|
|
||||||
*retwsaddr = g_renew(SocketAddress *, *retwsaddr, *retnwsaddr + 1);
|
*retwsaddr = g_renew(SocketAddressLegacy *, *retwsaddr, *retnwsaddr + 1);
|
||||||
(*retwsaddr)[(*retnwsaddr)++] = wsaddr;
|
(*retwsaddr)[(*retnwsaddr)++] = wsaddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3618,11 +3618,11 @@ static int vnc_display_get_addresses(QemuOpts *opts,
|
|||||||
cleanup:
|
cleanup:
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
for (i = 0; i < *retnsaddr; i++) {
|
for (i = 0; i < *retnsaddr; i++) {
|
||||||
qapi_free_SocketAddress((*retsaddr)[i]);
|
qapi_free_SocketAddressLegacy((*retsaddr)[i]);
|
||||||
}
|
}
|
||||||
g_free(*retsaddr);
|
g_free(*retsaddr);
|
||||||
for (i = 0; i < *retnwsaddr; i++) {
|
for (i = 0; i < *retnwsaddr; i++) {
|
||||||
qapi_free_SocketAddress((*retwsaddr)[i]);
|
qapi_free_SocketAddressLegacy((*retwsaddr)[i]);
|
||||||
}
|
}
|
||||||
g_free(*retwsaddr);
|
g_free(*retwsaddr);
|
||||||
*retsaddr = *retwsaddr = NULL;
|
*retsaddr = *retwsaddr = NULL;
|
||||||
@ -3632,9 +3632,9 @@ static int vnc_display_get_addresses(QemuOpts *opts,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int vnc_display_connect(VncDisplay *vd,
|
static int vnc_display_connect(VncDisplay *vd,
|
||||||
SocketAddress **saddr,
|
SocketAddressLegacy **saddr,
|
||||||
size_t nsaddr,
|
size_t nsaddr,
|
||||||
SocketAddress **wsaddr,
|
SocketAddressLegacy **wsaddr,
|
||||||
size_t nwsaddr,
|
size_t nwsaddr,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
@ -3648,8 +3648,8 @@ static int vnc_display_connect(VncDisplay *vd,
|
|||||||
error_setg(errp, "Expected a single address in reverse mode");
|
error_setg(errp, "Expected a single address in reverse mode");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* TODO SOCKET_ADDRESS_KIND_FD when fd has AF_UNIX */
|
/* TODO SOCKET_ADDRESS_LEGACY_KIND_FD when fd has AF_UNIX */
|
||||||
vd->is_unix = saddr[0]->type == SOCKET_ADDRESS_KIND_UNIX;
|
vd->is_unix = saddr[0]->type == SOCKET_ADDRESS_LEGACY_KIND_UNIX;
|
||||||
sioc = qio_channel_socket_new();
|
sioc = qio_channel_socket_new();
|
||||||
qio_channel_set_name(QIO_CHANNEL(sioc), "vnc-reverse");
|
qio_channel_set_name(QIO_CHANNEL(sioc), "vnc-reverse");
|
||||||
if (qio_channel_socket_connect_sync(sioc, saddr[0], errp) < 0) {
|
if (qio_channel_socket_connect_sync(sioc, saddr[0], errp) < 0) {
|
||||||
@ -3662,7 +3662,7 @@ static int vnc_display_connect(VncDisplay *vd,
|
|||||||
|
|
||||||
|
|
||||||
static int vnc_display_listen_addr(VncDisplay *vd,
|
static int vnc_display_listen_addr(VncDisplay *vd,
|
||||||
SocketAddress *addr,
|
SocketAddressLegacy *addr,
|
||||||
const char *name,
|
const char *name,
|
||||||
QIOChannelSocket ***lsock,
|
QIOChannelSocket ***lsock,
|
||||||
guint **lsock_tag,
|
guint **lsock_tag,
|
||||||
@ -3670,7 +3670,7 @@ static int vnc_display_listen_addr(VncDisplay *vd,
|
|||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
QIODNSResolver *resolver = qio_dns_resolver_get_instance();
|
QIODNSResolver *resolver = qio_dns_resolver_get_instance();
|
||||||
SocketAddress **rawaddrs = NULL;
|
SocketAddressLegacy **rawaddrs = NULL;
|
||||||
size_t nrawaddrs = 0;
|
size_t nrawaddrs = 0;
|
||||||
Error *listenerr = NULL;
|
Error *listenerr = NULL;
|
||||||
bool listening = false;
|
bool listening = false;
|
||||||
@ -3700,7 +3700,7 @@ static int vnc_display_listen_addr(VncDisplay *vd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < nrawaddrs; i++) {
|
for (i = 0; i < nrawaddrs; i++) {
|
||||||
qapi_free_SocketAddress(rawaddrs[i]);
|
qapi_free_SocketAddressLegacy(rawaddrs[i]);
|
||||||
}
|
}
|
||||||
g_free(rawaddrs);
|
g_free(rawaddrs);
|
||||||
|
|
||||||
@ -3724,9 +3724,9 @@ static int vnc_display_listen_addr(VncDisplay *vd,
|
|||||||
|
|
||||||
|
|
||||||
static int vnc_display_listen(VncDisplay *vd,
|
static int vnc_display_listen(VncDisplay *vd,
|
||||||
SocketAddress **saddr,
|
SocketAddressLegacy **saddr,
|
||||||
size_t nsaddr,
|
size_t nsaddr,
|
||||||
SocketAddress **wsaddr,
|
SocketAddressLegacy **wsaddr,
|
||||||
size_t nwsaddr,
|
size_t nwsaddr,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
@ -3761,7 +3761,7 @@ void vnc_display_open(const char *id, Error **errp)
|
|||||||
{
|
{
|
||||||
VncDisplay *vd = vnc_display_find(id);
|
VncDisplay *vd = vnc_display_find(id);
|
||||||
QemuOpts *opts = qemu_opts_find(&qemu_vnc_opts, id);
|
QemuOpts *opts = qemu_opts_find(&qemu_vnc_opts, id);
|
||||||
SocketAddress **saddr = NULL, **wsaddr = NULL;
|
SocketAddressLegacy **saddr = NULL, **wsaddr = NULL;
|
||||||
size_t nsaddr, nwsaddr;
|
size_t nsaddr, nwsaddr;
|
||||||
const char *share, *device_id;
|
const char *share, *device_id;
|
||||||
QemuConsole *con;
|
QemuConsole *con;
|
||||||
@ -3997,10 +3997,10 @@ void vnc_display_open(const char *id, Error **errp)
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
for (i = 0; i < nsaddr; i++) {
|
for (i = 0; i < nsaddr; i++) {
|
||||||
qapi_free_SocketAddress(saddr[i]);
|
qapi_free_SocketAddressLegacy(saddr[i]);
|
||||||
}
|
}
|
||||||
for (i = 0; i < nwsaddr; i++) {
|
for (i = 0; i < nwsaddr; i++) {
|
||||||
qapi_free_SocketAddress(wsaddr[i]);
|
qapi_free_SocketAddressLegacy(wsaddr[i]);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1029,17 +1029,17 @@ int unix_connect(const char *path, Error **errp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SocketAddress *socket_parse(const char *str, Error **errp)
|
SocketAddressLegacy *socket_parse(const char *str, Error **errp)
|
||||||
{
|
{
|
||||||
SocketAddress *addr;
|
SocketAddressLegacy *addr;
|
||||||
|
|
||||||
addr = g_new0(SocketAddress, 1);
|
addr = g_new0(SocketAddressLegacy, 1);
|
||||||
if (strstart(str, "unix:", NULL)) {
|
if (strstart(str, "unix:", NULL)) {
|
||||||
if (str[5] == '\0') {
|
if (str[5] == '\0') {
|
||||||
error_setg(errp, "invalid Unix socket address");
|
error_setg(errp, "invalid Unix socket address");
|
||||||
goto fail;
|
goto fail;
|
||||||
} else {
|
} else {
|
||||||
addr->type = SOCKET_ADDRESS_KIND_UNIX;
|
addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
|
||||||
addr->u.q_unix.data = g_new(UnixSocketAddress, 1);
|
addr->u.q_unix.data = g_new(UnixSocketAddress, 1);
|
||||||
addr->u.q_unix.data->path = g_strdup(str + 5);
|
addr->u.q_unix.data->path = g_strdup(str + 5);
|
||||||
}
|
}
|
||||||
@ -1048,18 +1048,18 @@ SocketAddress *socket_parse(const char *str, Error **errp)
|
|||||||
error_setg(errp, "invalid file descriptor address");
|
error_setg(errp, "invalid file descriptor address");
|
||||||
goto fail;
|
goto fail;
|
||||||
} else {
|
} else {
|
||||||
addr->type = SOCKET_ADDRESS_KIND_FD;
|
addr->type = SOCKET_ADDRESS_LEGACY_KIND_FD;
|
||||||
addr->u.fd.data = g_new(String, 1);
|
addr->u.fd.data = g_new(String, 1);
|
||||||
addr->u.fd.data->str = g_strdup(str + 3);
|
addr->u.fd.data->str = g_strdup(str + 3);
|
||||||
}
|
}
|
||||||
} else if (strstart(str, "vsock:", NULL)) {
|
} else if (strstart(str, "vsock:", NULL)) {
|
||||||
addr->type = SOCKET_ADDRESS_KIND_VSOCK;
|
addr->type = SOCKET_ADDRESS_LEGACY_KIND_VSOCK;
|
||||||
addr->u.vsock.data = g_new(VsockSocketAddress, 1);
|
addr->u.vsock.data = g_new(VsockSocketAddress, 1);
|
||||||
if (vsock_parse(addr->u.vsock.data, str + strlen("vsock:"), errp)) {
|
if (vsock_parse(addr->u.vsock.data, str + strlen("vsock:"), errp)) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
addr->type = SOCKET_ADDRESS_KIND_INET;
|
addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
|
||||||
addr->u.inet.data = g_new(InetSocketAddress, 1);
|
addr->u.inet.data = g_new(InetSocketAddress, 1);
|
||||||
if (inet_parse(addr->u.inet.data, str, errp)) {
|
if (inet_parse(addr->u.inet.data, str, errp)) {
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -1068,25 +1068,25 @@ SocketAddress *socket_parse(const char *str, Error **errp)
|
|||||||
return addr;
|
return addr;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
qapi_free_SocketAddress(addr);
|
qapi_free_SocketAddressLegacy(addr);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int socket_connect(SocketAddress *addr, NonBlockingConnectHandler *callback,
|
int socket_connect(SocketAddressLegacy *addr, NonBlockingConnectHandler *callback,
|
||||||
void *opaque, Error **errp)
|
void *opaque, Error **errp)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
switch (addr->type) {
|
switch (addr->type) {
|
||||||
case SOCKET_ADDRESS_KIND_INET:
|
case SOCKET_ADDRESS_LEGACY_KIND_INET:
|
||||||
fd = inet_connect_saddr(addr->u.inet.data, callback, opaque, errp);
|
fd = inet_connect_saddr(addr->u.inet.data, callback, opaque, errp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SOCKET_ADDRESS_KIND_UNIX:
|
case SOCKET_ADDRESS_LEGACY_KIND_UNIX:
|
||||||
fd = unix_connect_saddr(addr->u.q_unix.data, callback, opaque, errp);
|
fd = unix_connect_saddr(addr->u.q_unix.data, callback, opaque, errp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SOCKET_ADDRESS_KIND_FD:
|
case SOCKET_ADDRESS_LEGACY_KIND_FD:
|
||||||
fd = monitor_get_fd(cur_mon, addr->u.fd.data->str, errp);
|
fd = monitor_get_fd(cur_mon, addr->u.fd.data->str, errp);
|
||||||
if (fd >= 0 && callback) {
|
if (fd >= 0 && callback) {
|
||||||
qemu_set_nonblock(fd);
|
qemu_set_nonblock(fd);
|
||||||
@ -1094,7 +1094,7 @@ int socket_connect(SocketAddress *addr, NonBlockingConnectHandler *callback,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SOCKET_ADDRESS_KIND_VSOCK:
|
case SOCKET_ADDRESS_LEGACY_KIND_VSOCK:
|
||||||
fd = vsock_connect_saddr(addr->u.vsock.data, callback, opaque, errp);
|
fd = vsock_connect_saddr(addr->u.vsock.data, callback, opaque, errp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1104,24 +1104,24 @@ int socket_connect(SocketAddress *addr, NonBlockingConnectHandler *callback,
|
|||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
int socket_listen(SocketAddress *addr, Error **errp)
|
int socket_listen(SocketAddressLegacy *addr, Error **errp)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
switch (addr->type) {
|
switch (addr->type) {
|
||||||
case SOCKET_ADDRESS_KIND_INET:
|
case SOCKET_ADDRESS_LEGACY_KIND_INET:
|
||||||
fd = inet_listen_saddr(addr->u.inet.data, 0, false, errp);
|
fd = inet_listen_saddr(addr->u.inet.data, 0, false, errp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SOCKET_ADDRESS_KIND_UNIX:
|
case SOCKET_ADDRESS_LEGACY_KIND_UNIX:
|
||||||
fd = unix_listen_saddr(addr->u.q_unix.data, false, errp);
|
fd = unix_listen_saddr(addr->u.q_unix.data, false, errp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SOCKET_ADDRESS_KIND_FD:
|
case SOCKET_ADDRESS_LEGACY_KIND_FD:
|
||||||
fd = monitor_get_fd(cur_mon, addr->u.fd.data->str, errp);
|
fd = monitor_get_fd(cur_mon, addr->u.fd.data->str, errp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SOCKET_ADDRESS_KIND_VSOCK:
|
case SOCKET_ADDRESS_LEGACY_KIND_VSOCK:
|
||||||
fd = vsock_listen_saddr(addr->u.vsock.data, errp);
|
fd = vsock_listen_saddr(addr->u.vsock.data, errp);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1133,11 +1133,11 @@ int socket_listen(SocketAddress *addr, Error **errp)
|
|||||||
|
|
||||||
void socket_listen_cleanup(int fd, Error **errp)
|
void socket_listen_cleanup(int fd, Error **errp)
|
||||||
{
|
{
|
||||||
SocketAddress *addr;
|
SocketAddressLegacy *addr;
|
||||||
|
|
||||||
addr = socket_local_address(fd, errp);
|
addr = socket_local_address(fd, errp);
|
||||||
|
|
||||||
if (addr->type == SOCKET_ADDRESS_KIND_UNIX
|
if (addr->type == SOCKET_ADDRESS_LEGACY_KIND_UNIX
|
||||||
&& addr->u.q_unix.data->path) {
|
&& addr->u.q_unix.data->path) {
|
||||||
if (unlink(addr->u.q_unix.data->path) < 0 && errno != ENOENT) {
|
if (unlink(addr->u.q_unix.data->path) < 0 && errno != ENOENT) {
|
||||||
error_setg_errno(errp, errno,
|
error_setg_errno(errp, errno,
|
||||||
@ -1146,19 +1146,19 @@ void socket_listen_cleanup(int fd, Error **errp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qapi_free_SocketAddress(addr);
|
qapi_free_SocketAddressLegacy(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp)
|
int socket_dgram(SocketAddressLegacy *remote, SocketAddressLegacy *local, Error **errp)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO SOCKET_ADDRESS_KIND_FD when fd is AF_INET or AF_INET6
|
* TODO SOCKET_ADDRESS_LEGACY_KIND_FD when fd is AF_INET or AF_INET6
|
||||||
* (although other address families can do SOCK_DGRAM, too)
|
* (although other address families can do SOCK_DGRAM, too)
|
||||||
*/
|
*/
|
||||||
switch (remote->type) {
|
switch (remote->type) {
|
||||||
case SOCKET_ADDRESS_KIND_INET:
|
case SOCKET_ADDRESS_LEGACY_KIND_INET:
|
||||||
fd = inet_dgram_saddr(remote->u.inet.data,
|
fd = inet_dgram_saddr(remote->u.inet.data,
|
||||||
local ? local->u.inet.data : NULL, errp);
|
local ? local->u.inet.data : NULL, errp);
|
||||||
break;
|
break;
|
||||||
@ -1171,14 +1171,14 @@ int socket_dgram(SocketAddress *remote, SocketAddress *local, Error **errp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static SocketAddress *
|
static SocketAddressLegacy *
|
||||||
socket_sockaddr_to_address_inet(struct sockaddr_storage *sa,
|
socket_sockaddr_to_address_inet(struct sockaddr_storage *sa,
|
||||||
socklen_t salen,
|
socklen_t salen,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
char host[NI_MAXHOST];
|
char host[NI_MAXHOST];
|
||||||
char serv[NI_MAXSERV];
|
char serv[NI_MAXSERV];
|
||||||
SocketAddress *addr;
|
SocketAddressLegacy *addr;
|
||||||
InetSocketAddress *inet;
|
InetSocketAddress *inet;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -1192,8 +1192,8 @@ socket_sockaddr_to_address_inet(struct sockaddr_storage *sa,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
addr = g_new0(SocketAddress, 1);
|
addr = g_new0(SocketAddressLegacy, 1);
|
||||||
addr->type = SOCKET_ADDRESS_KIND_INET;
|
addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
|
||||||
inet = addr->u.inet.data = g_new0(InetSocketAddress, 1);
|
inet = addr->u.inet.data = g_new0(InetSocketAddress, 1);
|
||||||
inet->host = g_strdup(host);
|
inet->host = g_strdup(host);
|
||||||
inet->port = g_strdup(serv);
|
inet->port = g_strdup(serv);
|
||||||
@ -1208,16 +1208,16 @@ socket_sockaddr_to_address_inet(struct sockaddr_storage *sa,
|
|||||||
|
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
static SocketAddress *
|
static SocketAddressLegacy *
|
||||||
socket_sockaddr_to_address_unix(struct sockaddr_storage *sa,
|
socket_sockaddr_to_address_unix(struct sockaddr_storage *sa,
|
||||||
socklen_t salen,
|
socklen_t salen,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
SocketAddress *addr;
|
SocketAddressLegacy *addr;
|
||||||
struct sockaddr_un *su = (struct sockaddr_un *)sa;
|
struct sockaddr_un *su = (struct sockaddr_un *)sa;
|
||||||
|
|
||||||
addr = g_new0(SocketAddress, 1);
|
addr = g_new0(SocketAddressLegacy, 1);
|
||||||
addr->type = SOCKET_ADDRESS_KIND_UNIX;
|
addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
|
||||||
addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
|
addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);
|
||||||
if (su->sun_path[0]) {
|
if (su->sun_path[0]) {
|
||||||
addr->u.q_unix.data->path = g_strndup(su->sun_path,
|
addr->u.q_unix.data->path = g_strndup(su->sun_path,
|
||||||
@ -1229,17 +1229,17 @@ socket_sockaddr_to_address_unix(struct sockaddr_storage *sa,
|
|||||||
#endif /* WIN32 */
|
#endif /* WIN32 */
|
||||||
|
|
||||||
#ifdef CONFIG_AF_VSOCK
|
#ifdef CONFIG_AF_VSOCK
|
||||||
static SocketAddress *
|
static SocketAddressLegacy *
|
||||||
socket_sockaddr_to_address_vsock(struct sockaddr_storage *sa,
|
socket_sockaddr_to_address_vsock(struct sockaddr_storage *sa,
|
||||||
socklen_t salen,
|
socklen_t salen,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
SocketAddress *addr;
|
SocketAddressLegacy *addr;
|
||||||
VsockSocketAddress *vaddr;
|
VsockSocketAddress *vaddr;
|
||||||
struct sockaddr_vm *svm = (struct sockaddr_vm *)sa;
|
struct sockaddr_vm *svm = (struct sockaddr_vm *)sa;
|
||||||
|
|
||||||
addr = g_new0(SocketAddress, 1);
|
addr = g_new0(SocketAddressLegacy, 1);
|
||||||
addr->type = SOCKET_ADDRESS_KIND_VSOCK;
|
addr->type = SOCKET_ADDRESS_LEGACY_KIND_VSOCK;
|
||||||
addr->u.vsock.data = vaddr = g_new0(VsockSocketAddress, 1);
|
addr->u.vsock.data = vaddr = g_new0(VsockSocketAddress, 1);
|
||||||
vaddr->cid = g_strdup_printf("%u", svm->svm_cid);
|
vaddr->cid = g_strdup_printf("%u", svm->svm_cid);
|
||||||
vaddr->port = g_strdup_printf("%u", svm->svm_port);
|
vaddr->port = g_strdup_printf("%u", svm->svm_port);
|
||||||
@ -1248,7 +1248,7 @@ socket_sockaddr_to_address_vsock(struct sockaddr_storage *sa,
|
|||||||
}
|
}
|
||||||
#endif /* CONFIG_AF_VSOCK */
|
#endif /* CONFIG_AF_VSOCK */
|
||||||
|
|
||||||
SocketAddress *
|
SocketAddressLegacy *
|
||||||
socket_sockaddr_to_address(struct sockaddr_storage *sa,
|
socket_sockaddr_to_address(struct sockaddr_storage *sa,
|
||||||
socklen_t salen,
|
socklen_t salen,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
@ -1277,7 +1277,7 @@ socket_sockaddr_to_address(struct sockaddr_storage *sa,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SocketAddress *socket_local_address(int fd, Error **errp)
|
SocketAddressLegacy *socket_local_address(int fd, Error **errp)
|
||||||
{
|
{
|
||||||
struct sockaddr_storage ss;
|
struct sockaddr_storage ss;
|
||||||
socklen_t sslen = sizeof(ss);
|
socklen_t sslen = sizeof(ss);
|
||||||
@ -1292,7 +1292,7 @@ SocketAddress *socket_local_address(int fd, Error **errp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SocketAddress *socket_remote_address(int fd, Error **errp)
|
SocketAddressLegacy *socket_remote_address(int fd, Error **errp)
|
||||||
{
|
{
|
||||||
struct sockaddr_storage ss;
|
struct sockaddr_storage ss;
|
||||||
socklen_t sslen = sizeof(ss);
|
socklen_t sslen = sizeof(ss);
|
||||||
@ -1306,13 +1306,13 @@ SocketAddress *socket_remote_address(int fd, Error **errp)
|
|||||||
return socket_sockaddr_to_address(&ss, sslen, errp);
|
return socket_sockaddr_to_address(&ss, sslen, errp);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *socket_address_to_string(struct SocketAddress *addr, Error **errp)
|
char *socket_address_to_string(struct SocketAddressLegacy *addr, Error **errp)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
InetSocketAddress *inet;
|
InetSocketAddress *inet;
|
||||||
|
|
||||||
switch (addr->type) {
|
switch (addr->type) {
|
||||||
case SOCKET_ADDRESS_KIND_INET:
|
case SOCKET_ADDRESS_LEGACY_KIND_INET:
|
||||||
inet = addr->u.inet.data;
|
inet = addr->u.inet.data;
|
||||||
if (strchr(inet->host, ':') == NULL) {
|
if (strchr(inet->host, ':') == NULL) {
|
||||||
buf = g_strdup_printf("%s:%s", inet->host, inet->port);
|
buf = g_strdup_printf("%s:%s", inet->host, inet->port);
|
||||||
@ -1321,15 +1321,15 @@ char *socket_address_to_string(struct SocketAddress *addr, Error **errp)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SOCKET_ADDRESS_KIND_UNIX:
|
case SOCKET_ADDRESS_LEGACY_KIND_UNIX:
|
||||||
buf = g_strdup(addr->u.q_unix.data->path);
|
buf = g_strdup(addr->u.q_unix.data->path);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SOCKET_ADDRESS_KIND_FD:
|
case SOCKET_ADDRESS_LEGACY_KIND_FD:
|
||||||
buf = g_strdup(addr->u.fd.data->str);
|
buf = g_strdup(addr->u.fd.data->str);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SOCKET_ADDRESS_KIND_VSOCK:
|
case SOCKET_ADDRESS_LEGACY_KIND_VSOCK:
|
||||||
buf = g_strdup_printf("%s:%s",
|
buf = g_strdup_printf("%s:%s",
|
||||||
addr->u.vsock.data->cid,
|
addr->u.vsock.data->cid,
|
||||||
addr->u.vsock.data->port);
|
addr->u.vsock.data->port);
|
||||||
@ -1341,28 +1341,28 @@ char *socket_address_to_string(struct SocketAddress *addr, Error **errp)
|
|||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
SocketAddress *socket_address_crumple(SocketAddressFlat *addr_flat)
|
SocketAddressLegacy *socket_address_crumple(SocketAddressFlat *addr_flat)
|
||||||
{
|
{
|
||||||
SocketAddress *addr = g_new(SocketAddress, 1);
|
SocketAddressLegacy *addr = g_new(SocketAddressLegacy, 1);
|
||||||
|
|
||||||
switch (addr_flat->type) {
|
switch (addr_flat->type) {
|
||||||
case SOCKET_ADDRESS_FLAT_TYPE_INET:
|
case SOCKET_ADDRESS_FLAT_TYPE_INET:
|
||||||
addr->type = SOCKET_ADDRESS_KIND_INET;
|
addr->type = SOCKET_ADDRESS_LEGACY_KIND_INET;
|
||||||
addr->u.inet.data = QAPI_CLONE(InetSocketAddress,
|
addr->u.inet.data = QAPI_CLONE(InetSocketAddress,
|
||||||
&addr_flat->u.inet);
|
&addr_flat->u.inet);
|
||||||
break;
|
break;
|
||||||
case SOCKET_ADDRESS_FLAT_TYPE_UNIX:
|
case SOCKET_ADDRESS_FLAT_TYPE_UNIX:
|
||||||
addr->type = SOCKET_ADDRESS_KIND_UNIX;
|
addr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX;
|
||||||
addr->u.q_unix.data = QAPI_CLONE(UnixSocketAddress,
|
addr->u.q_unix.data = QAPI_CLONE(UnixSocketAddress,
|
||||||
&addr_flat->u.q_unix);
|
&addr_flat->u.q_unix);
|
||||||
break;
|
break;
|
||||||
case SOCKET_ADDRESS_FLAT_TYPE_VSOCK:
|
case SOCKET_ADDRESS_FLAT_TYPE_VSOCK:
|
||||||
addr->type = SOCKET_ADDRESS_KIND_VSOCK;
|
addr->type = SOCKET_ADDRESS_LEGACY_KIND_VSOCK;
|
||||||
addr->u.vsock.data = QAPI_CLONE(VsockSocketAddress,
|
addr->u.vsock.data = QAPI_CLONE(VsockSocketAddress,
|
||||||
&addr_flat->u.vsock);
|
&addr_flat->u.vsock);
|
||||||
break;
|
break;
|
||||||
case SOCKET_ADDRESS_FLAT_TYPE_FD:
|
case SOCKET_ADDRESS_FLAT_TYPE_FD:
|
||||||
addr->type = SOCKET_ADDRESS_KIND_FD;
|
addr->type = SOCKET_ADDRESS_LEGACY_KIND_FD;
|
||||||
addr->u.fd.data = QAPI_CLONE(String, &addr_flat->u.fd);
|
addr->u.fd.data = QAPI_CLONE(String, &addr_flat->u.fd);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user