On 8/11/20 12:38 PM, Eric Blake wrote:
@@ -136,6 +155,11 @@ STATE_MACHINE { return 0; }
+ if ((h->gflags & LIBNBD_HANDSHAKE_FLAG_FIXED_NEWSTYLE) == 0) + h->protocol = "newstyle"; + else + h->protocol = "newstyle-fixed"; + cflags = h->gflags; h->sbuf.cflags = htobe32 (cflags); h->wbuf = &h->sbuf;
This makes me think maybe we should just derive this string from the gflags when the caller calls get_protocol.
Doable. Probably even something we could separate out, to keep the meat of this patch more focused.
I spoke too soon, originally hoping to get rid of h->protocol altogether. But we still set h->protocol = "oldstyle" in a different file, and have nothing else in h that lets us tell oldstyle apart from newstyle (only newstyle-fixed is easy to detect in h->gflags). Rather, this hunk was code motion, to make nbd_get_protocol work in Negotiating state (we were previously setting it in NEWSTYLE.FINISH, which is too late). But again, that sort of change can be separated out to make it easier to see (adding the Negotiating state done in a different patch than allowing existing commands to be callable in Negotiating state). -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org