librelist archives

« back to archive

Disk Handler

Disk Handler

From:
yeswanth swami
Date:
2011-06-13 @ 17:03
Hi,

This post is regarding Virtual Hard Disk management.

My problem :

1) How do i create a .vdi image using libvirt
2) How do i partition the image
3) How do i mount the image onto host

Search findings (corresponding to the numbers in "My problem"):

1) cant create a disk image using libvirt. We have to use qemu-img to create
 qcow2 or other formats .We have to use VBoxManage to create .vdi
2) , 3) Use external tools .

My proposed solution :

1)VBoxManage
2) , 3) libguestfs

Libguestfs:

I would like to introduce a library here libguestfs[1] . This library
facilities accessing and modifying VM disk images. We can also mount it on
the host system. This library takes help from  libvirt for some of its
functionalities. I should also mention here that it uses Linux kernel code
and qemu code  but supports a lot of file systems(vdi,qemu,vmdk, cd dvd
iso,sd card,etc). That means this library can be used only with a linux host
. Guest can be of any platform.

I have tried to use some functionality of libguestfs  in PyTI [2]

What do you think ?
Should I carry on with libguestfs for the disk management ? Also VBoxManage
to create a .vdi image ? (With libguestfs I cant create a .vdi image, though
i can partition/manage it )

[1]http://libguestfs.org/
[2]https://bitbucket.org/swamiyeswanth/pyti/src/2b3a7401eccf/diskhandler.py


-- 
Cheers,
Yeswanth

Re: [pyti] Disk Handler

From:
Pierre-Yves David
Date:
2011-06-13 @ 23:10
It's a very good idea to communication that fast about your ginding and issue

Here is a quick response before going to bed.

On Mon, Jun 13, 2011 at 10:33:45PM +0530, yeswanth swami wrote:

> My problem :
> 
> 1) How do i create a .vdi image using libvirt
> 2) How do i partition the image

Why do you want to partition the image ?

> 3) How do i mount the image onto host
> 
> Search findings (corresponding to the numbers in "My problem"):
> 
> 1) cant create a disk image using libvirt. We have to use qemu-img to create
>  qcow2 or other formats .We have to use VBoxManage to create .vdi
> 2) , 3) Use external tools .

Did you had a look at Fuse based solution ?

I'm not really suprised useful tool for automatic handling of VM are only
available for Linux.

> -- 
> Cheers,
> Yeswanth

Re: [pyti] Disk Handler

From:
Alexis Métaireau
Date:
2011-06-14 @ 09:00
On 06/14/2011 01:10 AM, Pierre-Yves David wrote:
> It's a very good idea to communication that fast about your finding and issue

+1, this helps us a lot to follow your reasoning.

> My problem :
>
> 1) How do i create a .vdi image using libvirt

Is the image creation a recurring problem? IOW, do we need such image 
creation on a regular basis or is it something we just want once, at the 
beginning of the process (the first time we install the guest OS). In 
the last case, we can rely on external tools / manual procedures if it 
simplify the process.

> 2) How do i partition the image

Same question than P-Y: why partitioning this image ?

> 3) How do i mount the image onto host

I'm not sure to get which image are we talking about. It seems we have 
two images to consider (a) the operating system image and (b) the 
input/output disk.

Then, we have two steps to go through for each (a) and (b): mounting the 
virtual device to the virtual machine (the equivalent of the hardware 
action to plug an hard disk to a machine) and accessing this hardware 
from the operating system (which we do using "mount" on linux systems).

The first step (disk plug) have to be done by the host whereas the 
second one (mount) have to be done from the VM. I though it was possible 
to plug harddisk (a) directly using libvirt, Am I mistaken?

Mounting the virtual device (b) can probably be done directly from the 
OS. On linux, you will have to add lines into /etc/fstab.

In all those cases, I don't see the point of using an external tool like 
libguestfs in place of directly doing so in the OS. I am a bit confused 
so please tell me if I'm missing your point.

See you at the meeting in a few hours.
-- 
Alexis

Re: [pyti] Disk Handler

