[pve-devel] qemu2.7: cpu hotplug && hot-unplug v1

datanom.net mir at datanom.net
Mon Sep 12 14:22:20 CEST 2016


On 2016-09-12 13:48, Alexandre DERUMIER wrote:
> I think a basic implementation could be:
> 
> 
>    while (l) {
>         PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
>         l = g_list_next(l);
> +    AioContext *aio_context;
> +    aio_context = blk_get_aio_context(di->bs);
> +    aio_context_acquire(aio_context);
> +    bdrv_set_aio_context(di->target, aio_context);
> 
> 
>         backup_start(di->bs, di->target, speed, MIRROR_SYNC_MODE_FULL, 
> NULL,
>                      BLOCKDEV_ON_ERROR_REPORT, 
> BLOCKDEV_ON_ERROR_REPORT,
>                      pvebackup_dump_cb, pvebackup_complete_cb, di,
>                      1, NULL, &local_err);
> 
> + aio_context_release(aio_context);
> 
>         if (local_err != NULL) {
>             error_setg(&backup_state.error, "backup_job_create 
> failed");
>             pvebackup_cancel(NULL);
>         }
>     }
> 
> 
> 
> (and the more difficult is to cleanly release aiocontext  for all 
> exceptions)
> qemu use a  "goto out;" for this
> 
> out:
>     aio_context_release(aio_context);
> 
> 

Due to scope rules in C The declaration of aio_context must be moved out 
of the while block. I would suggest the following code then:
AioContext *aio_context = NULL;

while (l) {
     PVEBackupDevInfo *di = (PVEBackupDevInfo *)l->data;
     l = g_list_next(l);
     aio_context = blk_get_aio_context(di->bs);
     if (aio_context == NULL) {
         error_setg(&backup_state.error, "aio_context == NULL. 
backup_job_create failed");
         goto out;
     }
     aio_context_acquire(aio_context);
     bdrv_set_aio_context(di->target, aio_context);


     backup_start(di->bs, di->target, speed, MIRROR_SYNC_MODE_FULL, NULL,
                  BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
                  pvebackup_dump_cb, pvebackup_complete_cb, di,
                  1, NULL, &local_err);

     aio_context_release(aio_context);

     if (local_err != NULL) {
         error_setg(&backup_state.error, "backup_job_create failed");
         pvebackup_cancel(NULL);
     }
}

out:
     if (aio_context) {
         aio_context_release(aio_context);
     }

-- 
Hilsen/Regards
Michael Rasmussen

Get my public GnuPG keys:
michael <at> rasmussen <dot> cc
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xD3C9A00E
mir <at> datanom <dot> net
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xE501F51C
mir <at> miras <dot> org
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xE3E80917
--------------------------------------------------------------

----

This mail was virus scanned and spam checked before delivery.
This mail is also DKIM signed. See header dkim-signature.




More information about the pve-devel mailing list