[libvirt] Draft of pre migration checks framework

Paolo Smiraglia paolo.smiraglia at gmail.com
Fri May 21 13:16:00 UTC 2010


Hi guys, I'm working on a pre migration checks implementation.

The patch files attached provide a framework to execute
pre-migration-checks before the domain migration.


     ================================================================
     1 - FRAMEWORK OVERVIEW
     ================================================================
     Pre-Migration-Checks are enabled by adding a "--pmc" option in
     "virsh migrate" command

         $ virsh migrate --pmc ...

     In this way, before the execution of function virDomainMigrate(),
     an array of "checks" are performed. Return value of every check
     set if the migration will continue or not.

     ================================================================
     2 - FRAMEWORK STRUCTURE
     ================================================================
     Every check is defined in the file

         libvirt/src/util/pmc.c

     Check list is defined by object "chklist". This is a struct
     defined as

         static virPMCCheckList chklist = {
             .count = 2,
             .check = {&chk1,&chk2,NULL}
         };

     where "count" define the current array size, and "check" is an
     array of pointer to virPMCCheck object.

     virPMCCheck is a stuct defined as

         struct _virPMCCheck
         {
             const char *name;
             virPMCCheckRun run;
         };

     where "name" is the name of the check needed for debugging
     messages, and "run" is a pointer to check function.

     ================================================================
     3 - HOW TO ADD NEW CHECK
     ================================================================
     Adding new check is very simple! You have to define a check
     funcion as

         static int
         pmcCheckFooCheck(virDomainPtr domain,
                          virConnectPtr dconn)
         {
             /* do something */
             return CHECK_SUCCESS
         }

     then you have to define a "check-hook" as

         static virPMCCheck chk3 = {
             .name = "this is fooCheck",
             .run = pmcCheckFooCheck
         };

     and update the object "chklist"

         static virPMCCheckList chklist = {
             .count = 3,                       /* previous value was 2 */
             .check = {&chk1,&chk2,&chk3,NULL} /* previous content not
                                                * include a pointer to
                                                * chk3 object
                                                */
         };

     ================================================================
     4 - POSSIBLE ENHANCHEMENT
     ================================================================
     1. Adding infos in _virPMCCheck struct about check security level.

         Example: if a check with level CRITICAL return CHECK_FAIL,
         migration process is stopped,

     2. Implementing framework not as util, but as driver. For example
        this can permit to define new checks by xml file.

     3. Define external checks loadable by shared library.

     ================================================================
     5 - PATCH FILE DESCRIPTION
     ================================================================
     file: datatypes.h.patch
     desc: define new type virPMCCheckRun
           define struct _virPMCCheck
           define struct _virPMCCheckList

     file: libvirt.c.patch
     desc: impement public API virDomainMigratePMC()

     file: libvirt.h.in.patch
     desc: impement public API virDomainMigratePMC() prototype
           define type virPMCCheck
           define type virPMCCheckPtr
           define type virPMCCheckList
           define type virPMCCheckListPtr
           define macro PMC_LIST_SIZE

     file: libvirt_public.syms
     desc: export public API virDomainMigratePMC()

     file: pmc.c.patch, pmc.h.patch
     desc: define and implements pre migration checks and some auxiliary
           functions.

     file: virsh.c.patch
     desc: add option "pmc" to virsh migrate command

     ================================================================
     6 - NOTES
     ================================================================
     I start to implement this framework on git sources, but the
     latest sources produce a regress on my code. For this reason
     I applied my code on latest stable release of libvirt (0.8.1).



What do you think about that? Is this a good approach to implement pre
migration checks? Have you a suggestions? There is a possibility to
include this patch in future libvirt distributions?

Waiting for feedback...

         Paolo Smiraglia




-- 
PAOLO SMIRAGLIA
http://portale.isf.polito.it/paolo-smiraglia
-------------- next part --------------
A non-text attachment was scrubbed...
Name: datatypes.h.patch
Type: text/x-diff
Size: 635 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100521/44bf8dd6/attachment-0007.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libvirt.c.patch
Type: text/x-diff
Size: 3689 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100521/44bf8dd6/attachment-0008.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libvirt.h.in.patch
Type: text/x-diff
Size: 1194 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100521/44bf8dd6/attachment-0009.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libvirt_public.syms.patch
Type: text/x-diff
Size: 410 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100521/44bf8dd6/attachment-0010.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pmc.c.patch
Type: text/x-diff
Size: 7314 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100521/44bf8dd6/attachment-0011.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pmc.h.patch
Type: text/x-diff
Size: 507 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100521/44bf8dd6/attachment-0012.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: virsh.c.patch
Type: text/x-diff
Size: 2708 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100521/44bf8dd6/attachment-0013.bin>


More information about the libvir-list mailing list