To keep feature parity, we need to be able to format the PR manager
alias when using blockdev.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_block.c | 5 +++++
tests/qemublocktest.c | 1 +
.../qemublocktestdata/xml2json/block-raw-reservations.json | 14 ++++++++++++++
.../qemublocktestdata/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 8494c9e48a..0c335abc5b 100644
--- a/tests/qemublocktest.c
+++ b/tests/qemublocktest.c
@@ -489,6 +489,7 @@ mymain(void)
TEST_DISK_TO_JSON("network-nbd-tls");
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 @@
+<disk device='disk' type='block'>
+ <driver name='qemu' type='raw'/>
+ <source dev='/dev/blah'>
+ <reservations enabled='yes' managed='yes'/>
+ <privateData>
+ <nodenames>
+ <nodename type='storage' name='node-a-st'/>
+ <nodename type='format' name='node-a-fo'/>
+ </nodenames>
+ <reservations mgralias='node-a-st-pr-alias'/>
+ </privateData>
+ </source>
+ <target dev='vda'/>
+</disk>
--
2.16.2