Skip to content

Instantly share code, notes, and snippets.

@jreidinger
Last active May 29, 2017 14:42
Show Gist options
  • Save jreidinger/b37ae595b3c3d8519453cd3c9fc0f198 to your computer and use it in GitHub Desktop.
Save jreidinger/b37ae595b3c3d8519453cd3c9fc0f198 to your computer and use it in GitHub Desktop.
Demonstration of hard to debug caching problem when device is from no longer valid device graph
<?xml version="1.0"?>
<Devicegraph>
<Devices>
<Disk>
<sid>42</sid>
<name>/dev/sda</name>
<sysfs-name>sda</sysfs-name>
<sysfs-path>/devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda</sysfs-path>
<region>
<length>16777216</length>
<block-size>512</block-size>
</region>
<udev-path>pci-0000:00:1f.2-ata-1.0</udev-path>
<udev-id>ata-VBOX_HARDDISK_VB3b96ac9d-f9f14bd2</udev-id>
<udev-id>scsi-0ATA_VBOX_HARDDISK_VB3b96ac9d-f9f14bd2</udev-id>
<udev-id>scsi-1ATA_VBOX_HARDDISK_VB3b96ac9d-f9f14bd2</udev-id>
<udev-id>scsi-SATA_VBOX_HARDDISK_VB3b96ac9d-f9f14bd2</udev-id>
<topology/>
<range>256</range>
<transport>SATA</transport>
</Disk>
</Devices>
</Devicegraph>
require "storage"
env = Storage::Environment.new(1, Storage::ProbeMode_READ_DEVICEGRAPH, Storage::TargetMode_DIRECT)
env.devicegraph_filename = "./disk-devicegraph.xml"
storage = Storage::Storage.new(env)
storage.probe
graph = storage.probed
disk = graph.all_disks.to_a.first
storage.probe # this cause invalidation of disk
disk.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment