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

Alexandre DERUMIER aderumier at odiso.com
Tue Sep 13 06:36:30 CEST 2016


I have tried a simple
+    AioContext *aio_context;

...

+           const char *devname = bdrv_get_device_name(di->bs);
+           blk = blk_by_name(devname);
+           if (!blk) {
+               error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
+                  "toto Device '%s' not found", devname);
+               return NULL;
+           }
+
+           aio_context = blk_get_aio_context(blk);
+           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,


It's almost work when output to raw.
But with vma, we don't have di->target.

I don't known how to set aio context in this case.
(maybe somewhere in the callback, I'm not sure)


----- Mail original -----
De: "aderumier" <aderumier at odiso.com>
À: "pve-devel" <pve-devel at pve.proxmox.com>
Envoyé: Lundi 12 Septembre 2016 14:25:54
Objet: Re: [pve-devel] qemu2.7: cpu hotplug && hot-unplug v1

>>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; 

Yes, sure. I just post a basic sample ;) 

also, 
aio_context = blk_get_aio_context(di->bs); 

is wrong 

it should be the blk device, something like: 


+ BlockBackend *blk; 
+ const char *devname = bdrv_get_device_name(di->bs); 
+ blk = blk_by_name(devname); 
+ 
+ aio_context = blk_get_aio_context(blk); 

----- Mail original ----- 
De: "datanom.net" <mir at datanom.net> 
À: "pve-devel" <pve-devel at pve.proxmox.com> 
Envoyé: Lundi 12 Septembre 2016 14:22:20 
Objet: Re: [pve-devel] qemu2.7: cpu hotplug && hot-unplug v1 

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. 

_______________________________________________ 
pve-devel mailing list 
pve-devel at pve.proxmox.com 
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel 

_______________________________________________ 
pve-devel mailing list 
pve-devel at pve.proxmox.com 
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel 




More information about the pve-devel mailing list