if (ret) {
error_report("unable to get address info %s, %s",
addr, strerror(errno));
- return -1;
+ return -errno;
}
for (res = res0; res; res = res->ai_next) {
dprintf("connected to %s:%s\n", addr, port);
goto success;
}
- fd = -1;
+ fd = -errno;
error_report("failed connect to %s:%s", addr, port);
success:
freeaddrinfo(res0);
ret = qemu_send_full(sockfd, hdr, sizeof(*hdr), 0);
if (ret < sizeof(*hdr)) {
error_report("failed to send a req, %s", strerror(errno));
- return ret;
+ return -errno;
}
ret = qemu_send_full(sockfd, data, *wlen, 0);
if (ret < *wlen) {
error_report("failed to send a req, %s", strerror(errno));
+ ret = -errno;
}
return ret;
ret = qemu_recv_full(sockfd, hdr, sizeof(*hdr), 0);
if (ret < sizeof(*hdr)) {
error_report("failed to get a rsp, %s", strerror(errno));
+ ret = -errno;
goto out;
}
ret = qemu_recv_full(sockfd, data, *rlen, 0);
if (ret < *rlen) {
error_report("failed to get the data, %s", strerror(errno));
+ ret = -errno;
goto out;
}
}
ret = qemu_co_recv(sockfd, hdr, sizeof(*hdr));
if (ret < sizeof(*hdr)) {
error_report("failed to get a rsp, %s", strerror(errno));
+ ret = -errno;
goto out;
}
ret = qemu_co_recv(sockfd, data, *rlen);
if (ret < *rlen) {
error_report("failed to get the data, %s", strerror(errno));
+ ret = -errno;
goto out;
}
}
fd = connect_to_sdog(s->addr, s->port);
if (fd < 0) {
error_report("%s", strerror(errno));
- return -1;
+ return fd;
}
socket_set_nonblock(fd);
if (ret) {
error_report("%s", strerror(errno));
closesocket(fd);
- return -1;
+ return -errno;
}
qemu_aio_set_fd_handler(fd, co_read_response, NULL, aio_flush_request, s);
fd = connect_to_sdog(s->addr, s->port);
if (fd < 0) {
- return -1;
+ return fd;
}
memset(buf, 0, sizeof(buf));
ret = do_req(fd, (SheepdogReq *)&hdr, buf, &wlen, &rlen);
if (ret) {
- ret = -1;
goto out;
}
if (rsp->result != SD_RES_SUCCESS) {
error_report("cannot get vdi info, %s, %s %d %s",
sd_strerror(rsp->result), filename, snapid, tag);
- ret = -1;
+ if (rsp->result == SD_RES_NO_VDI) {
+ ret = -ENOENT;
+ } else {
+ ret = -EIO;
+ }
goto out;
}
*vid = rsp->vdi_id;
if (ret < 0) {
qemu_co_mutex_unlock(&s->lock);
error_report("failed to send a req, %s", strerror(errno));
- return -EIO;
+ return -errno;
}
if (wlen) {
if (ret < 0) {
qemu_co_mutex_unlock(&s->lock);
error_report("failed to send a data, %s", strerror(errno));
- return -EIO;
+ return -errno;
}
}
ret = do_req(fd, (SheepdogReq *)&hdr, buf, &wlen, &rlen);
if (ret) {
error_report("failed to send a request to the sheep");
- return -1;
+ return ret;
}
switch (rsp->result) {
return 0;
default:
error_report("%s", sd_strerror(rsp->result));
- return -1;
+ return -EIO;
}
}
memset(vdi, 0, sizeof(vdi));
memset(tag, 0, sizeof(tag));
if (parse_vdiname(s, filename, vdi, &snapid, tag) < 0) {
+ ret = -EINVAL;
goto out;
}
s->fd = get_sheep_fd(s);
if (s->fd < 0) {
+ ret = s->fd;
goto out;
}
s->flush_fd = connect_to_sdog(s->addr, s->port);
if (s->flush_fd < 0) {
error_report("failed to connect");
+ ret = s->flush_fd;
goto out;
}
}
fd = connect_to_sdog(s->addr, s->port);
if (fd < 0) {
error_report("failed to connect");
+ ret = fd;
goto out;
}
closesocket(s->fd);
}
g_free(buf);
- return -1;
+ return ret;
}
static int do_sd_create(char *filename, int64_t vdi_size,
fd = connect_to_sdog(addr, port);
if (fd < 0) {
- return -EIO;
+ return fd;
}
memset(buf, 0, sizeof(buf));
closesocket(fd);
if (ret) {
- return -EIO;
+ return ret;
}
if (rsp->result != SD_RES_SUCCESS) {
}
ret = bdrv_file_open(&bs, backing_file, 0);
- if (ret < 0)
- return -EIO;
+ if (ret < 0) {
+ return ret;
+ }
s = bs->opaque;
fd = connect_to_sdog(s->addr, s->port);
if (fd < 0) {
- return -EIO;
+ return fd;
}
/* we don't need to update entire object */
if (ret < 0) {
error_report("failed to update an inode.");
- return -EIO;
}
- return 0;
+ return ret;
}
/*
fd = connect_to_sdog(s->addr, s->port);
if (fd < 0) {
error_report("failed to connect");
+ ret = fd;
goto out;
}
if (bs->growable && sector_num + nb_sectors > bs->total_sectors) {
/* TODO: shouldn't block here */
- if (sd_truncate(bs, (sector_num + nb_sectors) * SECTOR_SIZE) < 0) {
- return -EIO;
+ ret = sd_truncate(bs, (sector_num + nb_sectors) * SECTOR_SIZE);
+ if (ret < 0) {
+ return ret;
}
bs->total_sectors = sector_num + nb_sectors;
}
/* refresh inode. */
fd = connect_to_sdog(s->addr, s->port);
if (fd < 0) {
- ret = -EIO;
+ ret = fd;
goto cleanup;
}
s->inode.nr_copies, datalen, 0, 0, s->cache_enabled);
if (ret < 0) {
error_report("failed to write snapshot's inode.");
- ret = -EIO;
goto cleanup;
}
if (ret < 0) {
error_report("failed to create inode for snapshot. %s",
strerror(errno));
- ret = -EIO;
goto cleanup;
}
if (ret < 0) {
error_report("failed to read new inode info. %s", strerror(errno));
- ret = -EIO;
goto cleanup;
}
char *buf = NULL;
uint32_t vid;
uint32_t snapid = 0;
- int ret = -ENOENT, fd;
+ int ret = 0, fd;
old_s = g_malloc(sizeof(BDRVSheepdogState));
ret = find_vdi_name(s, vdi, snapid, tag, &vid, 1);
if (ret) {
error_report("Failed to find_vdi_name");
- ret = -ENOENT;
goto out;
}
fd = connect_to_sdog(s->addr, s->port);
if (fd < 0) {
error_report("failed to connect");
+ ret = fd;
goto out;
}
closesocket(fd);
if (ret) {
- ret = -ENOENT;
goto out;
}
fd = connect_to_sdog(s->addr, s->port);
if (fd < 0) {
+ ret = fd;
goto out;
}
fd = connect_to_sdog(s->addr, s->port);
if (fd < 0) {
error_report("failed to connect");
+ ret = fd;
goto out;
}
g_free(vdi_inuse);
+ if (ret < 0) {
+ return ret;
+ }
+
return found;
}
fd = connect_to_sdog(s->addr, s->port);
if (fd < 0) {
- ret = -EIO;
- goto cleanup;
+ return fd;
}
while (size) {
if (ret < 0) {
error_report("failed to save vmstate %s", strerror(errno));
- ret = -EIO;
goto cleanup;
}