From:
yeswanth swami
Date:
2011-06-14 @ 11:56
2011/6/14 Alexis Métaireau <alexis@notmyidea.org>

> On 06/14/2011 01:10 AM, Pierre-Yves David wrote:
> > It's a very good idea to communication that fast about your finding and
> issue
>
> +1, this helps us a lot to follow your reasoning.
>
> > My problem :
> >
> > 1) How do i create a .vdi image using libvirt
>
> Is the image creation a recurring problem? IOW, do we need such image
> creation on a regular basis or is it something we just want once, at the
> beginning of the process (the first time we install the guest OS). In
> the last case, we can rely on external tools / manual procedures if it
> simplify the process.
>
> I thought of it this way:

 When ever a distribution needs to be tested, slave downloads it. It creates
a new virtual hard disk( possibly .vdi format) and upload the packages to
the disk .
(or)
We can use the same virtual disk after formatting it possibly (not sure
formatting is necessary) and we can upload the distributions and
configuration into it.

Second solution sounds easier and probably we can go for it. We can use
external tools for the one time image creation.


> > 2) How do i partition the image
>
> Same question than P-Y: why partitioning this image ?
>
We would atleast need have to write a MBR into the disk and create a
filesystem. Ofcourse this can be done when an OS is being installed on to
the disk image.
This may not be a issue then.


>
> > 3) How do i mount the image onto host
>
> I'm not sure to get which image are we talking about. It seems we have
> two images to consider (a) the operating system image and (b) the
> input/output disk.
>
> I am talking about image as "Virtual Hard disk image" all through the post.
i.e option (a)


> Then, we have two steps to go through for each (a) and (b): mounting the
> virtual device to the virtual machine (the equivalent of the hardware
> action to plug an hard disk to a machine) and accessing this hardware
> from the operating system (which we do using "mount" on linux systems).
>
> The first step (disk plug) have to be done by the host whereas the
> second one (mount) have to be done from the VM. I though it was possible
> to plug harddisk (a) directly using libvirt, Am I mistaken?
>
> I was not talking about mounting the disk image on the guest . Libvirt
takes care of it .

What I am more concerned here is mounting the disk image on to the host
machine once tests have been conducted
inorder to view the output(raw data).


> Mounting the virtual device (b) can probably be done directly from the
> OS. On linux, you will have to add lines into /etc/fstab.
>
> In all those cases, I don't see the point of using an external tool like
> libguestfs in place of directly doing so in the OS. I am a bit confused
> so please tell me if I'm missing your point.
>
> See you at the meeting in a few hours.
> --
> Alexis
>

>Did you had a look at Fuse based solution ?
 I found these two FUSE based solutions.
1) guestfs (which uses libguestfs) [1]
2) xmount [2]

[1]http://libguestfs.org/guestmount.1.html
[2]http://manpages.ubuntu.com/manpages/natty/man1/xmount.1.html
-- 
Cheers,
Yeswanth

Re: [pyti] Disk Handler

From:
Alexis Métaireau
Date:
2011-06-14 @ 12:17
On 06/14/2011 01:56 PM, yeswanth swami wrote:
>   When ever a distribution needs to be tested, slave downloads it. It creates
> a new virtual hard disk( possibly .vdi format) and upload the packages to
> the disk .
> (or)
> We can use the same virtual disk after formatting it possibly (not sure
> formatting is necessary) and we can upload the distributions and
> configuration into it.
>
> Second solution sounds easier and probably we can go for it. We can use
> external tools for the one time image creation.
Why not creating a copy of this disk at the beginning of the process and 
deleting it at the end? If it's a small sized disk it can be valuable, 
otherwise we'll have to mount the disk on the host, do modifications on 
it etc. which can be time expensive.

> We would atleast need have to write a MBR into the disk and create a
> filesystem. Ofcourse this can be done when an OS is being installed on to
> the disk image.
> This may not be a issue then.
Yep, that could be handled at the creation of the OS (IOW, manually) :)

> What I am more concerned here is mounting the disk image on to the host
> machine once tests have been conducted
> inorder to view the output(raw data).
Ah, of course! +1 for libguestfs or equivalent solutions in this case.
-- 
Alexis