Re: [libvirt] [PATCH 4/4] test_driver: implement virDomainGetIOThreadInfo

2019-07-26 Thread Erik Skultety
On Fri, Jul 26, 2019 at 12:55:20PM +0200, Ilias Stamatis wrote:
> On Thu, Jul 25, 2019 at 5:43 PM Erik Skultety  wrote:
> >
> > On Tue, Jul 23, 2019 at 12:17:57PM +0200, Ilias Stamatis wrote:
> > > Signed-off-by: Ilias Stamatis 
> > > ---
> > >  src/test/test_driver.c | 74 ++
> > >  1 file changed, 74 insertions(+)
> > >
> > > diff --git a/src/test/test_driver.c b/src/test/test_driver.c
> > > index 47e28a01ec..4c6f3db8de 100644
> > > --- a/src/test/test_driver.c
> > > +++ b/src/test/test_driver.c
> > > @@ -2774,6 +2774,79 @@ testDomainPinIOThread(virDomainPtr dom,
> > >  }
> > >
> > >
> > > +static int
> > > +testDomainGetIOThreadInfo(virDomainPtr dom,
> > > +  virDomainIOThreadInfoPtr **info,
> > > +  unsigned int flags)
> > > +{
> > > +virDomainObjPtr vm = NULL;
> > > +virDomainDefPtr def = NULL;
> > > +virBitmapPtr cpumask = NULL;
> > > +virBitmapPtr bitmap = NULL;
> > > +virDomainIOThreadInfoPtr *info_ret = NULL;
> > > +size_t i;
> > > +int hostcpus;
> > > +int ret = -1;
> > > +
> > > +virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
> > > +  VIR_DOMAIN_AFFECT_CONFIG, -1);
> > > +
> > > +if (!(vm = testDomObjFromDomain(dom)))
> > > +goto cleanup;
> > > +
> > > +if (!(def = virDomainObjGetOneDef(vm, flags)))
> > > +goto cleanup;
> > > +
> > > +if (def->niothreadids == 0)
> > > +return 0;
> >
> > ^This will leave the object locked, so once you do Info, anything else after
> > that will deadlock, so goto is needed.
> >
> > Erik
>
> Of course... I don't know how I missed that. I guess I don't need to
> re-send it though only for this change?

No need, this can go straight in, I still need to look more closely on the
iothread deletion API though.

so for this one:
Reviewed-by: Erik Skultety 

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


Re: [libvirt] [PATCH 4/4] test_driver: implement virDomainGetIOThreadInfo

2019-07-26 Thread Ilias Stamatis
On Thu, Jul 25, 2019 at 5:43 PM Erik Skultety  wrote:
>
> On Tue, Jul 23, 2019 at 12:17:57PM +0200, Ilias Stamatis wrote:
> > Signed-off-by: Ilias Stamatis 
> > ---
> >  src/test/test_driver.c | 74 ++
> >  1 file changed, 74 insertions(+)
> >
> > diff --git a/src/test/test_driver.c b/src/test/test_driver.c
> > index 47e28a01ec..4c6f3db8de 100644
> > --- a/src/test/test_driver.c
> > +++ b/src/test/test_driver.c
> > @@ -2774,6 +2774,79 @@ testDomainPinIOThread(virDomainPtr dom,
> >  }
> >
> >
> > +static int
> > +testDomainGetIOThreadInfo(virDomainPtr dom,
> > +  virDomainIOThreadInfoPtr **info,
> > +  unsigned int flags)
> > +{
> > +virDomainObjPtr vm = NULL;
> > +virDomainDefPtr def = NULL;
> > +virBitmapPtr cpumask = NULL;
> > +virBitmapPtr bitmap = NULL;
> > +virDomainIOThreadInfoPtr *info_ret = NULL;
> > +size_t i;
> > +int hostcpus;
> > +int ret = -1;
> > +
> > +virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
> > +  VIR_DOMAIN_AFFECT_CONFIG, -1);
> > +
> > +if (!(vm = testDomObjFromDomain(dom)))
> > +goto cleanup;
> > +
> > +if (!(def = virDomainObjGetOneDef(vm, flags)))
> > +goto cleanup;
> > +
> > +if (def->niothreadids == 0)
> > +return 0;
>
> ^This will leave the object locked, so once you do Info, anything else after
> that will deadlock, so goto is needed.
>
> Erik

Of course... I don't know how I missed that. I guess I don't need to
re-send it though only for this change?

Ilias

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


Re: [libvirt] [PATCH 4/4] test_driver: implement virDomainGetIOThreadInfo

