All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] libxl: Allow multiple serial ports on HVM domain creation
@ 2014-07-31  0:24 White, Edmund H
  2014-07-31 12:57 ` Dario Faggioli
       [not found] ` <3bc317ae-967e-44e9-a6d6-444c8878f3ce@orsmsx101.amr.corp.intel.com>
  0 siblings, 2 replies; 6+ messages in thread
From: White, Edmund H @ 2014-07-31  0:24 UTC (permalink / raw)
  To: xen-devel; +Cc: ian.campbell, stefano.stabellini

This patch allows an HVM domain to be created with multiple serial
ports.

Since the previous interface only allowed the passing of a single
device, this requires us to add a new element to the hvm struct of
libxl_domain_build_info -- serial_list.  For API compatibility, the
old element, serial, remains.

If hvm.serial_list is set, each device listed will cause an extra
"-serial [foo]" to be appended to the qemu command line.

Callers may set either hvm.serial or hvm.serial_list, but not
both; libxl will throw an error if both are set.

In order to allow users of libxl to write software compatible with
older versions of libxl, also define LIBXL_HAVE_BUILDINFO_SERIAL_LIST.
If this is defined, callers may use either hvm.serial or
hvm.serial_list; otherwise, only hvm.serial will be available.

This patch borrows substantially from the multiple USB device patch
ac16730d0339d41fd7d129a5cb2d40ed67a303d9.

Signed-off-by: Ed White <edmund.h.white@intel.com>
---
 tools/libxl/libxl.h         | 16 ++++++++++++++++
 tools/libxl/libxl_dm.c      | 44 ++++++++++++++++++++++++++++++++++++++++----
 tools/libxl/libxl_types.idl |  1 +
 3 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 5ae6532..3f6cc4a 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -579,6 +579,22 @@ typedef struct libxl__ctx libxl_ctx;
  */
 #define LIBXL_HAVE_CPUPOOL_NAME 1
 
