How to add RAW data to definition of block device?

Hello!
I’m just starting my adventure with opennebula (5.2.0).
I would like to add raw data to definition of block device. Now I’ve got such xml (used by libvirt):
< disk type=‘file’ device=‘disk’ >
< source file=’/var/lib/one//datastores/101/22/disk.0’/>
< target dev=‘vda’/>
< driver name=‘qemu’ type=‘qcow2’ cache=‘none’ io=‘native’ discard=‘unmap’/>
< /disk>

And I’d like to add:
< blockio logical_block_size=‘4096’ physical_block_size=‘4096’/>

There is RAW = [ …] but content of this is added to the < devices> level not to < disk>

Right now there is now way to add this data inside the disk. The only only solutions I can come up now are:

I think the second one is easier.

Hi,

I bet on the second one too. I’ve played with such tweaks so it was not hard to scratch simple helper script. It needs lxml python module. if there is no distribution package for your OS you should use pip to install it (pip install lxml).

The usage should be straight forward - just drop the script in /var/lib/one/remotes/vmm/kvm/, make it executable and alter the deploy script adding few lines between cat > $domain and data= like:

<...>
cat > $domain

# first take a backup ... 
cp $domain ${domain}.orig
# alter the domain XML
$(dirname $0)/vmTweakDiskBlockioBlockSize.py $domain

data=`virsh --connect $LIBVIRT_URI create $domain`
<...>

Then propagate the change to the hypervisors:

su - oneadmin -c "onehost sync --force"

I hope this helps. Feel free to alter the script in any shape if needed.

Kind Regards,
Anton Todorov

1 Like

Thank you for you advices. I’ll check it in new year.

Javi, Anton, I didn’t know about scripts in remotes/ .
Your script is great, Anton, it’s good template for doing any changes.
Finally I ended with

blockio.set(“logical_block_size”, str(512))
blockio.set(“physical_block_size”, str(4096))

because qemu (seabios) can’t boot from device with logical block size other than 512B:
https://www.coreboot.org/pipermail/seabios/2016-April/010596.html

Javi, Anton, I didn’t know about scripts in remotes/ .
Your script is great, Anton, it’s good template for doing any changes.
Finally I ended with

                                   if blockio == None:
                                            blockio = ET.Element("blockio")
                                    if target_dev[0:3] == 'vda':
                                            blockio.set("logical_block_size", str(512))
                                    else:
                                            blockio.set("logical_block_size", str(4096))
                                    blockio.set("physical_block_size", str(4096))
                                    disk.append(blockio)

because qemu (seabios) can’t boot from device with logical block size other than 512B:
https://www.coreboot.org/pipermail/seabios/2016-April/010596.html

I am happy to help :slight_smile:
Also, you can take a look in our storage addon for other scripts - to tweak nqueues on virtio-scsi and enable virtio-blk data plane :wink:

Kind Regards,
Anton Todorov