[virt-tools-list] [virt-manager PATCH 0/1] virtinst: Use sudo where root permission is needed

Andrew Wong andrew.kw.w at gmail.com
Sat Sep 9 15:25:00 UTC 2017


On 09/09/17 05:29 AM, Pavel Hrdina wrote:
> On Fri, Sep 08, 2017 at 11:49:47PM -0400, Andrew Wong wrote:
>> Hello,
>>
>> I have a small request that I hope is reasonable. For testing VMs, I like to
>> install VMs as non-root. However, if I want to install from a location that
>> requires mounting, then installing becomes a bit of a hassle. I'd have to
>> manually mount the location with sudo or root, then pass the mount point into
>> "--location".  It'd be nice of virt-install could elevated to root where
>> necessary. Basically, something like the attached patch.
> Hi, thanks for the patch.  This is interesting idea but I'm not sure
> whether it's a good idea.  You can easily run the whole virt-install
> command using sudo.
Running the whole virt-install command with sudo would create the entire 
domain as root, which is not always desirable. The domain has to be 
started/destroyed/undefined as root. The config has to be modified as 
root. The disk device image is created as root.

The closest alternative would be to:
     $ sudo mount -o loop,ro /path/to/iso /some/mountpoint
and add the flag to virtinst:
     --location /some/dir
However, this is still not as nice as "--location /path/to/iso". With 
only "--location /some/mountpoint", virtinst will only extract the 
kernel and inird from the directory. The iso image itself won't be 
available as a cdrom device during the install, which is needed if I 
want to install from a install CD image. So I'll need to add "--disk 
path=/path/to/iso,device=cdrom".

The nice thing about "--location /path/to/iso" is that virtinst would 
extract kernel and initrd, add the iso image as a cdrom device, and even 
unset the iso after install. That's why it's very tempting to just add 
sudo to mount/umount.

Perhaps another option would be to avoid using mount/umount for iso 
entirely, and use something like "isoinfo" to extract the kernel, 
initrd, and any other files. This would probably involve a lot more code 
changes, and require the "isoinfo" command to be available.




More information about the virt-tools-list mailing list