[libvirt] [PATCH] qemu: Move some functions to qemu_capspriv.h

Andrea Bolognani posted 1 patch 7 years ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/1491403317-22780-1-git-send-email-abologna@redhat.com
src/qemu/qemu_capabilities.h | 19 -------------------
src/qemu/qemu_capspriv.h     | 22 ++++++++++++++++++++++
tests/qemuhelptest.c         |  4 ++++
3 files changed, 26 insertions(+), 19 deletions(-)
[libvirt] [PATCH] qemu: Move some functions to qemu_capspriv.h
Posted by Andrea Bolognani 7 years ago
This header file has been created so that we can expose
internal functions to the test suite without making them
public: those in qemu_capabilities.h bearing the comment

  /* Only for use by test suite */

are obvious candidates for being moved over.
---
 src/qemu/qemu_capabilities.h | 19 -------------------
 src/qemu/qemu_capspriv.h     | 22 ++++++++++++++++++++++
 tests/qemuhelptest.c         |  4 ++++
 3 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 24e2f38..cca9a12 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -473,11 +473,6 @@ bool virQEMUCapsIsValid(virQEMUCapsPtr qemuCaps,
 void virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps,
                                     const char *machineType);
 
-/* Only for use by test suite */
-void virQEMUCapsSetGICCapabilities(virQEMUCapsPtr qemuCaps,
-                                   virGICCapability *capabilities,
-                                   size_t ncapabilities);
-
 virQEMUCapsCachePtr virQEMUCapsCacheNew(const char *libDir,
                                         const char *cacheDir,
                                         uid_t uid, gid_t gid);
@@ -499,20 +494,6 @@ int virQEMUCapsGetDefaultVersion(virCapsPtr caps,
                                  virQEMUCapsCachePtr capsCache,
                                  unsigned int *version);
 
-/* Only for use by test suite */
-int virQEMUCapsParseHelpStr(const char *qemu,
-                            const char *str,
-                            virQEMUCapsPtr qemuCaps,
-                            unsigned int *version,
-                            bool *is_kvm,
-                            unsigned int *kvm_version,
-                            bool check_yajl,
-                            const char *qmperr);
-/* Only for use by test suite */
-int virQEMUCapsParseDeviceStr(virQEMUCapsPtr qemuCaps, const char *str);
-/* Only for use by test suite */
-void virQEMUCapsInitQMPBasicArch(virQEMUCapsPtr qemuCaps);
-
 VIR_ENUM_DECL(virQEMUCaps);
 
 bool virQEMUCapsSupportsChardev(const virDomainDef *def,
diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h
index 61ccd45..9818859 100644
--- a/src/qemu/qemu_capspriv.h
+++ b/src/qemu/qemu_capspriv.h
@@ -84,6 +84,9 @@ virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps,
                         virCPUDefPtr cpu);
 
 void
+virQEMUCapsInitQMPBasicArch(virQEMUCapsPtr qemuCaps);
+
+void
 virQEMUCapsSetCPUModelInfo(virQEMUCapsPtr qemuCaps,
                            virDomainVirtType type,
                            qemuMonitorCPUModelInfoPtr modelInfo);
@@ -92,4 +95,23 @@ virCPUDefPtr
 virQEMUCapsProbeHostCPUForEmulator(virCapsPtr caps,
                                    virQEMUCapsPtr qemuCaps,
                                    virDomainVirtType type);
+
+void
+virQEMUCapsSetGICCapabilities(virQEMUCapsPtr qemuCaps,
+                              virGICCapability *capabilities,
+                              size_t ncapabilities);
+
+int
+virQEMUCapsParseHelpStr(const char *qemu,
+                        const char *str,
+                        virQEMUCapsPtr qemuCaps,
+                        unsigned int *version,
+                        bool *is_kvm,
+                        unsigned int *kvm_version,
+                        bool check_yajl,
+                        const char *qmperr);
+
+int
+virQEMUCapsParseDeviceStr(virQEMUCapsPtr qemuCaps,
+                          const char *str);
 #endif
diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
index e3751b2..d80225c 100644
--- a/tests/qemuhelptest.c
+++ b/tests/qemuhelptest.c
@@ -8,6 +8,10 @@
 # include <stdlib.h>
 
 # include "qemu/qemu_capabilities.h"
