virNodeDeviceCapStorageDefFormatBlocksize: Report sector size and count together

Report both block count and size together when either one of them is
present equivalently to what the schema type 'blockData' in
'schemas/nodedev.rng' defines.

Resolves: https://issues.redhat.com/browse/RHEL-18165
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2023-12-07 13:01:34 +01:00
parent 9f855b149a
commit 06e344f762

View File

@ -540,11 +540,12 @@ static void
virNodeDeviceCapStorageDefFormatBlocksize(virBuffer *buf,
const virNodeDevCapData *data)
{
if (data->storage.logical_block_size > 0)
if (data->storage.logical_block_size == 0 &&
data->storage.num_blocks == 0)
return;
virBufferAsprintf(buf, "<logical_block_size>%llu</logical_block_size>\n",
data->storage.logical_block_size);
if (data->storage.num_blocks > 0)
virBufferAsprintf(buf, "<num_blocks>%llu</num_blocks>\n",
data->storage.num_blocks);
}