Skip to contentSkip to conversation

libxl: create backend/ xenstore dir for driver domains

PATCH In review Marek Marczykowski-Górecki 3 participants 9 messages Jan 5, 2020 – Mar 25, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: create backend/ xenstore dir for driver domains

Cleaning up backend xenstore entries is a responsibility of the backend. When backend lives outside of dom0, the domain needs proper permissions to do it. Normally it is given permission to remove the device dir itself, but not the dir containing it (named after frontend ID). After a whole those empty leftover directories accumulate to the point xenstore returning E2BIG on listing them.

Fix this by giving backend domain write access also to backend/ directory itself when c_info->driver_domain option is set. The code removing relevant dir is already there (just lacked permissions to do so).

Note this also allows the backend domain to create new entries, pretending to host backend devices it don't have. But since libxl uses /libxl/ xenstore dir for this information (still outside of backend domain control), this shouldn't be an issue.

---
 tools/libxl/libxl_create.c | 7 +++++++
 1 file changed, 7 insertions(+)
tools/libxl/libxl_create.c +7 -0
index a6d40b753e..38ca9b85a4 100644
@@ -763,6 +763,13 @@ retry_transaction:
          */
         libxl__xs_mknod(gc, t, GCSPRINTF("%s/device-model", dom_path), rwperm,
                         ARRAY_SIZE(rwperm));
+
+        /*
+         * Create a local "backend" directory for each guest, writable by that
+         * guest, to allow it properly cleanup removed devices
+         */
+        libxl__xs_mknod(gc, t, GCSPRINTF("%s/backend", dom_path), rwperm,
+                        ARRAY_SIZE(rwperm));
     }
 
     vm_list = libxl_list_vm(ctx, &nb_vm);
Signature · 7 lines
2.21.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw

Marek Marczykowski-Górecki writes ("[PATCH] libxl: create backend/ xenstore dir for driver domains"):

Quoted 7 lines

Cleaning up backend xenstore entries is a responsibility of the backend. When backend lives outside of dom0, the domain needs proper permissions to do it. Normally it is given permission to remove the device dir itself, but not the dir containing it (named after frontend ID). After a whole those empty leftover directories accumulate to the point xenstore returning E2BIG on listing them.

Quoted 8 lines

Fix this by giving backend domain write access also to backend/ directory itself when c_info->driver_domain option is set. The code removing relevant dir is already there (just lacked permissions to do so).

Note this also allows the backend domain to create new entries, pretending to host backend devices it don't have. But since libxl uses /libxl/ xenstore dir for this information (still outside of backend domain control), this shouldn't be an issue.

This seems quite hazardous to me. The reasoning you use to show that this iws OK seems fragile, and in general it doesn't feel right to give the particular backend such wide scope.

Can we find another way to address this problem ? I think the containing directory should be removed by the toolstack. Why is this difficult ? (I presume there is a reason or you would have done it that way...)

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

author Acked-by Ian Jackson Acked-by Ian Campbell
#2 lore raw
Quoted 17 lines · Ian Jackson

Marek Marczykowski-Górecki writes ("[PATCH] libxl: create backend/ xenstore dir for driver domains"):

Quoted 7 lines

Cleaning up backend xenstore entries is a responsibility of the backend. When backend lives outside of dom0, the domain needs proper permissions to do it. Normally it is given permission to remove the device dir itself, but not the dir containing it (named after frontend ID). After a whole those empty leftover directories accumulate to the point xenstore returning E2BIG on listing them.

Quoted 8 lines

Fix this by giving backend domain write access also to backend/ directory itself when c_info->driver_domain option is set. The code removing relevant dir is already there (just lacked permissions to do so).

Note this also allows the backend domain to create new entries, pretending to host backend devices it don't have. But since libxl uses /libxl/ xenstore dir for this information (still outside of backend domain control), this shouldn't be an issue.

Quoted 8 lines

This seems quite hazardous to me. The reasoning you use to show that this iws OK seems fragile, and in general it doesn't feel right to give the particular backend such wide scope.

Can we find another way to address this problem ? I think the containing directory should be removed by the toolstack. Why is this difficult ? (I presume there is a reason or you would have done it that way...)

It was done this way previously and caused issues, see this commit:

commit 546678c6a60f64fb186640460dfa69a837c8fba5

