From nobody Mon Feb 9 12:12:08 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=1562157539; cv=none; d=zoho.com; s=zohoarc; b=H4lvUz4/GCYhjDioMTHnYC7cKVcm19Y1+WxsnNeq9RclkEkpnyYl9ftigXf5MghZ4cZPcnfFII01VA0mYIw2FNipq4P2zrVRboRPA/kxR5F0nIQPf2ievQI4WR/po0onep3R3DJLIkeX8hZjoq9WANSHAj4/QGaJxGGorR/wV/k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562157539; 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=HeaYJhDuiHNQN7c6W3efsVAlNj7s47UTcm7kixRuBKI=; b=agWbNMqBXbbkld9xNE4VK/eM7Nr+qMVsBebiNYHzGel7hrPbWWG/c3ijLHdvVF8oIvLwiJGhwYPcXiKBWyj/QSrXKb4KtT0wc2cWOuSC3z8SG33bVmvDJad8zbVrRX+Z0+XT2uqZegBCvaVxQFj9ydEZm96EVUx9i2+yK8PT9uM= 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 1562157538885382.1418014152815; Wed, 3 Jul 2019 05:38:58 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 596BDC04FFF1; Wed, 3 Jul 2019 12:38:55 +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 D55F884250; Wed, 3 Jul 2019 12:38:47 +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 473E118433A1; Wed, 3 Jul 2019 12:38:45 +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 x63CcJjw007898 for ; Wed, 3 Jul 2019 08:38:19 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7072117CEB; Wed, 3 Jul 2019 12:38:19 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id EFD8B834EB 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:03 +0200 Message-Id: <542abc5069018213423eee81ac104d239508f6f4.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 11/14] xen: Move xenParseSxprChar 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 03 Jul 2019 12:38:55 +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 | 146 +++++++++++++++++++++++++++++++++++++ src/xenconfig/xen_sxpr.c | 146 ------------------------------------- src/xenconfig/xen_sxpr.h | 2 - 4 files changed, 146 insertions(+), 149 deletions(-) diff --git a/src/libvirt_xenconfig.syms b/src/libvirt_xenconfig.syms index 603f1ce420..ddaecd6850 100644 --- a/src/libvirt_xenconfig.syms +++ b/src/libvirt_xenconfig.syms @@ -5,7 +5,6 @@ # xenconfig/xen_sxpr.h xenGetDomIdFromSxpr; xenGetDomIdFromSxprString; -xenParseSxprChar; # xenconfig/xen_xm.h xenFormatXM; diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index 8eaa64a4e9..aa069fb74e 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -763,6 +763,152 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def) } +/** + * xenParseSxprChar: + * @value: A string describing a character device. + * @tty: the console pty path + * + * Parse the xend S-expression for description of a character device. + * + * Returns a character device object or NULL in case of failure. + */ +static virDomainChrDefPtr +xenParseSxprChar(const char *value, + const char *tty) +{ + const char *prefix; + char *tmp; + virDomainChrDefPtr def; + + if (!(def =3D virDomainChrDefNew(NULL))) + return NULL; + + prefix =3D value; + + if (value[0] =3D=3D '/') { + def->source->type =3D VIR_DOMAIN_CHR_TYPE_DEV; + if (VIR_STRDUP(def->source->data.file.path, value) < 0) + goto error; + } else { + if ((tmp =3D strchr(value, ':')) !=3D NULL) { + *tmp =3D '\0'; + value =3D tmp + 1; + } + + if (STRPREFIX(prefix, "telnet")) { + def->source->type =3D VIR_DOMAIN_CHR_TYPE_TCP; + def->source->data.tcp.protocol =3D VIR_DOMAIN_CHR_TCP_PROTOCOL= _TELNET; + } else { + if ((def->source->type =3D virDomainChrTypeFromString(prefix))= < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown chr device type '%s'"), prefix); + goto error; + } + } + } + + switch (def->source->type) { + case VIR_DOMAIN_CHR_TYPE_PTY: + if (VIR_STRDUP(def->source->data.file.path, tty) < 0) + goto error; + break; + + case VIR_DOMAIN_CHR_TYPE_FILE: + case VIR_DOMAIN_CHR_TYPE_PIPE: + if (VIR_STRDUP(def->source->data.file.path, value) < 0) + goto error; + break; + + case VIR_DOMAIN_CHR_TYPE_TCP: + { + const char *offset =3D strchr(value, ':'); + const char *offset2; + + if (offset =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("malformed char device string")); + goto error; + } + + if (offset !=3D value && + VIR_STRNDUP(def->source->data.tcp.host, value, offset - value)= < 0) + goto error; + + offset2 =3D strchr(offset, ','); + offset++; + if (VIR_STRNDUP(def->source->data.tcp.service, offset, + offset2 ? offset2 - offset : -1) < 0) + goto error; + + if (offset2 && strstr(offset2, ",server")) + def->source->data.tcp.listen =3D true; + } + break; + + case VIR_DOMAIN_CHR_TYPE_UDP: + { + const char *offset =3D strchr(value, ':'); + const char *offset2, *offset3; + + if (offset =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("malformed char device string")); + goto error; + } + + if (offset !=3D value && + VIR_STRNDUP(def->source->data.udp.connectHost, value, offset -= value) < 0) + goto error; + + offset2 =3D strchr(offset, '@'); + if (offset2 !=3D NULL) { + if (VIR_STRNDUP(def->source->data.udp.connectService, + offset + 1, offset2 - offset - 1) < 0) + goto error; + + offset3 =3D strchr(offset2, ':'); + if (offset3 =3D=3D NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("malformed char device string")); + goto error; + } + + if (offset3 > (offset2 + 1) && + VIR_STRNDUP(def->source->data.udp.bindHost, + offset2 + 1, offset3 - offset2 - 1) < 0) + goto error; + + if (VIR_STRDUP(def->source->data.udp.bindService, offset3 + 1)= < 0) + goto error; + } else { + if (VIR_STRDUP(def->source->data.udp.connectService, offset + = 1) < 0) + goto error; + } + } + break; + + case VIR_DOMAIN_CHR_TYPE_UNIX: + { + const char *offset =3D strchr(value, ','); + if (VIR_STRNDUP(def->source->data.nix.path, value, + offset ? offset - value : -1) < 0) + goto error; + + if (offset !=3D NULL && + strstr(offset, ",server") !=3D NULL) + def->source->data.nix.listen =3D true; + } + break; + } + + return def; + + error: + virDomainChrDefFree(def); + return NULL; +} + + static int xenParseCharDev(virConfPtr conf, virDomainDefPtr def, const char *nativeFo= rmat) { diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c index 953909e7b4..f087464c4d 100644 --- a/src/xenconfig/xen_sxpr.c +++ b/src/xenconfig/xen_sxpr.c @@ -62,149 +62,3 @@ int xenGetDomIdFromSxpr(const struct sexpr *root, int *= id) *id =3D tmp ? sexpr_int(root, "domain/domid") : -1; return 0; } - - -/** - * xenParseSxprChar: - * @value: A string describing a character device. - * @tty: the console pty path - * - * Parse the xend S-expression for description of a character device. - * - * Returns a character device object or NULL in case of failure. - */ -virDomainChrDefPtr -xenParseSxprChar(const char *value, - const char *tty) -{ - const char *prefix; - char *tmp; - virDomainChrDefPtr def; - - if (!(def =3D virDomainChrDefNew(NULL))) - return NULL; - - prefix =3D value; - - if (value[0] =3D=3D '/') { - def->source->type =3D VIR_DOMAIN_CHR_TYPE_DEV; - if (VIR_STRDUP(def->source->data.file.path, value) < 0) - goto error; - } else { - if ((tmp =3D strchr(value, ':')) !=3D NULL) { - *tmp =3D '\0'; - value =3D tmp + 1; - } - - if (STRPREFIX(prefix, "telnet")) { - def->source->type =3D VIR_DOMAIN_CHR_TYPE_TCP; - def->source->data.tcp.protocol =3D VIR_DOMAIN_CHR_TCP_PROTOCOL= _TELNET; - } else { - if ((def->source->type =3D virDomainChrTypeFromString(prefix))= < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown chr device type '%s'"), prefix); - goto error; - } - } - } - - switch (def->source->type) { - case VIR_DOMAIN_CHR_TYPE_PTY: - if (VIR_STRDUP(def->source->data.file.path, tty) < 0) - goto error; - break; - - case VIR_DOMAIN_CHR_TYPE_FILE: - case VIR_DOMAIN_CHR_TYPE_PIPE: - if (VIR_STRDUP(def->source->data.file.path, value) < 0) - goto error; - break; - - case VIR_DOMAIN_CHR_TYPE_TCP: - { - const char *offset =3D strchr(value, ':'); - const char *offset2; - - if (offset =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("malformed char device string")); - goto error; - } - - if (offset !=3D value && - VIR_STRNDUP(def->source->data.tcp.host, value, offset - value)= < 0) - goto error; - - offset2 =3D strchr(offset, ','); - offset++; - if (VIR_STRNDUP(def->source->data.tcp.service, offset, - offset2 ? offset2 - offset : -1) < 0) - goto error; - - if (offset2 && strstr(offset2, ",server")) - def->source->data.tcp.listen =3D true; - } - break; - - case VIR_DOMAIN_CHR_TYPE_UDP: - { - const char *offset =3D strchr(value, ':'); - const char *offset2, *offset3; - - if (offset =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("malformed char device string")); - goto error; - } - - if (offset !=3D value && - VIR_STRNDUP(def->source->data.udp.connectHost, value, offset -= value) < 0) - goto error; - - offset2 =3D strchr(offset, '@'); - if (offset2 !=3D NULL) { - if (VIR_STRNDUP(def->source->data.udp.connectService, - offset + 1, offset2 - offset - 1) < 0) - goto error; - - offset3 =3D strchr(offset2, ':'); - if (offset3 =3D=3D NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("malformed char device string")); - goto error; - } - - if (offset3 > (offset2 + 1) && - VIR_STRNDUP(def->source->data.udp.bindHost, - offset2 + 1, offset3 - offset2 - 1) < 0) - goto error; - - if (VIR_STRDUP(def->source->data.udp.bindService, offset3 + 1)= < 0) - goto error; - } else { - if (VIR_STRDUP(def->source->data.udp.connectService, offset + = 1) < 0) - goto error; - } - } - break; - - case VIR_DOMAIN_CHR_TYPE_UNIX: - { - const char *offset =3D strchr(value, ','); - if (VIR_STRNDUP(def->source->data.nix.path, value, - offset ? offset - value : -1) < 0) - goto error; - - if (offset !=3D NULL && - strstr(offset, ",server") !=3D NULL) - def->source->data.nix.listen =3D true; - } - break; - } - - return def; - - error: - virDomainChrDefFree(def); - return NULL; -} diff --git a/src/xenconfig/xen_sxpr.h b/src/xenconfig/xen_sxpr.h index f7112bc6ee..ad6e293e57 100644 --- a/src/xenconfig/xen_sxpr.h +++ b/src/xenconfig/xen_sxpr.h @@ -30,5 +30,3 @@ /* helper functions to get the dom id from a sexpr */ int xenGetDomIdFromSxprString(const char *sexpr, int *id); int xenGetDomIdFromSxpr(const struct sexpr *root, int *id); - -virDomainChrDefPtr xenParseSxprChar(const char *value, const char *tty); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list