|
|
357786 |
From d52addb6a2ca32ce942f348ed47da26cd9524fbd Mon Sep 17 00:00:00 2001
|
|
|
357786 |
From: John Snow <jsnow@redhat.com>
|
|
|
357786 |
Date: Wed, 18 Jul 2018 22:55:10 +0200
|
|
|
357786 |
Subject: [PATCH 85/89] nbd/client: Add x-dirty-bitmap to query bitmap from
|
|
|
357786 |
server
|
|
|
357786 |
|
|
|
357786 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
357786 |
Message-id: <20180718225511.14878-35-jsnow@redhat.com>
|
|
|
357786 |
Patchwork-id: 81414
|
|
|
357786 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 34/35] nbd/client: Add x-dirty-bitmap to query bitmap from server
|
|
|
357786 |
Bugzilla: 1207657
|
|
|
357786 |
RH-Acked-by: Eric Blake <eblake@redhat.com>
|
|
|
357786 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
357786 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
357786 |
|
|
|
357786 |
From: Eric Blake <eblake@redhat.com>
|
|
|
357786 |
|
|
|
357786 |
In order to test that the NBD server is properly advertising
|
|
|
357786 |
dirty bitmaps, we need a bare minimum client that can request
|
|
|
357786 |
and read the context. Since feature freeze for 3.0 is imminent,
|
|
|
357786 |
this is the smallest workable patch, which replaces the qemu
|
|
|
357786 |
block status report with the results of the NBD server's dirty
|
|
|
357786 |
bitmap (making it very easy to use 'qemu-img map --output=json'
|
|
|
357786 |
to learn where the dirty portions are). Note that the NBD
|
|
|
357786 |
protocol defines a dirty section with the same bit but opposite
|
|
|
357786 |
sense that normal "base:allocation" uses to report an allocated
|
|
|
357786 |
section; so in qemu-img map output, "data":true corresponds to
|
|
|
357786 |
clean, "data":false corresponds to dirty.
|
|
|
357786 |
|
|
|
357786 |
A more complete solution that allows dirty bitmaps to be queried
|
|
|
357786 |
at the same time as normal block status will be required before
|
|
|
357786 |
this addition can lose the x- prefix. Until then, the fact that
|
|
|
357786 |
this replaces normal status with dirty status means actions
|
|
|
357786 |
like 'qemu-img convert' will likely misbehave due to treating
|
|
|
357786 |
dirty regions of the file as if they are unallocated.
|
|
|
357786 |
|
|
|
357786 |
The next patch adds an iotest to exercise this new code.
|
|
|
357786 |
|
|
|
357786 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
357786 |
Message-Id: <20180702191458.28741-2-eblake@redhat.com>
|
|
|
357786 |
(cherry picked from commit 216ee3657e14013505abe7853cecb632199fb13e)
|
|
|
357786 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
357786 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
357786 |
---
|
|
|
357786 |
block/nbd-client.c | 3 +++
|
|
|
357786 |
block/nbd-client.h | 1 +
|
|
|
357786 |
block/nbd.c | 10 ++++++++--
|
|
|
357786 |
include/block/nbd.h | 1 +
|
|
|
357786 |
nbd/client.c | 4 ++--
|
|
|
357786 |
qapi/block-core.json | 7 ++++++-
|
|
|
357786 |
6 files changed, 21 insertions(+), 5 deletions(-)
|
|
|
357786 |
|
|
|
357786 |
diff --git a/block/nbd-client.c b/block/nbd-client.c
|
|
|
357786 |
index e7caf49..98637c0 100644
|
|
|
357786 |
--- a/block/nbd-client.c
|
|
|
357786 |
+++ b/block/nbd-client.c
|
|
|
357786 |
@@ -966,6 +966,7 @@ int nbd_client_init(BlockDriverState *bs,
|
|
|
357786 |
const char *export,
|
|
|
357786 |
QCryptoTLSCreds *tlscreds,
|
|
|
357786 |
const char *hostname,
|
|
|
357786 |
+ const char *x_dirty_bitmap,
|
|
|
357786 |
Error **errp)
|
|
|
357786 |
{
|
|
|
357786 |
NBDClientSession *client = nbd_get_client_session(bs);
|
|
|
357786 |
@@ -978,9 +979,11 @@ int nbd_client_init(BlockDriverState *bs,
|
|
|
357786 |
client->info.request_sizes = true;
|
|
|
357786 |
client->info.structured_reply = true;
|
|
|
357786 |
client->info.base_allocation = true;
|
|
|
357786 |
+ client->info.x_dirty_bitmap = g_strdup(x_dirty_bitmap);
|
|
|
357786 |
ret = nbd_receive_negotiate(QIO_CHANNEL(sioc), export,
|
|
|
357786 |
tlscreds, hostname,
|
|
|
357786 |
&client->ioc, &client->info, errp);
|
|
|
357786 |
+ g_free(client->info.x_dirty_bitmap);
|
|
|
357786 |
if (ret < 0) {
|
|
|
357786 |
logout("Failed to negotiate with the NBD server\n");
|
|
|
357786 |
return ret;
|
|
|
357786 |
diff --git a/block/nbd-client.h b/block/nbd-client.h
|
|
|
357786 |
index 0ece76e..cfc9055 100644
|
|
|
357786 |
--- a/block/nbd-client.h
|
|
|
357786 |
+++ b/block/nbd-client.h
|
|
|
357786 |
@@ -45,6 +45,7 @@ int nbd_client_init(BlockDriverState *bs,
|
|
|
357786 |
const char *export_name,
|
|
|
357786 |
QCryptoTLSCreds *tlscreds,
|
|
|
357786 |
const char *hostname,
|
|
|
357786 |
+ const char *x_dirty_bitmap,
|
|
|
357786 |
Error **errp);
|
|
|
357786 |
void nbd_client_close(BlockDriverState *bs);
|
|
|
357786 |
|
|
|
357786 |
diff --git a/block/nbd.c b/block/nbd.c
|
|
|
357786 |
index 10912c3..f29c10f 100644
|
|
|
357786 |
--- a/block/nbd.c
|
|
|
357786 |
+++ b/block/nbd.c
|
|
|
357786 |
@@ -378,6 +378,12 @@ static QemuOptsList nbd_runtime_opts = {
|
|
|
357786 |
.type = QEMU_OPT_STRING,
|
|
|
357786 |
.help = "ID of the TLS credentials to use",
|
|
|
357786 |
},
|
|
|
357786 |
+ {
|
|
|
357786 |
+ .name = "x-dirty-bitmap",
|
|
|
357786 |
+ .type = QEMU_OPT_STRING,
|
|
|
357786 |
+ .help = "experimental: expose named dirty bitmap in place of "
|
|
|
357786 |
+ "block status",
|
|
|
357786 |
+ },
|
|
|
357786 |
{ /* end of list */ }
|
|
|
357786 |
},
|
|
|
357786 |
};
|
|
|
357786 |
@@ -438,8 +444,8 @@ static int nbd_open(BlockDriverState *bs, QDict *options, int flags,
|
|
|
357786 |
}
|
|
|
357786 |
|
|
|
357786 |
/* NBD handshake */
|
|
|
357786 |
- ret = nbd_client_init(bs, sioc, s->export,
|
|
|
357786 |
- tlscreds, hostname, errp);
|
|
|
357786 |
+ ret = nbd_client_init(bs, sioc, s->export, tlscreds, hostname,
|
|
|
357786 |
+ qemu_opt_get(opts, "x-dirty-bitmap"), errp);
|
|
|
357786 |
error:
|
|
|
357786 |
if (sioc) {
|
|
|
357786 |
object_unref(OBJECT(sioc));
|
|
|
357786 |
diff --git a/include/block/nbd.h b/include/block/nbd.h
|
|
|
357786 |
index daaeae6..4638c83 100644
|
|
|
357786 |
--- a/include/block/nbd.h
|
|
|
357786 |
+++ b/include/block/nbd.h
|
|
|
357786 |
@@ -259,6 +259,7 @@ static inline bool nbd_reply_type_is_error(int type)
|
|
|
357786 |
struct NBDExportInfo {
|
|
|
357786 |
/* Set by client before nbd_receive_negotiate() */
|
|
|
357786 |
bool request_sizes;
|
|
|
357786 |
+ char *x_dirty_bitmap;
|
|
|
357786 |
|
|
|
357786 |
/* In-out fields, set by client before nbd_receive_negotiate() and
|
|
|
357786 |
* updated by server results during nbd_receive_negotiate() */
|
|
|
357786 |
diff --git a/nbd/client.c b/nbd/client.c
|
|
|
357786 |
index b9e175d..25603f2 100644
|
|
|
357786 |
--- a/nbd/client.c
|
|
|
357786 |
+++ b/nbd/client.c
|
|
|
357786 |
@@ -1,5 +1,5 @@
|
|
|
357786 |
/*
|
|
|
357786 |
- * Copyright (C) 2016-2017 Red Hat, Inc.
|
|
|
357786 |
+ * Copyright (C) 2016-2018 Red Hat, Inc.
|
|
|
357786 |
* Copyright (C) 2005 Anthony Liguori <anthony@codemonkey.ws>
|
|
|
357786 |
*
|
|
|
357786 |
* Network Block Device Client Side
|
|
|
357786 |
@@ -825,7 +825,7 @@ int nbd_receive_negotiate(QIOChannel *ioc, const char *name,
|
|
|
357786 |
|
|
|
357786 |
if (info->structured_reply && base_allocation) {
|
|
|
357786 |
result = nbd_negotiate_simple_meta_context(
|
|
|
357786 |
- ioc, name, "base:allocation",
|
|
|
357786 |
+ ioc, name, info->x_dirty_bitmap ?: "base:allocation",
|
|
|
357786 |
&info->meta_base_allocation_id, errp);
|
|
|
357786 |
if (result < 0) {
|
|
|
357786 |
goto fail;
|
|
|
357786 |
diff --git a/qapi/block-core.json b/qapi/block-core.json
|
|
|
357786 |
index 69e0cf8..8a00bec 100644
|
|
|
357786 |
--- a/qapi/block-core.json
|
|
|
357786 |
+++ b/qapi/block-core.json
|
|
|
357786 |
@@ -3457,12 +3457,17 @@
|
|
|
357786 |
#
|
|
|
357786 |
# @tls-creds: TLS credentials ID
|
|
|
357786 |
#
|
|
|
357786 |
+# @x-dirty-bitmap: A "qemu:dirty-bitmap:NAME" string to query in place of
|
|
|
357786 |
+# traditional "base:allocation" block status (see
|
|
|
357786 |
+# NBD_OPT_LIST_META_CONTEXT in the NBD protocol) (since 3.0)
|
|
|
357786 |
+#
|
|
|
357786 |
# Since: 2.9
|
|
|
357786 |
##
|
|
|
357786 |
{ 'struct': 'BlockdevOptionsNbd',
|
|
|
357786 |
'data': { 'server': 'SocketAddress',
|
|
|
357786 |
'*export': 'str',
|
|
|
357786 |
- '*tls-creds': 'str' } }
|
|
|
357786 |
+ '*tls-creds': 'str',
|
|
|
357786 |
+ '*x-dirty-bitmap': 'str' } }
|
|
|
357786 |
|
|
|
357786 |
##
|
|
|
357786 |
# @BlockdevOptionsRaw:
|
|
|
357786 |
--
|
|
|
357786 |
1.8.3.1
|
|
|
357786 |
|