mirror of https://github.com/xemu-project/xemu.git
qemu-nbd: rename socket variable
It will be moved to a global variable by the next patch, and it would conflict with the socket function. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
bb345110f0
commit
b32f6c28d5
25
qemu-nbd.c
25
qemu-nbd.c
|
@ -202,8 +202,7 @@ int main(int argc, char **argv)
|
||||||
socklen_t addr_len = sizeof(addr);
|
socklen_t addr_len = sizeof(addr);
|
||||||
off_t fd_size;
|
off_t fd_size;
|
||||||
char *device = NULL;
|
char *device = NULL;
|
||||||
char *socket = NULL;
|
char *sockpath = NULL;
|
||||||
char sockpath[128];
|
|
||||||
const char *sopt = "hVb:o:p:rsnP:c:dvk:e:t";
|
const char *sopt = "hVb:o:p:rsnP:c:dvk:e:t";
|
||||||
struct option lopt[] = {
|
struct option lopt[] = {
|
||||||
{ "help", 0, NULL, 'h' },
|
{ "help", 0, NULL, 'h' },
|
||||||
|
@ -294,8 +293,8 @@ int main(int argc, char **argv)
|
||||||
errx(EXIT_FAILURE, "Invalid partition %d", partition);
|
errx(EXIT_FAILURE, "Invalid partition %d", partition);
|
||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
socket = optarg;
|
sockpath = optarg;
|
||||||
if (socket[0] != '/')
|
if (sockpath[0] != '/')
|
||||||
errx(EXIT_FAILURE, "socket path must be absolute\n");
|
errx(EXIT_FAILURE, "socket path must be absolute\n");
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
|
@ -384,10 +383,9 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (socket == NULL) {
|
if (sockpath == NULL) {
|
||||||
snprintf(sockpath, sizeof(sockpath), SOCKET_PATH,
|
sockpath = g_malloc(128);
|
||||||
basename(device));
|
snprintf(sockpath, 128, SOCKET_PATH, basename(device));
|
||||||
socket = sockpath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
|
@ -401,7 +399,7 @@ int main(int argc, char **argv)
|
||||||
bdrv_close(bs);
|
bdrv_close(bs);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
sock = unix_socket_outgoing(socket);
|
sock = unix_socket_outgoing(sockpath);
|
||||||
if (sock == -1) {
|
if (sock == -1) {
|
||||||
if (errno != ENOENT && errno != ECONNREFUSED) {
|
if (errno != ENOENT && errno != ECONNREFUSED) {
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
@ -452,8 +450,8 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
sharing_fds = g_malloc((shared + 1) * sizeof(int));
|
sharing_fds = g_malloc((shared + 1) * sizeof(int));
|
||||||
|
|
||||||
if (socket) {
|
if (sockpath) {
|
||||||
sharing_fds[0] = unix_socket_incoming(socket);
|
sharing_fds[0] = unix_socket_incoming(sockpath);
|
||||||
} else {
|
} else {
|
||||||
sharing_fds[0] = tcp_socket_incoming(bindto, port);
|
sharing_fds[0] = tcp_socket_incoming(bindto, port);
|
||||||
}
|
}
|
||||||
|
@ -515,8 +513,9 @@ int main(int argc, char **argv)
|
||||||
close(sharing_fds[0]);
|
close(sharing_fds[0]);
|
||||||
bdrv_close(bs);
|
bdrv_close(bs);
|
||||||
g_free(sharing_fds);
|
g_free(sharing_fds);
|
||||||
if (socket)
|
if (sockpath) {
|
||||||
unlink(socket);
|
unlink(sockpath);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue