]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
schema: Add missing block data for nodedev
authorJohn Ferlan <jferlan@redhat.com>
Sat, 19 May 2018 12:00:58 +0000 (08:00 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Fri, 25 May 2018 13:36:42 +0000 (09:36 -0400)
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>

docs/schemas/nodedev.rng
tests/nodedevschemadata/DVD_with_media.xml
tests/nodedevschemadata/storage_serial_3600c0ff000d7a2a5d463ff4902000000.xml
tests/nodedevschemadata/storage_serial_SATA_HTS721010G9SA00_MPCZ12Y0GNGWSE.xml
tests/nodedevxml2xmltest.c

index 6b063cc225e23b6a0aeebaafb97165116e9e2be1..0498489cfd8d5c5b0e82703d8811f7b2eee708f7 100644 (file)
           <text/>
         </element>
       </optional>
+      <ref name='blockData'/>
     </element>
   </define>
 
     <element name='size'>
       <ref name='unsignedLong'/>
     </element>
+    <ref name='blockData'/>
+  </define>
+
+  <define name='blockData'>
+    <optional>
+      <element name='logical_block_size'>
+        <ref name='unsignedLong'/>
+      </element>
+      <element name='num_blocks'>
+        <ref name='unsignedLong'/>
+      </element>
+    </optional>
   </define>
 
   <define name='capdrm'>
index 673e88fd0a6a514195475bda176d9784a5c7fcaa..f169885eb186c3c45c0f0e2f5209b5d6d405da57 100644 (file)
@@ -11,6 +11,8 @@
       <media_available>1</media_available>
       <media_size>12345678</media_size>
       <media_label>Windows_XP_Label</media_label>
+      <logical_block_size>2048</logical_block_size>
+      <num_blocks>6028</num_blocks>
     </capability>
   </capability>
 </device>
index d225dca8fa67d5c005c5e19fc549d6b598af6c85..5bdbb8ac95dbbeb321df3298b0b96d10f3353b9d 100644 (file)
@@ -13,5 +13,7 @@
     <vendor>HP</vendor>
     <serial>3600c0ff000d7a2a5d463ff4902000000</serial>
     <size>15626928128</size>
+    <logical_block_size>512</logical_block_size>
+    <num_blocks>30521344</num_blocks>
   </capability>
 </device>
index 3595a0baaabcc051010ac416063971542f3a0190..68dbf0be96e785c1092106b06a1eac60442b3425 100644 (file)
@@ -8,5 +8,7 @@
     <model>HTS721010G9SA00</model>
     <vendor>ATA</vendor>
     <size>100030242816</size>
+    <logical_block_size>512</logical_block_size>
+    <num_blocks>195371568</num_blocks>
   </capability>
 </device>
index 41ed5c01c24182ab21fcd3c77c163ff8b74ca642..207d97483e8dce86638d62b57adbcd1dff0badfb 100644 (file)
@@ -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;