qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Marcel Apfelbaum <marcel@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>,
	Eduardo Habkost <ehabkost@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>,
	QEMU Developers <qemu-devel@nongnu.org>,
	Igor Mammedov <imammedo@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Xiao Guangrong <guangrong.xiao@linux.intel.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Cornelia Huck <cohuck@redhat.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Anthony Perard <anthony.perard@citrix.com>
Subject: Re: [Qemu-devel] [RFC PATCH] qdev: Mark devices as non-hotpluggable by default
Date: Wed, 20 Sep 2017 13:57:16 +0300	[thread overview]
Message-ID: <54a1ab1c-4da0-ded1-c225-f50d4756b773@redhat.com> (raw)
In-Reply-To: <CAFEAcA_morPirUBzbpX1tHKfSCX+vAEcWX+KmUZKdnNm3O3vhA@mail.gmail.com>

On 20/09/2017 13:07, Peter Maydell wrote:
> On 20 September 2017 at 08:50, Marcel Apfelbaum <marcel@redhat.com> wrote:
>> Hi Thomas,
>>
>>
>> On 19/09/2017 11:55, Thomas Huth wrote:
>>>
>>> Historically we've marked all devices as hotpluggable by default. However,
>>> most devices are not hotpluggable, and you also need a HotplugHandler to
>>> support these devices. So if the user tries to "device_add" or
>>> "device_del"
>>> such a non-hotpluggable device during runtime, either nothing really
>>> usable
>>> happens, or QEMU even crashes/aborts unexpectedly (see for example commit
>>> 84ebd3e8c7d4fe955b - "Mark diag288 watchdog as non-hotpluggable").
>>> So let's change this dangerous default behaviour and mark the devices as
>>> non-hotpluggable by default. Certain parent devices classes which are
>>> known
>>> as hotpluggable (e.g. PCI, USB, etc.) are marked with "hotpluggable =
>>> true",
>>> so that devices that are derived from these classes continue to work as
>>> expected.
>>>
>>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>>> ---
>>>    Note: I've marked the patch as RFC since I'm not 100% sure whether I've
>>>    correctly identified all devices that should still be marked as hot-
>>>    pluggable. Feedback is welcome!
>>>
>>>    hw/core/qdev.c        | 10 ++++------
>>>    hw/cpu/core.c         |  1 +
>>>    hw/mem/nvdimm.c       |  3 +++
>>>    hw/mem/pc-dimm.c      |  1 +
>>>    hw/pci/pci.c          |  1 +
>>>    hw/s390x/ccw-device.c |  1 +
>>>    hw/scsi/scsi-bus.c    |  1 +
>>>    hw/usb/bus.c          |  1 +
>>>    8 files changed, 13 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
>>> index 606ab53..c4f1902 100644
>>> --- a/hw/core/qdev.c
>>> +++ b/hw/core/qdev.c
>>> @@ -1120,13 +1120,11 @@ static void device_class_init(ObjectClass *class,
>>> void *data)
>>>        dc->realize = device_realize;
>>>        dc->unrealize = device_unrealize;
>>>    -    /* by default all devices were considered as hotpluggable,
>>> -     * so with intent to check it in generic qdev_unplug() /
>>> -     * device_set_realized() functions make every device
>>> -     * hotpluggable. Devices that shouldn't be hotpluggable,
>>> -     * should override it in their class_init()
>>> +    /*
>>> +     * All devices are considered as cold-pluggable by default. The
>>> devices
>>> +     * that are hotpluggable should override it in their class_init().
>>>         */
>>> -    dc->hotpluggable = true;
>>> +    dc->hotpluggable = false;
>>
>>
>> I agree with the defensive mode as long as we don't
>> introduce any regression...
> 
> Is it possible to hack together some kind of test code that
> can give us a list of the devices compiled in that have
> hotpluggable enabled? Then we could compare before and
> after to see which devices we've changed.
> 

Eduardo came up with some cool automated tests not long ago.
Eduardo, can your tests help?

Thanks,
Marcel

> thanks
> -- PMM
> 

  reply	other threads:[~2017-09-20 13:26 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-19  8:55 [Qemu-devel] [RFC PATCH] qdev: Mark devices as non-hotpluggable by default Thomas Huth
2017-09-20  7:50 ` Marcel Apfelbaum
2017-09-20 10:07   ` Peter Maydell
2017-09-20 10:57     ` Marcel Apfelbaum [this message]
2017-09-20 11:17       ` Thomas Huth
2017-09-20 16:10         ` Thomas Huth
2017-09-20 16:15           ` David Hildenbrand
2017-09-21  8:04           ` Igor Mammedov
2017-09-21 15:27 ` Anthony PERARD
2017-09-21 18:50 ` Eduardo Habkost
2017-09-22  7:38   ` Cornelia Huck
2017-09-22  7:52     ` Thomas Huth
2017-09-22  7:47   ` Thomas Huth
2017-09-22 19:25     ` Cédric Le Goater

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=54a1ab1c-4da0-ded1-c225-f50d4756b773@redhat.com \
    --to=marcel@redhat.com \
    --cc=anthony.perard@citrix.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=guangrong.xiao@linux.intel.com \
    --cc=imammedo@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sstabellini@kernel.org \
    --cc=thuth@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).