Re: [PATCH v2 6/8] perf: reenable perf events when libvirtd restart

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

 



On Mon, Dec 07, 2015 at 03:53:57PM +0800, Qiaowei Ren wrote:
> When libvirtd daemon restart, this patch will reenable those perf
> events previously enabled.
> 
> Signed-off-by: Qiaowei Ren <qiaowei.ren@xxxxxxxxx>
> ---
>  src/qemu/qemu_driver.c | 33 +++++++++++++++++++++++++++++++++
>  1 file changed, 33 insertions(+)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 7f3c2a5..91aa79f 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -164,6 +164,9 @@ static int qemuDomainGetMaxVcpus(virDomainPtr dom);
>  static int qemuDomainManagedSaveLoad(virDomainObjPtr vm,
>                                       void *opaque);
>  
> +static int qemuDomainPerfRestart(virDomainObjPtr vm,
> +                                 void *data);
> +
>  static int qemuOpenFile(virQEMUDriverPtr driver,
>                          virDomainObjPtr vm,
>                          const char *path, int oflags,
> @@ -939,6 +942,10 @@ qemuStateInitialize(bool privileged,
>                              qemuDomainManagedSaveLoad,
>                              qemu_driver);
>  
> +    virDomainObjListForEach(qemu_driver->domains,
> +                            qemuDomainPerfRestart,
> +                            NULL);
> +
>      qemuProcessReconnectAll(conn, qemu_driver);
>  
>      qemu_driver->workerPool = virThreadPoolNew(0, 1, 0, qemuProcessEventHandler, qemu_driver);
> @@ -3460,6 +3467,32 @@ qemuDomainManagedSaveLoad(virDomainObjPtr vm,
>      return ret;
>  }
>  
> +static int
> +qemuDomainPerfRestart(virDomainObjPtr vm,
> +                      void *data ATTRIBUTE_UNUSED)
> +{
> +    virDomainDefPtr def = vm->def;
> +    qemuDomainObjPrivatePtr priv = vm->privateData;
> +
> +    if (priv->perf)
> +        virPerfFree(priv->perf);

No need for the if() as virPerfFree accepts NULL

> +    priv->perf = virPerfNew();
> +    if (!priv->perf)
> +        return -1;
> +
> +    if (def->perf.cmt && def->perf.cmt == VIR_TRISTATE_BOOL_YES) {
> +        if (virPerfEventEnable(priv->perf, VIR_PERF_EVENT_CMT, vm->pid))
> +            goto cleanup;
> +    }

If you change the XML as I suggest, you can do

  for (i = 0; i < VIR_PERF_EVENT_LAST; i++) {
      if (def->perf.events[i] &&
          virPerfEventEnable(priv->perf, i, vm->pid))
              goto cleanup;
  }

Which again avoids hardcoding 'CMT' anywhere


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]