[PATCH v8 3/3] qemu: Implement rbd namespace to the source name attribute

Peter Krempa pkrempa at redhat.com
Mon Jun 7 14:53:34 UTC 2021


On Wed, May 26, 2021 at 21:35:12 +0800, Han Han wrote:
> Since Nautilus ceph supports separate image namespaces within a pool for
> tenant isolation and QEMU adds it as a rbd blockdev options from 5.0.0.
> The source name with format "<pool>/<namespace>/<image>" could be used to
> access a rbd image with namespace.
> 
> Add unit tests for this attribute.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1816909
> 
> Signed-off-by: Han Han <hhan at redhat.com>
> ---
>  src/qemu/qemu_block.c                         |  1 +
>  src/qemu/qemu_domain.c                        |  8 +++
>  ...k-network-rbd-namespace.x86_64-latest.args | 38 ++++++++++++++
>  .../disk-network-rbd-namespace.xml            | 40 +++++++++++++++
>  tests/qemuxml2argvtest.c                      |  1 +
>  ...sk-network-rbd-namespace.x86_64-latest.xml | 50 +++++++++++++++++++
>  tests/qemuxml2xmltest.c                       |  1 +
>  7 files changed, 139 insertions(+)
>  create mode 100644 tests/qemuxml2argvdata/disk-network-rbd-namespace.x86_64-latest.args
>  create mode 100644 tests/qemuxml2argvdata/disk-network-rbd-namespace.xml
>  create mode 100644 tests/qemuxml2xmloutdata/disk-network-rbd-namespace.x86_64-latest.xml


