From mboxrd@z Thu Jan 1 00:00:00 1970 From: jd Subject: Fwd: Re: KVM management and API Date: Mon, 30 Apr 2007 19:01:55 -0700 (PDT) Message-ID: <455463.58286.qm@web35806.mail.mud.yahoo.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="0-557687603-1177984915=:58286" Content-Transfer-Encoding: 7bit To: kvm-devel Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org --0-557687603-1177984915=:58286 Content-Type: multipart/alternative; boundary="0-354442072-1177984915=:58286" --0-354442072-1177984915=:58286 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable oops. forgot to put kvm-devel. /Jd Note: forwarded message attached. =20 --------------------------------- Ahhh...imagining that irresistible "new car" smell? Check outnew cars at Yahoo! Autos. --0-354442072-1177984915=:58286 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable oops. forgot to put kvm-devel.

/Jd

Note: forwarded message = attached.


Ahhh...imagining that irresistible "new car" smell? Check out new cars at Yahoo! Autos. --0-354442072-1177984915=:58286-- --0-557687603-1177984915=:58286 Content-Type: message/rfc822 Content-Transfer-Encoding: 7bit Received: from [24.6.255.91] by web35812.mail.mud.yahoo.com via HTTP; Fri, 27 Apr 2007 22:11:41 PDT Date: Fri, 27 Apr 2007 22:11:41 -0700 (PDT) From: jd Subject: Re: [kvm-devel] KVM management and API To: "Daniel P. Berrange" In-Reply-To: <20070427220657.GB8384-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1836689879-1177737101=:3341" Content-Length: 4773 Content-Transfer-Encoding: 7bit --0-1836689879-1177737101=:3341 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Thanks Daniel. But I was looking for bit of under the hood answers. Does libvirt use ps -ef | grep qemu to find out qemu processes ? Or it ma= nages only ones that are started using libvirt. Using some naming scheme. How do you know if a running process is using kvm kernel module or not ?=20 libvirt seems to be connecting to qemu console through qemud ? right ? = You have done quite a bit of work to send command and parse. !! Isnt this= error prone ? (will code for parsing work in different char set ? or qem= u console is always guarenteed to be in english ?) How do you find out what % of allocated memory is actually used by VM ?=20 For cpu /proc seems to be used.. which seems fine, but will not work for = QEMU on Windows. Some core qemu quesions still remains=20 -- what are the plans to dynamically be able to change cpu , mem, disks a= nd n/w for a running vm ? -- proper shutdown/restart of VM ? Hoping some kvm/qemu experts would thrown in some light on the directions= and plans. Thanks in advance. /Jd =20 "Daniel P. Berrange" wrote: On Fri, Apr 27, 2007 at= 02:29:52PM -0700, jd wrote: > Hi > This is a great project with a lots and lots of potential. I have a=20 > bunch of questions related to managing kvm VMs. >=20 > I would like to know what kind of options are available for doing=20 > effective management ot KVM/QEMU processes (VMs). And know more abut= =20 > plans / roadmap /directions to get to a proper API. (similar to Xen-= API) We are supporting QEMU / KVM management in libvirt since version 0.3.0 aiming to have feature parity for our management APIs between Xen, QEMU and KVM. This gives a C, Python & Perl API. A command line tool virsh. And a couple of higher level tools virt-install & virt-manager. I'll illustrate possible answers to your questions in terms of virsh... > 1. Discovery : How does one find all processes running KVM vms ? > ps -ef | grep qemu ?=20 libvirt doesn't expose the PIDs to app developers, but you can get a list using # export VIRSH_DEFAULT_CONNECT_URI=3Dqemu:///system # virsh list --all Id Name State ---------------------------------- 1 QEMUGuest1 running - wizz shut off > How does one know if qemu is using the kvm or not ? # virsh dumpxml QEMUGuest1 | grep domain =20 The 'type' attribute will be one of qemu, kqemu, kvm > 2. Identity : I am assuming that each VM is a process and pid would=20 > be an identifier, is there any other more unique identifier available.=20 libvirt provides 3 identifiers with different levels of uniqueness 1. 'id' - integer uniquely identifying amongst active guests on a host 2. 'name' - string uniquely identifying amongst active & inactive guests= on a host 3. 'uuid' - hex string uniquely identifying globally > 3. Managing running processs : > a. How does one connect to the manage the running vms ? > I have read about screen and socat options. > Both of these act as tty client, where success/failure and errors= for a given=20 > command are very vague (parsing..). (A way to get return code for= the operation=20 > would be great). Parsing ... command response and interpreting...= is error prone. > Say I choose socat, how do I gracefully detach from the console. (= other than =20 > just killing socat) virsh provides a set of commands for controlling lifecycle & configurati= on of the guest from the host machine, eg shutdown, start, pause, resume, su= spend, restore, dominfo, dumpxml, etc, etc The graphical console is typically exposed with VNC / SDL. You can find t= he VNC port with: # virsh vncdisplay QEMUGuest1 :0 If you configured a serial port & setup the guest to start a getty on it you can also connect via the 'serial console' # virsh console QEMUGuest1 > b. How does one get the stats for the running VM ?=20 > 1. status : running, stopped, *migrating*..? > 2. Current use of the memory : example allocated 1 GB, used 512 = MB. > 3. CPU : Effective cpu used ? Are vcpus supported ? > /proc can be used... what about windows ? (when and if we ha= ve kvm on windows) > 4. How much I/O and Network I/O > 5. Wait times to get to I/O or CPU. (contention measures) Can do the first 3 options # virsh dominfo QEMUGuest1 Id: 1 Name: QEMUGuest1 UUID: c7a5fdbd-edaf-9455-926a-d65c16db1809 OS Type: hvm State: running CPU(s): 1 CPU time: 98.8s Max memory: 219200 kB Used memory: 219200 kB We don't currently have APIs to show disk & network I/O stats. We also do= n't yet provide migration support. > 6. What is kvm_stats ? How to interpret its output? No idea :-) > c. Can one change memory, cpus, disks and networks on the fly for a = running VM ? If so how ?=20 > This is critical for achiving dynamic resource management. Not AFAIK. To be precise, libvirt provides APIs for that, but it requires= better guest support / paravirt device drivers. Also QEMU can do hot-add/remove = of USB devices. > 4. Shutdown : How does one send command to VM to shutdown normally. = I see only reset=20 > and powerdown commands only. Also, after shutdown, the image running i= n the machine=20 > shuts down, but the VM keeps running. Shouldnt the process also die ? A controlled shutdown isn't provided by QEMU/KVM yet. One would need to s= imulate some kind of ACPI power management support in the guest so it saw a virtu= al software power button press i guess. > 5. Snapshots : where are snapshots saved ? I tried savevm with /tmp/x, = I was expecting a=20 > file containing memory image... do these work differrently ? > Also, when one does loadvm, is the snapshot gone ? I mean can one re= store the same=20 > snapshot multiple times ? libvirt has APIs for snapshotting, but we've not implement them for QEMU or KVM yet. You can save the file to any location you have write permissi= ons for. Its not a plain memory image because it also contains info about the state of all the various virtual devices. The snapshot doesn't deal with changes in state on your disks. So if you = restored a snapshot, ran it for a while doing disk IO and then quit & tried to res= tore the snapshot again your disks would be out of sync. That said if one could take snapshots of the disks (eg with LVM, or QCOW)= then it ought to be possible to use a snapshot multiple times over. Dan. --=20 |=3D- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 24= 96 -=3D| |=3D- Perl modules: http://search.cpan.org/~danberr/ = -=3D| |=3D- Projects: http://freshmeat.net/~danielpb/ = -=3D| |=3D- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 950= 5 -=3D|=20 =20 --------------------------------- Ahhh...imagining that irresistible "new car" smell? Check outnew cars at Yahoo! Autos. --0-1836689879-1177737101=:3341 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Thanks Daniel. But I was looking for bit of under the hood answers.
Does libvirt use ps -ef | grep qemu to find out qemu processes ? Or it = manages only ones that are started using libvirt. Using some naming schem= e.

