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