mirror of https://github.com/xemu-project/xemu.git
block: gluster - code movements, state storage changes
In preparation for supporting reopen on gluster, move flag parsing out to a function. Also, add a NULL check in the gconf cleanup. Signed-off-by: Jeff Cody <jcody@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
9a05feabd5
commit
1b37b3442f
|
@ -45,11 +45,13 @@ typedef struct GlusterConf {
|
||||||
|
|
||||||
static void qemu_gluster_gconf_free(GlusterConf *gconf)
|
static void qemu_gluster_gconf_free(GlusterConf *gconf)
|
||||||
{
|
{
|
||||||
g_free(gconf->server);
|
if (gconf) {
|
||||||
g_free(gconf->volname);
|
g_free(gconf->server);
|
||||||
g_free(gconf->image);
|
g_free(gconf->volname);
|
||||||
g_free(gconf->transport);
|
g_free(gconf->image);
|
||||||
g_free(gconf);
|
g_free(gconf->transport);
|
||||||
|
g_free(gconf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_volume_options(GlusterConf *gconf, char *path)
|
static int parse_volume_options(GlusterConf *gconf, char *path)
|
||||||
|
@ -272,11 +274,28 @@ static QemuOptsList runtime_opts = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void qemu_gluster_parse_flags(int bdrv_flags, int *open_flags)
|
||||||
|
{
|
||||||
|
assert(open_flags != NULL);
|
||||||
|
|
||||||
|
*open_flags |= O_BINARY;
|
||||||
|
|
||||||
|
if (bdrv_flags & BDRV_O_RDWR) {
|
||||||
|
*open_flags |= O_RDWR;
|
||||||
|
} else {
|
||||||
|
*open_flags |= O_RDONLY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((bdrv_flags & BDRV_O_NOCACHE)) {
|
||||||
|
*open_flags |= O_DIRECT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int qemu_gluster_open(BlockDriverState *bs, QDict *options,
|
static int qemu_gluster_open(BlockDriverState *bs, QDict *options,
|
||||||
int bdrv_flags, Error **errp)
|
int bdrv_flags, Error **errp)
|
||||||
{
|
{
|
||||||
BDRVGlusterState *s = bs->opaque;
|
BDRVGlusterState *s = bs->opaque;
|
||||||
int open_flags = O_BINARY;
|
int open_flags = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
GlusterConf *gconf = g_malloc0(sizeof(GlusterConf));
|
GlusterConf *gconf = g_malloc0(sizeof(GlusterConf));
|
||||||
QemuOpts *opts;
|
QemuOpts *opts;
|
||||||
|
@ -299,15 +318,7 @@ static int qemu_gluster_open(BlockDriverState *bs, QDict *options,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bdrv_flags & BDRV_O_RDWR) {
|
qemu_gluster_parse_flags(bdrv_flags, &open_flags);
|
||||||
open_flags |= O_RDWR;
|
|
||||||
} else {
|
|
||||||
open_flags |= O_RDONLY;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((bdrv_flags & BDRV_O_NOCACHE)) {
|
|
||||||
open_flags |= O_DIRECT;
|
|
||||||
}
|
|
||||||
|
|
||||||
s->fd = glfs_open(s->glfs, gconf->image, open_flags);
|
s->fd = glfs_open(s->glfs, gconf->image, open_flags);
|
||||||
if (!s->fd) {
|
if (!s->fd) {
|
||||||
|
|
Loading…
Reference in New Issue