Author: Roger Pau Monne <[email protected]>
Date:   Wed Sep 23 12:06:56 2015 +0200

libxl: fix the cleanup of the backend path when using driver domains

With the current libxl implementation the control domain will remove both the frontend and the backend xenstore paths of a device that's handled by a driver domain. This is incorrect, since the driver domain possibly needs to access the backend path in order to perform the disconnection and cleanup of the device.

Fix this by making sure the control domain only cleans the frontend path, leaving the backend path to be cleaned by the driver domain. Note that if the device is not handled by a driver domain the control domain will perform the removal of both the frontend and the backend paths.

Signature · 5 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw

Adding Roger to the CC.

Marek Marczykowski-Górecki writes ("Re: [PATCH] libxl: create backend/ xenstore dir for driver domains"):

Quoted 27 lines · Ian Jackson
Quoted 17 lines

Marek Marczykowski-Górecki writes ("[PATCH] libxl: create backend/ xenstore dir for driver domains"):

Quoted 7 lines

Cleaning up backend xenstore entries is a responsibility of the backend. When backend lives outside of dom0, the domain needs proper permissions to do it. Normally it is given permission to remove the device dir itself, but not the dir containing it (named after frontend ID). After a whole those empty leftover directories accumulate to the point xenstore returning E2BIG on listing them.

Quoted 8 lines

Fix this by giving backend domain write access also to backend/ directory itself when c_info->driver_domain option is set. The code removing relevant dir is already there (just lacked permissions to do so).

Note this also allows the backend domain to create new entries, pretending to host backend devices it don't have. But since libxl uses /libxl/ xenstore dir for this information (still outside of backend domain control), this shouldn't be an issue.

Quoted 8 lines

This seems quite hazardous to me. The reasoning you use to show that this iws OK seems fragile, and in general it doesn't feel right to give the particular backend such wide scope.

Can we find another way to address this problem ? I think the containing directory should be removed by the toolstack. Why is this difficult ? (I presume there is a reason or you would have done it that way...)

Quoted 7 lines

It was done this way previously and caused issues, see this commit:

commit 546678c6a60f64fb186640460dfa69a837c8fba5

Author: Roger Pau Monne <[email protected]>
Date:   Wed Sep 23 12:06:56 2015 +0200

libxl: fix the cleanup of the backend path when using driver domains

Thanks.

Quoted 7 lines

With the current libxl implementation the control domain will remove both the frontend and the backend xenstore paths of a device that's handled by a driver domain. This is incorrect, since the driver domain possibly needs to access the backend path in order to perform the disconnection and cleanup of the device.

Quoted 5 lines

Fix this by making sure the control domain only cleans the frontend path, leaving the backend path to be cleaned by the driver domain. Note that if the device is not handled by a driver domain the control domain will perform the removal of both the frontend and the backend paths.

Hmm. I see my Ack on that. Nevertheless maybe it is wrong.

Looking at it afresh, I think maybe the right answer is:

* If the driver domain is expected to be working properly, the toolstack should wait for the driver domain to complete the device shutdown, before removing the backend node. Indeed, the toolstack ought to wait for this before actually destroying the guest in Xen, by the usual logic for clean domain shutdown.

* There needs to be a way to deal with a broken/unresponsive driver domain. That will involve not waiting for the backend so must involve simply deleting the backend from xenstore.

Is the distinction here between "xl shutdown" and "xl destroy", on the actual guest domain, good enough ? Hopefully if the driver domain sees the backend directory simply vanish it can destructively tear everything down ?

Ian.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw
Quoted 55 lines · Ian Jackson

Adding Roger to the CC.

Marek Marczykowski-Górecki writes ("Re: [PATCH] libxl: create backend/ xenstore dir for driver domains"):

Quoted 27 lines · Ian Jackson
Quoted 17 lines

Marek Marczykowski-Górecki writes ("[PATCH] libxl: create backend/ xenstore dir for driver domains"):

Quoted 7 lines

Cleaning up backend xenstore entries is a responsibility of the backend. When backend lives outside of dom0, the domain needs proper permissions to do it. Normally it is given permission to remove the device dir itself, but not the dir containing it (named after frontend ID). After a whole those empty leftover directories accumulate to the point xenstore returning E2BIG on listing them.

Quoted 8 lines

Fix this by giving backend domain write access also to backend/ directory itself when c_info->driver_domain option is set. The code removing relevant dir is already there (just lacked permissions to do so).

