Revision 7267c094 block/sheepdog.c
b/block/sheepdog.c | ||
---|---|---|
368 | 368 |
{ |
369 | 369 |
AIOReq *aio_req; |
370 | 370 |
|
371 |
aio_req = qemu_malloc(sizeof(*aio_req));
|
|
371 |
aio_req = g_malloc(sizeof(*aio_req));
|
|
372 | 372 |
aio_req->aiocb = acb; |
373 | 373 |
aio_req->iov_offset = iov_offset; |
374 | 374 |
aio_req->oid = oid; |
... | ... | |
390 | 390 |
SheepdogAIOCB *acb = aio_req->aiocb; |
391 | 391 |
QLIST_REMOVE(aio_req, outstanding_aio_siblings); |
392 | 392 |
QLIST_REMOVE(aio_req, aioreq_siblings); |
393 |
qemu_free(aio_req);
|
|
393 |
g_free(aio_req);
|
|
394 | 394 |
|
395 | 395 |
return !QLIST_EMPTY(&acb->aioreq_head); |
396 | 396 |
} |
... | ... | |
470 | 470 |
for (i = 0; i < msg->msg_iovlen; i++) { |
471 | 471 |
size += msg->msg_iov[i].iov_len; |
472 | 472 |
} |
473 |
buf = qemu_malloc(size);
|
|
473 |
buf = g_malloc(size);
|
|
474 | 474 |
|
475 | 475 |
p = buf; |
476 | 476 |
for (i = 0; i < msg->msg_iovlen; i++) { |
... | ... | |
480 | 480 |
|
481 | 481 |
ret = send(s, buf, size, flags); |
482 | 482 |
|
483 |
qemu_free(buf);
|
|
483 |
g_free(buf);
|
|
484 | 484 |
return ret; |
485 | 485 |
} |
486 | 486 |
|
... | ... | |
494 | 494 |
for (i = 0; i < msg->msg_iovlen; i++) { |
495 | 495 |
size += msg->msg_iov[i].iov_len; |
496 | 496 |
} |
497 |
buf = qemu_malloc(size);
|
|
497 |
buf = g_malloc(size);
|
|
498 | 498 |
|
499 | 499 |
ret = qemu_recv(s, buf, size, flags); |
500 | 500 |
if (ret < 0) { |
... | ... | |
507 | 507 |
p += msg->msg_iov[i].iov_len; |
508 | 508 |
} |
509 | 509 |
out: |
510 |
qemu_free(buf);
|
|
510 |
g_free(buf);
|
|
511 | 511 |
return ret; |
512 | 512 |
} |
513 | 513 |
|
... | ... | |
952 | 952 |
char *p, *q; |
953 | 953 |
int nr_sep; |
954 | 954 |
|
955 |
p = q = qemu_strdup(filename);
|
|
955 |
p = q = g_strdup(filename);
|
|
956 | 956 |
|
957 | 957 |
/* count the number of separators */ |
958 | 958 |
nr_sep = 0; |
... | ... | |
992 | 992 |
} |
993 | 993 |
|
994 | 994 |
if (s->addr == NULL) { |
995 |
qemu_free(q);
|
|
995 |
g_free(q);
|
|
996 | 996 |
} |
997 | 997 |
|
998 | 998 |
return 0; |
... | ... | |
1210 | 1210 |
goto out; |
1211 | 1211 |
} |
1212 | 1212 |
|
1213 |
buf = qemu_malloc(SD_INODE_SIZE);
|
|
1213 |
buf = g_malloc(SD_INODE_SIZE);
|
|
1214 | 1214 |
ret = read_object(fd, buf, vid_to_vdi_oid(vid), 0, SD_INODE_SIZE, 0); |
1215 | 1215 |
|
1216 | 1216 |
closesocket(fd); |
... | ... | |
1225 | 1225 |
|
1226 | 1226 |
bs->total_sectors = s->inode.vdi_size / SECTOR_SIZE; |
1227 | 1227 |
strncpy(s->name, vdi, sizeof(s->name)); |
1228 |
qemu_free(buf);
|
|
1228 |
g_free(buf);
|
|
1229 | 1229 |
return 0; |
1230 | 1230 |
out: |
1231 | 1231 |
qemu_aio_set_fd_handler(s->fd, NULL, NULL, NULL, NULL, NULL); |
1232 | 1232 |
if (s->fd >= 0) { |
1233 | 1233 |
closesocket(s->fd); |
1234 | 1234 |
} |
1235 |
qemu_free(buf);
|
|
1235 |
g_free(buf);
|
|
1236 | 1236 |
return -1; |
1237 | 1237 |
} |
1238 | 1238 |
|
... | ... | |
1291 | 1291 |
BlockDriverState *bs = NULL; |
1292 | 1292 |
uint32_t idx, max_idx; |
1293 | 1293 |
int64_t vdi_size; |
1294 |
void *buf = qemu_mallocz(SD_DATA_OBJ_SIZE);
|
|
1294 |
void *buf = g_malloc0(SD_DATA_OBJ_SIZE);
|
|
1295 | 1295 |
int ret; |
1296 | 1296 |
|
1297 | 1297 |
ret = bdrv_file_open(&bs, filename, BDRV_O_RDWR); |
... | ... | |
1324 | 1324 |
if (bs) { |
1325 | 1325 |
bdrv_delete(bs); |
1326 | 1326 |
} |
1327 |
qemu_free(buf);
|
|
1327 |
g_free(buf);
|
|
1328 | 1328 |
|
1329 | 1329 |
return ret; |
1330 | 1330 |
} |
... | ... | |
1444 | 1444 |
|
1445 | 1445 |
qemu_aio_set_fd_handler(s->fd, NULL, NULL, NULL, NULL, NULL); |
1446 | 1446 |
closesocket(s->fd); |
1447 |
qemu_free(s->addr);
|
|
1447 |
g_free(s->addr);
|
|
1448 | 1448 |
} |
1449 | 1449 |
|
1450 | 1450 |
static int64_t sd_getlength(BlockDriverState *bs) |
... | ... | |
1542 | 1542 |
|
1543 | 1543 |
dprintf("%" PRIx32 " is snapshot.\n", s->inode.vdi_id); |
1544 | 1544 |
|
1545 |
buf = qemu_malloc(SD_INODE_SIZE);
|
|
1545 |
buf = g_malloc(SD_INODE_SIZE);
|
|
1546 | 1546 |
|
1547 | 1547 |
ret = do_sd_create(s->name, s->inode.vdi_size, s->inode.vdi_id, &vid, 1, |
1548 | 1548 |
s->addr, s->port); |
... | ... | |
1574 | 1574 |
dprintf("%" PRIx32 " was newly created.\n", s->inode.vdi_id); |
1575 | 1575 |
|
1576 | 1576 |
out: |
1577 |
qemu_free(buf);
|
|
1577 |
g_free(buf);
|
|
1578 | 1578 |
|
1579 | 1579 |
return ret; |
1580 | 1580 |
} |
... | ... | |
1786 | 1786 |
goto cleanup; |
1787 | 1787 |
} |
1788 | 1788 |
|
1789 |
inode = (SheepdogInode *)qemu_malloc(datalen);
|
|
1789 |
inode = (SheepdogInode *)g_malloc(datalen);
|
|
1790 | 1790 |
|
1791 | 1791 |
ret = read_object(fd, (char *)inode, vid_to_vdi_oid(new_vid), |
1792 | 1792 |
s->inode.nr_copies, datalen, 0); |
... | ... | |
1816 | 1816 |
uint32_t snapid = 0; |
1817 | 1817 |
int ret = -ENOENT, fd; |
1818 | 1818 |
|
1819 |
old_s = qemu_malloc(sizeof(BDRVSheepdogState));
|
|
1819 |
old_s = g_malloc(sizeof(BDRVSheepdogState));
|
|
1820 | 1820 |
|
1821 | 1821 |
memcpy(old_s, s, sizeof(BDRVSheepdogState)); |
1822 | 1822 |
|
... | ... | |
1842 | 1842 |
goto out; |
1843 | 1843 |
} |
1844 | 1844 |
|
1845 |
buf = qemu_malloc(SD_INODE_SIZE);
|
|
1845 |
buf = g_malloc(SD_INODE_SIZE);
|
|
1846 | 1846 |
ret = read_object(fd, buf, vid_to_vdi_oid(vid), s->inode.nr_copies, |
1847 | 1847 |
SD_INODE_SIZE, 0); |
1848 | 1848 |
|
... | ... | |
1863 | 1863 |
|
1864 | 1864 |
s->is_snapshot = 1; |
1865 | 1865 |
|
1866 |
qemu_free(buf);
|
|
1867 |
qemu_free(old_s);
|
|
1866 |
g_free(buf);
|
|
1867 |
g_free(old_s);
|
|
1868 | 1868 |
|
1869 | 1869 |
return 0; |
1870 | 1870 |
out: |
1871 | 1871 |
/* recover bdrv_sd_state */ |
1872 | 1872 |
memcpy(s, old_s, sizeof(BDRVSheepdogState)); |
1873 |
qemu_free(buf);
|
|
1874 |
qemu_free(old_s);
|
|
1873 |
g_free(buf);
|
|
1874 |
g_free(old_s);
|
|
1875 | 1875 |
|
1876 | 1876 |
error_report("failed to open. recover old bdrv_sd_state."); |
1877 | 1877 |
|
... | ... | |
1898 | 1898 |
uint64_t hval; |
1899 | 1899 |
uint32_t vid; |
1900 | 1900 |
|
1901 |
vdi_inuse = qemu_malloc(max);
|
|
1901 |
vdi_inuse = g_malloc(max);
|
|
1902 | 1902 |
|
1903 | 1903 |
fd = connect_to_sdog(s->addr, s->port); |
1904 | 1904 |
if (fd < 0) { |
... | ... | |
1920 | 1920 |
goto out; |
1921 | 1921 |
} |
1922 | 1922 |
|
1923 |
sn_tab = qemu_mallocz(nr * sizeof(*sn_tab));
|
|
1923 |
sn_tab = g_malloc0(nr * sizeof(*sn_tab));
|
|
1924 | 1924 |
|
1925 | 1925 |
/* calculate a vdi id with hash function */ |
1926 | 1926 |
hval = fnv_64a_buf(s->name, strlen(s->name), FNV1A_64_INIT); |
... | ... | |
1963 | 1963 |
out: |
1964 | 1964 |
*psn_tab = sn_tab; |
1965 | 1965 |
|
1966 |
qemu_free(vdi_inuse);
|
|
1966 |
g_free(vdi_inuse);
|
|
1967 | 1967 |
|
1968 | 1968 |
return found; |
1969 | 1969 |
} |
Also available in: Unified diff