From: Oleksandr Grytsov <al1img@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: ian.jackson@eu.citrix.com, wei.liu2@citrix.com,
Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Subject: [PATCH v4 12/13] libxl: remove unneeded DEVICE_ADD macro
Date: Tue, 18 Jul 2017 17:25:29 +0300 [thread overview]
Message-ID: <1500387930-16317-13-git-send-email-al1img@gmail.com> (raw)
In-Reply-To: <1500387930-16317-1-git-send-email-al1img@gmail.com>
From: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com>
---
tools/libxl/libxl_device.c | 6 ++---
tools/libxl/libxl_disk.c | 5 +++--
tools/libxl/libxl_internal.h | 52 +++-----------------------------------------
tools/libxl/libxl_pci.c | 3 ++-
tools/libxl/libxl_usb.c | 8 +++----
5 files changed, 14 insertions(+), 60 deletions(-)
diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index f1d4848..ca7b165 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -1793,10 +1793,8 @@ out:
return AO_CREATE_FAIL(rc);
}
-static void device_add_domain_config(libxl__gc *gc,
- libxl_domain_config *d_config,
- const struct libxl_device_type *dt,
- void *type)
+void device_add_domain_config(libxl__gc *gc, libxl_domain_config *d_config,
+ const struct libxl_device_type *dt, void *type)
{
int *num_dev;
int i;
diff --git a/tools/libxl/libxl_disk.c b/tools/libxl/libxl_disk.c
index f4f10cb..c41c7b5 100644
--- a/tools/libxl/libxl_disk.c
+++ b/tools/libxl/libxl_disk.c
@@ -277,7 +277,8 @@ static void device_disk_add(libxl__egc *egc, uint32_t domid,
rc = libxl__get_domain_configuration(gc, domid, &d_config);
if (rc) goto out;
- DEVICE_ADD(disk, disks, domid, &disk_saved, COMPARE_DISK, &d_config);
+ device_add_domain_config(gc, &d_config, &libxl__disk_devtype,
+ &disk_saved);
rc = libxl__dm_check_start(gc, &d_config, domid);
if (rc) goto out;
@@ -832,7 +833,7 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk,
rc = libxl__get_domain_configuration(gc, domid, &d_config);
if (rc) goto out;
- DEVICE_ADD(disk, disks, domid, &disk_saved, COMPARE_DISK, &d_config);
+ device_add_domain_config(gc, &d_config, &libxl__disk_devtype, &disk_saved);
rc = libxl__dm_check_start(gc, &d_config, domid);
if (rc) goto out;
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 4b1c5ab..5fd0356 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -4282,55 +4282,6 @@ void libxl__xcinfo2xlinfo(libxl_ctx *ctx,
(a)->port == (b)->port)
#define COMPARE_USBCTRL(a, b) ((a)->devid == (b)->devid)
-/* DEVICE_ADD
- *
- * Add a device in libxl_domain_config structure
- *
- * It takes 6 parameters:
- * type: the type of the device, say nic, vtpm, disk, pci etc
- * ptr: pointer to the start of the array, the array must be
- * of type libxl_device_#type
- * domid: domain id of target domain
- * dev: the device that is to be added / removed / updated
- * compare: the COMPARE_* macro used to compare @dev's identifier to
- * those in the array pointed to by @ptr
- * d_config: pointer to template domain config
- *
- * For most device types (nic, vtpm), the array pointer @ptr can be
- * derived from @type, pci device being the exception, hence we need
- * to have @ptr.
- *
- * If there is already a device with the same identifier in d_config,
- * that entry is updated.
- */
-#define DEVICE_ADD(type, ptr, domid, dev, compare, d_config) \
- ({ \
- int DA_x; \
- libxl_device_##type *DA_p = NULL; \
- \
- /* Check for existing device */ \
- for (DA_x = 0; DA_x < (d_config)->num_##ptr; DA_x++) { \
- if (compare(&(d_config)->ptr[DA_x], (dev))) { \
- DA_p = &(d_config)->ptr[DA_x]; \
- break; \
- } \
- } \
- \
- if (!DA_p) { \
- (d_config)->ptr = \
- libxl__realloc(NOGC, (d_config)->ptr, \
- ((d_config)->num_##ptr + 1) * \
- sizeof(libxl_device_##type)); \
- DA_p = &(d_config)->ptr[(d_config)->num_##ptr]; \
- (d_config)->num_##ptr++; \
- } else { \
- libxl_device_##type##_dispose(DA_p); \
- } \
- \
- libxl_device_##type##_init(DA_p); \
- libxl_device_##type##_copy(CTX, DA_p, (dev)); \
- })
-
/* This function copies X bytes from source to destination bitmap,
* where X is the smaller of the two sizes.
*
@@ -4360,6 +4311,9 @@ static inline bool libxl__acpi_defbool_val(const libxl_domain_build_info *b_info
libxl_defbool_val(b_info->u.hvm.acpi);
}
+void device_add_domain_config(libxl__gc *gc, libxl_domain_config *d_config,
+ const struct libxl_device_type *dt, void *type);
+
void libxl__device_add_async(libxl__egc *egc, uint32_t domid,
const struct libxl_device_type *dt, void *type,
libxl__ao_device *aodev);
diff --git a/tools/libxl/libxl_pci.c b/tools/libxl/libxl_pci.c
index c3f1e5c..159d046 100644
--- a/tools/libxl/libxl_pci.c
+++ b/tools/libxl/libxl_pci.c
@@ -160,7 +160,8 @@ static int libxl__device_pci_add_xenstore(libxl__gc *gc, uint32_t domid, libxl_d
rc = libxl__get_domain_configuration(gc, domid, &d_config);
if (rc) goto out;
- DEVICE_ADD(pci, pcidevs, domid, &pcidev_saved, COMPARE_PCI, &d_config);
+ device_add_domain_config(gc, &d_config, &libxl__pcidev_devtype,
+ &pcidev_saved);
rc = libxl__dm_check_start(gc, &d_config, domid);
if (rc) goto out;
diff --git a/tools/libxl/libxl_usb.c b/tools/libxl/libxl_usb.c
index 07fb202..e526c08 100644
--- a/tools/libxl/libxl_usb.c
+++ b/tools/libxl/libxl_usb.c
@@ -245,8 +245,8 @@ static int libxl__device_usbctrl_add_xenstore(libxl__gc *gc, uint32_t domid,
rc = libxl__get_domain_configuration(gc, domid, &d_config);
if (rc) goto out;
- DEVICE_ADD(usbctrl, usbctrls, domid, &usbctrl_saved,
- COMPARE_USBCTRL, &d_config);
+ device_add_domain_config(gc, &d_config, &libxl__usbctrl_devtype,
+ &usbctrl_saved);
rc = libxl__dm_check_start(gc, &d_config, domid);
if (rc) goto out;
@@ -1199,8 +1199,8 @@ static int libxl__device_usbdev_add_xenstore(libxl__gc *gc, uint32_t domid,
rc = libxl__get_domain_configuration(gc, domid, &d_config);
if (rc) goto out;
- DEVICE_ADD(usbdev, usbdevs, domid, &usbdev_saved,
- COMPARE_USB, &d_config);
+ device_add_domain_config(gc, &d_config, &libxl__usbdev_devtype,
+ &usbdev_saved);
rc = libxl__dm_check_start(gc, &d_config, domid);
if (rc) goto out;
--
2.7.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-07-18 14:25 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-18 14:25 [PATCH v4 00/13] libxl: add PV display device driver interface Oleksandr Grytsov
2017-07-18 14:25 ` [PATCH v4 01/13] libxl: add generic function to add device Oleksandr Grytsov
2017-09-05 11:47 ` Wei Liu
2017-09-05 16:44 ` Oleksandr Grytsov
2017-09-06 9:36 ` Wei Liu
2017-09-06 12:08 ` Oleksandr Grytsov
2017-07-18 14:25 ` [PATCH v4 02/13] libxl: add generic functions to get and free device list Oleksandr Grytsov
2017-09-05 11:51 ` Wei Liu
2017-09-06 12:31 ` Oleksandr Grytsov
2017-07-18 14:25 ` [PATCH v4 03/13] libxl: add vdispl device Oleksandr Grytsov
2017-09-05 12:52 ` Wei Liu
2017-09-05 12:58 ` Ian Jackson
2017-09-05 13:04 ` Wei Liu
2017-09-06 13:02 ` Oleksandr Grytsov
2017-09-06 13:39 ` Wei Liu
2017-07-18 14:25 ` [PATCH v4 04/13] xl: add PV display device commands Oleksandr Grytsov
2017-07-28 14:11 ` Wei Liu
2017-07-18 14:25 ` [PATCH v4 05/13] docs: add PV display driver information Oleksandr Grytsov
2017-07-28 14:11 ` Wei Liu
2017-07-18 14:25 ` [PATCH v4 06/13] libxl: change p9 to use generec add function Oleksandr Grytsov
2017-07-28 14:11 ` Wei Liu
2017-07-28 16:23 ` Wei Liu
2017-07-30 18:42 ` Oleksandr Grytsov
2017-07-31 14:36 ` Wei Liu
2017-08-01 11:58 ` Oleksandr Grytsov
2017-08-01 13:00 ` Wei Liu
2017-08-02 11:37 ` Oleksandr Grytsov
2017-08-04 11:53 ` Wei Liu
2017-08-08 12:39 ` Oleksandr Grytsov
2017-08-08 15:05 ` Wei Liu
2017-09-05 12:53 ` Wei Liu
2017-07-18 14:25 ` [PATCH v4 07/13] libxl: change vkb " Oleksandr Grytsov
2017-09-05 12:54 ` Wei Liu
2017-07-18 14:25 ` [PATCH v4 08/13] libxl: change vfb " Oleksandr Grytsov
2017-09-05 12:55 ` Wei Liu
2017-07-18 14:25 ` [PATCH v4 09/13] libxl: change disk to use generic getting list functions Oleksandr Grytsov
2017-09-05 12:58 ` Wei Liu
2017-07-18 14:25 ` [PATCH v4 10/13] libxl: change nic to use generec add function Oleksandr Grytsov
2017-09-05 13:03 ` Wei Liu
2017-09-06 15:39 ` Oleksandr Grytsov
2017-07-18 14:25 ` [PATCH v4 11/13] libxl: change vtpm " Oleksandr Grytsov
2017-09-05 13:05 ` Wei Liu
2017-07-18 14:25 ` Oleksandr Grytsov [this message]
2017-09-05 13:05 ` [PATCH v4 12/13] libxl: remove unneeded DEVICE_ADD macro Wei Liu
2017-07-18 14:25 ` [PATCH v4 13/13] libxl: make pci and usb setdefault function generic Oleksandr Grytsov
2017-09-05 13:06 ` Wei Liu
2017-09-06 15:53 ` Oleksandr Grytsov
2017-09-07 9:05 ` Wei Liu
2017-07-27 11:30 ` [PATCH v4 00/13] libxl: add PV display device driver interface Oleksandr Andrushchenko
2017-07-27 14:49 ` Wei Liu
2017-07-28 14:13 ` Wei Liu
2017-08-17 10:13 ` Oleksandr Grytsov
2017-08-17 11:11 ` Wei Liu
2017-08-30 15:49 ` Oleksandr Grytsov
2017-08-30 15:52 ` Ian Jackson
2017-08-31 9:01 ` Oleksandr Grytsov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1500387930-16317-13-git-send-email-al1img@gmail.com \
--to=al1img@gmail.com \
--cc=ian.jackson@eu.citrix.com \
--cc=oleksandr_grytsov@epam.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).