From nobody Wed May 15 00:38:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1645036726; cv=none; d=zohomail.com; s=zohoarc; b=F0DQuyEoWYm0gurAjGDylzli0A0BpmFFGIBiF+tI2gsrs4zVVeLMu5YejBLj0xc+xOAwAcufi8mrgysewf1V7KR2A4VILAFQIreDo80x3UzgUxuQuo3JDRWJHZJn3tOlji3P97eV8RDMgKLlKUuuNlgek90JWdQY78sCSdebhY8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1645036726; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=DnSdq7b5kMq6K6/wvGxeAmku5LHKhORV5TOg+W+EN+I=; b=PhEgc/xNJwQ59/L3Pn7nutN/uX1Qik5ruQ1om2AkPaV0O2FeOAGBC4FhLRin37pfP7HCeim7ShWRoKl7lO8HXi7KUU7q6EuFA/JMmVS0CYDF0ovs8z0uRhKpNnTaRlLMjIn4WHTm5eOPEPNj7KGBr9E6Pq0oWmKxnMlME/gblSU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1645036726242399.2747024943909; Wed, 16 Feb 2022 10:38:46 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-618-Wbu0E2ErPn-KvKh7loh3Pw-1; Wed, 16 Feb 2022 13:38:43 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3A7CE8145EA; Wed, 16 Feb 2022 18:38:38 +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 06B167746B; Wed, 16 Feb 2022 18:38:38 +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 C3E691809CBF; Wed, 16 Feb 2022 18:38:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 21GIcalt014104 for ; Wed, 16 Feb 2022 13:38:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5434477473; Wed, 16 Feb 2022 18:38:36 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.245]) by smtp.corp.redhat.com (Postfix) with ESMTP id 335C27746B; Wed, 16 Feb 2022 18:38:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1645036726; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=DnSdq7b5kMq6K6/wvGxeAmku5LHKhORV5TOg+W+EN+I=; b=bbgSLQcgNm6C5lKOfGKh32Ymf1ZTsmSYYDr2Hoyzfv30qW9FM6wY7mjegvbeeXRJ8F6lE3 yPtNhAH+dyOk/aMA6HW/jifQHpqcLK7UeLFnUG6FGv+p1AZAAzVU0+kQvqAj71P6wRFTUi cm++G206g2jT6gYHMXcUP/X+/pARhV0= X-MC-Unique: Wbu0E2ErPn-KvKh7loh3Pw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2] util: drop support for obsolete systemd in RHEL-7 Date: Wed, 16 Feb 2022 18:38:23 +0000 Message-Id: <20220216183823.1761409-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1645036728246100001 The systemd version in RHEL-7 lacked support for the LISTEN_FDNAMES env variable with socket activation. Since we stopped targetting RHEL-7 we can drop some considerable amount of compatibility code. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: J=C3=A1n Tomko --- docs/daemons.rst | 26 ------- src/locking/lock_daemon.c | 8 +- src/logging/log_daemon.c | 8 +- src/remote/libvirtd-admin.socket.in | 2 - src/remote/libvirtd-ro.socket.in | 2 - src/remote/libvirtd-tcp.socket.in | 2 - src/remote/libvirtd-tls.socket.in | 2 - src/remote/libvirtd.conf.in | 6 +- src/remote/libvirtd.socket.in | 2 - src/remote/remote_daemon.c | 19 +---- src/util/virsystemd.c | 117 +++------------------------- src/util/virsystemd.h | 15 +--- tests/virsystemdtest.c | 38 +-------- 13 files changed, 21 insertions(+), 226 deletions(-) diff --git a/docs/daemons.rst b/docs/daemons.rst index c3970eb89c..383f0f64ff 100644 --- a/docs/daemons.rst +++ b/docs/daemons.rst @@ -209,13 +209,6 @@ controlled via the system unit files ``libvirtd.socket``, ``libvirtd-ro.socket`` and ``libvirtd-admin.socket`= ` unit files. =20 -Systemd releases prior to version 227 lacked support for passing the activ= ation -socket unit names into the service. When using these old versions, the -``tcp_port``, ``tls_port`` and ``unix_sock_dir`` settings in ``libvirtd.co= nf`` -must be changed in lock-step with the equivalent settings in the unit file= s to -ensure that ``libvirtd`` can identify the sockets. - - Modular driver daemons =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 @@ -354,13 +347,6 @@ controlled via the system unit files: ``virt${DRIVER}d.socket``, ``virt${DRIVER}d-ro.socket`` and ``virt${DRIVER}d-admin.socket`` unit files. =20 -Systemd releases prior to version 227 lacked support for passing the activ= ation -socket unit names into the service. When using these old versions, the -``unix_sock_dir`` setting in ``virt${DRIVER}d.conf`` must be changed in -lock-step with the equivalent setting in the unit files to ensure that -``virt${DRIVER}d`` can identify the sockets. - - Switching to modular daemons ---------------------------- =20 @@ -639,12 +625,6 @@ controlled via the system unit files: independently controlled via the ``ListenStream`` parameter in any of the ``virtlogd.socket`` and ``virtlogd-admin.socket`` unit files. =20 -Systemd releases prior to version 227 lacked support for passing the activ= ation -socket unit names into the service. When using these old versions, the -``unix_sock_dir`` setting in ``virtlogd.conf`` must be changed in -lock-step with the equivalent setting in the unit files to ensure that -``virtlogd`` can identify the sockets. - Locking daemon =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 @@ -733,12 +713,6 @@ controlled via the system unit files: independently controlled via the ``ListenStream`` parameter in any of the ``virtlockd.socket`` and ``virtlockd-admin.socket`` unit files. =20 -Systemd releases prior to version 227 lacked support for passing the activ= ation -socket unit names into the service. When using these old versions, the -``unix_sock_dir`` setting in ``virtlockd.conf`` must be changed in -lock-step with the equivalent setting in the unit files to ensure that -``virtlockd`` can identify the sockets. - Changing command line options for daemons =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index b44649bfbe..178e8cf830 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -986,10 +986,6 @@ int main(int argc, char **argv) { * saved state is present, therefore initialize from scratch here. */ if (rv =3D=3D 0) { g_autoptr(virSystemdActivation) act =3D NULL; - virSystemdActivationMap actmap[] =3D { - { .name =3D "virtlockd.socket", .family =3D AF_UNIX, .path =3D= sock_file }, - { .name =3D "virtlockd-admin.socket", .family =3D AF_UNIX, .pa= th =3D admin_sock_file }, - }; =20 if (godaemon) { if (chdir("/") < 0) { @@ -1016,9 +1012,7 @@ int main(int argc, char **argv) { goto cleanup; } =20 - if (virSystemdGetActivation(actmap, - G_N_ELEMENTS(actmap), - &act) < 0) { + if (virSystemdGetActivation(&act) < 0) { ret =3D VIR_DAEMON_ERR_NETWORK; goto cleanup; } diff --git a/src/logging/log_daemon.c b/src/logging/log_daemon.c index 245df9dbbd..82f625142b 100644 --- a/src/logging/log_daemon.c +++ b/src/logging/log_daemon.c @@ -794,10 +794,6 @@ int main(int argc, char **argv) { */ if (rv =3D=3D 0) { g_autoptr(virSystemdActivation) act =3D NULL; - virSystemdActivationMap actmap[] =3D { - { .name =3D "virtlogd.socket", .family =3D AF_UNIX, .path =3D = sock_file }, - { .name =3D "virtlogd-admin.socket", .family =3D AF_UNIX, .pat= h =3D admin_sock_file }, - }; =20 if (godaemon) { if (chdir("/") < 0) { @@ -824,9 +820,7 @@ int main(int argc, char **argv) { goto cleanup; } =20 - if (virSystemdGetActivation(actmap, - G_N_ELEMENTS(actmap), - &act) < 0) { + if (virSystemdGetActivation(&act) < 0) { ret =3D VIR_DAEMON_ERR_NETWORK; goto cleanup; } diff --git a/src/remote/libvirtd-admin.socket.in b/src/remote/libvirtd-admi= n.socket.in index 4129abc1ab..01e1a08939 100644 --- a/src/remote/libvirtd-admin.socket.in +++ b/src/remote/libvirtd-admin.socket.in @@ -6,8 +6,6 @@ After=3D@service@.socket @deps@ =20 [Socket] -# The directory must match the @sysconfdir@/libvirt/@service@.conf unix_so= ck_dir setting -# when using systemd version < 227 ListenStream=3D@runstatedir@/libvirt/@sockprefix@-admin-sock Service=3D@service@.service SocketMode=3D0600 diff --git a/src/remote/libvirtd-ro.socket.in b/src/remote/libvirtd-ro.sock= et.in index cb5e6bd60f..58ae1beb95 100644 --- a/src/remote/libvirtd-ro.socket.in +++ b/src/remote/libvirtd-ro.socket.in @@ -6,8 +6,6 @@ After=3D@service@.socket @deps@ =20 [Socket] -# The directory must match the @sysconfdir@/libvirt/@service@.conf unix_so= ck_dir setting -# when using systemd version < 227 ListenStream=3D@runstatedir@/libvirt/@sockprefix@-sock-ro Service=3D@service@.service SocketMode=3D0666 diff --git a/src/remote/libvirtd-tcp.socket.in b/src/remote/libvirtd-tcp.so= cket.in index dd60317d47..6949df315e 100644 --- a/src/remote/libvirtd-tcp.socket.in +++ b/src/remote/libvirtd-tcp.socket.in @@ -6,8 +6,6 @@ After=3D@service@.socket @deps@ =20 [Socket] -# This must match the @sysconfdir@/libvirt/@service@.conf tcp_port setting -# when using systemd version < 227 ListenStream=3D16509 Service=3D@service@.service =20 diff --git a/src/remote/libvirtd-tls.socket.in b/src/remote/libvirtd-tls.so= cket.in index 8b89737fff..ada2b871f0 100644 --- a/src/remote/libvirtd-tls.socket.in +++ b/src/remote/libvirtd-tls.socket.in @@ -6,8 +6,6 @@ After=3D@service@.socket @deps@ =20 [Socket] -# This must match the @sysconfdir@/libvirt/@service@.conf tls_port setting -# when using systemd version < 227 ListenStream=3D16514 Service=3D@service@.service =20 diff --git a/src/remote/libvirtd.conf.in b/src/remote/libvirtd.conf.in index 2cd20aaa7f..defe6b83d0 100644 --- a/src/remote/libvirtd.conf.in +++ b/src/remote/libvirtd.conf.in @@ -40,7 +40,7 @@ # This can be a port number, or service name # # This setting is not required or honoured if using systemd socket -# activation with systemd version >=3D 227 +# activation. # #tls_port =3D "16514" =20 @@ -48,7 +48,7 @@ # This can be a port number, or service name # # This setting is not required or honoured if using systemd socket -# activation with systemd version >=3D 227 +# activation. # #tcp_port =3D "16509" =20 @@ -117,7 +117,7 @@ # Set the name of the directory in which sockets will be found/created. # # This setting is not required or honoured if using systemd socket -# activation with systemd version >=3D 227 +# activation. # #unix_sock_dir =3D "@runstatedir@/libvirt" =20 diff --git a/src/remote/libvirtd.socket.in b/src/remote/libvirtd.socket.in index 0f349656f5..4842712648 100644 --- a/src/remote/libvirtd.socket.in +++ b/src/remote/libvirtd.socket.in @@ -4,8 +4,6 @@ Before=3D@service@.service @deps@ =20 [Socket] -# The directory must match the @sysconfdir@/libvirt/@service@.conf unix_so= ck_dir setting -# when using systemd version < 227 ListenStream=3D@runstatedir@/libvirt/@sockprefix@-sock Service=3D@service@.service SocketMode=3D@mode@ diff --git a/src/remote/remote_daemon.c b/src/remote/remote_daemon.c index 1b8e982a2f..26469e0d9f 100644 --- a/src/remote/remote_daemon.c +++ b/src/remote/remote_daemon.c @@ -214,25 +214,8 @@ daemonSetupNetworking(virNetServer *srv, unsigned int tcp_min_ssf =3D 0; #endif /* !WITH_SASL */ g_autoptr(virSystemdActivation) act =3D NULL; - virSystemdActivationMap actmap[] =3D { - { .name =3D DAEMON_NAME ".socket", .family =3D AF_UNIX, .path =3D = sock_path }, - { .name =3D DAEMON_NAME "-ro.socket", .family =3D AF_UNIX, .path = =3D sock_path_ro }, - { .name =3D DAEMON_NAME "-admin.socket", .family =3D AF_UNIX, .pat= h =3D sock_path_adm }, -#ifdef WITH_IP - { .name =3D DAEMON_NAME "-tcp.socket", .family =3D AF_INET }, - { .name =3D DAEMON_NAME "-tls.socket", .family =3D AF_INET }, -#endif /* ! WITH_IP */ - }; - -#ifdef WITH_IP - if ((actmap[3].port =3D virSocketAddrResolveService(config->tcp_port))= < 0) - return -1; - - if ((actmap[4].port =3D virSocketAddrResolveService(config->tls_port))= < 0) - return -1; -#endif /* ! WITH_IP */ =20 - if (virSystemdGetActivation(actmap, G_N_ELEMENTS(actmap), &act) < 0) + if (virSystemdGetActivation(&act) < 0) return -1; =20 #ifdef WITH_IP diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c index a86d4c6bb9..c95b6c93d3 100644 --- a/src/util/virsystemd.c +++ b/src/util/virsystemd.c @@ -788,98 +788,6 @@ virSystemdActivationInitFromNames(virSystemdActivation= *act, } =20 =20 -/* - * Back compat for systemd < v227 which lacks LISTEN_FDNAMES. - * Delete when min systemd is increased ie RHEL7 dropped - */ -static int -virSystemdActivationInitFromMap(virSystemdActivation *act, - int nfds, - virSystemdActivationMap *map, - size_t nmap) -{ - int nextfd =3D STDERR_FILENO + 1; - size_t i; - - while (nfds) { - virSocketAddr addr; - const char *name =3D NULL; - - memset(&addr, 0, sizeof(addr)); - - addr.len =3D sizeof(addr.data); - if (getsockname(nextfd, &addr.data.sa, &addr.len) < 0) { - virReportSystemError(errno, "%s", _("Unable to get local socke= t name")); - goto error; - } - - VIR_DEBUG("Got socket family %d for FD %d", - addr.data.sa.sa_family, nextfd); - - for (i =3D 0; i < nmap && !name; i++) { - if (map[i].name =3D=3D NULL) - continue; - - if (addr.data.sa.sa_family =3D=3D AF_INET) { - if (map[i].family =3D=3D AF_INET) { - VIR_DEBUG("Expect %d got %d", - map[i].port, ntohs(addr.data.inet4.sin_port)= ); - if (addr.data.inet4.sin_port =3D=3D htons(map[i].port)) - name =3D map[i].name; - } - } else if (addr.data.sa.sa_family =3D=3D AF_INET6) { - /* NB use of AF_INET here is correct. The "map" struct - * only refers to AF_INET. The socket may be AF_INET - * or AF_INET6 - */ - if (map[i].family =3D=3D AF_INET) { - VIR_DEBUG("Expect %d got %d", - map[i].port, ntohs(addr.data.inet6.sin6_port= )); - if (addr.data.inet6.sin6_port =3D=3D htons(map[i].port= )) - name =3D map[i].name; - } -#ifndef WIN32 - } else if (addr.data.sa.sa_family =3D=3D AF_UNIX) { - if (map[i].family =3D=3D AF_UNIX) { - VIR_DEBUG("Expect %s got %s", map[i].path, addr.data.u= n.sun_path); - if (STREQLEN(map[i].path, - addr.data.un.sun_path, - sizeof(addr.data.un.sun_path))) - name =3D map[i].name; - } -#endif - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected socket family %d"), - addr.data.sa.sa_family); - goto error; - } - } - - if (!name) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Cannot find name for FD %d socket family %d"= ), - nextfd, addr.data.sa.sa_family); - goto error; - } - - if (virSystemdActivationAddFD(act, name, nextfd) < 0) - goto error; - - nfds--; - nextfd++; - } - - return 0; - - error: - for (i =3D 0; i < nfds; i++) { - int fd =3D nextfd + i; - VIR_FORCE_CLOSE(fd); - } - return -1; -} - #ifndef WIN32 =20 /** @@ -954,9 +862,7 @@ virSystemdGetListenFDs(void) #endif /* WIN32 */ =20 static virSystemdActivation * -virSystemdActivationNew(virSystemdActivationMap *map, - size_t nmap, - int nfds) +virSystemdActivationNew(int nfds) { g_autoptr(virSystemdActivation) act =3D g_new0(virSystemdActivation, 1= ); const char *fdnames; @@ -966,14 +872,15 @@ virSystemdActivationNew(virSystemdActivationMap *map, act->fds =3D virHashNew(virSystemdActivationEntryFree); =20 fdnames =3D getenv("LISTEN_FDNAMES"); - if (fdnames) { - if (virSystemdActivationInitFromNames(act, nfds, fdnames) < 0) - return NULL; - } else { - if (virSystemdActivationInitFromMap(act, nfds, map, nmap) < 0) - return NULL; + if (!fdnames) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Missing LISTEN_FDNAMES env from systemd socket a= ctivation")); + return NULL; } =20 + if (virSystemdActivationInitFromNames(act, nfds, fdnames) < 0) + return NULL; + VIR_DEBUG("Created activation object for %d FDs", nfds); return g_steal_pointer(&act); } @@ -981,8 +888,6 @@ virSystemdActivationNew(virSystemdActivationMap *map, =20 /** * virSystemdGetActivation: - * @map: mapping of socket addresses to names - * @nmap: number of entries in @map * @act: filled with allocated activation object * * Acquire an object for handling systemd activation. @@ -995,9 +900,7 @@ virSystemdActivationNew(virSystemdActivationMap *map, * Returns: 0 on success, -1 on failure */ int -virSystemdGetActivation(virSystemdActivationMap *map, - size_t nmap, - virSystemdActivation **act) +virSystemdGetActivation(virSystemdActivation **act) { int nfds =3D 0; =20 @@ -1010,7 +913,7 @@ virSystemdGetActivation(virSystemdActivationMap *map, return 0; } =20 - *act =3D virSystemdActivationNew(map, nmap, nfds); + *act =3D virSystemdActivationNew(nfds); return 0; } =20 diff --git a/src/util/virsystemd.h b/src/util/virsystemd.h index 93320e40b9..19fb714132 100644 --- a/src/util/virsystemd.h +++ b/src/util/virsystemd.h @@ -25,17 +25,6 @@ =20 typedef struct _virSystemdActivation virSystemdActivation; =20 -/* - * Back compat for systemd < v227 which lacks LISTEN_FDNAMES. - * Delete when min systemd is increased ie RHEL7 dropped - */ -typedef struct _virSystemdActivationMap { - const char *name; - int family; - int port; /* if family =3D=3D AF_INET/AF_INET6 */ - const char *path; /* if family =3D=3D AF_UNIX */ -} virSystemdActivationMap; - char *virSystemdMakeScopeName(const char *name, const char *drivername, bool legacy_behaviour); @@ -70,9 +59,7 @@ char *virSystemdGetMachineNameByPID(pid_t pid); =20 char *virSystemdGetMachineUnitByPID(pid_t pid); =20 -int virSystemdGetActivation(virSystemdActivationMap *map, - size_t nmap, - virSystemdActivation **act); +int virSystemdGetActivation(virSystemdActivation **act); =20 bool virSystemdActivationHasName(virSystemdActivation *act, const char *name); diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c index 9a063dd1fc..9b513697e0 100644 --- a/tests/virsystemdtest.c +++ b/tests/virsystemdtest.c @@ -513,7 +513,7 @@ testActivationCreateFDs(virNetSocket **sockUNIX, =20 =20 static int -testActivation(bool useNames) +testActivationFDNames(const void *opaque G_GNUC_UNUSED) { virNetSocket *sockUNIX; virNetSocket **sockIP; @@ -522,7 +522,6 @@ testActivation(bool useNames) size_t i; char nfdstr[VIR_INT64_STR_BUFLEN]; char pidstr[VIR_INT64_STR_BUFLEN]; - virSystemdActivationMap map[2]; int *fds =3D NULL; size_t nfds =3D 0; g_autoptr(virSystemdActivation) act =3D NULL; @@ -544,21 +543,9 @@ testActivation(bool useNames) =20 g_setenv("LISTEN_FDS", nfdstr, TRUE); g_setenv("LISTEN_PID", pidstr, TRUE); + g_setenv("LISTEN_FDNAMES", virBufferCurrentContent(&names), TRUE); =20 - if (useNames) - g_setenv("LISTEN_FDNAMES", virBufferCurrentContent(&names), TRUE); - else - g_unsetenv("LISTEN_FDNAMES"); - - map[0].name =3D "demo-unix.socket"; - map[0].family =3D AF_UNIX; - map[0].path =3D demo_socket_path; - - map[1].name =3D "demo-ip.socket"; - map[1].family =3D AF_INET; - map[1].port =3D virNetSocketGetPort(sockIP[0]); - - if (virSystemdGetActivation(map, G_N_ELEMENTS(map), &act) < 0) + if (virSystemdGetActivation(&act) < 0) goto cleanup; =20 if (act =3D=3D NULL) { @@ -617,7 +604,7 @@ testActivationEmpty(const void *opaque G_GNUC_UNUSED) =20 g_unsetenv("LISTEN_FDS"); =20 - if (virSystemdGetActivation(NULL, 0, &act) < 0) + if (virSystemdGetActivation(&act) < 0) return -1; =20 if (act !=3D NULL) { @@ -629,21 +616,6 @@ testActivationEmpty(const void *opaque G_GNUC_UNUSED) return 0; } =20 - -static int -testActivationFDNames(const void *opaque G_GNUC_UNUSED) -{ - return testActivation(true); -} - - -static int -testActivationFDAddrs(const void *opaque G_GNUC_UNUSED) -{ - return testActivation(false); -} - - static int mymain(void) { @@ -759,8 +731,6 @@ mymain(void) fcntl(STDERR_FILENO + 3, F_GETFL) =3D=3D -1 && errno =3D=3D EBADF)= { if (virTestRun("Test activation names", testActivationFDNames, NUL= L) < 0) ret =3D -1; - if (virTestRun("Test activation addrs", testActivationFDAddrs, NUL= L) < 0) - ret =3D -1; } else { VIR_INFO("Skipping activation tests as FD 3/4/5 is open"); } --=20 2.34.1