Note this also allows the backend domain to create new entries, pretending to host backend devices it don't have. But since libxl uses /libxl/ xenstore dir for this information (still outside of backend domain control), this shouldn't be an issue.

Quoted 8 lines

This seems quite hazardous to me. The reasoning you use to show that this iws OK seems fragile, and in general it doesn't feel right to give the particular backend such wide scope.

Can we find another way to address this problem ? I think the containing directory should be removed by the toolstack. Why is this difficult ? (I presume there is a reason or you would have done it that way...)

Quoted 7 lines

It was done this way previously and caused issues, see this commit:

commit 546678c6a60f64fb186640460dfa69a837c8fba5

Author: Roger Pau Monne <[email protected]>
Date:   Wed Sep 23 12:06:56 2015 +0200

libxl: fix the cleanup of the backend path when using driver domains

Thanks.

Quoted 7 lines

With the current libxl implementation the control domain will remove both the frontend and the backend xenstore paths of a device that's handled by a driver domain. This is incorrect, since the driver domain possibly needs to access the backend path in order to perform the disconnection and cleanup of the device.

Quoted 5 lines

Fix this by making sure the control domain only cleans the frontend path, leaving the backend path to be cleaned by the driver domain. Note that if the device is not handled by a driver domain the control domain will perform the removal of both the frontend and the backend paths.

Hmm. I see my Ack on that. Nevertheless maybe it is wrong.

Quoted 7 lines

Looking at it afresh, I think maybe the right answer is:

* If the driver domain is expected to be working properly, the toolstack should wait for the driver domain to complete the device shutdown, before removing the backend node. Indeed, the toolstack ought to wait for this before actually destroying the guest in Xen, by the usual logic for clean domain shutdown.

I think that's not enough. .../state = 6 is set by the kernel, but xl devd in the driver domain may want to cleanup things (hotplug scripts etc). And indeed libxl__device_destroy() is called from device_hotplug_done(), not device_backend_callback().

Alternatively, toolstack could wait for the actual backend node to be removed (by the driver domain), and then cleanup the parent directory (if empty). I don't find it particularly appealing, as every contact with libxl async code reduce overall happiness...

Quoted 3 lines

* There needs to be a way to deal with a broken/unresponsive driver domain. That will involve not waiting for the backend so must involve simply deleting the backend from xenstore.

It's already there: if driver domain fails to set .../state = 6 within a timeout, toolstack will forcibly remove the entry.

Quoted 4 lines

Is the distinction here between "xl shutdown" and "xl destroy", on the actual guest domain, good enough ? Hopefully if the driver domain sees the backend directory simply vanish it can destructively tear everything down ?

In the past this lead to multiple issues, where hotplug script didn't know which device actually was removed. In some cases I needed to workaround this by saving xenstore dump into a file in an "online" hotplug script, but it is very ugly solution.

Signature · 5 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#5 lore raw
Quoted 86 lines · Marek Marczykowski-Górecki
Quoted 55 lines · Ian Jackson

Adding Roger to the CC.

Marek Marczykowski-Górecki writes ("Re: [PATCH] libxl: create backend/ xenstore dir for driver domains"):

Quoted 27 lines · Ian Jackson
Quoted 17 lines

Marek Marczykowski-Górecki writes ("[PATCH] libxl: create backend/ xenstore dir for driver domains"):

Quoted 7 lines

Cleaning up backend xenstore entries is a responsibility of the backend. When backend lives outside of dom0, the domain needs proper permissions to do it. Normally it is given permission to remove the device dir itself, but not the dir containing it (named after frontend ID). After a whole those empty leftover directories accumulate to the point xenstore returning E2BIG on listing them.

Quoted 8 lines

Fix this by giving backend domain write access also to backend/ directory itself when c_info->driver_domain option is set. The code removing relevant dir is already there (just lacked permissions to do so).

Note this also allows the backend domain to create new entries, pretending to host backend devices it don't have. But since libxl uses /libxl/ xenstore dir for this information (still outside of backend domain control), this shouldn't be an issue.

Quoted 8 lines

This seems quite hazardous to me. The reasoning you use to show that this iws OK seems fragile, and in general it doesn't feel right to give the particular backend such wide scope.

Can we find another way to address this problem ? I think the containing directory should be removed by the toolstack. Why is this difficult ? (I presume there is a reason or you would have done it that way...)

