All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: "Julia Suvorova" <jusual@redhat.com>,
	qemu-devel@nongnu.org, "Daniel P. Berrangé" <berrange@redhat.com>,
	"Laine Stump" <laine@redhat.com>,
	qemu-trivial@nongnu.org
Subject: Re: [PATCH] hw/pci/pcie: Forbid hot-plug via QMP if it's disabled on the slot
Date: Mon, 13 Apr 2020 06:54:51 -0400	[thread overview]
Message-ID: <20200413065048-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20200408125120.7678d9ae@redhat.com>

On Wed, Apr 08, 2020 at 12:51:20PM +0200, Igor Mammedov wrote:
> On Tue,  7 Apr 2020 16:50:17 +0200
> Julia Suvorova <jusual@redhat.com> wrote:
> 
> > Raise an error when trying to hot-plug/unplug a device through QMP to a device
> > with disabled hot-plug capability. This makes the device behaviour more
> > consistent and provides an explanation of the failure in the case of
> > asynchronous unplug.
> 
> it applies to hotplug in general (i.e. not only QMP)
> 
> > 
> > Signed-off-by: Julia Suvorova <jusual@redhat.com>
> > ---
> >  hw/pci/pcie.c | 24 +++++++++++++++++++++---
> >  1 file changed, 21 insertions(+), 3 deletions(-)
> > 
> > diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
> > index 0eb3a2a5d2..e9798caa8a 100644
> > --- a/hw/pci/pcie.c
> > +++ b/hw/pci/pcie.c
> > @@ -415,6 +415,7 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
> >  {
> >      PCIDevice *hotplug_pdev = PCI_DEVICE(hotplug_dev);
> >      uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap;
> > +    uint32_t sltcap = pci_get_word(exp_cap + PCI_EXP_SLTCAP);
> >      PCIDevice *pci_dev = PCI_DEVICE(dev);
> >  
> >      /* Don't send event when device is enabled during qemu machine creation:
> > @@ -430,6 +431,13 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
> >          return;
> >      }
> >  
> > +    /* Hot-plug is disabled on the slot */
> > +    if ((sltcap & PCI_EXP_SLTCAP_HPC) == 0) {
> > +        error_setg(errp, "Device '%s' does not support hot-plug",
> > +                         DEVICE(hotplug_dev)->id);
> plug and unplug_req are synchronous. so one can skip on "Device '%s'",
> user will get this error message as response to device_add/del command.
> 
> and more exactly it's concrete slot that does not support hotplug, how about
> "slot doesn't support ..." or just "hotlpug is not supported"

Well device name is useful here, while these commands are synchronous
others aren't so log parsing might not be synchronous.

I do think we should mention slot since that's the reason
hotplug failed:
    "Device '%s' hot-plug failed: unsupported by slot"

> > +        return;
> > +    }
> > +
> >      /* To enable multifunction hot-plug, we just ensure the function
> >       * 0 added last. When function 0 is added, we set the sltsta and
> >       * inform OS via event notification.
> > @@ -464,14 +472,24 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque)
> >      object_unparent(OBJECT(dev));
> >  }
> >  
> > -void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,
> > +void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_handler,
> >                                       DeviceState *dev, Error **errp)
> >  {
> >      Error *local_err = NULL;
> >      PCIDevice *pci_dev = PCI_DEVICE(dev);
> >      PCIBus *bus = pci_get_bus(pci_dev);
> > +    PCIDevice *hotplug_dev = PCI_DEVICE(hotplug_handler);
> > +    uint8_t *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap;
> > +    uint32_t sltcap = pci_get_word(exp_cap + PCI_EXP_SLTCAP);
> > +
> > +    /* Hot-unplug is disabled on the slot */
> > +    if ((sltcap & PCI_EXP_SLTCAP_HPC) == 0) {
> > +        error_setg(errp, "Device '%s' does not support hot-unplug",
> > +                         DEVICE(hotplug_dev)->id);
> > +        return;

Here too let's mention slot since that's the reason
hotplug failed:
    "Device '%s' hot-unplug failed: unsupported by slot"

?

> > +    }
> >  
> > -    pcie_cap_slot_plug_common(PCI_DEVICE(hotplug_dev), dev, &local_err);
> > +    pcie_cap_slot_plug_common(hotplug_dev, dev, &local_err);
> >      if (local_err) {
> >          error_propagate(errp, local_err);
> >          return;
> > @@ -490,7 +508,7 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,
> >          return;
> >      }
> >  
> > -    pcie_cap_slot_push_attention_button(PCI_DEVICE(hotplug_dev));
> > +    pcie_cap_slot_push_attention_button(hotplug_dev);
> >  }
> >  
> >  /* pci express slot for pci express root/downstream port



WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: qemu-trivial@nongnu.org,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Julia Suvorova" <jusual@redhat.com>,
	qemu-devel@nongnu.org, "Laine Stump" <laine@redhat.com>
Subject: Re: [PATCH] hw/pci/pcie: Forbid hot-plug via QMP if it's disabled on the slot
Date: Mon, 13 Apr 2020 06:54:51 -0400	[thread overview]
Message-ID: <20200413065048-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20200408125120.7678d9ae@redhat.com>

On Wed, Apr 08, 2020 at 12:51:20PM +0200, Igor Mammedov wrote:
> On Tue,  7 Apr 2020 16:50:17 +0200
> Julia Suvorova <jusual@redhat.com> wrote:
> 
> > Raise an error when trying to hot-plug/unplug a device through QMP to a device
> > with disabled hot-plug capability. This makes the device behaviour more
> > consistent and provides an explanation of the failure in the case of
> > asynchronous unplug.
> 
> it applies to hotplug in general (i.e. not only QMP)
> 
> > 
> > Signed-off-by: Julia Suvorova <jusual@redhat.com>
> > ---
> >  hw/pci/pcie.c | 24 +++++++++++++++++++++---
> >  1 file changed, 21 insertions(+), 3 deletions(-)
> > 
> > diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
> > index 0eb3a2a5d2..e9798caa8a 100644
> > --- a/hw/pci/pcie.c
> > +++ b/hw/pci/pcie.c
> > @@ -415,6 +415,7 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
> >  {
> >      PCIDevice *hotplug_pdev = PCI_DEVICE(hotplug_dev);
> >      uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap;
> > +    uint32_t sltcap = pci_get_word(exp_cap + PCI_EXP_SLTCAP);
> >      PCIDevice *pci_dev = PCI_DEVICE(dev);
> >  
> >      /* Don't send event when device is enabled during qemu machine creation:
> > @@ -430,6 +431,13 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev,
> >          return;
> >      }
> >  
> > +    /* Hot-plug is disabled on the slot */
> > +    if ((sltcap & PCI_EXP_SLTCAP_HPC) == 0) {
> > +        error_setg(errp, "Device '%s' does not support hot-plug",
> > +                         DEVICE(hotplug_dev)->id);
> plug and unplug_req are synchronous. so one can skip on "Device '%s'",
> user will get this error message as response to device_add/del command.
> 
> and more exactly it's concrete slot that does not support hotplug, how about
> "slot doesn't support ..." or just "hotlpug is not supported"

Well device name is useful here, while these commands are synchronous
others aren't so log parsing might not be synchronous.

I do think we should mention slot since that's the reason
hotplug failed:
    "Device '%s' hot-plug failed: unsupported by slot"

> > +        return;
> > +    }
> > +
> >      /* To enable multifunction hot-plug, we just ensure the function
> >       * 0 added last. When function 0 is added, we set the sltsta and
> >       * inform OS via event notification.
> > @@ -464,14 +472,24 @@ static void pcie_unplug_device(PCIBus *bus, PCIDevice *dev, void *opaque)
> >      object_unparent(OBJECT(dev));
> >  }
> >  
> > -void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,
> > +void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_handler,
> >                                       DeviceState *dev, Error **errp)
> >  {
> >      Error *local_err = NULL;
> >      PCIDevice *pci_dev = PCI_DEVICE(dev);
> >      PCIBus *bus = pci_get_bus(pci_dev);
> > +    PCIDevice *hotplug_dev = PCI_DEVICE(hotplug_handler);
> > +    uint8_t *exp_cap = hotplug_dev->config + hotplug_dev->exp.exp_cap;
> > +    uint32_t sltcap = pci_get_word(exp_cap + PCI_EXP_SLTCAP);
> > +
> > +    /* Hot-unplug is disabled on the slot */
> > +    if ((sltcap & PCI_EXP_SLTCAP_HPC) == 0) {
> > +        error_setg(errp, "Device '%s' does not support hot-unplug",
> > +                         DEVICE(hotplug_dev)->id);
> > +        return;

Here too let's mention slot since that's the reason
hotplug failed:
    "Device '%s' hot-unplug failed: unsupported by slot"

?

> > +    }
> >  
> > -    pcie_cap_slot_plug_common(PCI_DEVICE(hotplug_dev), dev, &local_err);
> > +    pcie_cap_slot_plug_common(hotplug_dev, dev, &local_err);
> >      if (local_err) {
> >          error_propagate(errp, local_err);
> >          return;
> > @@ -490,7 +508,7 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler *hotplug_dev,
> >          return;
> >      }
> >  
> > -    pcie_cap_slot_push_attention_button(PCI_DEVICE(hotplug_dev));
> > +    pcie_cap_slot_push_attention_button(hotplug_dev);
> >  }
> >  
> >  /* pci express slot for pci express root/downstream port



  reply	other threads:[~2020-04-13 10:55 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-07 14:50 [PATCH] hw/pci/pcie: Forbid hot-plug via QMP if it's disabled on the slot Julia Suvorova
2020-04-07 14:50 ` Julia Suvorova
2020-04-08 10:51 ` Igor Mammedov
2020-04-08 10:51   ` Igor Mammedov
2020-04-13 10:54   ` Michael S. Tsirkin [this message]
2020-04-13 10:54     ` Michael S. Tsirkin
2020-04-15 20:20     ` Julia Suvorova
2020-04-15 20:20       ` Julia Suvorova
2020-04-17  9:51       ` Michael S. Tsirkin
2020-04-17  9:51         ` Michael S. Tsirkin
2020-04-17 11:03         ` Julia Suvorova
2020-04-17 11:03           ` Julia Suvorova
2020-04-17 11:10           ` Michael S. Tsirkin
2020-04-17 11:10             ` Michael S. Tsirkin
2020-04-17 12:17             ` Julia Suvorova
2020-04-17 12:17               ` Julia Suvorova
2020-04-14  8:07 ` Marcel Apfelbaum
2020-04-14  8:07   ` Marcel Apfelbaum
2020-04-15 20:13   ` Julia Suvorova
2020-04-15 20:13     ` Julia Suvorova
2020-04-20 21:41   ` Julia Suvorova

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=20200413065048-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=berrange@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=jusual@redhat.com \
    --cc=laine@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.