Skip to contentSkip to conversation

libxl: spolit up libxl.c

PATCH Superseded Juergen Gross 5 participants 19 messages Feb 8, 2017 – Feb 9, 2017

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover libxl: spolit up libxl.c

libxl.c has become rather large. Split it up into multiple files.

Code movement only. No functional change intended.

Juergen Gross (9):
libxl: adjust copyright comment of libxl.c
libxl: carve out cpupool specific functions from libxl.c
libxl: carve out scheduler specific functions from libxl.c
libxl: carve out disk specific functions from libxl.c
libxl: carve out console specific functions from libxl.c
libxl: carve out memory specific functions from libxl.c
libxl: move device specific functions out of libxl.c
libxl: carve out tmem specific functions from libxl.c
libxl: carve out domain specific functions from libxl.c

 tools/libxl/Makefile         |    4 +-
 tools/libxl/libxl.c          | 6252 +-----------------------------------------
 tools/libxl/libxl_console.c  |  862 ++++++
 tools/libxl/libxl_cpupool.c  |  443 +++
 tools/libxl/libxl_device.c   |  435 ++-
 tools/libxl/libxl_disk.c     | 1258 +++++++++
 tools/libxl/libxl_domain.c   | 1744 ++++++++++++
 tools/libxl/libxl_internal.h |    8 +-
 tools/libxl/libxl_mem.c      |  601 ++++
 tools/libxl/libxl_sched.c    |  915 +++++++
 tools/libxl/libxl_tmem.c     |  167 ++
 11 files changed, 6424 insertions(+), 6265 deletions(-)
 create mode 100644 tools/libxl/libxl_console.c
 create mode 100644 tools/libxl/libxl_cpupool.c
 create mode 100644 tools/libxl/libxl_disk.c
 create mode 100644 tools/libxl/libxl_domain.c
 create mode 100644 tools/libxl/libxl_mem.c
 create mode 100644 tools/libxl/libxl_sched.c
 create mode 100644 tools/libxl/libxl_tmem.c
Signature · 7 lines
2.10.2


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

PATCH 1/9 libxl: adjust copyright comment of libxl.c

The copyright of libxl.c is a little bit outdated.

Adjust it to reality.

---
 tools/libxl/libxl.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
