From: Max Reitz <mreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PATCH v5 1/6] block: Change bdrv_get_encrypted_filename()
Date: Mon, 19 Oct 2015 20:49:01 +0200 [thread overview]
Message-ID: <1445280546-26226-2-git-send-email-mreitz@redhat.com> (raw)
In-Reply-To: <1445280546-26226-1-git-send-email-mreitz@redhat.com>
Instead of returning a pointer to the filename, g_strdup() it. This will
become necessary once we do not have BlockDriverState.filename anymore.
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
block.c | 17 ++++++++++-------
include/block/block.h | 2 +-
monitor.c | 5 ++++-
3 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/block.c b/block.c
index f4dec11..60f9450 100644
--- a/block.c
+++ b/block.c
@@ -2585,10 +2585,12 @@ void bdrv_add_key(BlockDriverState *bs, const char *key, Error **errp)
}
} else {
if (bdrv_key_required(bs)) {
+ char *enc_filename = bdrv_get_encrypted_filename(bs);
error_set(errp, ERROR_CLASS_DEVICE_ENCRYPTED,
"'%s' (%s) is encrypted",
bdrv_get_device_or_node_name(bs),
- bdrv_get_encrypted_filename(bs));
+ enc_filename ?: "");
+ g_free(enc_filename);
}
}
}
@@ -2810,14 +2812,15 @@ bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs)
return false;
}
-const char *bdrv_get_encrypted_filename(BlockDriverState *bs)
+char *bdrv_get_encrypted_filename(BlockDriverState *bs)
{
- if (bs->backing && bs->backing->bs->encrypted)
- return bs->backing_file;
- else if (bs->encrypted)
- return bs->filename;
- else
+ if (bs->backing && bs->backing->bs->encrypted) {
+ return g_strdup(bs->backing_file);
+ } else if (bs->encrypted) {
+ return g_strdup(bs->filename);
+ } else {
return NULL;
+ }
}
void bdrv_get_backing_filename(BlockDriverState *bs,
diff --git a/include/block/block.h b/include/block/block.h
index 28d903c..340c00f 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -421,7 +421,7 @@ void bdrv_round_to_clusters(BlockDriverState *bs,
int64_t *cluster_sector_num,
int *cluster_nb_sectors);
-const char *bdrv_get_encrypted_filename(BlockDriverState *bs);
+char *bdrv_get_encrypted_filename(BlockDriverState *bs);
void bdrv_get_backing_filename(BlockDriverState *bs,
char *filename, int filename_size);
void bdrv_get_full_backing_filename(BlockDriverState *bs,
diff --git a/monitor.c b/monitor.c
index 301a143..63b884c 100644
--- a/monitor.c
+++ b/monitor.c
@@ -4117,10 +4117,13 @@ int monitor_read_bdrv_key_start(Monitor *mon, BlockDriverState *bs,
BlockCompletionFunc *completion_cb,
void *opaque)
{
+ char *enc_filename;
int err;
+ enc_filename = bdrv_get_encrypted_filename(bs);
monitor_printf(mon, "%s (%s) is encrypted.\n", bdrv_get_device_name(bs),
- bdrv_get_encrypted_filename(bs));
+ enc_filename ?: "");
+ g_free(enc_filename);
mon->password_completion_cb = completion_cb;
mon->password_opaque = opaque;
--
2.6.1
next prev parent reply other threads:[~2015-10-19 18:49 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-19 18:49 [Qemu-devel] [PATCH v5 0/6] block: Drop BDS.filename Max Reitz
2015-10-19 18:49 ` Max Reitz [this message]
2015-10-19 20:15 ` [Qemu-devel] [PATCH v5 1/6] block: Change bdrv_get_encrypted_filename() Eric Blake
2015-10-26 18:20 ` Kevin Wolf
2015-10-19 18:49 ` [Qemu-devel] [PATCH v5 2/6] block: Avoid BlockDriverState.filename Max Reitz
2015-10-19 20:35 ` Eric Blake
2015-10-26 16:51 ` Kevin Wolf
2015-10-19 18:49 ` [Qemu-devel] [PATCH v5 3/6] block: Add bdrv_filename() Max Reitz
2015-10-19 20:52 ` Eric Blake
2015-10-26 18:20 ` Kevin Wolf
2015-10-19 18:49 ` [Qemu-devel] [PATCH v5 4/6] qemu-img: Use bdrv_filename() for map Max Reitz
2015-10-19 21:02 ` Eric Blake
2015-10-26 18:21 ` Kevin Wolf
2015-10-19 18:49 ` [Qemu-devel] [PATCH v5 5/6] block: Drop BlockDriverState.filename Max Reitz
2015-10-19 21:11 ` Eric Blake
2015-10-27 9:39 ` Kevin Wolf
2015-10-19 18:49 ` [Qemu-devel] [PATCH v5 6/6] iotests: Test changed Quorum filename Max Reitz
2015-10-19 21:13 ` Eric Blake
2015-10-27 9:41 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1445280546-26226-2-git-send-email-mreitz@redhat.com \
--to=mreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).