[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 21/36] rbd: Pass BlockdevOptionsRbd to qemu_r
From: |
Max Reitz |
Subject: |
Re: [Qemu-devel] [PATCH v3 21/36] rbd: Pass BlockdevOptionsRbd to qemu_rbd_connect() |
Date: |
Mon, 26 Feb 2018 13:23:40 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 |
On 2018-02-23 20:25, Kevin Wolf wrote:
> With the conversion to a QAPI options object, the function is now
> prepared to be used in a .bdrv_co_create implementation.
>
> Signed-off-by: Kevin Wolf <address@hidden>
> ---
> block/rbd.c | 109
> +++++++++++++++++++++++++++++-------------------------------
> 1 file changed, 53 insertions(+), 56 deletions(-)
>
> diff --git a/block/rbd.c b/block/rbd.c
> index 2e79c2d1fd..9b247f020d 100644
> --- a/block/rbd.c
> +++ b/block/rbd.c
[...]
> @@ -482,29 +484,27 @@ static void qemu_rbd_complete_aio(RADOSCB *rcb)
> qemu_aio_unref(acb);
> }
>
> -static char *qemu_rbd_mon_host(QDict *options, Error **errp)
> +static char *qemu_rbd_mon_host(BlockdevOptionsRbd *opts, Error **errp)
> {
> - const char **vals = g_new(const char *, qdict_size(options) + 1);
> - char keybuf[32];
> + const char **vals;
> const char *host, *port;
> char *rados_str;
> - int i;
> -
> - for (i = 0;; i++) {
> - sprintf(keybuf, "server.%d.host", i);
> - host = qdict_get_try_str(options, keybuf);
> - qdict_del(options, keybuf);
> - sprintf(keybuf, "server.%d.port", i);
> - port = qdict_get_try_str(options, keybuf);
> - qdict_del(options, keybuf);
> - if (!host && !port) {
> - break;
> - }
> - if (!host) {
> - error_setg(errp, "Parameter server.%d.host is missing", i);
> - rados_str = NULL;
> - goto out;
> - }
> + InetSocketAddressBaseList *p;
> + int i, cnt;
> +
> + if (!opts->has_server) {
> + return NULL;
> + }
> +
> + for (cnt = 0, p = opts->server; p; p = p->next) {
> + cnt++;
> + }
> +
> + vals = g_new(const char *, cnt + 1);
> +
> + for (i = 0, p = opts->server; p; p = p->next, i++) {
> + host = p->value->host;
> + port = p->value->port;
>
> if (strchr(host, ':')) {
> vals[i] = port ? g_strdup_printf("[%s]:%s", host, port)
host *and* port are mandatory, so this and the next ternary can be
simplified, too. ;-)
But not necessary, so:
Reviewed-by: Max Reitz <address@hidden>
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH v3 10/36] test-qemu-opts: Test qemu_opts_to_qdict_filtered(), (continued)
- [Qemu-devel] [PATCH v3 10/36] test-qemu-opts: Test qemu_opts_to_qdict_filtered(), Kevin Wolf, 2018/02/23
- [Qemu-devel] [PATCH v3 13/36] block: Make bdrv_is_whitelisted() public, Kevin Wolf, 2018/02/23
- [Qemu-devel] [PATCH v3 16/36] file-win32: Support .bdrv_co_create, Kevin Wolf, 2018/02/23
- [Qemu-devel] [PATCH v3 14/36] block: x-blockdev-create QMP command, Kevin Wolf, 2018/02/23
- [Qemu-devel] [PATCH v3 15/36] file-posix: Support .bdrv_co_create, Kevin Wolf, 2018/02/23
- [Qemu-devel] [PATCH v3 12/36] qcow2: Use visitor for options in qcow2_create(), Kevin Wolf, 2018/02/23
- [Qemu-devel] [PATCH v3 17/36] gluster: Support .bdrv_co_create, Kevin Wolf, 2018/02/23
- [Qemu-devel] [PATCH v3 18/36] rbd: Fix use after free in qemu_rbd_set_keypairs() error path, Kevin Wolf, 2018/02/23
- [Qemu-devel] [PATCH v3 19/36] rbd: Factor out qemu_rbd_connect(), Kevin Wolf, 2018/02/23
- [Qemu-devel] [PATCH v3 21/36] rbd: Pass BlockdevOptionsRbd to qemu_rbd_connect(), Kevin Wolf, 2018/02/23
- Re: [Qemu-devel] [PATCH v3 21/36] rbd: Pass BlockdevOptionsRbd to qemu_rbd_connect(),
Max Reitz <=
- [Qemu-devel] [PATCH v3 23/36] rbd: Assign s->snap/image_name in qemu_rbd_open(), Kevin Wolf, 2018/02/23
- [Qemu-devel] [PATCH v3 22/36] rbd: Support .bdrv_co_create, Kevin Wolf, 2018/02/23
- [Qemu-devel] [PATCH v3 20/36] rbd: Remove non-schema options from runtime_opts, Kevin Wolf, 2018/02/23
- [Qemu-devel] [PATCH v3 24/36] rbd: Use qemu_rbd_connect() in qemu_rbd_do_create(), Kevin Wolf, 2018/02/23
- [Qemu-devel] [PATCH v3 25/36] nfs: Use QAPI options in nfs_client_open(), Kevin Wolf, 2018/02/23
- [Qemu-devel] [PATCH v3 26/36] nfs: Support .bdrv_co_create, Kevin Wolf, 2018/02/23
- [Qemu-devel] [PATCH v3 27/36] sheepdog: QAPIfy "redundancy" create option, Kevin Wolf, 2018/02/23