[Libvir] [RFC] Life-cycle Management of the domain

Saori Fukuta fukuta.saori at jp.fujitsu.com
Fri Apr 13 07:26:37 UTC 2007


Hi all,

I've been thinking about a way to change the hardware allocation on the 
Life-cycle. And I have some idea. Can I hear your comments about this?

1. Necessity of function
These are conceivable cases of changing hardware allocation.

    CASE A: Dynamic change
            change the allocation dynamically
            -> change the hardware allocation for now, 
               and next time, start by the allocation before it changes.
            (example of use)
            At night, change the hardware allocation.
            Next morning rebooting, return it.

    CASE B: Static change
            change the allocation statically
            -> do not change the hardware allocation for now, 
               but set the allocation for starting next.
            (example of use)
            Next time, want to start by the value that set before.
            
    CASE C: Permanent change 
            change the allocation permanently
            -> change the hardware allocation,
               and start next time with the same setting.
            (example of use)
            want to start by same value permanently.

The current situation of virsh command with Xen.
                     CASE A /  CASE B / CASE C
    virsh setmem       x         x        o
    virsh setmaxmem    x         x        o
    virsh setvcpus     o         x        x
    virsh vcpupin      o         x        x

And I find that the value on Xenstore is used for starting the domain 
next time.


2. Change of command
We need to add 3 options to the virsh command of changing allocation 
for CASE A, B, and C. So I propose the following options.

    option name
    --dynamic ... dynamic change option (default) for CASE A
    --static  ... static change option for CASE B
    --perm    ... permanent change option for CASE C

If no option is specified, the Default option("--dynamic") will be chosen.

    (example)
    Example of changing the memory allocation 256MB to 512MB.
        # virsh dominfo Domain-A | grep "Used memory"
        Used memory:    256000 kB

    CASE A: Dynamic change
        # virsh setmem Domain-A 512000
        or
        # virsh setmem Domain-A 512000 --dynamic

        # virsh dominfo Domain-A | grep "Used memory"
        Used memory:    512000 kB

    CASE B: Static change
        # virsh setmem Domain-A 512000 --static

        # virsh dominfo Domain-A | grep "Used memory"
        Used memory:    256000 kB

    CASE C: Permanent change
        # virsh setmem Domain-A 512000 --perm

        # virsh dominfo Domain-A | grep "Used memory"
        Used memory:    512000 kB