+/*
+ * LIBXL_HAVE_BUILDINFO_SERIAL_LIST
+ *
+ * If this is defined, then the libxl_domain_build_info structure will
+ * contain hvm.serial_list, a libxl_string_list type that contains
+ * a list of serial ports to specify on the qemu command-line.
+ *
+ * If it is set, callers may use either hvm.serial or
+ * hvm.serial_list, but not both; if both are set, libxl will
+ * throw an error.
+ *
+ * If this is not defined, callers can only use hvm.serial.  Note
+ * that this means only one serial port can be added at domain build time.
+ */
+#define LIBXL_HAVE_BUILDINFO_SERIAL_LIST 1
+
 typedef uint8_t libxl_mac[6];
 #define LIBXL_MAC_FMT "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx"
 #define LIBXL_MAC_FMTLEN ((2*6)+5) /* 6 hex bytes plus 5 colons */
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index addacdb..0b83ed9 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -196,8 +196,26 @@ static char ** libxl__build_device_model_args_old(libxl__gc *gc,
         int nr_set_cpus = 0;
         char *s;
 
-        if (b_info->u.hvm.serial) {
-            flexarray_vappend(dm_args, "-serial", b_info->u.hvm.serial, NULL);
+        if (b_info->u.hvm.serial || b_info->u.hvm.serial_list) {
+            if ( b_info->u.hvm.serial && b_info->u.hvm.serial_list )
+            {
+                LOG(ERROR, "%s: Both serial and serial_list set",
+                    __func__);
+                return NULL;
+            }
+            if (b_info->u.hvm.serial) {
+                flexarray_vappend(dm_args,
+                                  "-serial", b_info->u.hvm.serial, NULL);
+            } else if (b_info->u.hvm.serial_list) {
+                char **p;
+                for (p = b_info->u.hvm.serial_list;
+                     *p;
+                     p++) {
+                    flexarray_vappend(dm_args,
+                                      "-serial",
+                                      *p, NULL);
+                }
+            }
         }
 
         if (libxl_defbool_val(b_info->u.hvm.nographic) && (!sdl && !vnc)) {
@@ -479,8 +497,26 @@ static char ** libxl__build_device_model_args_new(libxl__gc *gc,
     if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) {
         int ioemu_nics = 0;
 
-        if (b_info->u.hvm.serial) {
-            flexarray_vappend(dm_args, "-serial", b_info->u.hvm.serial, NULL);
+        if (b_info->u.hvm.serial || b_info->u.hvm.serial_list) {
+            if ( b_info->u.hvm.serial && b_info->u.hvm.serial_list )
+            {
+                LOG(ERROR, "%s: Both serial and serial_list set",
+                    __func__);
+                return NULL;
+            }
+            if (b_info->u.hvm.serial) {
+                flexarray_vappend(dm_args,
+                                  "-serial", b_info->u.hvm.serial, NULL);
+            } else if (b_info->u.hvm.serial_list) {
+                char **p;
+                for (p = b_info->u.hvm.serial_list;
+                     *p;
+                     p++) {
+                    flexarray_vappend(dm_args,
+                                      "-serial",
+                                      *p, NULL);
+                }
+            }
         }
 
         if (libxl_defbool_val(b_info->u.hvm.nographic) && (!sdl && !vnc)) {
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index a412f9c..1e56b34 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -395,6 +395,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
                                        ("vendor_device",    libxl_vendor_device),
                                        # See libxl_ms_vm_genid_generate()
                                        ("ms_vm_genid",      libxl_ms_vm_genid),
+                                       ("serial_list",      libxl_string_list),
                                        ])),
                  ("pv", Struct(None, [("kernel", string),
                                       ("slack_memkb", MemKB),
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] libxl: Allow multiple serial ports on HVM domain creation
  2014-07-31  0:24 [PATCH 1/2] libxl: Allow multiple serial ports on HVM domain creation White, Edmund H
@ 2014-07-31 12:57 ` Dario Faggioli
       [not found] ` <3bc317ae-967e-44e9-a6d6-444c8878f3ce@orsmsx101.amr.corp.intel.com>
  1 sibling, 0 replies; 6+ messages in thread
From: Dario Faggioli @ 2014-07-31 12:57 UTC (permalink / raw)
  To: White, Edmund H; +Cc: stefano.stabellini, ian.campbell, xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 1798 bytes --]

On gio, 2014-07-31 at 00:24 +0000, White, Edmund H wrote:


> diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
> index addacdb..0b83ed9 100644
> --- a/tools/libxl/libxl_dm.c
> +++ b/tools/libxl/libxl_dm.c
> @@ -196,8 +196,26 @@ static char ** libxl__build_device_model_args_old(libxl__gc *gc,
>          int nr_set_cpus = 0;
>          char *s;
>  
> -        if (b_info->u.hvm.serial) {
> -            flexarray_vappend(dm_args, "-serial", b_info->u.hvm.serial, NULL);
> +        if (b_info->u.hvm.serial || b_info->u.hvm.serial_list) {
> +            if ( b_info->u.hvm.serial && b_info->u.hvm.serial_list )
> +            {
> +                LOG(ERROR, "%s: Both serial and serial_list set",
> +                    __func__);
>
Looking at LOG-->LIBXL_LOG's definition in tools/libxl/libxl_internal.h,
it looks like __func__ is already included in there, so I don't think
you need to include it explicitly.

> +                return NULL;
> +            }
> +            if (b_info->u.hvm.serial) {
> +                flexarray_vappend(dm_args,
> +                                  "-serial", b_info->u.hvm.serial, NULL);
> +            } else if (b_info->u.hvm.serial_list) {
> +                char **p;
> +                for (p = b_info->u.hvm.serial_list;
> +                     *p;
> +                     p++) {
>
Not a big deal, but, doesn't the for fit in one line (a matter of taste,
though, I guess, as I don't think libxl coding style forbids this).

Regards,
Dario

-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R&D Ltd., Cambridge (UK)


[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

[-- Attachment #2: Type: text/plain, Size: 126 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] libxl: Allow multiple serial ports on HVM domain creation
       [not found] ` <3bc317ae-967e-44e9-a6d6-444c8878f3ce@orsmsx101.amr.corp.intel.com>
@ 2014-07-31 16:31   ` White, Edmund H
  2014-08-01 11:39     ` Wei Liu
  0 siblings, 1 reply; 6+ messages in thread
From: White, Edmund H @ 2014-07-31 16:31 UTC (permalink / raw)
  To: Dario Faggioli; +Cc: stefano.stabellini, ian.campbell, xen-devel

> -----Original Message-----
> From: Dario Faggioli [mailto:dario.faggioli@citrix.com]
> Sent: Thursday, July 31, 2014 5:58 AM
> To: White, Edmund H
> Cc: xen-devel@lists.xen.org; ian.campbell@citrix.com;
> stefano.stabellini@eu.citrix.com
> Subject: Re: [Xen-devel] [PATCH 1/2] libxl: Allow multiple serial ports on HVM
> domain creation
> 
> On gio, 2014-07-31 at 00:24 +0000, White, Edmund H wrote:
> 
> 
> > diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index
> > addacdb..0b83ed9 100644
> > --- a/tools/libxl/libxl_dm.c
> > +++ b/tools/libxl/libxl_dm.c
> > @@ -196,8 +196,26 @@ static char **
> libxl__build_device_model_args_old(libxl__gc *gc,
> >          int nr_set_cpus = 0;
> >          char *s;
> >
> > -        if (b_info->u.hvm.serial) {
> > -            flexarray_vappend(dm_args, "-serial", b_info->u.hvm.serial, NULL);
> > +        if (b_info->u.hvm.serial || b_info->u.hvm.serial_list) {
> > +            if ( b_info->u.hvm.serial && b_info->u.hvm.serial_list )
> > +            {
> > +                LOG(ERROR, "%s: Both serial and serial_list set",
> > +                    __func__);
> >
> Looking at LOG-->LIBXL_LOG's definition in tools/libxl/libxl_internal.h, it looks
> like __func__ is already included in there, so I don't think you need to include
> it explicitly.
> 

I simply copied the existing USB device code and changed USB to serial,
so if this is wrong that's wrong too.

> > +                return NULL;
> > +            }
> > +            if (b_info->u.hvm.serial) {
> > +                flexarray_vappend(dm_args,
> > +                                  "-serial", b_info->u.hvm.serial, NULL);
> > +            } else if (b_info->u.hvm.serial_list) {
> > +                char **p;
> > +                for (p = b_info->u.hvm.serial_list;
> > +                     *p;
> > +                     p++) {
> >
> Not a big deal, but, doesn't the for fit in one line (a matter of taste, though, I
> guess, as I don't think libxl coding style forbids this).
> 

See above.

> Regards,
> Dario
> 
> --
> <<This happens because I choose it to happen!>> (Raistlin Majere)
> -----------------------------------------------------------------
> Dario Faggioli, Ph.D, http://about.me/dario.faggioli Senior Software
> Engineer, Citrix Systems R&D Ltd., Cambridge (UK)

Ed

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] libxl: Allow multiple serial ports on HVM domain creation
  2014-07-31 16:31   ` White, Edmund H
@ 2014-08-01 11:39     ` Wei Liu
  2014-08-01 17:31       ` White, Edmund H
  0 siblings, 1 reply; 6+ messages in thread
From: Wei Liu @ 2014-08-01 11:39 UTC (permalink / raw)
  To: White, Edmund H
  Cc: Dario Faggioli, xen-devel, wei.liu2, ian.campbell, stefano.stabellini

On Thu, Jul 31, 2014 at 04:31:36PM +0000, White, Edmund H wrote:
> > -----Original Message-----
> > From: Dario Faggioli [mailto:dario.faggioli@citrix.com]
> > Sent: Thursday, July 31, 2014 5:58 AM
> > To: White, Edmund H
> > Cc: xen-devel@lists.xen.org; ian.campbell@citrix.com;
> > stefano.stabellini@eu.citrix.com
> > Subject: Re: [Xen-devel] [PATCH 1/2] libxl: Allow multiple serial ports on HVM
> > domain creation
> > 
> > On gio, 2014-07-31 at 00:24 +0000, White, Edmund H wrote:
> > 
> > 
> > > diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index
> > > addacdb..0b83ed9 100644
> > > --- a/tools/libxl/libxl_dm.c
> > > +++ b/tools/libxl/libxl_dm.c
> > > @@ -196,8 +196,26 @@ static char **
> > libxl__build_device_model_args_old(libxl__gc *gc,
> > >          int nr_set_cpus = 0;
> > >          char *s;
> > >
> > > -        if (b_info->u.hvm.serial) {
> > > -            flexarray_vappend(dm_args, "-serial", b_info->u.hvm.serial, NULL);
> > > +        if (b_info->u.hvm.serial || b_info->u.hvm.serial_list) {
> > > +            if ( b_info->u.hvm.serial && b_info->u.hvm.serial_list )
> > > +            {
> > > +                LOG(ERROR, "%s: Both serial and serial_list set",
> > > +                    __func__);
> > >
> > Looking at LOG-->LIBXL_LOG's definition in tools/libxl/libxl_internal.h, it looks
> > like __func__ is already included in there, so I don't think you need to include
> > it explicitly.
> > 
> 
> I simply copied the existing USB device code and changed USB to serial,
> so if this is wrong that's wrong too.
> 

I've sent a patch to remove those "__func__", please remove it from your
patch in you next version.

BTW, you should explicitly CC toolstack maintainers Ian Campbell and Ian
Jackson for your patch.

Wei.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] libxl: Allow multiple serial ports on HVM domain creation
  2014-08-01 11:39     ` Wei Liu
@ 2014-08-01 17:31       ` White, Edmund H
  2014-08-01 17:39         ` Wei Liu
  0 siblings, 1 reply; 6+ messages in thread
From: White, Edmund H @ 2014-08-01 17:31 UTC (permalink / raw)
  To: Wei Liu; +Cc: Dario Faggioli, xen-devel, ian.campbell, stefano.stabellini

> -----Original Message-----
> From: Wei Liu [mailto:wei.liu2@citrix.com]
> Sent: Friday, August 01, 2014 4:40 AM
> To: White, Edmund H
> Cc: Dario Faggioli; stefano.stabellini@eu.citrix.com;
> ian.campbell@citrix.com; xen-devel@lists.xen.org; wei.liu2@citrix.com
> Subject: Re: [Xen-devel] [PATCH 1/2] libxl: Allow multiple serial ports on
> HVM domain creation
> 
> On Thu, Jul 31, 2014 at 04:31:36PM +0000, White, Edmund H wrote:
> > > -----Original Message-----
> > > From: Dario Faggioli [mailto:dario.faggioli@citrix.com]
> > > Sent: Thursday, July 31, 2014 5:58 AM
> > > To: White, Edmund H
> > > Cc: xen-devel@lists.xen.org; ian.campbell@citrix.com;
> > > stefano.stabellini@eu.citrix.com
> > > Subject: Re: [Xen-devel] [PATCH 1/2] libxl: Allow multiple serial
> > > ports on HVM domain creation
> > >
> > > On gio, 2014-07-31 at 00:24 +0000, White, Edmund H wrote:
> > >
> > >
> > > > diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index
> > > > addacdb..0b83ed9 100644
> > > > --- a/tools/libxl/libxl_dm.c
> > > > +++ b/tools/libxl/libxl_dm.c
> > > > @@ -196,8 +196,26 @@ static char **
> > > libxl__build_device_model_args_old(libxl__gc *gc,
> > > >          int nr_set_cpus = 0;
> > > >          char *s;
> > > >
> > > > -        if (b_info->u.hvm.serial) {
> > > > -            flexarray_vappend(dm_args, "-serial", b_info->u.hvm.serial,
> NULL);
> > > > +        if (b_info->u.hvm.serial || b_info->u.hvm.serial_list) {
> > > > +            if ( b_info->u.hvm.serial && b_info->u.hvm.serial_list )
> > > > +            {
> > > > +                LOG(ERROR, "%s: Both serial and serial_list set",
> > > > +                    __func__);
> > > >
> > > Looking at LOG-->LIBXL_LOG's definition in
> > > tools/libxl/libxl_internal.h, it looks like __func__ is already
> > > included in there, so I don't think you need to include it explicitly.
> > >
> >
> > I simply copied the existing USB device code and changed USB to
> > serial, so if this is wrong that's wrong too.
> >
> 
> I've sent a patch to remove those "__func__", please remove it from
> your patch in you next version.
> 

OK. If I resend this patch as V2, should I resend the other patch also as V2
with no changes, or leave it as is? I haven't had any response on that patch.

> BTW, you should explicitly CC toolstack maintainers Ian Campbell and Ian
> Jackson for your patch.
> 

It looked to me like the maintainers were Ian Campbell and Stefano
Stabellini (and Ian Campbell asked me to create the patches), so I
copied them. Are you saying I should remove Stefano Stabellini and
add Ian Jackson instead?

> Wei.

Ed

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] libxl: Allow multiple serial ports on HVM domain creation
  2014-08-01 17:31       ` White, Edmund H
@ 2014-08-01 17:39         ` Wei Liu
  0 siblings, 0 replies; 6+ messages in thread
From: Wei Liu @ 2014-08-01 17:39 UTC (permalink / raw)
  To: White, Edmund H
  Cc: Dario Faggioli, xen-devel, Wei Liu, ian.campbell, stefano.stabellini

On Fri, Aug 01, 2014 at 05:31:45PM +0000, White, Edmund H wrote:
[...]
> 
> OK. If I resend this patch as V2, should I resend the other patch also as V2
> with no changes, or leave it as is? I haven't had any response on that patch.
> 

I think you should wait for input from maintainers before respin. Ian C
is currently away, and Ian J prefers submitters to CC him directly. IMHO
you need to expect a turnaround time for several days to a week.

> > BTW, you should explicitly CC toolstack maintainers Ian Campbell and Ian
> > Jackson for your patch.
> > 
> 
> It looked to me like the maintainers were Ian Campbell and Stefano
> Stabellini (and Ian Campbell asked me to create the patches), so I
> copied them. Are you saying I should remove Stefano Stabellini and
> add Ian Jackson instead?
> 

Oh, sorry. I somehow missed your email header, sorry for the noise.
CCing Ian C and Stefano is fine but I would add Ian Jackson to CC list
as well.

Wei.

> > Wei.
> 
> Ed

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-08-01 17:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-31  0:24 [PATCH 1/2] libxl: Allow multiple serial ports on HVM domain creation White, Edmund H
2014-07-31 12:57 ` Dario Faggioli
     [not found] ` <3bc317ae-967e-44e9-a6d6-444c8878f3ce@orsmsx101.amr.corp.intel.com>
2014-07-31 16:31   ` White, Edmund H
2014-08-01 11:39     ` Wei Liu
2014-08-01 17:31       ` White, Edmund H
2014-08-01 17:39         ` Wei Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.