0

if my VM's are not created using virt-manager or are created using any other tool, then virsh system list command does not give them in the list of running VM's however they are running perfectly on my KVM server. Is there a way to list these VM's in my system list anyhow?

I have VM's managed by GKVM, AQEMU, libvirt etc. also some of the user start their VM's using the qemu command as follows:

kvm "image name" -m "memory". this starts the VM and allow them to work perfectly. but I am not able to list all these VM's using the virsh system list command.

adding the output of ps command:

# ps -ef |grep kvm
avahi      980     1  0 Nov02 ?        00:00:00 avahi-daemon: running [ubuntukvm.local]
root      1117     2  0 Nov02 ?        00:00:00 [kvm-irqfd-clean]
1000      1849     1  0 Nov02 ?        00:00:00 /usr/lib/gvfs//gvfs-fuse-daemon -f /home/ubuntu-kvm/.gvfs
1000     14364     1  0 Nov05 ?        00:00:42 gnome-terminal --login --geometry=80x24+10+10 -t ubuntukvm:4 (ubuntu-kvm) Desktop
115      23786     1  0 15:14 ?        00:00:08 /usr/bin/kvm -S -M pc-1.0 -enable-kvm -m 1024 -smp 1,sockets=1,cores=1,threads=1 -name **Ubuntu-guest-vm01** -uuid ed5a33c1-76fd-b67e-ff1b-f53a60681ec7 -nodefconfig -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/Ubuntu-guest-vm01.monitor,server,nowait -monchardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -drive file=/dev/lvm_disk/Ubuntu-guest-vm01,if=none,id=drive-ide0-0-0,format=raw -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,bootindex=1 -drive if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -netdev tap,fd=18,id=hostnet0 -device rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:fa:4a:bd,bus=pci.0,addr=0x3 -chardev pty,id=charserial0 -device isa-serial,chardev=charserial0,id=serial0 -usb -vnc 127.0.0.1:2 -vga cirrus -device intel-hda,id=sound0,bus=pci.0,addr=0x4 -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5
root     23787     2  0 15:14 ?        00:00:00 [kvm-pit-wq]
root     31140 29549  0 17:05 pts/0    00:00:00 sudo kvm winxp-guest-vm00.qcow2 -m 1024
root     31141 31140 54 17:05 pts/0    00:00:05 **kvm winxp-guest-vm00.qcow2 -m 1024**
root     31142     2  0 17:05 ?        00:00:00 [kvm-pit-wq]
1000     31157 23873  0 17:05 pts/9    00:00:00 grep --color=auto kvm

here my vm name ubuntu-guest-vm01 is started by virtmanager, and vm named winxp-guest-vm00 is started by kvm command however both were created using the virtmanager. so my issue is if my user start this vm using the kvm or qemu command i do not get the argument list in ps also so not able to collect all the required details

Stefan Lasiewski
  • 23,667
  • 41
  • 132
  • 186
Dr. Death
  • 45
  • 11

1 Answers1

1

Just list the processes, that's all KVM is after all ps -ef |grep kvm should do the trick, and you can parse the command line for details if you need to

dyasny
  • 18,802
  • 6
  • 49
  • 64
  • hi dyasny, i already tried using ps but it does not give me the details about my vm such as image path and it also does not give any info regarding the config file for the VM. Now when i list the VM i have only the name of VM and nothing else is available in case of vm created or started by not using virtmanager. – Dr. Death Nov 06 '12 at 10:00
  • In my case i am listing the VM's running from a remote machine which can detect any machine in network. so I need to list down the VM's running on network in order to perform any operation on that particular VM. Now when I start create vm using virtmanager, virsh can list it, but if any of the vm is created using any other tool I can only get the name of the vm from ps command. it does not give the path of the image file and config file as it gives in case of virtmanager. – Dr. Death Nov 06 '12 at 10:07
  • if you use the command I provided you will see the entire command line for the VM start, that has to include the disk image path and every other detail you can think of – dyasny Nov 06 '12 at 11:08
  • you can start a VM by just writing kvm -m and it will run. ps -ef can show this as just the last process run. Now, If i say that i had created a vm using virtmanager. now i start this vm using kvm command and do not start it using the virtmanager, then in that case you do not get the arguments that have been passed by virtmanager (when you run it using virtmanager). – Dr. Death Nov 06 '12 at 11:33
  • i added the ps output in my query but unable to crealy format it. please refer it as botht eh machine are created using virtmanager and used same type of argument at time of creation but the difference is how they are stared. first one is stared using virtmanager and later is using kvm command. please suggest how to proceed. – Dr. Death Nov 06 '12 at 11:47
  • You wanted a disk image name, and you have it in both outputs. What else did you want to see there? – dyasny Nov 06 '12 at 12:25
  • @dysany I require the disk image path and its config file(if possible as it is available when listing with virsh system list) for those which are not started using virtmanager. just to add disk image is not necessary the default path for each and every vm – Dr. Death Nov 06 '12 at 12:29
  • If you can start a VM with a simple command line, this VM does not need to have a config file at all. Having a definition file is one of the upsides to libvirt, but all libvirt does is parse that file, build a qemu-kvm command line and execute it. That's exactly the command line you can see in `ps`. If the VM wasn't started by virsh, there can be no config file, and so, you cannot get it from anywhere, since it doesn't exist – dyasny Nov 06 '12 at 12:40