3. Summary of the ways
Xen does not provide these cases. So I propose that we start the domain 
by a file for libvirt.

    3.1 When starting the domain first time, 
        copy a file from config.sxp(/etc/xen config file) to virt.sxp(libvirt).

        (image)
                    +--- Xend ---+      +-- libvirt --+
        +--------+  l config.sxp ------->   virt.sxp  l  +--------+
        lDomain-Al  +------------+ copy +-------------+  lDomain-Al
        lmem=256 l                                       lmem=256 l
        +--------+  ---------------------------------->  +--------+
                         "virsh start Domain-A"

    3.2 When starting the domain,
        if they have virt.sxp(libvirt) define that file.

        (image)
        Step.1 value of the domain before start.

                    +--- Xend --------------------+
                    l +-Xenstore-+ +-config.sxp-+ l
        before      l l mem=256  l l mem=256    l l
        +--------+  l +----------+ +------------+ l
        lDomain-Al  +-----------------------------+
        lmem=256 l 
        +--------+  ---------------------------------> continue Step.2

        Step.2 define the value of virt.sxp.

                            +--- Xend ---------------------+
                            l +-Xenstore-+  +-config.sxp-+ l
                         +----> mem=512  l -> mem=512    l l
                 define  l  l +----------+  +------------+ l
                         l  +------------------------------+
                         l
                    +--- l --------+ 
                    l +- l --------+ 
        before      l l mem=512  l l 
        +--------+  l +-virt.sxp-+ l 
        lDomain-Al  +--- libvirt --+ 
        lmem=256 l                                     
        +--------+  ---------------------------------> continue Step.3

        Step.3 start the domain and copy a file from config.sxp to virt.sxp.

                    +--- Xend ---------------------+ 
                    l +-Xenstore-+  +-config.sxp-+ l 
                    l l mem=512  l  l mem=512    l l 
                    l +--- l ----+  +----- l ----+ l 
                    +----- l ------------- l ------+ 
                           l               l           +--- libvirt --+ 
                           l               l copy      l +-virt.sxp-+ l 
                           l               +-------------> mem=256  l l 
        before             l                           l +----------+ l 
        +--------+         l start       +--------+    +--------------+ 
        lDomain-Al         +------------>lDomain-Al 
        lmem=256 l                       lmem=512 l 
        +--------+  -------------------> +--------+ 
                     "virsh start Domain-A"

    3.3 When changing the allocation statically or permanently,
        write the change into virt.sxp.
        (When changing the allocation dynamically, do nothing)

        CASE A: Dynamic change
        (image)            
                    +--- Xend --------------------+             ll next start
                    l +-Xenstore-+ +-config.sxp-+ l             ll
                    l l mem=512  l l mem=512    l l             ll
                    l +----------+ +------------+ l             ll
                    +-----------------------------+             ll
                    +--- libvirt --+                            ll
                    l +-virt.sxp-+ l                            ll           
        before      l l mem=256  l l                 after      ll       
        +--------+  l +----------+ l                 +--------+ ll +--------+ 
        lDomain-Al  +--------------+                 lDomain-Al ll lDomain-Al 
        lmem=256 l                                   lmem=512 l ll lmem=256 l 
        +--------+  -------------------------------> +--------+ ll +--------+ 
                     "virsh setmem Domain-A 512000"             ll

        (state transition matrix)
        +-------------------------------------------------------------+
         operational procedure   Xend                 libvirt
                                 Xenstore config.sxp  virt.sxp
        +-------------------------------------------------------------+
         1.start the domain      mem=X,   mem=X   --->mem=X(create file)
         2.change the allocation mem=Y,   mem=Y       mem=X(no change)
           mem X to Y dynamically 
         3.stop the domain       mem=Y,   mem=Y       mem=X
         4.start the domain      <------- <-----------define value
                                 mem=X,   mem=X   --->mem=X(create file)
         5.delete the domain     del      del         delete file 
        +-------------------------------------------------------------+

        CASE B: Static change
        (image)            
                    +--- Xend --------------------+             ll next start
                    l +-Xenstore-+ +-config.sxp-+ l             ll
                    l l mem=256  l l mem=256    l l             ll
                    l +----------+ +------------+ l             ll
                    +-----------------------------+             ll
                    +--- libvirt --+                            ll
                    l +-virt.sxp-+ l                            ll           
        before      l l mem=512  l l                 after      ll       
        +--------+  l +----------+ l                 +--------+ ll +--------+ 
        lDomain-Al  +--------------+                 lDomain-Al ll lDomain-Al 
        lmem=256 l                                   lmem=256 l ll lmem=512 l 
        +--------+  -------------------------------> +--------+ ll +--------+ 
                     "virsh setmem Domain-A 512000 --static"    ll

        (state transition matrix)
        +-------------------------------------------------------------+
         operational procedure   Xend                 libvirt
                                 Xenstore config.sxp  virt.sxp
        +-------------------------------------------------------------+
         1.start the domain      mem=X,   mem=X   --->mem=X(create file)
         2.change the allocation mem=X,   mem=Y       mem=Y(change to Y)
           mem X to Y statically 
         3.stop the domain       mem=X,   mem=X       mem=Y
         4.start the domain      <------- <-----------define value
                                 mem=Y,   mem=Y   --->mem=Y(create file)
         5.delete the domain     del      del         delete file 
        +-------------------------------------------------------------+

        CASE C: Permanent change
        (image)            
                    +--- Xend --------------------+             ll next start
                    l +-Xenstore-+ +-config.sxp-+ l             ll
                    l l mem=512  l l mem=512    l l             ll
                    l +----------+ +------------+ l             ll
                    +-----------------------------+             ll
                    +--- libvirt --+                            ll
                    l +-virt.sxp-+ l                            ll           
        before      l l mem=512  l l                 after      ll       
        +--------+  l +----------+ l                 +--------+ ll +--------+ 
        lDomain-Al  +--------------+                 lDomain-Al ll lDomain-Al 
        lmem=256 l                                   lmem=512 l ll lmem=512 l 
        +--------+  -------------------------------> +--------+ ll +--------+ 
                     "virsh setmem Domain-A 512000 --perm"      ll

        (state transition matrix)
        +-------------------------------------------------------------+
         operational procedure   Xend                 libvirt
                                 Xenstore config.sxp  virt.sxp
        +-------------------------------------------------------------+
         1.start the domain      mem=X,   mem=X   --->mem=X(create file)
         2.change the allocation mem=Y,   mem=Y       mem=Y(change to Y)
           mem X to Y permanently  
         3.stop the domain       mem=Y,   mem=Y       mem=Y
         4.start the domain      <------- <-----------define value
                                 mem=Y,   mem=Y   --->mem=Y(create file)
         5.delete the domain     del      del         delete file 
        +-------------------------------------------------------------+

Thanks,
Saori Fukuta





More information about the libvir-list mailing list