Re: [libvirt] [PATCH 2/3] Qemu: add CMT support

2015-10-31 Thread Ren, Qiaowei

> -Original Message-
> From: Jiri Denemark [mailto:jdene...@redhat.com]
> Sent: Thursday, October 29, 2015 5:52 PM
> To: Ren, Qiaowei
> Cc: libvir-list@redhat.com; Feng, Shaohe
> Subject: Re: [libvirt] [PATCH 2/3] Qemu: add CMT support
> 
> On Thu, Oct 29, 2015 at 14:02:29 +0800, Qiaowei Ren wrote:
> > One RFC in
> > https://www.redhat.com/archives/libvir-list/2015-June/msg01509.html
> >
> > CMT (Cache Monitoring Technology) can be used to measure the usage of
> > cache by VM running on the host. This patch will extend the bulk stats
> > API (virDomainListGetStats) to add this field. Applications based on
> > libvirt can use this API to achieve cache usage of VM. Because CMT
> > implementation in Linux kernel is based on perf mechanism, this patch
> > will enable perf event for CMT when VM is created and disable it when
> > VM is destroyed.
> >
> > Signed-off-by: Qiaowei Ren 
> > ---
> >  include/libvirt/libvirt-domain.h |  1 +
> >  src/qemu/qemu_domain.h   |  3 ++
> >  src/qemu/qemu_driver.c   | 48 ++
> >  src/qemu/qemu_process.c  | 86
> 
> >  4 files changed, 138 insertions(+)
> >
> > diff --git a/include/libvirt/libvirt-domain.h
> > b/include/libvirt/libvirt-domain.h
> > index e8202cf..fb5e1f4 100644
> > --- a/include/libvirt/libvirt-domain.h
> > +++ b/include/libvirt/libvirt-domain.h
> > @@ -1764,6 +1764,7 @@ typedef enum {
> >  VIR_DOMAIN_STATS_VCPU = (1 << 3), /* return domain virtual CPU info */
> >  VIR_DOMAIN_STATS_INTERFACE = (1 << 4), /* return domain interfaces
> info */
> >  VIR_DOMAIN_STATS_BLOCK = (1 << 5), /* return domain block info */
> > +VIR_DOMAIN_STATS_CACHE = (1 << 6), /* return domain block info */
> 
> This flag is not documented anywhere and the comment is completely wrong.
> 
> >  } virDomainStatsTypes;
> >
> >  typedef enum {
> > diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index
> > 54e1e7b..31bce33 100644
> > --- a/src/qemu/qemu_domain.h
> > +++ b/src/qemu/qemu_domain.h
> > @@ -196,6 +196,9 @@ struct _qemuDomainObjPrivate {
> >
> >  bool hookRun;  /* true if there was a hook run over this domain
> > */
> >
> > +int cmt_fd;  /* perf handler for CMT */
> 
> So you declare cmt_fd as int...
> 
> > +
> > +
> 
> Why two empty lines?
> 
> >  /* Bitmaps below hold data from the auto NUMA feature */
> >  virBitmapPtr autoNodeset;
> >  virBitmapPtr autoCpuset;
> > diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index
> > 4cfae03..8c678c9 100644
> > --- a/src/qemu/qemu_driver.c
> > +++ b/src/qemu/qemu_driver.c
> > @@ -19320,6 +19320,53 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr
> > driver,
> >
> >  #undef QEMU_ADD_COUNT_PARAM
> >
> > +static int
> > +qemuDomainGetStatsCache(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
> > +virDomainObjPtr dom,
> > +virDomainStatsRecordPtr record,
> > +int *maxparams,
> > +unsigned int privflags ATTRIBUTE_UNUSED) {
> > +qemuDomainObjPrivatePtr priv = dom->privateData;
> > +FILE *fd;
> > +unsigned long long cache = 0;
> > +int scaling_factor = 0;
> > +
> > +if (priv->cmt_fd <= 0)
> 
> Shouldn't this only check for cmt_fd < 0?
> 
> > +return -1;
> > +
> > +if (read(priv->cmt_fd, &cache, sizeof(uint64_t)) < 0) {
> 
> Shouldn't cache be declared as uint64_t then?
> 
> > +virReportSystemError(errno, "%s",
> > + _("Unable to read cache data"));
> > +return -1;
> > +}
> > +
> > +fd = fopen("/sys/devices/intel_cqm/events/llc_occupancy.scale", "r");
> > +if (!fd) {
> > +virReportSystemError(errno, "%s",
> > + _("Unable to open CMT scale file"));
> > +return -1;
> > +}
> > +if (fscanf(fd, "%d", &scaling_factor) != 1) {
> > +virReportSystemError(errno, "%s",
> > + _("Unable to read CMT scale file"));
> > +VIR_FORCE_FCLOSE(fd);
> > +return -1;
> > +}
> > +VIR_FORCE_FCLOSE(fd);
> > +
> > +cache *= scaling_factor;
> > +
> > +if (virTypedParamsAddULLong(&record->params,
> > +&record->nparams,
> > +maxparams,
> > +"cache.current",
> > +cache) < 0)
> 
> Any documentation of this new statistics is missing. The commit message
> doesn't really help understanding it either.
> 
> > +return -1;
> > +
> > +return 0;
> > +}
> > +
> >  typedef int
> >  (*qemuDomainGetStatsFunc)(virQEMUDriverPtr driver,
> >virDomainObjPtr dom, @@ -19340,6 +19387,7
> > @@ static struct qemuDomainGetStatsWorker qemuDomainGetStatsWorkers[]
> = {
> >  { qemuDomainGetStatsVcpu, VIR_DOMAIN_STATS_VCPU, false },
> >  { qemuDomainGetStatsInterface, VIR_DOMAIN_STATS_INTERFACE, false }

Re: [libvirt] Entering freeze for libvirt-1.2.21

2015-10-31 Thread Daniel Veillard
On Sat, Oct 31, 2015 at 11:40:22AM +0100, Guido Günther wrote:
> Hi Daniel,
> On Sat, Oct 31, 2015 at 02:01:54PM +0800, Daniel Veillard wrote:
> >   Hi Guido,
> > 
> > On Fri, Oct 30, 2015 at 10:00:41PM +0100, Guido Günther wrote:
> > > On Thu, Oct 29, 2015 at 03:28:51PM +0800, Daniel Veillard wrote:
> > > >   As pointed our on Tuesday it's time for a new release. I have tagged
> > > > the release candidate 1 in git and pushed signed tarball and rpms to
> > > > the usual place at:
> > > > 
> > > >ftp://libvirt.org/libvirt/
> > > > 
> > > >   Based on my limited testing this works just fine, but that's very 
> > > > limited
> > > > and doesn't test portability at all, so please give it a try !
> > > 
> > > I'm having trouble verifying the signature:
> > > 
> > > $ gpg --verify libvirt-1.2.21-rc1.tar.gz.pgp libvirt-1.2.21-rc1.tar.gz
> > > gpg: Signature made Do 29 Okt 2015 07:41:52 CET
> > > gpg:using DSA key 0x4606B8A5DE95BC1F
> > > gpg: please do a --check-trustdb
> > > gpg: BAD signature from "Daniel Veillard (Red Hat work email) 
> > > " [unknown]
> > > 
> > > while verifying e.g. 1.2.20 works as expected.
> > 
> >   Hum, where is libvirt-1.2.21-rc1.tar.gz.pgp coming from ? I only uploaded
> > libvirt-1.2.21-rc1.tar.gz.asc !
> 
> It's the same file. Debian's uscan just renames it after download.
> 
> > 
> >   that said indeed there is an issue with rc1 signing ...
> > 
> > [root@libvirt libvirt]# gpg2 --keyserver hkp://pgp.mit.edu --recv-keys 
> > DE95BC1Fgpg: requesting key DE95BC1F from hkp server pgp.mit.edu
> > gpg: /root/.gnupg/trustdb.gpg: trustdb created
> > gpg: key DE95BC1F: public key "Daniel Veillard (Red Hat work email) 
> > " imported
> > gpg: no ultimately trusted keys found
> > gpg: Total number processed: 1
> > gpg:   imported: 1
> > [root@libvirt libvirt]# gpg --verify libvirt-1.2.20.tar.gz.asc 
> > libvirt-1.2.20.tar.gz
> > gpg: Signature made Fri 02 Oct 2015 01:12:08 PM CEST using DSA key ID 
> > DE95BC1F
> > gpg: Good signature from "Daniel Veillard (Red Hat work email) 
> > "
> > gpg: aka "Daniel Veillard "
> > gpg: WARNING: This key is not certified with a trusted signature!
> > gpg:  There is no indication that the signature belongs to the 
> > owner.
> > Primary key fingerprint: C744 15BA 7C9C 7F78 F02E  1DC3 4606 B8A5 DE95 BC1F
> > [root@libvirt libvirt]# gpg --verify libvirt-1.2.21-rc1.tar.gz.asc 
> > libvirt-1.2.21-rc1.tar.gz
> > gpg: Signature made Thu 29 Oct 2015 07:41:52 AM CET using DSA key ID 
> > DE95BC1F
> > gpg: BAD signature from "Daniel Veillard (Red Hat work email) 
> > "
> > [root@libvirt libvirt]#
> > 
> >   I verified, the libvirt-1.2.21-rc1.tar.gz.asc present on libvirt server is
> > the same that I have left in my working dir of the machine where I assembled
> > the release.
> >   On the other hand libvirt-1.2.21-rc1.tar.gz diverges
> > 
> > thinkpad2:~/libvirt -> sha256sum libvirt-1.2.21-rc1.tar.gz
> > 3cc9f2882a145562ee41b8369a8c3d1cb0f383fe13c3e39ac923f712bf8614d0  
> > libvirt-1.2.21-rc1.tar.gz
> > thinkpad2:~/libvirt ->
> > 
> > and 
> > 
> > [root@libvirt libvirt]# sha256sum libvirt-1.2.21-rc1.tar.gz
> > 00cce64d4eb906f294921effab7b0128dbded46da614f9d88681abdb80af0ae2  
> > libvirt-1.2.21-rc1.tar.gz
> > [root@libvirt libvirt]# 
> > 
> >   I remember that I interrupted the rsync when pushing the release and 
> > restarted
> > it this may have introduced that divergence, I reuploaded the rc1:
> > 
> > [root@libvirt libvirt]# sha256sum libvirt-1.2.21-rc1.tar.gz
> > 3cc9f2882a145562ee41b8369a8c3d1cb0f383fe13c3e39ac923f712bf8614d0  
> > libvirt-1.2.21-rc1.tar.gz
> > [root@libvirt libvirt]# sha256sum libvirt-1.2.21-rc1.tar.gz.asc
> > 9bfb1fe53c5d1457d5bc6a4f7ce4661ad925210f9ab2708bd0c523accf16f5e5  
> > libvirt-1.2.21-rc1.tar.gz.asc
> > [root@libvirt libvirt]# gpg --verify libvirt-1.2.21-rc1.tar.gz.asc 
> > libvirt-1.2.21-rc1.tar.gz
> > gpg: Signature made Thu 29 Oct 2015 07:41:52 AM CET using DSA key ID 
> > DE95BC1F
> > gpg: Good signature from "Daniel Veillard (Red Hat work email) 
> > "
> > gpg: aka "Daniel Veillard "
> > gpg: WARNING: This key is not certified with a trusted signature!
> > gpg:  There is no indication that the signature belongs to the 
> > owner.
> > Primary key fingerprint: C744 15BA 7C9C 7F78 F02E  1DC3 4606 B8A5 DE95 BC1F
> > [root@libvirt libvirt]# 
> > 
> >   and that version is fine,
> 
> Indeed. With the new tarball it verifies correctly. Thanks!

 Good, and after verifications the old one was really broken:

thinkpad2:/tmp -> tar xvzf libvirt-1.2.21-rc1.tar.gz.broken

libvirt-1.2.21/po/hi.po

gzip: stdin: unexpected end of file
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
thinkpad2:/tmp ->

  So it's a case of restarting an rsync -P after an user interruption where
the copied file ends up being corrupted, there is a bug somewhere but nothing
malicious :-)

Daniel

> Cheers,
>  -- Guido
> 
> 

Re: [libvirt] Entering freeze for libvirt-1.2.21

2015-10-31 Thread Guido Günther
Hi Daniel,
On Sat, Oct 31, 2015 at 02:01:54PM +0800, Daniel Veillard wrote:
>   Hi Guido,
> 
> On Fri, Oct 30, 2015 at 10:00:41PM +0100, Guido Günther wrote:
> > On Thu, Oct 29, 2015 at 03:28:51PM +0800, Daniel Veillard wrote:
> > >   As pointed our on Tuesday it's time for a new release. I have tagged
> > > the release candidate 1 in git and pushed signed tarball and rpms to
> > > the usual place at:
> > > 
> > >ftp://libvirt.org/libvirt/
> > > 
> > >   Based on my limited testing this works just fine, but that's very 
> > > limited
> > > and doesn't test portability at all, so please give it a try !
> > 
> > I'm having trouble verifying the signature:
> > 
> > $ gpg --verify libvirt-1.2.21-rc1.tar.gz.pgp libvirt-1.2.21-rc1.tar.gz
> > gpg: Signature made Do 29 Okt 2015 07:41:52 CET
> > gpg:using DSA key 0x4606B8A5DE95BC1F
> > gpg: please do a --check-trustdb
> > gpg: BAD signature from "Daniel Veillard (Red Hat work email) 
> > " [unknown]
> > 
> > while verifying e.g. 1.2.20 works as expected.
> 
>   Hum, where is libvirt-1.2.21-rc1.tar.gz.pgp coming from ? I only uploaded
> libvirt-1.2.21-rc1.tar.gz.asc !

It's the same file. Debian's uscan just renames it after download.

> 
>   that said indeed there is an issue with rc1 signing ...
> 
> [root@libvirt libvirt]# gpg2 --keyserver hkp://pgp.mit.edu --recv-keys 
> DE95BC1Fgpg: requesting key DE95BC1F from hkp server pgp.mit.edu
> gpg: /root/.gnupg/trustdb.gpg: trustdb created
> gpg: key DE95BC1F: public key "Daniel Veillard (Red Hat work email) 
> " imported
> gpg: no ultimately trusted keys found
> gpg: Total number processed: 1
> gpg:   imported: 1
> [root@libvirt libvirt]# gpg --verify libvirt-1.2.20.tar.gz.asc 
> libvirt-1.2.20.tar.gz
> gpg: Signature made Fri 02 Oct 2015 01:12:08 PM CEST using DSA key ID DE95BC1F
> gpg: Good signature from "Daniel Veillard (Red Hat work email) 
> "
> gpg: aka "Daniel Veillard "
> gpg: WARNING: This key is not certified with a trusted signature!
> gpg:  There is no indication that the signature belongs to the owner.
> Primary key fingerprint: C744 15BA 7C9C 7F78 F02E  1DC3 4606 B8A5 DE95 BC1F
> [root@libvirt libvirt]# gpg --verify libvirt-1.2.21-rc1.tar.gz.asc 
> libvirt-1.2.21-rc1.tar.gz
> gpg: Signature made Thu 29 Oct 2015 07:41:52 AM CET using DSA key ID DE95BC1F
> gpg: BAD signature from "Daniel Veillard (Red Hat work email) 
> "
> [root@libvirt libvirt]#
> 
>   I verified, the libvirt-1.2.21-rc1.tar.gz.asc present on libvirt server is
> the same that I have left in my working dir of the machine where I assembled
> the release.
>   On the other hand libvirt-1.2.21-rc1.tar.gz diverges
> 
> thinkpad2:~/libvirt -> sha256sum libvirt-1.2.21-rc1.tar.gz
> 3cc9f2882a145562ee41b8369a8c3d1cb0f383fe13c3e39ac923f712bf8614d0  
> libvirt-1.2.21-rc1.tar.gz
> thinkpad2:~/libvirt ->
> 
> and 
> 
> [root@libvirt libvirt]# sha256sum libvirt-1.2.21-rc1.tar.gz
> 00cce64d4eb906f294921effab7b0128dbded46da614f9d88681abdb80af0ae2  
> libvirt-1.2.21-rc1.tar.gz
> [root@libvirt libvirt]# 
> 
>   I remember that I interrupted the rsync when pushing the release and 
> restarted
> it this may have introduced that divergence, I reuploaded the rc1:
> 
> [root@libvirt libvirt]# sha256sum libvirt-1.2.21-rc1.tar.gz
> 3cc9f2882a145562ee41b8369a8c3d1cb0f383fe13c3e39ac923f712bf8614d0  
> libvirt-1.2.21-rc1.tar.gz
> [root@libvirt libvirt]# sha256sum libvirt-1.2.21-rc1.tar.gz.asc
> 9bfb1fe53c5d1457d5bc6a4f7ce4661ad925210f9ab2708bd0c523accf16f5e5  
> libvirt-1.2.21-rc1.tar.gz.asc
> [root@libvirt libvirt]# gpg --verify libvirt-1.2.21-rc1.tar.gz.asc 
> libvirt-1.2.21-rc1.tar.gz
> gpg: Signature made Thu 29 Oct 2015 07:41:52 AM CET using DSA key ID DE95BC1F
> gpg: Good signature from "Daniel Veillard (Red Hat work email) 
> "
> gpg: aka "Daniel Veillard "
> gpg: WARNING: This key is not certified with a trusted signature!
> gpg:  There is no indication that the signature belongs to the owner.
> Primary key fingerprint: C744 15BA 7C9C 7F78 F02E  1DC3 4606 B8A5 DE95 BC1F
> [root@libvirt libvirt]# 
> 
>   and that version is fine,

Indeed. With the new tarball it verifies correctly. Thanks!

Cheers,
 -- Guido

> 
>thanks for the heads-up !
> 
> Daniel
> 
> -- 
> Daniel Veillard  | Open Source and Standards, Red Hat
> veill...@redhat.com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
> http://veillard.com/ | virtualization library  http://libvirt.org/
> 

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


[libvirt] [python PATCH] fix crash introduced by commit 1d39dbaf

2015-10-31 Thread Pavel Hrdina
Some of the libvirt_*Wrap functions steals the reference and we need to
set the item in array to NULL no not free it on success.  Those three
places was accidentally removed by commit 1d39dbaf.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1270977

Signed-off-by: Pavel Hrdina 
---

Pushed as fix for critical crasher.

 libvirt-override.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libvirt-override.c b/libvirt-override.c
index c6c1da8..5f1c98f 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -2448,6 +2448,7 @@ libvirt_virDomainListAllSnapshots(PyObject *self 
ATTRIBUTE_UNUSED,
 for (i = 0; i < c_retval; i++) {
 VIR_PY_LIST_SET_GOTO(py_retval, i,
  libvirt_virDomainSnapshotPtrWrap(snaps[i]), 
error);
+snaps[i] = NULL;
 }
 
  cleanup:
@@ -2544,9 +2545,11 @@ libvirt_virDomainSnapshotListAllChildren(PyObject *self 
ATTRIBUTE_UNUSED,
 if (!(py_retval = PyList_New(c_retval)))
 goto cleanup;
 
-for (i = 0; i < c_retval; i++)
+for (i = 0; i < c_retval; i++) {
 VIR_PY_LIST_SET_GOTO(py_retval, i,
  libvirt_virDomainSnapshotPtrWrap(snaps[i]), 
error);
+snaps[i] = NULL;
+}
 
  cleanup:
 for (i = 0; i < c_retval; i++)
@@ -3117,9 +3120,11 @@ libvirt_virConnectListAllNetworks(PyObject *self 
ATTRIBUTE_UNUSED,
 if (!(py_retval = PyList_New(c_retval)))
 goto cleanup;
 
-for (i = 0; i < c_retval; i++)
+for (i = 0; i < c_retval; i++) {
 VIR_PY_LIST_SET_GOTO(py_retval, i,
  libvirt_virNetworkPtrWrap(nets[i]), error);
+nets[i] = NULL;
+}
 
  cleanup:
 for (i = 0; i < c_retval; i++)
-- 
2.6.2

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