Skip to contentSkip to conversation

libxl: add libxl__is_driver_domain function

PATCH In review Oleksandr Grytsov 2 participants 11 messages Dec 14, 2017 – Oct 2, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxl: add libxl__is_driver_domain function

From: Oleksandr Grytsov <[email protected]>

We have following arm-based setup:

- Dom0 with xen and xen tools;
- Dom1 with device backends (but it is not the driver domain);
- Dom2 with device frontend;

On Dom2 destroying we have timeout error. Because xl treats our Dom1 as driver domain and waits for backend path to be cleared by the driver domain which is not our case.

According to libxl__domain_make in case of driver domain it has "libxl" xen store entry:

    if (libxl_defbool_val(info->driver_domain)) {
        /*
         * Create a local "libxl" directory for each guest, since we might want
         * to use libxl from inside the guest
         */
        libxl__xs_mknod(gc, t, GCSPRINTF("%s/libxl", dom_path), rwperm,
                        ARRAY_SIZE(rwperm));

This patch introduces libxl__is_driver_domain which determines the driver domain by checking if "libxl" entry is present and uses this function on device destroy to check by whom domain path should be cleaned up (libxl or the driver domain).

Oleksandr Grytsov (1):
libxl: add libxl__is_driver_domain function

 tools/libxl/libxl_device.c   | 17 ++++++++++-------
 tools/libxl/libxl_internal.c | 16 ++++++++++++++++
 tools/libxl/libxl_internal.h |  4 ++++
 3 files changed, 30 insertions(+), 7 deletions(-)
Signature · 7 lines
2.7.4


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

PATCH 1/1 libxl: add libxl__is_driver_domain function

From: Oleksandr Grytsov <[email protected]>

libxl__is_driver_domain determines the driver domain by presence of libxl entry in the domain xen store. Use this function on device destroy to properly manage cleanup in case backends are located on domain with non zero id.

---
 tools/libxl/libxl_device.c   | 17 ++++++++++-------
 tools/libxl/libxl_internal.c | 16 ++++++++++++++++
 tools/libxl/libxl_internal.h |  4 ++++
 3 files changed, 30 insertions(+), 7 deletions(-)
tools/libxl/libxl_device.c +10 -7
index f84422e..08a33e2 100644
@@ -732,7 +732,7 @@ int libxl__device_destroy(libxl__gc *gc, libxl__device *dev)
                 libxl__xs_path_cleanup(gc, t, fe_path);
             libxl__xs_path_cleanup(gc, t, libxl_path);
         }
