[libvirt-users] Checking if the VM has been created

I'm a Libvirt newbie and I'd really appreciate it if someone could answer my doubts. I'm using Libvirt's Java API. My doubts: 1.Currently, I'm able to create a VM on Ubuntu 11.04 using Libvirt functions domainCreateLinux() and domainDefineXML(). Apart fromt the boolean return status of these operations and running the virsh list command, is there any way to SSH in (login) to the newly created VMs and run applications on them? I tried running virsh console but nothing comes up. Also I tried fixing the XML file to accommodate the console operation( link <http://ubuntuforums.org/showthread.php?t=1159220>) but that was unsuccessful too. 2. If yes, how can I get the IP of the VM created? 3. Is there any function to create image files(in any format qcow or qcow2) using Libvirt API? Right now, I'm using a shell script which creates the image from it's iso. Thanks in advance P Ramesh

Am 16.11.2011 14:46, schrieb William A. Mahaffey III:
The route command on the host will show the newly added routes for the VM. Also, tail your syslog file & you will see messages about every 15 min. from dnsmasq w/ the IP adder. of the VM.
route just shows the bridge, the individual IP of the VM is only shown in the syslog. However, this is just a workaround, and does not provide reliable identification of the IP if there are many VMs. libvirt resp. virsh should provide a way of obtaining the IP directly from the domain name. Best, Till -- Prof. Dr. Till Mossakowski Cartesium, room 2.51 Phone +49-421-218-64226 DFKI GmbH Bremen Fax +49-421-218-9864226 Cyber-Physical Systems Till.Mossakowski@dfki.de Enrique-Schmidt-Str. 5, D-28359 Bremen http://www.dfki.de/sks/till Deutsches Forschungszentrum fuer Kuenstliche Intelligenz GmbH principal office, *not* the address for mail etc.!!!: Trippstadter Str. 122, D-67663 Kaiserslautern management board: Prof. Wolfgang Wahlster (chair), Dr. Walter Olthoff supervisory board: Prof. Hans A. Aukes (chair) Amtsgericht Kaiserslautern, HRB 2313

On 11/16/11 08:28, Till Mossakowski wrote:
Am 16.11.2011 14:46, schrieb William A. Mahaffey III:
The route command on the host will show the newly added routes for the VM. Also, tail your syslog file & you will see messages about every 15 min. from dnsmasq w/ the IP adder. of the VM.
route just shows the bridge, the individual IP of the VM is only shown in the syslog. However, this is just a workaround, and does not provide reliable identification of the IP if there are many VMs. libvirt resp. virsh should provide a way of obtaining the IP directly from the domain name.
Best, Till
output from 'route -CFvnee' as root on my host attached, 4th line in file shows IP addr of my VM, visible in other lines as well .... & I definitely agree that virsh *should* show that info :-) .... -- William A. Mahaffey III ---------------------------------------------------------------------- "The M1 Garand is without doubt the finest implement of war ever devised by man." -- Gen. George S. Patton Jr.

On 16.11.2011 16:46, William A. Mahaffey III wrote:
On 11/16/11 08:28, Till Mossakowski wrote:
Am 16.11.2011 14:46, schrieb William A. Mahaffey III:
The route command on the host will show the newly added routes for the VM. Also, tail your syslog file & you will see messages about every 15 min. from dnsmasq w/ the IP adder. of the VM.
route just shows the bridge, the individual IP of the VM is only shown in the syslog. However, this is just a workaround, and does not provide reliable identification of the IP if there are many VMs. libvirt resp. virsh should provide a way of obtaining the IP directly from the domain name.
Best, Till
output from 'route -CFvnee' as root on my host attached, 4th line in file shows IP addr of my VM, visible in other lines as well ....
& I definitely agree that virsh *should* show that info :-) ....
It is not so simple. Although we have this 'ip address learning module' in nwfilters code, it is not reliable. In general there is no reliable technique to determine guest IP address(es) unless using guest agent who'll tell us. Listening on bridge and guessing addresses is not right, as guest might be not playing a fair game and produce packets with different IP addresses. Moreover, sniffing on multiple bridges and guessing IP addresses can be CPU consuming. And one would need to do this sniffing repeatedly as IP address might change over time. Michal

On 11/16/2011 08:46 AM, William A. Mahaffey III wrote:
The route command on the host will show the newly added routes for the VM. Also, tail your syslog file & you will see messages about every 15 min. from dnsmasq w/ the IP adder. of the VM.
& I definitely agree that virsh *should* show that info :-) ....
This has been an oft-requested feature, but no one has yet submitted patches. The closest we have is that use of nwfilter can snoop a guest's address, but this isn't yet exposed to the user via an easy-to-access API. If you set up a DHCP server to assign guest IP addresses based on guest MAC address, then you know what IP address the guest should have. But if this is not the case, then the only way libvirt can learn this is by snooping - libvirt can snoop DHCP traffic to learn what an external dhcp server is giving to the guest, as well as snoop guest traffic to see what address the guest appears to be using. But a malicious guest can spoof this snooping, not to mention that a guest that uses multiple IP addresses on a single interface may confuse libvirt, which will probably only snoop the first address used. And a guest that never initiates traffic is hard to snoop - making it hard to know what address to use for ssh into the guest. There are also plans to make use of a guest agent for communicating the guest IP address back over the agent channel (right now, libvirt's only use of a guest agent is for triggering guest shutdown), but again this relies on the agent being present in the guest and cannot be deemed 100% reliable. Use of libvirt guest console features tends to be more reliable than trying to ssh into a guest, since that bypasses the need to learn the guest's IP address. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (5)
-
Eric Blake
-
Michal Privoznik
-
Preethi Ramesh
-
Till Mossakowski
-
William A. Mahaffey III