From patchwork Tue Sep 12 13:48:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Grytsov X-Patchwork-Id: 9949283 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3D48C60360 for ; Tue, 12 Sep 2017 13:51:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DC7928FE3 for ; Tue, 12 Sep 2017 13:51:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22D1828FEA; Tue, 12 Sep 2017 13:51:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4D3C128FE3 for ; Tue, 12 Sep 2017 13:51:16 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drlYT-0005io-Jx; Tue, 12 Sep 2017 13:48:45 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drlYT-0005hz-63 for xen-devel@lists.xenproject.org; Tue, 12 Sep 2017 13:48:45 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id F6/EA-03422-CB5E7B95; Tue, 12 Sep 2017 13:48:44 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJIsWRWlGSWpSXmKPExsVyMfS6s+7Wp9s jDXYcMrT4vmUykwOjx+EPV1gCGKNYM/OS8isSWDM6dp1hLnhWXnFomnQD4/6wLkZODiGB6YwS X3d4dTFycbAIvGSR2HOtlRHEkRDoZ5WY03eZGaRKQiBJ4vKjLywQdprE/Etv2CDsConjdzvZI CbJSxxsucwO0iwkMIVJYv2eHewgCTYBLYn7t1eAFYkIKEncWzWZCcRmFkiR2LuujRHEFhZwl1 h74yGYzSKgKjF721awGl4BR4m2M1+YIJbJSdw81wl2ECdQvP13FzPEYgeJK2v2sE1gFFzAyLC KUaM4tagstUjX0FgvqSgzPaMkNzEzR9fQwEwvN7W4ODE9NScxqVgvOT93EyMw4BiAYAfjl2UB hxglOZiURHmV72+PFOJLyk+pzEgszogvKs1JLT7EqMHBIfDz6d8WRimWvPy8VCUJ3utPgOoEi 1LTUyvSMnOAMQFTKsHBoyTCWwmS5i0uSMwtzkyHSJ1itOe4cOfSHyaOY5suA8kDe24ByY6bd/ 8wCYFNlRLnzQdpEwBpyyjNgxsKi+FLjLJSwryMQCcL8RSkFuVmlqDKv2IU52BUEubdAjKFJzO vBG73K6CzmIDO4rm0BeSskkSElFQDI0NXUwOXxgObb883rbJ89nTHjH+TPc4ssHbuFHm+uC62 +9nJFzw710/aVZeR+e9W/1o1EyZNpobH2Z4n9/U53bvTWWdm6BeRJa/CvKvB8+vcJI4btkVBZ iKL0/XXmk6Zp9XvVXLXTcPwn81Ehp2zjrstL+92tclY83TvAqG12bZdQlfchRzalViKMxINtZ iLihMB4uG8mdwCAAA= X-Env-Sender: al1img@gmail.com X-Msg-Ref: server-7.tower-27.messagelabs.com!1505224117!111780582!1 X-Originating-IP: [209.85.215.67] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 487 invoked from network); 12 Sep 2017 13:48:37 -0000 Received: from mail-lf0-f67.google.com (HELO mail-lf0-f67.google.com) (209.85.215.67) by server-7.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 12 Sep 2017 13:48:37 -0000 Received: by mail-lf0-f67.google.com with SMTP id h80so5384160lfe.1 for ; Tue, 12 Sep 2017 06:48:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VzC1uOTErSEjg7PknIr+s5OyNcNsyl2gLWtVvwD7NsY=; b=XaYBE3C7lnwAS8etdhobtq+KNxl9XsZbnLk6jwqOFTxc49sJ0HVVg98EZ6XU/BRrkJ 7a5kvhEieJKM9Pgr/e0ubzyCHdprmsGOIFroyeyLot1LuQSZIvJUZw2LjQuz8Wed25/c GKhGTJpf22Ts/nRjto0BbyrP3+Hh8BLlG15pl5j3w7yTodmThuKmIyRFHq+sbqTyeOEy S0zgYTgOr8wYWbG76/oxi//fDxvtPOqqYmVrSPISG1o3W5DHwED0CWtHmPsFd8BDvozM 2XEZ5sDoGRaKMiWk2tq0EeLgDJzP6zOrUC7AQMdYBFlaRWSWeuTGAvUmfDVkALnkm/OS iTmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VzC1uOTErSEjg7PknIr+s5OyNcNsyl2gLWtVvwD7NsY=; b=tYWMzxKuTkX+7HGCoSxMxGYpEpsgsEZETTz1/VwwPmdAD0rvacKhyJD5nDoTaCSlmK H5Riofixbn4yLWRRCMYtasz1gqOhmeJ/ajQQdnPgrFUTbb4FMfO3Z8S+51M/IM/I9wmG cbVTSePQs3A+3IYbDWb8kSFSHav7DIXX7+uEKNu1tWho7DA/c3ck9m9ws2tGIr0pRfpV m0Ikrhi/jPNXNKa7+HEM60ILU5WbXCK3QgQl9SGQJynYzlyBtxeVlhMkJwkvwOgnw6sQ 32bIh8jiZ6RkxDj+HVRfA3cPG8vfeOCQCGRODHW/09NAuRkUjv17a4iRjXzT/QMDXCmg iaRg== X-Gm-Message-State: AHPjjUiXhx1YK3JreFc07gZIFlw/ItcEexfGtnlabovnzH+h+zy0ENL2 MuClBOZVamHt/eEWdAg= X-Google-Smtp-Source: AOwi7QC85tyoh9lVIBruDgV1a9a9PhsaThFtK8hCcovVbVQf0W3VfsavF5zuit/5Xzlwjty/I6lNeQ== X-Received: by 10.25.145.66 with SMTP id y2mr4274479lfj.102.1505224116523; Tue, 12 Sep 2017 06:48:36 -0700 (PDT) Received: from al1-pc.kyiv.epam.com (ll-56.209.223.85.sovam.net.ua. [85.223.209.56]) by smtp.gmail.com with ESMTPSA id s5sm690074lfb.14.2017.09.12.06.48.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Sep 2017 06:48:35 -0700 (PDT) From: Oleksandr Grytsov To: xen-devel@lists.xenproject.org Date: Tue, 12 Sep 2017 16:48:15 +0300 Message-Id: <1505224098-19330-11-git-send-email-al1img@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505224098-19330-1-git-send-email-al1img@gmail.com> References: <1505224098-19330-1-git-send-email-al1img@gmail.com> Cc: ian.jackson@eu.citrix.com, wei.liu2@citrix.com, Oleksandr Grytsov Subject: [Xen-devel] [PATCH v6 10/13] libxl: change nic to use generec add function X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Oleksandr Grytsov Signed-off-by: Oleksandr Grytsov Acked-by: Wei Liu --- tools/libxl/libxl.h | 9 +- tools/libxl/libxl_checkpoint_device.c | 9 +- tools/libxl/libxl_colo_save.c | 3 +- tools/libxl/libxl_dm.c | 4 +- tools/libxl/libxl_internal.h | 2 - tools/libxl/libxl_nic.c | 191 +++++++--------------------------- tools/ocaml/libs/xl/xenlight_stubs.c | 3 +- tools/xl/xl_nic.c | 3 +- 8 files changed, 51 insertions(+), 173 deletions(-) diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index d5a3ab7..abe129e 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -1850,9 +1850,14 @@ int libxl_device_nic_destroy(libxl_ctx *ctx, uint32_t domid, const libxl_asyncop_how *ao_how) LIBXL_EXTERNAL_CALLERS_ONLY; -libxl_device_nic *libxl_device_nic_list(libxl_ctx *ctx, uint32_t domid, int *num); +libxl_device_nic *libxl_device_nic_list(libxl_ctx *ctx, + uint32_t domid, int *num) + LIBXL_EXTERNAL_CALLERS_ONLY; +void libxl_device_nic_list_free(libxl_device_nic* list, int num) + LIBXL_EXTERNAL_CALLERS_ONLY; int libxl_device_nic_getinfo(libxl_ctx *ctx, uint32_t domid, - libxl_device_nic *nic, libxl_nicinfo *nicinfo); + libxl_device_nic *nic, libxl_nicinfo *nicinfo) + LIBXL_EXTERNAL_CALLERS_ONLY; /* * Virtual Channels diff --git a/tools/libxl/libxl_checkpoint_device.c b/tools/libxl/libxl_checkpoint_device.c index f6a4437..d1cc155 100644 --- a/tools/libxl/libxl_checkpoint_device.c +++ b/tools/libxl/libxl_checkpoint_device.c @@ -63,7 +63,8 @@ void libxl__checkpoint_devices_setup(libxl__egc *egc, cds->num_disks = 0; if (cds->device_kind_flags & (1 << LIBXL__DEVICE_KIND_VIF)) - cds->nics = libxl_device_nic_list(CTX, cds->domid, &cds->num_nics); + cds->nics = libxl__device_list(gc, &libxl__nic_devtype, cds->domid, + "vif", &cds->num_nics); if (cds->device_kind_flags & (1 << LIBXL__DEVICE_KIND_VBD)) cds->disks = libxl__device_list(gc, &libxl__disk_devtype, cds->domid, @@ -206,8 +207,6 @@ static void devices_teardown_cb(libxl__egc *egc, libxl__multidev *multidev, int rc) { - int i; - STATE_AO_GC(multidev->ao); /* Convenience aliases */ @@ -215,9 +214,7 @@ static void devices_teardown_cb(libxl__egc *egc, CONTAINER_OF(multidev, *cds, multidev); /* clean nic */ - for (i = 0; i < cds->num_nics; i++) - libxl_device_nic_dispose(&cds->nics[i]); - free(cds->nics); + libxl__device_list_free(&libxl__nic_devtype, cds->nics, cds->num_nics); cds->nics = NULL; cds->num_nics = 0; diff --git a/tools/libxl/libxl_colo_save.c b/tools/libxl/libxl_colo_save.c index f687d5a..bf68198 100644 --- a/tools/libxl/libxl_colo_save.c +++ b/tools/libxl/libxl_colo_save.c @@ -122,7 +122,8 @@ void libxl__colo_save_setup(libxl__egc *egc, libxl__colo_save_state *css) cds->device_kind_flags = (1 << LIBXL__DEVICE_KIND_VBD); /* Use this args we can connect to qemu colo-compare */ - nics = libxl_device_nic_list(CTX, cds->domid, &cds->num_nics); + nics = libxl__device_list(gc, &libxl__nic_devtype, + cds->domid, "vif", &cds->num_nics); css->cps.checkpoint_host = nics->colo_checkpoint_host; css->cps.checkpoint_port = nics->colo_checkpoint_port; } else { diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c index 275fabc..98f89a9 100644 --- a/tools/libxl/libxl_dm.c +++ b/tools/libxl/libxl_dm.c @@ -1975,8 +1975,8 @@ static void spawn_stub_launch_dm(libxl__egc *egc, * called libxl_device_nic_add at this point, but qemu needs * the nic information to be complete. */ - ret = libxl__device_nic_setdefault(gc, dm_domid, &dm_config->nics[i], - false); + ret = libxl__nic_devtype.set_default(gc, dm_domid, &dm_config->nics[i], + false); if (ret) goto out; } diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index de1706c..976827a 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -1242,8 +1242,6 @@ _hidden int libxl__domain_create_info_setdefault(libxl__gc *gc, libxl_domain_create_info *c_info); _hidden int libxl__domain_build_info_setdefault(libxl__gc *gc, libxl_domain_build_info *b_info); -_hidden int libxl__device_nic_setdefault(libxl__gc *gc, uint32_t domid, - libxl_device_nic *nic, bool hotplug); _hidden void libxl__rdm_setdefault(libxl__gc *gc, libxl_domain_build_info *b_info); diff --git a/tools/libxl/libxl_nic.c b/tools/libxl/libxl_nic.c index e7792ba..d81b95b 100644 --- a/tools/libxl/libxl_nic.c +++ b/tools/libxl/libxl_nic.c @@ -20,6 +20,7 @@ int libxl_mac_to_device_nic(libxl_ctx *ctx, uint32_t domid, const char *mac, libxl_device_nic *nic) { + GC_INIT(ctx); libxl_device_nic *nics; int nb, rc, i; libxl_mac mac_n; @@ -28,7 +29,7 @@ int libxl_mac_to_device_nic(libxl_ctx *ctx, uint32_t domid, if (rc) return rc; - nics = libxl_device_nic_list(ctx, domid, &nb); + nics = libxl__device_list(gc, &libxl__nic_devtype, domid, "vif", &nb); if (!nics) return ERROR_FAIL; @@ -52,8 +53,8 @@ int libxl_mac_to_device_nic(libxl_ctx *ctx, uint32_t domid, return rc; } -int libxl__device_nic_setdefault(libxl__gc *gc, uint32_t domid, - libxl_device_nic *nic, bool hotplug) +static int libxl__device_nic_setdefault(libxl__gc *gc, uint32_t domid, + libxl_device_nic *nic, bool hotplug) { int rc; @@ -140,45 +141,13 @@ static void libxl__update_config_nic(libxl__gc *gc, libxl_device_nic *dst, static LIBXL_DEFINE_UPDATE_DEVID(nic, "vif") -static void libxl__device_nic_add(libxl__egc *egc, uint32_t domid, - libxl_device_nic *nic, - libxl__ao_device *aodev) +static int libxl__set_xenstore_nic(libxl__gc *gc, uint32_t domid, + libxl_device_nic *nic, + flexarray_t *back, flexarray_t *front, + flexarray_t *ro_front) { - STATE_AO_GC(aodev->ao); - flexarray_t *front; - flexarray_t *back; - libxl__device *device; - int rc; - xs_transaction_t t = XBT_NULL; - libxl_domain_config d_config; - libxl_device_nic nic_saved; - libxl__domain_userdata_lock *lock = NULL; - - libxl_domain_config_init(&d_config); - libxl_device_nic_init(&nic_saved); - libxl_device_nic_copy(CTX, &nic_saved, nic); - - rc = libxl__device_nic_setdefault(gc, domid, nic, aodev->update_json); - if (rc) goto out; + flexarray_grow(back, 2); - front = flexarray_make(gc, 16, 1); - back = flexarray_make(gc, 18, 1); - - rc = libxl__device_nic_update_devid(gc, domid, nic); - if (rc) goto out; - - libxl__update_config_nic(gc, &nic_saved, nic); - - GCNEW(device); - rc = libxl__device_from_nic(gc, domid, nic, device); - if ( rc != 0 ) goto out; - - flexarray_append(back, "frontend-id"); - flexarray_append(back, GCSPRINTF("%d", domid)); - flexarray_append(back, "online"); - flexarray_append(back, "1"); - flexarray_append(back, "state"); - flexarray_append(back, GCSPRINTF("%d", XenbusStateInitialising)); if (nic->script) flexarray_append_pair(back, "script", libxl__abs_path(gc, nic->script, @@ -279,78 +248,24 @@ static void libxl__device_nic_add(libxl__egc *egc, uint32_t domid, flexarray_append(back, libxl__strdup(gc, libxl_nic_type_to_string(nic->nictype))); - flexarray_append(front, "backend-id"); - flexarray_append(front, GCSPRINTF("%d", nic->backend_domid)); - flexarray_append(front, "state"); - flexarray_append(front, GCSPRINTF("%d", XenbusStateInitialising)); flexarray_append(front, "handle"); flexarray_append(front, GCSPRINTF("%d", nic->devid)); flexarray_append(front, "mac"); flexarray_append(front, GCSPRINTF( LIBXL_MAC_FMT, LIBXL_MAC_BYTES(nic->mac))); - if (aodev->update_json) { - lock = libxl__lock_domain_userdata(gc, domid); - if (!lock) { - rc = ERROR_LOCK_FAIL; - goto out; - } - - rc = libxl__get_domain_configuration(gc, domid, &d_config); - if (rc) goto out; - - DEVICE_ADD(nic, nics, domid, &nic_saved, COMPARE_DEVID, &d_config); - - rc = libxl__dm_check_start(gc, &d_config, domid); - if (rc) goto out; - } - - for (;;) { - rc = libxl__xs_transaction_start(gc, &t); - if (rc) goto out; - - rc = libxl__device_exists(gc, t, device); - if (rc < 0) goto out; - if (rc == 1) { /* already exists in xenstore */ - LOGD(ERROR, domid, "device already exists in xenstore"); - aodev->action = LIBXL__DEVICE_ACTION_ADD; /* for error message */ - rc = ERROR_DEVICE_EXISTS; - goto out; - } - - if (aodev->update_json) { - rc = libxl__set_domain_configuration(gc, domid, &d_config); - if (rc) goto out; - } - - libxl__device_generic_add(gc, t, device, - libxl__xs_kvs_of_flexarray(gc, back), - libxl__xs_kvs_of_flexarray(gc, front), - NULL); - - rc = libxl__xs_transaction_commit(gc, &t); - if (!rc) break; - if (rc < 0) goto out; - } - - aodev->dev = device; - aodev->action = LIBXL__DEVICE_ACTION_ADD; - libxl__wait_device_connection(egc, aodev); + return 0; +} - rc = 0; -out: - libxl__xs_transaction_abort(gc, &t); - if (lock) libxl__unlock_domain_userdata(lock); - libxl_device_nic_dispose(&nic_saved); - libxl_domain_config_dispose(&d_config); - aodev->rc = rc; - if (rc) aodev->callback(egc, aodev); - return; +static void libxl__device_nic_add(libxl__egc *egc, uint32_t domid, + libxl_device_nic *nic, + libxl__ao_device *aodev) +{ + libxl__device_add_async(egc, domid, &libxl__nic_devtype, nic, aodev); } -static int libxl__device_nic_from_xenstore(libxl__gc *gc, - const char *libxl_path, - libxl_device_nic *nic) +static int libxl__nic_from_xenstore(libxl__gc *gc, const char *libxl_path, + libxl_devid devid, libxl_device_nic *nic) { const char *tmp; int rc; @@ -496,7 +411,7 @@ int libxl_devid_to_device_nic(libxl_ctx *ctx, uint32_t domid, libxl_path = GCSPRINTF("%s/device/vif/%d", libxl_dom_path, devid); - rc = libxl__device_nic_from_xenstore(gc, libxl_path, nic); + rc = libxl__nic_from_xenstore(gc, libxl_path, devid, nic); if (rc) goto out; rc = 0; @@ -505,64 +420,22 @@ out: return rc; } -static int libxl__append_nic_list(libxl__gc *gc, - uint32_t domid, - libxl_device_nic **nics, - int *nnics) -{ - char *libxl_dir_path = NULL; - char **dir = NULL; - unsigned int n = 0; - libxl_device_nic *pnic = NULL, *pnic_end = NULL; - int rc; - - libxl_dir_path = GCSPRINTF("%s/device/vif", - libxl__xs_libxl_path(gc, domid)); - dir = libxl__xs_directory(gc, XBT_NULL, libxl_dir_path, &n); - if (dir && n) { - libxl_device_nic *tmp; - tmp = realloc(*nics, sizeof (libxl_device_nic) * (*nnics + n)); - if (tmp == NULL) - return ERROR_NOMEM; - *nics = tmp; - pnic = *nics + *nnics; - pnic_end = *nics + *nnics + n; - for (; pnic < pnic_end; pnic++, dir++) { - const char *p; - p = GCSPRINTF("%s/%s", libxl_dir_path, *dir); - rc = libxl__device_nic_from_xenstore(gc, p, pnic); - if (rc) goto out; - } - *nnics += n; - } - return 0; - - out: - return rc; -} - libxl_device_nic *libxl_device_nic_list(libxl_ctx *ctx, uint32_t domid, int *num) { - GC_INIT(ctx); - libxl_device_nic *nics = NULL; - int rc; + libxl_device_nic *r; - *num = 0; + GC_INIT(ctx); - rc = libxl__append_nic_list(gc, domid, &nics, num); - if (rc) goto out_err; + r = libxl__device_list(gc, &libxl__nic_devtype, domid, "vif", num); GC_FREE; - return nics; -out_err: - LOGD(ERROR, domid, "Unable to list nics"); - while (*num) { - (*num)--; - libxl_device_nic_dispose(&nics[*num]); - } - free(nics); - return NULL; + return r; +} + +void libxl_device_nic_list_free(libxl_device_nic* list, int num) +{ + libxl__device_list_free(&libxl__nic_devtype, list, num); } int libxl_device_nic_getinfo(libxl_ctx *ctx, uint32_t domid, @@ -668,7 +541,13 @@ LIBXL_DEFINE_DEVICES_ADD(nic) LIBXL_DEFINE_DEVICE_REMOVE(nic) DEFINE_DEVICE_TYPE_STRUCT(nic, - .update_config = libxl_device_nic_update_config + .update_config = libxl_device_nic_update_config, + .from_xenstore = (int (*)(libxl__gc *, const char *, libxl_devid, void *)) + libxl__nic_from_xenstore, + .set_xenstore_config = (int (*)(libxl__gc *, uint32_t, void *, + flexarray_t *back, flexarray_t *front, + flexarray_t *ro_front)) + libxl__set_xenstore_nic ); /* diff --git a/tools/ocaml/libs/xl/xenlight_stubs.c b/tools/ocaml/libs/xl/xenlight_stubs.c index 55f09d7..badf9c9 100644 --- a/tools/ocaml/libs/xl/xenlight_stubs.c +++ b/tools/ocaml/libs/xl/xenlight_stubs.c @@ -734,9 +734,8 @@ value stub_xl_device_nic_list(value ctx, value domid) Field(list, 1) = temp; temp = list; Store_field(list, 0, Val_device_nic(&c_list[i])); - libxl_device_nic_dispose(&c_list[i]); } - free(c_list); + libxl_device_nic_list_free(c_list, nb) CAMLreturn(list); } diff --git a/tools/xl/xl_nic.c b/tools/xl/xl_nic.c index a78d944..2315dcd 100644 --- a/tools/xl/xl_nic.c +++ b/tools/xl/xl_nic.c @@ -124,9 +124,8 @@ int main_networklist(int argc, char **argv) nicinfo.rref_tx, nicinfo.rref_rx, nicinfo.backend); libxl_nicinfo_dispose(&nicinfo); } - libxl_device_nic_dispose(&nics[i]); } - free(nics); + libxl_device_nic_list_free(nics, nb); } return 0; }