* [Qemu-devel] [RFC V2 0/3] Giving names to BlockDriverState graph nodes
@ 2013-11-12 14:39 Benoît Canet
2013-11-12 14:39 ` [Qemu-devel] [RFC V2 1/3] block: Add bs->node_name to hold the name of a bs node of the bs graph Benoît Canet
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Benoît Canet @ 2013-11-12 14:39 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, famz, Benoît Canet, jcody, armbru, stefanha
This series fix the issues of V1 and add the skeletton of a new QMP command
useful to communicate a bs graph to libvirt.
The minimum is exposed to the management to avoid binding it too much with QEMU.
Tell me if you think it's worth implementing.
Best regards
Benoît
v2:
s/give/gives/ [Eric]
s/see/sees/ [Eric]
prevent duplicate node_name [Eric]
drop "undefined" and use "" [Eric, Kevin, Jeff]
remove from graph list on bdrv_make_anon [Jeff]
comment the two chains [Fam]
Add new command stub to retrieve the graph from libvirt [Benoît]
Benoît Canet (3):
block: Add bs->node_name to hold the name of a bs node of the bs
graph.
block: Allow the user to define "node-name" option.
qapi: Add skeletton of command to query a drive bs graph.
block.c | 88 +++++++++++++++++++++++++++++++++++++----------
block/blkverify.c | 2 +-
block/iscsi.c | 2 +-
block/vmdk.c | 2 +-
block/vvfat.c | 4 +--
blockdev.c | 16 ++++++---
hw/block/xen_disk.c | 2 +-
include/block/block.h | 3 +-
include/block/block_int.h | 9 ++++-
qapi-schema.json | 32 +++++++++++++++++
qemu-img.c | 6 ++--
qemu-io.c | 2 +-
qemu-nbd.c | 2 +-
13 files changed, 134 insertions(+), 36 deletions(-)
--
1.8.3.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [RFC V2 1/3] block: Add bs->node_name to hold the name of a bs node of the bs graph.
2013-11-12 14:39 [Qemu-devel] [RFC V2 0/3] Giving names to BlockDriverState graph nodes Benoît Canet
@ 2013-11-12 14:39 ` Benoît Canet
2013-11-12 14:39 ` [Qemu-devel] [RFC V2 2/3] block: Allow the user to define "node-name" option Benoît Canet
2013-11-12 14:39 ` [Qemu-devel] [RFC V2 3/3] qapi: Add skeletton of command to query a drive bs graph Benoît Canet
2 siblings, 0 replies; 4+ messages in thread
From: Benoît Canet @ 2013-11-12 14:39 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, famz, Benoît Canet, jcody, armbru, stefanha
Add the minimum of code to prepare the followings patches.
Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
block.c | 72 ++++++++++++++++++++++++++++++++++-------------
block/blkverify.c | 2 +-
block/iscsi.c | 2 +-
block/vmdk.c | 2 +-
block/vvfat.c | 4 +--
blockdev.c | 8 +++---
hw/block/xen_disk.c | 2 +-
include/block/block.h | 3 +-
include/block/block_int.h | 9 +++++-
qemu-img.c | 6 ++--
qemu-io.c | 2 +-
qemu-nbd.c | 2 +-
12 files changed, 78 insertions(+), 36 deletions(-)
diff --git a/block.c b/block.c
index fd05a80..c397ee9 100644
--- a/block.c
+++ b/block.c
@@ -89,6 +89,9 @@ static int coroutine_fn bdrv_co_do_write_zeroes(BlockDriverState *bs,
static QTAILQ_HEAD(, BlockDriverState) bdrv_states =
QTAILQ_HEAD_INITIALIZER(bdrv_states);
+static QTAILQ_HEAD(, BlockDriverState) graph_bdrv_states =
+ QTAILQ_HEAD_INITIALIZER(graph_bdrv_states);
+
static QLIST_HEAD(, BlockDriver) bdrv_drivers =
QLIST_HEAD_INITIALIZER(bdrv_drivers);
@@ -318,14 +321,20 @@ void bdrv_register(BlockDriver *bdrv)
}
/* create a new block device (by default it is empty) */
-BlockDriverState *bdrv_new(const char *device_name)
+BlockDriverState *bdrv_new(const char *device_name, const char *node_name)
{
BlockDriverState *bs;
+ assert(node_name);
+
bs = g_malloc0(sizeof(BlockDriverState));
pstrcpy(bs->device_name, sizeof(bs->device_name), device_name);
if (device_name[0] != '\0') {
- QTAILQ_INSERT_TAIL(&bdrv_states, bs, list);
+ QTAILQ_INSERT_TAIL(&bdrv_states, bs, device_list);
+ }
+ pstrcpy(bs->node_name, sizeof(bs->node_name), node_name);
+ if (node_name[0] != '\0') {
+ QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list);
}
bdrv_iostatus_disable(bs);
notifier_list_init(&bs->close_notifiers);
@@ -870,7 +879,7 @@ int bdrv_file_open(BlockDriverState **pbs, const char *filename,
options = qdict_new();
}
- bs = bdrv_new("");
+ bs = bdrv_new("", "");
bs->options = options;
options = qdict_clone_shallow(options);
@@ -992,7 +1001,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
sizeof(backing_filename));
}
- bs->backing_hd = bdrv_new("");
+ bs->backing_hd = bdrv_new("", "");
if (bs->backing_format[0] != '\0') {
back_drv = bdrv_find_format(bs->backing_format);
@@ -1062,7 +1071,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
instead of opening 'filename' directly */
/* if there is a backing file, use it */
- bs1 = bdrv_new("");
+ bs1 = bdrv_new("", "");
ret = bdrv_open(bs1, filename, NULL, 0, drv, &local_err);
if (ret < 0) {
bdrv_unref(bs1);
@@ -1495,7 +1504,7 @@ void bdrv_close_all(void)
{
BlockDriverState *bs;
- QTAILQ_FOREACH(bs, &bdrv_states, list) {
+ QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
bdrv_close(bs);
}
}
@@ -1524,7 +1533,7 @@ static bool bdrv_requests_pending(BlockDriverState *bs)
static bool bdrv_requests_pending_all(void)
{
BlockDriverState *bs;
- QTAILQ_FOREACH(bs, &bdrv_states, list) {
+ QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
if (bdrv_requests_pending(bs)) {
return true;
}
@@ -1554,7 +1563,7 @@ void bdrv_drain_all(void)
/* FIXME: We do not have timer support here, so this is effectively
* a busy wait.
*/
- QTAILQ_FOREACH(bs, &bdrv_states, list) {
+ QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
if (bdrv_start_throttled_reqs(bs)) {
busy = true;
}
@@ -1565,14 +1574,18 @@ void bdrv_drain_all(void)
}
}
-/* make a BlockDriverState anonymous by removing from bdrv_state list.
+/* make a BlockDriverState anonymous by removing from bdrv_state and
+ * graph_bdrv_state list.
Also, NULL terminate the device_name to prevent double remove */
void bdrv_make_anon(BlockDriverState *bs)
{
if (bs->device_name[0] != '\0') {
- QTAILQ_REMOVE(&bdrv_states, bs, list);
+ QTAILQ_REMOVE(&bdrv_states, bs, device_list);
}
bs->device_name[0] = '\0';
+ if (bs->node_name[0] != '\0') {
+ QTAILQ_REMOVE(&graph_bdrv_states, bs, node_list);
+ }
}
static void bdrv_rebind(BlockDriverState *bs)
@@ -1626,7 +1639,12 @@ static void bdrv_move_feature_fields(BlockDriverState *bs_dest,
/* keep the same entry in bdrv_states */
pstrcpy(bs_dest->device_name, sizeof(bs_dest->device_name),
bs_src->device_name);
- bs_dest->list = bs_src->list;
+ bs_dest->device_list = bs_src->device_list;
+
+ /* keep the same entry in graph_bdrv_states */
+ pstrcpy(bs_dest->node_name, sizeof(bs_dest->node_name),
+ bs_src->node_name);
+ bs_dest->node_list = bs_src->node_list;
}
/*
@@ -1950,7 +1968,7 @@ int bdrv_commit_all(void)
{
BlockDriverState *bs;
- QTAILQ_FOREACH(bs, &bdrv_states, list) {
+ QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
if (bs->drv && bs->backing_hd) {
int ret = bdrv_commit(bs);
if (ret < 0) {
@@ -3017,11 +3035,12 @@ void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
}
}
+/* This function is to find block backend bs */
BlockDriverState *bdrv_find(const char *name)
{
BlockDriverState *bs;
- QTAILQ_FOREACH(bs, &bdrv_states, list) {
+ QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
if (!strcmp(name, bs->device_name)) {
return bs;
}
@@ -3029,19 +3048,34 @@ BlockDriverState *bdrv_find(const char *name)
return NULL;
}
+/* This function is to find a node in the bs graph */
+BlockDriverState *bdrv_find_node(const char *node_name)
+{
+ BlockDriverState *bs;
+
+ assert(node_name);
+
+ QTAILQ_FOREACH(bs, &graph_bdrv_states, node_list) {
+ if (!strcmp(node_name, bs->node_name)) {
+ return bs;
+ }
+ }
+ return NULL;
+}
+
BlockDriverState *bdrv_next(BlockDriverState *bs)
{
if (!bs) {
return QTAILQ_FIRST(&bdrv_states);
}
- return QTAILQ_NEXT(bs, list);
+ return QTAILQ_NEXT(bs, device_list);
}
void bdrv_iterate(void (*it)(void *opaque, BlockDriverState *bs), void *opaque)
{
BlockDriverState *bs;
- QTAILQ_FOREACH(bs, &bdrv_states, list) {
+ QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
it(opaque, bs);
}
}
@@ -3061,7 +3095,7 @@ int bdrv_flush_all(void)
BlockDriverState *bs;
int result = 0;
- QTAILQ_FOREACH(bs, &bdrv_states, list) {
+ QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
int ret = bdrv_flush(bs);
if (ret < 0 && !result) {
result = ret;
@@ -4127,7 +4161,7 @@ void bdrv_invalidate_cache_all(void)
{
BlockDriverState *bs;
- QTAILQ_FOREACH(bs, &bdrv_states, list) {
+ QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
bdrv_invalidate_cache(bs);
}
}
@@ -4136,7 +4170,7 @@ void bdrv_clear_incoming_migration_all(void)
{
BlockDriverState *bs;
- QTAILQ_FOREACH(bs, &bdrv_states, list) {
+ QTAILQ_FOREACH(bs, &bdrv_states, device_list) {
bs->open_flags = bs->open_flags & ~(BDRV_O_INCOMING);
}
}
@@ -4582,7 +4616,7 @@ void bdrv_img_create(const char *filename, const char *fmt,
back_flags =
flags & ~(BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING);
- bs = bdrv_new("");
+ bs = bdrv_new("", "");
ret = bdrv_open(bs, backing_file->value.s, NULL, back_flags,
backing_drv, &local_err);
diff --git a/block/blkverify.c b/block/blkverify.c
index 55819a0..e755e4e 100644
--- a/block/blkverify.c
+++ b/block/blkverify.c
@@ -155,7 +155,7 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags,
goto fail;
}
- s->test_file = bdrv_new("");
+ s->test_file = bdrv_new("", "");
ret = bdrv_open(s->test_file, filename, NULL, flags, NULL, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
diff --git a/block/iscsi.c b/block/iscsi.c
index a2a961e..673b156 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -1461,7 +1461,7 @@ static int iscsi_create(const char *filename, QEMUOptionParameter *options,
IscsiLun *iscsilun = NULL;
QDict *bs_options;
- bs = bdrv_new("");
+ bs = bdrv_new("", "");
/* Read out options */
while (options && options->name) {
diff --git a/block/vmdk.c b/block/vmdk.c
index 32ec8b77..e258db8 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -1672,7 +1672,7 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options,
return -ENOTSUP;
}
if (backing_file) {
- BlockDriverState *bs = bdrv_new("");
+ BlockDriverState *bs = bdrv_new("", "");
ret = bdrv_open(bs, backing_file, NULL, 0, NULL, errp);
if (ret != 0) {
bdrv_unref(bs);
diff --git a/block/vvfat.c b/block/vvfat.c
index 3ddaa0b..f973c08 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -2935,7 +2935,7 @@ static int enable_write_target(BDRVVVFATState *s)
goto err;
}
- s->qcow = bdrv_new("");
+ s->qcow = bdrv_new("", "");
ret = bdrv_open(s->qcow, s->qcow_filename, NULL,
BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH, bdrv_qcow,
@@ -2951,7 +2951,7 @@ static int enable_write_target(BDRVVVFATState *s)
unlink(s->qcow_filename);
#endif
- s->bs->backing_hd = bdrv_new("");
+ s->bs->backing_hd = bdrv_new("", "");
s->bs->backing_hd->drv = &vvfat_write_target;
s->bs->backing_hd->opaque = g_malloc(sizeof(void*));
*(void**)s->bs->backing_hd->opaque = s;
diff --git a/blockdev.c b/blockdev.c
index b260477..911ee7e 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -469,7 +469,7 @@ static DriveInfo *blockdev_init(QDict *bs_opts,
/* init */
dinfo = g_malloc0(sizeof(*dinfo));
dinfo->id = g_strdup(qemu_opts_id(opts));
- dinfo->bdrv = bdrv_new(dinfo->id);
+ dinfo->bdrv = bdrv_new(dinfo->id, "");
dinfo->bdrv->open_flags = snapshot ? BDRV_O_SNAPSHOT : 0;
dinfo->bdrv->read_only = ro;
dinfo->type = type;
@@ -1254,7 +1254,7 @@ static void external_snapshot_prepare(BlkTransactionState *common,
}
/* We will manually add the backing_hd field to the bs later */
- state->new_bs = bdrv_new("");
+ state->new_bs = bdrv_new("", "");
/* TODO Inherit bs->options or only take explicit options with an
* extended QMP command? */
ret = bdrv_open(state->new_bs, new_image_file, NULL,
@@ -1921,7 +1921,7 @@ void qmp_drive_backup(const char *device, const char *target,
return;
}
- target_bs = bdrv_new("");
+ target_bs = bdrv_new("", "");
ret = bdrv_open(target_bs, target, NULL, flags, drv, &local_err);
if (ret < 0) {
bdrv_unref(target_bs);
@@ -2055,7 +2055,7 @@ void qmp_drive_mirror(const char *device, const char *target,
/* Mirroring takes care of copy-on-write using the source's backing
* file.
*/
- target_bs = bdrv_new("");
+ target_bs = bdrv_new("", "");
ret = bdrv_open(target_bs, target, NULL, flags | BDRV_O_NO_BACKING, drv,
&local_err);
if (ret < 0) {
diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
index 098f6c6..e8a45d1 100644
--- a/hw/block/xen_disk.c
+++ b/hw/block/xen_disk.c
@@ -808,7 +808,7 @@ static int blk_connect(struct XenDevice *xendev)
if (!blkdev->dinfo) {
/* setup via xenbus -> create new block driver instance */
xen_be_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n");
- blkdev->bs = bdrv_new(blkdev->dev);
+ blkdev->bs = bdrv_new(blkdev->dev, "");
if (blkdev->bs) {
Error *local_err = NULL;
BlockDriver *drv = bdrv_find_whitelisted_format(blkdev->fileproto,
diff --git a/include/block/block.h b/include/block/block.h
index 3560deb..2d27bd9 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -149,7 +149,7 @@ int bdrv_create(BlockDriver *drv, const char* filename,
QEMUOptionParameter *options, Error **errp);
int bdrv_create_file(const char* filename, QEMUOptionParameter *options,
Error **errp);
-BlockDriverState *bdrv_new(const char *device_name);
+BlockDriverState *bdrv_new(const char *device_name, const char *node_name);
void bdrv_make_anon(BlockDriverState *bs);
void bdrv_swap(BlockDriverState *bs_new, BlockDriverState *bs_old);
void bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top);
@@ -339,6 +339,7 @@ void bdrv_lock_medium(BlockDriverState *bs, bool locked);
void bdrv_eject(BlockDriverState *bs, bool eject_flag);
const char *bdrv_get_format_name(BlockDriverState *bs);
BlockDriverState *bdrv_find(const char *name);
+BlockDriverState *bdrv_find_node(const char *node_name);
BlockDriverState *bdrv_next(BlockDriverState *bs);
void bdrv_iterate(void (*it)(void *opaque, BlockDriverState *bs),
void *opaque);
diff --git a/include/block/block_int.h b/include/block/block_int.h
index a48731d..84d8db5 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -297,11 +297,18 @@ struct BlockDriverState {
BlockdevOnError on_read_error, on_write_error;
bool iostatus_enabled;
BlockDeviceIoStatus iostatus;
+
+ /* the following member gives a name to every node on the bs graph. */
+ char node_name[32];
+ /* element of the list of named nodes building the graph */
+ QTAILQ_ENTRY(BlockDriverState) node_list;
+ /* Device name is the name associated with the "drive" the guest sees */
char device_name[32];
+ /* element of the list of "drives" the guest sees */
+ QTAILQ_ENTRY(BlockDriverState) device_list;
HBitmap *dirty_bitmap;
int refcnt;
int in_use; /* users other than guest access, eg. block migration */
- QTAILQ_ENTRY(BlockDriverState) list;
QLIST_HEAD(, BdrvTrackedRequest) tracked_requests;
diff --git a/qemu-img.c b/qemu-img.c
index 926f0a0..1803a59 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -269,7 +269,7 @@ static BlockDriverState *bdrv_new_open(const char *filename,
Error *local_err = NULL;
int ret;
- bs = bdrv_new("image");
+ bs = bdrv_new("image", "");
if (fmt) {
drv = bdrv_find_format(fmt);
@@ -2225,7 +2225,7 @@ static int img_rebase(int argc, char **argv)
} else {
char backing_name[1024];
- bs_old_backing = bdrv_new("old_backing");
+ bs_old_backing = bdrv_new("old_backing", "");
bdrv_get_backing_filename(bs, backing_name, sizeof(backing_name));
ret = bdrv_open(bs_old_backing, backing_name, NULL, BDRV_O_FLAGS,
old_backing_drv, &local_err);
@@ -2236,7 +2236,7 @@ static int img_rebase(int argc, char **argv)
goto out;
}
if (out_baseimg[0]) {
- bs_new_backing = bdrv_new("new_backing");
+ bs_new_backing = bdrv_new("new_backing", "");
ret = bdrv_open(bs_new_backing, out_baseimg, NULL, BDRV_O_FLAGS,
new_backing_drv, &local_err);
if (ret) {
diff --git a/qemu-io.c b/qemu-io.c
index 3b3340a..fb04c74 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -63,7 +63,7 @@ static int openfile(char *name, int flags, int growable, QDict *opts)
return 1;
}
} else {
- qemuio_bs = bdrv_new("hda");
+ qemuio_bs = bdrv_new("hda", "");
if (bdrv_open(qemuio_bs, name, opts, flags, NULL, &local_err) < 0) {
fprintf(stderr, "%s: can't open device %s: %s\n", progname, name,
diff --git a/qemu-nbd.c b/qemu-nbd.c
index c26c98e..245fecf 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -572,7 +572,7 @@ int main(int argc, char **argv)
drv = NULL;
}
- bs = bdrv_new("hda");
+ bs = bdrv_new("hda", "");
srcpath = argv[optind];
ret = bdrv_open(bs, srcpath, NULL, flags, drv, &local_err);
if (ret < 0) {
--
1.8.3.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [RFC V2 2/3] block: Allow the user to define "node-name" option.
2013-11-12 14:39 [Qemu-devel] [RFC V2 0/3] Giving names to BlockDriverState graph nodes Benoît Canet
2013-11-12 14:39 ` [Qemu-devel] [RFC V2 1/3] block: Add bs->node_name to hold the name of a bs node of the bs graph Benoît Canet
@ 2013-11-12 14:39 ` Benoît Canet
2013-11-12 14:39 ` [Qemu-devel] [RFC V2 3/3] qapi: Add skeletton of command to query a drive bs graph Benoît Canet
2 siblings, 0 replies; 4+ messages in thread
From: Benoît Canet @ 2013-11-12 14:39 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, famz, Benoît Canet, jcody, armbru, stefanha
Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
block.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/block.c b/block.c
index c397ee9..6690e3d 100644
--- a/block.c
+++ b/block.c
@@ -872,6 +872,7 @@ int bdrv_file_open(BlockDriverState **pbs, const char *filename,
const char *drvname;
bool allow_protocol_prefix = false;
Error *local_err = NULL;
+ const char *node_name = NULL;
int ret;
/* NULL means an empty set of options */
@@ -879,7 +880,14 @@ int bdrv_file_open(BlockDriverState **pbs, const char *filename,
options = qdict_new();
}
- bs = bdrv_new("", "");
+ node_name = qdict_get_try_str(options, "node-name");
+ if (node_name && bdrv_find_node(node_name)) {
+ error_setg(errp, "Duplicate node name");
+ return -EINVAL;
+ }
+ bs = bdrv_new("", node_name ? node_name : "");
+ qdict_del(options, "node-name");
+
bs->options = options;
options = qdict_clone_shallow(options);
@@ -979,6 +987,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
int back_flags, ret;
BlockDriver *back_drv = NULL;
Error *local_err = NULL;
+ const char *node_name = NULL;
if (bs->backing_hd != NULL) {
QDECREF(options);
@@ -1001,7 +1010,14 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *options, Error **errp)
sizeof(backing_filename));
}
- bs->backing_hd = bdrv_new("", "");
+ node_name = qdict_get_try_str(options, "node-name");
+ if (node_name && bdrv_find_node(node_name)) {
+ error_setg(errp, "Duplicate node name");
+ QDECREF(options);
+ return -EINVAL;
+ }
+ bs->backing_hd = bdrv_new("", node_name ? node_name : "");
+ qdict_del(options, "node-name");
if (bs->backing_format[0] != '\0') {
back_drv = bdrv_find_format(bs->backing_format);
--
1.8.3.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [RFC V2 3/3] qapi: Add skeletton of command to query a drive bs graph.
2013-11-12 14:39 [Qemu-devel] [RFC V2 0/3] Giving names to BlockDriverState graph nodes Benoît Canet
2013-11-12 14:39 ` [Qemu-devel] [RFC V2 1/3] block: Add bs->node_name to hold the name of a bs node of the bs graph Benoît Canet
2013-11-12 14:39 ` [Qemu-devel] [RFC V2 2/3] block: Allow the user to define "node-name" option Benoît Canet
@ 2013-11-12 14:39 ` Benoît Canet
2 siblings, 0 replies; 4+ messages in thread
From: Benoît Canet @ 2013-11-12 14:39 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, famz, Benoît Canet, jcody, armbru, stefanha
---
blockdev.c | 8 ++++++++
qapi-schema.json | 32 ++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/blockdev.c b/blockdev.c
index 911ee7e..bfaeda0 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1938,6 +1938,14 @@ void qmp_drive_backup(const char *device, const char *target,
}
}
+BlockGraphNode *qmp_query_drive_graph(const char *device, Error **errp)
+{
+ /* the implementation of this function would recurse through the
+ * BlockDriverState graph to build it's result
+ */
+ return NULL;
+}
+
#define DEFAULT_MIRROR_BUF_SIZE (10 << 20)
void qmp_drive_mirror(const char *device, const char *target,
diff --git a/qapi-schema.json b/qapi-schema.json
index 60f3fd1..bca3d5a 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1983,6 +1983,38 @@
{ 'command': 'drive-backup', 'data': 'DriveBackup' }
##
+# @BlockGraphNode
+#
+# Information about a node of the block driver state graph
+#
+# @node-name: the name of the node in the graph
+#
+# @drv: the name of the block format used by this node as described in
+# @BlockDeviceInfo.
+#
+# @children: a list of @BlockGraphNode being the children of this node
+#
+# Since 1.8
+##
+{ 'type': 'BlockGraphNode',
+ 'data': { 'node-name': 'str', 'drv': 'str', 'children': ['BlockGraphNode'] } }
+
+##
+# @query-drive-graph
+#
+# Get the block driver states graph for a given drive
+#
+# @device: the name of the device to get the graph from
+#
+# Returns: the root @BlockGraphNode
+#
+# Since 1.8
+##
+{ 'command': 'query-drive-graph',
+ 'data': { 'device': 'str' },
+ 'returns': 'BlockGraphNode' }
+
+##
# @drive-mirror
#
# Start mirroring a block device's writes to a new destination.
--
1.8.3.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-11-12 14:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-12 14:39 [Qemu-devel] [RFC V2 0/3] Giving names to BlockDriverState graph nodes Benoît Canet
2013-11-12 14:39 ` [Qemu-devel] [RFC V2 1/3] block: Add bs->node_name to hold the name of a bs node of the bs graph Benoît Canet
2013-11-12 14:39 ` [Qemu-devel] [RFC V2 2/3] block: Allow the user to define "node-name" option Benoît Canet
2013-11-12 14:39 ` [Qemu-devel] [RFC V2 3/3] qapi: Add skeletton of command to query a drive bs graph Benoît Canet
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).