|
|
7711c0 |
From 1d8de67d4435beff1839b868672a05c4195c9d92 Mon Sep 17 00:00:00 2001
|
|
|
7711c0 |
From: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Date: Wed, 27 Mar 2019 17:22:54 +0100
|
|
|
7711c0 |
Subject: [PATCH 116/163] nbd/client: Work around 3.0 bug for listing meta
|
|
|
7711c0 |
contexts
|
|
|
7711c0 |
|
|
|
7711c0 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Message-id: <20190327172308.31077-42-jsnow@redhat.com>
|
|
|
7711c0 |
Patchwork-id: 85211
|
|
|
7711c0 |
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 41/55] nbd/client: Work around 3.0 bug for listing meta contexts
|
|
|
7711c0 |
Bugzilla: 1691009
|
|
|
7711c0 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
7711c0 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
From: Eric Blake <eblake@redhat.com>
|
|
|
7711c0 |
|
|
|
7711c0 |
Commit 3d068aff forgot to advertise available qemu: contexts
|
|
|
7711c0 |
when the client requests a list with 0 queries. Furthermore,
|
|
|
7711c0 |
3.0 shipped with a qemu-img hack of x-dirty-bitmap (commit
|
|
|
7711c0 |
216ee365) that _silently_ acts as though the entire image is
|
|
|
7711c0 |
clean if a requested bitmap is not present. Both bugs have
|
|
|
7711c0 |
been recently fixed, so that a modern qemu server gives full
|
|
|
7711c0 |
context output right away, and the client refuses a
|
|
|
7711c0 |
connection if a requested x-dirty-bitmap was not found.
|
|
|
7711c0 |
|
|
|
7711c0 |
Still, it is likely that there will be users that have to
|
|
|
7711c0 |
work with a mix of old and new qemu versions, depending on
|
|
|
7711c0 |
which features get backported where, at which point being
|
|
|
7711c0 |
able to rely on 'qemu-img --list' output to know for sure
|
|
|
7711c0 |
whether a given NBD export has the desired dirty bitmap is
|
|
|
7711c0 |
much nicer than blindly connecting and risking that the
|
|
|
7711c0 |
entire image may appear clean. We can make our --list code
|
|
|
7711c0 |
smart enough to work around buggy servers by tracking
|
|
|
7711c0 |
whether we've seen any qemu: replies in the original 0-query
|
|
|
7711c0 |
list; if not, repeat with a single query on "qemu:" (which
|
|
|
7711c0 |
may still have no replies, but then we know for sure we
|
|
|
7711c0 |
didn't trip up on the server bug).
|
|
|
7711c0 |
|
|
|
7711c0 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
7711c0 |
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
|
7711c0 |
Message-Id: <20190117193658.16413-21-eblake@redhat.com>
|
|
|
7711c0 |
(cherry picked from commit 7c6f5ddca62905e67025aa0657e8a011cbdffa11)
|
|
|
7711c0 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
7711c0 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
7711c0 |
---
|
|
|
7711c0 |
nbd/client.c | 19 +++++++++++++++++++
|
|
|
7711c0 |
1 file changed, 19 insertions(+)
|
|
|
7711c0 |
|
|
|
7711c0 |
diff --git a/nbd/client.c b/nbd/client.c
|
|
|
7711c0 |
index 798b82f..8a083c2 100644
|
|
|
7711c0 |
--- a/nbd/client.c
|
|
|
7711c0 |
+++ b/nbd/client.c
|
|
|
7711c0 |
@@ -21,6 +21,7 @@
|
|
|
7711c0 |
#include "qapi/error.h"
|
|
|
7711c0 |
#include "trace.h"
|
|
|
7711c0 |
#include "nbd-internal.h"
|
|
|
7711c0 |
+#include "qemu/cutils.h"
|
|
|
7711c0 |
|
|
|
7711c0 |
/* Definitions for opaque data types */
|
|
|
7711c0 |
|
|
|
7711c0 |
@@ -828,6 +829,8 @@ static int nbd_list_meta_contexts(QIOChannel *ioc,
|
|
|
7711c0 |
Error **errp)
|
|
|
7711c0 |
{
|
|
|
7711c0 |
int ret;
|
|
|
7711c0 |
+ int seen_any = false;
|
|
|
7711c0 |
+ int seen_qemu = false;
|
|
|
7711c0 |
|
|
|
7711c0 |
if (nbd_send_meta_query(ioc, NBD_OPT_LIST_META_CONTEXT,
|
|
|
7711c0 |
info->name, NULL, errp) < 0) {
|
|
|
7711c0 |
@@ -839,9 +842,25 @@ static int nbd_list_meta_contexts(QIOChannel *ioc,
|
|
|
7711c0 |
|
|
|
7711c0 |
ret = nbd_receive_one_meta_context(ioc, NBD_OPT_LIST_META_CONTEXT,
|
|
|
7711c0 |
&context, NULL, errp);
|
|
|
7711c0 |
+ if (ret == 0 && seen_any && !seen_qemu) {
|
|
|
7711c0 |
+ /*
|
|
|
7711c0 |
+ * Work around qemu 3.0 bug: the server forgot to send
|
|
|
7711c0 |
+ * "qemu:" replies to 0 queries. If we saw at least one
|
|
|
7711c0 |
+ * reply (probably base:allocation), but none of them were
|
|
|
7711c0 |
+ * qemu:, then run a more specific query to make sure.
|
|
|
7711c0 |
+ */
|
|
|
7711c0 |
+ seen_qemu = true;
|
|
|
7711c0 |
+ if (nbd_send_meta_query(ioc, NBD_OPT_LIST_META_CONTEXT,
|
|
|
7711c0 |
+ info->name, "qemu:", errp) < 0) {
|
|
|
7711c0 |
+ return -1;
|
|
|
7711c0 |
+ }
|
|
|
7711c0 |
+ continue;
|
|
|
7711c0 |
+ }
|
|
|
7711c0 |
if (ret <= 0) {
|
|
|
7711c0 |
return ret;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
+ seen_any = true;
|
|
|
7711c0 |
+ seen_qemu |= strstart(context, "qemu:", NULL);
|
|
|
7711c0 |
info->contexts = g_renew(char *, info->contexts, ++info->n_contexts);
|
|
|
7711c0 |
info->contexts[info->n_contexts - 1] = context;
|
|
|
7711c0 |
}
|
|
|
7711c0 |
--
|
|
|
7711c0 |
1.8.3.1
|
|
|
7711c0 |
|