tools/libxl/libxl.c +1 -3
index d400fa2..0641a8a 100644
@@ -1,7 +1,5 @@
 /*
- * Copyright (C) 2009      Citrix Ltd.
- * Author Vincent Hanquez <[email protected]>
- * Author Stefano Stabellini <[email protected]>
+ * Copyright 2009-2017 Citrix Ltd and other contributors
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
Signature · 7 lines
2.10.2


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

PATCH 2/9 libxl: carve out cpupool specific functions from libxl.c

In reply to Juergen Gross

libxl.c has grown to an uncomfortable size. Carve out the cpupool related functions to libxl_cpupool.c.

---
 tools/libxl/Makefile        |   1 +
 tools/libxl/libxl.c         | 418 -----------------------------------------
 tools/libxl/libxl_cpupool.c | 443 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 444 insertions(+), 418 deletions(-)
 create mode 100644 tools/libxl/libxl_cpupool.c
tools/libxl/Makefile +1 -0
index 91e2f97..0125871 100644
@@ -137,6 +137,7 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \
 			libxl_qmp.o libxl_event.o libxl_fork.o \
 			libxl_dom_suspend.o libxl_dom_save.o libxl_usb.o \
 			libxl_vtpm.o libxl_nic.o \
+			libxl_cpupool.o \
                         $(LIBXL_OBJS-y)
 LIBXL_OBJS += libxl_genid.o
 LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
tools/libxl/libxl.c +0 -418

430 lines not on this page · raw message

tools/libxl/libxl_cpupool.c new file +443 -0

443 lines not on this page · raw message

Signature · 7 lines
2.10.2


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

PATCH 3/9 libxl: carve out scheduler specific functions from libxl.c

In reply to Juergen Gross

libxl.c has grown to an uncomfortable size. Carve out the scheduler related functions to libxl_sched.c.

---
 tools/libxl/Makefile      |   2 +-
 tools/libxl/libxl.c       | 891 --------------------------------------------
 tools/libxl/libxl_sched.c | 915 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 916 insertions(+), 892 deletions(-)
 create mode 100644 tools/libxl/libxl_sched.c
tools/libxl/Makefile +1 -1
index 0125871..7514cc2 100644
@@ -137,7 +137,7 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \
 			libxl_qmp.o libxl_event.o libxl_fork.o \
 			libxl_dom_suspend.o libxl_dom_save.o libxl_usb.o \
 			libxl_vtpm.o libxl_nic.o \
-			libxl_cpupool.o \
+			libxl_cpupool.o libxl_sched.o \
                         $(LIBXL_OBJS-y)
 LIBXL_OBJS += libxl_genid.o
 LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
tools/libxl/libxl.c +0 -891

903 lines not on this page · raw message

tools/libxl/libxl_sched.c new file +915 -0

915 lines not on this page · raw message

Signature · 7 lines
2.10.2


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

PATCH 4/9 libxl: carve out disk specific functions from libxl.c

In reply to Juergen Gross

libxl.c has grown to an uncomfortable size. Carve out the disk related functions to libxl_disk.c.

---
 tools/libxl/Makefile     |    2 +-
 tools/libxl/libxl.c      | 1234 ---------------------------------------------
 tools/libxl/libxl_disk.c | 1258 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1259 insertions(+), 1235 deletions(-)
 create mode 100644 tools/libxl/libxl_disk.c
tools/libxl/Makefile +1 -1
index 7514cc2..baf591d 100644
@@ -136,7 +136,7 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \
 			libxl_save_callout.o _libxl_save_msgs_callout.o \
 			libxl_qmp.o libxl_event.o libxl_fork.o \
 			libxl_dom_suspend.o libxl_dom_save.o libxl_usb.o \
-			libxl_vtpm.o libxl_nic.o \
+			libxl_vtpm.o libxl_nic.o libxl_disk.o \
 			libxl_cpupool.o libxl_sched.o \
                         $(LIBXL_OBJS-y)
 LIBXL_OBJS += libxl_genid.o
tools/libxl/libxl.c +0 -1234

1,270 lines not on this page · raw message

tools/libxl/libxl_disk.c new file +1258 -0

1,258 lines not on this page · raw message

Signature · 7 lines
2.10.2


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

PATCH 5/9 libxl: carve out console specific functions from libxl.c

In reply to Juergen Gross

libxl.c has grown to an uncomfortable size. Carve out the console related functions (including channels, keyboard and frame buffer) to libxl_console.c.

---
 tools/libxl/Makefile        |   2 +-
 tools/libxl/libxl.c         | 846 -------------------------------------------
 tools/libxl/libxl_console.c | 862 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 863 insertions(+), 847 deletions(-)
 create mode 100644 tools/libxl/libxl_console.c
tools/libxl/Makefile +1 -1
index baf591d..dd7aa41 100644
@@ -136,7 +136,7 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \
 			libxl_save_callout.o _libxl_save_msgs_callout.o \
 			libxl_qmp.o libxl_event.o libxl_fork.o \
 			libxl_dom_suspend.o libxl_dom_save.o libxl_usb.o \
-			libxl_vtpm.o libxl_nic.o libxl_disk.o \
+			libxl_vtpm.o libxl_nic.o libxl_disk.o libxl_console.o \
 			libxl_cpupool.o libxl_sched.o \
                         $(LIBXL_OBJS-y)
 LIBXL_OBJS += libxl_genid.o
tools/libxl/libxl.c +0 -846

864 lines not on this page · raw message

tools/libxl/libxl_console.c new file +862 -0

862 lines not on this page · raw message

Signature · 7 lines
2.10.2


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

PATCH 6/9 libxl: carve out memory specific functions from libxl.c

In reply to Juergen Gross

libxl.c has grown to an uncomfortable size. Carve out the memory related functions to libxl_mem.c.

---
 tools/libxl/Makefile         |   2 +-
 tools/libxl/libxl.c          | 583 +----------------------------------------
 tools/libxl/libxl_internal.h |   7 +
 tools/libxl/libxl_mem.c      | 601 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 612 insertions(+), 581 deletions(-)
 create mode 100644 tools/libxl/libxl_mem.c
tools/libxl/Makefile +1 -1
index dd7aa41..4b05e34 100644
@@ -137,7 +137,7 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \
 			libxl_qmp.o libxl_event.o libxl_fork.o \
 			libxl_dom_suspend.o libxl_dom_save.o libxl_usb.o \
 			libxl_vtpm.o libxl_nic.o libxl_disk.o libxl_console.o \
-			libxl_cpupool.o libxl_sched.o \
+			libxl_cpupool.o libxl_mem.o libxl_sched.o \
                         $(LIBXL_OBJS-y)
 LIBXL_OBJS += libxl_genid.o
 LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
tools/libxl/libxl.c +3 -580

601 lines not on this page · raw message

tools/libxl/libxl_internal.h +7 -0
index 5f46578..43456a9 100644
@@ -4239,6 +4239,13 @@ uint64_t libxl__get_targetmem_fudge(libxl__gc *gc,
     return info->video_memkb + mem_target_fudge;
 }
 
+int libxl__get_memory_target(libxl__gc *gc, uint32_t domid, 
+                             uint64_t *out_target_memkb,
+                             uint64_t *out_max_memkb);
+void xcinfo2xlinfo(libxl_ctx *ctx,
+                   const xc_domaininfo_t *xcinfo,
+                   libxl_dominfo *xlinfo);
+
 /* Macros used to compare device identifier. Returns true if the two
  * devices have same identifier. */
 #define COMPARE_DEVID(a, b) ((a)->devid == (b)->devid)
tools/libxl/libxl_mem.c new file +601 -0

601 lines not on this page · raw message

Signature · 7 lines
2.10.2


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

PATCH 7/9 libxl: move device specific functions out of libxl.c

In reply to Juergen Gross

Move the few generic device specific functions left in libxl.c to libxl_device.c.

---
 tools/libxl/libxl.c          | 416 -----------------------------------------
 tools/libxl/libxl_device.c   | 435 +++++++++++++++++++++++++++++++++++++++++--
 tools/libxl/libxl_internal.h |   1 -
 3 files changed, 423 insertions(+), 429 deletions(-)
tools/libxl/libxl.c +0 -416
index d040e12..d559991 100644
@@ -1529,50 +1529,6 @@ out:
 
 /******************************************************************************/
 