-        if (dev->backend_domid == domid && !libxl_only) {
+        if (!libxl__is_driver_domain(gc, dev->backend_domid) && !libxl_only) {
             /*
              * The driver domain is in charge of removing what it can
              * from the backend path.
@@ -1110,16 +1110,19 @@ static void device_hotplug(libxl__egc *egc, libxl__ao_device *aodev)
         LOGD(ERROR, aodev->dev->domid, "Failed to get domid");
         goto out;
     }
-    if (aodev->dev->backend_domid != domid) {
+
+    if (aodev->dev->backend_domid != domid &&
+        aodev->action != LIBXL__DEVICE_ACTION_REMOVE) {
+        LOG(DEBUG, "Not a remove, not executing hotplug scripts");
+        goto out;
+    }
+
+    if (libxl__is_driver_domain(gc, aodev->dev->backend_domid) &&
+        aodev->action == LIBXL__DEVICE_ACTION_REMOVE) {
         LOGD(DEBUG, aodev->dev->domid,
              "Backend domid %d, domid %d, assuming driver domains",
              aodev->dev->backend_domid, domid);
 
-        if (aodev->action != LIBXL__DEVICE_ACTION_REMOVE) {
-            LOG(DEBUG, "Not a remove, not executing hotplug scripts");
-            goto out;
-        }
-
         aodev->xswait.ao = ao;
         aodev->xswait.what = "removal of backend path";
         aodev->xswait.path = be_path;
tools/libxl/libxl_internal.c +16 -0
index f492dae..a65bc58 100644
@@ -575,6 +575,22 @@ void libxl__update_domain_configuration(libxl__gc *gc,
     dst->b_info.video_memkb = src->b_info.video_memkb;
 }
 
+bool libxl__is_driver_domain(libxl__gc *gc, uint32_t domid)
+{
+    const char *val;
+    int rc;
+
+    char *dom_path = libxl__xs_get_dompath(gc, domid);
+
+    if (!dom_path) return false;
+
+    rc = libxl__xs_read_checked(gc, XBT_NULL,
+                                GCSPRINTF("%s/libxl", dom_path), &val);
+    if (rc) return false;
+
+    return val != NULL;
+}
+
 /*
  * Local variables:
  * mode: C
tools/libxl/libxl_internal.h +4 -0
index 7fab561..f566d81 100644
@@ -4414,6 +4414,10 @@ void* libxl__device_list(libxl__gc *gc, const struct libxl_device_type *dt,
                          uint32_t domid, int *num);
 void libxl__device_list_free(const struct libxl_device_type *dt,
                              void *list, int num);
+
+/* Check if domain is driver domain */
+_hidden bool libxl__is_driver_domain(libxl__gc *gc, uint32_t domid);
+
 #endif
 
 /*
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#2 lore raw
In reply to Oleksandr Grytsov
Quoted 32 lines · Oleksandr Grytsov

From: Oleksandr Grytsov <[email protected]>

We have following arm-based setup:

- Dom0 with xen and xen tools;
- Dom1 with device backends (but it is not the driver domain);
- Dom2 with device frontend;

On Dom2 destroying we have timeout error. Because xl treats our Dom1 as driver domain and waits for backend path to be cleared by the driver domain which is not our case.

According to libxl__domain_make in case of driver domain it has "libxl" xen store entry:

    if (libxl_defbool_val(info->driver_domain)) {
        /*
         * Create a local "libxl" directory for each guest, since we might
want
         * to use libxl from inside the guest
         */
        libxl__xs_mknod(gc, t, GCSPRINTF("%s/libxl", dom_path), rwperm,
                        ARRAY_SIZE(rwperm));

This patch introduces libxl__is_driver_domain which determines the driver domain by checking if "libxl" entry is present and uses this function on device destroy to check by whom domain path should be cleaned up (libxl or the driver domain).

Oleksandr Grytsov (1):
libxl: add libxl__is_driver_domain function

Quoted 9 lines
 tools/libxl/libxl_device.c   | 17 ++++++++++-------
 tools/libxl/libxl_internal.c | 16 ++++++++++++++++
 tools/libxl/libxl_internal.h |  4 ++++
 3 files changed, 30 insertions(+), 7 deletions(-)

--
2.7.4

ping and update

There is run_hotplug_scripts parameter in xl.cfg. I guess it is related to this issue. But looking
through the code I see that this parameter is not used. Could anyone provide more info about
this parameter?

Signature · 2 lines
Best Regards,
Oleksandr Grytsov.

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

#3 lore raw
Quoted 53 lines · Oleksandr Grytsov
Quoted 32 lines · Oleksandr Grytsov

From: Oleksandr Grytsov <[email protected]>

We have following arm-based setup:

- Dom0 with xen and xen tools;
- Dom1 with device backends (but it is not the driver domain);
- Dom2 with device frontend;

On Dom2 destroying we have timeout error. Because xl treats our Dom1 as driver domain and waits for backend path to be cleared by the driver domain which is not our case.

According to libxl__domain_make in case of driver domain it has "libxl" xen store entry:

    if (libxl_defbool_val(info->driver_domain)) {
        /*
         * Create a local "libxl" directory for each guest, since we
might want
         * to use libxl from inside the guest
         */
        libxl__xs_mknod(gc, t, GCSPRINTF("%s/libxl", dom_path), rwperm,
                        ARRAY_SIZE(rwperm));

This patch introduces libxl__is_driver_domain which determines the driver domain by checking if "libxl" entry is present and uses this function on device destroy to check by whom domain path should be cleaned up (libxl or the driver domain).

Oleksandr Grytsov (1):
libxl: add libxl__is_driver_domain function

Quoted 9 lines
 tools/libxl/libxl_device.c   | 17 ++++++++++-------
 tools/libxl/libxl_internal.c | 16 ++++++++++++++++
 tools/libxl/libxl_internal.h |  4 ++++
 3 files changed, 30 insertions(+), 7 deletions(-)

--
2.7.4

ping and update

There is run_hotplug_scripts parameter in xl.cfg. I guess it is related to this issue. But looking
through the code I see that this parameter is not used. Could anyone provide more info about
this parameter?

Quoted 4 lines

--
Best Regards,
Oleksandr Grytsov.

ping

Signature · 2 lines
Best Regards,
Oleksandr Grytsov.

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

#4 lore raw
In reply to Oleksandr Grytsov
Quoted 6 lines · Oleksandr Grytsov

From: Oleksandr Grytsov <[email protected]>

We have following arm-based setup:

- Dom0 with xen and xen tools;
- Dom1 with device backends (but it is not the driver domain);

What is your definition of a "driver domain"? What does it do in this case?

I seem to have seen people use this term in different contexts to mean slightly different things. I need to figure out what you actually mean first.

Quoted 22 lines

- Dom2 with device frontend;

On Dom2 destroying we have timeout error. Because xl treats our Dom1 as driver domain and waits for backend path to be cleared by the driver domain which is not our case.

According to libxl__domain_make in case of driver domain it has "libxl" xen store entry:

    if (libxl_defbool_val(info->driver_domain)) {
        /*
         * Create a local "libxl" directory for each guest, since we might want
         * to use libxl from inside the guest
         */
        libxl__xs_mknod(gc, t, GCSPRINTF("%s/libxl", dom_path), rwperm,
                        ARRAY_SIZE(rwperm));

This patch introduces libxl__is_driver_domain which determines the driver domain by checking if "libxl" entry is present and uses this function on device destroy to check by whom domain path should be cleaned up (libxl or the driver domain).

Quoted 11 lines

Oleksandr Grytsov (1):
libxl: add libxl__is_driver_domain function

 tools/libxl/libxl_device.c   | 17 ++++++++++-------
 tools/libxl/libxl_internal.c | 16 ++++++++++++++++
 tools/libxl/libxl_internal.h |  4 ++++
 3 files changed, 30 insertions(+), 7 deletions(-)
Signature · 1 line
2.7.4

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

#5 lore raw
Quoted 8 lines · Wei Liu
Quoted 6 lines · Oleksandr Grytsov

From: Oleksandr Grytsov <[email protected]>

We have following arm-based setup:

- Dom0 with xen and xen tools;
- Dom1 with device backends (but it is not the driver domain);

Quoted 8 lines

What is your definition of a "driver domain"? What does it do in this case?

I seem to have seen people use this term in different contexts to mean slightly different things. I need to figure out what you actually mean first.

I see in the libxl/xl sources that closing PV devices is done differently in case backends are in Dom0 and are in other domain. It is called as driver domain in the sources. So, I don't have clear understanding what does it mean. In our setup backends are in Dom1 and xl is in Dom0. And I see that xl dosn't close PV device on domain reboot or shutdown.

Quoted 35 lines
Quoted 6 lines

- Dom2 with device frontend;

On Dom2 destroying we have timeout error. Because xl treats our Dom1 as driver domain and waits for backend path to be cleared by the driver domain which is not our case.

Quoted 6 lines

According to libxl__domain_make in case of driver domain it has "libxl" xen store entry:

    if (libxl_defbool_val(info->driver_domain)) {
        /*
         * Create a local "libxl" directory for each guest, since we

might want

Quoted 21 lines
         * to use libxl from inside the guest
         */
        libxl__xs_mknod(gc, t, GCSPRINTF("%s/libxl", dom_path), rwperm,
                        ARRAY_SIZE(rwperm));

This patch introduces libxl__is_driver_domain which determines the driver domain by checking if "libxl" entry is present and uses this function on device destroy to check by whom domain path should be cleaned up (libxl or the driver domain).

Oleksandr Grytsov (1):
libxl: add libxl__is_driver_domain function

 tools/libxl/libxl_device.c   | 17 ++++++++++-------
 tools/libxl/libxl_internal.c | 16 ++++++++++++++++
 tools/libxl/libxl_internal.h |  4 ++++
 3 files changed, 30 insertions(+), 7 deletions(-)

--
2.7.4

Signature · 2 lines
Best Regards,
Oleksandr Grytsov.

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

#6 lore raw
Quoted 18 lines · Oleksandr Grytsov
Quoted 8 lines · Wei Liu
Quoted 6 lines · Oleksandr Grytsov

From: Oleksandr Grytsov <[email protected]>

We have following arm-based setup:

- Dom0 with xen and xen tools;
- Dom1 with device backends (but it is not the driver domain);

Quoted 8 lines

What is your definition of a "driver domain"? What does it do in this case?

I seem to have seen people use this term in different contexts to mean slightly different things. I need to figure out what you actually mean first.

Quoted 5 lines

I see in the libxl/xl sources that closing PV devices is done differently in case backends are in Dom0 and are in other domain. It is called as driver domain in the sources. So, I don't have clear understanding what does it mean. In our setup backends are in Dom1 and xl is in Dom0. And I see that xl dosn't close PV device on domain reboot or shutdown.

Do you run xl devd in your backend domain?

Wei.

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

#7 lore raw
Quoted 25 lines · Wei Liu
Quoted 18 lines · Oleksandr Grytsov
Quoted 8 lines · Wei Liu
Quoted 6 lines · Oleksandr Grytsov

From: Oleksandr Grytsov <[email protected]>

We have following arm-based setup:

- Dom0 with xen and xen tools;
- Dom1 with device backends (but it is not the driver domain);

Quoted 8 lines

What is your definition of a "driver domain"? What does it do in this case?

I seem to have seen people use this term in different contexts to mean slightly different things. I need to figure out what you actually mean first.

Quoted 5 lines

I see in the libxl/xl sources that closing PV devices is done differently in case backends are in Dom0 and are in other domain. It is called as driver domain in the sources. So, I don't have clear understanding what does it mean. In our setup backends are in Dom1 and xl is in Dom0. And I see that xl dosn't close PV device on domain reboot or shutdown.

Quoted 4 lines

Do you run xl devd in your backend domain?

Wei.

No I don't

Signature · 2 lines
Best Regards,
Oleksandr Grytsov.

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

#8 lore raw
Quoted 27 lines · Oleksandr Grytsov
Quoted 25 lines · Wei Liu
Quoted 23 lines · Oleksandr Grytsov
Quoted 8 lines · Wei Liu
Quoted 6 lines · Oleksandr Grytsov

From: Oleksandr Grytsov <[email protected]>

We have following arm-based setup:

- Dom0 with xen and xen tools;
- Dom1 with device backends (but it is not the driver domain);

Quoted 8 lines

What is your definition of a "driver domain"? What does it do in this case?

I seem to have seen people use this term in different contexts to mean slightly different things. I need to figure out what you actually mean first.

I see in the libxl/xl sources that closing PV devices is done differently in case backends are in Dom0 and are in other domain. It is called as driver domain in the sources. So, I don't have clear understanding what does it mean. In our setup backends are in Dom1 and xl is in Dom0. And I see that xl dosn't close PV device on domain reboot or shutdown.

Quoted 6 lines
Quoted 4 lines

Do you run xl devd in your backend domain?

Wei.

No I don't

Can you try that? I think xl devd should clean up the stale entries -- that's how we envisage driver domains to be used.

Wei.

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

#9 lore raw
Quoted 39 lines · Wei Liu
Quoted 6 lines · Oleksandr Grytsov
Quoted 4 lines · Wei Liu
Quoted 3 lines · Oleksandr Grytsov
Quoted 1 line · Wei Liu

On Thu, Dec 14, 2017 at 04:14:12PM +0200, Oleksandr Grytsov wrote:

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines

From: Oleksandr Grytsov <[email protected]>

We have following arm-based setup:

- Dom0 with xen and xen tools;
- Dom1 with device backends (but it is not the driver domain);

What is your definition of a "driver domain"? What does it do in

this

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

case?

I seem to have seen people use this term in different contexts to

mean

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

slightly different things. I need to figure out what you actually

mean

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

first.

I see in the libxl/xl sources that closing PV devices is done

differently

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

in case backends are in Dom0 and are in other domain. It is called as driver domain in the sources. So, I don't have clear understanding what does it mean. In our setup backends are in Dom1 and xl is in

Dom0.

Quoted 1 line
Quoted 1 line
Quoted 1 line

And I see that xl dosn't close PV device on domain reboot or

shutdown.

Quoted 6 lines
Quoted 5 lines

Do you run xl devd in your backend domain?

Wei.

Quoted 7 lines
Quoted 1 line

No I don't

Can you try that? I think xl devd should clean up the stale entries -- that's how we envisage driver domains to be used.

Wei.

We will check this. Thanks.

Signature · 2 lines
Best Regards,
Oleksandr Grytsov.

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

#10 lore raw
Quoted 41 lines · Oleksandr Grytsov
Quoted 39 lines · Wei Liu
Quoted 27 lines · Oleksandr Grytsov
Quoted 25 lines · Wei Liu
Quoted 23 lines · Oleksandr Grytsov
Quoted 8 lines · Wei Liu
Quoted 6 lines · Oleksandr Grytsov

From: Oleksandr Grytsov <[email protected]>

We have following arm-based setup:

- Dom0 with xen and xen tools;
- Dom1 with device backends (but it is not the driver domain);

Quoted 8 lines

What is your definition of a "driver domain"? What does it do in this case?

I seem to have seen people use this term in different contexts to mean slightly different things. I need to figure out what you actually mean first.

I see in the libxl/xl sources that closing PV devices is done differently in case backends are in Dom0 and are in other domain. It is called as driver domain in the sources. So, I don't have clear understanding what does it mean. In our setup backends are in Dom1 and xl is in Dom0. And I see that xl dosn't close PV device on domain reboot or shutdown.

Quoted 6 lines
Quoted 4 lines

Do you run xl devd in your backend domain?

Wei.

No I don't

Can you try that? I think xl devd should clean up the stale entries -- that's how we envisage driver domains to be used.

Quoted 8 lines
Quoted 1 line

Wei.

We will check this. Thanks.

--
Best Regards,
Oleksandr Grytsov.

Let me renew this topic.

xl devd cleans up the state entries only for specific devices: VBD, VIF, QDISK. I wonder, shall xl devd perform cleaning for all other backends in driver domain as well?

Signature · 7 lines
Best Regards,
Oleksandr Grytsov.

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