diff mbox

[v6,3/6] libxl: add query function for backend support by device model

Message ID 1459403346-28677-4-git-send-email-jgross@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jürgen Groß March 31, 2016, 5:49 a.m. UTC
Add a function to query whether the device model is supporting a
specific backend type. The device model is writing the supported
backend types to Xenstore on startup. The new query function checks
for the appropriate entry to be present.

As not all versions of qemu are capable to indicate support of
specific backends the query function is to be called with an indicator
whether the default return value should be "supported" (in case qemu
doesn't know set any support information) or "not supported".

Signed-off-by: Juergen Gross <jgross@suse.com>
---
V6: add Xenstore path documentation as requested by Wei Liu
---
 docs/misc/xenstore-paths.markdown |  7 +++++++
 tools/libxl/libxl_dm.c            | 19 +++++++++++++++++++
 tools/libxl/libxl_internal.h      |  5 +++++
 3 files changed, 31 insertions(+)

Comments

Wei Liu March 31, 2016, 2:33 p.m. UTC | #1
On Thu, Mar 31, 2016 at 07:49:03AM +0200, Juergen Gross wrote:
> Add a function to query whether the device model is supporting a
> specific backend type. The device model is writing the supported
> backend types to Xenstore on startup. The new query function checks
> for the appropriate entry to be present.
> 
> As not all versions of qemu are capable to indicate support of
> specific backends the query function is to be called with an indicator
> whether the default return value should be "supported" (in case qemu
> doesn't know set any support information) or "not supported".
> 
> Signed-off-by: Juergen Gross <jgross@suse.com>
> ---
> V6: add Xenstore path documentation as requested by Wei Liu
> ---
>  docs/misc/xenstore-paths.markdown |  7 +++++++
>  tools/libxl/libxl_dm.c            | 19 +++++++++++++++++++
>  tools/libxl/libxl_internal.h      |  5 +++++
>  3 files changed, 31 insertions(+)
> 
> diff --git a/docs/misc/xenstore-paths.markdown b/docs/misc/xenstore-paths.markdown
> index 76f67b1..890d261 100644
> --- a/docs/misc/xenstore-paths.markdown
> +++ b/docs/misc/xenstore-paths.markdown
> @@ -472,6 +472,13 @@ in the value supplied by the guest in this case).
>  
>  Contains the status of the device models running on the domain.
>  
> +#### ~/device-model/$DOMID/backends/* [w]
> +
> +Backend types the device model is supporting. Each entry below backends
> +is a directory which may contain further nodes specific to the backend
> +type. The name of each backend directory is the same as the backend type
> +(e.g. "qdisk").
> +

Anthony, can you ack / nack this?

The rest of code looks OK.

Wei.
Wei Liu March 31, 2016, 2:34 p.m. UTC | #2
Actually CC Anthony

On Thu, Mar 31, 2016 at 03:33:59PM +0100, Wei Liu wrote:
> On Thu, Mar 31, 2016 at 07:49:03AM +0200, Juergen Gross wrote:
> > Add a function to query whether the device model is supporting a
> > specific backend type. The device model is writing the supported
> > backend types to Xenstore on startup. The new query function checks
> > for the appropriate entry to be present.
> > 
> > As not all versions of qemu are capable to indicate support of
> > specific backends the query function is to be called with an indicator
> > whether the default return value should be "supported" (in case qemu
> > doesn't know set any support information) or "not supported".
> > 
> > Signed-off-by: Juergen Gross <jgross@suse.com>
> > ---
> > V6: add Xenstore path documentation as requested by Wei Liu
> > ---
> >  docs/misc/xenstore-paths.markdown |  7 +++++++
> >  tools/libxl/libxl_dm.c            | 19 +++++++++++++++++++
> >  tools/libxl/libxl_internal.h      |  5 +++++
> >  3 files changed, 31 insertions(+)
> > 
> > diff --git a/docs/misc/xenstore-paths.markdown b/docs/misc/xenstore-paths.markdown
> > index 76f67b1..890d261 100644
> > --- a/docs/misc/xenstore-paths.markdown
> > +++ b/docs/misc/xenstore-paths.markdown
> > @@ -472,6 +472,13 @@ in the value supplied by the guest in this case).
> >  
> >  Contains the status of the device models running on the domain.
> >  
> > +#### ~/device-model/$DOMID/backends/* [w]
> > +
> > +Backend types the device model is supporting. Each entry below backends
> > +is a directory which may contain further nodes specific to the backend
> > +type. The name of each backend directory is the same as the backend type
> > +(e.g. "qdisk").
> > +
> 
> Anthony, can you ack / nack this?
> 
> The rest of code looks OK.
> 
> Wei.
Anthony PERARD April 1, 2016, 2:23 p.m. UTC | #3
On Thu, Mar 31, 2016 at 03:33:59PM +0100, Wei Liu wrote:
> On Thu, Mar 31, 2016 at 07:49:03AM +0200, Juergen Gross wrote:
> > Add a function to query whether the device model is supporting a
> > specific backend type. The device model is writing the supported
> > backend types to Xenstore on startup. The new query function checks
> > for the appropriate entry to be present.
> > 
> > As not all versions of qemu are capable to indicate support of
> > specific backends the query function is to be called with an indicator
> > whether the default return value should be "supported" (in case qemu
> > doesn't know set any support information) or "not supported".
> > 
> > Signed-off-by: Juergen Gross <jgross@suse.com>
> > ---
> > V6: add Xenstore path documentation as requested by Wei Liu
> > ---
> >  docs/misc/xenstore-paths.markdown |  7 +++++++
> >  tools/libxl/libxl_dm.c            | 19 +++++++++++++++++++
> >  tools/libxl/libxl_internal.h      |  5 +++++
> >  3 files changed, 31 insertions(+)
> > 
> > diff --git a/docs/misc/xenstore-paths.markdown b/docs/misc/xenstore-paths.markdown
> > index 76f67b1..890d261 100644
> > --- a/docs/misc/xenstore-paths.markdown
> > +++ b/docs/misc/xenstore-paths.markdown
> > @@ -472,6 +472,13 @@ in the value supplied by the guest in this case).
> >  
> >  Contains the status of the device models running on the domain.
> >  
> > +#### ~/device-model/$DOMID/backends/* [w]
> > +
> > +Backend types the device model is supporting. Each entry below backends
> > +is a directory which may contain further nodes specific to the backend
> > +type. The name of each backend directory is the same as the backend type
> > +(e.g. "qdisk").
> > +
> 
> Anthony, can you ack / nack this?

That sounds good to me.
Acked-by: Anthony PERARD <anthony.perard@citrix.com>

> The rest of code looks OK.
> 
> Wei.
Wei Liu April 1, 2016, 2:57 p.m. UTC | #4
On Fri, Apr 01, 2016 at 03:23:03PM +0100, Anthony PERARD wrote:
> On Thu, Mar 31, 2016 at 03:33:59PM +0100, Wei Liu wrote:
> > On Thu, Mar 31, 2016 at 07:49:03AM +0200, Juergen Gross wrote:
> > > Add a function to query whether the device model is supporting a
> > > specific backend type. The device model is writing the supported
> > > backend types to Xenstore on startup. The new query function checks
> > > for the appropriate entry to be present.
> > > 
> > > As not all versions of qemu are capable to indicate support of
> > > specific backends the query function is to be called with an indicator
> > > whether the default return value should be "supported" (in case qemu
> > > doesn't know set any support information) or "not supported".
> > > 
> > > Signed-off-by: Juergen Gross <jgross@suse.com>
> > > ---
> > > V6: add Xenstore path documentation as requested by Wei Liu
> > > ---
> > >  docs/misc/xenstore-paths.markdown |  7 +++++++
> > >  tools/libxl/libxl_dm.c            | 19 +++++++++++++++++++
> > >  tools/libxl/libxl_internal.h      |  5 +++++
> > >  3 files changed, 31 insertions(+)
> > > 
> > > diff --git a/docs/misc/xenstore-paths.markdown b/docs/misc/xenstore-paths.markdown
> > > index 76f67b1..890d261 100644
> > > --- a/docs/misc/xenstore-paths.markdown
> > > +++ b/docs/misc/xenstore-paths.markdown
> > > @@ -472,6 +472,13 @@ in the value supplied by the guest in this case).
> > >  
> > >  Contains the status of the device models running on the domain.
> > >  
> > > +#### ~/device-model/$DOMID/backends/* [w]
> > > +
> > > +Backend types the device model is supporting. Each entry below backends
> > > +is a directory which may contain further nodes specific to the backend
> > > +type. The name of each backend directory is the same as the backend type
> > > +(e.g. "qdisk").
> > > +
> > 
> > Anthony, can you ack / nack this?
> 
> That sounds good to me.
> Acked-by: Anthony PERARD <anthony.perard@citrix.com>

Thanks, in that case:

Acked-by: Wei Liu <wei.liu2@citrix.com>

> 
> > The rest of code looks OK.
> > 
> > Wei.
> 
> -- 
> Anthony PERARD
diff mbox

Patch

diff --git a/docs/misc/xenstore-paths.markdown b/docs/misc/xenstore-paths.markdown
index 76f67b1..890d261 100644
--- a/docs/misc/xenstore-paths.markdown
+++ b/docs/misc/xenstore-paths.markdown
@@ -472,6 +472,13 @@  in the value supplied by the guest in this case).
 
 Contains the status of the device models running on the domain.
 
