Package: vagrant-libvirt
Version: 0.9.0-1
Severity: normal
Tags: patch

Dear Maintainer,

Since libvirt 8.4.0 (or possibly earlier) the allow_existing option for disks 
has been broken in in vagrant-libvirt. The reason is that libvirt gives a 
slightly different error message when adding a disk that already exists than 
what vagrant-libvirt expects, leading to failure.

The attached patch fixes this, and is in fact already merged upstream, but not 
released yet. Would you mind applying it to the Debian package?

Cheers!
From 1ed088924a1560375c353f91f79f4c1cd02de92d Mon Sep 17 00:00:00 2001
From: anonym <ano...@riseup.net>
Date: Wed, 8 Jun 2022 18:21:35 +0000
Subject: [PATCH] Fix allow_existing for disks against newer versions of
 libvirt. (#1507)

When running vagrant-libvirt on an up-to-date Debian unstable with
libvirt 8.4.0 the expected error message doesn't contain the full
path any more.
---
 lib/vagrant-libvirt/action/create_domain.rb | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/vagrant-libvirt/action/create_domain.rb b/lib/vagrant-libvirt/action/create_domain.rb
index 7899424..9da82d3 100644
--- a/lib/vagrant-libvirt/action/create_domain.rb
+++ b/lib/vagrant-libvirt/action/create_domain.rb
@@ -151,9 +151,11 @@ module VagrantPlugins
             rescue Libvirt::Error => e
               # It is hard to believe that e contains just a string
               # and no useful error code!
-              msg = "Call to virStorageVolCreateXML failed: " +
-                    "storage volume '#{disk[:absolute_path]}' exists already"
-              if e.message == msg and disk[:allow_existing]
+              msgs = [disk[:name], disk[:absolute_path]].map do |name|
+                "Call to virStorageVolCreateXML failed: " +
+                "storage volume '#{name}' exists already"
+              end
+              if msgs.include?(e.message) and disk[:allow_existing]
                 disk[:preexisting] = true
               else
                 raise Errors::FogCreateDomainVolumeError,
-- 
2.36.1

Reply via email to