[libvirt] [PATCH RFC] Add domainSave/Restore to libxl driver

Markus Groß gross at univention.de
Mon May 30 07:54:15 UTC 2011


Am Donnerstag 26 Mai 2011 22:04:35 schrieb Jim Fehlig:
> Markus Groß wrote:
> > Am Dienstag 24 Mai 2011 06:06:08 schrieb Jim Fehlig:
> >   
> >>> +
> >>> +        event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
> >>> +                                         VIR_DOMAIN_EVENT_STOPPED_SAVED);
> >>> +
> >>> +        if (libxlVmReap(driver, vm, 1, VIR_DOMAIN_SHUTOFF_SAVED) != 0) {
> >>> +            libxlError(VIR_ERR_INTERNAL_ERROR,
> >>> +                       _("Failed to destroy domain '%d'"), dom->id);
> >>> +            goto cleanup;
> >>> +        }
> >>>   
> >>>       
> >> And here call libxl_domain_destroy() directly instead of libxlVmReap(),
> >> allowing the event handler to cleanup the vm.
> >>
> >> Can you make these changes and ensure all the save/restore issues are
> >> resolved in your environment?
> >>     
> >
> > I made these changes but this leads to another issue.
> > When using the event handler to cleanup the domain
> > there seems to be a race condition.
> > The call to libxl_event_get_domain_death_info returns a value != 1
> >   
> 
> That should be fine though.  libxl_event_get_domain_death_info() will
> return 1 if the event is for the specified domid.  If it returns a value
> != 1, we goto cleanup and keep listening.
> 
> > sometimes and the domain gets not cleaned up.
> >   
> 
> Did you use the force flag when invoking
> libxl_event_get_domain_death_info()?  I've noticed that no events are
> generated when using that flag.
> 
> > The latest version of the patch I posted in this thread earlier does
> > not have this issue as it cleans up the domain directly.
> >   
> 
> How about this adjustment to your latest version?  I can't find any
> issues using this change, and it follows the same pattern used in xl client.
> 

The issue also occurs when not using the force-flag.
I tested your adjustment and it leads to the same problem.
Often the death-event for the domain is not properly set
(as the libxl_event_get_domain_death_info function returns != 1)
and therefore the domain is not cleaned up.

# virsh start domU && virsh save domU foo.img && virsh list
...
 Id Name                 Status
----------------------------------
 19 domU              running

# restart libvirt
# virsh list
 Id Name                 Status
----------------------------------

Regards,
Markus

> --- a/src/libxl/libxl_driver.c
> +++ b/src/libxl/libxl_driver.c
> @@ -378,6 +378,9 @@ static void libxlEventHandler(int watch,
>                  libxlVmReap(driver, vm, 0, VIR_DOMAIN_SHUTOFF_SHUTDOWN);
>                  libxlVmStart(driver, vm, 0, -1);
>                  break;
> +            case SHUTDOWN_suspend:
> +                libxlVmCleanup(driver, vm, VIR_DOMAIN_SHUTOFF_SAVED);
> +                break;
>              default:
>                  VIR_INFO("Unhandled shutdown_reason %d",
> info.shutdown_reason);
>                  break;
> @@ -1719,7 +1722,7 @@ libxlDomainSave(virDomainPtr dom, const char *to)
>          event = virDomainEventNewFromObj(vm, VIR_DOMAIN_EVENT_STOPPED,
>                                           VIR_DOMAIN_EVENT_STOPPED_SAVED);
> 
> -        if (libxlVmReap(driver, vm, 1, VIR_DOMAIN_SHUTOFF_SAVED) != 0) {
> +        if (libxl_domain_destroy(&priv->ctx, dom->id, 0) < 0) {
>              libxlError(VIR_ERR_INTERNAL_ERROR,
>                         _("Failed to destroy domain '%d'"), dom->id);
>              goto cleanup;
> 
> 





More information about the libvir-list mailing list