How do you know if a running process is using kvm kernel module= or not ?

libvirt seems to be connecting to  qemu console th= rough qemud ? right ?  You have done quite a bit of work to send com= mand and parse. !! Isnt this error prone ? (will code for parsing work in= different char set ? or qemu console is always guarenteed to be in engli= sh ?)

How do you find out what % of allocated memory is actually u= sed by VM ?

For cpu /proc seems to be used.. which seems fine, bu= t will not work for QEMU on Windows.

Some core qemu quesions still= remains
-- what are the plans to dynamically be able to change cpu ,= mem, disks and n/w for  a running vm ?

-- proper shutdown/re= start of VM ?

Hoping some kvm/qemu experts would thrown in some light on the directions and plans.=

Thanks in advance.
/Jd
 



"Daniel = P. Berrange" <berrange-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org> wrote:
On Fri, Apr 27, 2007 at 02:29:52PM -0700, jd wro= te:
> Hi
> This is a great project with a lots and lots of= potential. I have a
> bunch of questions related to managing k= vm VMs.
>
> I would like to know what kind of options are= available for doing
> effective management ot KVM/QEMU process= es (VMs). And know more abut
> plans / roadmap /directions to g= et to a proper API. (similar to Xen-API)

We are supporting QEMU / = KVM management in libvirt since version 0.3.0
aiming to have feature p= arity for our management APIs between Xen, QEMU
and KVM. This gives a = C, Python & Perl API. A command line tool virsh.
And a couple of higher level tools virt-install & vir= t-manager. I'll
illustrate possible answers to your questions in terms= of virsh...

> 1. Discovery : How does one find all processes r= unning KVM vms ?
> ps -ef | grep qemu ?