+#### ~/device-model/$DOMID/backends/* [w]
+
+Backend types the device model is supporting. Each entry below backends
+is a directory which may contain further nodes specific to the backend
+type. The name of each backend directory is the same as the backend type
+(e.g. "qdisk").
+
 #### ~/libxl/$DOMID/qdisk-backend-pid [w]
 
 Contains the PIDs of the device models running on the domain.
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 027d32b..1ade4e4 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -1920,6 +1920,25 @@  out:
         device_model_spawn_outcome(egc, dmss, rc);
 }
 
+bool libxl__query_qemu_backend(libxl__gc *gc, uint32_t domid,
+                               uint32_t backend_id, const char *type, bool def)
+{
+    char *path;
+    char **dir;
+    unsigned int n;
+
+    path = GCSPRINTF("%s/device-model/%u/backends",
+                     libxl__xs_get_dompath(gc, backend_id), domid);
+    dir = libxl__xs_directory(gc, XBT_NULL, path, &n);
+    if (!dir)
+        return def;
+
+    path = GCSPRINTF("%s/device-model/%u/backends/%s",
+                     libxl__xs_get_dompath(gc, backend_id), domid, type);
+    dir = libxl__xs_directory(gc, XBT_NULL, path, &n);
+
+    return !!dir;
+}
 
 static void device_model_confirm(libxl__egc *egc, libxl__spawn_state *spawn,
                                  const char *xsdata)
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index fc7bdab..c06ffc0 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1617,6 +1617,11 @@  _hidden const char *libxl__domain_device_model(libxl__gc *gc,
                                         const libxl_domain_build_info *info);
 _hidden int libxl__need_xenpv_qemu(libxl__gc *gc,
                                    libxl_domain_config *d_config);
+_hidden bool libxl__query_qemu_backend(libxl__gc *gc,
+                                       uint32_t domid,
+                                       uint32_t backend_id,
+                                       const char *type,
+                                       bool def);
 
 /*
  * This function will fix reserved device memory conflict