> diff --git a/tests/qemuxml2argvdata/disk-network-rbd-namespace.x86_64-latest.args b/tests/qemuxml2argvdata/disk-network-rbd-namespace.x86_64-latest.args
> new file mode 100644
> index 0000000000..f89773e3e1
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/disk-network-rbd-namespace.x86_64-latest.args
> @@ -0,0 +1,38 @@
> +LC_ALL=C \
> +PATH=/bin \
> +HOME=/tmp/lib/domain--1-QEMUGuest1 \
> +USER=test \
> +LOGNAME=test \
> +XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
> +XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
> +XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
> +/usr/bin/qemu-system-x86_64 \
> +-name guest=QEMUGuest1,debug-threads=on \
> +-S \
> +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest1/master-key.aes"}' \
> +-machine pc,accel=tcg,usb=off,dump-guest-core=off,memory-backend=pc.ram \
> +-cpu qemu64 \
> +-m 214 \
> +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \
> +-overcommit mem-lock=off \
> +-smp 1,sockets=1,cores=1,threads=1 \
> +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
> +-display none \
> +-no-user-config \
> +-nodefaults \
> +-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
> +-mon chardev=charmonitor,id=monitor,mode=control \
> +-rtc base=utc \
> +-no-shutdown \
> +-no-acpi \
> +-boot strict=on \
> +-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
> +-blockdev '{"driver":"rbd","pool":"pool","image":"image","namespace":"ns","server":[{"host":"mon1.example.org","port":"6321"},{"host":"mon2.example.org","port":"6322"},{"host":"mon3.example.org","port":"6322"}],"node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \
> +-blockdev '{"node-name":"libvirt-2-format","read-only":false,"driver":"raw","file":"libvirt-2-storage"}' \
> +-device virtio-blk-pci,bus=pci.0,addr=0x2,drive=libvirt-2-format,id=virtio-disk0,bootindex=1 \
> +-blockdev '{"driver":"rbd","pool":"pool","image":"image","server":[{"host":"mon1.example.org","port":"6321"}],"node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \



> diff --git a/tests/qemuxml2argvdata/disk-network-rbd-namespace.xml b/tests/qemuxml2argvdata/disk-network-rbd-namespace.xml
> new file mode 100644
> index 0000000000..5389cbda2f
> --- /dev/null
> +++ b/tests/qemuxml2argvdata/disk-network-rbd-namespace.xml
> @@ -0,0 +1,40 @@

So, prior to patch 2/3 in this series ...

> +    <disk type='network' device='disk'>
> +      <driver name='qemu' type='raw'/>
> +      <source protocol='rbd' name='pool/ns/image'>

what would this refer to when used with qemu?

this woudl become:

"pool": "pool",
"image": "ns/image"

> +        <host name='mon1.example.org' port='6321'/>
> +        <host name='mon2.example.org' port='6322'/>
> +        <host name='mon3.example.org' port='6322'/>
> +      </source>
> +      <target dev='vda' bus='virtio'/>
> +    </disk>
> +    <disk type='network' device='disk'>
> +      <driver name='qemu' type='raw'/>
> +      <source protocol='rbd' name='pool//image'>

and this:

"pool": "pool",
"image": "/image"

Are those valid names in RBD? if yes, this will most probably cause
a regression.


> +        <host name='mon1.example.org' port='6321'/>
> +      </source>
> +      <target dev='vdb' bus='virtio'/>
> +    </disk>
> +    <controller type='usb' index='0'/>
> +    <controller type='ide' index='0'/>
> +    <controller type='pci' index='0' model='pci-root'/>
> +    <input type='mouse' bus='ps2'/>
> +    <input type='keyboard' bus='ps2'/>
> +    <memballoon model='none'/>
> +  </devices>
> +</domain>



> diff --git a/tests/qemuxml2xmloutdata/disk-network-rbd-namespace.x86_64-latest.xml b/tests/qemuxml2xmloutdata/disk-network-rbd-namespace.x86_64-latest.xml
> new file mode 100644
> index 0000000000..710938e9ee
> --- /dev/null
> +++ b/tests/qemuxml2xmloutdata/disk-network-rbd-namespace.x86_64-latest.xml
> @@ -0,0 +1,50 @@
> +<domain type='qemu'>
> +  <name>QEMUGuest1</name>
> +  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
> +  <memory unit='KiB'>219136</memory>
> +  <currentMemory unit='KiB'>219136</currentMemory>
> +  <vcpu placement='static'>1</vcpu>
> +  <os>
> +    <type arch='x86_64' machine='pc'>hvm</type>
> +    <boot dev='hd'/>
> +  </os>
> +  <cpu mode='custom' match='exact' check='none'>
> +    <model fallback='forbid'>qemu64</model>
> +  </cpu>
> +  <clock offset='utc'/>
> +  <on_poweroff>destroy</on_poweroff>
> +  <on_reboot>restart</on_reboot>
> +  <on_crash>destroy</on_crash>
> +  <devices>
> +    <emulator>/usr/bin/qemu-system-x86_64</emulator>
> +    <disk type='network' device='disk'>
> +      <driver name='qemu' type='raw'/>
> +      <source protocol='rbd' name='pool/ns/image'>
> +        <host name='mon1.example.org' port='6321'/>
> +        <host name='mon2.example.org' port='6322'/>
> +        <host name='mon3.example.org' port='6322'/>
> +      </source>
> +      <target dev='vda' bus='virtio'/>
> +      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
> +    </disk>
> +    <disk type='network' device='disk'>
> +      <driver name='qemu' type='raw'/>
> +      <source protocol='rbd' name='pool/image'>

This removed the extra '/', but it depends on the semantics of the
previously existing code whether that's okay or not.

> +        <host name='mon1.example.org' port='6321'/>
> +      </source>
> +      <target dev='vdb' bus='virtio'/>
> +      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
> +    </disk>



> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
> index dd039bd846..0f115df8ad 100644
> --- a/tests/qemuxml2xmltest.c
> +++ b/tests/qemuxml2xmltest.c
> @@ -317,6 +317,7 @@ mymain(void)
>              QEMU_CAPS_SCSI_BLOCK);
>      DO_TEST("disk-network-gluster", NONE);
>      DO_TEST("disk-network-rbd", NONE);
> +    DO_TEST_CAPS_ARCH_LATEST("disk-network-rbd-namespace", "x86_64");

DO_TEST_CAPS_LATEST is enough for x86_64

>      DO_TEST("disk-network-source-auth", NONE);
>      DO_TEST("disk-network-sheepdog", NONE);
>      DO_TEST("disk-network-vxhs", NONE);
> -- 
> 2.31.1
> 




More information about the libvir-list mailing list