libvirt doesn't= expose the PIDs to app developers, but you can get a
list using
# export VIRSH_DEFAULT_CONNECT_URI=3Dqemu:///system
# virsh list -= -all
Id Name State
---------------------------= -------
1 QEMUGuest1 running
- wizz = shut off

> How does one know if qemu is using the kvm or= not ?

# virsh dumpxml QEMUGuest1 | grep domain


The 'type' attribute will be one of qemu, kqemu, = kvm

> 2. Identity : I am assuming that each VM is a process and= pid would
> be an identifier, is there any other more unique iden= tifier available.

libvirt provides 3 identifiers with different levels of uniqueness

1. 'id' - inte= ger uniquely identifying amongst active guests on a host
2. 'name' - = string uniquely identifying amongst active & inactive guests on a hos= t
3. 'uuid' - hex string uniquely identifying globally

> 3.= Managing running processs :
> a. How does one connect to the ma= nage the running vms ?
> I have read about screen and socat = options.
> Both of these act as tty client, where success/fai= lure and errors for a given
> command are very vague (parsin= g..). (A way to get return code for the operation
> would be= great). Parsing ... command response and interpreting... is error prone.=
> Say I choose socat, how do I gracefully detach from the con= sole. ( other than
> just killing socat)

virsh provide= s a set of commands for controlling lifecycle & configuration
of = the guest from the host machine, eg shutdown, start, pause, resume, suspend,
restore, dominfo, dumpxml, e= tc, etc

The graphical console is typically exposed with VNC / SDL.= You can find the
VNC port with:

# virsh vncdisplay QEMUGuest= 1
:0

If you configured a serial port & setup the guest to= start a getty on it
you can also connect via the 'serial console'
=
# virsh console QEMUGuest1


> b. How does one get t= he stats for the running VM ?
> 1. status : running, stoppe= d, *migrating*..?
> 2. Current use of the memory : example a= llocated 1 GB, used 512 MB.
> 3. CPU : Effective cpu used ? = Are vcpus supported ?
> /proc can be used... what about = windows ? (when and if we have kvm on windows)
> 4. How much= I/O and Network I/O
> 5. Wait times to get to I/O or CPU. (= contention measures)

Can do the first 3 options

# virsh dom= info QEMUGuest1
Id: =20 1
Name: QEMUGuest1
UUID: c7a5fdbd-edaf-9455-92= 6a-d65c16db1809
OS Type: hvm
State: running
CPU(= s): 1
CPU time: 98.8s
Max memory: 219200 kB
Us= ed memory: 219200 kB

We don't currently have APIs to show disk = & network I/O stats. We also don't
yet provide migration support.<= br>
> 6. What is kvm_stats ? How to interpret its output?
No idea :-)

> c. Can one change memory, cpus, disks and= networks on the fly for a running VM ? If so how ?
> This= is critical for achiving dynamic resource management.

Not AFAIK. = To be precise, libvirt provides APIs for that, but it requires better
= guest support / paravirt device drivers. Also QEMU can do hot-add/remove = of USB
devices.

> 4. Shutdown : How does one send command = to VM to shutdown normally. I see only reset
> and powerdown co= mmands only. Also, after shutdown, the image running in the machine
> shuts down, but the VM keeps runni= ng. Shouldnt the process also die ?

A controlled shutdown isn't pr= ovided by QEMU/KVM yet. One would need to simulate
some kind of ACPI p= ower management support in the guest so it saw a virtual
software powe= r button press i guess.

> 5. Snapshots : where are snapshots sa= ved ? I tried savevm with /tmp/x, I was expecting a
> file cont= aining memory image... do these work differrently ?
> Also, when= one does loadvm, is the snapshot gone ? I mean can one restore the same =
> snapshot multiple times ?

libvirt has APIs for snapsho= tting, but we've not implement them for QEMU
or KVM yet. You can save = the file to any location you have write permissions
for. Its not a pla= in memory image because it also contains info about the
state of all t= he various virtual devices.

The snapshot doesn't deal with changes= in state on your disks. So if you restored
a snapshot, ran it for a while doing disk IO and then quit &= amp; tried to restore the
snapshot again your disks would be out of sy= nc.

That said if one could take snapshots of the disks (eg with LV= M, or QCOW) then
it ought to be possible to use a snapshot multiple ti= mes over.

Dan.
--
|=3D- Red Hat, Engineering, Emerging Tech= nologies, Boston. +1 978 392 2496 -=3D|
|=3D- Perl modules:= http://search.cpan.org/~danberr/ -=3D|
|=3D- = Projects: http://freshmeat.net/~danielpb/ -=3D|
|=3D-= GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=3D= |


Ahhh...imagining that irresistible "new car" smell? Check out new cars at Yahoo! Autos. --0-1836689879-1177737101=:3341-- --0-557687603-1177984915=:58286 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ --0-557687603-1177984915=:58286 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kvm-devel mailing list kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/kvm-devel --0-557687603-1177984915=:58286--