From d840ce3eb3f3709787eee948147d726f21b549b3 Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Wed, 26 Aug 2015 16:04:30 +0200 Subject: [PATCH] feature #3782: fix monitoring of persistent images --- src/vmm/LibVirtDriverKVM.cc | 9 +++++++++ src/vmm_mad/remotes/poll_xen_kvm.rb | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/vmm/LibVirtDriverKVM.cc b/src/vmm/LibVirtDriverKVM.cc index 5d9ac9cb57..b79ce8b5bf 100644 --- a/src/vmm/LibVirtDriverKVM.cc +++ b/src/vmm/LibVirtDriverKVM.cc @@ -1118,6 +1118,15 @@ int LibVirtDriver::deployment_description_kvm( file << "\t" << default_raw << endl; } + // ------------------------------------------------------------------------ + // Metadata used by drivers + // ------------------------------------------------------------------------ + + file << "\t" << endl; + file << "\t\t" << vm->get_remote_system_dir() << + "" << endl; + file << "\t" << endl; + file << "" << endl; file.close(); diff --git a/src/vmm_mad/remotes/poll_xen_kvm.rb b/src/vmm_mad/remotes/poll_xen_kvm.rb index 9435ce0edf..881309f5ec 100755 --- a/src/vmm_mad/remotes/poll_xen_kvm.rb +++ b/src/vmm_mad/remotes/poll_xen_kvm.rb @@ -318,6 +318,8 @@ module KVM doc = REXML::Document.new(xml) size = 0 + systemds = doc.elements['domain/metadata/system_datastore'] rescue nil + systemds = systemds.text.gsub(/\/+/, '/') if systemds data = { :disk_size => [], @@ -358,6 +360,24 @@ module KVM end else + # Search the disk in system datastore when the source + # is a persistent image with snapshots + if !file.match(/.*disk\.\d+$/) && systemds + source = file.gsub(%r{/+}, '/') + + disks = Dir["#{systemds}/disk.*"] + + disks.each do |disk| + next if !File.symlink?(disk) + link = File.readlink(disk).gsub(%r{/+}, '/') + + if link == source + file = disk + break + end + end + end + # Regular Disk text = `qemu-img info --output=json #{file}` next if !$? || !$?.success?