diff options
author | John Ferlan <jferlan@redhat.com> | 2018-05-19 08:00:58 -0400 |
---|---|---|
committer | John Ferlan <jferlan@redhat.com> | 2018-05-25 09:36:42 -0400 |
commit | 4804a4db33a37f828d033733bc47f6eff5d262c3 (patch) | |
tree | bbd57efb01df76925466a68b24e1a7de8a91f9f3 /tests/nodedevxml2xmltest.c | |
parent | c1a0601debfe2c84160234cf6269606f4198faa0 (diff) | |
download | libvirt-4804a4db33a37f828d033733bc47f6eff5d262c3.tar.gz |
schema: Add missing block data for nodedev
https://bugzilla.redhat.com/show_bug.cgi?id=1566416
Commit id 'fe2af45b' added output for logical_block_size and
num_blocks for both removeable and fixed storage, but did not
update the nodedev capability causing virt-xml-validate to fail.
It's listed as optional only because it only prints if the
sizes are > 0. For a CDROM drive the values won't be formatted.
Update the nodedevxml2xmltest in order to output the values
for storage based on the logic from udevProcessRemoveableMedia
and udevProcessSD with respect to the logical_blocksize and
num_blocks calculations.
Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by Michal Privoznik <mprivozn@redhat.com>
Diffstat (limited to 'tests/nodedevxml2xmltest.c')
-rw-r--r-- | tests/nodedevxml2xmltest.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c index 41ed5c01c2..207d97483e 100644 --- a/tests/nodedevxml2xmltest.c +++ b/tests/nodedevxml2xmltest.c @@ -23,6 +23,7 @@ testCompareXMLToXMLFiles(const char *xml) char *actual = NULL; int ret = -1; virNodeDeviceDefPtr dev = NULL; + virNodeDevCapsDefPtr caps; if (virTestLoadFile(xml, &xmlData) < 0) goto fail; @@ -30,6 +31,27 @@ testCompareXMLToXMLFiles(const char *xml) if (!(dev = virNodeDeviceDefParseString(xmlData, EXISTING_DEVICE, NULL))) goto fail; + /* Calculate some things that are not read in */ + for (caps = dev->caps; caps; caps = caps->next) { + virNodeDevCapDataPtr data = &caps->data; + + if (caps->data.type == VIR_NODE_DEV_CAP_STORAGE) { + if (data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_REMOVABLE) { + if (data->storage.flags & + VIR_NODE_DEV_CAP_STORAGE_REMOVABLE_MEDIA_AVAILABLE) { + data->storage.logical_block_size = 2048; + data->storage.num_blocks = + data->storage.removable_media_size / + data->storage.logical_block_size; + } + } else { + data->storage.logical_block_size = 512; + data->storage.num_blocks = data->storage.size / + data->storage.logical_block_size; + } + } + } + if (!(actual = virNodeDeviceDefFormat(dev))) goto fail; |