From nobody Mon Feb 9 17:08:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1562157703; cv=none; d=zoho.com; s=zohoarc; b=fOfRbAljbyJUiQvpd2GinNAbeXUHyIM/Eo8wbAy9DASvxjoNKC7H/4gaR9LZk4q/hAtSLDnCT+SYQ6VRwMjqTwNkrA0CzKiHJYcUROX8dauhRHOJ5+EoXBcvOcSrll+JL2+VyMsemvwyQiTsFyRkC7dDN9Cf9ekBpW88wcoLx0Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562157703; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=TXcrCpQfk396U5h1LHukEy4kwRL7B1pIlWcpF8SAw34=; b=Af7mrQn4uGbKbH5R+Wx1seacBT4j05AnpbJrKkvsWlZKPFNxkvIGFl/Lj1gRI0RX3lQZfToXfOzzAT0vqpRhKBCfURBPbaMo5TrrAIyz1xCfOJ5qMUrgcG5APC6mhZSwbSWJM4eAMN8worPR+atIyNVfc151cotEfHaE/ij5vX4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1562157703538728.4459073563866; Wed, 3 Jul 2019 05:41:43 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 996F388304; Wed, 3 Jul 2019 12:41:41 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6CB567BE6C; Wed, 3 Jul 2019 12:41:41 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 1F4BE18433A8; Wed, 3 Jul 2019 12:41:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x63CcIOk007869 for ; Wed, 3 Jul 2019 08:38:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id A4A5117CEB; Wed, 3 Jul 2019 12:38:18 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 30493834EB for ; Wed, 3 Jul 2019 12:38:18 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 3 Jul 2019 14:38:02 +0200 Message-Id: <6c541682e719d7ab04f4913a7b55381a67d6f8c7.1562157378.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/14] xen: Move xenParseSxprVifRate to xen_common X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 03 Jul 2019 12:41:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" It's the only place where it's used. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/libvirt_xenconfig.syms | 1 - src/xenconfig/xen_common.c | 62 ++++++++++++++++++++++++++++++++++++++ src/xenconfig/xen_sxpr.c | 62 -------------------------------------- src/xenconfig/xen_sxpr.h | 2 -- 4 files changed, 62 insertions(+), 65 deletions(-) diff --git a/src/libvirt_xenconfig.syms b/src/libvirt_xenconfig.syms index 77701c14d9..603f1ce420 100644 --- a/src/libvirt_xenconfig.syms +++ b/src/libvirt_xenconfig.syms @@ -6,7 +6,6 @@ xenGetDomIdFromSxpr; xenGetDomIdFromSxprString; xenParseSxprChar; -xenParseSxprVifRate; # xenconfig/xen_xm.h xenFormatXM; diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index a8905ad049..8eaa64a4e9 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -24,6 +24,8 @@ #include +#include + #include "internal.h" #include "virerror.h" #include "virconf.h" @@ -926,6 +928,66 @@ xenParseVifBridge(virDomainNetDefPtr net, char *bridge) } +static const char *vif_bytes_per_sec_re =3D "^[0-9]+[GMK]?[Bb]/s$"; + +static int +xenParseSxprVifRate(const char *rate, unsigned long long *kbytes_per_sec) +{ + char *trate =3D NULL; + char *p; + regex_t rec; + int err; + char *suffix; + unsigned long long tmp; + int ret =3D -1; + + if (VIR_STRDUP(trate, rate) < 0) + return -1; + + p =3D strchr(trate, '@'); + if (p !=3D NULL) + *p =3D 0; + + err =3D regcomp(&rec, vif_bytes_per_sec_re, REG_EXTENDED|REG_NOSUB); + if (err !=3D 0) { + char error[100]; + regerror(err, &rec, error, sizeof(error)); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to compile regular expression '%s': %s"), + vif_bytes_per_sec_re, error); + goto cleanup; + } + + if (regexec(&rec, trate, 0, NULL, 0)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid rate '%s' specified"), rate); + goto cleanup; + } + + if (virStrToLong_ull(rate, &suffix, 10, &tmp)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to parse rate '%s'"), rate); + goto cleanup; + } + + if (*suffix =3D=3D 'G') + tmp *=3D 1024 * 1024; + else if (*suffix =3D=3D 'M') + tmp *=3D 1024; + + if (*suffix =3D=3D 'b' || *(suffix + 1) =3D=3D 'b') + tmp /=3D 8; + + *kbytes_per_sec =3D tmp; + ret =3D 0; + + cleanup: + regfree(&rec); + VIR_FREE(trate); + return ret; +} + + static virDomainNetDefPtr xenParseVif(char *entry, const char *vif_typename) { diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c index 8876350b8f..953909e7b4 100644 --- a/src/xenconfig/xen_sxpr.c +++ b/src/xenconfig/xen_sxpr.c @@ -22,8 +22,6 @@ #include -#include - #include "internal.h" #include "virerror.h" #include "virconf.h" @@ -210,63 +208,3 @@ xenParseSxprChar(const char *value, virDomainChrDefFree(def); return NULL; } - - -static const char *vif_bytes_per_sec_re =3D "^[0-9]+[GMK]?[Bb]/s$"; - -int -xenParseSxprVifRate(const char *rate, unsigned long long *kbytes_per_sec) -{ - char *trate =3D NULL; - char *p; - regex_t rec; - int err; - char *suffix; - unsigned long long tmp; - int ret =3D -1; - - if (VIR_STRDUP(trate, rate) < 0) - return -1; - - p =3D strchr(trate, '@'); - if (p !=3D NULL) - *p =3D 0; - - err =3D regcomp(&rec, vif_bytes_per_sec_re, REG_EXTENDED|REG_NOSUB); - if (err !=3D 0) { - char error[100]; - regerror(err, &rec, error, sizeof(error)); - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to compile regular expression '%s': %s"), - vif_bytes_per_sec_re, error); - goto cleanup; - } - - if (regexec(&rec, trate, 0, NULL, 0)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid rate '%s' specified"), rate); - goto cleanup; - } - - if (virStrToLong_ull(rate, &suffix, 10, &tmp)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to parse rate '%s'"), rate); - goto cleanup; - } - - if (*suffix =3D=3D 'G') - tmp *=3D 1024 * 1024; - else if (*suffix =3D=3D 'M') - tmp *=3D 1024; - - if (*suffix =3D=3D 'b' || *(suffix + 1) =3D=3D 'b') - tmp /=3D 8; - - *kbytes_per_sec =3D tmp; - ret =3D 0; - - cleanup: - regfree(&rec); - VIR_FREE(trate); - return ret; -} diff --git a/src/xenconfig/xen_sxpr.h b/src/xenconfig/xen_sxpr.h index 54dfcbb53d..f7112bc6ee 100644 --- a/src/xenconfig/xen_sxpr.h +++ b/src/xenconfig/xen_sxpr.h @@ -32,5 +32,3 @@ int xenGetDomIdFromSxprString(const char *sexpr, int *id); int xenGetDomIdFromSxpr(const struct sexpr *root, int *id); virDomainChrDefPtr xenParseSxprChar(const char *value, const char *tty); - -int xenParseSxprVifRate(const char *rate, unsigned long long *kbytes_per_s= ec); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list