[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 05/10] sheepdog: use heap instead of stack for BDRVS
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 05/10] sheepdog: use heap instead of stack for BDRVSheepdogState |
Date: |
Fri, 25 May 2012 19:38:49 +0200 |
From: MORITA Kazutaka <address@hidden>
bdrv_create() is called in coroutine context now, so we cannot use
more stack than 1 MB in the function if we use ucontext coroutine.
This patch allocates BDRVSheepdogState, whose size is 4 MB, on the
heap in sd_create().
Signed-off-by: MORITA Kazutaka <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/sheepdog.c | 35 ++++++++++++++++++++++-------------
1 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index 991133e..6d52277 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -1249,24 +1249,26 @@ out:
static int sd_create(const char *filename, QEMUOptionParameter *options)
{
- int ret;
+ int ret = 0;
uint32_t vid = 0, base_vid = 0;
int64_t vdi_size = 0;
char *backing_file = NULL;
- BDRVSheepdogState s;
+ BDRVSheepdogState *s;
char vdi[SD_MAX_VDI_LEN], tag[SD_MAX_VDI_TAG_LEN];
uint32_t snapid;
int prealloc = 0;
const char *vdiname;
+ s = g_malloc0(sizeof(BDRVSheepdogState));
+
strstart(filename, "sheepdog:", &vdiname);
- memset(&s, 0, sizeof(s));
memset(vdi, 0, sizeof(vdi));
memset(tag, 0, sizeof(tag));
- if (parse_vdiname(&s, vdiname, vdi, &snapid, tag) < 0) {
+ if (parse_vdiname(s, vdiname, vdi, &snapid, tag) < 0) {
error_report("invalid filename");
- return -EINVAL;
+ ret = -EINVAL;
+ goto out;
}
while (options && options->name) {
@@ -1282,7 +1284,8 @@ static int sd_create(const char *filename,
QEMUOptionParameter *options)
} else {
error_report("Invalid preallocation mode: '%s'",
options->value.s);
- return -EINVAL;
+ ret = -EINVAL;
+ goto out;
}
}
options++;
@@ -1290,7 +1293,8 @@ static int sd_create(const char *filename,
QEMUOptionParameter *options)
if (vdi_size > SD_MAX_VDI_SIZE) {
error_report("too big image size");
- return -EINVAL;
+ ret = -EINVAL;
+ goto out;
}
if (backing_file) {
@@ -1302,12 +1306,13 @@ static int sd_create(const char *filename,
QEMUOptionParameter *options)
drv = bdrv_find_protocol(backing_file);
if (!drv || strcmp(drv->protocol_name, "sheepdog") != 0) {
error_report("backing_file must be a sheepdog image");
- return -EINVAL;
+ ret = -EINVAL;
+ goto out;
}
ret = bdrv_file_open(&bs, backing_file, 0);
if (ret < 0) {
- return ret;
+ goto out;
}
s = bs->opaque;
@@ -1315,19 +1320,23 @@ static int sd_create(const char *filename,
QEMUOptionParameter *options)
if (!is_snapshot(&s->inode)) {
error_report("cannot clone from a non snapshot vdi");
bdrv_delete(bs);
- return -EINVAL;
+ ret = -EINVAL;
+ goto out;
}
base_vid = s->inode.vdi_id;
bdrv_delete(bs);
}
- ret = do_sd_create(vdi, vdi_size, base_vid, &vid, 0, s.addr, s.port);
+ ret = do_sd_create(vdi, vdi_size, base_vid, &vid, 0, s->addr, s->port);
if (!prealloc || ret) {
- return ret;
+ goto out;
}
- return sd_prealloc(filename);
+ ret = sd_prealloc(filename);
+out:
+ g_free(s);
+ return ret;
}
static void sd_close(BlockDriverState *bs)
--
1.7.6.5
- [Qemu-devel] [PULL 00/10] Block patches for 1.1, Kevin Wolf, 2012/05/25
- [Qemu-devel] [PATCH 01/10] qcow2: don't leak buffer for unexpected qcow_version in header, Kevin Wolf, 2012/05/25
- [Qemu-devel] [PATCH 02/10] qemu-img: Explain how rebase operation can be used to perform a 'diff' operation., Kevin Wolf, 2012/05/25
- [Qemu-devel] [PATCH 03/10] sheepdog: mark image as snapshot when tag is specified, Kevin Wolf, 2012/05/25
- [Qemu-devel] [PATCH 04/10] sheepdog: return -errno on error, Kevin Wolf, 2012/05/25
- [Qemu-devel] [PATCH 06/10] qcow2: Check qcow2_alloc_clusters_at() return value, Kevin Wolf, 2012/05/25
- [Qemu-devel] [PATCH 05/10] sheepdog: use heap instead of stack for BDRVSheepdogState,
Kevin Wolf <=
- [Qemu-devel] [PATCH 09/10] fdc: fix media detection, Kevin Wolf, 2012/05/25
- [Qemu-devel] [PATCH 08/10] fdc: floppy drive should be visible after start without media, Kevin Wolf, 2012/05/25
- [Qemu-devel] [PATCH 07/10] qemu-iotests: mark 035 qcow2-only, Kevin Wolf, 2012/05/25
- [Qemu-devel] [PATCH 10/10] fdc-test: introduced qtest no_media_on_start and cmos qtest for floppy, Kevin Wolf, 2012/05/25
- Re: [Qemu-devel] [PULL 00/10] Block patches for 1.1, Anthony Liguori, 2012/05/29