[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH for-2.6] nbd: Don't fail handshake on NBD_OPT_LI
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH for-2.6] nbd: Don't fail handshake on NBD_OPT_LIST descriptions |
Date: |
Thu, 14 Apr 2016 16:07:25 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 |
On 04/14/2016 03:31 PM, Max Reitz wrote:
> On 08.04.2016 03:09, Eric Blake wrote:
>> The NBD Protocol states that NBD_REP_SERVER may set
>> 'length > sizeof(namelen) + namelen'; in which case the rest
>> of the packet is a UTF-8 description of the export. While we
>> don't know of any NBD servers that send this description yet,
>> we had better consume the data so we don't choke when we start
>> to talk to such a server.
>>
>> @@ -214,6 +219,20 @@ static int nbd_receive_list(QIOChannel *ioc, char
>> **name, Error **errp)
>> return -1;
>> }
>> (*name)[namelen] = '\0';
>> + len -= namelen;
>> + if (len) {
>> + char *buf = g_malloc(len + 1);
>> + if (read_sync(ioc, buf, len) != len) {
>> + error_setg(errp, "failed to read export description");
>> + g_free(*name);
>> + g_free(buf);
>> + *name = NULL;
>> + return -1;
>> + }
>> + buf[len] = '\0';
>> + TRACE("Ignoring export description: %s", buf);
>
> I find this funny, somehow.
>
> Perhaps it's because this may explicitly print something while
> explaining that it's being ignored.
The server.c code had a nice function for skipping unwanted bytes; and
in a 2.7 series, I borrowed that idea:
https://lists.gnu.org/archive/html/qemu-devel/2016-04/msg01597.html
but for the purpose of minimal churn in 2.6, I don't mind the
(temporary) oddity.
>
>> + g_free(buf);
>> + }
>> } else {
>> error_setg(errp, "Unexpected reply type %x expected %x",
>> type, NBD_REP_SERVER);
>>
>
> Thanks Eric, I applied this patch to my block branch (for 2.6). If this
> was not your intention, please speak up. :-)
>
> https://github.com/XanClic/qemu/commits/block
You did the right thing.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature