[libvirt] [PATCH 0/2] qemu: block: Add more tests and support for pr-manager

Note that patch 1 can be applied only with the series adding TLS support for NBD. Patch 2 is independent. Peter Krempa (2): tests: qemublock: Test NBD with TLS qemu: block: Add support for 'pr-manager' in qemuBlockStorageSourceGetFileProps src/qemu/qemu_block.c | 5 +++++ tests/qemublocktest.c | 2 ++ .../xml2json/block-raw-reservations.json | 14 ++++++++++++++ .../xml2json/block-raw-reservations.xml | 14 ++++++++++++++ .../qemublocktestdata/xml2json/network-nbd-tls.json | 20 ++++++++++++++++++++ tests/qemublocktestdata/xml2json/network-nbd-tls.xml | 18 ++++++++++++++++++ 6 files changed, 73 insertions(+) create mode 100644 tests/qemublocktestdata/xml2json/block-raw-reservations.json create mode 100644 tests/qemublocktestdata/xml2json/block-raw-reservations.xml create mode 100644 tests/qemublocktestdata/xml2json/network-nbd-tls.json create mode 100644 tests/qemublocktestdata/xml2json/network-nbd-tls.xml -- 2.16.2

Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/qemublocktest.c | 1 + .../qemublocktestdata/xml2json/network-nbd-tls.json | 20 ++++++++++++++++++++ tests/qemublocktestdata/xml2json/network-nbd-tls.xml | 18 ++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 tests/qemublocktestdata/xml2json/network-nbd-tls.json create mode 100644 tests/qemublocktestdata/xml2json/network-nbd-tls.xml diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c index ec882b43e1..8494c9e48a 100644 --- a/tests/qemublocktest.c +++ b/tests/qemublocktest.c @@ -486,6 +486,7 @@ mymain(void) TEST_DISK_TO_JSON("file-backing_basic-cache-unsafe"); TEST_DISK_TO_JSON("network-qcow2-backing-chain-cache-unsafe"); TEST_DISK_TO_JSON("dir-fat-cache"); + TEST_DISK_TO_JSON("network-nbd-tls"); TEST_DISK_TO_JSON("block-raw-noopts"); diff --git a/tests/qemublocktestdata/xml2json/network-nbd-tls.json b/tests/qemublocktestdata/xml2json/network-nbd-tls.json new file mode 100644 index 0000000000..e68f421874 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/network-nbd-tls.json @@ -0,0 +1,20 @@ +{ + "node-name": "node-b-f", + "read-only": false, + "driver": "qcow2", + "file": "node-a-s", + "backing": null +} +{ + "driver": "nbd", + "server": { + "type": "inet", + "host": "host1.example.com", + "port": "10809" + }, + "export": "rbdpool/rbdimg", + "tls-creds": "node-a-s-tls0", + "node-name": "node-a-s", + "read-only": false, + "discard": "unmap" +} diff --git a/tests/qemublocktestdata/xml2json/network-nbd-tls.xml b/tests/qemublocktestdata/xml2json/network-nbd-tls.xml new file mode 100644 index 0000000000..40102327e2 --- /dev/null +++ b/tests/qemublocktestdata/xml2json/network-nbd-tls.xml @@ -0,0 +1,18 @@ +<disk type='network' device='disk'> + <driver name='qemu' type='qcow2'/> + <source protocol='nbd' name='rbdpool/rbdimg' tls='yes'> + <host name='host1.example.com'/> + <privateData> + <nodenames> + <nodename type='storage' name='node-a-s'/> + <nodename type='format' name='node-b-f'/> + </nodenames> + <objects> + <tlsX509 alias='node-a-s-tls0'/> + </objects> + </privateData> + </source> + <backingStore/> + <target dev='vda' bus='virtio'/> + <alias name='virtio-disk0'/> +</disk> -- 2.16.2

On Wed, May 30, 2018 at 03:56:21PM +0200, Peter Krempa wrote:
Signed-off-by: Peter Krempa <pkrempa@redhat.com> --- tests/qemublocktest.c | 1 + .../qemublocktestdata/xml2json/network-nbd-tls.json | 20 ++++++++++++++++++++ tests/qemublocktestdata/xml2json/network-nbd-tls.xml | 18 ++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 tests/qemublocktestdata/xml2json/network-nbd-tls.json create mode 100644 tests/qemublocktestdata/xml2json/network-nbd-tls.xml
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

To keep feature parity, we need to be able to format the PR manager alias when using blockdev. Signed-off-by: Peter Krempa <pkrempa@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

On Wed, May 30, 2018 at 03:56:22PM +0200, Peter Krempa wrote:
To keep feature parity, we need to be able to format the PR manager alias when using blockdev.
Signed-off-by: Peter Krempa <pkrempa@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
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano
participants (2)
-
Ján Tomko
-
Peter Krempa