Re: [PATCH] qemu: Adjust VM id allocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 28, 2015 at 05:41:25PM +0200, Erik Skultety wrote:
> Our atomic increment (virAtomicIntInc) uses (if available) gcc
> __sync_add_and_fetch builtin. In qemu driver though, we'd profit more
> from __sync_fetch_and_add builtin. To keep it simplistic, this patch
> adjusts qemu driver initialization rather than adding a new atomic
> increment macro.
> ---
>  src/qemu/qemu_conf.c   | 2 +-
>  src/qemu/qemu_conf.h   | 2 +-
>  src/qemu/qemu_driver.c | 7 ++-----
>  3 files changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
> index 38d4a86..29049dc 100644
> --- a/src/qemu/qemu_conf.c
> +++ b/src/qemu/qemu_conf.c
> @@ -1492,7 +1492,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev)
>  
>  int qemuDriverAllocateID(virQEMUDriverPtr driver)
>  {
> -    return virAtomicIntInc(&driver->nextvmid);
> +    return virAtomicIntInc(&driver->lastvmid);
>  }
>  
>  
> diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
> index 3f73929..ed9cd46 100644
> --- a/src/qemu/qemu_conf.h
> +++ b/src/qemu/qemu_conf.h
> @@ -192,7 +192,7 @@ struct _virQEMUDriver {
>      virThreadPoolPtr workerPool;
>  
>      /* Atomic increment only */
> -    int nextvmid;
> +    int lastvmid;
>  
>      /* Atomic inc/dec only */
>      unsigned int nactive;
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index a761448..055f0ca 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -612,7 +612,7 @@ qemuDomainFindMaxID(virDomainObjPtr vm,
>      int *driver_maxid = data;
>  
>      if (vm->def->id >= *driver_maxid)

You can s/>=/>/ now too - functionally the same but slightly
less misleading

> -        *driver_maxid = vm->def->id + 1;
> +        *driver_maxid = vm->def->id;
>  
>      return 0;
>  }
> @@ -649,9 +649,6 @@ qemuStateInitialize(bool privileged,
>      qemu_driver->inhibitCallback = callback;
>      qemu_driver->inhibitOpaque = opaque;
>  
> -    /* Don't have a dom0 so start from 1 */
> -    qemu_driver->nextvmid = 1;
> -
>      qemu_driver->privileged = privileged;
>  
>      if (!(qemu_driver->domains = virDomainObjListNew()))
> @@ -909,7 +906,7 @@ qemuStateInitialize(bool privileged,
>       * threads */
>      virDomainObjListForEach(qemu_driver->domains,
>                              qemuDomainFindMaxID,
> -                            &qemu_driver->nextvmid);
> +                            &qemu_driver->lastvmid);
>  
>      virDomainObjListForEach(qemu_driver->domains,
>                              qemuDomainNetsRestart,

ACK

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]