-/* generic callback for devices that only need to set ao_complete */
-void device_addrm_aocomplete(libxl__egc *egc, libxl__ao_device *aodev)
-{
-    STATE_AO_GC(aodev->ao);
-
-    if (aodev->rc) {
-        if (aodev->dev) {
-            LOGD(ERROR, aodev->dev->domid, "Unable to %s %s with id %u",
-                        libxl__device_action_to_string(aodev->action),
-                        libxl__device_kind_to_string(aodev->dev->kind),
-                        aodev->dev->devid);
-        } else {
-            LOG(ERROR, "unable to %s device",
-                       libxl__device_action_to_string(aodev->action));
-        }
-        goto out;
-    }
-
-out:
-    libxl__ao_complete(egc, ao, aodev->rc);
-    return;
-}
-
-/* common function to get next device id */
-int libxl__device_nextid(libxl__gc *gc, uint32_t domid, char *device)
-{
-    char *libxl_dom_path, **l;
-    unsigned int nb;
-    int nextid = -1;
-
-    if (!(libxl_dom_path = libxl__xs_libxl_path(gc, domid)))
-        return nextid;
-
-    l = libxl__xs_directory(gc, XBT_NULL,
-        GCSPRINTF("%s/device/%s", libxl_dom_path, device),
-                            &nb);
-    if (l == NULL || nb == 0)
-        nextid = 0;
-    else
-        nextid = strtoul(l[nb - 1], NULL, 10) + 1;
-
-    return nextid;
-}
-
 int libxl__resolve_domid(libxl__gc *gc, const char *name, uint32_t *domid)
 {
     if (!name)
@@ -1581,378 +1537,6 @@ int libxl__resolve_domid(libxl__gc *gc, const char *name, uint32_t *domid)
 }
 
 /******************************************************************************/
