Skip to contentSkip to conversation

GlusterFS support in QEMU - v2

RFC PATCH Superseded Bharata B Rao 8 participants 20 messages Jul 21, 2012 – Jul 24, 2012 Block layer

v1 of 10 Superseded Latest is v10 →

lore
Share & tools
lore
#0 lore raw

cover GlusterFS support in QEMU - v2

Hi,

Here is the v2 patchset for supporting GlusterFS protocol from QEMU.

This set of patches enables QEMU to boot VM images from gluster volumes. This is achieved by adding gluster as a new block backend driver in QEMU. Its already possible to boot from VM images on gluster volumes, but this patchset provides the ability to boot VM images from gluster volumes by by-passing the FUSE layer in gluster. In case the image is present on the local system, it is possible to even bypass client and server translator and hence the RPC overhead.

The major change in this version is to not implement libglusterfs based gluster backend within QEMU but instead use libgfapi. libgfapi library from GlusterFS project provides APIs to access gluster volumes directly. With the use of libgfapi, the specification of gluster backend from QEMU matches more closely with the GlusterFS's way of specifying volumes. We now specify the gluster backed image like this:

-drive file=gluster:server@port:volname:image

- Here 'gluster' is the protocol.
- 'server@port' specifies the server where the volume file specification for the given volume resides. 'port' is the port number on which gluster management daemon (glusterd) is listening. This is optional and if not specified, QEMU will send 0 which will make libgfapi to use the default port.
- 'volname' is the name of the gluster volume which contains the VM image.
- 'image' is the path to the actual VM image in the gluster volume.

Note that we are no longer using volfiles directly and use volume names instead. For this to work, gluster management daemon (glusterd) needs to be running on the QEMU node. This limits the QEMU user to access the volumes by the default volfiles that are generated by gluster CLI. This should be fine as long as gluster CLI provides the capability to generate or regenerate volume files for a given volume with the xlator set that QEMU user is interested in. GlusterFS developers tell me that this can be provided with some enhancements to Gluster CLI/glusterd. Note that the custom volume files is typically needed when GlusterFS server is co-located with QEMU in which case it would be beneficial to get rid of client-server overhead and RPC communication overhead.

Using the patches
=================
- GlusterFS backend is enabled by specifying --enable-glusterfs with the configure script.
- You need to have installed GlusterFS from latest gluster git which provides the required libgfapi library. (git://git.gluster.com/glusterfs.git)
- As mentioned above, the VM image on gluster volume can be specified like this:
-drive file=gluster:localhost:testvol:/F17,format=gluster

Note that format=gluster is not needed ideally and its a work around I have until libgfapi provides a working connection cleanup routine (glfs_fini()). When the format isn't specified, QEMU figures out the format by doing find_image_format that results in one open and close before opening the image file long term for standard read and write. Gluster connection initialization is done from open and connection termination is done from close. But since glfs_fini() isn't working yet, I am bypassing find_image_format by specifying format=gluster directly which results in just one open and hence I am not limited by glfs_fini().

Changes for v2
==============
- Removed the libglusterfs based gluster backend implementation within QEMU and instead using the APIs from libgfapi.
- Change in the specification from file=gluster:volfile:image to file=gluster:server@port:volname:image. format=gluster is no longer specified.
- Passing iovectors obtained from generic block layer of QEMU directly to libgfapi instead of converting them to linear buffers.
- Processing the aio call back directly from the read thread of event handler pipe instead of scheduling a BH and delegating the processing to that BH.
- Added async flush (fsync) support.
- Refusal to handle partial read/writes in gluster block driver.
- Other minor cleanups based on review comments from v1 post. There is one comment that is yet to be addressed (using a local argument vs using a field of bs - Stefan), I will address them in the next iteration.

v1
== lists.nongnu.org/archive/html/qemu-devel/2012-06/msg01745.html

fio benchmark numbers
=====================
Environment
-----------
Dual core x86_64 laptop
QEMU (c0958559b1a58)
GlusterFS (35810fb2a7a12)
Guest: Fedora 16 (kernel 3.1.0-7.fc16.x86_64)
Host: Fedora 16 (kernel 3.4)
fio-HEAD-47ea504

fio jobfile
-----------

# cat aio-read-direct-seq 
; Read 4 files with aio at different depths
[global]
ioengine=libaio
direct=1
rw=read
bs=128k
size=512m
directory=/data1

[file1]
iodepth=4

[file2]
iodepth=32

[file3]
iodepth=8

[file4]
iodepth=16

Scenarios
---------
Base: QEMU boots from directly from image on gluster brick.
Fuse mount: QEMU boots from VM image on gluster FUSE mount.
Fuse bypass: QEMU uses gluster protocol and uses standard client volfile. Fuse bypass custom: QEMU uses gluster protocol and uses a minimal client
volfile that just has client xlator.
RPC bypass: QEMU uses just posix xlator and doesn't depend on gluster server.

Numbers (aggrb, minb and maxb in kB/s. mint and maxt in msec)
-------
aggrb minb maxb mint maxt
Base 63076 15769 17488 29979 33248
Fuse mount 29392 7348 9266 56581 71350
Fuse bypass 53609 13402 14909 35164 39119
Fuse bypass custom 62968 15742 17962 29188 33305
RPC bypass 63505 15876 18534 28287 33023

All the scenarios used if=virtio and cache=none options.

#1 lore raw

RFC PATCH 1/2 qemu: Add a config option for GlusterFS as block backend

qemu: Add a config option for GlusterFS as block backend

From: Bharata B Rao <[email protected]>

---

 configure |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)
configure +34 -0
index 500fe24..03547b9 100755
@@ -824,6 +824,10 @@ for opt do
   ;;
   --disable-guest-agent) guest_agent="no"
   ;;
+  --disable-glusterfs) glusterfs="no"
+  ;;
+  --enable-glusterfs) glusterfs="yes"
+  ;;
   *) echo "ERROR: unknown option $opt"; show_help="yes"
   ;;
   esac
@@ -1110,6 +1114,8 @@ echo "  --disable-guest-agent    disable building of the QEMU Guest Agent"
 echo "  --enable-guest-agent     enable building of the QEMU Guest Agent"
 echo "  --with-coroutine=BACKEND coroutine backend. Supported options:"
 echo "                           gthread, ucontext, sigaltstack, windows"
+echo "  --enable-glusterfs       enable GlusterFS backend"
+echo "  --disable-glusterfs      disable GlusterFS backend"
 echo ""
 echo "NOTE: The object files are built at the place where configure is launched"
 exit 1
@@ -2259,6 +2265,29 @@ EOF
   fi
 fi
 
+##########################################
+# glusterfs probe
+if test "$glusterfs" != "no" ; then
+  cat > $TMPC <<EOF
+#include <glusterfs/api/glfs.h>
+int main(void) {
+    (void) glfs_new("volume");
+    return 0;
+}
+EOF
+  glusterfs_libs="-lgfapi -lgfrpc -lgfxdr"
+  if compile_prog "" "$glusterfs_libs" ; then
+    glusterfs=yes
+    libs_tools="$glusterfs_libs $libs_tools"
+    libs_softmmu="$glusterfs_libs $libs_softmmu"
+  else
+    if test "$glusterfs" = "yes" ; then
+      feature_not_found "GlusterFS backend support"
+    fi
+    glusterfs=no
+  fi
+fi
+
 #
 # Check for xxxat() functions when we are building linux-user
 # emulator.  This is done because older glibc versions don't
