[PATCH 5/6] docs: Distribute the XMLs with ACL permission flags for APIs

Peter Krempa posted 6 patches 2 years, 11 months ago
[PATCH 5/6] docs: Distribute the XMLs with ACL permission flags for APIs
Posted by Peter Krempa 2 years, 11 months ago
Similarly to the API XML we can distribute the ACL permissions for the
APIs so that users who are potentially interested into the data don't
have to scrape our web.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---
 docs/meson.build       | 27 +++++++++++++++++++++++++++
 libvirt.spec.in        |  3 +++
 src/access/meson.build | 17 -----------------
 3 files changed, 30 insertions(+), 17 deletions(-)

diff --git a/docs/meson.build b/docs/meson.build
index a90c59866a..08bf75e329 100644
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -168,6 +168,33 @@ docs_lxc_api_xml = docs_api_generated[1]
 docs_qemu_api_xml = docs_api_generated[2]
 docs_admin_api_xml = docs_api_generated[3]

+access_gen_xml = []
+
+foreach name : [ 'remote', 'qemu', 'lxc' ]
+  if name == 'remote'
+    xml_file = 'libvirt_access.xml'
+  else
+    xml_file = 'libvirt_access_@0@.xml'.format(name)
+  endif
+  protocol_file = remote_path / '@0@_protocol.x'.format(name)
+
+  access_gen_xml += custom_target(
+    xml_file,
+    input: protocol_file,
+    output: xml_file,
+    capture: true,
+    command: [
+      gendispatch_prog, '--mode=aclapi', name, name.to_upper(), '@INPUT@',
+    ],
+    install: true,
+    install_dir: pkgdatadir / 'api',
+  )
+endforeach
+
+docs_acl_xml = access_gen_xml[0]
+docs_acl_qemu_xml = access_gen_xml[1]
+docs_acl_lxc_xml = access_gen_xml[2]
+
 docs_programs_groups = [
   { 'name': 'rst2html5', 'prog': [ 'rst2html5', 'rst2html5.py', 'rst2html5-3' ] },
   { 'name': 'rst2man', 'prog': [ 'rst2man', 'rst2man.py', 'rst2man-3' ] },
diff --git a/libvirt.spec.in b/libvirt.spec.in
index e795b98d48..df625a0db4 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -2333,6 +2333,9 @@ exit 0
 %{_datadir}/libvirt/api/libvirt-admin-api.xml
 %{_datadir}/libvirt/api/libvirt-qemu-api.xml
 %{_datadir}/libvirt/api/libvirt-lxc-api.xml
+%{_datadir}/libvirt/api/libvirt_access.xml
+%{_datadir}/libvirt/api/libvirt_access_qemu.xml
+%{_datadir}/libvirt/api/libvirt_access_lxc.xml

 %if %{with_mingw}
 %files -n mingw32-libvirt -f mingw32-libvirt.lang
diff --git a/src/access/meson.build b/src/access/meson.build
index 0b12581dc1..842f37a4b6 100644
--- a/src/access/meson.build
+++ b/src/access/meson.build
@@ -16,19 +16,16 @@ remote_path = meson.project_source_root() / 'src' / 'remote'
 access_gen_headers = []
 access_gen_sources = []
 access_gen_sym = []
-access_gen_xml = []

 foreach name : [ 'remote', 'qemu', 'lxc' ]
   if name == 'remote'
     header_file = 'viraccessapicheck.h'
     source_file = 'viraccessapicheck.c'
     syms_file = 'libvirt_access.syms'
-    xml_file = 'libvirt_access.xml'
   else
     header_file = 'viraccessapicheck@0@.h'.format(name)
     source_file = 'viraccessapicheck@0@.c'.format(name)
     syms_file = 'libvirt_access_@0@.syms'.format(name)
-    xml_file = 'libvirt_access_@0@.xml'.format(name)
   endif
   protocol_file = remote_path / '@0@_protocol.x'.format(name)

@@ -62,22 +59,8 @@ foreach name : [ 'remote', 'qemu', 'lxc' ]
       gendispatch_prog, '--mode=aclsym', name, name.to_upper(), '@INPUT@',
     ]
   )
-
-  access_gen_xml += custom_target(
-    xml_file,
-    input: protocol_file,
-    output: xml_file,
-    capture: true,
-    command: [
-      gendispatch_prog, '--mode=aclapi', name, name.to_upper(), '@INPUT@',
-    ],
-  )
 endforeach

