[virt-tools-list] Re: [libvirt] Create a new VM from an existent image?

Cole Robinson crobinso at redhat.com
Tue Jul 21 02:40:07 UTC 2009


Jun Koi wrote:
> On Tue, Jul 21, 2009 at 11:07 AM, Jun Koi<junkoi2004 at gmail.com> wrote:
>> On Tue, Jul 21, 2009 at 10:45 AM, Jun Koi<junkoi2004 at gmail.com> wrote:
>>> On Mon, Jul 20, 2009 at 1:19 AM, Cole Robinson<crobinso at redhat.com> wrote:
>>>> (taking to virt-tools-list, this isn't relevant to libvirt)
>>>>
>>>> Jun Koi wrote:
>>>>> On Sun, Jul 19, 2009 at 1:59 AM, Cole Robinson<crobinso at redhat.com> wrote:
>>>>>> Jun Koi wrote:
>>>>>>> On Fri, Jul 17, 2009 at 10:42 PM, Cole Robinson<crobinso at redhat.com> wrote:
>>>>>>>> Jun Koi wrote:
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> To use libvirt, I am strying to use virt-install to create a new VM
>>>>>>>>> from an existent (KVM) VM image. I did the following steps:
>>>>>>>>>
>>>>>>>>> 1) run libvirtd with "libvirtd -d" (I use the latest libvirt git tree)
>>>>>>>>>
>>>>>>>>> 2) Run virt-install (0.400.3) with my existent image in img/img.winxp
>>>>>>>>>
>>>>>>>>> # virt-install --import -n winxp -f img/img.xp3 --vnc --hvm
>>>>>>>>> --accelerate --ram 800
>>>>>>>>>
>>>>>>>> That looks fine.
>>>>>>>>
>>>>>>>>> However, this step returns error like:
>>>>>>>>>
>>>>>>>>> "ERROR    Could not find usable default libvirt connection."
>>>>>>>>>
>>>>>>>> If 'virsh --connect qemu:///system' doesn't work, you probably didn't
>>>>>>>> configure your libvirt install correctly.
>>>>>>>>
>>>>>>> But it works! So the problem stays elsewhere.
>>>>>>>
>>>>>>> Do you have any suggestion?
>>>>>>>
>>>>>> Hmm, then you probably need this patch to virtinst, since our URI detection
>>>>>> likely isn't as thorough as libvirt:
>>>>>>
>>>>>> http://hg.et.redhat.com/cgi-bin/hg-virt.cgi/applications/virtinst--devel/rev/030fbc6df74f
>>>>>>
>>>>> I got the latest code from hg tree, and installed that.  But running
>>>>> "virt-install" (without option) returns the error message:
>>>>>
>>>>> Traceback (most recent call last):
>>>>>   File "/usr/local/bin/virt-install", line 36, in <module>
>>>>>     from virtinst.VirtualCharDevice import VirtualCharDevice
>>>>> ImportError: No module named VirtualCharDevice
>>>>>
>>>>>
>>>>>
>>>>> How to fix this problem?
>>>>>
>>>> There must be an install issue, you shouldn't have this issue. My guess is
>>>> /usr/local/bin/virt-install isn't looking at the newly installed virtinst libs.
>>>>
>>>> What command did you use to install? What distro are you on? What does:
>>>>
>>>> python -c 'import virtinst; print virtinst'
>>>>
>>>> show? It should list the path to the newly installed virtinst, the one via
>>>> your distro.
>>> It prints out: <module 'virtinst' from 'virtinst/__init__.py'>""
>>>
>>> I checked again, and see that virt-install was installed into
>>> /usr/local/bin, which might not be the right place? It should be in
>>> /usr/bin, right? So how to install virt-install there?
>>>
>>> If that matters, I install virt-install by running "python setup.py
>>> install". I am on Ubuntu 904, and I heard that Python 2.6.2 on this
>>> distro has some problems with installation, so that they always put
>>> code into /usr/local/ (??)
>> I tried to install virt-install again, with command:
>>
>> python setup.py install --prefix=/usr
>>
>> Then I run "virt-install" again (without option). This time I got the
>> below error:
>>
>> Traceback (most recent call last):
>>  File "/usr/bin/virt-install", line 36, in <module>
>>    from virtinst.VirtualCharDevice import VirtualCharDevice
>> ImportError: No module named VirtualCharDevice
>>
>>
>> So it is still the same problem as before. Do you have any hint?
>>
>> My impression is that so far, libvirt stuff is not well supported in
>> Ubuntu, but only in Fedora Core.
> 
> I had another attempt on another Ubuntu (8.04), and it seems to work
> this time. Ubuntu 804 use older Python 2.5.2, and that makes the
> difference?
> 

Not sure exactly. Sounds like the newer Ubuntu version changed how python
packages are installed by default, and something is slipping up. The above
error message likely means that 'virt-install' couldn't find the newly
installed virtinst libs. Maybe a PYTHONPATH problem?

Either way, if you find out how to install virtinst from source on the newer
ubuntu version, let us know.

> However, when I run the below command to import an existent KVM image:
> 
> virt-install --import -n xp3 -f img/img.xp3 --vnc --hvm --accelerate
> --ram 1000 --prompt
> 
> I got the question: "How large would you like the disk img/img.xp3 to be?"
> 
> This is really confused to me: it seems virt-install is trying to
> create a new image, while all i want to do is to *import* image (I
> already specified --import above), but not to create a new one.
> 
> How to fix this?
> 

I'm not sure, I can't reproduce on my system with a latest checkout. Does that
file path definitely exist? Can you attach the output of that command with the
--debug flag?

Also, if you are importing an XP image, you will probably want to specify
--os-variant winxp to get the proper defaults.

- Cole




More information about the virt-tools-list mailing list