@@ -3055,6 +3084,7 @@ echo "OpenGL support    $opengl"
 echo "libiscsi support  $libiscsi"
 echo "build guest agent $guest_agent"
 echo "coroutine backend $coroutine_backend"
+echo "GlusterFS support $glusterfs"
 
 if test "$sdl_too_old" = "yes"; then
 echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -3384,6 +3414,10 @@ if test "$has_environ" = "yes" ; then
   echo "CONFIG_HAS_ENVIRON=y" >> $config_host_mak
 fi
 
+if test "$glusterfs" = "yes" ; then
+  echo "CONFIG_GLUSTERFS=y" >> $config_host_mak
+fi
+
 # USB host support
 case "$usb" in
 linux)
#2 lore raw

RFC PATCH 2/2 block: gluster as block backend

In reply to Bharata B Rao

block: gluster as block backend

From: Bharata B Rao <[email protected]>

This patch adds gluster as the new block backend in QEMU. This gives QEMU the ability to boot VM images from gluster volumes.

---

 block/Makefile.objs |    1 
 block/gluster.c     |  483 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 484 insertions(+), 0 deletions(-)
 create mode 100644 block/gluster.c
block/Makefile.objs +1 -0
index b5754d3..a1ae67f 100644
@@ -9,3 +9,4 @@ block-obj-$(CONFIG_POSIX) += raw-posix.o
 block-obj-$(CONFIG_LIBISCSI) += iscsi.o
 block-obj-$(CONFIG_CURL) += curl.o
 block-obj-$(CONFIG_RBD) += rbd.o
+block-obj-$(CONFIG_GLUSTERFS) += gluster.o
block/gluster.c new file +483 -0

483 lines not on this page · raw message

#3 lore raw

Re: [Qemu-devel] [RFC PATCH 2/2] block: gluster as block backend

block/gluster.c line 24

Quoted 3 lines · Bharata B Rao
block/gluster.c new file +3 -0
+typedef struct GlusterAIOCB {
+    BlockDriverAIOCB common;
+    QEMUIOVector *qiov;

The qiov field is unused.

Quoted 1 line

+ char *bounce;

Unused.

Quoted 1 line

+ struct BDRVGlusterState *s;

You can get this through common.bs->opaque, but if you like having a shortcut, that's fine.

Quoted 1 line

+ int cancelled;

bool

block/gluster.c line 35

Quoted 8 lines
block/gluster.c new file +8 -0
+} GlusterAIOCB;
+
+typedef struct GlusterCBKData {
+    GlusterAIOCB *acb;
+    struct BDRVGlusterState *s;
+    int64_t size;
+    int ret;
+} GlusterCBKData;

I think GlusterCBKData could just be part of GlusterAIOCB. That would simplify the code a little and avoid some malloc/free.

Quoted 10 lines
block/gluster.c new file +10 -0
+
+typedef struct BDRVGlusterState {
+    struct glfs *glfs;
+    int fds[2];
+    int open_flags;
+    struct glfs_fd *fd;
+    int qemu_aio_count;
+    int event_reader_pos;
+    GlusterCBKData *event_gcbk;
+} BDRVGlusterState;

block/gluster.c line 55

