[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 19/29] nbd: Implement bdrv_refresh_filename()
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 19/29] nbd: Implement bdrv_refresh_filename() |
Date: |
Fri, 22 Aug 2014 16:51:43 +0200 |
From: Max Reitz <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/nbd.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/block/nbd.c b/block/nbd.c
index 4eda095..89775e1 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -31,8 +31,10 @@
#include "block/block_int.h"
#include "qemu/module.h"
#include "qemu/sockets.h"
+#include "qapi/qmp/qdict.h"
#include "qapi/qmp/qjson.h"
#include "qapi/qmp/qint.h"
+#include "qapi/qmp/qstring.h"
#include <sys/types.h>
#include <unistd.h>
@@ -338,6 +340,37 @@ static void nbd_attach_aio_context(BlockDriverState *bs,
nbd_client_session_attach_aio_context(&s->client, new_context);
}
+static void nbd_refresh_filename(BlockDriverState *bs)
+{
+ BDRVNBDState *s = bs->opaque;
+ QDict *opts = qdict_new();
+ const char *path = qemu_opt_get(s->socket_opts, "path");
+ const char *host = qemu_opt_get(s->socket_opts, "host");
+ const char *port = qemu_opt_get(s->socket_opts, "port");
+ const char *export = qemu_opt_get(s->socket_opts, "export");
+
+ qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("nbd")));
+
+ if (path) {
+ snprintf(bs->exact_filename, sizeof(bs->exact_filename),
+ "nbd+unix:%s", path);
+ qdict_put_obj(opts, "path", QOBJECT(qstring_from_str(path)));
+ } else if (export) {
+ snprintf(bs->exact_filename, sizeof(bs->exact_filename),
+ "nbd:%s:%s/%s", host, port, export);
+ qdict_put_obj(opts, "host", QOBJECT(qstring_from_str(host)));
+ qdict_put_obj(opts, "port", QOBJECT(qstring_from_str(port)));
+ qdict_put_obj(opts, "export", QOBJECT(qstring_from_str(export)));
+ } else {
+ snprintf(bs->exact_filename, sizeof(bs->exact_filename),
+ "nbd:%s:%s", host, port);
+ qdict_put_obj(opts, "host", QOBJECT(qstring_from_str(host)));
+ qdict_put_obj(opts, "port", QOBJECT(qstring_from_str(port)));
+ }
+
+ bs->full_open_options = opts;
+}
+
static BlockDriver bdrv_nbd = {
.format_name = "nbd",
.protocol_name = "nbd",
@@ -352,6 +385,7 @@ static BlockDriver bdrv_nbd = {
.bdrv_getlength = nbd_getlength,
.bdrv_detach_aio_context = nbd_detach_aio_context,
.bdrv_attach_aio_context = nbd_attach_aio_context,
+ .bdrv_refresh_filename = nbd_refresh_filename,
};
static BlockDriver bdrv_nbd_tcp = {
@@ -368,6 +402,7 @@ static BlockDriver bdrv_nbd_tcp = {
.bdrv_getlength = nbd_getlength,
.bdrv_detach_aio_context = nbd_detach_aio_context,
.bdrv_attach_aio_context = nbd_attach_aio_context,
+ .bdrv_refresh_filename = nbd_refresh_filename,
};
static BlockDriver bdrv_nbd_unix = {
@@ -384,6 +419,7 @@ static BlockDriver bdrv_nbd_unix = {
.bdrv_getlength = nbd_getlength,
.bdrv_detach_aio_context = nbd_detach_aio_context,
.bdrv_attach_aio_context = nbd_attach_aio_context,
+ .bdrv_refresh_filename = nbd_refresh_filename,
};
static void bdrv_nbd_init(void)
--
1.8.3.1
- [Qemu-devel] [PULL 10/29] iotests: Add test for qcow2's cache options, (continued)
- [Qemu-devel] [PULL 10/29] iotests: Add test for qcow2's cache options, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 09/29] qcow2: Add runtime options for cache sizes, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 11/29] test-coroutine: test cost introduced by coroutine, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 12/29] qemu-iotests: Fix 028 reference output for qed, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 14/29] virtio-blk: allow block_resize with dataplane, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 13/29] block: acquire AioContext in qmp_block_resize(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 15/29] virtio-blk: fix reference a pointer which might be freed, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 17/29] blkdebug: Implement bdrv_refresh_filename(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 16/29] block: Add bdrv_refresh_filename(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 18/29] blkverify: Implement bdrv_refresh_filename(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 19/29] nbd: Implement bdrv_refresh_filename(),
Kevin Wolf <=
- [Qemu-devel] [PULL 21/29] iotests: Add test for image filename construction, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 22/29] block/vvfat.c: remove debugging code to reinit stderr if NULL, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 20/29] quorum: Implement bdrv_refresh_filename(), Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 24/29] raw-posix: fix O_DIRECT short reads, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 23/29] block/iscsi: fix memory corruption on iscsi resize, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 25/29] qemu-iotests: add test case 101 for short file I/O, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 26/29] blkdebug: Delete BH in bdrv_aio_cancel, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 27/29] vmdk: Use bdrv_nb_sectors() where sectors, not bytes are wanted, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 28/29] qemu-img: Allow source cache mode specification, Kevin Wolf, 2014/08/22
- [Qemu-devel] [PULL 29/29] qemu-img: Allow cache mode specification for amend, Kevin Wolf, 2014/08/22