Re: [Qemu-devel] [PATCH 2/4] virtio-serial: Add description fields for qdev properties

2011-01-10 Thread Markus Armbruster
Amit Shah  writes:

> Document the parameters for the virtserialport and virtioconsole
> devices.
>
> Example:
>
> $ ./x86_64-softmmu/qemu-system-x86_64 -device virtserialport,?
> virtserialport.nr=uint32, The 'number' for the port for \
> predictable port numbers. Use this to spawn ports if you \
> plan to migrate the guest.
>
> virtserialport.chardev=chr, The chardev to associate this port with.
>
> virtserialport.name=string, Name for the port that's exposed to \
> the guest for port discovery.
>
> Signed-off-by: Amit Shah 
> ---
>  hw/virtio-console.c |   17 ++---
>  hw/virtio-serial.h  |   13 +
>  2 files changed, 23 insertions(+), 7 deletions(-)
>
> diff --git a/hw/virtio-console.c b/hw/virtio-console.c
> index ccd277a..8a99a99 100644
> --- a/hw/virtio-console.c
> +++ b/hw/virtio-console.c
> @@ -95,11 +95,13 @@ static VirtIOSerialPortInfo virtconsole_info = {
>  .init  = virtconsole_initfn,
>  .exit  = virtconsole_exitfn,
>  .qdev.props = (Property[]) {
> -DEFINE_PROP_UINT8("is_console", VirtConsole, port.is_console, 1, ""),
> +DEFINE_PROP_UINT8("is_console", VirtConsole, port.is_console, 1,
> +  PROP_VIRTSERIAL_IS_CONSOLE_DESC),
>  DEFINE_PROP_UINT32("nr", VirtConsole, port.id, VIRTIO_CONSOLE_BAD_ID,
> -   ""),
> -DEFINE_PROP_CHR("chardev", VirtConsole, chr, ""),
> -DEFINE_PROP_STRING("name", VirtConsole, port.name, ""),
> +   PROP_VIRTSERIAL_NR_DESC),
> +DEFINE_PROP_CHR("chardev", VirtConsole, chr, 
> PROP_VIRTSERIAL_CHR_DESC),
> +DEFINE_PROP_STRING("name", VirtConsole, port.name,
> +   PROP_VIRTSERIAL_NAME_DESC),
>  DEFINE_PROP_END_OF_LIST(),
>  },
>  };
> @@ -133,9 +135,10 @@ static VirtIOSerialPortInfo virtserialport_info = {
>  .exit  = virtconsole_exitfn,
>  .qdev.props = (Property[]) {
>  DEFINE_PROP_UINT32("nr", VirtConsole, port.id, VIRTIO_CONSOLE_BAD_ID,
> -   ""),
> -DEFINE_PROP_CHR("chardev", VirtConsole, chr, ""),
> -DEFINE_PROP_STRING("name", VirtConsole, port.name, ""),
> +   PROP_VIRTSERIAL_NR_DESC),
> +DEFINE_PROP_CHR("chardev", VirtConsole, chr, 
> PROP_VIRTSERIAL_CHR_DESC),
> +DEFINE_PROP_STRING("name", VirtConsole, port.name,
> +   PROP_VIRTSERIAL_NAME_DESC),
>  DEFINE_PROP_END_OF_LIST(),
>  },
>  };
> diff --git a/hw/virtio-serial.h b/hw/virtio-serial.h
> index ff08c40..187d5e4 100644
> --- a/hw/virtio-serial.h
> +++ b/hw/virtio-serial.h
> @@ -57,6 +57,19 @@ struct virtio_console_control {
>  
>  /* == In-qemu interface == */
>  
> +#define PROP_VIRTSERIAL_IS_CONSOLE_DESC \
> +"An hvc console will be spawned in the guest if this is set."
> +
> +#define PROP_VIRTSERIAL_NR_DESC \
> +"The 'number' for the port for predictable port numbers. Use this to " \
> +"spawn ports if you plan to migrate the guest."
> +
> +#define PROP_VIRTSERIAL_CHR_DESC\
> +"The chardev to associate this port with."
> +
> +#define PROP_VIRTSERIAL_NAME_DESC\
> +"Name for the port that's exposed to the guest for port discovery."
> +
>  typedef struct VirtIOSerial VirtIOSerial;
>  typedef struct VirtIOSerialBus VirtIOSerialBus;
>  typedef struct VirtIOSerialPort VirtIOSerialPort;

Let me elaborate on my comment asking for prettier output.  Here's how I
expect -virtconsole,\? look like with your code:

virtconsole.is_console=uint8, An hvc console will be spawned in the guest if 
this is set.
virtconsole.nr=uint32, The 'number' for the port for predictable port numbers. 
Use this to spawn ports if you plan to migrate the guest.
virtconsole.chardev=chr, The chardev to associate this port with.
virtconsole.name=string, Name for the port that's exposed to the guest for port 
discovery.

Long lines, hard to read.

By the way, properties without a description are printed with a trailing
", ".  I find that irritating.

We can do better by adopting suitable conventions for the help text, say
"first line is a brief description (50 characters max), like a headline
(no sentence-ending period), following lines (if any) are 70 characters
max."

Then we print it like this:

virtconsole.nr=uint32First line, 50 characters max., just like this one
 More lines (if any)

When the X=Y part is long, we can break like this:

virtconsole.is_console=uint8
 First line, 50 characters max., just like this one
 More lines (if any)

or maybe

virtconsole.is_console=uint8
 First line, 50 characters max., just like this one
 More lines (if any)



Re: [Qemu-devel] [PATCH 2/4] virtio-serial: Add description fields for qdev properties

2010-09-28 Thread Amit Shah
On (Tue) Sep 28 2010 [15:48:26], Markus Armbruster wrote:
> > diff --git a/hw/virtio-serial.h b/hw/virtio-serial.h
> > index ff08c40..187d5e4 100644
> > --- a/hw/virtio-serial.h
> > +++ b/hw/virtio-serial.h
> > @@ -57,6 +57,19 @@ struct virtio_console_control {
> >  
> >  /* == In-qemu interface == */
> >  
> > +#define PROP_VIRTSERIAL_IS_CONSOLE_DESC \
> > +"An hvc console will be spawned in the guest if this is set."
> > +
> > +#define PROP_VIRTSERIAL_NR_DESC \
> > +"The 'number' for the port for predictable port numbers. Use this to " 
> > \
> > +"spawn ports if you plan to migrate the guest."
> > +
> > +#define PROP_VIRTSERIAL_CHR_DESC\
> > +"The chardev to associate this port with."
> > +
> > +#define PROP_VIRTSERIAL_NAME_DESC\
> > +"Name for the port that's exposed to the guest for port discovery."
> > +
> >  typedef struct VirtIOSerial VirtIOSerial;
> >  typedef struct VirtIOSerialBus VirtIOSerialBus;
> >  typedef struct VirtIOSerialPort VirtIOSerialPort;
> 
> Do you expect these macros to be used elsewhere?  If not, I'd rather
> have them right next to their use, so that they do double-duty
> documenting source code.

Yes, other users of virtio-serial, like spice, clipboard sharing apps,
etc.

Amit



Re: [Qemu-devel] [PATCH 2/4] virtio-serial: Add description fields for qdev properties

2010-09-28 Thread Markus Armbruster
Amit Shah  writes:

> Document the parameters for the virtserialport and virtioconsole
> devices.
>
> Example:
>
> $ ./x86_64-softmmu/qemu-system-x86_64 -device virtserialport,?
> virtserialport.nr=uint32, The 'number' for the port for \
> predictable port numbers. Use this to spawn ports if you \
> plan to migrate the guest.
>
> virtserialport.chardev=chr, The chardev to associate this port with.
>
> virtserialport.name=string, Name for the port that's exposed to \
> the guest for port discovery.
>
> Signed-off-by: Amit Shah 
> ---
>  hw/virtio-console.c |   17 ++---
>  hw/virtio-serial.h  |   13 +
>  2 files changed, 23 insertions(+), 7 deletions(-)
>
> diff --git a/hw/virtio-console.c b/hw/virtio-console.c
> index ccd277a..8a99a99 100644
> --- a/hw/virtio-console.c
> +++ b/hw/virtio-console.c
> @@ -95,11 +95,13 @@ static VirtIOSerialPortInfo virtconsole_info = {
>  .init  = virtconsole_initfn,
>  .exit  = virtconsole_exitfn,
>  .qdev.props = (Property[]) {
> -DEFINE_PROP_UINT8("is_console", VirtConsole, port.is_console, 1, ""),
> +DEFINE_PROP_UINT8("is_console", VirtConsole, port.is_console, 1,
> +  PROP_VIRTSERIAL_IS_CONSOLE_DESC),
>  DEFINE_PROP_UINT32("nr", VirtConsole, port.id, VIRTIO_CONSOLE_BAD_ID,
> -   ""),
> -DEFINE_PROP_CHR("chardev", VirtConsole, chr, ""),
> -DEFINE_PROP_STRING("name", VirtConsole, port.name, ""),
> +   PROP_VIRTSERIAL_NR_DESC),
> +DEFINE_PROP_CHR("chardev", VirtConsole, chr, 
> PROP_VIRTSERIAL_CHR_DESC),
> +DEFINE_PROP_STRING("name", VirtConsole, port.name,
> +   PROP_VIRTSERIAL_NAME_DESC),
>  DEFINE_PROP_END_OF_LIST(),
>  },
>  };
> @@ -133,9 +135,10 @@ static VirtIOSerialPortInfo virtserialport_info = {
>  .exit  = virtconsole_exitfn,
>  .qdev.props = (Property[]) {
>  DEFINE_PROP_UINT32("nr", VirtConsole, port.id, VIRTIO_CONSOLE_BAD_ID,
> -   ""),
> -DEFINE_PROP_CHR("chardev", VirtConsole, chr, ""),
> -DEFINE_PROP_STRING("name", VirtConsole, port.name, ""),
> +   PROP_VIRTSERIAL_NR_DESC),
> +DEFINE_PROP_CHR("chardev", VirtConsole, chr, 
> PROP_VIRTSERIAL_CHR_DESC),
> +DEFINE_PROP_STRING("name", VirtConsole, port.name,
> +   PROP_VIRTSERIAL_NAME_DESC),
>  DEFINE_PROP_END_OF_LIST(),
>  },
>  };
> diff --git a/hw/virtio-serial.h b/hw/virtio-serial.h
> index ff08c40..187d5e4 100644
> --- a/hw/virtio-serial.h
> +++ b/hw/virtio-serial.h
> @@ -57,6 +57,19 @@ struct virtio_console_control {
>  
>  /* == In-qemu interface == */
>  
> +#define PROP_VIRTSERIAL_IS_CONSOLE_DESC \
> +"An hvc console will be spawned in the guest if this is set."
> +
> +#define PROP_VIRTSERIAL_NR_DESC \
> +"The 'number' for the port for predictable port numbers. Use this to " \
> +"spawn ports if you plan to migrate the guest."
> +
> +#define PROP_VIRTSERIAL_CHR_DESC\
> +"The chardev to associate this port with."
> +
> +#define PROP_VIRTSERIAL_NAME_DESC\
> +"Name for the port that's exposed to the guest for port discovery."
> +
>  typedef struct VirtIOSerial VirtIOSerial;
>  typedef struct VirtIOSerialBus VirtIOSerialBus;
>  typedef struct VirtIOSerialPort VirtIOSerialPort;

Do you expect these macros to be used elsewhere?  If not, I'd rather
have them right next to their use, so that they do double-duty
documenting source code.