Skip to contentSkip to conversation

reset PCI devices on force removal even when QEMU returns error

PATCH In review Stefano Stabellini 5 participants 9 messages Nov 28, 2014 – Jan 6, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 reset PCI devices on force removal even when QEMU returns error

On do_pci_remove when QEMU returns error, we just bail out early without resetting the device. On domain shutdown we are racing with QEMU exiting and most often QEMU closes the QMP connection before executing the requested command.

In these cases if force=1, it makes sense to go ahead with rest of the PCI device removal, that includes resetting the device and calling xc_deassign_device. Otherwise we risk not resetting the device properly on domain shutdown.

tools/libxl/libxl_pci.c +1 -1
index 316643c..0ac0b93 100644
@@ -1243,7 +1245,7 @@ static int do_pci_remove(libxl__gc *gc, uint32_t domid,
             rc = ERROR_INVAL;
             goto out_fail;
         }
-        if (rc) {
+        if (rc && !force) {
             rc = ERROR_FAIL;
             goto out_fail;
         }
Acked-by on v1 1/1
#1 lore raw

On Fri, 2014-11-28 at 16:53 +0000, Stefano Stabellini wrote:

CCing Boris because he was fixing a similar sounding issue in the same area. Not sure if this is related to those patches or not.

Quoted 9 lines

On do_pci_remove when QEMU returns error, we just bail out early without resetting the device. On domain shutdown we are racing with QEMU exiting and most often QEMU closes the QMP connection before executing the requested command.

In these cases if force=1, it makes sense to go ahead with rest of the PCI device removal, that includes resetting the device and calling xc_deassign_device. Otherwise we risk not resetting the device properly on domain shutdown.

ISTR seeing a conversation along the lines of there being a better solution which was more 4.6 material, is that right?

Quoted 1 line

But, I'd prefer to see a version which logs when the qemu side has failed but it is continuing. Probably just adding right after the existing if:

        if (rc)
            LOG("Something appropriate");

would do the trick.

Also this needs RM input from Konrad.

Quoted 14 lines
tools/libxl/libxl_pci.c +1 -1
index 316643c..0ac0b93 100644
@@ -1243,7 +1245,7 @@ static int do_pci_remove(libxl__gc *gc, uint32_t domid,
             rc = ERROR_INVAL;
             goto out_fail;
         }
-        if (rc) {
+        if (rc && !force) {
             rc = ERROR_FAIL;
             goto out_fail;
         }
#2 lore raw
Quoted 4 lines · Ian Campbell

On Fri, 2014-11-28 at 16:53 +0000, Stefano Stabellini wrote:

CCing Boris because he was fixing a similar sounding issue in the same area. Not sure if this is related to those patches or not.

Not really. I was trying to fix something that another Stefano's patch from yesterday is trying to address:

http://lists.xenproject.org/archives/html/xen-devel/2014-12/msg00160.html

although I thought that removing the call to xc_domain_irq_permission() would be the solution.

(which reminds me --- and maybe I shouldn't overload this thread --- that this patch from IanJ needs to get in as well:

http://lists.xenproject.org/archives/html/xen-devel/2014-11/msg01342.html

)

Thanks.
-boris

Quoted 39 lines
Quoted 10 lines

On do_pci_remove when QEMU returns error, we just bail out early without resetting the device. On domain shutdown we are racing with QEMU exiting and most often QEMU closes the QMP connection before executing the requested command.

In these cases if force=1, it makes sense to go ahead with rest of the PCI device removal, that includes resetting the device and calling xc_deassign_device. Otherwise we risk not resetting the device properly on domain shutdown.

ISTR seeing a conversation along the lines of there being a better solution which was more 4.6 material, is that right?

Quoted 1 line

But, I'd prefer to see a version which logs when the qemu side has failed but it is continuing. Probably just adding right after the existing if:

         if (rc)
             LOG("Something appropriate");

would do the trick.

Also this needs RM input from Konrad.

Quoted 13 lines
tools/libxl/libxl_pci.c +1 -1
index 316643c..0ac0b93 100644
@@ -1243,7 +1245,7 @@ static int do_pci_remove(libxl__gc *gc, uint32_t domid,
              rc = ERROR_INVAL;
              goto out_fail;
          }
-        if (rc) {
+        if (rc && !force) {
              rc = ERROR_FAIL;
              goto out_fail;
          }
#3 lore raw
In reply to Stefano Stabellini

Hi Konrad,

This doesn't seem to be applied yet, nor does it seem to have a release-(N)ACK from you ?

--
Sander

Quoted 25 lines · you

On do_pci_remove when QEMU returns error, we just bail out early without resetting the device. On domain shutdown we are racing with QEMU exiting and most often QEMU closes the QMP connection before executing the requested command.

In these cases if force=1, it makes sense to go ahead with rest of the PCI device removal, that includes resetting the device and calling xc_deassign_device. Otherwise we risk not resetting the device properly on domain shutdown.

tools/libxl/libxl_pci.c +1 -1
index 316643c..0ac0b93 100644
@@ -1243,7 +1245,7 @@ static int do_pci_remove(libxl__gc *gc, uint32_t domid,
             rc = ERROR_INVAL;
             goto out_fail;
         }
-        if (rc) {
+        if (rc && !force) {
             rc = ERROR_FAIL;
             goto out_fail;
         }
#4 lore raw
Quoted 4 lines · Sander Eikelenboom

Hi Konrad,

This doesn't seem to be applied yet, nor does it seem to have a release-(N)ACK from you ?

Hm, Stefano:

- Is this a regression?

- What are the risks of this not going in? I presume that it just means we haven't reset it in sysfs. But the xc_deassign_device operation if not done will not affect the hypervisor - which will move the device to dom0 upon guest teardown.

Quoted 35 lines

--
Sander

Quoted 25 lines · you

On do_pci_remove when QEMU returns error, we just bail out early without resetting the device. On domain shutdown we are racing with QEMU exiting and most often QEMU closes the QMP connection before executing the requested command.

In these cases if force=1, it makes sense to go ahead with rest of the PCI device removal, that includes resetting the device and calling xc_deassign_device. Otherwise we risk not resetting the device properly on domain shutdown.

tools/libxl/libxl_pci.c +1 -1
index 316643c..0ac0b93 100644
@@ -1243,7 +1245,7 @@ static int do_pci_remove(libxl__gc *gc, uint32_t domid,
             rc = ERROR_INVAL;
             goto out_fail;
         }
-        if (rc) {
+        if (rc && !force) {
             rc = ERROR_FAIL;
             goto out_fail;
         }
#5 lore raw
Quoted 9 lines · Konrad Rzeszutek Wilk
Quoted 4 lines · Sander Eikelenboom

Hi Konrad,

This doesn't seem to be applied yet, nor does it seem to have a release-(N)ACK from you ?

Hm, Stefano:

- Is this a regression?

I don't think so. Probably a regression compared to the xend toolstack though.

Quoted 4 lines

- What are the risks of this not going in? I presume that it just means we haven't reset it in sysfs. But the xc_deassign_device operation if not done will not affect the hypervisor - which will move the device to dom0 upon guest teardown.

The device becomes unusable until somebody manually resets it.

Quoted 36 lines
Quoted 35 lines

--
Sander

Quoted 25 lines · you

On do_pci_remove when QEMU returns error, we just bail out early without resetting the device. On domain shutdown we are racing with QEMU exiting and most often QEMU closes the QMP connection before executing the requested command.

In these cases if force=1, it makes sense to go ahead with rest of the PCI device removal, that includes resetting the device and calling xc_deassign_device. Otherwise we risk not resetting the device properly on domain shutdown.

tools/libxl/libxl_pci.c +1 -1
index 316643c..0ac0b93 100644
@@ -1243,7 +1245,7 @@ static int do_pci_remove(libxl__gc *gc, uint32_t domid,
             rc = ERROR_INVAL;
             goto out_fail;
         }
-        if (rc) {
+        if (rc && !force) {
             rc = ERROR_FAIL;
             goto out_fail;
         }
#6 lore raw
Quoted 7 lines · Stefano Stabellini
Quoted 6 lines · Konrad Rzeszutek Wilk
Quoted 4 lines · Sander Eikelenboom

Hi Konrad,

This doesn't seem to be applied yet, nor does it seem to have a release-(N)ACK from you ?

Quoted 6 lines
Quoted 3 lines

Hm, Stefano:

- Is this a regression?

I don't think so. Probably a regression compared to the xend toolstack though.

OK, so that is Xen 4.4 -> Xen 4.5 regression then.

Thanks.

Quoted 46 lines
Quoted 6 lines

- What are the risks of this not going in? I presume that it just means we haven't reset it in sysfs. But the xc_deassign_device operation if not done will not affect the hypervisor - which will move the device to dom0 upon guest teardown.

The device becomes unusable until somebody manually resets it.

Quoted 36 lines
Quoted 35 lines

--
Sander

Quoted 25 lines · you

On do_pci_remove when QEMU returns error, we just bail out early without resetting the device. On domain shutdown we are racing with QEMU exiting and most often QEMU closes the QMP connection before executing the requested command.

In these cases if force=1, it makes sense to go ahead with rest of the PCI device removal, that includes resetting the device and calling xc_deassign_device. Otherwise we risk not resetting the device properly on domain shutdown.

tools/libxl/libxl_pci.c +1 -1
index 316643c..0ac0b93 100644
@@ -1243,7 +1245,7 @@ static int do_pci_remove(libxl__gc *gc, uint32_t domid,
             rc = ERROR_INVAL;
             goto out_fail;
         }
-        if (rc) {
+        if (rc && !force) {
             rc = ERROR_FAIL;
             goto out_fail;
         }
#7 lore raw
Quoted 10 lines · Konrad Rzeszutek Wilk
Quoted 9 lines · Stefano Stabellini
Quoted 8 lines · Konrad Rzeszutek Wilk
Quoted 4 lines · Sander Eikelenboom

Hi Konrad,

This doesn't seem to be applied yet, nor does it seem to have a release-(N)ACK from you ?

Hm, Stefano:

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

- Is this a regression?

I don't think so. Probably a regression compared to the xend toolstack though.

OK, so that is Xen 4.4 -> Xen 4.5 regression then.

An updated version with the logging which I had indicated I would prefer doesn't appear to be forthcoming so I've just applied this one.

#8 lore raw
Quoted 16 lines · you
Quoted 15 lines · Konrad Rzeszutek Wilk
Quoted 13 lines · Stefano Stabellini
Quoted 9 lines · Konrad Rzeszutek Wilk
Quoted 4 lines · Sander Eikelenboom

Hi Konrad,

This doesn't seem to be applied yet, nor does it seem to have a release-(N)ACK from you ?

Hm, Stefano:

- Is this a regression?

I don't think so. Probably a regression compared to the xend toolstack though.

Quoted 6 lines
Quoted 3 lines

OK, so that is Xen 4.4 -> Xen 4.5 regression then.

An updated version with the logging which I had indicated I would prefer doesn't appear to be forthcoming so I've just applied this one.

I wasn't aware of that, thx for applying !

--
Sander