All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: Eric Blake <eblake@redhat.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "nsoffer@redhat.com" <nsoffer@redhat.com>,
	"rjones@redhat.com" <rjones@redhat.com>,
	"jsnow@redhat.com" <jsnow@redhat.com>,
	"qemu-block@nongnu.org" <qemu-block@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v3 17/19] qemu-nbd: Add --list option
Date: Thu, 17 Jan 2019 17:11:31 +0000	[thread overview]
Message-ID: <a62787bc-b6cb-5fe6-75bb-c67c6ec5db01@virtuozzo.com> (raw)
In-Reply-To: <071f88a7-a1a8-0dcc-8153-99034790168b@redhat.com>

17.01.2019 19:58, Eric Blake wrote:
> On 1/17/19 4:05 AM, Vladimir Sementsov-Ogievskiy wrote:
>> 12.01.2019 20:58, Eric Blake wrote:
>>> We want to be able to detect whether a given qemu NBD server is
>>> exposing the right export(s) and dirty bitmaps, at least for
>>> regression testing.  We could use 'nbd-client -l' from the upstream
>>> NBD project to list exports, but it's annoying to rely on
>>> out-of-tree binaries; furthermore, nbd-client doesn't necessarily
>>> know about all of the qemu NBD extensions.  Thus, it is time to add
>>> a new mode to qemu-nbd that merely sniffs all possible information
>>> from the server during handshake phase, then disconnects and dumps
>>> the information.
>>>
>>> This patch actually implements --list/-L, while reusing other
>>> options such as --tls-creds for now designating how to connect
>>> as the client (rather than their non-list usage of how to operate
>>> as the server).
>>>
> 
>>>
>>> Not done here, but maybe worth future experiments: capture
>>> the meat of NBDExportInfo into a QAPI struct, and use the
>>> generated QAPI pretty-printers instead of hand-rolling our
>>> output loop.  It would also permit us to add a JSON output
>>> mode for machine parsing.
> 
> A start of that experiment has now been posted:
> https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg04196.html
> 
> 
>>>    @item --tls-creds=ID
>>>    Enable mandatory TLS encryption for the server by setting the ID
>>>    of the TLS credentials object previously created with the --object
>>> -option.
>>> +option; or provide the credentials needed for connecting as a client
>>> +in list mode.
>>
>> may be "list mode (--list)", as "list mode" is not directly defined. On the other hand,
>> list option is extremely close to tls-creds, so it is obvious anyway.
> 
> I'm thinking of adding this (and see conversation below that mentions [1]):
> 
> diff --git i/qemu-nbd.texi w/qemu-nbd.texi
> index 65caeb7874a..0d297eed6db 100644
> --- i/qemu-nbd.texi
> +++ w/qemu-nbd.texi
> @@ -105,7 +105,9 @@ Set the NBD volume export description, as a
> human-readable
>   string.
>   @item -L, --list
>   Connect as a client and list all details about the exports exposed by
> -a remote NBD server.
> +a remote NBD server.  This enables list mode, and is incompatible
> +with options that change behavior related to a specific export (such as
> +@option{--export-name}, @option{--offset}, ...).
>   @item --tls-creds=ID
>   Enable mandatory TLS encryption for the server by setting the ID
>   of the TLS credentials object previously created with the --object
> 
> 
>>> +static int qemu_nbd_client_list(SocketAddress *saddr, QCryptoTLSCreds *tls,
>>> +                                const char *hostname)
>>> +{
>>> +    int ret = EXIT_FAILURE;
>>> +    int rc;
>>> +    Error *err = NULL;
>>> +    QIOChannelSocket *sioc;
>>> +    NBDExportInfo *list;
>>> +    int i, j;
>>> +
>>> +    sioc = qio_channel_socket_new();
>>> +    if (qio_channel_socket_connect_sync(sioc, saddr, &err) < 0) {
>>> +        error_report_err(err);
>>> +        goto out;
>>
>> May be just return EXIT_FAUILURE here;
>> remove out label;
>> s/out_socket/out
> 
> Will do. Probably leftovers from earlier attempts as I changed my
> approach over time.
> 
> 
>>> +    printf("exports available: %d\n", rc);
>>> +    for (i = 0; i < rc; i++) {
>>> +        printf(" export: '%s'\n", list[i].name);
>>> +        if (list[i].description && *list[i].description) {
>>> +            printf("  description: %s\n", list[i].description);
>>> +        }
>>> +        if (list[i].flags & NBD_FLAG_HAS_FLAGS) {
>>
>> actually this is
>>
>> if (server not have a bug of not setting NBD_FLAG_HAS_FLAGS) {
> 
> Which, as the commit message mentions, is for servers so old and rare
> that it really doesn't matter.
> 
>>    ...
>> }
>>
>> Why not to print @size for example, if @flags field has a bug?
>>
>> Or, then, why to print flags, if @size has a bug?
> 
> Because we don't have to worry about those servers being mainstream.
> 
>>>
>>> -    if ((argc - optind) != 1) {
>>> +    if (list) {
>>> +        if (argc != optind) {
>>> +            error_report("List mode is incompatible with a file name");
>>> +            exit(EXIT_FAILURE);
>>> +        }
>>> +        if (export_name || export_description || dev_offset || partition ||
>>> +            device || disconnect || fmt || sn_id_or_name || bitmap) {
>>> +            error_report("List mode is incompatible with per-device settings");
>>> +            exit(EXIT_FAILURE);
>>
>> and what about aio, discard, etc?
> 
> I don't mind adding in any more options that you think are useful to
> flag the user on.  Looks like I missed seen_aio, seen_cache,
> seen_discard.  Catching '-s' is harder, as it merely sets a bit within
> flags rather than a witness variable.
> 
>> Also, I think, it would be good to specify in Usage
>> (or in man), which options are available for list mode.
> 
> I worry that keeping an exact list may be a maintenance nightmare (the
> two are likely to get out of sync); does my proposed wording above at
> [1] satisfy the problem by at least making the user aware that not all
> combinations will work?

I don't really care of it, current version is OK too. Of course, an addition
sounds better than nothing)

> 
> Another alternative would be to just silently ignore all per-export
> options, instead of warning the user that they are incompatible.  I
> don't know if that's any friendlier, but it is less code.
> 
>>
>> Hm, note, --help has grouping of options and man don't.
> 
> That could be a separate patch, if it is desired (or squashed into 2/19)
> 
>>
>>
>> I don't have good understanding of tls related things, the rest looks OK,
>> my suggestions are optional, so, if you don't want to improve docs and
>> option conflict checking now:
>> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>>
>>
> 


-- 
Best regards,
Vladimir

  reply	other threads:[~2019-01-17 17:11 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-12 17:57 [Qemu-devel] [PATCH v3 00/19] nbd: add qemu-nbd --list Eric Blake
2019-01-12 17:57 ` [Qemu-devel] [PATCH v3 01/19] maint: Allow for EXAMPLES in texi2pod Eric Blake
2019-01-15 17:51   ` Richard W.M. Jones
2019-01-12 17:57 ` [Qemu-devel] [PATCH v3 02/19] qemu-nbd: Enhance man page Eric Blake
2019-01-15 17:53   ` Richard W.M. Jones
2019-01-12 17:57 ` [Qemu-devel] [PATCH v3 03/19] qemu-nbd: Sanity check partition bounds Eric Blake
2019-01-15 16:20   ` Vladimir Sementsov-Ogievskiy
2019-01-15 16:53     ` Eric Blake
2019-01-15 18:00   ` Richard W.M. Jones
2019-01-15 18:08     ` Eric Blake
2019-01-16  7:46   ` Vladimir Sementsov-Ogievskiy
2019-01-12 17:57 ` [Qemu-devel] [PATCH v3 04/19] nbd/server: Hoist length check to qemp_nbd_server_add Eric Blake
2019-01-15  9:44   ` Vladimir Sementsov-Ogievskiy
2019-01-15 15:25     ` Eric Blake
2019-01-15 16:26       ` Vladimir Sementsov-Ogievskiy
2019-01-15 16:58         ` Eric Blake
2019-01-16 18:03           ` Eric Blake
2019-01-16 18:05   ` Eric Blake
2019-01-12 17:57 ` [Qemu-devel] [PATCH v3 05/19] nbd/server: Favor [u]int64_t over off_t Eric Blake
2019-01-15 10:19   ` Vladimir Sementsov-Ogievskiy
2019-01-15 15:33     ` Eric Blake
2019-01-15 15:41       ` Vladimir Sementsov-Ogievskiy
2019-01-16  8:23       ` Vladimir Sementsov-Ogievskiy
2019-01-16 14:23         ` Eric Blake
2019-01-12 17:57 ` [Qemu-devel] [PATCH v3 06/19] qemu-nbd: Avoid strtol open-coding Eric Blake
2019-01-15 12:31   ` Vladimir Sementsov-Ogievskiy
2019-01-15 15:35     ` Eric Blake
2019-01-15 18:09   ` Richard W.M. Jones
2019-01-12 17:58 ` [Qemu-devel] [PATCH v3 07/19] nbd/client: Refactor nbd_receive_list() Eric Blake
2019-01-12 17:58 ` [Qemu-devel] [PATCH v3 08/19] nbd/client: Move export name into NBDExportInfo Eric Blake
2019-01-12 17:58 ` [Qemu-devel] [PATCH v3 09/19] nbd/client: Change signature of nbd_negotiate_simple_meta_context() Eric Blake
2019-01-12 17:58 ` [Qemu-devel] [PATCH v3 10/19] nbd/client: Split out nbd_send_one_meta_context() Eric Blake
2019-01-15 13:18   ` Vladimir Sementsov-Ogievskiy
2019-01-15 15:44     ` Eric Blake
2019-01-15 15:52       ` Vladimir Sementsov-Ogievskiy
2019-01-15 15:55         ` Eric Blake
2019-01-15 15:59           ` Vladimir Sementsov-Ogievskiy
2019-01-16 10:40       ` Vladimir Sementsov-Ogievskiy
2019-01-12 17:58 ` [Qemu-devel] [PATCH v3 11/19] nbd/client: Split out nbd_receive_one_meta_context() Eric Blake
2019-01-15 15:05   ` Vladimir Sementsov-Ogievskiy
2019-01-15 15:50     ` Eric Blake
2019-01-15 15:53       ` Vladimir Sementsov-Ogievskiy
2019-01-12 17:58 ` [Qemu-devel] [PATCH v3 12/19] nbd/client: Refactor return of nbd_receive_negotiate() Eric Blake
2019-01-12 17:58 ` [Qemu-devel] [PATCH v3 13/19] nbd/client: Split handshake into two functions Eric Blake
2019-01-15 15:34   ` Vladimir Sementsov-Ogievskiy
2019-01-12 17:58 ` [Qemu-devel] [PATCH v3 14/19] nbd/client: Pull out oldstyle size determination Eric Blake
2019-01-15 15:35   ` Vladimir Sementsov-Ogievskiy
2019-01-15 15:45     ` Vladimir Sementsov-Ogievskiy
2019-01-16 19:47     ` Eric Blake
2019-01-12 17:58 ` [Qemu-devel] [PATCH v3 15/19] nbd/client: Add nbd_receive_export_list() Eric Blake
2019-01-16 10:15   ` Vladimir Sementsov-Ogievskiy
2019-01-16 14:33     ` Eric Blake
2019-01-16 20:01     ` Eric Blake
2019-01-12 17:58 ` [Qemu-devel] [PATCH v3 16/19] nbd/client: Add meta contexts to nbd_receive_export_list() Eric Blake
2019-01-16 10:54   ` Vladimir Sementsov-Ogievskiy
2019-01-12 17:58 ` [Qemu-devel] [PATCH v3 17/19] qemu-nbd: Add --list option Eric Blake
2019-01-17 10:05   ` Vladimir Sementsov-Ogievskiy
2019-01-17 16:58     ` Eric Blake
2019-01-17 17:11       ` Vladimir Sementsov-Ogievskiy [this message]
2019-01-12 17:58 ` [Qemu-devel] [PATCH v3 18/19] nbd/client: Work around 3.0 bug for listing meta contexts Eric Blake
2019-01-16 15:43   ` Vladimir Sementsov-Ogievskiy
2019-01-17  3:21     ` Eric Blake
2019-01-17  8:07       ` Vladimir Sementsov-Ogievskiy
2019-01-17 14:20         ` Eric Blake
2019-01-12 17:58 ` [Qemu-devel] [PATCH v3 19/19] iotests: Enhance 223, 233 to cover 'qemu-nbd --list' Eric Blake
2019-01-17 13:34   ` Eric Blake
2019-01-14 12:22 ` [Qemu-devel] [PATCH v3 00/19] nbd: add qemu-nbd --list Vladimir Sementsov-Ogievskiy
2019-01-14 16:46   ` Eric Blake
2019-01-17 11:38 ` Vladimir Sementsov-Ogievskiy
2019-01-17 14:20   ` Eric Blake
2019-01-23 12:36 ` 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=a62787bc-b6cb-5fe6-75bb-c67c6ec5db01@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=eblake@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=nsoffer@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rjones@redhat.com \
    /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.