All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org,
	Eric Blake <eblake@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	ashijeetacharya@gmail.com
Subject: Re: [Qemu-devel] [PATCH v4 06/12] block/nbd: Accept SocketAddress
Date: Sat, 15 Oct 2016 19:12:35 +0200	[thread overview]
Message-ID: <4b932f12-e8ca-9816-970d-e9ea7b30f538@redhat.com> (raw)
In-Reply-To: <20161013114244.GG5803@noname.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 4815 bytes --]

On 13.10.2016 13:42, Kevin Wolf wrote:
> Am 28.09.2016 um 22:55 hat Max Reitz geschrieben:
>> Add a new option "address" to the NBD block driver which accepts a
>> SocketAddress.
>>
>> "path", "host" and "port" are still supported as legacy options and are
>> mapped to their corresponding SocketAddress representation.
>>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
> 
> Not opposed in principle to your change, but we should try to keep the
> naming consistent between NBD and the other block drivers, notably the
> SSH work that is currently going on.
> 
> This patch uses 'address' for the SockAddress, the proposed SSH patch
> uses 'server'. I don't mind too much which one we choose, though I like
> 'server' a bit better. Anyway, we should choose one and stick to it in
> all drivers.

OK, I'll use "server" then. I don't mind either way, so even a weak
opinion is enough to persuade me. ;-)

>>  block/nbd.c                   | 166 ++++++++++++++++++++++++++----------------
>>  tests/qemu-iotests/051.out    |   4 +-
>>  tests/qemu-iotests/051.pc.out |   4 +-
>>  3 files changed, 106 insertions(+), 68 deletions(-)
>>
>> diff --git a/block/nbd.c b/block/nbd.c
>> index cdab20f..449f94e 100644
>> --- a/block/nbd.c
>> +++ b/block/nbd.c
>> @@ -32,6 +32,9 @@
>>  #include "qemu/uri.h"
>>  #include "block/block_int.h"
>>  #include "qemu/module.h"
>> +#include "qapi-visit.h"
>> +#include "qapi/qmp-input-visitor.h"
>> +#include "qapi/qmp-output-visitor.h"
>>  #include "qapi/qmp/qdict.h"
>>  #include "qapi/qmp/qjson.h"
>>  #include "qapi/qmp/qint.h"
>> @@ -44,7 +47,8 @@ typedef struct BDRVNBDState {
>>      NbdClientSession client;
>>  
>>      /* For nbd_refresh_filename() */
>> -    char *path, *host, *port, *export, *tlscredsid;
>> +    SocketAddress *saddr;
>> +    char *export, *tlscredsid;
>>  } BDRVNBDState;
>>  
>>  static int nbd_parse_uri(const char *filename, QDict *options)
>> @@ -131,7 +135,9 @@ static bool nbd_has_filename_options_conflict(QDict *options, Error **errp)
>>          if (!strcmp(e->key, "host") ||
>>              !strcmp(e->key, "port") ||
>>              !strcmp(e->key, "path") ||
>> -            !strcmp(e->key, "export"))
>> +            !strcmp(e->key, "export") ||
>> +            !strcmp(e->key, "address") ||
>> +            !strncmp(e->key, "address.", 8))
> 
> strstart()?

Yep, will use.