-docs_acl_xml = access_gen_xml[0]
-docs_acl_qemu_xml = access_gen_xml[1]
-docs_acl_lxc_xml = access_gen_xml[2]
-
 if conf.has('WITH_POLKIT')
   access_sources += access_polkit_sources

-- 
2.39.2
Re: [PATCH 5/6] docs: Distribute the XMLs with ACL permission flags for APIs
Posted by Daniel P. Berrangé 2 years, 11 months ago
On Mon, Feb 20, 2023 at 11:47:08AM +0100, Peter Krempa wrote:
> Similarly to the API XML we can distribute the ACL permissions for the
> APIs so that users who are potentially interested into the data don't
> have to scrape our web.

IMHO if we want to expose this to apps, we should be including
the info directly in the API files we already ship, rather than
exporting something new.

> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
>  docs/meson.build       | 27 +++++++++++++++++++++++++++
>  libvirt.spec.in        |  3 +++
>  src/access/meson.build | 17 -----------------
>  3 files changed, 30 insertions(+), 17 deletions(-)

Note the current API XMLs are reported by 'pkg-config' but these
new XML files are not reported, so this change is not complete
in that regard


> diff --git a/docs/meson.build b/docs/meson.build
> index a90c59866a..08bf75e329 100644
> --- a/docs/meson.build
> +++ b/docs/meson.build
> @@ -168,6 +168,33 @@ docs_lxc_api_xml = docs_api_generated[1]
>  docs_qemu_api_xml = docs_api_generated[2]
>  docs_admin_api_xml = docs_api_generated[3]
> 
> +access_gen_xml = []
> +
> +foreach name : [ 'remote', 'qemu', 'lxc' ]
> +  if name == 'remote'
> +    xml_file = 'libvirt_access.xml'
> +  else
> +    xml_file = 'libvirt_access_@0@.xml'.format(name)
> +  endif
> +  protocol_file = remote_path / '@0@_protocol.x'.format(name)
> +
> +  access_gen_xml += custom_target(
> +    xml_file,
> +    input: protocol_file,
> +    output: xml_file,
> +    capture: true,
> +    command: [
> +      gendispatch_prog, '--mode=aclapi', name, name.to_upper(), '@INPUT@',
> +    ],
> +    install: true,
> +    install_dir: pkgdatadir / 'api',
> +  )
> +endforeach
> +
> +docs_acl_xml = access_gen_xml[0]
> +docs_acl_qemu_xml = access_gen_xml[1]
> +docs_acl_lxc_xml = access_gen_xml[2]
> +
>  docs_programs_groups = [
>    { 'name': 'rst2html5', 'prog': [ 'rst2html5', 'rst2html5.py', 'rst2html5-3' ] },
>    { 'name': 'rst2man', 'prog': [ 'rst2man', 'rst2man.py', 'rst2man-3' ] },
> diff --git a/libvirt.spec.in b/libvirt.spec.in
> index e795b98d48..df625a0db4 100644
> --- a/libvirt.spec.in
> +++ b/libvirt.spec.in
> @@ -2333,6 +2333,9 @@ exit 0
>  %{_datadir}/libvirt/api/libvirt-admin-api.xml
>  %{_datadir}/libvirt/api/libvirt-qemu-api.xml
>  %{_datadir}/libvirt/api/libvirt-lxc-api.xml
> +%{_datadir}/libvirt/api/libvirt_access.xml
> +%{_datadir}/libvirt/api/libvirt_access_qemu.xml
> +%{_datadir}/libvirt/api/libvirt_access_lxc.xml
> 
>  %if %{with_mingw}
>  %files -n mingw32-libvirt -f mingw32-libvirt.lang
> diff --git a/src/access/meson.build b/src/access/meson.build
> index 0b12581dc1..842f37a4b6 100644
> --- a/src/access/meson.build
> +++ b/src/access/meson.build
> @@ -16,19 +16,16 @@ remote_path = meson.project_source_root() / 'src' / 'remote'
>  access_gen_headers = []
>  access_gen_sources = []
>  access_gen_sym = []
> -access_gen_xml = []
> 
>  foreach name : [ 'remote', 'qemu', 'lxc' ]
>    if name == 'remote'
>      header_file = 'viraccessapicheck.h'
>      source_file = 'viraccessapicheck.c'
>      syms_file = 'libvirt_access.syms'
> -    xml_file = 'libvirt_access.xml'
>    else
>      header_file = 'viraccessapicheck@0@.h'.format(name)
>      source_file = 'viraccessapicheck@0@.c'.format(name)
>      syms_file = 'libvirt_access_@0@.syms'.format(name)
> -    xml_file = 'libvirt_access_@0@.xml'.format(name)
>    endif
>    protocol_file = remote_path / '@0@_protocol.x'.format(name)
> 
> @@ -62,22 +59,8 @@ foreach name : [ 'remote', 'qemu', 'lxc' ]
>        gendispatch_prog, '--mode=aclsym', name, name.to_upper(), '@INPUT@',
>      ]
>    )
> -
> -  access_gen_xml += custom_target(
> -    xml_file,
> -    input: protocol_file,
> -    output: xml_file,
> -    capture: true,
> -    command: [
> -      gendispatch_prog, '--mode=aclapi', name, name.to_upper(), '@INPUT@',
> -    ],
> -  )
>  endforeach
> 
> -docs_acl_xml = access_gen_xml[0]
> -docs_acl_qemu_xml = access_gen_xml[1]
> -docs_acl_lxc_xml = access_gen_xml[2]
> -
>  if conf.has('WITH_POLKIT')
>    access_sources += access_polkit_sources
> 
> -- 
> 2.39.2
> 

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
Re: [PATCH 5/6] docs: Distribute the XMLs with ACL permission flags for APIs
Posted by Peter Krempa 2 years, 11 months ago
On Mon, Feb 20, 2023 at 17:05:31 +0000, Daniel P. Berrangé wrote:
> On Mon, Feb 20, 2023 at 11:47:08AM +0100, Peter Krempa wrote:
> > Similarly to the API XML we can distribute the ACL permissions for the
> > APIs so that users who are potentially interested into the data don't
> > have to scrape our web.
> 
> IMHO if we want to expose this to apps, we should be including
> the info directly in the API files we already ship, rather than
> exporting something new.