-
-/*
- * Data structures used to track devices handled by driver domains
- */
-
-/*
- * Structure that describes a device handled by a driver domain
- */
-typedef struct libxl__ddomain_device {
-    libxl__device *dev;
-    LIBXL_SLIST_ENTRY(struct libxl__ddomain_device) next;
-} libxl__ddomain_device;
-
-/*
- * Structure that describes a domain and it's associated devices
- */
-typedef struct libxl__ddomain_guest {
-    uint32_t domid;
-    int num_vifs, num_vbds, num_qdisks;
-    LIBXL_SLIST_HEAD(, struct libxl__ddomain_device) devices;
-    LIBXL_SLIST_ENTRY(struct libxl__ddomain_guest) next;
-} libxl__ddomain_guest;
-
-/*
- * Main structure used by a driver domain to keep track of devices
- * currently in use
- */
-typedef struct {
-    libxl__ao *ao;
-    libxl__ev_xswatch watch;
-    LIBXL_SLIST_HEAD(, struct libxl__ddomain_guest) guests;
-} libxl__ddomain;
-
-static libxl__ddomain_guest *search_for_guest(libxl__ddomain *ddomain,
-                                               uint32_t domid)
-{
-    libxl__ddomain_guest *dguest;
-
-    LIBXL_SLIST_FOREACH(dguest, &ddomain->guests, next) {
-        if (dguest->domid == domid)
-            return dguest;
-    }
-    return NULL;
-}
-
-static libxl__ddomain_device *search_for_device(libxl__ddomain_guest *dguest,
-                                                libxl__device *dev)
-{
-    libxl__ddomain_device *ddev;
-
-    LIBXL_SLIST_FOREACH(ddev, &dguest->devices, next) {
-#define LIBXL_DEVICE_CMP(dev1, dev2, entry) (dev1->entry == dev2->entry)
-        if (LIBXL_DEVICE_CMP(ddev->dev, dev, backend_devid) &&
-            LIBXL_DEVICE_CMP(ddev->dev, dev, backend_domid) &&
-            LIBXL_DEVICE_CMP(ddev->dev, dev, devid) &&
-            LIBXL_DEVICE_CMP(ddev->dev, dev, domid) &&
-            LIBXL_DEVICE_CMP(ddev->dev, dev, backend_kind) &&
-            LIBXL_DEVICE_CMP(ddev->dev, dev, kind))
-            return ddev;
-#undef LIBXL_DEVICE_CMP
-    }
-
-    return NULL;
-}
-
-static void device_complete(libxl__egc *egc, libxl__ao_device *aodev)
-{
-    STATE_AO_GC(aodev->ao);
-
-    LOG(DEBUG, "device %s %s %s",
-               libxl__device_backend_path(gc, aodev->dev),
-               libxl__device_action_to_string(aodev->action),
-               aodev->rc ? "failed" : "succeed");
-
-    if (aodev->action == LIBXL__DEVICE_ACTION_REMOVE)
-        free(aodev->dev);
-
-    libxl__nested_ao_free(aodev->ao);
-}
-
-static void qdisk_spawn_outcome(libxl__egc *egc, libxl__dm_spawn_state *dmss,
-                                int rc)
-{
-    STATE_AO_GC(dmss->spawn.ao);
-
-    LOGD(DEBUG, dmss->guest_domid, "qdisk backend spawn %s",
-                rc ? "failed" : "succeed");
-
-    libxl__nested_ao_free(dmss->spawn.ao);
-}
-
-/*
- * The following comment applies to both add_device and remove_device.
- *
- * If the return value is greater than 0, it means there's no ao dispatched,
- * so the free of the nested ao should be done by the parent when it has
- * finished.
- */
-static int add_device(libxl__egc *egc, libxl__ao *ao,
-                      libxl__ddomain_guest *dguest,
-                      libxl__ddomain_device *ddev)
-{
-    AO_GC;
-    libxl__device *dev = ddev->dev;
-    libxl__ao_device *aodev;
-    libxl__dm_spawn_state *dmss;
-    int rc = 0;
-
-    switch(dev->backend_kind) {
-    case LIBXL__DEVICE_KIND_VBD:
-    case LIBXL__DEVICE_KIND_VIF:
-        if (dev->backend_kind == LIBXL__DEVICE_KIND_VBD) dguest->num_vbds++;
-        if (dev->backend_kind == LIBXL__DEVICE_KIND_VIF) dguest->num_vifs++;
-
-        GCNEW(aodev);
-        libxl__prepare_ao_device(ao, aodev);
-        aodev->dev = dev;
-        aodev->action = LIBXL__DEVICE_ACTION_ADD;
-        aodev->callback = device_complete;
-        libxl__wait_device_connection(egc, aodev);
-
-        break;
-    case LIBXL__DEVICE_KIND_QDISK:
-        if (dguest->num_qdisks == 0) {
-            GCNEW(dmss);
-            dmss->guest_domid = dev->domid;
-            dmss->spawn.ao = ao;
-            dmss->callback = qdisk_spawn_outcome;
-
-            libxl__spawn_qdisk_backend(egc, dmss);
-        }
-        dguest->num_qdisks++;
-
-        break;
-    default:
-        rc = 1;
-        break;
-    }
-
-    return rc;
-}
-
-static int remove_device(libxl__egc *egc, libxl__ao *ao,
-                         libxl__ddomain_guest *dguest,
-                         libxl__ddomain_device *ddev)
-{
-    AO_GC;
-    libxl__device *dev = ddev->dev;
-    libxl__ao_device *aodev;
-    int rc = 0;
-
-    switch(ddev->dev->backend_kind) {
-    case LIBXL__DEVICE_KIND_VBD:
-    case LIBXL__DEVICE_KIND_VIF:
-        if (dev->backend_kind == LIBXL__DEVICE_KIND_VBD) dguest->num_vbds--;
-        if (dev->backend_kind == LIBXL__DEVICE_KIND_VIF) dguest->num_vifs--;
-
-        GCNEW(aodev);
-        libxl__prepare_ao_device(ao, aodev);
-        aodev->dev = dev;
-        aodev->action = LIBXL__DEVICE_ACTION_REMOVE;
-        aodev->callback = device_complete;
-        libxl__initiate_device_generic_remove(egc, aodev);
-        break;
-    case LIBXL__DEVICE_KIND_QDISK:
-        if (--dguest->num_qdisks == 0) {
-            rc = libxl__destroy_qdisk_backend(gc, dev->domid);
-            if (rc)
-                goto out;
-        }
-        libxl__device_destroy(gc, dev);
-        free(dev);
-        /* Fall through to return > 0, no ao has been dispatched */
-    default:
-        rc = 1;
-        break;
-    }
-
-out:
-    return rc;
-}
-
-static void backend_watch_callback(libxl__egc *egc, libxl__ev_xswatch *watch,
-                                   const char *watch_path,
-                                   const char *event_path)
-{
-    libxl__ddomain *ddomain = CONTAINER_OF(watch, *ddomain, watch);
-    libxl__ao *nested_ao = libxl__nested_ao_create(ddomain->ao);
-    STATE_AO_GC(nested_ao);
-    char *p, *path;
-    const char *sstate, *sonline;
-    int state, online, rc, num_devs;
-    libxl__device *dev = NULL;
-    libxl__ddomain_device *ddev = NULL;
-    libxl__ddomain_guest *dguest = NULL;
-    bool free_ao = false;
-
-    /* Check if event_path ends with "state" or "online" and truncate it. */
-    path = libxl__strdup(gc, event_path);
-    p = strrchr(path, '/');
-    if (p == NULL)
-        goto skip;
-    if (strcmp(p, "/state") != 0 && strcmp(p, "/online") != 0)
-        goto skip;
-    /* Truncate the string so it points to the backend directory. */
-    *p = '\0';
-
-    /* Fetch the value of the state and online nodes. */
-    rc = libxl__xs_read_checked(gc, XBT_NULL, GCSPRINTF("%s/state", path),
-                                &sstate);
-    if (rc || !sstate)
-        goto skip;
-    state = atoi(sstate);
-
-    rc = libxl__xs_read_checked(gc, XBT_NULL, GCSPRINTF("%s/online", path),
-                                &sonline);
-    if (rc || !sonline)
-        goto skip;
-    online = atoi(sonline);
-
-    dev = libxl__zalloc(NOGC, sizeof(*dev));
-    rc = libxl__parse_backend_path(gc, path, dev);
-    if (rc)
-        goto skip;
-
-    dguest = search_for_guest(ddomain, dev->domid);
-    if (dguest == NULL && state == XenbusStateClosed) {
-        /*
-         * Spurious state change, device has already been disconnected
-         * or never attached.
-         */
-        goto skip;
-    }
-    if (dguest == NULL) {
-        /* Create a new guest struct and initialize it */
-        dguest = libxl__zalloc(NOGC, sizeof(*dguest));
-        dguest->domid = dev->domid;
-        LIBXL_SLIST_INIT(&dguest->devices);
-        LIBXL_SLIST_INSERT_HEAD(&ddomain->guests, dguest, next);
-        LOGD(DEBUG, dguest->domid, "Added domain to the list of active guests");
-    }
-    ddev = search_for_device(dguest, dev);
-    if (ddev == NULL && state == XenbusStateClosed) {
-        /*
-         * Spurious state change, device has already been disconnected
-         * or never attached.
-         */
-        goto skip;
-    } else if (ddev == NULL) {
-        /*
-         * New device addition, allocate a struct to hold it and add it
-         * to the list of active devices for a given guest.
-         */
-        ddev = libxl__zalloc(NOGC, sizeof(*ddev));
-        ddev->dev = dev;
-        LIBXL_SLIST_INSERT_HEAD(&dguest->devices, ddev, next);
-        LOGD(DEBUG, dev->domid, "Added device %s to the list of active devices",
-             path);
-        rc = add_device(egc, nested_ao, dguest, ddev);
-        if (rc > 0)
-            free_ao = true;
-    } else if (state == XenbusStateClosed && online == 0) {
-        /*
-         * Removal of an active device, remove it from the list and
-         * free it's data structures if they are no longer needed.
-         *
-         * The free of the associated libxl__device is left to the
-         * helper remove_device function.
-         */
-        LIBXL_SLIST_REMOVE(&dguest->devices, ddev, libxl__ddomain_device,
-                           next);
-        LOGD(DEBUG, dev->domid, "Removed device %s from the list of active devices",
-             path);
-        rc = remove_device(egc, nested_ao, dguest, ddev);
-        if (rc > 0)
-            free_ao = true;
-
-        free(ddev);
-        /* If this was the last device in the domain, remove it from the list */
-        num_devs = dguest->num_vifs + dguest->num_vbds + dguest->num_qdisks;
-        if (num_devs == 0) {
-            LIBXL_SLIST_REMOVE(&ddomain->guests, dguest, libxl__ddomain_guest,
-                               next);
-            LOGD(DEBUG, dguest->domid, "Removed domain from the list of active guests");
-            /* Clear any leftovers in libxl/<domid> */
-            libxl__xs_rm_checked(gc, XBT_NULL,
-                                 GCSPRINTF("libxl/%u", dguest->domid));
-            free(dguest);
-        }
-    }
-
-    if (free_ao)
-        libxl__nested_ao_free(nested_ao);
-
-    return;
-
-skip:
-    libxl__nested_ao_free(nested_ao);
-    free(dev);
-    free(ddev);
-    free(dguest);
-    return;
-}
-
-/* Handler of events for device driver domains */
-int libxl_device_events_handler(libxl_ctx *ctx,
-                                const libxl_asyncop_how *ao_how)
-{
-    AO_CREATE(ctx, 0, ao_how);
-    int rc;
-    uint32_t domid;
-    libxl__ddomain ddomain;
-    char *be_path;
-    char **kinds = NULL, **domains = NULL, **devs = NULL;
-    const char *sstate;
-    char *state_path;
-    int state;
-    unsigned int nkinds, ndomains, ndevs;
-    int i, j, k;
-
-    ddomain.ao = ao;
-    LIBXL_SLIST_INIT(&ddomain.guests);
-
-    rc = libxl__get_domid(gc, &domid);
-    if (rc) {
-        LOG(ERROR, "unable to get domain id");
-        goto out;
-    }
-
-    /*
-     * We use absolute paths because we want xswatch to also return
-     * absolute paths that can be parsed by libxl__parse_backend_path.
-     */
-    be_path = GCSPRINTF("/local/domain/%u/backend", domid);
-    rc = libxl__ev_xswatch_register(gc, &ddomain.watch, backend_watch_callback,
-                                    be_path);
-    if (rc) goto out;
-
-    kinds = libxl__xs_directory(gc, XBT_NULL, be_path, &nkinds);
-    if (kinds) {
-        for (i = 0; i < nkinds; i++) {
-            domains = libxl__xs_directory(gc, XBT_NULL,
-                    GCSPRINTF("%s/%s", be_path, kinds[i]), &ndomains);
-            if (!domains)
-                continue;
-            for (j = 0; j < ndomains; j++) {
-                devs = libxl__xs_directory(gc, XBT_NULL,
-                        GCSPRINTF("%s/%s/%s", be_path, kinds[i], domains[j]), &ndevs);
-                if (!devs)
-                    continue;
-                for (k = 0; k < ndevs; k++) {
-                    state_path = GCSPRINTF("%s/%s/%s/%s/state",
-                            be_path, kinds[i], domains[j], devs[k]);
-                    rc = libxl__xs_read_checked(gc, XBT_NULL, state_path, &sstate);
-                    if (rc || !sstate)
-                        continue;
-                    state = atoi(sstate);
-                    if (state == XenbusStateInitWait)
-                        backend_watch_callback(egc, &ddomain.watch,
-                                               be_path, state_path);
-                }
-            }
-        }
-    }
-
-    return AO_INPROGRESS;
-
-out:
-    return AO_CREATE_FAIL(rc);
-}
-
-/******************************************************************************/
 int libxl_get_physinfo(libxl_ctx *ctx, libxl_physinfo *physinfo)
 {
     xc_physinfo_t xcphysinfo = { 0 };
tools/libxl/libxl_device.c +423 -12

459 lines not on this page · raw message

tools/libxl/libxl_internal.h +0 -1
index 43456a9..292c480 100644
@@ -1199,7 +1199,6 @@ _hidden int libxl__device_exists(libxl__gc *gc, xs_transaction_t t,
 _hidden int libxl__device_generic_add(libxl__gc *gc, xs_transaction_t t,
         libxl__device *device, char **bents, char **fents, char **ro_fents);
 _hidden char *libxl__device_backend_path(libxl__gc *gc, libxl__device *device);
-_hidden char *libxl__device_frontend_path(libxl__gc *gc, libxl__device *device);
 _hidden char *libxl__device_libxl_path(libxl__gc *gc, libxl__device *device);
 _hidden int libxl__parse_backend_path(libxl__gc *gc, const char *path,
                                       libxl__device *dev);
Signature · 7 lines
2.10.2


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

PATCH 8/9 libxl: carve out tmem specific functions from libxl.c

In reply to Juergen Gross

libxl.c has grown to an uncomfortable size. Carve out the tmem related functions to libxl_tmem.c.

---
 tools/libxl/Makefile     |   2 +-
 tools/libxl/libxl.c      | 142 ----------------------------------------
 tools/libxl/libxl_tmem.c | 167 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 168 insertions(+), 143 deletions(-)
 create mode 100644 tools/libxl/libxl_tmem.c
tools/libxl/Makefile +1 -1
index 4b05e34..99ddae1 100644
@@ -137,7 +137,7 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \
 			libxl_qmp.o libxl_event.o libxl_fork.o \
 			libxl_dom_suspend.o libxl_dom_save.o libxl_usb.o \
 			libxl_vtpm.o libxl_nic.o libxl_disk.o libxl_console.o \
-			libxl_cpupool.o libxl_mem.o libxl_sched.o \
+			libxl_cpupool.o libxl_mem.o libxl_sched.o libxl_tmem.o \
                         $(LIBXL_OBJS-y)
 LIBXL_OBJS += libxl_genid.o
 LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
tools/libxl/libxl.c +0 -142

148 lines not on this page · raw message

tools/libxl/libxl_tmem.c new file +167 -0

167 lines not on this page · raw message

Signature · 7 lines
2.10.2


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

PATCH 9/9 libxl: carve out domain specific functions from libxl.c

In reply to Juergen Gross

libxl.c has grown to an uncomfortable size. Carve out the domain related functions to libxl_domain.c.

---
 tools/libxl/Makefile       |    1 +
 tools/libxl/libxl.c        | 1724 -------------------------------------------
 tools/libxl/libxl_domain.c | 1744 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1745 insertions(+), 1724 deletions(-)
 create mode 100644 tools/libxl/libxl_domain.c
tools/libxl/Makefile +1 -0
index 99ddae1..6cc7b45 100644
@@ -138,6 +138,7 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o libxl_pci.o \
 			libxl_dom_suspend.o libxl_dom_save.o libxl_usb.o \
 			libxl_vtpm.o libxl_nic.o libxl_disk.o libxl_console.o \
 			libxl_cpupool.o libxl_mem.o libxl_sched.o libxl_tmem.o \
+			libxl_domain.o \
                         $(LIBXL_OBJS-y)
 LIBXL_OBJS += libxl_genid.o
 LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
tools/libxl/libxl.c +0 -1724

1,754 lines not on this page · raw message

tools/libxl/libxl_domain.c new file +1744 -0

1,239 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 7 lines
2.10.2


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

Part of the diff is not shown here. View the raw message.

#10 lore raw
In reply to Juergen Gross

Juergen Gross writes ("[PATCH 0/9] libxl: spolit up libxl.c"):

Quoted 1 line

Code movement only. No functional change intended.

This statement is not true because

Quoted 2 lines

Juergen Gross (9):
libxl: adjust copyright comment of libxl.c

... that patch is not just code motion.

Can you please double-check, and explicitly enumerate the other intentional changes ? Obviously there is an intentional change to the Makefile, and the copyright header is duplicated in each case.

Are there any other changes which are not precisely moving a block of lines from libxl.c into other file(s), completely unchanged ?

Did you have to make any functions non-static ?

Thanks,
Ian.

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

#11 lore raw
Quoted 9 lines · Ian Jackson

Juergen Gross writes ("[PATCH 0/9] libxl: spolit up libxl.c"):

Quoted 1 line

Code movement only. No functional change intended.

This statement is not true because

Quoted 2 lines

Juergen Gross (9):
libxl: adjust copyright comment of libxl.c

... that patch is not just code motion.

Okay, more precise wording:

Changes are:
- moving functions into new or existing sources
- modification of Copyright comment
- made two functions non-static: libxl__get_memory_target(), xcinfo2xlinfo()
- made one function static: libxl__device_frontend_path()
- modified Makefile to include new source files
- removed some trailing spaces in moved code
- reordered some functions in new sources to get rid of some local prototypes

Quoted 8 lines

Can you please double-check, and explicitly enumerate the other intentional changes ? Obviously there is an intentional change to the Makefile, and the copyright header is duplicated in each case.

Are there any other changes which are not precisely moving a block of lines from libxl.c into other file(s), completely unchanged ?

Did you have to make any functions non-static ?

Juergen

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

#12 lore raw

Juergen Gross writes ("Re: [PATCH 0/9] libxl: spolit up libxl.c"):

Quoted 1 line

Okay, more precise wording:

Thanks.

Quoted 7 lines

Changes are:
- moving functions into new or existing sources
- modification of Copyright comment

- made two functions non-static: libxl__get_memory_target(), xcinfo2xlinfo()
- made one function static: libxl__device_frontend_path()

Can you split these out into their own patch(es) ?

Quoted 1 line

- removed some trailing spaces in moved code

And split this one out too ?

Sorry to be pernickety, but this will make it much easier to check what you have done automatically, without trying read the whole thing by eye !

Thanks,
Ian.

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

#13 lore raw
Quoted 15 lines · Ian Jackson

Juergen Gross writes ("Re: [PATCH 0/9] libxl: spolit up libxl.c"):

Quoted 1 line

Okay, more precise wording:

Thanks.

Quoted 7 lines

Changes are:
- moving functions into new or existing sources
- modification of Copyright comment

- made two functions non-static: libxl__get_memory_target(), xcinfo2xlinfo()
- made one function static: libxl__device_frontend_path()

Can you split these out into their own patch(es) ?

Quoted 7 lines
Quoted 1 line

- removed some trailing spaces in moved code

And split this one out too ?

Sorry to be pernickety, but this will make it much easier to check what you have done automatically, without trying read the whole thing by eye !

Okay.

Juergen

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

#14 lore raw
In reply to Juergen Gross

Cc Yi Sun as well.

Haozhong and Yi: This is just a heads-up -- Juergen from SuSE took the time to split libxl.c so things are better organised. It's likely this series will go in before yours, so you will then need to rebase your series. I don't expect there to be much breakage because it is all mechanical, but rebasing is still work for you.

Let us know if you have any concern so that we can coordinate this.

Wei.

Quoted 26 lines · Juergen Gross

libxl.c has become rather large. Split it up into multiple files.

Code movement only. No functional change intended.

Juergen Gross (9):
libxl: adjust copyright comment of libxl.c
libxl: carve out cpupool specific functions from libxl.c
libxl: carve out scheduler specific functions from libxl.c
libxl: carve out disk specific functions from libxl.c
libxl: carve out console specific functions from libxl.c
libxl: carve out memory specific functions from libxl.c
libxl: move device specific functions out of libxl.c
libxl: carve out tmem specific functions from libxl.c
libxl: carve out domain specific functions from libxl.c

 tools/libxl/Makefile         |    4 +-
 tools/libxl/libxl.c          | 6252 +-----------------------------------------
 tools/libxl/libxl_console.c  |  862 ++++++
 tools/libxl/libxl_cpupool.c  |  443 +++
 tools/libxl/libxl_device.c   |  435 ++-
 tools/libxl/libxl_disk.c     | 1258 +++++++++
 tools/libxl/libxl_domain.c   | 1744 ++++++++++++
 tools/libxl/libxl_internal.h |    8 +-
 tools/libxl/libxl_mem.c      |  601 ++++
 tools/libxl/libxl_sched.c    |  915 +++++++
 tools/libxl/libxl_tmem.c     |  167 ++
Quoted 12 lines
 11 files changed, 6424 insertions(+), 6265 deletions(-)
 create mode 100644 tools/libxl/libxl_console.c
 create mode 100644 tools/libxl/libxl_cpupool.c
 create mode 100644 tools/libxl/libxl_disk.c
 create mode 100644 tools/libxl/libxl_domain.c
 create mode 100644 tools/libxl/libxl_mem.c
 create mode 100644 tools/libxl/libxl_sched.c
 create mode 100644 tools/libxl/libxl_tmem.c
Signature · 1 line
2.10.2

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

#15 lore raw

And CC Zhangchen

Quoted 8 lines · Wei Liu

Cc Yi Sun as well.

Haozhong and Yi: This is just a heads-up -- Juergen from SuSE took the time to split libxl.c so things are better organised. It's likely this series will go in before yours, so you will then need to rebase your series. I don't expect there to be much breakage because it is all mechanical, but rebasing is still work for you.

Quoted 43 lines

Let us know if you have any concern so that we can coordinate this.

Wei.

Quoted 38 lines · Juergen Gross

libxl.c has become rather large. Split it up into multiple files.

Code movement only. No functional change intended.

Juergen Gross (9):
libxl: adjust copyright comment of libxl.c
libxl: carve out cpupool specific functions from libxl.c
libxl: carve out scheduler specific functions from libxl.c
libxl: carve out disk specific functions from libxl.c
libxl: carve out console specific functions from libxl.c
libxl: carve out memory specific functions from libxl.c
libxl: move device specific functions out of libxl.c
libxl: carve out tmem specific functions from libxl.c
libxl: carve out domain specific functions from libxl.c

 tools/libxl/Makefile         |    4 +-
 tools/libxl/libxl.c          | 6252 +-----------------------------------------
 tools/libxl/libxl_console.c  |  862 ++++++
 tools/libxl/libxl_cpupool.c  |  443 +++
 tools/libxl/libxl_device.c   |  435 ++-
 tools/libxl/libxl_disk.c     | 1258 +++++++++
 tools/libxl/libxl_domain.c   | 1744 ++++++++++++
 tools/libxl/libxl_internal.h |    8 +-
 tools/libxl/libxl_mem.c      |  601 ++++
 tools/libxl/libxl_sched.c    |  915 +++++++
 tools/libxl/libxl_tmem.c     |  167 ++
 11 files changed, 6424 insertions(+), 6265 deletions(-)
 create mode 100644 tools/libxl/libxl_console.c
 create mode 100644 tools/libxl/libxl_cpupool.c
 create mode 100644 tools/libxl/libxl_disk.c
 create mode 100644 tools/libxl/libxl_domain.c
 create mode 100644 tools/libxl/libxl_mem.c
 create mode 100644 tools/libxl/libxl_sched.c
 create mode 100644 tools/libxl/libxl_tmem.c
Signature · 1 line
2.10.2

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

#16 lore raw
Quoted 1 line · Wei Liu

And CC Zhangchen

Thanks, I will apply this patch set before test my patch.

Zhang Chen

Quoted 56 lines · Wei Liu
Quoted 8 lines

Cc Yi Sun as well.

Haozhong and Yi: This is just a heads-up -- Juergen from SuSE took the time to split libxl.c so things are better organised. It's likely this series will go in before yours, so you will then need to rebase your series. I don't expect there to be much breakage because it is all mechanical, but rebasing is still work for you.

Quoted 43 lines

Let us know if you have any concern so that we can coordinate this.

Wei.

Quoted 38 lines · Juergen Gross

libxl.c has become rather large. Split it up into multiple files.

Code movement only. No functional change intended.

Juergen Gross (9):
libxl: adjust copyright comment of libxl.c
libxl: carve out cpupool specific functions from libxl.c
libxl: carve out scheduler specific functions from libxl.c
libxl: carve out disk specific functions from libxl.c
libxl: carve out console specific functions from libxl.c
libxl: carve out memory specific functions from libxl.c
libxl: move device specific functions out of libxl.c
libxl: carve out tmem specific functions from libxl.c
libxl: carve out domain specific functions from libxl.c

  tools/libxl/Makefile         |    4 +-
  tools/libxl/libxl.c          | 6252 +-----------------------------------------
  tools/libxl/libxl_console.c  |  862 ++++++
  tools/libxl/libxl_cpupool.c  |  443 +++
  tools/libxl/libxl_device.c   |  435 ++-
  tools/libxl/libxl_disk.c     | 1258 +++++++++
  tools/libxl/libxl_domain.c   | 1744 ++++++++++++
  tools/libxl/libxl_internal.h |    8 +-
  tools/libxl/libxl_mem.c      |  601 ++++
  tools/libxl/libxl_sched.c    |  915 +++++++
  tools/libxl/libxl_tmem.c     |  167 ++
  11 files changed, 6424 insertions(+), 6265 deletions(-)

create mode 100644 tools/libxl/libxl_console.c
create mode 100644 tools/libxl/libxl_cpupool.c
create mode 100644 tools/libxl/libxl_disk.c
create mode 100644 tools/libxl/libxl_domain.c
create mode 100644 tools/libxl/libxl_mem.c
create mode 100644 tools/libxl/libxl_sched.c
create mode 100644 tools/libxl/libxl_tmem.c

Signature · 1 line
2.10.2

.

Signature · 10 lines
Thanks
Zhang Chen




_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#17 lore raw
Quoted 7 lines · Zhang Chen
Quoted 1 line · Wei Liu

And CC Zhangchen

Thanks, I will apply this patch set before test my patch.

This is not yet the final form. Please need to wait until this work gets applied.

Wei.

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

#18 lore raw
In reply to Wei Liu
Quoted 8 lines · Wei Liu

Cc Yi Sun as well.

Haozhong and Yi: This is just a heads-up -- Juergen from SuSE took the time to split libxl.c so things are better organised. It's likely this series will go in before yours, so you will then need to rebase your series. I don't expect there to be much breakage because it is all mechanical, but rebasing is still work for you.

Thank you for the remind. As this series does not introduce functional changes and most of libxl changes for NVDIMM already went into a separate libxl_nvdimm.c in my patches, the rebase should be trivial for me.

Haozhong

Quoted 43 lines

Let us know if you have any concern so that we can coordinate this.

Wei.

Quoted 38 lines · Juergen Gross

libxl.c has become rather large. Split it up into multiple files.

Code movement only. No functional change intended.

Juergen Gross (9):
libxl: adjust copyright comment of libxl.c
libxl: carve out cpupool specific functions from libxl.c
libxl: carve out scheduler specific functions from libxl.c
libxl: carve out disk specific functions from libxl.c
libxl: carve out console specific functions from libxl.c
libxl: carve out memory specific functions from libxl.c
libxl: move device specific functions out of libxl.c
libxl: carve out tmem specific functions from libxl.c
libxl: carve out domain specific functions from libxl.c

 tools/libxl/Makefile         |    4 +-
 tools/libxl/libxl.c          | 6252 +-----------------------------------------
 tools/libxl/libxl_console.c  |  862 ++++++
 tools/libxl/libxl_cpupool.c  |  443 +++
 tools/libxl/libxl_device.c   |  435 ++-
 tools/libxl/libxl_disk.c     | 1258 +++++++++
 tools/libxl/libxl_domain.c   | 1744 ++++++++++++
 tools/libxl/libxl_internal.h |    8 +-
 tools/libxl/libxl_mem.c      |  601 ++++
 tools/libxl/libxl_sched.c    |  915 +++++++
 tools/libxl/libxl_tmem.c     |  167 ++
 11 files changed, 6424 insertions(+), 6265 deletions(-)
 create mode 100644 tools/libxl/libxl_console.c
 create mode 100644 tools/libxl/libxl_cpupool.c
 create mode 100644 tools/libxl/libxl_disk.c
 create mode 100644 tools/libxl/libxl_domain.c
 create mode 100644 tools/libxl/libxl_mem.c
 create mode 100644 tools/libxl/libxl_sched.c
 create mode 100644 tools/libxl/libxl_tmem.c

--
2.10.2

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