Quoted 7 lines

It was done this way previously and caused issues, see this commit:

commit 546678c6a60f64fb186640460dfa69a837c8fba5

Author: Roger Pau Monne <[email protected]>
Date:   Wed Sep 23 12:06:56 2015 +0200

libxl: fix the cleanup of the backend path when using driver domains

Thanks.

Quoted 7 lines

With the current libxl implementation the control domain will remove both the frontend and the backend xenstore paths of a device that's handled by a driver domain. This is incorrect, since the driver domain possibly needs to access the backend path in order to perform the disconnection and cleanup of the device.

Quoted 5 lines

Fix this by making sure the control domain only cleans the frontend path, leaving the backend path to be cleaned by the driver domain. Note that if the device is not handled by a driver domain the control domain will perform the removal of both the frontend and the backend paths.

Hmm. I see my Ack on that. Nevertheless maybe it is wrong.

Quoted 7 lines

Looking at it afresh, I think maybe the right answer is:

* If the driver domain is expected to be working properly, the toolstack should wait for the driver domain to complete the device shutdown, before removing the backend node. Indeed, the toolstack ought to wait for this before actually destroying the guest in Xen, by the usual logic for clean domain shutdown.

I think that's not enough. .../state = 6 is set by the kernel, but xl devd in the driver domain may want to cleanup things (hotplug scripts etc). And indeed libxl__device_destroy() is called from device_hotplug_done(), not device_backend_callback().

Alternatively, toolstack could wait for the actual backend node to be removed (by the driver domain), and then cleanup the parent directory (if empty). I don't find it particularly appealing, as every contact with libxl async code reduce overall happiness...

Quoted 3 lines

* There needs to be a way to deal with a broken/unresponsive driver domain. That will involve not waiting for the backend so must involve simply deleting the backend from xenstore.

It's already there: if driver domain fails to set .../state = 6 within a timeout, toolstack will forcibly remove the entry.

Quoted 4 lines

Is the distinction here between "xl shutdown" and "xl destroy", on the actual guest domain, good enough ? Hopefully if the driver domain sees the backend directory simply vanish it can destructively tear everything down ?

Quoted 4 lines

In the past this lead to multiple issues, where hotplug script didn't know which device actually was removed. In some cases I needed to workaround this by saving xenstore dump into a file in an "online" hotplug script, but it is very ugly solution.

Any opinion on the above?
In the above context (plus the fact that the toolstack use /libxl to enumerate devices), I still think giving driver domain write access to the backend/ node is the right solution for this problem.

Signature · 5 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#6 lore raw
In reply to Marek Marczykowski-Górecki
Quoted 64 lines · Marek Marczykowski-Górecki
Quoted 55 lines · Ian Jackson

Adding Roger to the CC.

Marek Marczykowski-Górecki writes ("Re: [PATCH] libxl: create backend/ xenstore dir for driver domains"):

Quoted 27 lines · Ian Jackson
Quoted 17 lines

Marek Marczykowski-Górecki writes ("[PATCH] libxl: create backend/ xenstore dir for driver domains"):

Quoted 7 lines

Cleaning up backend xenstore entries is a responsibility of the backend. When backend lives outside of dom0, the domain needs proper permissions to do it. Normally it is given permission to remove the device dir itself, but not the dir containing it (named after frontend ID). After a whole those empty leftover directories accumulate to the point xenstore returning E2BIG on listing them.

Quoted 8 lines

Fix this by giving backend domain write access also to backend/ directory itself when c_info->driver_domain option is set. The code removing relevant dir is already there (just lacked permissions to do so).

Note this also allows the backend domain to create new entries, pretending to host backend devices it don't have. But since libxl uses /libxl/ xenstore dir for this information (still outside of backend domain control), this shouldn't be an issue.

Quoted 8 lines

This seems quite hazardous to me. The reasoning you use to show that this iws OK seems fragile, and in general it doesn't feel right to give the particular backend such wide scope.

Can we find another way to address this problem ? I think the containing directory should be removed by the toolstack. Why is this difficult ? (I presume there is a reason or you would have done it that way...)

Quoted 7 lines

It was done this way previously and caused issues, see this commit:

commit 546678c6a60f64fb186640460dfa69a837c8fba5