2019-07-25 Thread Erik Skultety
On Tue, Jul 23, 2019 at 12:17:57PM +0200, Ilias Stamatis wrote:
> Signed-off-by: Ilias Stamatis 
> ---
>  src/test/test_driver.c | 74 ++
>  1 file changed, 74 insertions(+)
>
> diff --git a/src/test/test_driver.c b/src/test/test_driver.c
> index 47e28a01ec..4c6f3db8de 100644
> --- a/src/test/test_driver.c
> +++ b/src/test/test_driver.c
> @@ -2774,6 +2774,79 @@ testDomainPinIOThread(virDomainPtr dom,
>  }
>
>
> +static int
> +testDomainGetIOThreadInfo(virDomainPtr dom,
> +  virDomainIOThreadInfoPtr **info,
> +  unsigned int flags)
> +{
> +virDomainObjPtr vm = NULL;
> +virDomainDefPtr def = NULL;
> +virBitmapPtr cpumask = NULL;
> +virBitmapPtr bitmap = NULL;
> +virDomainIOThreadInfoPtr *info_ret = NULL;
> +size_t i;
> +int hostcpus;
> +int ret = -1;
> +
> +virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
> +  VIR_DOMAIN_AFFECT_CONFIG, -1);
> +
> +if (!(vm = testDomObjFromDomain(dom)))
> +goto cleanup;
> +
> +if (!(def = virDomainObjGetOneDef(vm, flags)))
> +goto cleanup;
> +
> +if (def->niothreadids == 0)
> +return 0;

^This will leave the object locked, so once you do Info, anything else after
that will deadlock, so goto is needed.

Erik

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


[libvirt] [PATCH 4/4] test_driver: implement virDomainGetIOThreadInfo

2019-07-23 Thread Ilias Stamatis
Signed-off-by: Ilias Stamatis 
---
 src/test/test_driver.c | 74 ++
 1 file changed, 74 insertions(+)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 47e28a01ec..4c6f3db8de 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -2774,6 +2774,79 @@ testDomainPinIOThread(virDomainPtr dom,
 }


+static int
+testDomainGetIOThreadInfo(virDomainPtr dom,
+  virDomainIOThreadInfoPtr **info,
+  unsigned int flags)
+{
+virDomainObjPtr vm = NULL;
+virDomainDefPtr def = NULL;
+virBitmapPtr cpumask = NULL;
+virBitmapPtr bitmap = NULL;
+virDomainIOThreadInfoPtr *info_ret = NULL;
+size_t i;
+int hostcpus;
+int ret = -1;
+
+virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
+  VIR_DOMAIN_AFFECT_CONFIG, -1);
+
+if (!(vm = testDomObjFromDomain(dom)))
+goto cleanup;
+
+if (!(def = virDomainObjGetOneDef(vm, flags)))
+goto cleanup;
+
+if (def->niothreadids == 0)
+return 0;
+
+if ((hostcpus = virHostCPUGetCount()) < 0)
+goto cleanup;
+
+if (VIR_ALLOC_N(info_ret, def->niothreadids) < 0)
+goto cleanup;
+
+for (i = 0; i < def->niothreadids; i++) {
+if (VIR_ALLOC(info_ret[i]) < 0)
+goto cleanup;
+
+info_ret[i]->iothread_id = def->iothreadids[i]->iothread_id;
+
+cpumask = def->iothreadids[i]->cpumask;
+if (!cpumask) {
+if (def->cpumask) {
+cpumask = def->cpumask;
+} else {
+if (!(bitmap = virBitmapNew(hostcpus)))
+goto cleanup;
+virBitmapSetAll(bitmap);
+cpumask = bitmap;
+}
+}
+
+if (virBitmapToData(cpumask, _ret[i]->cpumap,
+_ret[i]->cpumaplen) < 0)
+goto cleanup;
+
+virBitmapFree(bitmap);
+bitmap = NULL;
+}
+
+VIR_STEAL_PTR(*info, info_ret);
+ret = def->niothreadids;
+
+ cleanup:
+if (info_ret) {
+for (i = 0; i < def->niothreadids; i++)
+virDomainIOThreadInfoFree(info_ret[i]);
+VIR_FREE(info_ret);
+}
+virBitmapFree(bitmap);
+virDomainObjEndAPI();
+return ret;
+}
+
+
 static int
 testDomainSetUserPassword(virDomainPtr dom,
   const char *user ATTRIBUTE_UNUSED,
@@ -7916,6 +7989,7 @@ static virHypervisorDriver testHypervisorDriver = {
 .domainAddIOThread = testDomainAddIOThread, /* 5.6.0 */
 .domainDelIOThread = testDomainDelIOThread, /* 5.6.0 */
 .domainPinIOThread = testDomainPinIOThread, /* 5.6.0 */
+.domainGetIOThreadInfo = testDomainGetIOThreadInfo, /* 5.6.0 */
 .domainSetUserPassword = testDomainSetUserPassword, /* 5.6.0 */
 .domainSetVcpus = testDomainSetVcpus, /* 0.1.4 */
 .domainSetVcpusFlags = testDomainSetVcpusFlags, /* 0.8.5 */
--
2.22.0

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