Quoted 10 lines
block/gluster.c new file +10 -0
+
+#define GLUSTER_FD_READ 0
+#define GLUSTER_FD_WRITE 1
+
+static void qemu_gluster_complete_aio(GlusterCBKData *gcbk)
+{
+    GlusterAIOCB *acb = gcbk->acb;
+    int ret;
+
+    if (acb->cancelled) {

Where does cancelled get set?

block/gluster.c line 65

Quoted 10 lines
block/gluster.c new file +10 -0
+        qemu_aio_release(acb);
+        goto done;
+    }
+
+    if (gcbk->ret == gcbk->size) {
+        ret = 0; /* Success */
+    } else if (gcbk->ret < 0) {
+        ret = gcbk->ret; /* Read/Write failed */
+    } else {
+        ret = -EINVAL; /* Partial read/write - fail it */

EINVAL is for invalid arguments. EIO would be better.

Quoted 17 lines
block/gluster.c new file +17 -0
+/*
+ * file=protocol:server@port:volname:image
+ */
+static int qemu_gluster_parsename(GlusterConf *c, const char *filename)
+{
+    char *file = g_strdup(filename);
+    char *token, *next_token, *saveptr;
+    char *token_s, *next_token_s, *saveptr_s;
+    int ret = -EINVAL;
+
+    /* Discard the protocol */
+    token = strtok_r(file, ":", &saveptr);
+    if (!token) {
+        goto out;
+    }
+
+    /* server@port */

block/gluster.c line 128

Quoted 10 lines
block/gluster.c new file +10 -0
+    next_token = strtok_r(NULL, ":", &saveptr);
+    if (!next_token) {
+        goto out;
+    }
+    if (strchr(next_token, '@')) {
+        token_s = strtok_r(next_token, "@", &saveptr_s);
+        if (!token_s) {
+            goto out;
+        }
+        strncpy(c->server, token_s, HOST_NAME_MAX);

strncpy(3) will not NUL-terminate when token_s is HOST_NAME_MAX characters long. QEMU has cutils.c:pstrcpy().

When the argument is too long we should probably report an error instead of truncating.

Same below.

block/gluster.c line 133

Quoted 5 lines
block/gluster.c new file +5 -0
+        next_token_s = strtok_r(NULL, "@", &saveptr_s);
+        if (!next_token_s) {
+            goto out;
+        }
+        c->port = atoi(next_token_s);

No error checking. If the input is invalid an error message would help the user here.

Quoted 14 lines
block/gluster.c new file +14 -0
+static struct glfs *qemu_gluster_init(GlusterConf *c, const char *filename)
+{
+    struct glfs *glfs = NULL;
+    int ret;
+
+    ret = qemu_gluster_parsename(c, filename);
+    if (ret < 0) {
+        errno = -ret;
+        goto out;
+    }
+
+    glfs = glfs_new(c->volname);
+    if (!glfs) {
+        goto out;

block/gluster.c line 181

Quoted 10 lines
block/gluster.c new file +10 -0
+    }
+
+    ret = glfs_set_volfile_server(glfs, "socket", c->server, c->port);
+    if (ret < 0) {
+        goto out;
+    }
+
+    /*
+     * TODO: Logging is not necessary but instead nice to have.
+     * Can QEMU optionally log into a standard place ?

QEMU prints to stderr, can you do that here too? The global log file is not okay, especially when multiple QEMU instances are running.

Quoted 16 lines
block/gluster.c new file +16 -0
+     * Need to use defines like gf_loglevel_t:GF_LOG_INFO instead of
+     * hard coded values like 7 here.
+     */
+    ret = glfs_set_logging(glfs, "/tmp/qemu-gluster.log", 7);
+    if (ret < 0) {
+        goto out;
+    }
+
+    ret = glfs_init(glfs);
+    if (ret < 0) {
+        goto out;
+    }
+    return glfs;
+
+out:
+    if (glfs) {

block/gluster.c line 207

Quoted 10 lines
block/gluster.c new file +10 -0
+        (void)glfs_fini(glfs);
+    }
+    return NULL;
+}
+
+static int qemu_gluster_open(BlockDriverState *bs, const char *filename,
+    int bdrv_flags)
+{
+    BDRVGlusterState *s = bs->opaque;
+    GlusterConf *c = g_malloc(sizeof(GlusterConf));

Can this be allocated on the stack?

block/gluster.c line 216

Quoted 9 lines
block/gluster.c new file +9 -0
+    int ret;
+
+    s->glfs = qemu_gluster_init(c, filename);
+    if (!s->glfs) {
+        ret = -errno;
+        goto out;
+    }
+
+    s->open_flags |=  O_BINARY;

Can open_flags be a local variable?

Quoted 14 lines
block/gluster.c new file +14 -0
+static int qemu_gluster_create(const char *filename,
+        QEMUOptionParameter *options)
+{
+    struct glfs *glfs;
+    struct glfs_fd *fd;
+    GlusterConf *c = g_malloc(sizeof(GlusterConf));
+    int ret = 0;
+    int64_t total_size = 0;
+
+    glfs = qemu_gluster_init(c, filename);
+    if (!glfs) {
+        ret = -errno;
+        goto out;
+    }

block/gluster.c line 279

Quoted 10 lines
block/gluster.c new file +10 -0
+
+    /* Read out options */
+    while (options && options->name) {
+        if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
+            total_size = options->value.n / BDRV_SECTOR_SIZE;
+        }
+        options++;
+    }
+
+    fd = glfs_creat(glfs, c->image, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU);

Why set the execute permission bit?

block/gluster.c line 450

Quoted 8 lines
block/gluster.c new file +8 -0
+static void qemu_gluster_close(BlockDriverState *bs)
+{
+    BDRVGlusterState *s = bs->opaque;
+
+    if (s->fd) {
+        glfs_close(s->fd);
+        s->fd = NULL;
+    }

Why not call glfs_fini() here?

#4 lore raw

Re: [Qemu-devel] [RFC PATCH 2/2] block: gluster as block backend

Quoted 11 lines · Stefan Hajnoczi

block/gluster.c line 24

Quoted 3 lines · Bharata B Rao
block/gluster.c new file +3 -0
+typedef struct GlusterAIOCB {
+    BlockDriverAIOCB common;
+    QEMUIOVector *qiov;

The qiov field is unused.

Quoted 1 line

+ char *bounce;

Unused.

Yes, removed these two.

Quoted 9 lines
Quoted 2 lines

+ struct BDRVGlusterState *s;

You can get this through common.bs->opaque, but if you like having a shortcut, that's fine.

Quoted 1 line

+ int cancelled;

bool

Ok.

Quoted 12 lines

block/gluster.c line 35

Quoted 9 lines
block/gluster.c new file +8 -0
+} GlusterAIOCB;
+
+typedef struct GlusterCBKData {
+    GlusterAIOCB *acb;
+    struct BDRVGlusterState *s;
+    int64_t size;
+    int ret;
+} GlusterCBKData;

I think GlusterCBKData could just be part of GlusterAIOCB. That would simplify the code a little and avoid some malloc/free.

Are you suggesting to put a field

GlusterCBKData gcbk;

inside GlusterAIOCB and use gcbk from there or

Are you suggesting that I make the fields of GlusterCBKData part of GlusterAIOCB and get rid of GlusterCBKData altogether ? This means I would have to pass the GlusterAIOCB to gluster async calls and update its fields from gluster callback routine. I can do this, but I am not sure if you can touch the fields of GlusterAIOCB in non-QEMU threads (gluster callback thread).

Quoted 15 lines
Quoted 15 lines
block/gluster.c new file +14 -0
+
+typedef struct BDRVGlusterState {
+    struct glfs *glfs;
+    int fds[2];
+    int open_flags;
+    struct glfs_fd *fd;
+    int qemu_aio_count;
+    int event_reader_pos;
+    GlusterCBKData *event_gcbk;
+} BDRVGlusterState;
+
+#define GLUSTER_FD_READ 0
+#define GLUSTER_FD_WRITE 1
+
Quoted 8 lines

block/gluster.c line 55

Quoted 6 lines
block/gluster.c new file +6 -0
+static void qemu_gluster_complete_aio(GlusterCBKData *gcbk)
+{
+    GlusterAIOCB *acb = gcbk->acb;
+    int ret;
+
+    if (acb->cancelled) {

Where does cancelled get set?

I realised that I am not supporting bdrv_aio_cancel(). I guess I will have to add support for this in next version.

Quoted 12 lines

block/gluster.c line 65

Quoted 11 lines
block/gluster.c new file +10 -0
+        qemu_aio_release(acb);
+        goto done;
+    }
+
+    if (gcbk->ret == gcbk->size) {
+        ret = 0; /* Success */
+    } else if (gcbk->ret < 0) {
+        ret = gcbk->ret; /* Read/Write failed */
+    } else {
+        ret = -EINVAL; /* Partial read/write - fail it */
Quoted 1 line

EINVAL is for invalid arguments. EIO would be better.

Ok.

Quoted 23 lines
Quoted 23 lines
block/gluster.c new file +22 -0
+/*
+ * file=protocol:server@port:volname:image
+ */
+static int qemu_gluster_parsename(GlusterConf *c, const char *filename)
+{
+    char *file = g_strdup(filename);
+    char *token, *next_token, *saveptr;
+    char *token_s, *next_token_s, *saveptr_s;
+    int ret = -EINVAL;
+
+    /* Discard the protocol */
+    token = strtok_r(file, ":", &saveptr);
+    if (!token) {
+        goto out;
+    }
+
+    /* server@port */
+    next_token = strtok_r(NULL, ":", &saveptr);
+    if (!next_token) {
+        goto out;
+    }
+    if (strchr(next_token, '@')) {
Quoted 8 lines

block/gluster.c line 128

Quoted 5 lines
block/gluster.c new file +5 -0
+        token_s = strtok_r(next_token, "@", &saveptr_s);
+        if (!token_s) {
+            goto out;
+        }
+        strncpy(c->server, token_s, HOST_NAME_MAX);

strncpy(3) will not NUL-terminate when token_s is HOST_NAME_MAX characters long. QEMU has cutils.c:pstrcpy().

Will use pstrcpy.

Quoted 3 lines

When the argument is too long we should probably report an error instead of truncating.

Or should we let gluster APIs to flag an error with truncated server and volume names ?

Quoted 11 lines

Same below.

block/gluster.c line 133

Quoted 5 lines
block/gluster.c new file +5 -0
+        next_token_s = strtok_r(NULL, "@", &saveptr_s);
+        if (!next_token_s) {
+            goto out;
+        }
+        c->port = atoi(next_token_s);

No error checking. If the input is invalid an error message would help the user here.

Fixed.

Quoted 20 lines
Quoted 20 lines
block/gluster.c new file +19 -0
+static struct glfs *qemu_gluster_init(GlusterConf *c, const char *filename)
+{
+    struct glfs *glfs = NULL;
+    int ret;
+
+    ret = qemu_gluster_parsename(c, filename);
+    if (ret < 0) {
+        errno = -ret;
+        goto out;
+    }
+
+    glfs = glfs_new(c->volname);
+    if (!glfs) {
+        goto out;
+    }
+
+    ret = glfs_set_volfile_server(glfs, "socket", c->server, c->port);
+    if (ret < 0) {
+        goto out;
Quoted 8 lines

block/gluster.c line 181

Quoted 5 lines
block/gluster.c new file +5 -0
+    }
+
+    /*
+     * TODO: Logging is not necessary but instead nice to have.
+     * Can QEMU optionally log into a standard place ?

QEMU prints to stderr, can you do that here too? The global log file is not okay, especially when multiple QEMU instances are running.

Ok, I can do glfs_set_logging(glfs, "/dev/stderr", loglevel);

Quoted 21 lines
Quoted 21 lines
block/gluster.c new file +20 -0
+     * Need to use defines like gf_loglevel_t:GF_LOG_INFO instead of
+     * hard coded values like 7 here.
+     */
+    ret = glfs_set_logging(glfs, "/tmp/qemu-gluster.log", 7);
+    if (ret < 0) {
+        goto out;
+    }
+
+    ret = glfs_init(glfs);
+    if (ret < 0) {
+        goto out;
+    }
+    return glfs;
+
+out:
+    if (glfs) {
+        (void)glfs_fini(glfs);
+    }
+    return NULL;
+}
Quoted 8 lines

block/gluster.c line 207

Quoted 6 lines
block/gluster.c new file +6 -0
+
+static int qemu_gluster_open(BlockDriverState *bs, const char *filename,
+    int bdrv_flags)
+{
+    BDRVGlusterState *s = bs->opaque;
+    GlusterConf *c = g_malloc(sizeof(GlusterConf));

Can this be allocated on the stack?

It consists of PATH_MAX(4096), HOST_NAME_MAX(255) and GLUSTERD_MAX_VOLUME_NAME (1000). A bit heavy to be on stack ?

Quoted 12 lines

block/gluster.c line 216

Quoted 10 lines
block/gluster.c new file +9 -0
+    int ret;
+
+    s->glfs = qemu_gluster_init(c, filename);
+    if (!s->glfs) {
+        ret = -errno;
+        goto out;
+    }
+
+    s->open_flags |=  O_BINARY;

Can open_flags be a local variable?

Yes, fixed.

Quoted 19 lines
Quoted 19 lines
block/gluster.c new file +18 -0
+static int qemu_gluster_create(const char *filename,
+        QEMUOptionParameter *options)
+{
+    struct glfs *glfs;
+    struct glfs_fd *fd;
+    GlusterConf *c = g_malloc(sizeof(GlusterConf));
+    int ret = 0;
+    int64_t total_size = 0;
+
+    glfs = qemu_gluster_init(c, filename);
+    if (!glfs) {
+        ret = -errno;
+        goto out;
+    }
+
+    /* Read out options */
+    while (options && options->name) {
+        if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
Quoted 8 lines

block/gluster.c line 279

Quoted 6 lines
block/gluster.c new file +6 -0
+            total_size = options->value.n / BDRV_SECTOR_SIZE;
+        }
+        options++;
+    }
+
+    fd = glfs_creat(glfs, c->image, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU);

Why set the execute permission bit?

Changed to read and write only.

Quoted 11 lines

block/gluster.c line 450

Quoted 9 lines
block/gluster.c new file +8 -0
+static void qemu_gluster_close(BlockDriverState *bs)
+{
+    BDRVGlusterState *s = bs->opaque;
+
+    if (s->fd) {
+        glfs_close(s->fd);
+        s->fd = NULL;
+    }

Why not call glfs_fini() here?

Missed that, fixed now.

Thanks for your comments.

Regards,
Bharata.

#5 lore raw

Re: [Qemu-devel] [RFC PATCH 2/2] block: gluster as block backend

Quoted 19 lines · Bharata B Rao
Quoted 13 lines · Stefan Hajnoczi

block/gluster.c line 35

Quoted 8 lines · Bharata B Rao
block/gluster.c new file +8 -0
+} GlusterAIOCB;
+
+typedef struct GlusterCBKData {
+    GlusterAIOCB *acb;
+    struct BDRVGlusterState *s;
+    int64_t size;
+    int ret;
+} GlusterCBKData;

I think GlusterCBKData could just be part of GlusterAIOCB. That would simplify the code a little and avoid some malloc/free.

Are you suggesting to put a field

GlusterCBKData gcbk;

Quoted 7 lines

inside GlusterAIOCB and use gcbk from there or

Are you suggesting that I make the fields of GlusterCBKData part of GlusterAIOCB and get rid of GlusterCBKData altogether ? This means I would have to pass the GlusterAIOCB to gluster async calls and update its fields from gluster callback routine. I can do this, but I am not sure if you can touch the fields of GlusterAIOCB in non-QEMU threads (gluster callback thread).

The fields in GlusterCBKData could become part of GlusterAIOCB. Different threads can access fields in a struct, they just need to ensure access is synchronized if they touch the same fields. In the case of this code I think there is nothing that requires synchronization beyond the pipe mechanism that you already use to complete processing in a QEMU thread.

Quoted 5 lines
Quoted 2 lines

When the argument is too long we should probably report an error instead of truncating.

Or should we let gluster APIs to flag an error with truncated server and volume names ?

What if the truncated name is a valid but different object? For example:
Max chars = 5
Objects:
"helloworld"
"hello"

If "helloworld" is truncated to "hello" we get no error back because it's a valid object!

We need to either check sizes explicitly without truncating or use a g_strdup() approach without any size limits and let the gfapi functions error out if the input string is too long.

Quoted 28 lines
Quoted 19 lines
Quoted 19 lines
block/gluster.c new file +19 -0
+static struct glfs *qemu_gluster_init(GlusterConf *c, const char *filename)
+{
+    struct glfs *glfs = NULL;
+    int ret;
+
+    ret = qemu_gluster_parsename(c, filename);
+    if (ret < 0) {
+        errno = -ret;
+        goto out;
+    }
+
+    glfs = glfs_new(c->volname);
+    if (!glfs) {
+        goto out;
+    }
+
+    ret = glfs_set_volfile_server(glfs, "socket", c->server, c->port);
+    if (ret < 0) {
+        goto out;
Quoted 8 lines

block/gluster.c line 181

Quoted 5 lines
block/gluster.c new file +5 -0
+    }
+
+    /*
+     * TODO: Logging is not necessary but instead nice to have.
+     * Can QEMU optionally log into a standard place ?

QEMU prints to stderr, can you do that here too? The global log file is not okay, especially when multiple QEMU instances are running.

Quoted 1 line

Ok, I can do glfs_set_logging(glfs, "/dev/stderr", loglevel);

Yes. I think "-" is best since it is supported by gfapi (libglusterfs/src/logging.c:gf_log_init). /dev/stderr is not POSIX.

Quoted 29 lines
Quoted 20 lines
Quoted 20 lines
block/gluster.c new file +20 -0
+     * Need to use defines like gf_loglevel_t:GF_LOG_INFO instead of
+     * hard coded values like 7 here.
+     */
+    ret = glfs_set_logging(glfs, "/tmp/qemu-gluster.log", 7);
+    if (ret < 0) {
+        goto out;
+    }
+
+    ret = glfs_init(glfs);
+    if (ret < 0) {
+        goto out;
+    }
+    return glfs;
+
+out:
+    if (glfs) {
+        (void)glfs_fini(glfs);
+    }
+    return NULL;
+}
Quoted 8 lines

block/gluster.c line 207

Quoted 6 lines
block/gluster.c new file +6 -0
+
+static int qemu_gluster_open(BlockDriverState *bs, const char *filename,
+    int bdrv_flags)
+{
+    BDRVGlusterState *s = bs->opaque;
+    GlusterConf *c = g_malloc(sizeof(GlusterConf));

Can this be allocated on the stack?

Quoted 2 lines

It consists of PATH_MAX(4096), HOST_NAME_MAX(255) and GLUSTERD_MAX_VOLUME_NAME (1000). A bit heavy to be on stack ?

This is userspace, stacks are big but it's up to you.

Stefan

#6 lore raw
In reply to Bharata B Rao
Quoted 14 lines · Bharata B Rao

We now
specify the gluster backed image like this:

-drive file=gluster:server@port:volname:image

- Here 'gluster' is the protocol.
- 'server@port' specifies the server where the volume file specification for the given volume resides. 'port' is the port number on which gluster management daemon (glusterd) is listening. This is optional and if not specified, QEMU will send 0 which will make libgfapi to use the default port.
- 'volname' is the name of the gluster volume which contains the VM image.
- 'image' is the path to the actual VM image in the gluster volume.

Quoted 3 lines

Note that we are no longer using volfiles directly and use volume names instead. For this to work, gluster management daemon (glusterd) needs to be running on the QEMU node.

glusterd needs to be running on the server that is specified in 'server@port' option.

Quoted 9 lines

Scenarios
---------
Base: QEMU boots from directly from image on gluster brick.
Fuse mount: QEMU boots from VM image on gluster FUSE mount.
Fuse bypass: QEMU uses gluster protocol and uses standard client volfile. Fuse bypass custom: QEMU uses gluster protocol and uses a minimal client
volfile that just has client xlator.
RPC bypass: QEMU uses just posix xlator and doesn't depend on gluster server.

For the Fuse mount, Fuse bypass and Fuse bypass custom scenarios, I assume a single local gluster brick is being used. Is this correct?

Thanks,
Vijay

#7 lore raw
Quoted 15 lines · Vijay Bellur
Quoted 14 lines · Bharata B Rao

We now
specify the gluster backed image like this:

-drive file=gluster:server@port:volname:image

- Here 'gluster' is the protocol.
- 'server@port' specifies the server where the volume file specification for the given volume resides. 'port' is the port number on which gluster management daemon (glusterd) is listening. This is optional and if not specified, QEMU will send 0 which will make libgfapi to use the default port.
- 'volname' is the name of the gluster volume which contains the VM image.
- 'image' is the path to the actual VM image in the gluster volume.

Quoted 7 lines
Quoted 3 lines

Note that we are no longer using volfiles directly and use volume names instead. For this to work, gluster management daemon (glusterd) needs to be running on the QEMU node.

glusterd needs to be running on the server that is specified in 'server@port' option.

oh yes, thanks.

Quoted 13 lines
Quoted 12 lines

Scenarios
---------
Base: QEMU boots from directly from image on gluster brick.
Fuse mount: QEMU boots from VM image on gluster FUSE mount.
Fuse bypass: QEMU uses gluster protocol and uses standard client volfile. Fuse bypass custom: QEMU uses gluster protocol and uses a minimal client
volfile that just has client xlator.
RPC bypass: QEMU uses just posix xlator and doesn't depend on gluster server.

Quoted 2 lines

For the Fuse mount, Fuse bypass and Fuse bypass custom scenarios, I assume a single local gluster brick is being used. Is this correct?

Right, fio numbers are for single local gluster brick scenario.

Regards,
Bharata.

#8 lore raw
In reply to Bharata B Rao
Quoted 8 lines · Bharata B Rao

-drive file=gluster:server@port:volname:image

- Here 'gluster' is the protocol.
- 'server@port' specifies the server where the volume file specification for the given volume resides. 'port' is the port number on which gluster management daemon (glusterd) is listening. This is optional and if not specified, QEMU will send 0 which will make libgfapi to use the default port.

'server@port' is weird notation. Normally it is 'server:port' (e.g. URLs). Can you change it?

What about the other transports supported by libgfapi: UNIX domain sockets and RDMA? My reading of glfs.h is that there are 3 connection options:
1. 'transport': 'socket' (default), 'unix', 'rdma'
2. 'host': server hostname for 'socket', path to UNIX domain socket for 'unix', or something else for 'rdma'
3. 'port': TCP port when 'socket' is used. Ignored otherwise.

Unfortunately QEMU block drivers cannot take custom options yet. That would make it possible to cleanly map these connection options and save you from inventing syntax which doesn't expose all options.

In the meantime it would be nice if the syntax exposed all options.

Quoted 11 lines

Note that we are no longer using volfiles directly and use volume names instead. For this to work, gluster management daemon (glusterd) needs to be running on the QEMU node. This limits the QEMU user to access the volumes by the default volfiles that are generated by gluster CLI. This should be fine as long as gluster CLI provides the capability to generate or regenerate volume files for a given volume with the xlator set that QEMU user is interested in. GlusterFS developers tell me that this can be provided with some enhancements to Gluster CLI/glusterd. Note that the custom volume files is typically needed when GlusterFS server is co-located with QEMU in which case it would be beneficial to get rid of client-server overhead and RPC communication overhead.

My knowledge of GlusterFS is limited. Here is what I am thinking:

1. The user cannot specify a local configuration file, you require that there is a glusterd running which provides configuration information.
2. It is currently not possible to bypass RPC because the glusterd managed configuration file doesn't support that.

I'm not sure if these statements are true?

Would you support local volfiles in the future again? Why force users to run glusterd?

Quoted 4 lines

- As mentioned above, the VM image on gluster volume can be specified like this:
-drive file=gluster:localhost:testvol:/F17,format=gluster

Quoted 9 lines

Note that format=gluster is not needed ideally and its a work around I have until libgfapi provides a working connection cleanup routine (glfs_fini()). When the format isn't specified, QEMU figures out the format by doing find_image_format that results in one open and close before opening the image file long term for standard read and write. Gluster connection initialization is done from open and connection termination is done from close. But since glfs_fini() isn't working yet, I am bypassing find_image_format by specifying format=gluster directly which results in just one open and hence I am not limited by glfs_fini().

Has libgfapi been released yet? Does it have versioning which will allow the QEMU GlusterFS block driver to build against different versions? I'm just wondering how the pieces will fit together once distros start shipping them.

Stefan

#9 lore raw
Quoted 11 lines · Stefan Hajnoczi
Quoted 8 lines · Bharata B Rao

-drive file=gluster:server@port:volname:image

- Here 'gluster' is the protocol.
- 'server@port' specifies the server where the volume file specification for the given volume resides. 'port' is the port number on which gluster management daemon (glusterd) is listening. This is optional and if not specified, QEMU will send 0 which will make libgfapi to use the default port.

Quoted 2 lines

'server@port' is weird notation. Normally it is 'server:port' (e.g. URLs). Can you change it?

I don't like but, but settled for it since port was optional and : was being used as separator here.

Quoted 9 lines

What about the other transports supported by libgfapi: UNIX domain sockets and RDMA? My reading of glfs.h is that there are 3 connection options:
1. 'transport': 'socket' (default), 'unix', 'rdma'
2. 'host': server hostname for 'socket', path to UNIX domain socket for 'unix', or something else for 'rdma'
3. 'port': TCP port when 'socket' is used. Ignored otherwise.

Quoted 5 lines

Unfortunately QEMU block drivers cannot take custom options yet. That would make it possible to cleanly map these connection options and save you from inventing syntax which doesn't expose all options.

In the meantime it would be nice if the syntax exposed all options.

So without the capability to pass custom options to block drivers, am I forced to keep extending the file= with more and more options ?

file=gluster:transport:server:port:volname:image ?

Looks ugly and not easy to make any particular option optional. If needed I can support this from GlusterFS backend.

Quoted 13 lines
Quoted 12 lines

Note that we are no longer using volfiles directly and use volume names instead. For this to work, gluster management daemon (glusterd) needs to be running on the QEMU node. This limits the QEMU user to access the volumes by the default volfiles that are generated by gluster CLI. This should be fine as long as gluster CLI provides the capability to generate or regenerate volume files for a given volume with the xlator set that QEMU user is interested in. GlusterFS developers tell me that this can be provided with some enhancements to Gluster CLI/glusterd. Note that the custom volume files is typically needed when GlusterFS server is co-located with QEMU in which case it would be beneficial to get rid of client-server overhead and RPC communication overhead.

Quoted 5 lines

My knowledge of GlusterFS is limited. Here is what I am thinking:

1. The user cannot specify a local configuration file, you require that there is a glusterd running which provides configuration information.

Yes. User only specifies a volume name and glusterd is used to fetch the right volume file for that volume name.

Quoted 2 lines

2. It is currently not possible to bypass RPC because the glusterd managed configuration file doesn't support that.

It is possible. Gluster already supports custom extensions
to volume names and it is possible to use the required volfile by specifying this custom volname extension.

For eg, if I have a volume named test, by default the volfile used for it will be test-fuse.vol. Currently I can put my own custom volfile into the standard location and get glusterd pick that up. I can specify test.rpcbypass as volname and glusterd will pick test.rpcbypass.vol.

What is currently not supported is the ability to create test.rpcbypass.vol from gluster CLI. I believe that gluster developers are ok with enhancing gluster CLI to support generating/regenerating volfiles for a given volume with custom translator set.

Quoted 5 lines

I'm not sure if these statements are true?

Would you support local volfiles in the future again? Why force users to run glusterd?

I will let gluster folks on CC to answer this and let us know the benefits of always depending on glusterd.

I guess running glusterd would be beneficial when supporting migration. QEMU working from a local volume (with volname=test.rpcbypass) can be easily restarted on a different node by just changing volname to test. glusterd will take care of fetching the right volfile automatically for us.

Quoted 15 lines
Quoted 5 lines

- As mentioned above, the VM image on gluster volume can be specified like this:
-drive file=gluster:localhost:testvol:/F17,format=gluster

Quoted 9 lines

Note that format=gluster is not needed ideally and its a work around I have until libgfapi provides a working connection cleanup routine (glfs_fini()). When the format isn't specified, QEMU figures out the format by doing find_image_format that results in one open and close before opening the image file long term for standard read and write. Gluster connection initialization is done from open and connection termination is done from close. But since glfs_fini() isn't working yet, I am bypassing find_image_format by specifying format=gluster directly which results in just one open and hence I am not limited by glfs_fini().

Quoted 1 line

Has libgfapi been released yet?

Its part of gluster mainline now.

Quoted 4 lines

Does it have versioning which will
allow the QEMU GlusterFS block driver to build against different versions? I'm just wondering how the pieces will fit together once distros start shipping them.

I request gluster folks on CC to comment about version and shipping information.

Regards,
Bharata.

#10 lore raw
Quoted 33 lines · Bharata B Rao
Quoted 11 lines · Stefan Hajnoczi
Quoted 8 lines · Bharata B Rao

-drive file=gluster:server@port:volname:image

- Here 'gluster' is the protocol.
- 'server@port' specifies the server where the volume file specification for the given volume resides. 'port' is the port number on which gluster management daemon (glusterd) is listening. This is optional and if not specified, QEMU will send 0 which will make libgfapi to use the default port.

Quoted 2 lines

'server@port' is weird notation. Normally it is 'server:port' (e.g. URLs). Can you change it?

I don't like but, but settled for it since port was optional and : was being used as separator here.

Quoted 9 lines

What about the other transports supported by libgfapi: UNIX domain sockets and RDMA? My reading of glfs.h is that there are 3 connection options:
1. 'transport': 'socket' (default), 'unix', 'rdma'
2. 'host': server hostname for 'socket', path to UNIX domain socket for 'unix', or something else for 'rdma'
3. 'port': TCP port when 'socket' is used. Ignored otherwise.

Quoted 5 lines

Unfortunately QEMU block drivers cannot take custom options yet. That would make it possible to cleanly map these connection options and save you from inventing syntax which doesn't expose all options.

In the meantime it would be nice if the syntax exposed all options.

Quoted 7 lines

So without the capability to pass custom options to block drivers, am I forced to keep extending the file= with more and more options ?

file=gluster:transport:server:port:volname:image ?

Looks ugly and not easy to make any particular option optional. If needed I can support this from GlusterFS backend.

Kevin, Markus: Any thoughts on passing options to block drivers? Encoding GlusterFS options into a "filename" string is pretty cumbersome.

#11 lore raw

Stefan,

in iscsi, i just specify those extra arguments that are required that are not part of the url itself as just command line options :

qemu-system-i386 -iscsi initiator-name=iqn.qemu.test:my-initiator \
    -boot d -drive file=iscsi://127.0.0.1/iqn.qemu.test/1 \
    -cdrom iscsi://127.0.0.1/iqn.qemu.test/2

Here initiator-name is a custom option to the iscsi layer to tell it which name to use when identifying/logging in to the target.

Similar concept could be used by glusterfs ?

regards
ronnie sahlberg

Quoted 47 lines · Stefan Hajnoczi
Quoted 33 lines · Bharata B Rao
Quoted 11 lines · Stefan Hajnoczi
Quoted 8 lines · Bharata B Rao

-drive file=gluster:server@port:volname:image

- Here 'gluster' is the protocol.
- 'server@port' specifies the server where the volume file specification for the given volume resides. 'port' is the port number on which gluster management daemon (glusterd) is listening. This is optional and if not specified, QEMU will send 0 which will make libgfapi to use the default port.

Quoted 2 lines

'server@port' is weird notation. Normally it is 'server:port' (e.g. URLs). Can you change it?

I don't like but, but settled for it since port was optional and : was being used as separator here.

Quoted 9 lines

What about the other transports supported by libgfapi: UNIX domain sockets and RDMA? My reading of glfs.h is that there are 3 connection options:
1. 'transport': 'socket' (default), 'unix', 'rdma'
2. 'host': server hostname for 'socket', path to UNIX domain socket for 'unix', or something else for 'rdma'
3. 'port': TCP port when 'socket' is used. Ignored otherwise.

Quoted 5 lines

Unfortunately QEMU block drivers cannot take custom options yet. That would make it possible to cleanly map these connection options and save you from inventing syntax which doesn't expose all options.

In the meantime it would be nice if the syntax exposed all options.

Quoted 7 lines

So without the capability to pass custom options to block drivers, am I forced to keep extending the file= with more and more options ?

file=gluster:transport:server:port:volname:image ?

Looks ugly and not easy to make any particular option optional. If needed I can support this from GlusterFS backend.

Kevin, Markus: Any thoughts on passing options to block drivers? Encoding GlusterFS options into a "filename" string is pretty cumbersome.

#12 lore raw
Quoted 4 lines · ronnie sahlberg

in iscsi, i just specify those extra arguments that are required that are not part of the url itself as just command line options :

Quoted 8 lines
qemu-system-i386 -iscsi initiator-name=iqn.qemu.test:my-initiator \
    -boot d -drive file=iscsi://127.0.0.1/iqn.qemu.test/1 \
    -cdrom iscsi://127.0.0.1/iqn.qemu.test/2

Here initiator-name is a custom option to the iscsi layer to tell it which name to use when identifying/logging in to the target.

Similar concept could be used by glusterfs ?

That works for global options only. If it's per-drive then this approach can't be used because different drives might need different option values.

Stefan

#13 lore raw
In reply to Stefan Hajnoczi
Quoted 4 lines · Stefan Hajnoczi
Quoted 4 lines

So without the capability to pass custom options to block drivers, am I forced to keep extending the file= with more and more options ?

Quoted 8 lines
Quoted 4 lines

file=gluster:transport:server:port:volname:image ?

Looks ugly and not easy to make any particular option optional. If needed I can support this from GlusterFS backend.

Kevin, Markus: Any thoughts on passing options to block drivers? Encoding GlusterFS options into a "filename" string is pretty cumbersome.

On 07/23/2012 03:28 AM, ronnie sahlberg wrote:> Why not use

Quoted 2 lines

-drive file=gluster://server[:port]/volname/image

At which point, options can fit into this URI scheme:

-drive file=gluster://server:port/volname/image?option1=foo&option2=bar

where anything after the ? of the URI can introduce whichever options you need.

Signature · 2 lines
Eric Blake   [email protected]    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#14 lore raw
Quoted 16 lines · Eric Blake
Quoted 4 lines · Stefan Hajnoczi
Quoted 4 lines

So without the capability to pass custom options to block drivers, am I forced to keep extending the file= with more and more options ?

Quoted 8 lines
Quoted 4 lines

file=gluster:transport:server:port:volname:image ?

Looks ugly and not easy to make any particular option optional. If needed I can support this from GlusterFS backend.

Kevin, Markus: Any thoughts on passing options to block drivers? Encoding GlusterFS options into a "filename" string is pretty cumbersome.

On 07/23/2012 03:28 AM, ronnie sahlberg wrote:> Why not use

Quoted 1 line
Quoted 8 lines
Quoted 1 line

-drive file=gluster://server[:port]/volname/image

At which point, options can fit into this URI scheme:

-drive file=gluster://server:port/volname/image?option1=foo&option2=bar

where anything after the ? of the URI can introduce whichever options you need.

The URI covered everything and left only transport as the option, which could be made part of the URI itself ?

So looks like we have two options:

gluster://server[:port]/[transport]/volname/image

vs

gluster:server:[port]:[transport]:volname:image

Unless there is a strong preference on one over the other, I am inclined to go with the latter (colon based) approach and expect user to provide double colons (::) wherever any default value needs to be specified.

Eg 1. gluster:localhost:::test:/a.img
Eg 2. gluster:localhost:0:socket:test:/a.img

Regards,
Bharata.

#15 lore raw
In reply to Stefan Hajnoczi

Am 23.07.2012 11:20, schrieb Stefan Hajnoczi:

Quoted 20 lines
Quoted 18 lines · Bharata B Rao
Quoted 8 lines · Stefan Hajnoczi

What about the other transports supported by libgfapi: UNIX domain sockets and RDMA? My reading of glfs.h is that there are 3 connection options:
1. 'transport': 'socket' (default), 'unix', 'rdma'
2. 'host': server hostname for 'socket', path to UNIX domain socket for 'unix', or something else for 'rdma'
3. 'port': TCP port when 'socket' is used. Ignored otherwise.

Quoted 5 lines

Unfortunately QEMU block drivers cannot take custom options yet. That would make it possible to cleanly map these connection options and save you from inventing syntax which doesn't expose all options.

In the meantime it would be nice if the syntax exposed all options.

So without the capability to pass custom options to block drivers, am I forced to keep extending the file= with more and more options ?

Quoted 8 lines
Quoted 4 lines

file=gluster:transport:server:port:volname:image ?

Looks ugly and not easy to make any particular option optional. If needed I can support this from GlusterFS backend.

Kevin, Markus: Any thoughts on passing options to block drivers? Encoding GlusterFS options into a "filename" string is pretty cumbersome.

This is the way it is without -blockdev. *shrug*

Kevin

#16 lore raw
In reply to Stefan Hajnoczi
Quoted 15 lines · Stefan Hajnoczi
Quoted 13 lines · Bharata B Rao
Quoted 12 lines · Stefan Hajnoczi
Quoted 9 lines · Bharata B Rao

-drive file=gluster:server@port:volname:image

- Here 'gluster' is the protocol.
- 'server@port' specifies the server where the volume file specification for
the given volume resides. 'port' is the port number on which gluster management daemon (glusterd) is listening. This is optional and if not specified, QEMU will send 0 which will make libgfapi to use the default port.

Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

'server@port' is weird notation. Normally it is 'server:port' (e.g. URLs). Can you change it?

I don't like but, but settled for it since port was optional and : was being used as separator here.

For what it's worth, icsi.c uses

iscsi://[<username>%<password>@]<host>[:<port>]/<targetname>/<lun>

Quoted 19 lines
Quoted 19 lines
Quoted 8 lines

What about the other transports supported by libgfapi: UNIX domain sockets and RDMA? My reading of glfs.h is that there are 3 connection options:
1. 'transport': 'socket' (default), 'unix', 'rdma'
2. 'host': server hostname for 'socket', path to UNIX domain socket for 'unix', or something else for 'rdma'
3. 'port': TCP port when 'socket' is used. Ignored otherwise.

Quoted 5 lines

Unfortunately QEMU block drivers cannot take custom options yet. That would make it possible to cleanly map these connection options and save you from inventing syntax which doesn't expose all options.

In the meantime it would be nice if the syntax exposed all options.

So without the capability to pass custom options to block drivers, am I forced to keep extending the file= with more and more options ?

file=gluster:transport:server:port:volname:image ?

Quoted 7 lines
Quoted 3 lines

Looks ugly and not easy to make any particular option optional. If needed I can
support this from GlusterFS backend.

Kevin, Markus: Any thoughts on passing options to block drivers? Encoding GlusterFS options into a "filename" string is pretty cumbersome.

Yes, it is. Every block driver with special parameters has its own ad hoc parser, and some of them are badly designed.

I'm working on a sane way to configure block drivers. Until we got that, encoding parameters into the "filename" is what you have to do.

Once we got it, block drivers shouldn't be required to expose *all* their parameters via -drive's encoded "filename".

#17 lore raw
In reply to Bharata B Rao
Quoted 13 lines · Bharata B Rao
Quoted 3 lines

2. It is currently not possible to bypass RPC because the glusterd managed configuration file doesn't support that.

It is possible. Gluster already supports custom extensions
to volume names and it is possible to use the required volfile by specifying this custom volname extension.

For eg, if I have a volume named test, by default the volfile used for it will be test-fuse.vol. Currently I can put my own custom volfile into the standard location and get glusterd pick that up. I can specify test.rpcbypass as volname and glusterd will pick test.rpcbypass.vol.

Quoted 4 lines

What is currently not supported is the ability to create test.rpcbypass.vol from gluster CLI. I believe that gluster developers are ok with enhancing gluster CLI to support generating/regenerating volfiles for a given volume with custom translator set.

Yes, this would be the preferred approach. We can tune the volume file generation to evolve the desired configuration file.

Quoted 7 lines
Quoted 6 lines

I'm not sure if these statements are true?

Would you support local volfiles in the future again? Why force users to run glusterd?

Quoted 7 lines

I will let gluster folks on CC to answer this and let us know the benefits of always depending on glusterd.

I guess running glusterd would be beneficial when supporting migration. QEMU working from a local volume (with volname=test.rpcbypass) can be easily restarted on a different node by just changing volname to test. glusterd will take care of fetching the right volfile automatically for us.

Yes, running glusterd would be beneficial in migration. Without deriving the file from glusterd features like volume tuning, client monitoring etc. would not be available to to clients that talk to a gluster volume. Additionally, driving configuration generation and management through glusterd helps in standardizing and stabilizing gluster configurations.

Quoted 7 lines
Quoted 4 lines

Has libgfapi been released yet?

Its part of gluster mainline now.

Quoted 8 lines
Quoted 4 lines

Does it have versioning which will
allow the QEMU GlusterFS block driver to build against different versions? I'm just wondering how the pieces will fit together once distros start shipping them.

I request gluster folks on CC to comment about version and shipping information.

There is no release that contains libgfapi as yet. Once that is done, we can probably have the dependency specified in QEMU as well.

Regards,
Vijay

#18 lore raw
In reply to Bharata B Rao
Quoted 21 lines · Bharata B Rao

Hi,

Here is the v2 patchset for supporting GlusterFS protocol from QEMU.

This set of patches enables QEMU to boot VM images from gluster volumes. This is achieved by adding gluster as a new block backend driver in QEMU. Its already possible to boot from VM images on gluster volumes, but this patchset provides the ability to boot VM images from gluster volumes by by-passing the FUSE layer in gluster. In case the image is present on the local system, it is possible to even bypass client and server translator and hence the RPC overhead.

The major change in this version is to not implement libglusterfs based gluster backend within QEMU but instead use libgfapi. libgfapi library from GlusterFS project provides APIs to access gluster volumes directly. With the use of libgfapi, the specification of gluster backend from QEMU matches more closely with the GlusterFS's way of specifying volumes. We now specify the gluster backed image like this:

-drive file=gluster:server@port:volname:image

Quoted 8 lines

- Here 'gluster' is the protocol.
- 'server@port' specifies the server where the volume file specification for the given volume resides. 'port' is the port number on which gluster management daemon (glusterd) is listening. This is optional and if not specified, QEMU will send 0 which will make libgfapi to use the default port.
- 'volname' is the name of the gluster volume which contains the VM image.
- 'image' is the path to the actual VM image in the gluster volume.

I don't think we should be using '@' as a field separator here, when ":" can do that job just fine. In addition we already have a precendent set with the sheepdog driver for using ':' for separating all fields:

-drive file=sheepdog:example.org:6000:imagename

If you want to allow for port number to be omitted, this can be handled thus:

-drive file=sheepdog:example.org::imagename

which is how -chardev deals with omitted port numbers

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
#19 lore raw

Why not use

-drive file=gluster://server[:port]/volname/image

A great many protocols today use the form

<protocol>://<server>:<port>]/<path>

so this would make it consistent with a lot of other naming schemes out there, and imho make
the url more intuitive.

FTP looks like this :   ftp://user:password@host:port/path
NFS looks like this :   nfs://<host>:<port><url-path>

CIFS looks like this :
smb://[[[authdomain;]user@]host[:port][/share[/path][/name]]][?context]

For iSCSI we use : iscsi://<server>[:<port>]/<target>/<lun>

(The iscsi syntax was picked explicitely to be consistent with the de-facto url naming scheme.)

I would argue that this is the de-facto way to create a url for
different protocols, so it would imho be natural to specify a
glusterfs url in a similar format.

ronnie sahlberg

Quoted 52 lines · Daniel P. Berrange
Quoted 21 lines · Bharata B Rao

Hi,

Here is the v2 patchset for supporting GlusterFS protocol from QEMU.

This set of patches enables QEMU to boot VM images from gluster volumes. This is achieved by adding gluster as a new block backend driver in QEMU. Its already possible to boot from VM images on gluster volumes, but this patchset provides the ability to boot VM images from gluster volumes by by-passing the FUSE layer in gluster. In case the image is present on the local system, it is possible to even bypass client and server translator and hence the RPC overhead.

The major change in this version is to not implement libglusterfs based gluster backend within QEMU but instead use libgfapi. libgfapi library from GlusterFS project provides APIs to access gluster volumes directly. With the use of libgfapi, the specification of gluster backend from QEMU matches more closely with the GlusterFS's way of specifying volumes. We now specify the gluster backed image like this:

-drive file=gluster:server@port:volname:image

Quoted 8 lines

- Here 'gluster' is the protocol.
- 'server@port' specifies the server where the volume file specification for the given volume resides. 'port' is the port number on which gluster management daemon (glusterd) is listening. This is optional and if not specified, QEMU will send 0 which will make libgfapi to use the default port.
- 'volname' is the name of the gluster volume which contains the VM image.
- 'image' is the path to the actual VM image in the gluster volume.

I don't think we should be using '@' as a field separator here, when ":" can do that job just fine. In addition we already have a precendent set with the sheepdog driver for using ':' for separating all fields:

-drive file=sheepdog:example.org:6000:imagename

If you want to allow for port number to be omitted, this can be handled thus:

-drive file=sheepdog:example.org::imagename

which is how -chardev deals with omitted port numbers

Regards,
Daniel
--

|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|