Author: Roger Pau Monne <[email protected]>
Date:   Wed Sep 23 12:06:56 2015 +0200

libxl: fix the cleanup of the backend path when using driver domains

Thanks.

Quoted 7 lines

With the current libxl implementation the control domain will remove both the frontend and the backend xenstore paths of a device that's handled by a driver domain. This is incorrect, since the driver domain possibly needs to access the backend path in order to perform the disconnection and cleanup of the device.

Quoted 5 lines

Fix this by making sure the control domain only cleans the frontend path, leaving the backend path to be cleaned by the driver domain. Note that if the device is not handled by a driver domain the control domain will perform the removal of both the frontend and the backend paths.

Hmm. I see my Ack on that. Nevertheless maybe it is wrong.

Quoted 7 lines

Looking at it afresh, I think maybe the right answer is:

* If the driver domain is expected to be working properly, the toolstack should wait for the driver domain to complete the device shutdown, before removing the backend node. Indeed, the toolstack ought to wait for this before actually destroying the guest in Xen, by the usual logic for clean domain shutdown.

Quoted 8 lines

I think that's not enough. .../state = 6 is set by the kernel, but xl devd in the driver domain may want to cleanup things (hotplug scripts etc). And indeed libxl__device_destroy() is called from device_hotplug_done(), not device_backend_callback().

Alternatively, toolstack could wait for the actual backend node to be removed (by the driver domain), and then cleanup the parent directory (if empty).

I'm not sure you need to cleanup the parent directory, albeit it wouldn't hurt. It needs to be done in a transaction though, so that you don't race with new additions to it.

Quoted 9 lines

I don't find it particularly appealing, as every contact with libxl async code reduce overall happiness...

Quoted 3 lines

* There needs to be a way to deal with a broken/unresponsive driver domain. That will involve not waiting for the backend so must involve simply deleting the backend from xenstore.

It's already there: if driver domain fails to set .../state = 6 within a timeout, toolstack will forcibly remove the entry.

Would it work to change this and instead of monitor .../state = 6 monitor that the parent directory still exist?

Quoted 9 lines
Quoted 4 lines

Is the distinction here between "xl shutdown" and "xl destroy", on the actual guest domain, good enough ? Hopefully if the driver domain sees the backend directory simply vanish it can destructively tear everything down ?

In the past this lead to multiple issues, where hotplug script didn't know which device actually was removed. In some cases I needed to workaround this by saving xenstore dump into a file in an "online" hotplug script, but it is very ugly solution.

Removing the whole directory without giving time to the driver domain to execute it's hotplug scripts can indeed lead to issues, as there's no guarantee that the hotplug script won't use data in xenstore in order to perform the cleanup IIRC.

My preferred option would be to wait for the backend directory to be removed by the driver domain, as I think it's the cleanest and likely safest approach.

Thanks, Roger.

#7 lore raw
Quoted 6 lines · Roger Pau Monné
Quoted 3 lines · Marek Marczykowski-Górecki

Alternatively, toolstack could wait for the actual backend node to be removed (by the driver domain), and then cleanup the parent directory (if empty).

I'm not sure you need to cleanup the parent directory,

You do, that's why this is an issue. Otherwise empty directories will accumulate there, leading to various issues (inability to list, running out of watches for monitoring them etc).

Example state:

/local/domain/5/backend = ""
/local/domain/5/backend/vif = ""
/local/domain/5/backend/vif/6 = "" /local/domain/5/backend/vif/7 = "" /local/domain/5/backend/vif/7/0 = "" /local/domain/5/backend/vif/7/0/frontend = "/local/domain/7/device/vif/0" /local/domain/5/backend/vif/7/0/frontend-id = "7" /local/domain/5/backend/vif/7/0/online = "1" /local/domain/5/backend/vif/7/0/state = "4" /local/domain/5/backend/vif/7/0/script = "/etc/xen/scripts/vif-route-qubes" /local/domain/5/backend/vif/7/0/mac = "00:16:3e:5e:6c:00" /local/domain/5/backend/vif/7/0/ip = "10.137.0.49 fd09:24ef:4179::a89:31" /local/domain/5/backend/vif/7/0/bridge = "xenbr0" /local/domain/5/backend/vif/7/0/handle = "0" /local/domain/5/backend/vif/7/0/type = "vif" /local/domain/5/backend/vif/7/0/feature-sg = "1" /local/domain/5/backend/vif/7/0/feature-gso-tcpv4 = "1" /local/domain/5/backend/vif/7/0/feature-gso-tcpv6 = "1" /local/domain/5/backend/vif/7/0/feature-ipv6-csum-offload = "1" /local/domain/5/backend/vif/7/0/feature-rx-copy = "1" /local/domain/5/backend/vif/7/0/feature-rx-flip = "0" /local/domain/5/backend/vif/7/0/feature-multicast-control = "1" /local/domain/5/backend/vif/7/0/feature-dynamic-multicast-control = "1" /local/domain/5/backend/vif/7/0/feature-split-event-channels = "1" /local/domain/5/backend/vif/7/0/multi-queue-max-queues = "2" /local/domain/5/backend/vif/7/0/feature-ctrl-ring = "1" /local/domain/5/backend/vif/7/0/hotplug-status = "connected" /local/domain/5/backend/vif/8 = "" /local/domain/5/backend/vif/11 = "" /local/domain/5/backend/vif/12 = "" /local/domain/5/backend/vif/17 = "" /local/domain/5/backend/vif/20 = "" /local/domain/5/backend/vif/23 = "" /local/domain/5/backend/vif/26 = "" /local/domain/5/backend/vif/28 = "" /local/domain/5/backend/vif/29 = "" /local/domain/5/backend/vif/30 = "" /local/domain/5/backend/vif/33 = "" /local/domain/5/backend/vif/34 = ""
(...)
/local/domain/5/backend/vif/416 = ""

Quoted 3 lines

albeit it
wouldn't hurt. It needs to be done in a transaction though, so that you don't race with new additions to it.

Good point.

Quoted 7 lines
Quoted 7 lines

I don't find it particularly appealing, as every contact with libxl async code reduce overall happiness...

Quoted 3 lines

* There needs to be a way to deal with a broken/unresponsive driver domain. That will involve not waiting for the backend so must involve simply deleting the backend from xenstore.

Quoted 5 lines
Quoted 2 lines

It's already there: if driver domain fails to set .../state = 6 within a timeout, toolstack will forcibly remove the entry.

Would it work to change this and instead of monitor .../state = 6 monitor that the parent directory still exist?

That could be a good idea, to avoid introducing yet another (set of) callback. I'll look into it, it may require different handling of dom0/non-dom0 backend.

Quoted 10 lines
Quoted 9 lines
Quoted 4 lines

Is the distinction here between "xl shutdown" and "xl destroy", on the actual guest domain, good enough ? Hopefully if the driver domain sees the backend directory simply vanish it can destructively tear everything down ?

In the past this lead to multiple issues, where hotplug script didn't know which device actually was removed. In some cases I needed to workaround this by saving xenstore dump into a file in an "online" hotplug script, but it is very ugly solution.

Quoted 4 lines

Removing the whole directory without giving time to the driver domain to execute it's hotplug scripts can indeed lead to issues, as there's no guarantee that the hotplug script won't use data in xenstore in order to perform the cleanup IIRC.

Yes, that's what 546678c6a60f64fb186640460dfa69a837c8fba5 fixed, but not removing it too early.

Quoted 6 lines

My preferred option would be to wait for the backend directory to be removed by the driver domain, as I think it's the cleanest and likely safest approach.

Thanks, Roger.

Signature · 5 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
#8 lore raw
Quoted 9 lines · Marek Marczykowski-Górecki
Quoted 8 lines · Roger Pau Monné
Quoted 6 lines · Marek Marczykowski-Górecki
Quoted 3 lines

* There needs to be a way to deal with a broken/unresponsive driver domain. That will involve not waiting for the backend so must involve simply deleting the backend from xenstore.

It's already there: if driver domain fails to set .../state = 6 within a timeout, toolstack will forcibly remove the entry.

Quoted 6 lines
Quoted 2 lines

Would it work to change this and instead of monitor .../state = 6 monitor that the parent directory still exist?

That could be a good idea, to avoid introducing yet another (set of) callback. I'll look into it, it may require different handling of dom0/non-dom0 backend.

Yes, the domain handling the backend needs to watch .../state, while the control domain (where the toolstack actually runs) would need to watch .../ AFAICT.

As you say, I think you could maybe reuse some of the code and add a special case for the toolstack domain when the backend runs in a driver domain.

Thanks, Roger.