[libvirt] [PATCH 08/10] tests: qemucapabilities: Test commands used to query capabilities

Peter Krempa posted 10 patches 6 years, 11 months ago
[libvirt] [PATCH 08/10] tests: qemucapabilities: Test commands used to query capabilities
Posted by Peter Krempa 6 years, 11 months ago
Use qemuMonitorTestNewFromFileFull which allows to test commands used
along with providing replies. This has two advantages:

1) It's easier to see which command was used when looking at the files
2) We check that the used commands are actually in the correct order

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 tests/qemucapabilitiestest.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c
index 6981e973a6..633389f263 100644
--- a/tests/qemucapabilitiestest.c
+++ b/tests/qemucapabilitiestest.c
@@ -32,7 +32,7 @@
 typedef struct _testQemuData testQemuData;
 typedef testQemuData *testQemuDataPtr;
 struct _testQemuData {
-    virDomainXMLOptionPtr xmlopt;
+    virQEMUDriver driver;
     const char *archName;
     const char *base;
 };
@@ -42,7 +42,7 @@ static int
 testQemuCaps(const void *opaque)
 {
     int ret = -1;
-    const testQemuData *data = opaque;
+    testQemuData *data = (void *) opaque;
     char *repliesFile = NULL;
     char *capsFile = NULL;
     qemuMonitorTestPtr mon = NULL;
@@ -55,7 +55,7 @@ testQemuCaps(const void *opaque)
                     abs_srcdir, data->base, data->archName) < 0)
         goto cleanup;

-    if (!(mon = qemuMonitorTestNewFromFile(repliesFile, data->xmlopt, false)))
+    if (!(mon = qemuMonitorTestNewFromFileFull(repliesFile, &data->driver, NULL)))
         goto cleanup;

     if (!(capsActual = virQEMUCapsNew()) ||
@@ -139,7 +139,6 @@ static int
 mymain(void)
 {
     int ret = 0;
-    virQEMUDriver driver;
     testQemuData data;

 #if !WITH_YAJL
@@ -148,13 +147,11 @@ mymain(void)
 #endif

     if (virThreadInitialize() < 0 ||
-        qemuTestDriverInit(&driver) < 0)
+        qemuTestDriverInit(&data.driver) < 0)
         return EXIT_FAILURE;

     virEventRegisterDefaultImpl();

-    data.xmlopt = driver.xmlopt;
-
 #define DO_TEST(arch, name) \
     do { \
         data.archName = arch; \
@@ -200,7 +197,7 @@ mymain(void)
      * "tests/qemucapsfixreplies foo.replies" to fix the replies ids.
      */

-    qemuTestDriverFree(&driver);
+    qemuTestDriverFree(&data.driver);

     return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
-- 
2.16.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 08/10] tests: qemucapabilities: Test commands used to query capabilities
Posted by John Ferlan 6 years, 11 months ago

On 06/04/2018 09:58 AM, Peter Krempa wrote:
> Use qemuMonitorTestNewFromFileFull which allows to test commands used
> along with providing replies. This has two advantages:
> 
> 1) It's easier to see which command was used when looking at the files
> 2) We check that the used commands are actually in the correct order
> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>  tests/qemucapabilitiestest.c | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
> 

With top of tree this one fails make check, but I assume that has to do
with changes in files since you posted... perhaps it's a combo of this
and the previous patch.

So I'll stop here and wait to see how things work themselves out.

John

> diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c
> index 6981e973a6..633389f263 100644
> --- a/tests/qemucapabilitiestest.c
> +++ b/tests/qemucapabilitiestest.c
> @@ -32,7 +32,7 @@
>  typedef struct _testQemuData testQemuData;
>  typedef testQemuData *testQemuDataPtr;
>  struct _testQemuData {
> -    virDomainXMLOptionPtr xmlopt;
> +    virQEMUDriver driver;
>      const char *archName;
>      const char *base;
>  };
> @@ -42,7 +42,7 @@ static int
>  testQemuCaps(const void *opaque)
>  {
>      int ret = -1;
> -    const testQemuData *data = opaque;
> +    testQemuData *data = (void *) opaque;
>      char *repliesFile = NULL;
>      char *capsFile = NULL;
>      qemuMonitorTestPtr mon = NULL;
> @@ -55,7 +55,7 @@ testQemuCaps(const void *opaque)
>                      abs_srcdir, data->base, data->archName) < 0)
>          goto cleanup;
> 
> -    if (!(mon = qemuMonitorTestNewFromFile(repliesFile, data->xmlopt, false)))
> +    if (!(mon = qemuMonitorTestNewFromFileFull(repliesFile, &data->driver, NULL)))
>          goto cleanup;
> 
>      if (!(capsActual = virQEMUCapsNew()) ||
> @@ -139,7 +139,6 @@ static int
>  mymain(void)
>  {
>      int ret = 0;
> -    virQEMUDriver driver;
>      testQemuData data;
> 
>  #if !WITH_YAJL
> @@ -148,13 +147,11 @@ mymain(void)
>  #endif
> 
>      if (virThreadInitialize() < 0 ||
> -        qemuTestDriverInit(&driver) < 0)
> +        qemuTestDriverInit(&data.driver) < 0)
>          return EXIT_FAILURE;
> 
>      virEventRegisterDefaultImpl();
> 
> -    data.xmlopt = driver.xmlopt;
> -
>  #define DO_TEST(arch, name) \
>      do { \
>          data.archName = arch; \
> @@ -200,7 +197,7 @@ mymain(void)
>       * "tests/qemucapsfixreplies foo.replies" to fix the replies ids.
>       */
> 
> -    qemuTestDriverFree(&driver);
> +    qemuTestDriverFree(&data.driver);
> 
>      return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
>  }
> 

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 08/10] tests: qemucapabilities: Test commands used to query capabilities
Posted by Peter Krempa 6 years, 11 months ago
On Thu, Jun 07, 2018 at 22:02:06 -0400, John Ferlan wrote:
> 
> 
> On 06/04/2018 09:58 AM, Peter Krempa wrote:
> > Use qemuMonitorTestNewFromFileFull which allows to test commands used
> > along with providing replies. This has two advantages:
> > 
> > 1) It's easier to see which command was used when looking at the files
> > 2) We check that the used commands are actually in the correct order
> > 
> > Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> > ---
> >  tests/qemucapabilitiestest.c | 13 +++++--------
> >  1 file changed, 5 insertions(+), 8 deletions(-)
> > 
> 
> With top of tree this one fails make check, but I assume that has to do
> with changes in files since you posted... perhaps it's a combo of this
> and the previous patch.

Well, it's probably because you also need the next patch (which is
supposed to be squashed into this one) for the tests to pass. I've
separatet it because all the changes were generated by the regeneration
tool. 
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 08/10] tests: qemucapabilities: Test commands used to query capabilities
Posted by John Ferlan 6 years, 11 months ago

On 06/08/2018 03:45 AM, Peter Krempa wrote:
> On Thu, Jun 07, 2018 at 22:02:06 -0400, John Ferlan wrote:
>>
>>
>> On 06/04/2018 09:58 AM, Peter Krempa wrote:
>>> Use qemuMonitorTestNewFromFileFull which allows to test commands used
>>> along with providing replies. This has two advantages:
>>>
>>> 1) It's easier to see which command was used when looking at the files
>>> 2) We check that the used commands are actually in the correct order
>>>
>>> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
>>> ---
>>>  tests/qemucapabilitiestest.c | 13 +++++--------
>>>  1 file changed, 5 insertions(+), 8 deletions(-)
>>>
>>
>> With top of tree this one fails make check, but I assume that has to do
>> with changes in files since you posted... perhaps it's a combo of this
>> and the previous patch.
> 
> Well, it's probably because you also need the next patch (which is
> supposed to be squashed into this one) for the tests to pass. I've
> separatet it because all the changes were generated by the regeneration
> tool. 
> 
Ah, right, I see.

Anyway, I figured Martin's patches would change the results here.
There's also the SEV patches that have capability changes which bring up
a few ordering concerns in which it may be "easier" if these last couple
of patches waited for at least the SEV ones to be merged. From recent
reviews, I'm aware of 2 other series that are perhaps impacted (Erik's
"Enable vfio-pci 'property' for mediated devices" which perhaps just
needs a v2 and Jie Wang's "Introduce align for hostmem-file", but that
one is not close to being ready yet). While I understand ordering and
merges are someone else's problem - still need to play nice though
especially if there's any back port concerns 0-).

BTW: Should we take this "opportunity" to finally update the 2.12 files
to the released version rather than the rc0 version? (only s390x got a
final update).

As for the changes themselves, consider both patch 8 and 9,

Reviewed-by: John Ferlan <jferlan@redhat.com>

as long as the commit message is cleaned up a bit.

John

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