qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Ashijeet Acharya <ashijeetacharya@gmail.com>, dgilbert@redhat.com
Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, quintela@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2] migrate: Introduce a 'dc->vmsd' check to avoid segfault for --only-migratable
Date: Sat, 4 Feb 2017 01:21:23 -0800	[thread overview]
Message-ID: <a0b18acc-07ed-4444-63db-d54e76097171@redhat.com> (raw)
In-Reply-To: <1486198784-31523-1-git-send-email-ashijeetacharya@gmail.com>



On 04/02/2017 00:59, Ashijeet Acharya wrote:
> Commit a3a3d8c7 introduced a segfault bug while checking for
> 'dc->vmsd->unmigratable' which caused QEMU to crash when trying to add
> devices which do no set their 'dc->vmsd' yet while initialization.
> Place a 'dc->vmsd' check prior to it so that we do not segfault for
> such devices.
> 
> NOTE: This doesn't compromise the functioning of --only-migratable
> option as all the unmigratable devices do set their 'dc->vmsd'.
> 
> Signed-off-by: Ashijeet Acharya <ashijeetacharya@gmail.com>
> Reviewed-by: Juan Quintela <quintela@redhat.com>
> ---
> Changes in v2:
> - place dc->vmsd check in hw/usb/bus.c as well
> ---
>  hw/usb/bus.c   | 2 +-
>  qdev-monitor.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/usb/bus.c b/hw/usb/bus.c
> index 1dcc35c..1e39b2c 100644
> --- a/hw/usb/bus.c
> +++ b/hw/usb/bus.c
> @@ -731,7 +731,7 @@ USBDevice *usbdevice_create(const char *cmdline)
>  
>      dc = DEVICE_CLASS(klass);
>  
> -    if (only_migratable) {
> +    if (only_migratable && dc->vmsd) {
>          if (dc->vmsd->unmigratable) {
>              error_report("Device %s is not migratable, but --only-migratable "
>                           "was specified", f->name);
> diff --git a/qdev-monitor.c b/qdev-monitor.c
> index 549f45f..b72e5a4 100644
> --- a/qdev-monitor.c
> +++ b/qdev-monitor.c
> @@ -579,7 +579,7 @@ DeviceState *qdev_device_add(QemuOpts *opts, Error **errp)
>          return NULL;
>      }
>  
> -    if (only_migratable) {
> +    if (only_migratable && dc->vmsd) {
>          if (dc->vmsd->unmigratable) {
>              error_setg(errp, "Device %s is not migratable, but "
>                         "--only-migratable was specified", driver);
> 

Could you handle only_migratable in device_set_realized (inside "if
(value && !dev->realized)"), to avoid the code duplication?  Separate
patch from this one, of course.

Thanks,

Paolo

      reply	other threads:[~2017-02-04  9:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-04  8:59 [Qemu-devel] [PATCH v2] migrate: Introduce a 'dc->vmsd' check to avoid segfault for --only-migratable Ashijeet Acharya
2017-02-04  9:21 ` Paolo Bonzini [this message]

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=a0b18acc-07ed-4444-63db-d54e76097171@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=ashijeetacharya@gmail.com \
    --cc=dgilbert@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).