From f18771d41cfd8b54c2dddc3ed84e1ba698c64d14 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 30 May 2018 15:47:13 +0200 Subject: [PATCH] qemu: block: Add support for 'pr-manager' in qemuBlockStorageSourceGetFileProps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To keep feature parity, we need to be able to format the PR manager alias when using blockdev. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/qemu/qemu_block.c | 5 +++++ tests/qemublocktest.c | 1 + .../xml2json/block-raw-reservations.json | 14 ++++++++++++++ .../xml2json/block-raw-reservations.xml | 14 ++++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 tests/qemublocktestdata/xml2json/block-raw-reservations.json create mode 100644 tests/qemublocktestdata/xml2json/block-raw-reservations.xml diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 09437cdb40..d1c2d756c2 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -998,6 +998,7 @@ qemuBlockStorageSourceGetFileProps(virStorageSourcePtr src) { const char *driver = "file"; const char *iomode = NULL; + const char *prManagerAlias = NULL; virJSONValuePtr ret = NULL; if (src->iomode != VIR_DOMAIN_DISK_IO_DEFAULT) @@ -1010,10 +1011,14 @@ qemuBlockStorageSourceGetFileProps(virStorageSourcePtr src) driver = "host_device"; } + if (src->pr) + prManagerAlias = src->pr->mgralias; + ignore_value(virJSONValueObjectCreate(&ret, "s:driver", driver, "s:filename", src->path, "S:aio", iomode, + "S:pr-manager", prManagerAlias, NULL) < 0); return ret; } diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index ec882b43e1..d0cd834b05 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -488,6 +488,7 @@ mymain(void) TEST_DISK_TO_JSON("dir-fat-cache"); TEST_DISK_TO_JSON("block-raw-noopts"); + TEST_DISK_TO_JSON("block-raw-reservations"); cleanup: virHashFree(diskxmljsondata.schema); diff --git a/tests/qemublocktestdata/xml2json/block-raw-reservations.json b/tests/qemublocktestdata/xml2json/block-raw-reservations.json new file mode 100644 index 0000000000..2fb106d673 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/block-raw-reservations.json @@ -0,0 +1,14 @@ +{ + "node-name": "node-a-fo", + "read-only": false, + "driver": "raw", + "file": "node-a-st" +} +{ + "driver": "host_device", + "filename": "/dev/blah", + "pr-manager": "node-a-st-pr-alias", + "node-name": "node-a-st", + "read-only": false, + "discard": "unmap" +} diff --git a/tests/qemublocktestdata/xml2json/block-raw-reservations.xml b/tests/qemublocktestdata/xml2json/block-raw-reservations.xml new file mode 100644 index 0000000000..3ebfe61186 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/block-raw-reservations.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + +