From: Josh Durgin <josh.durgin@dreamhost.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: ceph-devel@vger.kernel.org, qemu-devel@nongnu.org,
kvm@vger.kernel.org, Christian Brunner <chb@muc.de>
Subject: Re: [Qemu-devel] [PATCH v5 2/4] rbd: allow configuration of rados from the rbd filename
Date: Thu, 26 May 2011 16:06:26 -0700 [thread overview]
Message-ID: <4DDEDCF2.90804@dreamhost.com> (raw)
In-Reply-To: <4DDE0BBF.9010502@redhat.com>
On 05/26/2011 01:13 AM, Kevin Wolf wrote:
> Am 25.05.2011 22:34, schrieb Josh Durgin:
>> The new format is rbd:pool/image[@snapshot][:option1=value1[:option2=value2...]]
>> Each option is used to configure rados, and may be any Ceph option, or "conf".
>> The "conf" option specifies a Ceph configuration file to read.
>>
>> This allows rbd volumes from more than one Ceph cluster to be used by
>> specifying different monitor addresses, as well as having different
>> logging levels or locations for different volumes.
>>
>> Signed-off-by: Josh Durgin<josh.durgin@dreamhost.com>
>> ---
>> block/rbd.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++--------
>> 1 files changed, 102 insertions(+), 17 deletions(-)
>>
>> diff --git a/block/rbd.c b/block/rbd.c
>> index 2cee70d..d346a21 100644
>> --- a/block/rbd.c
>> +++ b/block/rbd.c
>> @@ -23,13 +23,17 @@
>> /*
>> * When specifying the image filename use:
>> *
>> - * rbd:poolname/devicename
>> + * rbd:poolname/devicename[@snapshotname][:option1=value1[:option2=value2...]]
>> *
>> * poolname must be the name of an existing rados pool
>> *
>> * devicename is the basename for all objects used to
>> * emulate the raw device.
>> *
>> + * Each option given is used to configure rados, and may be
>> + * any Ceph option, or "conf". The "conf" option specifies
>> + * a Ceph configuration file to read.
>> + *
>> * Metadata information (image size, ...) is stored in an
>> * object with the name "devicename.rbd".
>> *
>> @@ -123,7 +127,8 @@ static int qemu_rbd_next_tok(char *dst, int dst_len,
>> static int qemu_rbd_parsename(const char *filename,
>> char *pool, int pool_len,
>> char *snap, int snap_len,
>> - char *name, int name_len)
>> + char *name, int name_len,
>> + char *conf, int conf_len)
>> {
>> const char *start;
>> char *p, *buf;
>> @@ -135,28 +140,84 @@ static int qemu_rbd_parsename(const char *filename,
>>
>> buf = qemu_strdup(start);
>> p = buf;
>> + *snap = '\0';
>> + *conf = '\0';
>>
>> ret = qemu_rbd_next_tok(pool, pool_len, p, '/', "pool name",&p);
>> if (ret< 0 || !p) {
>> ret = -EINVAL;
>> goto done;
>> }
>> - ret = qemu_rbd_next_tok(name, name_len, p, '@', "object name",&p);
>> - if (ret< 0) {
>> - goto done;
>> +
>> + if (strchr(p, '@')) {
>> + ret = qemu_rbd_next_tok(name, name_len, p, '@', "object name",&p);
>> + if (ret< 0) {
>> + goto done;
>> + }
>> + ret = qemu_rbd_next_tok(snap, snap_len, p, ':', "snap name",&p);
>> + } else {
>> + ret = qemu_rbd_next_tok(name, name_len, p, ':', "object name",&p);
>> }
>> - if (!p) {
>> - *snap = '\0';
>> + if (ret< 0 || !p) {
>> goto done;
>> }
>>
>> - ret = qemu_rbd_next_tok(snap, snap_len, p, '\0', "snap name",&p);
>> + ret = qemu_rbd_next_tok(conf, conf_len, p, '\0', "configuration",&p);
>>
>> done:
>> qemu_free(buf);
>> return ret;
>> }
>>
>> +static int qemu_rbd_set_conf(rados_t cluster, const char *conf)
>> +{
>> + char *p, *buf;
>> + char name[RBD_MAX_CONF_NAME_SIZE];
>> + char value[RBD_MAX_CONF_VAL_SIZE];
>> + int ret = 0;
>> +
>> + buf = qemu_strdup(conf);
>> + p = buf;
>> +
>> + while (p) {
>> + ret = qemu_rbd_next_tok(name, sizeof(name), p,
>> + '=', "conf option name",&p);
>> + if (ret< 0) {
>> + break;
>> + }
>> +
>> + if (!p) {
>> + error_report("conf option %s has no value", name);
>> + ret = -EINVAL;
>> + break;
>> + }
>> +
>> + ret = qemu_rbd_next_tok(value, sizeof(value), p,
>> + ':', "conf option value",&p);
>> + if (ret< 0) {
>> + break;
>> + }
>> +
>> + if (strncmp(name, "conf", strlen("conf"))) {
>
> Do you really only want to check if name _starts_ with "conf"?
>
> Kevin
That should just be strcmp.
Josh
next prev parent reply other threads:[~2011-05-26 23:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-25 20:34 [Qemu-devel] [PATCH v5 0/4] rbd improvements Josh Durgin
2011-05-25 20:34 ` [Qemu-devel] [PATCH v5 1/4] rbd: use the higher level librbd instead of just librados Josh Durgin
2011-05-25 20:34 ` [Qemu-devel] [PATCH v5 2/4] rbd: allow configuration of rados from the rbd filename Josh Durgin
2011-05-26 8:13 ` Kevin Wolf
2011-05-26 23:06 ` Josh Durgin [this message]
2011-05-25 20:34 ` [Qemu-devel] [PATCH v5 3/4] rbd: check return values when scheduling aio Josh Durgin
2011-05-25 20:34 ` [Qemu-devel] [PATCH v5 4/4] rbd: Add bdrv_truncate implementation Josh Durgin
2011-05-26 8:05 ` Kevin Wolf
2011-05-26 23:09 ` Josh Durgin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DDEDCF2.90804@dreamhost.com \
--to=josh.durgin@dreamhost.com \
--cc=ceph-devel@vger.kernel.org \
--cc=chb@muc.de \
--cc=kvm@vger.kernel.org \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).