Yeah, I thought the same but didn't really fancy changing the generator
as they are partially generated by gendispatch rather than the ACL
generator as the information is in the protocol headers rather than with
the function headers.

I can drop this patch for now as the series works well without.
Re: [PATCH 5/6] docs: Distribute the XMLs with ACL permission flags for APIs
Posted by Daniel P. Berrangé 2 years, 11 months ago
On Mon, Feb 20, 2023 at 06:11:41PM +0100, Peter Krempa wrote:
> On Mon, Feb 20, 2023 at 17:05:31 +0000, Daniel P. Berrangé wrote:
> > On Mon, Feb 20, 2023 at 11:47:08AM +0100, Peter Krempa wrote:
> > > Similarly to the API XML we can distribute the ACL permissions for the
> > > APIs so that users who are potentially interested into the data don't
> > > have to scrape our web.
> > 
> > IMHO if we want to expose this to apps, we should be including
> > the info directly in the API files we already ship, rather than
> > exporting something new.
> 
> Yeah, I thought the same but didn't really fancy changing the generator
> as they are partially generated by gendispatch rather than the ACL
> generator as the information is in the protocol headers rather than with
> the function headers.

Rather than change the python generator, it would be possible to use
an XSL transform to merge the ACL XML info  into the main API info
doc. Whether that's better or not of course depends how much you
enjoy working with XSL :-)

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

Re: [PATCH 5/6] docs: Distribute the XMLs with ACL permission flags for APIs
Posted by Peter Krempa 2 years, 11 months ago
On Mon, Feb 20, 2023 at 17:13:24 +0000, Daniel P. Berrangé wrote:
> On Mon, Feb 20, 2023 at 06:11:41PM +0100, Peter Krempa wrote:
> > On Mon, Feb 20, 2023 at 17:05:31 +0000, Daniel P. Berrangé wrote:
> > > On Mon, Feb 20, 2023 at 11:47:08AM +0100, Peter Krempa wrote:
> > > > Similarly to the API XML we can distribute the ACL permissions for the
> > > > APIs so that users who are potentially interested into the data don't
> > > > have to scrape our web.
> > > 
> > > IMHO if we want to expose this to apps, we should be including
> > > the info directly in the API files we already ship, rather than
> > > exporting something new.
> > 
> > Yeah, I thought the same but didn't really fancy changing the generator
> > as they are partially generated by gendispatch rather than the ACL
> > generator as the information is in the protocol headers rather than with
> > the function headers.
> 
> Rather than change the python generator, it would be possible to use
> an XSL transform to merge the ACL XML info  into the main API info
> doc. Whether that's better or not of course depends how much you
> enjoy working with XSL :-)

Hmm yeah, I thought about that one too. But I wanted to avoid having an
extra step.

I do prefer XSL compared to trying to understand what gendispatch does
;)