+# define __QEMU_CAPSPRIV_H_ALLOW__
+# include "qemu/qemu_capspriv.h"
+# undef __QEMU_CAPSPRIV_H_ALLOW__
+
 # include "viralloc.h"
 # include "virstring.h"
 
-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Move some functions to qemu_capspriv.h
Posted by Martin Kletzander 7 years ago
On Wed, Apr 05, 2017 at 04:41:57PM +0200, Andrea Bolognani wrote:
>This header file has been created so that we can expose
>internal functions to the test suite without making them
>public: those in qemu_capabilities.h bearing the comment
>
>  /* Only for use by test suite */
>
>are obvious candidates for being moved over.
>---
> src/qemu/qemu_capabilities.h | 19 -------------------
> src/qemu/qemu_capspriv.h     | 22 ++++++++++++++++++++++
> tests/qemuhelptest.c         |  4 ++++
> 3 files changed, 26 insertions(+), 19 deletions(-)
>
>diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
>index 24e2f38..cca9a12 100644
>--- a/src/qemu/qemu_capabilities.h
>+++ b/src/qemu/qemu_capabilities.h
>@@ -473,11 +473,6 @@ bool virQEMUCapsIsValid(virQEMUCapsPtr qemuCaps,
> void virQEMUCapsFilterByMachineType(virQEMUCapsPtr qemuCaps,
>                                     const char *machineType);
>
>-/* Only for use by test suite */
>-void virQEMUCapsSetGICCapabilities(virQEMUCapsPtr qemuCaps,
>-                                   virGICCapability *capabilities,
>-                                   size_t ncapabilities);
>-
> virQEMUCapsCachePtr virQEMUCapsCacheNew(const char *libDir,
>                                         const char *cacheDir,
>                                         uid_t uid, gid_t gid);
>@@ -499,20 +494,6 @@ int virQEMUCapsGetDefaultVersion(virCapsPtr caps,
>                                  virQEMUCapsCachePtr capsCache,
>                                  unsigned int *version);
>
>-/* Only for use by test suite */
>-int virQEMUCapsParseHelpStr(const char *qemu,
>-                            const char *str,
>-                            virQEMUCapsPtr qemuCaps,
>-                            unsigned int *version,
>-                            bool *is_kvm,
>-                            unsigned int *kvm_version,
>-                            bool check_yajl,
>-                            const char *qmperr);
>-/* Only for use by test suite */
>-int virQEMUCapsParseDeviceStr(virQEMUCapsPtr qemuCaps, const char *str);
>-/* Only for use by test suite */
>-void virQEMUCapsInitQMPBasicArch(virQEMUCapsPtr qemuCaps);
>-
> VIR_ENUM_DECL(virQEMUCaps);
>
> bool virQEMUCapsSupportsChardev(const virDomainDef *def,
>diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h
>index 61ccd45..9818859 100644
>--- a/src/qemu/qemu_capspriv.h
>+++ b/src/qemu/qemu_capspriv.h
>@@ -84,6 +84,9 @@ virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps,
>                         virCPUDefPtr cpu);
>
> void
>+virQEMUCapsInitQMPBasicArch(virQEMUCapsPtr qemuCaps);
>+
>+void
> virQEMUCapsSetCPUModelInfo(virQEMUCapsPtr qemuCaps,
>                            virDomainVirtType type,
>                            qemuMonitorCPUModelInfoPtr modelInfo);
>@@ -92,4 +95,23 @@ virCPUDefPtr
> virQEMUCapsProbeHostCPUForEmulator(virCapsPtr caps,
>                                    virQEMUCapsPtr qemuCaps,
>                                    virDomainVirtType type);
>+
>+void
>+virQEMUCapsSetGICCapabilities(virQEMUCapsPtr qemuCaps,
>+                              virGICCapability *capabilities,
>+                              size_t ncapabilities);
>+
>+int
>+virQEMUCapsParseHelpStr(const char *qemu,
>+                        const char *str,
>+                        virQEMUCapsPtr qemuCaps,
>+                        unsigned int *version,
>+                        bool *is_kvm,
>+                        unsigned int *kvm_version,
>+                        bool check_yajl,
>+                        const char *qmperr);
>+
>+int
>+virQEMUCapsParseDeviceStr(virQEMUCapsPtr qemuCaps,
>+                          const char *str);
> #endif
>diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c
>index e3751b2..d80225c 100644
>--- a/tests/qemuhelptest.c
>+++ b/tests/qemuhelptest.c
>@@ -8,6 +8,10 @@
> # include <stdlib.h>
>
> # include "qemu/qemu_capabilities.h"
>+# define __QEMU_CAPSPRIV_H_ALLOW__
>+# include "qemu/qemu_capspriv.h"
>+# undef __QEMU_CAPSPRIV_H_ALLOW__
>+

We should, ideally, make some global PRIV_ENABLE macro that would be set
in Makefile for all tests.  And all private headers would check that
macro.  We wouldn't need to add these in the tests, and it might
actually be a bit more future-proof.

> # include "viralloc.h"
> # include "virstring.h"
>
>--
>2.7.4
>
>--
>libvir-list mailing list
>libvir-list@redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Move some functions to qemu_capspriv.h
Posted by Andrea Bolognani 7 years ago
On Thu, 2017-04-06 at 10:00 +0200, Martin Kletzander wrote:
> > @@ -8,6 +8,10 @@
> > # include <stdlib.h>
> > 
> > # include "qemu/qemu_capabilities.h"
> > +# define __QEMU_CAPSPRIV_H_ALLOW__
> > +# include "qemu/qemu_capspriv.h"
> > +# undef __QEMU_CAPSPRIV_H_ALLOW__
> > +
> 
> We should, ideally, make some global PRIV_ENABLE macro that would be set
> in Makefile for all tests.  And all private headers would check that
> macro.  We wouldn't need to add these in the tests, and it might
> actually be a bit more future-proof.

I don't necessarily disagree, but I think we have a long
way ahead before something like that can be implemented.

There are a lot of functions that are exposed to everyone
just because we want to test them, and I don't think all
modules have a corresponding private header file. So I'd
work towards that goal first.

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Move some functions to qemu_capspriv.h
Posted by Martin Kletzander 7 years ago
On Thu, Apr 06, 2017 at 11:33:03AM +0200, Andrea Bolognani wrote:
>On Thu, 2017-04-06 at 10:00 +0200, Martin Kletzander wrote:
>> > @@ -8,6 +8,10 @@
>> > # include <stdlib.h>
>> > 
>> > # include "qemu/qemu_capabilities.h"
>> > +# define __QEMU_CAPSPRIV_H_ALLOW__
>> > +# include "qemu/qemu_capspriv.h"
>> > +# undef __QEMU_CAPSPRIV_H_ALLOW__
>> > +
>> 
>> We should, ideally, make some global PRIV_ENABLE macro that would be set
>> in Makefile for all tests.  And all private headers would check that
>> macro.  We wouldn't need to add these in the tests, and it might
>> actually be a bit more future-proof.
>
>I don't necessarily disagree, but I think we have a long
>way ahead before something like that can be implemented.
>
>There are a lot of functions that are exposed to everyone
>just because we want to test them, and I don't think all
>modules have a corresponding private header file. So I'd
>work towards that goal first.
>

I didn't mean to have like a central location for all of them.  Just
have one macro.  Anyway I missed the fact that we need to include them
in the corresponding .c files and that wouldn't work.  So act like I
didn't reply.  The idea in my head sounded really cool, though.

>-- 
>Andrea Bolognani / Red Hat / Virtualization
>
>--
>libvir-list mailing list
>libvir-list@redhat.com
>https://www.redhat.com/mailman/listinfo/libvir-list
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Move some functions to qemu_capspriv.h
Posted by Ján Tomko 7 years ago
On Wed, Apr 05, 2017 at 04:41:57PM +0200, Andrea Bolognani wrote:
>This header file has been created so that we can expose
>internal functions to the test suite without making them
>public: those in qemu_capabilities.h bearing the comment
>
>  /* Only for use by test suite */
>
>are obvious candidates for being moved over.
>---
> src/qemu/qemu_capabilities.h | 19 -------------------
> src/qemu/qemu_capspriv.h     | 22 ++++++++++++++++++++++
> tests/qemuhelptest.c         |  4 ++++
> 3 files changed, 26 insertions(+), 19 deletions(-)
>

ACK

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