You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by Wido den Hollander <wi...@widodh.nl> on 2012/04/21 13:50:07 UTC

Using libguestfs for modifying (System) VM's

Hi,

I'm not a big fan of all the bash scripts which are being called on KVM 
system for deploying the System VM's.

They try to mount the guest, inject data (like SSH keys) and then 
continue the boot process of the guest.

It's something I don't like and I think libguestfs [0] can help here.

With guestfish [1] you can access the VM and modify its filesystem:

guestfish <<_EOF_
  add disk.img
  run
  mount /dev/vda1 /
  write-append /root/.ssh/authorized_keys "ssh-rsa XXXXXX...."
  _EOF_

Imho this would be a much cleaner way to modify the System VM's without 
having to set up loop devices, mount them, etc, etc.

The nice thing with libguestfs is that you can access the VM's while 
they are running (use with caution!), so that gives you much more 
flexibility!

There is a native C API, but there also seem to be Java bindings [2], so 
that could make it much cleaner to integrate into CloudStack.

libguestfs also seems to be present in Fedora [3] and in RHEL 6, so that 
shouldn't be a problem.

Searching the web showed me some reports of libguestfs and CloudStack, 
but browsing the code I found no reference to this.

Something worth looking at I think?

Wido

[0]: http://libguestfs.org/
[1]: http://libguestfs.org/guestfish.1.html
[2]: http://libguestfs.org/guestfs-java.3.html
[3]: https://fedoraproject.org/wiki/Features/libguestfs

Re: Using libguestfs for modifying (System) VM's

Posted by Wido den Hollander <wi...@widodh.nl>.
Hi,

On 04/21/2012 10:13 PM, Chiradeep Vittal wrote:
> Dunno..last time I checked, Ubuntu 10.04 did not have an "out-of-the-box"
> guestfish.
>
> Has this changed?

No, it hasn't.

The new Ubuntu LTS 12.04 is coming out in a couple of days though and 
that will ship with guestfish [0].

I don't have the time right now to work on this, but in a later stadium 
I think it would be a nice project. With the clean Java bindings for 
libguestfs we could get rid of a lot of nasty BASH scripts and make this 
code much more reliable.

This would also pave the road for running System VM's from RBD, which I 
don't see happening with the current BASH scripts.

Wido

[0]: http://packages.ubuntu.com/precise/guestfish
>
> On 4/21/12 12:52 PM, "David Nalley"<da...@gnsa.us>  wrote:
>
>> On Sat, Apr 21, 2012 at 7:50 AM, Wido den Hollander<wi...@widodh.nl>
>> wrote:
>>> Hi,
>>>
>>> I'm not a big fan of all the bash scripts which are being called on KVM
>>> system for deploying the System VM's.
>>>
>>> They try to mount the guest, inject data (like SSH keys) and then
>>> continue
>>> the boot process of the guest.
>>>
>>> It's something I don't like and I think libguestfs [0] can help here.
>>>
>>> With guestfish [1] you can access the VM and modify its filesystem:
>>>
>>> guestfish<<_EOF_
>>>   add disk.img
>>>   run
>>>   mount /dev/vda1 /
>>>   write-append /root/.ssh/authorized_keys "ssh-rsa XXXXXX...."
>>>   _EOF_
>>>
>>> Imho this would be a much cleaner way to modify the System VM's without
>>> having to set up loop devices, mount them, etc, etc.
>>>
>>> The nice thing with libguestfs is that you can access the VM's while
>>> they
>>> are running (use with caution!), so that gives you much more
>>> flexibility!
>>>
>>> There is a native C API, but there also seem to be Java bindings [2], so
>>> that could make it much cleaner to integrate into CloudStack.
>>>
>>> libguestfs also seems to be present in Fedora [3] and in RHEL 6, so that
>>> shouldn't be a problem.
>>>
>>> Searching the web showed me some reports of libguestfs and CloudStack,
>>> but
>>> browsing the code I found no reference to this.
>>>
>>> Something worth looking at I think?
>>>
>>> Wido
>>>
>>> [0]: http://libguestfs.org/
>>> [1]: http://libguestfs.org/guestfish.1.html
>>> [2]: http://libguestfs.org/guestfs-java.3.html
>>> [3]: https://fedoraproject.org/wiki/Features/libguestfs
>>
>> Yes please - guestfish would likely make this far more efficient all
>> the way around.
>>
>> --David (whose opinion doesn't matter much because I don't maintain
>> the systemvms :) )
>

