From nobody Sat May 4 20:53:28 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 1523960980775321.2959004338736; Tue, 17 Apr 2018 03:29:40 -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 3E6018535D; Tue, 17 Apr 2018 10:29:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 12FB719E30; Tue, 17 Apr 2018 10:29:39 +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 A6CB44CA9D; Tue, 17 Apr 2018 10:29:38 +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 w3HATbx6016067 for ; Tue, 17 Apr 2018 06:29:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 411EB111DCFA; Tue, 17 Apr 2018 10:29:37 +0000 (UTC) Received: from icr.brq.redhat.com (unknown [10.43.2.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8F0A111DCF0 for ; Tue, 17 Apr 2018 10:29:34 +0000 (UTC) From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Tue, 17 Apr 2018 12:29:32 +0200 Message-Id: <7e432497709a0b2d4ea87aad55b333446d52bee6.1523960970.git.jtomko@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] tests: mock qemuInterfaceOpenVhostNet 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 17 Apr 2018 10:29:39 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 This functions contains logic that tries to use vhost for virtio interfaces, even if was not supplied. In this case, a failure is non-fatal. On my system, /dev/vhost-net was not accessible to the user running 'make check', but we should not depend on that. Mock it to prevent accessing /dev/vhost-net and return some predictable file descriptor numbers instead. Introduced by commit c1f684e - deprecate QEMU_CAPS_VHOST_NET. Signed-off-by: J=C3=A1n Tomko Reported-by: Ji=C5=99=C3=AD Denemark Reviewed-by: Martin Kletzander --- tests/qemuxml2argvdata/user-aliases.args | 2 +- tests/qemuxml2argvmock.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/qemuxml2argvdata/user-aliases.args b/tests/qemuxml2argvd= ata/user-aliases.args index d887d53fa..774c599b5 100644 --- a/tests/qemuxml2argvdata/user-aliases.args +++ b/tests/qemuxml2argvdata/user-aliases.args @@ -51,7 +51,7 @@ id=3Dua-myEncryptedDisk1 \ if=3Dnone,id=3Ddrive-ua-WhatAnAwesomeCDROM,media=3Dcdrom,readonly=3Don,cac= he=3Dnone \ -device ide-drive,bus=3Dide.1,unit=3D0,drive=3Ddrive-ua-WhatAnAwesomeCDROM= ,\ id=3Dua-WhatAnAwesomeCDROM \ --netdev tap,fd=3D3,id=3Dhostua-CheckoutThisNIC \ +-netdev tap,fd=3D3,id=3Dhostua-CheckoutThisNIC,vhost=3Don,vhostfd=3D44 \ -device virtio-net-pci,netdev=3Dhostua-CheckoutThisNIC,id=3Dua-CheckoutThi= sNIC,\ mac=3D52:54:00:d6:c0:0b,bus=3Dpci.0,addr=3D0x3 \ -netdev socket,listen=3D127.0.0.1:1234,id=3Dhostua-WeCanAlsoDoServerMode \ diff --git a/tests/qemuxml2argvmock.c b/tests/qemuxml2argvmock.c index 177b24e0a..adab5c911 100644 --- a/tests/qemuxml2argvmock.c +++ b/tests/qemuxml2argvmock.c @@ -36,6 +36,7 @@ #include "virstring.h" #include "virtpm.h" #include "virutil.h" +#include "qemu/qemu_interface.h" #include #include =20 @@ -188,3 +189,21 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *pat= h ATTRIBUTE_UNUSED, { return VIR_STRDUP(*ifname, "vhost-user0"); } + +int +qemuInterfaceOpenVhostNet(virDomainDefPtr def ATTRIBUTE_UNUSED, + virDomainNetDefPtr net, + int *vhostfd, + size_t *vhostfdSize) +{ + size_t i; + + if (!(net->model && STREQ(net->model, "virtio"))) { + *vhostfdSize =3D 0; + return 0; + } + + for (i =3D 0; i < *vhostfdSize; i++) + vhostfd[i] =3D STDERR_FILENO + 42 + i; + return 0; +} --=20 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list