From nobody Fri May 3 05:28:48 2024 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 1523957424430454.8390284060939; Tue, 17 Apr 2018 02:30:24 -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 19F3962B; Tue, 17 Apr 2018 09:30:22 +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 0861217C5F; Tue, 17 Apr 2018 09:30:21 +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 61516180215E; Tue, 17 Apr 2018 09:30:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3H9UEph002845 for ; Tue, 17 Apr 2018 05:30:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9D40E2166BC7; Tue, 17 Apr 2018 09:30:14 +0000 (UTC) Received: from caroline.localdomain (unknown [10.43.2.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7C2592166BAE for ; Tue, 17 Apr 2018 09:30:14 +0000 (UTC) Received: from caroline.brq.redhat.com (caroline.usersys.redhat.com [127.0.0.1]) by caroline.localdomain (Postfix) with ESMTP id 6FCDD12001F for ; Tue, 17 Apr 2018 11:30:13 +0200 (CEST) From: Martin Kletzander To: libvir-list@redhat.com Date: Tue, 17 Apr 2018 11:30:06 +0200 Message-Id: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] tests: Don't touch /dev/vhost-net in qemuxml2argvtest 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: , MIME-Version: 1.0 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.29]); Tue, 17 Apr 2018 09:30:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The code is trying to open /dev/vhost-net from the host machine and if the current user has access to it, the command line will end up having two more options for an interface (,vhost=3Don,vhostfd=3DX where X is next free file descriptor). Signed-off-by: Martin Kletzander Reviewed-by: Jiri Denemark --- tests/qemuxml2argvmock.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 177b24e0a953..11626e2794c1 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -20,6 +20,10 @@ =20 #include =20 +#include +#include +#include + #include "internal.h" #include "viralloc.h" #include "vircommand.h" @@ -188,3 +192,35 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *pat= h ATTRIBUTE_UNUSED, { return VIR_STRDUP(*ifname, "vhost-user0"); } + +static int (*real_open)(const char *path, int flags, ...); + +static void init_syms(void) +{ + if (real_open) + return; + + VIR_MOCK_REAL_INIT(open); +} + +int open(const char *path, int flags, ...) +{ + va_list ap; + mode_t mode =3D 0; + + init_syms(); + + if (STREQ(path, "/dev/vhost-net")) + return -1; + + /* The mode argument is mandatory when O_CREAT is set in flags, + * otherwise the argument is ignored. + */ + if (flags & O_CREAT) { + va_start(ap, flags); + mode =3D (mode_t) va_arg(ap, int); + va_end(ap); + } + + return real_open(path, flags, mode); +} --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list