From nobody Wed May 14 17:22:30 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1526917099707355.1994701168579; Mon, 21 May 2018 08:38:19 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 199272A2D36; Mon, 21 May 2018 15:38:14 +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 D3D65611C1; Mon, 21 May 2018 15:38:13 +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 9593C1801254; Mon, 21 May 2018 15:38:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4LFbcpP024129 for ; Mon, 21 May 2018 11:37:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id E340310EE6D6; Mon, 21 May 2018 15:37:37 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6AE4810EE6D5; Mon, 21 May 2018 15:37:37 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Mon, 21 May 2018 17:37:18 +0200 Message-Id: <55c7deba357dfa5922cc7659a1035226eaf74156.1526916651.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: stefanha@redhat.com Subject: [libvirt] [PATCH 8/9] Introduce virNetDevVsockSetGuestCid 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-Type: text/plain; charset="utf-8" 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 21 May 2018 15:38:14 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 A wrapper function for setting the guest cid via ioctl. Signed-off-by: J=C3=A1n Tomko --- configure.ac | 8 ++++++++ src/libvirt_private.syms | 1 + src/util/virnetdev.c | 30 ++++++++++++++++++++++++++++++ src/util/virnetdev.h | 4 ++++ 4 files changed, 43 insertions(+) diff --git a/configure.ac b/configure.ac index cc005ea9e8..b869a17afe 100644 --- a/configure.ac +++ b/configure.ac @@ -641,6 +641,14 @@ if test "$with_linux" =3D "yes"; then [[#include ]]) fi =20 +dnl +dnl check for VHOST_VSOCK_SET_GUEST_CID +dnl +if test "$with_linux" =3D "yes"; then + AC_CHECK_DECLS([VHOST_VSOCK_SET_GUEST_CID], [], [], + [[#include ]]) +fi + dnl Allow perl/python overrides AC_PATH_PROGS([PYTHON], [python3 python2 python]) if test -z "$PYTHON"; then diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b4c86b60cc..204ac3806a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2287,6 +2287,7 @@ virNetDevSetRcvMulti; virNetDevSetupControl; virNetDevSysfsFile; virNetDevValidateConfig; +virNetDevVsockSetGuestCid; =20 =20 # util/virnetdevbandwidth.h diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index b250af9e2c..6ac2080821 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -50,6 +50,10 @@ # undef HAVE_STRUCT_IFREQ #endif =20 +#if HAVE_DECL_VHOST_VSOCK_SET_GUEST_CID +# include +#endif + #if defined(SIOCETHTOOL) && defined(HAVE_STRUCT_IFREQ) # include # include @@ -3605,3 +3609,29 @@ virNetDevRunEthernetScript(const char *ifname, const= char *script) virCommandFree(cmd); return ret; } + +#if HAVE_DECL_VHOST_VSOCK_SET_GUEST_CID +int +virNetDevVsockSetGuestCid(int fd, + unsigned int guest_cid) +{ + uint64_t val =3D guest_cid; + + if (ioctl(fd, VHOST_VSOCK_SET_GUEST_CID, &val) < 0) { + virReportSystemError(errno, "%s", + _("failed to set guest cid")); + return -1; + } + + return 0; +} +#else +int +virNetDevVsockSetGuestCid(int fd ATTRIBUTE_UNUSED, + unsigned int guest_cid ATTRIBUTE_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("vsock is not supported")); + return -1; +} +#endif diff --git a/src/util/virnetdev.h b/src/util/virnetdev.h index 71eaf45e30..836603b65d 100644 --- a/src/util/virnetdev.h +++ b/src/util/virnetdev.h @@ -313,4 +313,8 @@ int virNetDevSysfsFile(char **pf_sysfs_device_link, =20 int virNetDevRunEthernetScript(const char *ifname, const char *script) ATTRIBUTE_NOINLINE; + +int +virNetDevVsockSetGuestCid(int fd, + unsigned int guest_cid); #endif /* __VIR_NETDEV_H__ */ --=20 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list