Provide uid/gid for additional volumes qemu:///session (#1170)

When using qemu:///session, it's necessary to ensure the correct
user/group is passed in when creating additional volume storage as
otherwise the default is to attempt to chown/chgrp it to 0:0 which will
fail.

With this in place and recent changes around uri/qemu_use_session,
remove the checks guarding retrieving the storage pool as it is also
possible for it to be created as expected for the session.

Update create domain tests to check for the correct settings such as
storage path and user/group id's passed to the volume create call for
the additional disks.

Fixes: #986
This commit is contained in:
Darragh Bailey
2020-12-05 15:49:25 +00:00
committed by GitHub
parent 21f7a796ff
commit f51192e80b
4 changed files with 133 additions and 41 deletions

View File

@@ -5,6 +5,7 @@ module VagrantPlugins
module Action
class CreateDomain
include VagrantPlugins::ProviderLibvirt::Util::ErbTemplate
include VagrantPlugins::ProviderLibvirt::Util::StorageUtil
def initialize(app, _env)
@logger = Log4r::Logger.new('vagrant_libvirt::action::create_domain')
@@ -147,12 +148,10 @@ module VagrantPlugins
# If we have a box, take the path from the domain volume and set our storage_prefix.
# If not, we dump the storage pool xml to get its defined path.
# the default storage prefix is typically: /var/lib/libvirt/images/
if !config.qemu_use_session
if env[:machine].config.vm.box
storage_prefix = File.dirname(@domain_volume_path) + '/' # steal
else
storage_prefix = get_disk_storage_prefix(env, @storage_pool_name)
end
if env[:machine].config.vm.box
storage_prefix = File.dirname(@domain_volume_path) + '/' # steal
else
storage_prefix = get_disk_storage_prefix(env, @storage_pool_name)
end
@disks.each do |disk|
@@ -184,6 +183,8 @@ module VagrantPlugins
format_type: disk[:type],
path: disk[:absolute_path],
capacity: disk[:size],
owner: storage_uid(env),
group: storage_uid(env),
#:allocation => ?,
pool_name: disk_pool_name
)