>>          {
>>              error_setg(errp, "Option '%s' cannot be used with a file name",
>>                         e->key);
>> @@ -205,50 +211,67 @@ out:
>>      g_free(file);
>>  }
>>  
>> -static SocketAddress *nbd_config(BDRVNBDState *s, QemuOpts *opts, Error **errp)
>> +static bool nbd_process_legacy_socket_options(QDict *output_options,
>> +                                              QemuOpts *legacy_opts,
>> +                                              Error **errp)
>>  {
>> -    SocketAddress *saddr;
>> -
>> -    s->path = g_strdup(qemu_opt_get(opts, "path"));
>> -    s->host = g_strdup(qemu_opt_get(opts, "host"));
>> -    s->port = g_strdup(qemu_opt_get(opts, "port"));
>> -
>> -    if (!s->path == !s->host) {
>> -        if (s->path) {
>> -            error_setg(errp, "path and host may not be used at the same time");
>> -        } else {
>> -            error_setg(errp, "one of path and host must be specified");
>> +    const char *path = qemu_opt_get(legacy_opts, "path");
>> +    const char *host = qemu_opt_get(legacy_opts, "host");
>> +    const char *port = qemu_opt_get(legacy_opts, "port");
>> +
>> +    if (path && host) {
>> +        error_setg(errp, "path and host may not be used at the same time");
>> +        return false;
>> +    } else if (path) {
>> +        if (port) {
>> +            error_setg(errp, "port may not be used without host");
>> +            return false;
>>          }
>> -        return NULL;
>> +
>> +        qdict_put(output_options, "address.type", qstring_from_str("unix"));
>> +        qdict_put(output_options, "address.data.path", qstring_from_str(path));
>> +    } else if (host) {
>> +        qdict_put(output_options, "address.type", qstring_from_str("inet"));
>> +        qdict_put(output_options, "address.data.host", qstring_from_str(host));
>> +        qdict_put(output_options, "address.data.port",
>> +                  qstring_from_str(port ?: stringify(NBD_DEFAULT_PORT)));
>>      }
>> -    if (s->port && !s->host) {
>> -        error_setg(errp, "port may not be used without host");
>> -        return NULL;
>> +
>> +    return true;
>> +}
> 
> If both the legacy option and the new one are given, the legacy one
> takes precedence. Intentional?

No. I think it'll be easiest to just return an error when a user is
trying to use both.

Thanks,

Max


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 480 bytes --]

  parent reply	other threads:[~2016-10-15 17:12 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-28 20:55 [Qemu-devel] [PATCH v4 00/12] qapi: Allow blockdev-add for NBD Max Reitz
2016-09-28 20:55 ` [Qemu-devel] [PATCH v4 01/12] block/nbd: Drop trailing "." in error messages Max Reitz
2016-09-30 17:40   ` Eric Blake
2016-10-13 11:34   ` Kevin Wolf
2016-09-28 20:55 ` [Qemu-devel] [PATCH v4 02/12] block/nbd: Reject port parameter without host Max Reitz
2016-09-30 18:44   ` Eric Blake
2016-10-13 11:34   ` Kevin Wolf
2016-09-28 20:55 ` [Qemu-devel] [PATCH v4 03/12] block/nbd: Default port in nbd_refresh_filename() Max Reitz
2016-09-30 19:28   ` Eric Blake
2016-10-13 11:35   ` Kevin Wolf
2016-09-28 20:55 ` [Qemu-devel] [PATCH v4 04/12] block/nbd: Use qdict_put() Max Reitz
2016-10-03 15:31   ` Eric Blake
2016-10-13 11:35   ` Kevin Wolf
2016-09-28 20:55 ` [Qemu-devel] [PATCH v4 05/12] block/nbd: Add nbd_has_filename_options_conflict() Max Reitz
2016-10-03 18:46   ` Eric Blake
2016-10-04 17:29     ` Max Reitz
2016-10-13 11:35   ` Kevin Wolf
2016-09-28 20:55 ` [Qemu-devel] [PATCH v4 06/12] block/nbd: Accept SocketAddress Max Reitz
2016-10-13 11:42   ` Kevin Wolf
2016-10-14  9:34     ` Ashijeet Acharya
2016-10-15 17:12     ` Max Reitz [this message]
2016-09-28 20:55 ` [Qemu-devel] [PATCH v4 07/12] block/nbd: Use SocketAddress options Max Reitz
2016-10-13 13:01   ` Kevin Wolf
2016-09-28 20:55 ` [Qemu-devel] [PATCH v4 08/12] qapi: Allow blockdev-add for NBD Max Reitz
2016-10-13 13:01   ` Kevin Wolf
2016-09-28 20:55 ` [Qemu-devel] [PATCH v4 09/12] iotests.py: Add qemu_nbd function Max Reitz
2016-10-13 13:11   ` Kevin Wolf
2016-10-15 17:17     ` Max Reitz
2016-10-17  8:33       ` Kevin Wolf
2016-09-28 20:56 ` [Qemu-devel] [PATCH v4 10/12] iotests.py: Allow concurrent qemu instances Max Reitz
2016-10-13 13:12   ` Kevin Wolf
2016-09-28 20:56 ` [Qemu-devel] [PATCH v4 11/12] socket_scm_helper: Accept fd directly Max Reitz
2016-10-13 13:12   ` Kevin Wolf
2016-09-28 20:56 ` [Qemu-devel] [PATCH v4 12/12] iotests: Add test for NBD's blockdev-add interface Max Reitz
2016-10-13 13:26   ` Kevin Wolf
2016-10-15 17:19     ` Max Reitz
2016-10-14  4:09 ` [Qemu-devel] [PATCH v4 00/12] qapi: Allow blockdev-add for NBD no-reply

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=4b932f12-e8ca-9816-970d-e9ea7b30f538@redhat.com \
    --to=mreitz@redhat.com \
    --cc=armbru@redhat.com \
    --cc=ashijeetacharya@gmail.com \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.