All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Jan Kiszka <jan.kiszka@web.de>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
	Juan Quintela <quintela@redhat.com>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	qemu-devel@nongnu.org, Luiz Capitulino <lcapitulino@redhat.com>,
	Blue Swirl <blauwirbel@gmail.com>, Avi Kivity <avi@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v4 12/23] monitor: Add completion for qdev paths
Date: Wed, 23 Jun 2010 11:46:48 +0200	[thread overview]
Message-ID: <m339weaxo7.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <689485bfec05dff41775e244f8f8da06026669f9.1276641524.git.jan.kiszka@web.de> (Jan Kiszka's message of "Wed, 16 Jun 2010 00:38:36 +0200")

Jan Kiszka <jan.kiszka@web.de> writes:

> From: Jan Kiszka <jan.kiszka@siemens.com>
>
> Implement monitor command line completion for device tree paths. The
> first user are device_add ('bus' option) and device_del.
>
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  hw/qdev.c       |   19 +++++----
>  hw/qdev.h       |    3 +
>  monitor.c       |  115 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  qemu-monitor.hx |    4 +-
>  4 files changed, 129 insertions(+), 12 deletions(-)
>
> diff --git a/hw/qdev.c b/hw/qdev.c
> index 466d8d5..dbc5b10 100644
> --- a/hw/qdev.c
> +++ b/hw/qdev.c
> @@ -39,7 +39,6 @@ DeviceInfo *device_info_list;
>  
>  static BusState *qbus_find_recursive(BusState *bus, const char *name,
>                                       const BusInfo *info);
> -static BusState *qbus_find(const char *path, bool report_errors);
>  
>  /* Register a new device type.  */
>  void qdev_register(DeviceInfo *info)
> @@ -514,7 +513,7 @@ static DeviceState *qdev_find_id_recursive(BusState *bus, const char *id)
>      return qdev_iterate_recursive(bus, find_id_callback, (void *)id);
>  }
>  
> -static int qdev_instance_no(DeviceState *dev)
> +int qdev_instance_no(DeviceState *dev)
>  {
>      struct DeviceState *sibling;
>      int instance = 0;
> @@ -611,7 +610,7 @@ static DeviceState *qbus_find_dev(BusState *bus, const char *elem)
>      return NULL;
>  }
>  
> -static BusState *qbus_find(const char *path, bool report_errors)
> +BusState *qbus_find(const char *path, bool report_errors)
>  {
>      DeviceState *dev;
>      BusState *bus = main_system_bus;
> @@ -678,7 +677,7 @@ static BusState *qbus_find(const char *path, bool report_errors)
>      }
>  }
>  
> -static DeviceState *qdev_find(const char *path)
> +DeviceState *qdev_find(const char *path, bool report_errors)
>  {
>      const char *dev_name;
>      DeviceState *dev;
> @@ -688,7 +687,7 @@ static DeviceState *qdev_find(const char *path)
>      /* search for unique ID recursively if path is not absolute */
>      if (path[0] != '/') {
>          dev = qdev_find_id_recursive(main_system_bus, path);
> -        if (!dev) {
> +        if (!dev && report_errors) {
>              qerror_report(QERR_DEVICE_NOT_FOUND, path);
>          }
>          return dev;
> @@ -702,8 +701,10 @@ static DeviceState *qdev_find(const char *path)
>      bus = qbus_find(bus_path, false);
>      qemu_free(bus_path);
>      if (!bus) {
> -        /* retry with full path to generate correct error message */
> -        bus = qbus_find(path, true);
> +        if (report_errors) {
> +            /* retry with full path to generate correct error message */
> +            bus = qbus_find(path, report_errors);
> +        }
>          if (!bus) {
>              return NULL;
>          }
> @@ -711,7 +712,7 @@ static DeviceState *qdev_find(const char *path)
>      }
>  
>      dev = qbus_find_dev(bus, dev_name);
> -    if (!dev) {
> +    if (!dev && report_errors) {
>          qerror_report(QERR_DEVICE_NOT_FOUND, dev_name);
>          qbus_list_dev(bus);
>      }
> @@ -880,7 +881,7 @@ int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
>      const char *path = qdict_get_str(qdict, "device");
>      DeviceState *dev;
>  
> -    dev = qdev_find(path);
> +    dev = qdev_find(path, true);
>      if (!dev) {
>          return -1;
>      }
> diff --git a/hw/qdev.h b/hw/qdev.h
> index 111c876..59159a0 100644
> --- a/hw/qdev.h
> +++ b/hw/qdev.h
> @@ -171,6 +171,8 @@ CharDriverState *qdev_init_chardev(DeviceState *dev);
>  BusState *qdev_get_parent_bus(DeviceState *dev);
>  void *qdev_iterate_recursive(BusState *bus, qdev_iteratefn callback,
>                               void *opaque);
> +DeviceState *qdev_find(const char *path, bool report_errors);
> +int qdev_instance_no(DeviceState *dev);
>  
>  /*** BUS API. ***/
>  
> @@ -178,6 +180,7 @@ void qbus_create_inplace(BusState *bus, BusInfo *info,
>                           DeviceState *parent, const char *name);
>  BusState *qbus_create(BusInfo *info, DeviceState *parent, const char *name);
>  void qbus_free(BusState *bus);
> +BusState *qbus_find(const char *path, bool report_errors);
>  
>  #define FROM_QBUS(type, dev) DO_UPCAST(type, qbus, dev)
>  
> diff --git a/monitor.c b/monitor.c
> index 3e0d862..f535c56 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -64,12 +64,14 @@
>   *
>   * 'F'          filename
>   * 'B'          block device name
> + * 'q'          qdev bus path
> + * 'Q'          qdev device path
>   * 's'          string (accept optional quote)
>   * 'O'          option string of the form NAME=VALUE,...
>   *              parsed according to QemuOptsList given by its name
>   *              Example: 'device:O' uses qemu_device_opts.
>   *              Command completion for specific keys can be requested via
> - *              appending '(NAME:TYPE,...)' with 'F', 'B' as type.
> + *              appending '(NAME:TYPE,...)' with 'F', 'B', 'q', 'Q' as type.
>   *              Example: 'device:O(bus:Q)' to expand 'bus=...' as qtree path.
>   *              Restriction: only lists with empty desc are supported
>   *              TODO lift the restriction

Nitpick: you add "Example: 'device:O(bus:Q)'" in patch 11, before 'Q'
gets defined in patch 12.

  reply	other threads:[~2010-06-23  9:48 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-15 22:38 [Qemu-devel] [PATCH v4 00/23] qdev path reworks & basic device state visualization Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 01/23] qdev: Rework qtree path abbreviations Jan Kiszka
2010-06-23  8:44   ` Markus Armbruster
2010-06-23  9:32     ` Markus Armbruster
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 02/23] qdev: Restrict direct bus addressing via its name Jan Kiszka
2010-06-23  8:45   ` Markus Armbruster
2010-06-23 10:17     ` Jan Kiszka
2010-06-23 11:24       ` Markus Armbruster
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 03/23] qdev: Drop ID matching from qtree paths Jan Kiszka
2010-06-23  8:55   ` Markus Armbruster
2010-06-23 10:17     ` Jan Kiszka
2010-06-23 11:38       ` Markus Armbruster
2010-06-23 12:15         ` Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 04/23] qdev: Allow device addressing via 'driver.instance' Jan Kiszka
2010-06-23  9:10   ` Markus Armbruster
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 05/23] qdev: Convert device and bus lists to QTAILQ Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 06/23] qdev: Push QMP mode checks into qbus_list_bus/dev Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 07/23] qdev: Allow device specification by qtree path for device_del Jan Kiszka
2010-06-23  9:37   ` Markus Armbruster
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 08/23] qdev: Introduce qdev_iterate_recursive Jan Kiszka
2010-06-23  9:40   ` Markus Armbruster
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 09/23] monitor: Fix leakage during completion processing Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 10/23] monitor: Fix command completion vs. boolean switches Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 11/23] monitor: Add completion support for option lists Jan Kiszka
2010-06-23  9:45   ` Markus Armbruster
2010-06-23 10:28     ` Jan Kiszka
2010-06-23 17:08       ` Markus Armbruster
2010-06-28 14:28       ` Luiz Capitulino
2010-06-28 14:40         ` Jan Kiszka
2010-06-28 16:20           ` Luiz Capitulino
2010-06-28 16:27             ` [Qemu-devel] [PATCH] monitor: Allow to exclude commands from QMP Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 12/23] monitor: Add completion for qdev paths Jan Kiszka
2010-06-23  9:46   ` Markus Armbruster [this message]
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 13/23] monitor: Allow to specify HMP-specifc command arguments Jan Kiszka
2010-06-23  9:56   ` Markus Armbruster
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 14/23] monitor: return length of printed string via monitor_[v]printf Jan Kiszka
2010-06-23  9:57   ` Markus Armbruster
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 15/23] monitor: Establish cmd flags and convert the async tag Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 16/23] monitor: Allow to exclude commands from QMP Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 17/23] Add base64 encoder/decoder Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 18/23] QMP: Reserve namespace for complex object classes Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 19/23] QMP: Add QBuffer Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 20/23] monitor: Add basic device state visualization Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 21/23] QMP: Teach basic capability negotiation to python example Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 22/23] QMP: Fix python helper /wrt long return strings Jan Kiszka
2010-06-15 22:38 ` [Qemu-devel] [PATCH v4 23/23] QMP: Add support for buffer class to qmp python helper Jan Kiszka
2010-06-23 10:01 ` [Qemu-devel] [PATCH v4 00/23] qdev path reworks & basic device state visualization Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m339weaxo7.fsf@blackfin.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=avi@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=jan.kiszka@siemens.com \
    --cc=jan.kiszka@web.de \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.