From patchwork Mon Sep 11 17:15:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Grytsov X-Patchwork-Id: 9947767 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 3A58E6024A for ; Mon, 11 Sep 2017 17:18:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A53F28CD0 for ; Mon, 11 Sep 2017 17:18:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F11428CD3; Mon, 11 Sep 2017 17:18:07 +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=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, 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 4622728CCA for ; Mon, 11 Sep 2017 17:18:06 +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 1drSJ4-00022L-AR; Mon, 11 Sep 2017 17:15:34 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drSJ2-0001zm-U8 for xen-devel@lists.xenproject.org; Mon, 11 Sep 2017 17:15:33 +0000 Received: from [85.158.139.211] by server-4.bemta-5.messagelabs.com id 7D/50-09852-4B4C6B95; Mon, 11 Sep 2017 17:15:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFIsWRWlGSWpSXmKPExsVyMfS6o+7mI9s iDQ6+kbL4vmUykwOjx+EPV1gCGKNYM/OS8isSWDPeX9nNXHC7quLn8mmMDYzPI7oYuTiEBGYw StzddJwJxGEReMkisXTObUYQR0Kgn1Xi8MF5QA4nkBMn8fL7LtYuRg4gO02idT43RLhYoql3E zOILSQgL3Gw5TI7xNRpTBKrpv5lAkmwCWhJ3L+9gg3EFhFQkri3ajJYnFkgRWLvujaw+cIC7h KT734Fq2ERUJW4/3kBO4jNK+Ao8e/5Q2aIZXISN891gtmcQPElU7pYIRY7SBx53sk+gVFwASP DKkaN4tSistQiXUMTvaSizPSMktzEzBxdQwNTvdzU4uLE9NScxKRiveT83E2MwJBjAIIdjGdP ex5ilORgUhLlfXd8S6QQX1J+SmVGYnFGfFFpTmrxIUYNDg6Bn0//tjBKseTl56UqSfAePLwtU kiwKDU9tSItMwcYFTClEhw8SiK8OSBp3uKCxNzizHSI1ClGe44Ldy79YeI4tukykDyw5xaQ7L h59w+TENhUKXHeRSBtAiBtGaV5cENhUXyJUVZKmJcR6GQhnoLUotzMElT5V4ziHIxKwry5IFN 4MvNK4Ha/AjqLCegsnktbQM4qSURISTUwrjz3UZ95Zuy2hTeZrL/8PS7UYn//80atvu8yz5yP 1Las7J2bofoyTEdW+LROkpzYmc1cPirbOCtEGgR5yko+PDjXe+33jyi5xW7RH0uXdh3xkuL1E LhUHLTPcNalL2kFTUt+Ce3b9rfjRHFaY8TU9ZXsM5qWhWx//m1bN8s3Fx6fj/Jfv/T2KLEUZy QaajEXFScCAEG5S63dAgAA X-Env-Sender: al1img@gmail.com X-Msg-Ref: server-13.tower-206.messagelabs.com!1505150131!95510012!1 X-Originating-IP: [209.85.215.65] 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 29915 invoked from network); 11 Sep 2017 17:15:31 -0000 Received: from mail-lf0-f65.google.com (HELO mail-lf0-f65.google.com) (209.85.215.65) by server-13.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 11 Sep 2017 17:15:31 -0000 Received: by mail-lf0-f65.google.com with SMTP id m199so4226051lfe.5 for ; Mon, 11 Sep 2017 10:15:31 -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=QDbv0L+MsqJGN/Q35ejRXBIlmuk3xamU9PDATxSledo=; b=muCv5CFACql1mkgkaPmmYSkzhUhInll6nsAIqcaa1rBNBdYwN0rDZCW27lrMRT3bJ3 BMT6O2gE0bOU2FYcs7tZZdR1HWUOy4QzI8mrwofJLLMwk3JUKbNXj60Z0qJoQMZlfZ8+ StCXWJ6Md9npuibzPweV1iJcCVuwMfO4Q9n6J4KRPRGpeLdSZnWsBPmI6PEQsdn9R+zj tVHsmLQ6gSQ+pxMbNL5OCXlJB0WN4qp1WG31u+Gq5SoNqYs5w7UjP/5ohBZfl62LRwUS 3m+BIBlNNfcIEBDwB8zKQ9Crxz823+bbMPH3/tmHrtLCWz2dpeeqGHUj8TY6jWQkH5bq DoRg== 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=QDbv0L+MsqJGN/Q35ejRXBIlmuk3xamU9PDATxSledo=; b=XvCbremXreJPebG/427wOkoakZ8DZnEv+L+s2m9e1RgGd+8DB6mfF3rmZ4U/iuf3BN /2yzedB1iObI6ArTjAv2lcbZqgZI85L0+ZR2PLdilzr+2hpzBLHJnid1IDDF+7tkCJ2r bwbqyJdUuGV8TTqySOvm1XFyD60ZQYzfhebWeZDCx42iM5tBu5ceemjI6YX8sxiLIfw9 CYE+5FVGl5GF1Td8Y/suJyegqnQTi6Qsf1JYPc47ech3ZF7aU8Szksco55seAQZv/kpX vNHn9BIhLadcmjqeGXFNlIsbxJ8E35SuClxBRq+xN2rEKAkjvItHoaRi7eCLHy9B3CHl mq1w== X-Gm-Message-State: AHPjjUhtCU+NklCnnhHjsmjfK0sjCX5RJvFr9i+xP/+Rv7MohHqdxOzO jVQmYEUD2vSTQAYB X-Google-Smtp-Source: ADKCNb4jiiHdZfvWi+WSZ2mMLK8182dIl0XlRUBTbJ0F4LW+45KOITX1H7FxsuYYDPXfWLO76B2uAQ== X-Received: by 10.46.2.5 with SMTP id 5mr2860720ljc.75.1505150130360; Mon, 11 Sep 2017 10:15:30 -0700 (PDT) Received: from al1-pc.kyiv.epam.com (ll-57.209.223.85.sovam.net.ua. [85.223.209.57]) by smtp.gmail.com with ESMTPSA id g21sm1893044lje.52.2017.09.11.10.15.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Sep 2017 10:15:29 -0700 (PDT) From: Oleksandr Grytsov To: xen-devel@lists.xenproject.org Date: Mon, 11 Sep 2017 20:15:00 +0300 Message-Id: <1505150102-30806-11-git-send-email-al1img@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505150102-30806-1-git-send-email-al1img@gmail.com> References: <1505150102-30806-1-git-send-email-al1img@gmail.com> Cc: ian.jackson@eu.citrix.com, wei.liu2@citrix.com, Oleksandr Grytsov Subject: [Xen-devel] [PATCH v5 10/12] 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 | 4 +- 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, 52 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..8a9d37a 100644 --- a/tools/libxl/libxl_colo_save.c +++ b/tools/libxl/libxl_colo_save.c @@ -87,6 +87,7 @@ void libxl__colo_save_setup(libxl__egc *egc, libxl__colo_save_state *css) libxl__srm_save_autogen_callbacks *const callbacks = &dss->sws.shs.callbacks.save.a; libxl_device_nic *nics; + int nb; STATE_AO_GC(dss->ao); @@ -122,9 +123,10 @@ 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_nic_list(CTX, cds->domid, &nb); css->cps.checkpoint_host = nics->colo_checkpoint_host; css->cps.checkpoint_port = nics->colo_checkpoint_port; + libxl_device_nic_list_free(nics, nb); } else { cds->device_kind_flags = (1 << LIBXL__DEVICE_KIND_VIF) | (1 << LIBXL__DEVICE_KIND_VBD); 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; }