All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org, afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH] qdev: Make -device FOO, help help again when FOO is not pluggable
Date: Mon, 16 Mar 2015 15:13:57 -0300	[thread overview]
Message-ID: <20150316181357.GK3513@thinpad.lan.raisama.net> (raw)
In-Reply-To: <1426527232-15044-1-git-send-email-armbru@redhat.com>

On Mon, Mar 16, 2015 at 06:33:52PM +0100, Markus Armbruster wrote:
> Doesn't work since commit 31bed55 changed qdev_device_help() to reject
> abstract devices and devices that have
> cannot_instantiate_with_device_add_yet set.
> 
> The former makes sense: abstract devices are purely internal, and the
> implementation of the help feature can't cope with them.
> 
> The latter makes less sense: the implementation works fine, and even
> though you can't -device such a device, the help may still be useful
> elsewhere, for instance with -global.
> 
> Revert the latter by moving the cannot_instantiate_with_device_add_yet
> check back to the other caller of qdev_get_device_class(),
> qdev_device_add().

This reintroduces the following crash:

  $ ./x86_64-softmmu/qemu-system-x86_64    -device host-x86_64-cpu,help
  qemu-system-x86_64: /home/ehabkost/rh/proj/virt/qemu/target-i386/cpu.c:1391: host_x86_cpu_initfn: Assertion `(kvm_allowed)' failed.
  Aborted (core dumped)

And this (which is not x86-specific because other arches also call
cpu_exec_init() inside instance_init):

  $ ./x86_64-softmmu/qemu-system-x86_64    -monitor stdio
  QEMU 2.2.50 monitor - type 'help' for more information
  (qemu) device_add Nehalem-x86_64-cpu,help
  Nehalem-x86_64-cpu.filtered-features=X86CPUFeatureWordInfo
  Nehalem-x86_64-cpu.feature-words=X86CPUFeatureWordInfo
  Nehalem-x86_64-cpu.apic-id=int
  Nehalem-x86_64-cpu.tsc-frequency=int
  Nehalem-x86_64-cpu.model-id=string
  Nehalem-x86_64-cpu.vendor=string
  Nehalem-x86_64-cpu.xlevel=int
  Nehalem-x86_64-cpu.level=int
  Nehalem-x86_64-cpu.stepping=int
  Nehalem-x86_64-cpu.model=int
  Nehalem-x86_64-cpu.family=int
  Nehalem-x86_64-cpu.kvm=bool
  Nehalem-x86_64-cpu.enforce=bool
  Nehalem-x86_64-cpu.check=bool
  Nehalem-x86_64-cpu.hv-time=bool
  Nehalem-x86_64-cpu.hv-vapic=bool
  Nehalem-x86_64-cpu.hv-relaxed=bool
  Nehalem-x86_64-cpu.hv-spinlocks=int
  Nehalem-x86_64-cpu.pmu=bool
  (qemu) Segmentation fault (core dumped)

Should we:

1) Live with the crashes until we move all code with side-effects outside
   instance_init (including bot not limited to cpu_exec_init() calls on most
   CPU classes);
2) add a "instance_init_is_unsafe" flag to those classes classes; or
3) Keep the current code until we fix the classes that have unsafe
   instance_init functions?

> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  qdev-monitor.c | 22 ++++++++++++----------
>  1 file changed, 12 insertions(+), 10 deletions(-)
> 
> diff --git a/qdev-monitor.c b/qdev-monitor.c
> index 5d30ac5..b0b8cf1 100644
> --- a/qdev-monitor.c
> +++ b/qdev-monitor.c
> @@ -180,10 +180,14 @@ static const char *find_typename_by_alias(const char *alias)
>      return NULL;
>  }
>  
> +
> +/**
> + * Return DeviceClass for concrete device type @driver.
> + * On error, store an error through @errp if non-null, and return %NULL.
> + */
>  static DeviceClass *qdev_get_device_class(const char **driver, Error **errp)
>  {
>      ObjectClass *oc;
> -    DeviceClass *dc;
>  
>      oc = object_class_by_name(*driver);
>      if (!oc) {
> @@ -206,15 +210,7 @@ static DeviceClass *qdev_get_device_class(const char **driver, Error **errp)
>          return NULL;
>      }
>  
> -    dc = DEVICE_CLASS(oc);
> -    if (dc->cannot_instantiate_with_device_add_yet ||
> -        (qdev_hotplug && !dc->hotpluggable)) {
> -        error_set(errp, QERR_INVALID_PARAMETER_VALUE, "driver",
> -                  "pluggable device type");
> -        return NULL;
> -    }
> -
> -    return dc;
> +    return DEVICE_CLASS(oc);
>  }
>  
>  
> @@ -512,6 +508,12 @@ DeviceState *qdev_device_add(QemuOpts *opts)
>          error_free(err);
>          return NULL;
>      }
> +    if (dc->cannot_instantiate_with_device_add_yet ||
> +        (qdev_hotplug && !dc->hotpluggable)) {
> +        qerror_report(QERR_INVALID_PARAMETER_VALUE, "driver",
> +                      "pluggable device type");
> +        return NULL;
> +    }
>  
>      /* find bus */
>      path = qemu_opt_get(opts, "bus");
> -- 
> 1.9.3
> 

-- 
Eduardo

  parent reply	other threads:[~2015-03-16 18:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-16 17:33 [Qemu-devel] [PATCH] qdev: Make -device FOO, help help again when FOO is not pluggable Markus Armbruster
2015-03-16 17:37 ` Paolo Bonzini
2015-03-16 18:13 ` Eduardo Habkost [this message]
2015-03-17  7:15   ` Markus Armbruster
2015-03-17 14:57     ` Eduardo Habkost

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=20150316181357.GK3513@thinpad.lan.raisama.net \
    --to=ehabkost@redhat.com \
    --cc=afaerber@suse.de \
    --cc=armbru@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /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.