Re: Using libguestfs for modifying (System) VM's

Posted by Chiradeep Vittal <Ch...@citrix.com>.
Dunno..last time I checked, Ubuntu 10.04 did not have an "out-of-the-box"
guestfish. 

Has this changed?

On 4/21/12 12:52 PM, "David Nalley" <da...@gnsa.us> wrote:

>On Sat, Apr 21, 2012 at 7:50 AM, Wido den Hollander <wi...@widodh.nl>
>wrote:
>> Hi,
>>
>> I'm not a big fan of all the bash scripts which are being called on KVM
>> system for deploying the System VM's.
>>
>> They try to mount the guest, inject data (like SSH keys) and then
>>continue
>> the boot process of the guest.
>>
>> It's something I don't like and I think libguestfs [0] can help here.
>>
>> With guestfish [1] you can access the VM and modify its filesystem:
>>
>> guestfish <<_EOF_
>>  add disk.img
>>  run
>>  mount /dev/vda1 /
>>  write-append /root/.ssh/authorized_keys "ssh-rsa XXXXXX...."
>>  _EOF_
>>
>> Imho this would be a much cleaner way to modify the System VM's without
>> having to set up loop devices, mount them, etc, etc.
>>
>> The nice thing with libguestfs is that you can access the VM's while
>>they
>> are running (use with caution!), so that gives you much more
>>flexibility!
>>
>> There is a native C API, but there also seem to be Java bindings [2], so
>> that could make it much cleaner to integrate into CloudStack.
>>
>> libguestfs also seems to be present in Fedora [3] and in RHEL 6, so that
>> shouldn't be a problem.
>>
>> Searching the web showed me some reports of libguestfs and CloudStack,
>>but
>> browsing the code I found no reference to this.
>>
>> Something worth looking at I think?
>>
>> Wido
>>
>> [0]: http://libguestfs.org/
>> [1]: http://libguestfs.org/guestfish.1.html
>> [2]: http://libguestfs.org/guestfs-java.3.html
>> [3]: https://fedoraproject.org/wiki/Features/libguestfs
>
>Yes please - guestfish would likely make this far more efficient all
>the way around.
>
>--David (whose opinion doesn't matter much because I don't maintain
>the systemvms :) )


Re: Using libguestfs for modifying (System) VM's

Posted by David Nalley <da...@gnsa.us>.
On Sat, Apr 21, 2012 at 7:50 AM, Wido den Hollander <wi...@widodh.nl> wrote:
> Hi,
>
> I'm not a big fan of all the bash scripts which are being called on KVM
> system for deploying the System VM's.
>
> They try to mount the guest, inject data (like SSH keys) and then continue
> the boot process of the guest.
>
> It's something I don't like and I think libguestfs [0] can help here.
>
> With guestfish [1] you can access the VM and modify its filesystem:
>
> guestfish <<_EOF_
>  add disk.img
>  run
>  mount /dev/vda1 /
>  write-append /root/.ssh/authorized_keys "ssh-rsa XXXXXX...."
>  _EOF_
>
> Imho this would be a much cleaner way to modify the System VM's without
> having to set up loop devices, mount them, etc, etc.
>
> The nice thing with libguestfs is that you can access the VM's while they
> are running (use with caution!), so that gives you much more flexibility!
>
> There is a native C API, but there also seem to be Java bindings [2], so
> that could make it much cleaner to integrate into CloudStack.
>
> libguestfs also seems to be present in Fedora [3] and in RHEL 6, so that
> shouldn't be a problem.
>
> Searching the web showed me some reports of libguestfs and CloudStack, but
> browsing the code I found no reference to this.
>
> Something worth looking at I think?
>
> Wido
>
> [0]: http://libguestfs.org/
> [1]: http://libguestfs.org/guestfish.1.html
> [2]: http://libguestfs.org/guestfs-java.3.html
> [3]: https://fedoraproject.org/wiki/Features/libguestfs

Yes please - guestfish would likely make this far more efficient all
the way around.

--David (whose opinion doesn't matter much because I don't maintain
the systemvms :) )